diff --git a/src/tmltranslator/HwCPU.java b/src/tmltranslator/HwCPU.java index 81f71ae498c1bdfa973a0c73fdb5894aebcdaa3b..27d3d0e5271b83c6334a351c7db352fe2f885eab 100755 --- a/src/tmltranslator/HwCPU.java +++ b/src/tmltranslator/HwCPU.java @@ -45,6 +45,7 @@ knowledge of the CeCILL license and that you accept its terms. package tmltranslator; +import tmltranslator.ctranslator.*; import java.util.*; @@ -63,6 +64,7 @@ public class HwCPU extends HwExecutionNode { public static final int DEFAULT_CACHE_MISS = 5; public static final int DEFAULT_SCHEDULING = BASIC_ROUND_ROBIN; public static final int DEFAULT_SLICE_TIME = 10000; // in microseconds + public static final ArchUnitMEC DEFAULT_MODEL_EXTENSION_CONSTRUCT = new CpuMEC(); public int nbOfCores = DEFAULT_NB_OF_CORES; // Should be equal or greater than 1 public int byteDataSize = DEFAULT_BYTE_DATA_SIZE; // Should be greater than 0 @@ -74,6 +76,7 @@ public class HwCPU extends HwExecutionNode { public int cacheMiss = DEFAULT_CACHE_MISS; // Percentage: between 0 and 100 public int schedulingPolicy = DEFAULT_SCHEDULING; public int sliceTime = DEFAULT_SLICE_TIME; + public ArchUnitMEC MEC = DEFAULT_MODEL_EXTENSION_CONSTRUCT; public HwCPU(String _name) { @@ -91,4 +94,4 @@ public class HwCPU extends HwExecutionNode { } } -} \ No newline at end of file +} diff --git a/src/tmltranslator/TMLArchitecture.java b/src/tmltranslator/TMLArchitecture.java index 18fd447dd03b472df69dba9f4c39d0886e74e610..26d721f60268b0c03cb4b35530b53ff7e8841de8 100755 --- a/src/tmltranslator/TMLArchitecture.java +++ b/src/tmltranslator/TMLArchitecture.java @@ -287,6 +287,17 @@ public class TMLArchitecture { return null; } + public HwCPU getHwCPUByName(String _name) { + for(HwNode node: hwnodes) { + if (node.getName().equals(_name)) { + if (node instanceof HwCPU) { + return (HwCPU)node; + } + } + } + return null; + } + public HwBus getHwBusByName(String _name) { for(HwNode node: hwnodes) { if (node.getName().equals(_name)) { diff --git a/src/tmltranslator/ctranslator/AdaifMEC.java b/src/tmltranslator/ctranslator/AdaifMEC.java index 29de35c2376c828e88baf52c528e9b695218319a..c6e48a37756269541a0e448227644100612d2f07 100644 --- a/src/tmltranslator/ctranslator/AdaifMEC.java +++ b/src/tmltranslator/ctranslator/AdaifMEC.java @@ -53,14 +53,15 @@ public class AdaifMEC extends ArchUnitMEC { public static final String Context = "ADAIF_CONTEXT"; public static final String Ctx_cleanup = "adaif_ctx_cleanup"; + public static final String Operation = "Adaif operation"; - public AdaifMEC( String XOP, String ID0, String OD0 ) { + public AdaifMEC() { - node_type = "ADAIF"; - inst_type = "ADAIF"; - inst_decl = "ADAIF_CONTEXT"; - buff_type = "ADAIF_BUFFER_TYPE"; - buff_init = "= {/*l,b,q,t*/};"; + index = 4; + context = "ADAIF_CONTEXT"; + initCtxRoutine = "adaif_ctx_init"; + localMemoryPointer = "adaif_mss"; + ctxCleanupRoutine = "adaif_ctx_cleanup"; } } //End of class diff --git a/src/tmltranslator/ctranslator/ArchUnitMEC.java b/src/tmltranslator/ctranslator/ArchUnitMEC.java index 09161565dca6dc8e236eb65c50025c924fdedb35..de0d78afa893cd9cd6a95b9c9208d29489085bdd 100755 --- a/src/tmltranslator/ctranslator/ArchUnitMEC.java +++ b/src/tmltranslator/ctranslator/ArchUnitMEC.java @@ -52,35 +52,40 @@ import myutil.*; public abstract class ArchUnitMEC { + private static ArchUnitMEC[] typesArr = { new CpuMEC(), new FepMEC(), new InterleaverMEC(), new MapperMEC(), new AdaifMEC() }; + public static final Vector<ArchUnitMEC> Types = new Vector<ArchUnitMEC>( Arrays.asList( typesArr ) ); + public static final int CpuMECIndex = 0; + public static final int FepMECIndex = 1; + public static final int InterleaverMECIndex = 2; + public static final int MapperMECIndex = 3; + public static final int AdaifMECIndex = 4; + public String CR = "\n"; public String TAB = "\t"; - public String node_type = new String(); - public String inst_type = new String(); - public String inst_decl = new String(); - public String buff_type = new String(); - public String buff_init = new String(); - /*public String init_code = new String(); - public String exec_code = new String(); - public String cleanup_code = new String();*/ - - public String ID0 = new String(); - public String OD0 = new String(); - public String XOP = new String(); + protected int index; + protected String initCtxRoutine; + protected String ctxCleanupRoutine; + protected String localMemoryPointer; + protected String context = "EMBB_CONTEXT"; - public ArchUnitMEC() { - node_type = "1"; + public int getIndex() { + return index; } - /*public String getExecCode() { - return exec_code; + public String getContext() { + return context; } - public String getInitCode() { - return init_code; - }*/ + public String getCtxInitCode() { + return initCtxRoutine; + } + + public String getCtxCleanupCode() { + return ctxCleanupRoutine; + } - public String toString() { - return node_type;// + CR + inst_decl + CR + inst_type + CR + buff_type + CR + buff_init + CR + exec_code + CR + init_code + CR + cleanup_code; + public String getLocalMemoryPointer() { + return localMemoryPointer; } } //End of class diff --git a/src/tmltranslator/ctranslator/CpuMEC.java b/src/tmltranslator/ctranslator/CpuMEC.java index b35b669a9958095e7eb0724b91977c35e2b0cd23..8a40ef8dd370d6b12692e330eab817babcf415b8 100644 --- a/src/tmltranslator/ctranslator/CpuMEC.java +++ b/src/tmltranslator/ctranslator/CpuMEC.java @@ -53,11 +53,8 @@ public class CpuMEC extends ArchUnitMEC { protected String addr = ""; public CpuMEC() { - node_type = "CPU"; - inst_type = "CPUoperation"; - inst_decl = "VOID"; - buff_type = "MM_BUFFER_TYPE"; - buff_init = "VOID"; + index = 0; + context = "EMBB_CONTEXT"; } } //End of class diff --git a/src/tmltranslator/ctranslator/DoubleDmaMEC.java b/src/tmltranslator/ctranslator/DoubleDmaMEC.java index 8e1d23ebaaa506aba5e12780af83835704d1ac0e..3558ff79021d76f8b0b091cc0f4556ddaabe4a34 100755 --- a/src/tmltranslator/ctranslator/DoubleDmaMEC.java +++ b/src/tmltranslator/ctranslator/DoubleDmaMEC.java @@ -80,6 +80,18 @@ public class DoubleDmaMEC extends CPMEC { cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName + ");"; } + public DoubleDmaMEC( String ctxName, ArchUnitMEC archMEC ) { + + node_type = "DoubleDmaMEC"; + inst_type = "VOID"; + inst_decl = "EMBB_DMA_CONTEXT"; + buff_type = "MM_BUFFER_TYPE"; + buff_init = "VOID"; + exec_code = TAB + "embb_dma_start(&" + ctxName + ", /*USER TO DO: SRC_ADDRESS*/, /*USER TO DO: DST_ADDRESS*/, /*USER TO DO: NUM_SAMPLES */ );" + CR; + init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + ", " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR; + cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName + ");"; + } + public DoubleDmaMEC( String ctxName, String destinationAddress1, String sourceAddress1, String size1, String destinationAddress2, String sourceAddress2, String size2 ) { node_type = "DoubleDmaMEC"; diff --git a/src/tmltranslator/ctranslator/FepMEC.java b/src/tmltranslator/ctranslator/FepMEC.java index 4e77cfabc8ef8cdcb0babb203e42ff87ed567130..8f31ddb9cc823da42e89447ea38528d5c4f3e5ca 100644 --- a/src/tmltranslator/ctranslator/FepMEC.java +++ b/src/tmltranslator/ctranslator/FepMEC.java @@ -51,15 +51,24 @@ import java.util.*; public class FepMEC extends ArchUnitMEC { - public static final String Context = "FEP_CONTEXT"; public static final String Ctx_cleanup = "fep_ctx_cleanup"; - public FepMEC( String XOP, String ID0, String OD0 ) { + private static String[] opArr = { "CWA", "CWP", "CWM", "CWL", "SUM", "FFT" }; + public static final Vector<String> operationsList = new Vector<String>( Arrays.asList( opArr ) ); + public static final int CWAIndex = 0; + public static final int CWPndex = 1; + public static final int CWMIndex = 2; + public static final int CWLIndex = 3; + public static final int SUMIndex = 4; + public static final int FFTIndex = 5; - node_type = "FEP"; - inst_type = "FEP"; - inst_decl = "FEP_CONTEXT"; - buff_type = "FEP_BUFFER_TYPE"; + public FepMEC() { + + index = 1; + context = "FEP_CONTEXT"; + initCtxRoutine = "fep_ctx_init"; + localMemoryPointer = "fep_mss"; + ctxCleanupRoutine = "fep_ctx_cleanup"; } } //End of class diff --git a/src/tmltranslator/ctranslator/InterleaverMEC.java b/src/tmltranslator/ctranslator/InterleaverMEC.java index fdb18c10d65d9e87e051867ac60fd501a7b8d233..e01853ca741eeaa3611c567539ae9a6fdc6ddc41 100644 --- a/src/tmltranslator/ctranslator/InterleaverMEC.java +++ b/src/tmltranslator/ctranslator/InterleaverMEC.java @@ -53,14 +53,15 @@ public class InterleaverMEC extends ArchUnitMEC { public static final String Context = "INTL_CONTEXT"; public static final String Ctx_cleanup = "intl_ctx_cleanup"; + public static final String Operation = "Interleaver operation"; - public InterleaverMEC( String XOP, String ID0, String OD0 ) { + public InterleaverMEC() { - node_type = "INTERLEAVER"; - inst_type = "INTL"; - inst_decl = "INTL_CONTEXT"; - buff_type = "INTL_BUFFER_TYPE"; - buff_init = "= {/*l,b,q,t*/};"; + index = 2; + context = "INTL_CONTEXT"; + initCtxRoutine = "intl_ctx_init"; + localMemoryPointer = "intl_mss"; + ctxCleanupRoutine = "intl_ctx_cleanup"; } } //End of class diff --git a/src/tmltranslator/ctranslator/MapperMEC.java b/src/tmltranslator/ctranslator/MapperMEC.java index ff1eb7d3234aeec314b720213bfc62b459f49345..8c3575078c202e926e4e249cd2a0413585f12c1a 100644 --- a/src/tmltranslator/ctranslator/MapperMEC.java +++ b/src/tmltranslator/ctranslator/MapperMEC.java @@ -53,14 +53,15 @@ public class MapperMEC extends ArchUnitMEC { public static final String Context = "MAPPER_CONTEXT"; public static final String Ctx_cleanup = "mapper_ctx_cleanup"; + public static final String Operation = "Mapper operation"; - public MapperMEC( String XOP, String ID0, String OD0 ) { + public MapperMEC() { - node_type = "MAPPER"; - inst_type = "MAP"; - inst_decl = "MAP_CONTEXT"; - buff_type = "MAPPER_BUFFER_TYPE"; - buff_init = "= {/*l,b,q,t*/};"; + index = 3; + context = "MAPPER_CONTEXT"; + initCtxRoutine = "mapper_ctx_init"; + localMemoryPointer = "mapper_mss"; + ctxCleanupRoutine = "mapper_ctx_cleanup"; } } //End of class diff --git a/src/tmltranslator/ctranslator/SingleDmaMEC.java b/src/tmltranslator/ctranslator/SingleDmaMEC.java index c311fdfa5b2c94dc158daef9b3326186641f70e4..3d169a00e53cfd7fce106c2f5a32819958a3be4c 100755 --- a/src/tmltranslator/ctranslator/SingleDmaMEC.java +++ b/src/tmltranslator/ctranslator/SingleDmaMEC.java @@ -64,14 +64,23 @@ public class SingleDmaMEC extends CPMEC { public SingleDmaMEC( String ctxName ) { + node_type = "SingleDmaMEC"; + inst_type = "VOID"; + inst_decl = "EMBB_DMA_CONTEXT"; + buff_type = "MM_BUFFER_TYPE"; + buff_init = "VOID"; + } + + public SingleDmaMEC( String ctxName, ArchUnitMEC archMEC ) { + node_type = "SingleDmaMEC"; inst_type = "VOID"; inst_decl = "EMBB_DMA_CONTEXT"; buff_type = "MM_BUFFER_TYPE"; buff_init = "VOID"; exec_code = TAB + "embb_dma_start(&" + ctxName + ", (uintptr_t) /*USER TO DO: SRC_ADDRESS*/, (uintptr_t) /*USER TO DO: DST_ADDRESS*/, /*USER TO DO: NUM_SAMPLES */ );" + CR; - init_code = TAB + "embb_dma_ctx_init(&" + ctxName + ", /*USER TO DO: DMA_DEVICE*/, /*USER TO DO: DST_DEV*/, NULL );" + CR; - cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName +");"; + init_code = TAB + archMEC.getCtxInitCode() + "(&" + ctxName + ", " + "(uintptr_t) " + archMEC.getLocalMemoryPointer() + " );" + CR; + cleanup_code = TAB + archMEC.getCtxCleanupCode() + "(&" + ctxName +");"; } public SingleDmaMEC( String ctxName, String destinationAddress, String sourceAddress, String size ) { @@ -86,4 +95,8 @@ public class SingleDmaMEC extends CPMEC { cleanup_code = TAB + "embb_dma_ctx_cleanup(&" + ctxName +");"; } + public String getInitCode() { + return init_code; + } + } //End of class diff --git a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java index e1073c4fb93a2bab986a06686bb29c58d6e654df..fb269518afe4aeb05b0350e219e867bd90f540c0 100755 --- a/src/tmltranslator/ctranslator/TMLCCodeGeneration.java +++ b/src/tmltranslator/ctranslator/TMLCCodeGeneration.java @@ -773,30 +773,44 @@ public class TMLCCodeGeneration { } } instructionsString.append( CR2 + "/**** Data Transfers Instructions ****/" + CR ); + ArchUnitMEC archMEC = new CpuMEC(); for( DataTransfer dt: dataTransfersList ) { TMLCPLib tmlcplib = dt.getTMLCPLib(); - CPMEC mec = tmlcplib.getCPMEC(); + CPMEC cpMEC = tmlcplib.getCPMEC(); ctxName = dt.getContextName(); - if( mec instanceof CpuMemoryCopyMEC ) { + if( cpMEC instanceof CpuMemoryCopyMEC ) { if( declaration ) { - instructionsString.append( "extern" + SP + CpuMemoryCopyMEC.Context + SP + ctxName + SC + CR ); + instructionsString.append( "extern" + SP + archMEC.getContext() + SP + ctxName + SC + CR ); } - else { instructionsString.append( CpuMemoryCopyMEC.Context + SP + ctxName + SC + CR ); } + else { instructionsString.append( archMEC.getContext() + SP + ctxName + SC + CR ); } } - if( mec instanceof SingleDmaMEC ) { + if( cpMEC instanceof SingleDmaMEC ) { + for( String s: tmlcplib.getMappedUnits() ) { + if( s.contains( "DMA_Controller" ) ) { + String dmaUnit = s.split(":")[1].replaceAll("\\s+",""); + archMEC = tmla.getHwCPUByName( dmaUnit ).MEC; + break; + } + } if( declaration ) { - instructionsString.append( "extern" + SP + SingleDmaMEC.Context + SP + ctxName + SC + CR ); + instructionsString.append( "extern" + SP + archMEC.getContext() + SP + ctxName + SC + CR ); } else { - instructionsString.append( SingleDmaMEC.Context + SP + ctxName + SC + CR ); + instructionsString.append( archMEC.getContext() + SP + ctxName + SC + CR ); } } - if( mec instanceof DoubleDmaMEC ) { - if( declaration ) { - instructionsString.append( "extern" + SP + DoubleDmaMEC.Context + SP + ctxName + SC + CR ); - } - else { - instructionsString.append( DoubleDmaMEC.Context + SP + ctxName + SC + CR ); + if( cpMEC instanceof DoubleDmaMEC ) { + for( String s: tmlcplib.getMappedUnits() ) { + if( s.contains( "DMA_Controller" ) ) { + String dmaUnit = s.split(":")[1].replaceAll("\\s+",""); + archMEC = tmla.getHwCPUByName( dmaUnit ).MEC; + if( declaration ) { + instructionsString.append( "extern" + SP + archMEC.getContext() + SP + ctxName + SC + CR ); + } + else { + instructionsString.append( archMEC.getContext() + SP + ctxName + SC + CR ); + } + } } } } @@ -810,13 +824,6 @@ public class TMLCCodeGeneration { s.append( sig.getName() + "," + CR ); } s.append( postexList.get(0).getName() + "," + CR ); - /*for( Operation op: operationsList ) { - if( op.isPostex() ) { - TraceManager.addDev( "OPERATION: " + op.getName() ); - TraceManager.addDev( "\t\tinSignal = " + op.getInSignals().get(0).getName() ); - } - } - System.exit(0);*/ s.append( "NUM_SIGS };" + CR2 + "enum ops_enu {" + CR ); for( Operation op: operationsList ) { @@ -941,7 +948,7 @@ public class TMLCCodeGeneration { } code.append( "int op_" + op.getName() + "()\t{" + CR /*+ getTaskAttributes( fTask )*/ + CR ); - if( op.isPrex() ) { + if( op.isPrex() || op.isPostex() ) { code.append( TAB + "int status = 0;" + CR ); } @@ -1338,6 +1345,9 @@ public class TMLCCodeGeneration { private void generateInitRoutinesForCPs() { + ArchUnitMEC archMEC = new CpuMEC(); + ArrayList<ArchUnitMEC> archMECList = new ArrayList<ArchUnitMEC>(); + for( DataTransfer dt: dataTransfersList ) { TMLCPLib tmlcplib = dt.getTMLCPLib(); CPMEC cpMEC = tmlcplib.getCPMEC(); @@ -1349,14 +1359,29 @@ public class TMLCCodeGeneration { initFileString.append( "//" + TAB + mec.getInitCode() + "}" + CR2 ); } if( cpMEC instanceof SingleDmaMEC ) { + for( String s: tmlcplib.getMappedUnits() ) { + if( s.contains( "DMA_Controller" ) ) { + String dmaUnit = s.split(":")[1].replaceAll("\\s+",""); + archMEC = tmla.getHwCPUByName( dmaUnit ).MEC; + break; + } + } initFileString.append( "void init_" + name + "()\t{" + CR ); - SingleDmaMEC mec = new SingleDmaMEC( ctxName ); - initFileString.append( "//" + TAB + mec.getInitCode() + "}" + CR2 ); + SingleDmaMEC mec = new SingleDmaMEC( ctxName, archMEC ); + initFileString.append( TAB + mec.getInitCode() + "}" + CR2 ); } if( cpMEC instanceof DoubleDmaMEC ) { initFileString.append( "void init_" + name + "()\t{" + CR ); - DoubleDmaMEC mec = new DoubleDmaMEC( ctxName ); - initFileString.append( "//" + TAB + mec.getInitCode() + "}" + CR2 ); + for( String s: tmlcplib.getMappedUnits() ) { //there are two DMA_controllers + if( s.contains( "DMA_Controller" ) ) { + String dmaUnit = s.split(":")[1].replaceAll("\\s+",""); + archMEC = tmla.getHwCPUByName( dmaUnit ).MEC ; + //TraceManager.addDev( "DoubleDmaTransfer, archMEC: " + archMEC ); + DoubleDmaMEC mec = new DoubleDmaMEC( ctxName, archMEC ); + initFileString.append( TAB + mec.getInitCode() ); + } + } + initFileString.append( "}" + CR2 ); } } } diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java index dc07fe7e9a74d235355b1540faec9aeeb3cc7383..ea8480b9d69696395fd87016fda1216425d26753 100755 --- a/src/ui/GTMLModeling.java +++ b/src/ui/GTMLModeling.java @@ -2172,6 +2172,7 @@ public class GTMLModeling { cpu.execiTime = node.getExeciTime(); cpu.execcTime = node.getExeccTime(); cpu.clockRatio = node.getClockRatio(); + cpu.MEC = node.getMECType(); listE.addCor(cpu, node); archi.addHwNode(cpu); TraceManager.addDev("CPU node added: " + cpu.getName()); diff --git a/src/ui/tmldd/TMLArchiArtifact.java b/src/ui/tmldd/TMLArchiArtifact.java index 2c98f42c7e31230ed57dad3659219a63c0d4cb71..bb1b25789e0bf0cfd111054915ac344214fb26c7 100755 --- a/src/ui/tmldd/TMLArchiArtifact.java +++ b/src/ui/tmldd/TMLArchiArtifact.java @@ -73,7 +73,7 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa protected int priority = 0; // Between 0 and 10 protected String operation = "VOID"; - private String fatherMECType = "VOID"; + private ArchUnitMEC fatherArchUnitMECType; public TMLArchiArtifact(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -160,9 +160,9 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa String tmp; boolean error = false; - fatherMECType = ((TMLArchiNode)father).getMECType(); + fatherArchUnitMECType = ((TMLArchiNode)father).getMECType(); TraceManager.addDev( "Father: " + father.getClass().toString() + " with MEC " + ((TMLArchiNode)father).getMECType() ); - JDialogTMLTaskArtifact dialog = new JDialogTMLTaskArtifact(frame, "Setting artifact attributes", this, operation, fatherMECType); + JDialogTMLTaskArtifact dialog = new JDialogTMLTaskArtifact(frame, "Setting artifact attributes", this, operation, fatherArchUnitMECType); dialog.setSize(400, 350); GraphicLib.centerOnParent(dialog); dialog.show(); // blocked until dialog has been closed @@ -229,16 +229,16 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); - sb.append("<info value=\"" + value + "\" taskName=\"" + taskName + "\" referenceTaskName=\""); - sb.append(referenceTaskName); - sb.append("\" priority=\""); - sb.append(priority); - sb.append("\" operation=\""); - sb.append(operation); - sb.append("\" fatherComponentMECType=\""); - sb.append(fatherMECType); - sb.append("\" />\n"); - sb.append("</extraparam>\n"); + sb.append( "<info value=\"" + value + "\" taskName=\"" + taskName + "\" referenceTaskName=\"" ); + sb.append( referenceTaskName ); + sb.append( "\" priority=\"" ); + sb.append( priority ); + sb.append( "\" operation=\"" ); + sb.append( operation ); + sb.append( "\" fatherComponentMECType=\"" ); + sb.append( fatherArchUnitMECType.getIndex() ); + sb.append( "\" />\n" ); + sb.append( "</extraparam>\n" ); return new String(sb); } @@ -272,7 +272,7 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa priority = Integer.decode(prio).intValue(); } operation = elt.getAttribute("operation"); - fatherMECType = elt.getAttribute("fatherComponentMECType"); + fatherArchUnitMECType = ArchUnitMEC.Types.get( Integer.valueOf( elt.getAttribute("fatherComponentMECType") ) ); } if (svalue != null) { value = svalue; @@ -317,8 +317,8 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa public OperationMEC getOperationMECOfTask() { - TraceManager.addDev( "Inside getMECofTask, fatherMECType: " + fatherMECType ); - if( fatherMECType.equals( "FEP" ) ) { + TraceManager.addDev( "Inside getMECofTask, fatherArchUnitMECType: " + fatherArchUnitMECType ); + if( fatherArchUnitMECType instanceof FepMEC ) { if( operation.equals( "CWM" ) ) { return new CwmMEC( "", "", "" ); } @@ -338,81 +338,39 @@ public class TMLArchiArtifact extends TGCWithoutInternalComponent implements Swa return new SumMEC( "", "", "" ); } } - else if( fatherMECType.equals( "MAPPER" ) ) { + else if( fatherArchUnitMECType instanceof MapperMEC ) { return new MappOperationMEC( "", "", "" ); } - else if( fatherMECType.equals( "INTL" ) ) { + else if( fatherArchUnitMECType instanceof InterleaverMEC ) { return new IntlOperationMEC( "", "", "" ); } - else if( fatherMECType.equals( "ADAIF" ) ) { + else if( fatherArchUnitMECType instanceof AdaifMEC ) { return new AdaifOperationMEC( "", "", "" ); } - else if( fatherMECType.equals( "CPU" ) ) { + else if( fatherArchUnitMECType instanceof CpuMEC ) { return new CpuOperationMEC( "", "", "" ); } return null; } public ArchUnitMEC getArchUnitMEC() { - - if( fatherMECType.equals( "FEP" ) ) { - return new FepMEC( "", "", "" ); + return fatherArchUnitMECType; + /*if( fatherArchUnitMECType instanceof FepMEC ) { + return new FepMEC(); } - else if( fatherMECType.equals( "MAPPER" ) ) { - return new MapperMEC( "", "", "" ); + else if( fatherArchUnitMECType instanceof MapperMEC ) { + return new MapperMEC(); } - else if( fatherMECType.equals( "INTL" ) ) { - return new InterleaverMEC( "", "", "" ); + else if( fatherArchUnitMECType instanceof InterleaverMEC ) { + return new InterleaverMEC(); } - else if( fatherMECType.equals( "ADAIF" ) ) { - return new AdaifMEC( "", "", "" ); + else if( fatherArchUnitMECType instanceof AdaifMEC ) { + return new AdaifMEC(); } - else if( fatherMECType.equals( "CPU" ) ) { + else if( fatherArchUnitMECType instanceof CpuMEC ) { return new CpuMEC(); } - return null; + return null;*/ } - /*public Vector getListOfATG() { - Vector v = new Vector(); - DesignPanel dp = tdp.getGUI().getDesignPanel(value); - - if (dp == null) { - return v; - } - - //System.out.println("DesignPanel ok"); - LinkedList ll = dp.tcdp.getComponentList(); - ListIterator iterator = ll.listIterator(); - TGComponent tgc; - TCDTClass tc; - ArtifactTClassGate atg; - Vector listGates; - int i; - TAttribute ta; - - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if (tgc instanceof TCDTClass) { - tc = (TCDTClass)tgc; - //System.out.println("Found class = " + tc.getClassName()); - listGates = tc.getGates(); - for(i=0; i<listGates.size(); i++) { - ta = (TAttribute)(listGates.elementAt(i)); - if (ta.getAccess() == TAttribute.PUBLIC) { - // Verify if it is already involved in a synchronization internal to the component - if (!dp.tcdp.isASynchronizedGate(ta)) { - atg = new ArtifactTClassGate(value, tc.getClassName(), ta.getId()); - v.add(atg); - } - } - } - } - } - - return v; - - }*/ - - } diff --git a/src/ui/tmldd/TMLArchiCPUNode.java b/src/ui/tmldd/TMLArchiCPUNode.java index fcaa7f31d5e02c41ba7b09e356cb3fb21996ff7f..b48e62748ded9cad1d9f2e8e6fdfd59350f05ce2 100755 --- a/src/ui/tmldd/TMLArchiCPUNode.java +++ b/src/ui/tmldd/TMLArchiCPUNode.java @@ -57,6 +57,7 @@ import ui.*; import ui.window.*; import tmltranslator.*; +import tmltranslator.ctranslator.*; public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, WithAttributes { private int textY1 = 15; @@ -192,7 +193,8 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, GraphicLib.centerOnParent(dialog); dialog.show(); // blocked until dialog has been closed MECType = dialog.getMECType(); - TraceManager.addDev( "MECType: " + MECType ); + TraceManager.addDev( "after JDialog " + MECType ); + TraceManager.addDev( "after JDialog " + MECType.getIndex() ); if (!dialog.isRegularClose()) { return false; @@ -477,7 +479,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, sb.append(" execiTime=\"" + execiTime + "\""); sb.append(" execcTime=\"" + execcTime + "\""); sb.append(" clockRatio=\"" + clockRatio + "\""); - sb.append(" MECType=\"" + MECType + "\""); + sb.append(" MECType=\"" + MECType.getIndex() + "\""); sb.append("/>\n"); sb.append("</extraparam>\n"); return new String(sb); @@ -541,7 +543,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); } - MECType = elt.getAttribute("MECType"); + MECType = ArchUnitMEC.Types.get( Integer.valueOf( elt.getAttribute("MECType") ) ); if ((elt.getAttribute("sliceTime") != null) && (elt.getAttribute("sliceTime").length() > 0)){ sliceTime = Integer.decode(elt.getAttribute("sliceTime")).intValue(); } @@ -625,7 +627,7 @@ public class TMLArchiCPUNode extends TMLArchiNode implements SwallowTGComponent, attr += "Branch. pred. misrate (in %) = " + branchingPredictionPenalty + "\n"; attr += "Cache miss (in %) = " + cacheMiss + "\n"; attr += "Clock ratio = " + clockRatio + "\n"; - attr += "MECType = " + MECType + "\n"; + attr += "MECType = " + MECType.getIndex() + "\n"; return attr; } diff --git a/src/ui/tmldd/TMLArchiNode.java b/src/ui/tmldd/TMLArchiNode.java index fc0f816d5491081b74a6da948bf2ba86bcd10447..a5dbb9fd1b2a3bbaa84807b2c039fc0aaed76127 100755 --- a/src/ui/tmldd/TMLArchiNode.java +++ b/src/ui/tmldd/TMLArchiNode.java @@ -57,6 +57,7 @@ import ui.*; import ui.window.*; import tmltranslator.*; +import tmltranslator.ctranslator.*; public abstract class TMLArchiNode extends TGCWithInternalComponent implements SwallowTGComponent { protected int clockRatio = HwNode.DEFAULT_CLOCK_RATIO; @@ -66,7 +67,7 @@ public abstract class TMLArchiNode extends TGCWithInternalComponent implements S public final static int TRANSFER = 1; public final static int CONTROLLER = 2; public final static int OTHER = 3; //for CPNodes - protected String MECType = "VOID"; + protected ArchUnitMEC MECType; public TMLArchiNode(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -90,7 +91,7 @@ public abstract class TMLArchiNode extends TGCWithInternalComponent implements S return clockRatio; } - public String getMECType() { + public ArchUnitMEC getMECType() { return MECType; } diff --git a/src/ui/window/JDialogCPUNode.java b/src/ui/window/JDialogCPUNode.java index 4306fe1c93717a8d248e6c5dbed651318e0e4e9b..ac353abfd4225e4448ccab403f48d914103d90e4 100755 --- a/src/ui/window/JDialogCPUNode.java +++ b/src/ui/window/JDialogCPUNode.java @@ -52,11 +52,11 @@ import javax.swing.*; import ui.*; import ui.tmlcd.*; import java.util.*; - +import tmltranslator.ctranslator.*; import ui.*; - import ui.tmldd.*; +import myutil.*; public class JDialogCPUNode extends javax.swing.JDialog implements ActionListener { @@ -66,7 +66,7 @@ public class JDialogCPUNode extends javax.swing.JDialog implements ActionListene private Frame frame; private TMLArchiCPUNode node; - private String MECType = "VOID"; + private ArchUnitMEC MECType; // Panel1 @@ -82,7 +82,7 @@ public class JDialogCPUNode extends javax.swing.JDialog implements ActionListene private JButton cancelButton; /** Creates new form */ - public JDialogCPUNode(Frame _frame, String _title, TMLArchiCPUNode _node, String _MECType) { + public JDialogCPUNode(Frame _frame, String _title, TMLArchiCPUNode _node, ArchUnitMEC _MECType) { super(_frame, _title, true); frame = _frame; node = _node; @@ -233,18 +233,12 @@ public class JDialogCPUNode extends javax.swing.JDialog implements ActionListene c4.anchor = GridBagConstraints.CENTER;*/ panel4.add(new JLabel("Embb Model Extension Construct:"), c4); c4.gridwidth = GridBagConstraints.REMAINDER; //end row - Vector<String> MECTypes = new Vector<String>(); - MECTypes.add("CPU"); - MECTypes.add("FEP"); - MECTypes.add("MAPPER"); - MECTypes.add("INTL"); - MECTypes.add("ADAIF"); - MECTypeCB = new JComboBox( MECTypes ); - if( MECType.equals( "VOID" ) || MECType.equals( "" ) ) { + MECTypeCB = new JComboBox( ArchUnitMEC.Types ); + if( MECType == null ) { MECTypeCB.setSelectedIndex( 0 ); } else { - MECTypeCB.setSelectedIndex( MECTypes.indexOf( MECType ) ); + MECTypeCB.setSelectedIndex( MECType.getIndex() ); } MECTypeCB.addActionListener(this); panel4.add( MECTypeCB, c4); @@ -291,7 +285,7 @@ public class JDialogCPUNode extends javax.swing.JDialog implements ActionListene public void closeDialog() { regularClose = true; - MECType = (String)MECTypeCB.getItemAt( MECTypeCB.getSelectedIndex() ); + MECType = ArchUnitMEC.Types.get( MECTypeCB.getSelectedIndex() ); dispose(); } @@ -359,7 +353,7 @@ public class JDialogCPUNode extends javax.swing.JDialog implements ActionListene return schedulingPolicy.getSelectedIndex(); } - public String getMECType() { + public ArchUnitMEC getMECType() { return MECType; } diff --git a/src/ui/window/JDialogTMLTaskArtifact.java b/src/ui/window/JDialogTMLTaskArtifact.java index 269ce3966c2c215507b9836af824f65db16be3c2..ca91393e9a0005a93e7c60897e1a9f09a343b9db 100755 --- a/src/ui/window/JDialogTMLTaskArtifact.java +++ b/src/ui/window/JDialogTMLTaskArtifact.java @@ -53,8 +53,9 @@ import javax.swing.*; import java.util.*; import ui.*; - import ui.tmldd.*; +import tmltranslator.ctranslator.*; + import myutil.*; public class JDialogTMLTaskArtifact extends javax.swing.JDialog implements ActionListener { @@ -66,7 +67,7 @@ public class JDialogTMLTaskArtifact extends javax.swing.JDialog implements Actio private Frame frame; private TMLArchiArtifact artifact; private String operation = "VOID"; - private String MECType = "VOID"; + private ArchUnitMEC MECType; //protected JTextField taskName; protected JComboBox referenceTaskName, priority, operationsListCB; @@ -76,7 +77,7 @@ public class JDialogTMLTaskArtifact extends javax.swing.JDialog implements Actio private JButton cancelButton; /** Creates new form */ - public JDialogTMLTaskArtifact(Frame _frame, String _title, TMLArchiArtifact _artifact, String _operation, String _MECType) { + public JDialogTMLTaskArtifact(Frame _frame, String _title, TMLArchiArtifact _artifact, String _operation, ArchUnitMEC _MECType) { super(_frame, _title, true); frame = _frame; artifact = _artifact; @@ -160,28 +161,23 @@ public class JDialogTMLTaskArtifact extends javax.swing.JDialog implements Actio Vector<String> operationsListS = new Vector<String>(); int indexOp = 0; TraceManager.addDev( "Inside JDialogTMLTaskArtifact: " + MECType ); - if( MECType.equals( "FEP" ) ) { - operationsListS.add( "CWA" ); - operationsListS.add( "CWP" ); - operationsListS.add( "CWM" ); - operationsListS.add( "CWL" ); - operationsListS.add( "SUM" ); - operationsListS.add( "FFT" ); + if( MECType instanceof FepMEC ) { + operationsListS = FepMEC.operationsList; indexOp = operationsListS.indexOf( operation ); } - else if( MECType.equals( "MAPPER" ) ) { - operationsListS.add( "MapperOperation" ); + else if( MECType instanceof MapperMEC ) { + operationsListS.add( MapperMEC.Operation ); indexOp = operationsListS.indexOf( operation ); } - else if( MECType.equals( "INTL" ) ) { - operationsListS.add( "INTLOperation" ); + else if( MECType instanceof InterleaverMEC ) { + operationsListS.add( InterleaverMEC.Operation ); indexOp = operationsListS.indexOf( operation ); } - else if( MECType.equals( "ADAIF" ) ) { - operationsListS.add( "ADAIFOperation" ); + else if( MECType instanceof AdaifMEC ) { + operationsListS.add( AdaifMEC.Operation ); indexOp = operationsListS.indexOf( operation ); } - else if( MECType.equals( "CPU" ) ) { + else if( MECType instanceof CpuMEC ) { String tmp = (String)(referenceTaskName.getSelectedItem()); operationsListS.add( tmp.split("::")[1] ); indexOp = operationsListS.indexOf( operation );