diff --git a/src/tmltranslator/TMLCPLib.java b/src/tmltranslator/TMLCPLib.java index b9531eff9b7f05590f288d71a3241e74bf7e30a2..6d4363cf5b61e5f5a068a8cc1f5cd02df446b348 100755 --- a/src/tmltranslator/TMLCPLib.java +++ b/src/tmltranslator/TMLCPLib.java @@ -56,6 +56,7 @@ public class TMLCPLib extends TMLElement { private Vector<String> mappedUnits = new Vector<String>(); private CPMEC cpMEC; private String typeName; + private Vector<String> assignedAttributes; public TMLCPLib(String _name, String _typeName, Object _referenceObject, CPMEC _cpMEC ) { @@ -70,8 +71,8 @@ public class TMLCPLib extends TMLElement { init(); } - public void setMappedUnits(Vector<String> _mappedUnits) { - mappedUnits = _mappedUnits; + public void setMappedUnits( Vector<String> _mappedUnits ) { + mappedUnits = _mappedUnits; } private void init() { @@ -119,4 +120,12 @@ public class TMLCPLib extends TMLElement { public CPMEC getCPMEC() { return cpMEC; } + + public void setAssignedAttributes( Vector<String> _assignedAttributes ) { + assignedAttributes = _assignedAttributes; + } + + public Vector<String> getAssignedAttributes() { + return assignedAttributes; + } } //End of the class diff --git a/src/tmltranslator/ctranslator/CPMEC.java b/src/tmltranslator/ctranslator/CPMEC.java index e7722de161cc772ae7541fa8ffd2a125e2bab7e4..75fd80a0d1fe5c3d4e10d56c65f46371a7c4b3ae 100755 --- a/src/tmltranslator/ctranslator/CPMEC.java +++ b/src/tmltranslator/ctranslator/CPMEC.java @@ -67,6 +67,9 @@ public abstract class CPMEC { public String cleanup_code = new String(); public static final String[] cpTypes = { "Memory Copy", "Single DMA", "Double DMA" }; + public static final String SingleDMA = "Single DMA"; + public static final String DoubleDMA = "Double DMA"; + public static final String MemoryCopy = "Memory Copy"; public CPMEC() { node_type = "1"; diff --git a/src/tmltranslator/ctranslator/DoubleDmaMEC.java b/src/tmltranslator/ctranslator/DoubleDmaMEC.java index bd96abef498f50c7aba8694bb7ec028e53a9f1ce..997351c6564609df27fa22ea9e4b639dccd64732 100755 --- a/src/tmltranslator/ctranslator/DoubleDmaMEC.java +++ b/src/tmltranslator/ctranslator/DoubleDmaMEC.java @@ -53,6 +53,33 @@ public class DoubleDmaMEC extends CPMEC { public static final String Context = "embb_dma_context"; public static final String Ctx_cleanup = "dma_ctx_cleanup"; + public static final int MaxParameters = 12; + public static final int destinationAddress1Index = 0; + public static final int sourceAddress1Index = 1; + public static final int size1Index = 2; + public static final int counter1Index = 3; + public static final int ID1Index = 4; + public static final int bytesToTransfer1Index = 5; + public static final int destinationAddress2Index = 6; + public static final int sourceAddress2Index = 7; + public static final int size2Index = 8; + public static final int counter2Index = 9; + public static final int ID12Index = 10; + public static final int bytesToTransfer2Index = 11; + + public static final String destinationAddress1 = "destinationAddress1"; + public static final String sourceAddress1 = "sourceAddress1"; + public static final String size1 = "size1"; + public static final String counter1 = "counter1"; + public static final String ID1 = "ID1"; + public static final String bytesToTransfer1 = "bytesToTransfer1"; + public static final String destinationAddress2 = "destinationAddress2"; + public static final String sourceAddress2 = "sourceAddress2"; + public static final String size2 = "size2"; + public static final String counter2 = "counter2"; + public static final String ID12 = "ID12"; + public static final String bytesToTransfer2 = "bytesToTransfer2"; + public DoubleDmaMEC( String ctxName ) { node_type = "DoubleDmaMEC"; @@ -65,4 +92,18 @@ public class DoubleDmaMEC extends CPMEC { cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName + ");"; } + public DoubleDmaMEC( String ctxName, String destinationAddress1, String sourceAddress1, String size1, String destinationAddress2, String sourceAddress2, String size2 ) { + + node_type = "DoubleDmaMEC"; + inst_type = "VOID"; + inst_decl = "EMBB_DMA_CONTEXT"; + buff_type = "MM_BUFF_TYPE"; + buff_init = "VOID"; + exec_code = TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress1 + ", (uintptr_t) " + destinationAddress1 + ", (size_t) " + size1 + " );" + CR; + exec_code += TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress2 + ", (uintptr_t) " + destinationAddress2 + ", (size_t) " + size2 + " );" + CR; + init_code = TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, /*USER TO DO: SRC_DEV*/ );" + CR; + init_code += TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, /*USER TO DO: SRC_DEV*/ );" + CR; + cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName + ");"; + } + } //End of class diff --git a/src/tmltranslator/ctranslator/SingleDmaMEC.java b/src/tmltranslator/ctranslator/SingleDmaMEC.java index 79a221dc326ba663e569546c542a0ad4053fcadd..aecd0678c947c4c366c17c58c7122d56a22e8114 100755 --- a/src/tmltranslator/ctranslator/SingleDmaMEC.java +++ b/src/tmltranslator/ctranslator/SingleDmaMEC.java @@ -53,6 +53,21 @@ public class SingleDmaMEC extends CPMEC { public static final String Context = "embb_dma_context"; public static final String Ctx_cleanup = "dma_ctx_cleanup"; + public static final int MaxParameters = 6; + public static final int destinationAddressIndex = 0; + public static final int sourceAddressIndex = 1; + public static final int sizeIndex = 2; + public static final int counterIndex = 3; + public static final int ID1Index = 4; + public static final int bytesToTransferIndex = 5; + + public static final String destinationAddress = "destinationAddress"; + public static final String sourceAddress = "sourceAddress"; + public static final String size = "size"; + public static final String counter = "counter"; + public static final String ID1 = "ID1"; + public static final String bytesToTransfer = "bytesToTransfer"; + public SingleDmaMEC( String ctxName ) { node_type = "SingleDmaMEC"; @@ -64,5 +79,17 @@ public class SingleDmaMEC extends CPMEC { init_code = TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, /*USER TO DO: SRC_DEV*/ );" + CR; cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName +");"; } + + public SingleDmaMEC( String ctxName, String destinationAddress, String sourceAddress, String size ) { + + node_type = "SingleDmaMEC"; + inst_type = "VOID"; + inst_decl = "EMBB_DMA_CONTEXT"; + buff_type = "MM_BUFF_TYPE"; + buff_init = "VOID"; + exec_code = TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) " + sourceAddress + ", (uintptr_t) " + destinationAddress + ", (size_t) " + size + " );" + CR; + init_code = TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, /*USER TO DO: SRC_DEV*/ );" + CR; + cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName +");"; + } } //End of class diff --git a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java index b52c4e4e6040f6e951bcba41e23dbfcba6621b40..b25f206ff8dfa01a2a3c593036f552c73b701d06 100755 --- a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java +++ b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java @@ -1027,13 +1027,15 @@ public class TMLCCodeGeneration { private void generateCodeForCommunicationPatterns() { - String s; + String s, destinationAddress, sourceAddress, size, destinationAddress1, sourceAddress1, size1, destinationAddress2, sourceAddress2, size2; TMLCPLib tmlcplib; String ctxName; + Vector<String> attributes; for( DataTransfer dt: dataTransfersList ) { tmlcplib = dt.getTMLCPLib(); ctxName = dt.getContextName(); + attributes = tmlcplib.getAssignedAttributes(); String name = tmlcplib.getName().split("::")[0]; programString.append( "int op_" + name + "()\t{" + CR ); @@ -1041,16 +1043,28 @@ public class TMLCCodeGeneration { programString.append( TAB + "sig[ " + sig.getName() + " ].f = false;" + CR ); } CPMEC cpMEC = tmlcplib.getCPMEC(); + TraceManager.addDev( "CPMEC: " + cpMEC + "\n" + attributes.toString() ); if( cpMEC instanceof CpuMemoryCopyMEC ) { CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( ctxName ); programString.append( mec.getExecCode() ); } if( cpMEC instanceof SingleDmaMEC ) { - SingleDmaMEC mec = new SingleDmaMEC( ctxName ); + destinationAddress = attributes.get( SingleDmaMEC.destinationAddressIndex ); + sourceAddress = attributes.get( SingleDmaMEC.sourceAddressIndex ); + size = attributes.get( SingleDmaMEC.sizeIndex ); + SingleDmaMEC mec = new SingleDmaMEC( ctxName, destinationAddress, sourceAddress, size ); + //SingleDmaMEC mec = new SingleDmaMEC( ctxName ); programString.append( mec.getExecCode() ); } if( cpMEC instanceof DoubleDmaMEC ) { - DoubleDmaMEC mec = new DoubleDmaMEC( ctxName ); + destinationAddress1 = attributes.get( DoubleDmaMEC.destinationAddress1Index ); + sourceAddress1 = attributes.get( DoubleDmaMEC.sourceAddress1Index ); + size1 = attributes.get( DoubleDmaMEC.size1Index ); + destinationAddress2 = attributes.get( DoubleDmaMEC.destinationAddress2Index ); + sourceAddress2 = attributes.get( DoubleDmaMEC.sourceAddress2Index ); + size2 = attributes.get( DoubleDmaMEC.size2Index ); + DoubleDmaMEC mec = new DoubleDmaMEC( ctxName, destinationAddress1, sourceAddress1, size1, destinationAddress2, sourceAddress2, size2 ); + //DoubleDmaMEC mec = new DoubleDmaMEC( ctxName ); programString.append( mec.getExecCode() ); } diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java index 8f50f546e9c6b29553c5f402041f2cd24a67476c..5d8a006c88b6f0113a65a7e178b3b2df68f9743c 100755 --- a/src/ui/GTMLModeling.java +++ b/src/ui/GTMLModeling.java @@ -2910,9 +2910,10 @@ public class GTMLModeling { //TraceManager.addDev("---------------- tgc=" + tgc); if (tgc instanceof TMLArchiCPNode) { cp = (TMLArchiCPNode)tgc; - TMLCPLib tmlcplib = new TMLCPLib( cp.getCompleteName(), cp.getReference(), tgc, cp.getCPMEC()); + TMLCPLib tmlcplib = new TMLCPLib( cp.getCompleteName(), cp.getReference(), tgc, cp.getCPMEC() ); map.addTMLCPLib(tmlcplib); tmlcplib.setMappedUnits(cp.getMappedUnits()); + tmlcplib.setAssignedAttributes( cp.getAssignedAttributes() ); // Handling mapped artifacts for (TMLArchiPortArtifact artifact: cp.getPortArtifactList()) { diff --git a/src/ui/tmldd/TMLArchiCPNode.java b/src/ui/tmldd/TMLArchiCPNode.java index 96ea216448d40abcb63151ec390abb119aaac13e..7c272aa4ed08b5ba79a4bbece3ec405dd4b042ce 100755 --- a/src/ui/tmldd/TMLArchiCPNode.java +++ b/src/ui/tmldd/TMLArchiCPNode.java @@ -401,4 +401,102 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow public String getCompleteName() { return completeName; } + + public Vector<String> getAssignedAttributes() { + + //attributes must first be parsed and assigned to the correct position within array, in order to be correctly retrieved + Vector<String> vectorToReturn; + switch( cpMEC ) { + case CPMEC.MemoryCopy: + TraceManager.addDev( "Returning assignedAttributes as memory copy" ); + vectorToReturn = assignedAttributes; + break; + case CPMEC.SingleDMA: + vectorToReturn = sortAttributesForSingleDMA(); + break; + case CPMEC.DoubleDMA: + vectorToReturn = sortAttributesForDoubleDMA(); + break; + default: + TraceManager.addDev( "ERROR in returning assignedAttributes" ); + vectorToReturn = assignedAttributes; + break; + } + return vectorToReturn; + } + + private Vector<String> sortAttributesForSingleDMA() { + + Vector<String> newVector = new Vector<String>( assignedAttributes ); + for( String s: assignedAttributes ) { + if( s.contains( SingleDmaMEC.destinationAddress ) ) { + newVector.set( SingleDmaMEC.destinationAddressIndex, getAttributeValue(s) ); + } + if( s.contains( SingleDmaMEC.sourceAddress ) ) { + newVector.set( SingleDmaMEC.sourceAddressIndex, getAttributeValue(s) ); + } + if( s.contains( SingleDmaMEC.size ) ) { + newVector.set( SingleDmaMEC.sizeIndex, getAttributeValue(s) ); + } + if( s.contains( SingleDmaMEC.counter ) ) { + newVector.set( SingleDmaMEC.counterIndex, getAttributeValue(s) ); + } + if( s.contains( SingleDmaMEC.ID1 ) ) { + newVector.set( SingleDmaMEC.ID1Index, getAttributeValue(s) ); + } + if( s.contains( SingleDmaMEC.bytesToTransfer ) ) { + newVector.set( SingleDmaMEC.bytesToTransferIndex, getAttributeValue(s) ); + } + } + return newVector; + } + + private Vector<String> sortAttributesForDoubleDMA() { + + Vector<String> newVector = new Vector<String>( assignedAttributes ); + for( String s: assignedAttributes ) { + if( s.contains( DoubleDmaMEC.destinationAddress1 ) ) { + newVector.set( DoubleDmaMEC.destinationAddress1Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.sourceAddress1 ) ) { + newVector.set( DoubleDmaMEC.sourceAddress1Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.size1 ) ) { + newVector.set( DoubleDmaMEC.size1Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.counter1 ) ) { + newVector.set( DoubleDmaMEC.counter1Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.ID1 ) ) { + newVector.set( DoubleDmaMEC.ID1Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.bytesToTransfer1 ) ) { + newVector.set( DoubleDmaMEC.bytesToTransfer1Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.destinationAddress2 ) ) { + newVector.set( DoubleDmaMEC.destinationAddress2Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.sourceAddress2 ) ) { + newVector.set( DoubleDmaMEC.sourceAddress2Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.size2 ) ) { + newVector.set( DoubleDmaMEC.size2Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.counter2 ) ) { + newVector.set( DoubleDmaMEC.counter2Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.ID12 ) ) { + newVector.set( DoubleDmaMEC.ID12Index, getAttributeValue(s) ); + } + if( s.contains( DoubleDmaMEC.bytesToTransfer2 ) ) { + newVector.set( DoubleDmaMEC.bytesToTransfer2Index, getAttributeValue(s) ); + } + } + return newVector; + } + + private String getAttributeValue( String assignement ) { + String s = assignement.split(" = ")[1]; + return s.substring(0, s.length()-1); //remove trailing semi-colon + } } diff --git a/src/ui/tmlsd/TGConnectorMessageTMLSD.java b/src/ui/tmlsd/TGConnectorMessageTMLSD.java index 41b197e6d405803e4fe4e151bfc9cbafd7c3f2a3..d873a1110d3bbb8ca8dedabee96f42ba908251ac 100755 --- a/src/ui/tmlsd/TGConnectorMessageTMLSD.java +++ b/src/ui/tmlsd/TGConnectorMessageTMLSD.java @@ -148,7 +148,7 @@ public abstract class TGConnectorMessageTMLSD extends TGConnector { values[i+1] = params[i]; } - JDialogMultiString jdms = new JDialogMultiString( frame, "Setting message properties", nParam+1, labels, values ); + JDialogMultiStringCP jdms = new JDialogMultiStringCP( frame, "Setting message properties", nParam+1, labels, values ); jdms.setSize( 350, 300 ); GraphicLib.centerOnParent(jdms); jdms.show(); // blocked until dialog has been closed diff --git a/src/ui/window/JDialogReferenceCP.java b/src/ui/window/JDialogReferenceCP.java index 5d86755a96941436ba80a05e7d1768928ba0e303..98b6f49d61ad245d858b6c3bb1913a04e3756a5f 100644 --- a/src/ui/window/JDialogReferenceCP.java +++ b/src/ui/window/JDialogReferenceCP.java @@ -1039,6 +1039,10 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis cancelled = false; name = nameOfCP.getText(); cpMEC = (String)cpMECsCB.getSelectedItem(); + if( attributesVector.size() > 0 ) { //there are still parameters which must be assigned a value + JOptionPane.showMessageDialog( frame, "Please assign a value to all attributes", "Error", JOptionPane.INFORMATION_MESSAGE ); + return; + } dispose(); } @@ -1277,17 +1281,19 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis ArrayList<Integer> indexList = new ArrayList<Integer>(); for( String s: assignedAttributes ) { String token = s.split( " = " )[0]; - if( attributesVector.contains( token ) ) { - indexList.add( attributesVector.indexOf( token ) ); + for( Iterator<String> iterator = attributesVector.iterator(); iterator.hasNext(); ) { + String s1 = iterator.next(); + if( token.equals( s1 ) ) { + iterator.remove(); + } } } - for( Integer index: indexList ) { - attributesVector.remove( (int)index ); - } } public Vector<String> getAssignedAttributes() { + //before returning attributes I should sort them according to the cpMEC return assignedAttributes; } + } //End of class