diff --git a/src/tmltranslator/ctranslator/CpuMemoryCopyMEC.java b/src/tmltranslator/ctranslator/CpuMemoryCopyMEC.java index 545b168c453df64506dde5eaa7a34943d60fd17e..33c4356b990b68848d3928dad65c7ce6b86fdacd 100644 --- a/src/tmltranslator/ctranslator/CpuMemoryCopyMEC.java +++ b/src/tmltranslator/ctranslator/CpuMemoryCopyMEC.java @@ -48,6 +48,7 @@ package tmltranslator.ctranslator;; import java.util.*; +import myutil.*; public class CpuMemoryCopyMEC extends CPMEC { @@ -61,17 +62,25 @@ public class CpuMemoryCopyMEC extends CPMEC { public static final String counter = "samplesToLoad"; private String memoryBaseAddress = "embb_mss"; + private String srcAddress = USER_TO_DO; + private String dataToTransfer = USER_TO_DO; + + public CpuMemoryCopyMEC( String ctxName, Vector<String> attributes ) { + + CpuMEC cpu = new CpuMEC(); + if( attributes.size() > 0 ) { + srcAddress = attributes.get( sourceAddressIndex ); + dataToTransfer = attributes.get( counterIndex ); + // apparently there is no need to use destinationAddress + } - public CpuMemoryCopyMEC( String ctxName, ArchUnitMEC archMEC, String sizeString ) { - - exec_code = TAB + "embb_mem2ip((EMBB_CONTEXT *)&" + ctxName + ", (uintptr_t) " + memoryBaseAddress + ", /*USER TODO: *SRC */, " + sizeString + " );" + CR; - init_code = TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName + ", " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR; - cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName +");"; + exec_code = TAB + "embb_mem2ip((EMBB_CONTEXT *)&" + ctxName + ", (uintptr_t) " + memoryBaseAddress + ", " + srcAddress + ", " + dataToTransfer + " );" + CR; + init_code = TAB + cpu.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName + ", " + "(uintptr_t) " + cpu.getLocalMemoryPointer() + " );" + CR; + cleanup_code = TAB + cpu.getCtxCleanupCode() + "(&" + ctxName +");"; } public static Vector<String> sortAttributes( Vector<String> assignedAttributes ) { - //Vector<String> newVector = new Vector<String>( assignedAttributes ); Vector<String> newVector = new Vector<String>(); //temporary manual workaround newVector.add("0"); diff --git a/src/tmltranslator/ctranslator/DoubleDmaMEC.java b/src/tmltranslator/ctranslator/DoubleDmaMEC.java index 8a877aba590789c6be24d1da1d4aa3af6a9111e3..ffeb3cbc7217719cbcb4f27694638bd34f1e0c07 100755 --- a/src/tmltranslator/ctranslator/DoubleDmaMEC.java +++ b/src/tmltranslator/ctranslator/DoubleDmaMEC.java @@ -47,6 +47,7 @@ package tmltranslator.ctranslator;; import java.util.*; +import myutil.*; public class DoubleDmaMEC extends CPMEC { @@ -65,7 +66,7 @@ public class DoubleDmaMEC extends CPMEC { public static final String sourceAddress2 = "sourceAddress2"; public static final String counter2 = "counter2"; - private String memoryBaseAddress = "0"; + private Vector<String> memoryBaseAddress = new Vector<String>(); private String dataToTransfer1 = USER_TO_DO; private String dataToTransfer2 = USER_TO_DO; private String dstAddress1 = USER_TO_DO; @@ -77,29 +78,36 @@ public class DoubleDmaMEC extends CPMEC { private String ctxName1 = USER_TO_DO; private String ctxName2 = USER_TO_DO; - public DoubleDmaMEC( String ctxName, ArchUnitMEC archMEC, int srcMemoryType, int dstMemoryType, ArrayList<Integer> transferTypes, Vector<String> attributes ) { + public DoubleDmaMEC( String ctxName, Vector<ArchUnitMEC> archMECs, Vector<Integer> srcMemoryTypes, Vector<Integer> dstMemoryTypes, ArrayList<Integer> transferTypes, Vector<String> attributes ) { - switch( srcMemoryType ) { - case Buffer.FepBuffer: - memoryBaseAddress = "fep_mss"; + int numSrcMemories = srcMemoryTypes.size(); + + for( int i = 0; i < numSrcMemories; i++ ) { + switch( srcMemoryTypes.get(i).intValue() ) { + case Buffer.FepBuffer: + memoryBaseAddress.add( "fep_mss" ); + break; + case Buffer.AdaifBuffer: + memoryBaseAddress.add( "adaif_mss" ); break; - case Buffer.AdaifBuffer: - memoryBaseAddress = "adaif_mss"; - break; - case Buffer.InterleaverBuffer: - memoryBaseAddress = "intl_mss"; - break; - case Buffer.MapperBuffer: - memoryBaseAddress = "mapper_mss"; - break; - case Buffer.MainMemoryBuffer: - memoryBaseAddress = "0"; - break; - default: - memoryBaseAddress = "0"; - break; + case Buffer.InterleaverBuffer: + memoryBaseAddress.add( "intl_mss" ); + break; + case Buffer.MapperBuffer: + memoryBaseAddress.add( "mapper_mss" ); + break; + case Buffer.MainMemoryBuffer: + memoryBaseAddress.add( "0" ); + break; + default: + memoryBaseAddress.add( "0" ); + break; + } } + int dstMemoryType = dstMemoryTypes.get(0).intValue(); + ArchUnitMEC archMEC = archMECs.get(0); + if( attributes.size() > 0 ) { dataToTransfer1 = attributes.get( counter1Index ); dataToTransfer2 = attributes.get( counter2Index ); @@ -111,28 +119,40 @@ public class DoubleDmaMEC extends CPMEC { ctxName2 = ctxName + "_2"; } + // build the code for the first transfer type switch( transferTypes.get(0) ) { case CPMEC.mem2IP: - exec_code = TAB + "embb_mem2ip((EMBB_CONTEXT *)&" + ctxName1 + ", (uintptr_t) " + memoryBaseAddress1 + ", " + srcAddress1 + dataToTransfer1 + " );" + CR; - exec_code += TAB + "embb_mem2ip((EMBB_CONTEXT *)&" + ctxName2 + ", (uintptr_t) " + memoryBaseAddress2 + ", " + srcAddress2 + dataToTransfer2 + " );" + CR; - init_code = TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName1 + ", " + "(uintptr_t) " + memoryBaseAddress1 + " );" + CR; - init_code += TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName2 + ", " + "(uintptr_t) " + memoryBaseAddress2 + " );" + CR; + exec_code = TAB + "embb_mem2ip((EMBB_CONTEXT *)&" + ctxName1 + ", (uintptr_t) " + memoryBaseAddress.get(0) + ", " + srcAddress1 + ", " + dataToTransfer1 + " );" + CR; + init_code = TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName1 + ", " + "(uintptr_t) " + memoryBaseAddress.get(0) + " );" + CR; cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName1 + ");" + CR; - cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName2 + ");"; break; case CPMEC.IP2mem: - exec_code = TAB + "embb_ip2mem( " + dstAddress1 + ", (EMBB_CONTEXT *)&" + ctxName1 + ", (uintptr_t) " + memoryBaseAddress1 + ", " + dataToTransfer1 + " );" + CR; - exec_code += TAB + "embb_ip2mem( " + dstAddress2 + ", (EMBB_CONTEXT *)&" + ctxName2 + ", (uintptr_t) " + memoryBaseAddress2 + ", " + dataToTransfer2 + " );" + CR; - init_code = TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName1 + ", " + "(uintptr_t) " + memoryBaseAddress1 + " );" + CR; - init_code += TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName2 + ", " + "(uintptr_t) " + memoryBaseAddress2 + " );" + CR; - cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName + ");"; + exec_code = TAB + "embb_ip2mem( " + dstAddress1 + ", (EMBB_CONTEXT *)&" + ctxName1 + ", (uintptr_t) " + memoryBaseAddress.get(0) + ", " + dataToTransfer1 + " );" + CR; + init_code = TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName1 + ", " + "(uintptr_t) " + memoryBaseAddress.get(0) + " );" + CR; + cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName1 + ");"; break; case CPMEC.IP2IP: - exec_code = TAB + "embb_ip2ip((EMBB_CONTEXT *)&" + ctxName1 + ", (uintptr_t) " + memoryBaseAddress1 + ", (EMBB_CONTEXT *)&" + ctxName1 + ", (uintptr_t) " + memoryBaseAddress1 + ", " + dataToTransfer1 + " );" + CR; - exec_code += TAB + "embb_ip2ip((EMBB_CONTEXT *)&" + ctxName2 + ", (uintptr_t) " + memoryBaseAddress2 + ", (EMBB_CONTEXT *)&" + ctxName2 + ", (uintptr_t) " + memoryBaseAddress2 + ", " + dataToTransfer1 + " );" + CR; - init_code = TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName1 + "(uintptr_t) " + memoryBaseAddress1 + " );" + CR; - init_code += TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName2 + "(uintptr_t) " + memoryBaseAddress2 + " );" + CR; + exec_code = TAB + "embb_ip2ip((EMBB_CONTEXT *)&" + ctxName1 + ", (uintptr_t) " + memoryBaseAddress.get(0) + ", (EMBB_CONTEXT *)&" + ctxName1 + ", (uintptr_t) " + memoryBaseAddress.get(1) + ", " + dataToTransfer1 + " );" + CR; + init_code = TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName1 + "(uintptr_t) " + memoryBaseAddress.get(0) + " );" + CR; cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName1 + ");" + CR; + break; + } + + // build the code for the second transfer type + switch( transferTypes.get(1) ) { + case CPMEC.mem2IP: + exec_code += TAB + "embb_mem2ip((EMBB_CONTEXT *)&" + ctxName2 + ", (uintptr_t) " + memoryBaseAddress.get(1) + ", " + srcAddress2 + ", " + dataToTransfer2 + " );" + CR; + init_code += TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName2 + ", " + "(uintptr_t) " + memoryBaseAddress.get(1) + " );" + CR; + cleanup_code += TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName2 + ");"; + break; + case CPMEC.IP2mem: + exec_code += TAB + "embb_ip2mem( " + dstAddress2 + ", (EMBB_CONTEXT *)&" + ctxName2 + ", (uintptr_t) " + memoryBaseAddress.get(1) + ", " + dataToTransfer2 + " );" + CR; + init_code += TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName2 + ", " + "(uintptr_t) " + memoryBaseAddress.get(1) + " );" + CR; + cleanup_code += TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName2 + ");"; + break; + case CPMEC.IP2IP: + exec_code += TAB + "embb_ip2ip((EMBB_CONTEXT *)&" + ctxName2 + ", (uintptr_t) " + memoryBaseAddress.get(0) + ", (EMBB_CONTEXT *)&" + ctxName2 + ", (uintptr_t) " + memoryBaseAddress.get(1) + ", " + dataToTransfer1 + " );" + CR; + init_code += TAB + archMEC.getCtxInitCode() + "((EMBB_CONTEXT *)&" + ctxName2 + "(uintptr_t) " + memoryBaseAddress.get(1) + " );" + CR; cleanup_code += TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName2 + ");"; break; } diff --git a/src/tmltranslator/ctranslator/SingleDmaMEC.java b/src/tmltranslator/ctranslator/SingleDmaMEC.java index 5cdc856885fd22b7c7115d6b963499a33af8d390..14b6a3c2f5543c2f3944e9dd8b4163d7e4f070c9 100755 --- a/src/tmltranslator/ctranslator/SingleDmaMEC.java +++ b/src/tmltranslator/ctranslator/SingleDmaMEC.java @@ -93,11 +93,6 @@ public class SingleDmaMEC extends CPMEC { srcAddress = attributes.get( sourceAddressIndex ); dstAddress = attributes.get( destinationAddressIndex ); } - else { - dataToTransfer = USER_TO_DO; - srcAddress = USER_TO_DO; - dstAddress = USER_TO_DO; - } switch( transferType ) { case CPMEC.mem2IP: diff --git a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java index c21388568c088cf652fd5e0ed5e2323f8de6f99a..68cd30d21e06602fa3225add707e18e94c9b1f22 100755 --- a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java +++ b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java @@ -1118,13 +1118,12 @@ public class TMLCCodeGeneration { programString.append( TAB + "sig[ " + sig.getName() + " ].f = false;" + CR ); } int cpMECType = tmlcplib.getCPMECType(); + Vector<String> mecAttributes = tmlcplib.getAssignedAttributes(); if( cpMECType == CPMEC.CpuMemoryCopyMEC ) { - counter = (attributes.size() == 0 ) ? "/* USER TODO */" : attributes.get( CpuMemoryCopyMEC.counterIndex ); - CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( ctxName, new CpuMEC(), counter ); //mem2ip + CpuMemoryCopyMEC mec = new CpuMemoryCopyMEC( ctxName, mecAttributes ); //mem2ip programString.append( mec.getExecCode() ); } if( cpMECType == CPMEC.SingleDmaMEC ) { - int transferType = tmlcplib.getTransferTypes().get(0); for( String s1: tmlcplib.getMappedUnits() ) { if( s1.contains( CPMEC.dmaController ) ) { String dmaUnit = s1.split(":")[1].replaceAll("\\s+",""); @@ -1139,7 +1138,7 @@ public class TMLCCodeGeneration { dstMemoryType = tmla.getHwMemoryByName( memoryUnit ).BufferType; } } - SingleDmaMEC mec = new SingleDmaMEC( ctxName, dmaArchMEC, srcMemoryType, dstMemoryType, transferType, attributes ); + SingleDmaMEC mec = new SingleDmaMEC( ctxName, dmaArchMEC, srcMemoryType, dstMemoryType, tmlcplib.getTransferTypes().get(0), attributes ); programString.append( mec.getExecCode() ); } if( cpMECType == CPMEC.DoubleDmaMEC ) { @@ -1148,28 +1147,41 @@ public class TMLCCodeGeneration { Vector<Integer> srcMemoryTypes = new Vector<Integer>(); Vector<Integer> dstMemoryTypes = new Vector<Integer>(); Vector<ArchUnitMEC> dmaArchMECs = new Vector<ArchUnitMEC>(); - int iDma = 0; - int iSrc = 0; - int iDst = 0; - int iteration = 1; // fixing compilation + int iDma = 1; + int iSrc = 1; + int iDst = 1; +// int iteration = 1; // fixing compilation for( String s1: tmlcplib.getMappedUnits() ) { //there are two DMA_controllers - if( s1.contains( CPMEC.dmaController + "_" + String.valueOf(iteration) ) ) { + /*TraceManager.addDev( "Comparing " + s1 + " with " + CPMEC.dmaController + "_" + String.valueOf(iDma) ); + TraceManager.addDev( "Comparing " + s1 + " with " + CPMEC.sourceStorage + "_" + String.valueOf(iSrc) ); + TraceManager.addDev( "Comparing " + s1 + " with " + CPMEC.destinationStorage + "_" + String.valueOf(iDst) );*/ + if( s1.contains( CPMEC.dmaController + "_" + String.valueOf(iDma) ) ) { String dmaUnit = s1.split(":")[1].replaceAll("\\s+",""); - dmaArchMECs.set( iDma, tmla.getHwCPUByName( dmaUnit ).MEC ); + dmaArchMECs.add( iDma-1, tmla.getHwCPUByName( dmaUnit ).MEC ); iDma++; } - if( s1.contains( CPMEC.sourceStorage + "_" + String.valueOf(iteration) ) ) { + if( s1.contains( CPMEC.sourceStorage + "_" + String.valueOf(iSrc) ) ) { String memoryUnit = s1.split(":")[1].replaceAll("\\s+",""); - srcMemoryTypes.set( iSrc, tmla.getHwMemoryByName( memoryUnit ).BufferType ); + srcMemoryTypes.add( iSrc-1, tmla.getHwMemoryByName( memoryUnit ).BufferType ); iSrc++; } - if( s1.contains( CPMEC.destinationStorage + "_" + String.valueOf(iteration) ) ) { + if( s1.contains( CPMEC.destinationStorage + "_" + String.valueOf(iDst) ) ) { String memoryUnit = s1.split(":")[1].replaceAll("\\s+",""); - dstMemoryTypes.set( iDst, tmla.getHwMemoryByName( memoryUnit ).BufferType ); + dstMemoryTypes.add( iDst-1, tmla.getHwMemoryByName( memoryUnit ).BufferType ); iDst++; } } - DoubleDmaMEC mec = new DoubleDmaMEC( ctxName, dmaArchMECs.get(0), srcMemoryTypes.get(0), dstMemoryTypes.get(0), transferTypes, attributes ); + /*TraceManager.addDev( "About to create the DoubleDmaMEC class" ); + for( Integer i: srcMemoryTypes ) { + TraceManager.addDev( "srcMemoryTypes = " + i.intValue() ); + } + for( Integer i: dstMemoryTypes ) { + TraceManager.addDev( "dstMemoryTypes = " + i.intValue() ); + } + for( ArchUnitMEC i: dmaArchMECs ) { + TraceManager.addDev( "dmaArchMECs = " + i.toString() ); + }*/ + DoubleDmaMEC mec = new DoubleDmaMEC( ctxName, dmaArchMECs, srcMemoryTypes, dstMemoryTypes, transferTypes, attributes ); programString.append( mec.getExecCode() ); } for( Signal sig: dt.getOutSignals() ) { diff --git a/src/ui/window/JDialogReferenceCP.java b/src/ui/window/JDialogReferenceCP.java index 6f6e88493a3633d124bc168f62e793bb6ecb816e..b7b59d7dc06b27910d7eb96c4ea2231c9bce973c 100644 --- a/src/ui/window/JDialogReferenceCP.java +++ b/src/ui/window/JDialogReferenceCP.java @@ -124,7 +124,7 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis //Panel3: assign a value to CP attributes private JPanel panel3; - private JButton assignButton, addressButton; + private JButton attributeButton, addressButton; private JComboBox attributesList_CB, applicationAttributesList_CB, addressList_CB; private JTextField attributesValue_TF, addressValue_TF; private Vector<String> attributesVector, applicationAttributesVector, addressVector; @@ -241,7 +241,7 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis panel3 = new JPanel(); panel3.setLayout(gridbag3); - panel3.setBorder(new javax.swing.border.TitledBorder("Assigning attributes")); + panel3.setBorder(new javax.swing.border.TitledBorder("Assigning value to message parameters")); panel3.setPreferredSize(new Dimension(325, 300)); panel4 = new JPanel(); @@ -427,24 +427,29 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis c3.gridwidth = GridBagConstraints.REMAINDER; //end row panel3.add( new JLabel(" "), c3 ); - panel3.add( new JLabel("Application attribute:"), c3 ); + /*panel3.add( new JLabel("Application attribute:"), c3 ); applicationAttributesList_CB = new JComboBox( applicationAttributesVector ); applicationAttributesList_CB.addActionListener(this); - panel3.add( applicationAttributesList_CB, c3 ); + panel3.add( applicationAttributesList_CB, c3 );*/ - /*panel3.add( new JLabel("Value:"), c3 ); + c3.gridwidth = GridBagConstraints.REMAINDER; //end row + c3.fill = GridBagConstraints.BOTH; + c3.gridheight = 3; + panel3.add( new JLabel(" "), c3 ); //adds some vertical space in between two JLabels + + panel3.add( new JLabel("Attribute value:"), c3 ); attributesValue_TF = new JTextField( "", 5 ); attributesValue_TF.setPreferredSize( new Dimension(150, 30) ); - panel3.add( attributesValue_TF, c3 );*/ + panel3.add( attributesValue_TF, c3 ); c3.gridwidth = GridBagConstraints.REMAINDER; //end row c3.fill = GridBagConstraints.BOTH; c3.gridheight = 3; panel3.add( new JLabel(" "), c3 ); //adds some vertical space in between two JLabels - assignButton = new JButton("Assign attribute value"); - assignButton.addActionListener(this); - panel3.add( assignButton, c3 ); + attributeButton = new JButton("Assign attribute value"); + attributeButton.addActionListener(this); + panel3.add( attributeButton, c3 ); c3.gridwidth = GridBagConstraints.REMAINDER; //end row c3.fill = GridBagConstraints.BOTH; @@ -454,7 +459,8 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis if( assignedAttributes.size() > 0 ) { filterOutAssignedAddresses( addressVector ); //eliminate the addresses that have already been assigned a value } - panel3.add( new JLabel("Address:"), c3 ); + + panel3.add( new JLabel("CP address:"), c3 ); addressList_CB = new JComboBox( addressVector ); addressList_CB.addActionListener(this); panel3.add( addressList_CB, c3 ); @@ -464,7 +470,7 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis c3.gridheight = 3; panel3.add( new JLabel(" "), c3 ); - panel3.add( new JLabel("Value:"), c3 ); + panel3.add( new JLabel("Address value:"), c3 ); addressValue_TF = new JTextField( "", 5 ); addressValue_TF.setPreferredSize( new Dimension(150, 30) ); panel3.add( addressValue_TF, c3 ); @@ -760,7 +766,7 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis String attr, attrType; // Compare the action command to the known actions. - if( evt.getSource() == assignButton ) { + if( evt.getSource() == attributeButton ) { assignValueToAttribute(); } if( evt.getSource() == addressButton ) { @@ -1110,7 +1116,7 @@ public class JDialogReferenceCP extends javax.swing.JDialog implements ActionLis } } else { - JOptionPane.showMessageDialog( frame, "Please enter a value for the selected attribute", "No value for attribute", + JOptionPane.showMessageDialog( frame, "Please enter a value to the selected attribute", "No value for attribute", JOptionPane.INFORMATION_MESSAGE ); return; }