From d90285babf1c870c0ab4d5586929cca2dd265390 Mon Sep 17 00:00:00 2001 From: Daniela GENIUS <daniela.genius@lip6.fr> Date: Fri, 5 Apr 2019 16:27:37 +0200 Subject: [PATCH] merge --- MPSoC/Makefile.forsoclib | 4 +- .../SysCAMSSpecification.java | 9 + .../syscamstranslator/SysCAMSTBlockDE.java | 10 +- .../syscamstranslator/SysCAMSTBlockTDF.java | 98 +++--- .../syscamstranslator/SysCAMSTPortTDF.java | 10 + .../syscamstranslator/toSysCAMS/Header.java | 2 +- .../toSysCAMS/PrimitiveCode.java | 6 +- .../toSysCAMS/TopCellGenerator.java | 44 ++- .../toSysCAMSCluster/ClusterCode.java | 134 ++++---- .../{Header.java => HeaderCluster.java} | 10 +- .../MakefileCodeCluster.java} | 8 +- ...iveCode.java => PrimitiveCodeCluster.java} | 51 ++-- .../TopCellGeneratorCluster.java | 66 +++- .../ClusterCodeSoclib.java} | 8 +- .../HeaderSoclib.java} | 8 +- .../MakefileSoclibCode.java} | 10 +- .../PrimitiveCodeSoclib.java} | 10 +- .../TopCellGeneratorSoclib.java} | 77 +++-- src/main/java/ui/MainGUI.java | 4 - src/main/java/ui/SysCAMSPanelTranslator.java | 15 +- src/main/java/ui/TGConnector.java | 0 src/main/java/ui/syscams/SysCAMSBlockDE.java | 17 +- src/main/java/ui/syscams/SysCAMSBlockTDF.java | 31 +- .../window/JDialogSelectSysCAMSComponent.java | 6 +- .../java/ui/window/JDialogSysCAMSBlockDE.java | 31 +- .../ui/window/JDialogSysCAMSBlockTDF.java | 66 +++- ...DialogSysCAMSExecutableCodeGeneration.java | 287 ++++++++++++------ .../java/ui/window/JDialogSysCAMSPortDE.java | 16 +- 28 files changed, 687 insertions(+), 351 deletions(-) rename src/main/java/syscamstranslator/toSysCAMSCluster/{Header.java => HeaderCluster.java} (97%) rename src/main/java/syscamstranslator/{toSysCAMS_rodrigo/MakefileCodeRodrigo.java => toSysCAMSCluster/MakefileCodeCluster.java} (95%) rename src/main/java/syscamstranslator/toSysCAMSCluster/{PrimitiveCode.java => PrimitiveCodeCluster.java} (91%) rename src/main/java/syscamstranslator/{toSysCAMS_rodrigo/ClusterCodeRodrigo.java => toSysCAMSSoclib/ClusterCodeSoclib.java} (96%) rename src/main/java/syscamstranslator/{toSysCAMS_rodrigo/HeaderRodrigo.java => toSysCAMSSoclib/HeaderSoclib.java} (97%) rename src/main/java/syscamstranslator/{toSysCAMSCluster/MakefileCode.java => toSysCAMSSoclib/MakefileSoclibCode.java} (96%) rename src/main/java/syscamstranslator/{toSysCAMS_rodrigo/PrimitiveCodeRodrigo.java => toSysCAMSSoclib/PrimitiveCodeSoclib.java} (95%) rename src/main/java/syscamstranslator/{toSysCAMS_rodrigo/TopCellGeneratorRodrigo.java => toSysCAMSSoclib/TopCellGeneratorSoclib.java} (64%) mode change 100644 => 100755 src/main/java/ui/TGConnector.java diff --git a/MPSoC/Makefile.forsoclib b/MPSoC/Makefile.forsoclib index a7abb1e606..2950db6fd0 100755 --- a/MPSoC/Makefile.forsoclib +++ b/MPSoC/Makefile.forsoclib @@ -18,8 +18,8 @@ updateruntime: cp mutekh/libmwmr/include/mwmr/mwmr.h mutekh/examples/avatar cp mutekh/libsyscams/*.c mutekh/examples/avatar cp mutekh/libsyscams/*.h mutekh/examples/avatar - cp src/*.c ~/TTool/MPSoC/mutekh/examples/avatar - cp src/*.h ~/TTool/MPSoC/mutekh/examples/avatar + cp src/*.c mutekh/examples/avatar + cp src/*.h mutekh/examples/avatar updategeneratedcode: diff --git a/src/main/java/syscamstranslator/SysCAMSSpecification.java b/src/main/java/syscamstranslator/SysCAMSSpecification.java index 6f214d7749..6003750dc6 100644 --- a/src/main/java/syscamstranslator/SysCAMSSpecification.java +++ b/src/main/java/syscamstranslator/SysCAMSSpecification.java @@ -91,6 +91,7 @@ public class SysCAMSSpecification{ for (SysCAMSTComponent blockGPIO2VCI : components) { if (blockGPIO2VCI instanceof SysCAMSTBlockGPIO2VCI) { blocksGPIO2VCI.add((SysCAMSTBlockGPIO2VCI) blockGPIO2VCI); + //System.out.println("@@@@@GPIO block found in spec"); } } return blocksGPIO2VCI; @@ -238,6 +239,14 @@ public class SysCAMSSpecification{ } return cons; } + + public LinkedList<SysCAMSTConnector> getAllConnectors(){ + LinkedList<SysCAMSTConnector> cons = new LinkedList<SysCAMSTConnector>(); + for (SysCAMSTConnector con : connectors) { + cons.add(con); + } + return cons; + } public int getNbBlockTDF(){ return (getAllBlockTDF()).size(); diff --git a/src/main/java/syscamstranslator/SysCAMSTBlockDE.java b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java index dba0be54f7..ea5bc82260 100644 --- a/src/main/java/syscamstranslator/SysCAMSTBlockDE.java +++ b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java @@ -59,13 +59,14 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent { private DefaultListModel<String> listStruct; private String nameTemplate; private String typeTemplate; + private String valueTemplate; private DefaultListModel<String> listTypedef; private SysCAMSTCluster cluster; private LinkedList<SysCAMSTPortDE> portDE; - public SysCAMSTBlockDE(String _name, String _nameFn, String _code, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) { + public SysCAMSTBlockDE(String _name, String _nameFn, String _code, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) { name = _name; // period = _period; // time = _time; @@ -74,6 +75,7 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent { listStruct = _listStruct; nameTemplate = _nameTemplate; typeTemplate = _typeTemplate; + valueTemplate = _valueTemplate; listTypedef = _listTypedef; cluster = _cluster; portDE = new LinkedList<SysCAMSTPortDE>(); @@ -110,6 +112,10 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent { public String getTypeTemplate() { return typeTemplate; } + + public String getValueTemplate() { + return valueTemplate; + } public DefaultListModel<String> getListTypedef() { return listTypedef; @@ -126,4 +132,4 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent { public void addPortDE(SysCAMSTPortDE de){ portDE.add(de); } -} \ No newline at end of file +} diff --git a/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java b/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java index 6b59d50f50..083bb78420 100644 --- a/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java +++ b/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java @@ -57,9 +57,11 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { private double period; private String time; private String processCode; + private String constructorCode; private DefaultListModel<String> listStruct; private String nameTemplate; private String typeTemplate; + private String valueTemplate; private DefaultListModel<String> listTypedef; private SysCAMSTCluster cluster; @@ -67,21 +69,25 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { private LinkedList<SysCAMSTPortTDF> portTDF; private LinkedList<SysCAMSTPortConverter> portConverter; private SysCAMSTPortConverter localPortConverter; + private LinkedList<SysCAMSTPortConverter> localPortConverterList; private int n; private boolean isTimestepPropagated; - public SysCAMSTBlockTDF(String _name, double _period, String _time, String _processCode, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) { + public SysCAMSTBlockTDF(String _name, double _period, String _time, String _processCode, String _constructorCode, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) { name = _name; period = _period; time = _time; processCode = _processCode; + constructorCode = _constructorCode; listStruct = _listStruct; nameTemplate = _nameTemplate; typeTemplate = _typeTemplate; + valueTemplate = _valueTemplate; listTypedef = _listTypedef; cluster = _cluster; portTDF = new LinkedList<SysCAMSTPortTDF>(); portConverter = new LinkedList<SysCAMSTPortConverter>(); + localPortConverterList = new LinkedList<SysCAMSTPortConverter>(); n = 0; isTimestepPropagated = false; } @@ -105,6 +111,10 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { public String getProcessCode() { return processCode; } + + public String getConstructorCode() { + return constructorCode; + } public DefaultListModel<String> getListStruct() { return listStruct; @@ -117,6 +127,10 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { public String getTypeTemplate() { return typeTemplate; } + + public String getValueTemplate() { + return valueTemplate; + } public DefaultListModel<String> getListTypedef() { return listTypedef; @@ -153,8 +167,19 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { public void syncTDFBlockDEBlock(double[] time_prev) throws SysCAMSValidateException { double tp; try{ + //Order list to have input converter ports first, in case of multirate-multiport single-modules + localPortConverterList.clear(); for(int i = 0; i < portConverter.size(); i++) { localPortConverter = portConverter.get(i); + if(localPortConverter.getOrigin() == 0) { //Input + localPortConverterList.addFirst(localPortConverter); + } else if (localPortConverter.getOrigin() == 1) { //Output + localPortConverterList.addLast(localPortConverter); + } + } + + for(int i = 0; i < localPortConverterList.size(); i++) { + localPortConverter = localPortConverterList.get(i); if(localPortConverter.getOrigin() == 0) { //Input check_causality_in(time_prev); } else if (localPortConverter.getOrigin() == 1) { //Output @@ -169,8 +194,7 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { } private void check_causality_in(double[] time_prev_max) throws SysCAMSValidateException { - double time_now_min_tdf, time_now_max_tdf, time_tmp_tdf, time_tmp_de, - time_now_min_de, time_now_max_de; + double time_now_max_de; double tm = 0.0; double tp = 0.0; int r = 1; @@ -185,41 +209,22 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { if(localPortConverter.getDelay() > 0) d = localPortConverter.getDelay(); - time_now_min_tdf = (n*tm)+((k-1)*tp); - time_now_max_tdf = (n*tm)+((k-1)*tp); - time_now_min_de = (n*tm)+((k-1)*tp)-(d*tp); - time_now_max_de = (n*tm)+((k-1)*tp)-(d*tp); - - for (k = 1; k <= r; k++) { - time_tmp_tdf = (n*tm)+((k-1)*tp); - time_tmp_de = (n*tm)+((k-1)*tp)-(d*tp); - System.out.println("tmstmp_in_tdf: " + time_tmp_tdf); - System.out.println("tmstmp_in_de: " + time_tmp_de); - time_now_min_tdf = Math.min(time_tmp_tdf, time_now_min_tdf); - time_now_max_tdf = Math.max(time_tmp_tdf, time_now_max_tdf); - time_now_min_de = Math.min(time_tmp_de, time_now_min_de); - time_now_max_de = Math.max(time_tmp_de, time_now_max_de); - System.out.println("time_now_min_de: " + time_now_min_de); - System.out.println("time_now_max_de: " + time_now_max_de); - System.out.println("time_now_min_tdf: " + time_now_min_tdf); - System.out.println("time_now_max_tdf: " + time_now_max_tdf); - } + time_now_max_de = (n*tm)+((r-1)*tp)-(d*tp); - System.out.println("time_prev_max_out: " + time_prev_max[1]); - if(time_now_min_tdf < time_prev_max[1]) { - localPortConverter.setDelay((int)Math.ceil((time_prev_max[1]-time_now_min_de)/tp) + d); + + /*if(time_now_min_tdf2 < time_prev_max[1]) { + localPortConverter.setDelay((int)Math.ceil((time_prev_max[1]-time_now_min_tdf2)/tp) + d); localPortConverter.setRecompute(true); throw new SysCAMSValidateException("Timestamp of previous write port executed module is: " + time_prev_max[1] + " and current timestamp is: " + time_now_min_tdf + ".\n" - + "Suggested delay in port \"" + localPortConverter.getName() + "\": " + (Math.ceil((time_prev_max[1]-time_now_min_tdf)/tp) + d)); - } + + "Suggested delay in port \"" + localPortConverter.getName() + "\" using time_now_min_tdf: " + (Math.ceil((time_prev_max[1]-time_now_min_tdf)/tp) + d) + + " and using time_now_min_de: " + (Math.ceil((time_prev_max[1]-time_now_min_de)/tp) + d)); + }*/ time_prev_max[0] = Double.valueOf(Math.max(time_prev_max[0],time_now_max_de)); - System.out.println("New time_prev_max_in: " + time_prev_max[0]); } private void check_causality_out(double[] time_prev_max) throws SysCAMSValidateException { - double time_now_min_tdf, time_now_max_tdf, time_tmp_tdf, time_tmp_de, - time_now_min_de, time_now_max_de; + double time_now_min_tdf, time_now_max_de2; double tm = 0.0; double tp = 0.0; int r = 1; @@ -234,36 +239,19 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent { if(localPortConverter.getDelay() > 0) d = localPortConverter.getDelay(); - time_now_min_tdf = (n*tm)+((k-1)*tp); - time_now_max_tdf = (n*tm)+((k-1)*tp); - time_now_min_de = (n*tm)+((k-1)*tp)+(d*tp); - time_now_max_de = (n*tm)+((k-1)*tp)+(d*tp); + time_now_min_tdf = (n*tm)+((1-1)*tp)+(d*tp); + + time_now_max_de2 = (n*tm)+((r-1)*tp)-(d*tp); - for (k = 1; k <= r; k++) { - time_tmp_tdf = (n*tm)+((k-1)*tp); - time_tmp_de = (n*tm)+((k-1)*tp)+(d*tp);; - System.out.println("tmstmp_out_tdf: " + time_tmp_tdf); - System.out.println("tmstmp_out_de: " + time_tmp_de); - time_now_min_tdf = Math.min(time_tmp_tdf, time_now_min_tdf); - time_now_max_tdf = Math.max(time_tmp_tdf, time_now_max_tdf); - time_now_min_de = Math.min(time_tmp_de, time_now_min_de); - time_now_max_de = Math.max(time_tmp_de, time_now_max_de); - System.out.println("time_now_min_de: " + time_now_min_de); - System.out.println("time_now_max_de: " + time_now_max_de); - System.out.println("time_now_min_tdf: " + time_now_min_tdf); - System.out.println("time_now_max_tdf: " + time_now_max_tdf); - } - System.out.println("time_prev_max_in: " + time_prev_max[0]); - if(time_now_min_de < time_prev_max[0]) { - localPortConverter.setDelay((int)Math.ceil((time_prev_max[0]-time_now_min_de)/tp) + d); + if(time_now_min_tdf < time_prev_max[0]) { + localPortConverter.setDelay((int)Math.ceil((time_prev_max[0]-time_now_min_tdf)/tp) + d); localPortConverter.setRecompute(true); throw new SysCAMSValidateException("Timestamp of previous read port executed module is: " + time_prev_max[0] - + " and current timestamp is: " + time_now_min_de + ".\n" - + "Suggested delay in port " + localPortConverter.getName() + ": " + (Math.ceil((time_prev_max[0]-time_now_min_de)/tp) + d)); + + " and current timestamp is: " + time_now_min_tdf + ".\n" + + "Suggested delay in port " + localPortConverter.getName() + ": " + (Math.ceil((time_prev_max[0]-time_now_min_tdf)/tp) + d)); } - time_prev_max[1] = Double.valueOf(Math.max(time_prev_max[1],time_now_max_tdf)); - System.out.println("New time_prev_max_out: " + time_prev_max[1]); + time_prev_max[1] = Double.valueOf(Math.max(time_prev_max[1],time_now_max_de2)); } public void setN(int _n) { diff --git a/src/main/java/syscamstranslator/SysCAMSTPortTDF.java b/src/main/java/syscamstranslator/SysCAMSTPortTDF.java index ef12060e83..48e3ab275e 100644 --- a/src/main/java/syscamstranslator/SysCAMSTPortTDF.java +++ b/src/main/java/syscamstranslator/SysCAMSTPortTDF.java @@ -58,6 +58,7 @@ public class SysCAMSTPortTDF extends SysCAMSTComponent { private int delay; private int origin; private String TDFType; + private boolean recompute; private SysCAMSTBlockTDF blockTDF; private ELNTCluster cluster; @@ -71,6 +72,7 @@ public class SysCAMSTPortTDF extends SysCAMSTComponent { delay = _delay; origin = _origin; TDFType = _TDFType; + recompute = false; blockTDF = _blockTDF; } @@ -127,6 +129,14 @@ public class SysCAMSTPortTDF extends SysCAMSTComponent { public void setDelay(int _delay) { delay = _delay; } + + public boolean getRecompute() { + return recompute; + } + + public void setRecompute(boolean _recompute) { + recompute = _recompute; + } public int getOrigin() { return origin; diff --git a/src/main/java/syscamstranslator/toSysCAMS/Header.java b/src/main/java/syscamstranslator/toSysCAMS/Header.java index 6a08a46d7c..c5a1479264 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/Header.java +++ b/src/main/java/syscamstranslator/toSysCAMS/Header.java @@ -104,4 +104,4 @@ public class Header { } return headerCluster; } -} \ No newline at end of file +} diff --git a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java index 595b6121ee..03552b4092 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java @@ -370,7 +370,7 @@ public class PrimitiveCode { } } } - corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_H"; + corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_H"; } else { corpsPrimitiveTDF = ""; } @@ -596,10 +596,10 @@ public class PrimitiveCode { String pc = buffer.toString(); corpsPrimitiveDE = corpsPrimitiveDE + "\t" + pc; - corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_H"; + corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_H"; } else { corpsPrimitiveDE = ""; } return corpsPrimitiveDE; } -} \ No newline at end of file +} diff --git a/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java b/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java index 07a99113fb..7bb2dc6ebe 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java +++ b/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java @@ -63,6 +63,8 @@ public class TopCellGenerator { private final static String GENERATED_PATH1 = "generated_CPP" + File.separator; private final static String GENERATED_PATH2 = "generated_H" + File.separator; + private final static String CR = "\n"; + private final static String CR2 = "\n\n"; public TopCellGenerator(SysCAMSSpecification sys) { syscams = sys; @@ -94,40 +96,57 @@ public class TopCellGenerator { return (top); } - public void saveFile(String path) { + public void saveFile(String path, Boolean standalone) { SysCAMSTCluster cluster = TopCellGenerator.syscams.getCluster(); LinkedList<SysCAMSTConnector> connectors = TopCellGenerator.syscams.getAllConnectorCluster(); - + FileWriter fw; String top; try { // Save file .cpp System.err.println(path + GENERATED_PATH1 + cluster.getClusterName() + ".cpp"); - FileWriter fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tb.cpp"); + System.err.println(path + cluster.getClusterName() + ".cpp"); + if(standalone==true){ + //System.out.println("@@@@ topcell standalone @@@@"); + fw = new FileWriter(path + "/" + cluster.getClusterName() + "_tb.cpp");} + else{ + fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tb.cpp"); + } + fw = new FileWriter(path + "/" + cluster.getClusterName() + "_tb.cpp"); top = generateTopCell(cluster, connectors); fw.write(top); fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } // Save files .h - saveFileBlock(path, cluster); + saveFileBlock(path, cluster, standalone); } - public void saveFileBlock(String path, SysCAMSTCluster c) { + public void saveFileBlock(String path, SysCAMSTCluster c, Boolean standalone) { String headerTDF, headerDE, codeTDF, codeDE; LinkedList<SysCAMSTBlockTDF> tdf = c.getBlockTDF(); LinkedList<SysCAMSTBlockDE> de = c.getBlockDE(); - + FileWriter fw; for (SysCAMSTBlockTDF t : tdf) { try { System.err.println(path + GENERATED_PATH2 + t.getName() + ".h"); - FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h"); + System.err.println(path + t.getName() + ".h"); + if(standalone==true){ + //System.out.println("@@@@ TDF standalone @@@@"); + fw = new FileWriter(path + "/" + t.getName() + ".h");} + else + fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h"); + headerTDF = Header.getPrimitiveHeaderTDF(t); fw.write(headerTDF); codeTDF = PrimitiveCode.getPrimitiveCodeTDF(t); + // if(standalone==false) + // codeTDF = codeTDF + CR + "};" + CR2 + "#endif"; fw.write(codeTDF); fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } @@ -135,12 +154,21 @@ public class TopCellGenerator { for (SysCAMSTBlockDE t : de) { try { System.err.println(path + GENERATED_PATH2 + t.getName() + ".h"); - FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h"); + System.err.println(path + t.getName() + ".h");//ajoute DG + + if(standalone==true){ + //System.out.println("@@@@ DE standalone @@@@"); + fw = new FileWriter(path + "/" + t.getName() + ".h");} + else + fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h"); headerDE = Header.getPrimitiveHeaderDE(t); fw.write(headerDE); codeDE = PrimitiveCode.getPrimitiveCodeDE(t); + // if(standalone==false) + // codeDE = codeDE + CR + "};" + CR2 + "#endif";//DG fw.write(codeDE); fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } diff --git a/src/main/java/syscamstranslator/toSysCAMSCluster/ClusterCode.java b/src/main/java/syscamstranslator/toSysCAMSCluster/ClusterCode.java index d76cc5ddce..cd066c181f 100644 --- a/src/main/java/syscamstranslator/toSysCAMSCluster/ClusterCode.java +++ b/src/main/java/syscamstranslator/toSysCAMSCluster/ClusterCode.java @@ -69,39 +69,42 @@ public class ClusterCode { LinkedList<SysCAMSTBlockTDF> tdf = cluster.getBlockTDF(); LinkedList<SysCAMSTBlockDE> de = cluster.getBlockDE(); - System.out.println("Number of AMS connectors: " + connectors.size()); corpsCluster = "template <typename vci_param>" + CR + "class " +cluster.getClusterName()+ " : public sc_core::sc_module { "+ CR; + + for (SysCAMSTBlockTDF t : tdf) { + if (!t.getListTypedef().isEmpty()) { + for (int i = 0; i < t.getListTypedef().getSize(); i++) { + String select = t.getListTypedef().get(i); + String[] split = select.split(" : "); + corpsCluster = corpsCluster + "\ttypedef " + split[1] + "<"+ t.getValueTemplate() +"> " + split[0] + ";" + CR; + } + } + } + + for (SysCAMSTBlockDE t : de) { + if (!t.getListTypedef().isEmpty()) { + for (int i = 0; i < t.getListTypedef().getSize(); i++) { + String select = t.getListTypedef().get(i); + String[] split = select.split(" : "); + corpsCluster = corpsCluster + "\ttypedef " + split[1] + "<"+ t.getValueTemplate() +"> " + split[0] + ";" + CR; + } + } + } - corpsCluster = corpsCluster + "\t// Declare signals to interconnect." + CR; + corpsCluster = corpsCluster + CR + "\t// Declare signals to interconnect." + CR; - //for (SysCAMSTConnector c : connectors) { for (int i = 0; i < connectors.size(); i++) { nb_con = i; if ( !((connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockGPIO2VCI() != null) || (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockGPIO2VCI() != null)) ) { - /*if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortTDF) { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getTDFType() + "> " - + "sig_" + nb_con + ";" + CR; - //nb_con++; - } else if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter) { - corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getConvType() + "> " - + "sig_" + nb_con + ";" + CR; - //nb_con++; - } else if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { - corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getDEType() + "> " - + "sig_" + nb_con + ";" + CR; - //nb_con++; - }*/ - if ((connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortTDF && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortTDF) || (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortTDF && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortTDF)) { if (connectors.get(i).getName().equals("")) { corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getTDFType() + "> " + "sig_" + nb_con + ";" + CR; names.add("sig_" + nb_con); - //nb_con++; } else { corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getTDFType() + "> " + connectors.get(i).getName() + ";" + CR; @@ -112,7 +115,6 @@ public class ClusterCode { corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getConvType() + "> " + "sig_" + nb_con + ";" + CR; names.add("sig_" + nb_con); - //nb_con++; } else { corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getConvType() + "> " + connectors.get(i).getName() + ";" + CR; @@ -123,7 +125,6 @@ public class ClusterCode { corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getConvType() + "> " + "sig_" + nb_con + ";" + CR; names.add("sig_" + nb_con); - //nb_con++; } else { corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getConvType() + "> " + connectors.get(i).getName() + ";" + CR; @@ -135,7 +136,6 @@ public class ClusterCode { corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getDEType() + "> " + "sig_" + nb_con + ";" + CR; names.add("sig_" + nb_con); - //nb_con++; } else { corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getDEType() + "> " + connectors.get(i).getName() + ";" + CR; @@ -150,14 +150,20 @@ public class ClusterCode { corpsCluster = corpsCluster + CR + "\t// Instantiate cluster's modules." + CR; for (SysCAMSTBlockTDF t : tdf) { - corpsCluster = corpsCluster + "\t" + t.getName() + " " + - t.getName() + "_" + nb_block + ";" + CR; + corpsCluster = corpsCluster + "\t" + t.getName(); + if (!t.getListTypedef().isEmpty()) { + corpsCluster += "<"+t.getValueTemplate()+">"; + } + corpsCluster += " " + t.getName() + "_" + nb_block + ";" + CR; nb_block++; } for (SysCAMSTBlockDE t : de) { - corpsCluster = corpsCluster + "\t" + t.getName() + " " + - t.getName() + "_" + nb_block + ";" + CR; + corpsCluster = corpsCluster + "\t" + t.getName(); + if (!t.getListTypedef().isEmpty()) { + corpsCluster += "<"+t.getValueTemplate()+">"; + } + corpsCluster += " " + t.getName() + "_" + nb_block + ";" + CR; nb_block++; } @@ -244,33 +250,40 @@ public class ClusterCode { for (SysCAMSTPortDE p : portDE) { for (int i = 0; i < connectors.size(); i++) { - /*nb_con = i; - if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { - if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + "sig_" + nb_con + ");" + CR; - } - } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { - if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + "sig_" + nb_con + ");" + CR; - } - }*/ - if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { - if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; - } else if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; - } - } else if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { - if (((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; - } else if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + if ( !((connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockGPIO2VCI() != null) + || (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockGPIO2VCI() != null)) ) { + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } + } else if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } + } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } } - } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { - if (((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; - } else if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else { + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockGPIO2VCI() != null) { + if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(in_ams);" + CR; + } + } + } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockGPIO2VCI() != null) { + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(out_ams);" + CR; + } + } } } } @@ -281,23 +294,18 @@ public class ClusterCode { corpsCluster = corpsCluster + "\t}" + CR2; - /*corpsCluster = corpsCluster + "\t// Configure signal tracing." + CR - + "\tsca_trace_file* tfp = sca_create_tabular_trace_file(\"" + cluster.getClusterName() + "_tb\");" + CR; - - nb_con = 0; + corpsCluster = corpsCluster + "\t// Configure signal tracing." + CR; + corpsCluster += "\tvoid trace_" + cluster.getClusterName() +"(sca_util::sca_trace_file* tf) {" + CR; for (int i = 0; i < connectors.size(); i++) { if ( !((connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockGPIO2VCI() != null) - || (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockGPIO2VCI() != null)) ) { - corpsCluster = corpsCluster + "\tsca_trace(tfp, "+ "sig_" + nb_con + ", \"" + "sig_" + nb_con + "\");" + CR; - nb_con++; + || (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockGPIO2VCI() != null)) ) { + corpsCluster += "\t\tsca_trace(tf, "+ names.get(i) + ", \"" + names.get(i) + "\");" + CR; } } - corpsCluster = corpsCluster + CR + "\t// Close trace file and stop simulation to enable clean-up by" + CR - + "\t// asking SystemC to execute all end_of_simulation() callbacks." + CR - + "\tsca_close_tabular_trace_file(tfp);" + CR; - */ + corpsCluster += "\t}" +CR; + corpsCluster = corpsCluster + "};" + CR2; - corpsCluster = corpsCluster + "#endif // " + cluster.getClusterName().toUpperCase() + "_TDF_H"+ CR; + // corpsCluster = corpsCluster + "#endif // " + cluster.getClusterName().toUpperCase() + "_TDF_H"+ CR;//DG } else { corpsCluster = ""; } diff --git a/src/main/java/syscamstranslator/toSysCAMSCluster/Header.java b/src/main/java/syscamstranslator/toSysCAMSCluster/HeaderCluster.java similarity index 97% rename from src/main/java/syscamstranslator/toSysCAMSCluster/Header.java rename to src/main/java/syscamstranslator/toSysCAMSCluster/HeaderCluster.java index ba78e5bef3..a5f7b5b97c 100644 --- a/src/main/java/syscamstranslator/toSysCAMSCluster/Header.java +++ b/src/main/java/syscamstranslator/toSysCAMSCluster/HeaderCluster.java @@ -45,8 +45,8 @@ import java.util.LinkedList; import syscamstranslator.*; /** - * Class Header - * Header of files .h and .cpp + * Class HeaderCluster + * HeaderCluster of files .h and .cpp * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE @@ -54,7 +54,7 @@ import syscamstranslator.*; * @author Rodrigo CORTES PORTO */ -public class Header { +public class HeaderCluster { static private String headerPrimitiveTDF; static private String headerPrimitiveDE; static private String headerCluster; @@ -62,7 +62,7 @@ public class Header { private final static String CR = "\n"; private final static String CR2 = "\n\n"; - Header() {} + HeaderCluster() {} public static String getPrimitiveHeaderTDF(SysCAMSTBlockTDF tdf) { if (tdf != null) { @@ -107,4 +107,4 @@ public class Header { } return headerCluster; } -} \ No newline at end of file +} diff --git a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/MakefileCodeRodrigo.java b/src/main/java/syscamstranslator/toSysCAMSCluster/MakefileCodeCluster.java similarity index 95% rename from src/main/java/syscamstranslator/toSysCAMS_rodrigo/MakefileCodeRodrigo.java rename to src/main/java/syscamstranslator/toSysCAMSCluster/MakefileCodeCluster.java index 0482f7b278..2d11f97b0b 100644 --- a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/MakefileCodeRodrigo.java +++ b/src/main/java/syscamstranslator/toSysCAMSCluster/MakefileCodeCluster.java @@ -50,21 +50,21 @@ import java.util.LinkedList; import syscamstranslator.*; /** - * Class MakefileCodeRodrigo Principal code of a makefile Creation: 02/06/2018 + * Class MakefileCodeCluster Principal code of a makefile Creation: 02/06/2018 * * @version 1.0 02/06/2018 * @author Irina Kit Yan LEE */ -public class MakefileCodeRodrigo { +public class MakefileCodeCluster { static private String corpsMakefile; private final static String CR = "\n"; private final static String CR2 = "\n\n"; - MakefileCodeRodrigo() { + MakefileCodeCluster() { } - public static String getMakefileCodeRodrigo(LinkedList<SysCAMSTCluster> clusters) { + public static String getMakefileCode(LinkedList<SysCAMSTCluster> clusters) { if (clusters != null) { corpsMakefile = "# Compiler and linker flags" + CR + "CXXFLAGS = -g -Wall -I. $(SYSTEMC_INCLUDE_DIRS)" + CR + "LDFLAGS = $(SYSTEMC_LIBRARY_DIRS)" + CR2 + "# List of all ecutables to be compiled" + CR diff --git a/src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCode.java b/src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCodeCluster.java similarity index 91% rename from src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCode.java rename to src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCodeCluster.java index b5bc316143..e8a1b1e4f9 100644 --- a/src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCode.java +++ b/src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCodeCluster.java @@ -50,20 +50,20 @@ import java.util.LinkedList; import syscamstranslator.*; /** - * Class PrimitiveCode + * Class PrimitiveCodeCluster * Principal code of a primive component * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE */ -public class PrimitiveCode { +public class PrimitiveCodeCluster { static private String corpsPrimitiveTDF; static private String corpsPrimitiveDE; private final static String CR = "\n"; private final static String CR2 = "\n\n"; - PrimitiveCode() {} + PrimitiveCodeCluster() {} public static String getPrimitiveCodeTDF(SysCAMSTBlockTDF tdf) { corpsPrimitiveTDF = ""; @@ -127,14 +127,12 @@ public class PrimitiveCode { if (i == 0) { corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t: " + identifier + "(" + value + ")" + CR; } - if ((i > 0) && (i < tdf.getListStruct().getSize()-1)) { + if ((i > 0)) { corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR; } - if (i == tdf.getListStruct().getSize()-1 && i != 0) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR + "\t\t{}" + CR; - } else { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR; - } + if (i == tdf.getListStruct().getSize()-1) { + corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR; + } } corpsPrimitiveTDF = corpsPrimitiveTDF + "\t};" + CR2; } @@ -218,8 +216,9 @@ public class PrimitiveCode { } } } - corpsPrimitiveTDF = corpsPrimitiveTDF + "\t{}" + CR2 + "protected:" + CR; } + String ctorcode = tdf.getConstructorCode(); + corpsPrimitiveTDF = corpsPrimitiveTDF + "\t{\n"+ctorcode+"\n\t}" + CR2 + "protected:" + CR; if (tdf.getPeriod() != -1) { corpsPrimitiveTDF = corpsPrimitiveTDF + "\tvoid set_attributes() {" + CR + "\t\t" + "set_timestep(" + tdf.getPeriod() + ", sc_core::SC_" + tdf.getTime().toUpperCase() + ");" + CR; @@ -370,7 +369,7 @@ public class PrimitiveCode { } } } - corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_TDF_H"; + corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_TDF_H"; } else { corpsPrimitiveTDF = ""; } @@ -389,7 +388,7 @@ public class PrimitiveCode { corpsPrimitiveDE = corpsPrimitiveDE + "template<" + de.getTypeTemplate() + " " + de.getNameTemplate() + ">" + CR; } //corpsPrimitive = "SCA_TDF_MODULE(" + de.getName() + ") {" + CR2; - corpsPrimitiveDE = corpsPrimitiveDE + "class " + de.getName() + " : public sca_core::sca_module {" + CR2 + "public:" + CR; + corpsPrimitiveDE = corpsPrimitiveDE + "class " + de.getName() + " : public sc_core::sc_module {" + CR2 + "public:" + CR; if (!de.getListTypedef().isEmpty()) { for (int i = 0; i < de.getListTypedef().getSize(); i++) { @@ -438,14 +437,12 @@ public class PrimitiveCode { if (i == 0) { corpsPrimitiveDE = corpsPrimitiveDE + "\t\t: " + identifier + "(" + value + ")" + CR; } - if ((i > 0) && (i < de.getListStruct().getSize()-1)) { + if ((i > 0)) { corpsPrimitiveDE = corpsPrimitiveDE + "\t\t, " + identifier + "(" + value + ")" + CR; } - if (i == de.getListStruct().getSize()-1 && i != 0) { - corpsPrimitiveDE = corpsPrimitiveDE + "\t\t, " + identifier + "(" + value + ")" + CR + "\t\t{}" + CR; - } else { - corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR; - } + if (i == de.getListStruct().getSize()-1) { + corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR; + } } corpsPrimitiveDE = corpsPrimitiveDE + "\t};" + CR2; } @@ -453,9 +450,9 @@ public class PrimitiveCode { if (!deports.isEmpty()) { for (SysCAMSTPortDE t : deports) { if (t.getOrigin() == 0) { - corpsPrimitiveDE = corpsPrimitiveDE + "\tsca_core::sca_in<" + t.getDEType() + "> " + t.getName() + ";" + CR; + corpsPrimitiveDE = corpsPrimitiveDE + "\tsc_core::sc_in< " + t.getDEType() + " > " + t.getName() + ";" + CR; } else if (t.getOrigin() == 1) { - corpsPrimitiveDE = corpsPrimitiveDE + "\tsca_core::sca_out<" + t.getDEType() + "> " + t.getName() + ";" + CR; + corpsPrimitiveDE = corpsPrimitiveDE + "\tsc_core::sc_out< " + t.getDEType() + " > " + t.getName() + ";" + CR; } } } @@ -518,12 +515,14 @@ public class PrimitiveCode { if (method == false) { corpsPrimitiveDE = corpsPrimitiveDE + "\t{" + CR; } - corpsPrimitiveDE = corpsPrimitiveDE + "\t\tsensitive << " + t.getName() + "."; + corpsPrimitiveDE = corpsPrimitiveDE + "\t\tsensitive << " + t.getName(); if (t.getSensitiveMethod().equals("positive")) { - corpsPrimitiveDE = corpsPrimitiveDE + "pos();" + CR; + corpsPrimitiveDE = corpsPrimitiveDE + ".pos();" + CR; } else if (t.getSensitiveMethod().equals("negative")) { - corpsPrimitiveDE = corpsPrimitiveDE + "neg();" + CR; - } + corpsPrimitiveDE = corpsPrimitiveDE + ".neg();" + CR; + } else if (t.getSensitiveMethod().equals("")) { + corpsPrimitiveDE = corpsPrimitiveDE + ";" + CR; + } sensitive = true; } } @@ -596,10 +595,10 @@ public class PrimitiveCode { String pc = buffer.toString(); corpsPrimitiveDE = corpsPrimitiveDE + "\t" + pc; - corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_TDF_H"; + corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_TDF_H"; } else { corpsPrimitiveDE = ""; } return corpsPrimitiveDE; } -} \ No newline at end of file +} diff --git a/src/main/java/syscamstranslator/toSysCAMSCluster/TopCellGeneratorCluster.java b/src/main/java/syscamstranslator/toSysCAMSCluster/TopCellGeneratorCluster.java index ccdc017d7b..949e6b4f0f 100644 --- a/src/main/java/syscamstranslator/toSysCAMSCluster/TopCellGeneratorCluster.java +++ b/src/main/java/syscamstranslator/toSysCAMSCluster/TopCellGeneratorCluster.java @@ -66,6 +66,9 @@ public class TopCellGeneratorCluster { private final static String GENERATED_PATH1 = "generated_CPP" + File.separator; private final static String GENERATED_PATH2 = "generated_H" + File.separator; + private final static String CR = "\n"; + private final static String CR2 = "\n\n"; + public TopCellGeneratorCluster(SysCAMSSpecification sys) { syscams = sys; } @@ -74,7 +77,7 @@ public class TopCellGeneratorCluster { if (c == null) { System.out.println("***Warning: require at least one cluster***"); } - if (TopCellGeneratorCluster.syscams.getNbBlockTDF() == 0) { + /*if (TopCellGeneratorCluster.syscams.getNbBlockTDF() == 0) { System.out.println("***Warning: require at least one TDF block***"); } if (TopCellGeneratorCluster.syscams.getNbPortTDF() == 0) { @@ -91,58 +94,89 @@ public class TopCellGeneratorCluster { } if (TopCellGeneratorCluster.syscams.getNbConnectorCluster() == 0) { System.out.println("***Warning: require at least one connector***"); - } - String top = Header.getClusterHeader(c) + ClusterCode.getClusterCode(c, connectors); + }*/ + String top = HeaderCluster.getClusterHeader(c) + ClusterCode.getClusterCode(c, connectors); return (top); } - public void saveFile(String path) { + public void saveFile(String path, Boolean standalone) { SysCAMSTCluster cluster = TopCellGeneratorCluster.syscams.getCluster(); - LinkedList<SysCAMSTConnector> connectors = TopCellGeneratorCluster.syscams.getAllConnectorsCluster4Soclib(); - + LinkedList<SysCAMSTConnector> connectors = TopCellGeneratorCluster.syscams.getAllConnectors(); + FileWriter fw; String top; try { // Save file .cpp System.err.println(path + GENERATED_PATH1 + cluster.getClusterName() + "_tdf.h"); - FileWriter fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tdf.h"); + System.err.println(path + cluster.getClusterName() + "_tdf.h"); + if(standalone==true){ + //System.out.println("@@@ Cluster standalone"); + fw = new FileWriter(path + cluster.getClusterName() + "_tdf.h"); + } + else + fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tdf.h"); + top = generateTopCell(cluster, connectors); fw.write(top); fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } // Save files .h - saveFileBlock(path, cluster); + saveFileBlock(path, cluster, standalone); } - public void saveFileBlock(String path, SysCAMSTCluster c) { + public void saveFileBlock(String path, SysCAMSTCluster c, Boolean standalone) { String headerTDF, headerDE, codeTDF, codeDE; LinkedList<SysCAMSTBlockTDF> tdf = c.getBlockTDF(); LinkedList<SysCAMSTBlockDE> de = c.getBlockDE(); + + FileWriter fw; for (SysCAMSTBlockTDF t : tdf) { try { System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); - FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); - headerTDF = Header.getPrimitiveHeaderTDF(t); + System.err.println(path + t.getName() + "_tdf.h"); + if(standalone==true){ + //System.out.println("@@@ TDF Cluster standalone"); + fw = new FileWriter(path + "/" + t.getName() + "_tdf.h"); + } + + else + fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); + headerTDF = HeaderCluster.getPrimitiveHeaderTDF(t); fw.write(headerTDF); - codeTDF = PrimitiveCode.getPrimitiveCodeTDF(t); + codeTDF = PrimitiveCodeCluster.getPrimitiveCodeTDF(t); + //if(standalone==false) + // codeTDF = codeTDF + "#endif"+ CR; fw.write(codeTDF); fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } } for (SysCAMSTBlockDE t : de) { try { - System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); - FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); - headerDE = Header.getPrimitiveHeaderDE(t); + System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); + + + if(standalone==true) + { + //System.out.println("@@@ DE Cluster standalone"); + fw = new FileWriter(path +"/" + t.getName() + "_tdf.h");} + else + fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); + + headerDE = HeaderCluster.getPrimitiveHeaderDE(t); fw.write(headerDE); - codeDE = PrimitiveCode.getPrimitiveCodeDE(t); + codeDE = PrimitiveCodeCluster.getPrimitiveCodeDE(t); + //if(standalone==false) + // codeDE = codeDE + "#endif "+ CR; fw.write(codeDE); fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } diff --git a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/ClusterCodeRodrigo.java b/src/main/java/syscamstranslator/toSysCAMSSoclib/ClusterCodeSoclib.java similarity index 96% rename from src/main/java/syscamstranslator/toSysCAMS_rodrigo/ClusterCodeRodrigo.java rename to src/main/java/syscamstranslator/toSysCAMSSoclib/ClusterCodeSoclib.java index fa186bc8d1..adf429f793 100644 --- a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/ClusterCodeRodrigo.java +++ b/src/main/java/syscamstranslator/toSysCAMSSoclib/ClusterCodeSoclib.java @@ -50,19 +50,19 @@ import java.util.LinkedList; import syscamstranslator.*; /** - * Class ClusterCodeRodrigo + * Class ClusterCodeSoclib * Principal code of a cluster component * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE */ -public class ClusterCodeRodrigo { +public class ClusterCodeSoclib { static private String corpsCluster; private final static String CR = "\n"; private final static String CR2 = "\n\n"; - ClusterCodeRodrigo() {} + ClusterCodeSoclib() {} public static String getClusterCode(SysCAMSTCluster cluster, LinkedList<SysCAMSTConnector> connectors) { int nb_con = 0; @@ -227,7 +227,7 @@ public class ClusterCodeRodrigo { + "\tsca_close_tabular_trace_file(tfp);" + CR; */ corpsCluster = corpsCluster + "};" + CR2; - corpsCluster = corpsCluster + "#endif // " + cluster.getClusterName().toUpperCase() + "_TDF_H"+ CR; + // corpsCluster = corpsCluster + "#endif // " + cluster.getClusterName().toUpperCase() + "_TDF_H"+ CR;//DG } else { corpsCluster = ""; } diff --git a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/HeaderRodrigo.java b/src/main/java/syscamstranslator/toSysCAMSSoclib/HeaderSoclib.java similarity index 97% rename from src/main/java/syscamstranslator/toSysCAMS_rodrigo/HeaderRodrigo.java rename to src/main/java/syscamstranslator/toSysCAMSSoclib/HeaderSoclib.java index 84cd9c9519..da5fd35df1 100644 --- a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/HeaderRodrigo.java +++ b/src/main/java/syscamstranslator/toSysCAMSSoclib/HeaderSoclib.java @@ -50,14 +50,14 @@ import java.util.LinkedList; import syscamstranslator.*; /** - * Class HeaderRodrigo - * Header of files .h and .cpp + * Class HeaderSoclib + * HeaderSoclib of files .h and .cpp * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE */ -public class HeaderRodrigo { +public class HeaderSoclib { static private String headerPrimitiveTDF; static private String headerPrimitiveDE; static private String headerCluster; @@ -65,7 +65,7 @@ public class HeaderRodrigo { private final static String CR = "\n"; private final static String CR2 = "\n\n"; - HeaderRodrigo() {} + HeaderSoclib() {} public static String getPrimitiveHeaderTDF(SysCAMSTBlockTDF tdf) { if (tdf != null) { diff --git a/src/main/java/syscamstranslator/toSysCAMSCluster/MakefileCode.java b/src/main/java/syscamstranslator/toSysCAMSSoclib/MakefileSoclibCode.java similarity index 96% rename from src/main/java/syscamstranslator/toSysCAMSCluster/MakefileCode.java rename to src/main/java/syscamstranslator/toSysCAMSSoclib/MakefileSoclibCode.java index e438ff4d5b..50640d57c8 100644 --- a/src/main/java/syscamstranslator/toSysCAMSCluster/MakefileCode.java +++ b/src/main/java/syscamstranslator/toSysCAMSSoclib/MakefileSoclibCode.java @@ -43,25 +43,25 @@ /* authors: v1.0 Raja GATGOUT 2014 v2.0 Daniela GENIUS, Julien HENON 2015 */ -package syscamstranslator.toSysCAMSCluster; +package syscamstranslator.toSysCAMS; import java.util.LinkedList; import syscamstranslator.*; /** - * Class MakefileCode Principal code of a makefile Creation: 02/06/2018 + * Class MakefileSoclibCode Principal code of a makefile Creation: 02/06/2018 * * @version 1.0 02/06/2018 * @author Irina Kit Yan LEE */ -public class MakefileCode { +public class MakefileSoclibCode { static private String corpsMakefile; private final static String CR = "\n"; private final static String CR2 = "\n\n"; - MakefileCode() { + MakefileSoclibCode() { } public static String getMakefileCode(LinkedList<SysCAMSTCluster> clusters) { @@ -110,4 +110,4 @@ public class MakefileCode { } return corpsMakefile; } -} \ No newline at end of file +} diff --git a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/PrimitiveCodeRodrigo.java b/src/main/java/syscamstranslator/toSysCAMSSoclib/PrimitiveCodeSoclib.java similarity index 95% rename from src/main/java/syscamstranslator/toSysCAMS_rodrigo/PrimitiveCodeRodrigo.java rename to src/main/java/syscamstranslator/toSysCAMSSoclib/PrimitiveCodeSoclib.java index ef1f58c8cd..f32342d03a 100644 --- a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/PrimitiveCodeRodrigo.java +++ b/src/main/java/syscamstranslator/toSysCAMSSoclib/PrimitiveCodeSoclib.java @@ -50,20 +50,20 @@ import java.util.LinkedList; import syscamstranslator.*; /** - * Class PrimitiveCodeRodrigo + * Class PrimitiveCodeSoclib * Principal code of a primive component * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE */ -public class PrimitiveCodeRodrigo { +public class PrimitiveCodeSoclib { static private String corpsPrimitiveTDF; static private String corpsPrimitiveDE; private final static String CR = "\n"; private final static String CR2 = "\n\n"; - PrimitiveCodeRodrigo() {} + PrimitiveCodeSoclib() {} public static String getPrimitiveCodeTDF(SysCAMSTBlockTDF tdf) { corpsPrimitiveTDF = ""; @@ -370,7 +370,7 @@ public class PrimitiveCodeRodrigo { } } } - corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_H"; + corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_H";//DG } else { corpsPrimitiveTDF = ""; } @@ -596,7 +596,7 @@ public class PrimitiveCodeRodrigo { String pc = buffer.toString(); corpsPrimitiveDE = corpsPrimitiveDE + "\t" + pc; - corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_TDF_H"; + corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_TDF_H";//DG } else { corpsPrimitiveDE = ""; } diff --git a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/TopCellGeneratorRodrigo.java b/src/main/java/syscamstranslator/toSysCAMSSoclib/TopCellGeneratorSoclib.java similarity index 64% rename from src/main/java/syscamstranslator/toSysCAMS_rodrigo/TopCellGeneratorRodrigo.java rename to src/main/java/syscamstranslator/toSysCAMSSoclib/TopCellGeneratorSoclib.java index 0d24c64c61..119ea536cd 100644 --- a/src/main/java/syscamstranslator/toSysCAMS_rodrigo/TopCellGeneratorRodrigo.java +++ b/src/main/java/syscamstranslator/toSysCAMSSoclib/TopCellGeneratorSoclib.java @@ -51,20 +51,23 @@ import java.io.*; import java.util.LinkedList; /** - * Class TopCellGenerator + * Class TopCellGeneratorSoclib * Save the components and connectors in files * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE */ -public class TopCellGeneratorRodrigo { +public class TopCellGeneratorSoclib { public static SysCAMSSpecification syscams; private final static String GENERATED_PATH1 = "generated_CPP" + File.separator; private final static String GENERATED_PATH2 = "generated_H" + File.separator; + private final static String CR = "\n"; + private final static String CR2 = "\n\n"; - public TopCellGeneratorRodrigo(SysCAMSSpecification sys) { + + public TopCellGeneratorSoclib(SysCAMSSpecification sys) { syscams = sys; } @@ -72,62 +75,81 @@ public class TopCellGeneratorRodrigo { if (c == null) { System.out.println("***Warning: require at least one cluster***"); } - if (TopCellGeneratorRodrigo.syscams.getNbBlockTDF() == 0) { + if (TopCellGenerator.syscams.getNbBlockTDF() == 0) { System.out.println("***Warning: require at least one TDF block***"); } - if (TopCellGeneratorRodrigo.syscams.getNbPortTDF() == 0) { + if (TopCellGenerator.syscams.getNbPortTDF() == 0) { System.out.println("***Warning: require at least one TDF port***"); } - if (TopCellGeneratorRodrigo.syscams.getNbBlockDE() == 0) { + if (TopCellGenerator.syscams.getNbBlockDE() == 0) { System.out.println("***Warning: require at least one DE block***"); } - if (TopCellGeneratorRodrigo.syscams.getNbPortDE() == 0) { + if (TopCellGenerator.syscams.getNbPortDE() == 0) { System.out.println("***Warning: require at least one DE port***"); } - if (TopCellGeneratorRodrigo.syscams.getNbPortConverter() == 0) { + if (TopCellGenerator.syscams.getNbPortConverter() == 0) { System.out.println("***Warning: require at least one converter port***"); } - if (TopCellGeneratorRodrigo.syscams.getNbConnectorCluster() == 0) { + if (TopCellGenerator.syscams.getNbConnectorCluster() == 0) { System.out.println("***Warning: require at least one connector***"); } - String top = HeaderRodrigo.getClusterHeader(c) + ClusterCodeRodrigo.getClusterCode(c, connectors); + String top = HeaderSoclib.getClusterHeader(c) + ClusterCodeSoclib.getClusterCode(c, connectors); return (top); } - public void saveFile(String path) { - SysCAMSTCluster cluster = TopCellGeneratorRodrigo.syscams.getCluster(); - LinkedList<SysCAMSTConnector> connectors = TopCellGeneratorRodrigo.syscams.getAllConnectorCluster(); - + public void saveFile(String path, Boolean standalone) { + SysCAMSTCluster cluster = TopCellGenerator.syscams.getCluster(); + LinkedList<SysCAMSTConnector> connectors = TopCellGenerator.syscams.getAllConnectorCluster(); + FileWriter fw; String top; try { // Save file .cpp System.err.println(path + GENERATED_PATH1 + cluster.getClusterName() + "_tdf.h"); - FileWriter fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tdf.h"); + System.err.println(path + cluster.getClusterName() + "_tdf.h"); + + if(standalone==true) + fw = new FileWriter(path + cluster.getClusterName() + "_tdf.h"); + else + fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tdf.h"); top = generateTopCell(cluster, connectors); fw.write(top); fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } // Save files .h - saveFileBlock(path, cluster); + saveFileBlock(path, cluster,standalone); } - public void saveFileBlock(String path, SysCAMSTCluster c) { + public void saveFileBlock(String path, SysCAMSTCluster c, Boolean standalone) { String headerTDF, headerDE, codeTDF, codeDE; LinkedList<SysCAMSTBlockTDF> tdf = c.getBlockTDF(); LinkedList<SysCAMSTBlockDE> de = c.getBlockDE(); + FileWriter fw; for (SysCAMSTBlockTDF t : tdf) { try { System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); - FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); - headerTDF = HeaderRodrigo.getPrimitiveHeaderTDF(t); + System.err.println(path + t.getName() + "_tdf.h");//DG + + if(standalone==true){ + //System.out.println("@@@@@TDF Soclib version standalone"); + fw = new FileWriter(path + t.getName() + "_tdf.h");} + else + fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); + + headerTDF = HeaderSoclib.getPrimitiveHeaderTDF(t); fw.write(headerTDF); - codeTDF = PrimitiveCodeRodrigo.getPrimitiveCodeTDF(t); + + codeTDF = PrimitiveCodeSoclib.getPrimitiveCodeTDF(t); + // if(standalone==false) + // codeTDF = codeTDF + CR + "};" + CR2 + "#endif"+CR;//DG fw.write(codeTDF); + fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } @@ -135,12 +157,21 @@ public class TopCellGeneratorRodrigo { for (SysCAMSTBlockDE t : de) { try { System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); - FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); - headerDE = HeaderRodrigo.getPrimitiveHeaderDE(t); + + if(standalone==true){ + //System.out.println("@@@@@DE Soclib version standalone"); + fw = new FileWriter(path + t.getName() + "_tdf.h");} + else + fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); + headerDE = HeaderSoclib.getPrimitiveHeaderDE(t); fw.write(headerDE); - codeDE = PrimitiveCodeRodrigo.getPrimitiveCodeDE(t); + + codeDE = PrimitiveCodeSoclib.getPrimitiveCodeDE(t); + //if(standalone==false) + // codeDE = codeDE + CR + "};" + CR2 + "#endif" +CR; fw.write(codeDE); fw.close(); + } catch (Exception ex) { ex.printStackTrace(); } diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index fef7fd3ded..9c3a94f697 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -712,10 +712,6 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return helpManager; } - public void setHelpManager(HelpManager hm) { - helpManager = hm; - } - public void showIntegratedHelp() { if (helpManager != null) { openHelpFrame(helpManager); diff --git a/src/main/java/ui/SysCAMSPanelTranslator.java b/src/main/java/ui/SysCAMSPanelTranslator.java index c590afb21c..3699b5b214 100644 --- a/src/main/java/ui/SysCAMSPanelTranslator.java +++ b/src/main/java/ui/SysCAMSPanelTranslator.java @@ -114,6 +114,7 @@ public class SysCAMSPanelTranslator { syscamsComponents.add(syscamsPortDE); } syscamsMap.put(blockGPIO2VCI, syscamsBlockGPIO2VCI); + //System.out.println("@@@ GPIO block put in map @@@"); syscamsComponents.add(syscamsBlockGPIO2VCI); } else if (dp instanceof SysCAMSBlockDE) { SysCAMSBlockDE blockDE = (SysCAMSBlockDE) dp; @@ -128,7 +129,7 @@ public class SysCAMSPanelTranslator { // String typeTemplate = blockDE.getTypeTemplate(); // DefaultListModel<String> listTypedef = blockDE.getListTypedef(); - SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, "", "", null, "", "", null, null); + SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, "", "", null, "", "", "", null, null); List<SysCAMSPortDE> portsDE = blockDE.getAllInternalPortsDE(); for (int i = 0; i < portsDE.size(); i++) { @@ -149,8 +150,10 @@ public class SysCAMSPanelTranslator { syscamsMap.put(portDE, syscamsPortDE); syscamsBlockDE.addPortDE(syscamsPortDE); syscamsComponents.add(syscamsPortDE); - } + } + syscamsMap.put(blockDE, syscamsBlockDE); + // System.out.println("@@@ DE block put in map @@@"); syscamsComponents.add(syscamsBlockDE); } else if (dp instanceof SysCAMSCompositeComponent) { SysCAMSCompositeComponent cluster = (SysCAMSCompositeComponent) dp; @@ -173,12 +176,14 @@ public class SysCAMSPanelTranslator { timeBlock = "us"; } String processCode = blockTDF.getProcessCode(); + String constructorCode = blockTDF.getConstructorCode(); DefaultListModel<String> listStruct = blockTDF.getListStruct(); String nameTemplate = blockTDF.getNameTemplate(); String typeTemplate = blockTDF.getTypeTemplate(); + String valueTemplate = blockTDF.getValueTemplate(); DefaultListModel<String> listTypedef = blockTDF.getListTypedef(); - SysCAMSTBlockTDF syscamsBlockTDF = new SysCAMSTBlockTDF(blockTDFName, periodBlock, timeBlock, processCode, listStruct, nameTemplate, typeTemplate, listTypedef, syscamsCluster); + SysCAMSTBlockTDF syscamsBlockTDF = new SysCAMSTBlockTDF(blockTDFName, periodBlock, timeBlock, processCode, constructorCode, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef, syscamsCluster); List<SysCAMSPortTDF> portsTDF = blockTDF.getAllInternalPortsTDF(); for (int j = 0; j < portsTDF.size(); j++) { @@ -227,6 +232,7 @@ public class SysCAMSPanelTranslator { syscamsComponents.add(syscamsPortConverter); } syscamsMap.put(blockTDF, syscamsBlockTDF); + //System.out.println("@@@ TDF block put in map @@@"); syscamsCluster.addBlockTDF(syscamsBlockTDF); syscamsComponents.add(syscamsBlockTDF); } @@ -241,9 +247,10 @@ public class SysCAMSPanelTranslator { DefaultListModel<String> listStruct = blockDE.getListStruct(); String nameTemplate = blockDE.getNameTemplate(); String typeTemplate = blockDE.getTypeTemplate(); + String valueTemplate = blockDE.getValueTemplate(); DefaultListModel<String> listTypedef = blockDE.getListTypedef(); - SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, nameFn, code, listStruct, nameTemplate, typeTemplate, listTypedef, syscamsCluster); + SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, nameFn, code, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef, syscamsCluster); List<SysCAMSPortDE> portsDE = blockDE.getAllInternalPortsDE(); for (int j = 0; j < portsDE.size(); j++) { diff --git a/src/main/java/ui/TGConnector.java b/src/main/java/ui/TGConnector.java old mode 100644 new mode 100755 diff --git a/src/main/java/ui/syscams/SysCAMSBlockDE.java b/src/main/java/ui/syscams/SysCAMSBlockDE.java index 257a643d49..5e60736cda 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockDE.java +++ b/src/main/java/ui/syscams/SysCAMSBlockDE.java @@ -67,6 +67,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements private DefaultListModel<String> listStruct; private String nameTemplate; private String typeTemplate; + private String valueTemplate; private DefaultListModel<String> listTypedef; private int maxFontSize = 14; @@ -114,6 +115,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements setListStruct(new DefaultListModel<String>()); setNameTemplate(""); setTypeTemplate(""); + setValueTemplate(""); setListTypedef(new DefaultListModel<String>()); myImageIcon = IconManager.imgic1202; @@ -305,6 +307,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements sb.append("\" listStruct=\"" + splitParameters(getListStruct())); sb.append("\" nameTemplate=\"" + getNameTemplate()); sb.append("\" typeTemplate=\"" + getTypeTemplate()); + sb.append("\" valueTemplate=\"" + getValueTemplate()); sb.append("\" listTypedef=\"" + splitParameters(getListTypedef())); sb.append("\" />\n"); sb.append("</extraparam>\n"); @@ -430,7 +433,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements Node n1, n2; Element elt; - String code, nameFn, listStruct, nameTemplate, typeTemplate, listTypedef; + String code, nameFn, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -448,6 +451,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements listStruct = elt.getAttribute("listStruct"); nameTemplate = elt.getAttribute("nameTemplate"); typeTemplate = elt.getAttribute("typeTemplate"); + valueTemplate = elt.getAttribute("valueTemplate"); listTypedef = elt.getAttribute("listTypedef"); // setPeriod(period); // setTime(time); @@ -464,6 +468,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements setListStruct(lista); setNameTemplate(nameTemplate); setTypeTemplate(typeTemplate); + setValueTemplate(valueTemplate); String[] splitb = listTypedef.split("\\|"); DefaultListModel<String> listb = new DefaultListModel<String>(); for (String s : splitb) { @@ -574,6 +579,14 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements public void setTypeTemplate(String _typeTemplate) { typeTemplate = _typeTemplate; } + + public String getValueTemplate() { + return valueTemplate; + } + + public void setValueTemplate(String _valueTemplate) { + valueTemplate = _valueTemplate; + } public DefaultListModel<String> getListTypedef() { return listTypedef; @@ -582,4 +595,4 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements public void setListTypedef(DefaultListModel<String> _listTypedef) { listTypedef = _listTypedef; } -} \ No newline at end of file +} diff --git a/src/main/java/ui/syscams/SysCAMSBlockTDF.java b/src/main/java/ui/syscams/SysCAMSBlockTDF.java index 65ca8ee7a0..9076e8e147 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockTDF.java +++ b/src/main/java/ui/syscams/SysCAMSBlockTDF.java @@ -62,9 +62,11 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements private double period; private String time; private String processCode; + private String constructorCode; private DefaultListModel<String> listStruct; private String nameTemplate; private String typeTemplate; + private String valueTemplate; private DefaultListModel<String> listTypedef; private int maxFontSize = 14; @@ -109,9 +111,11 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements setPeriod(-1); setTime(""); setProcessCode("void processing() {\n\n}"); + setConstructorCode(""); setListStruct(new DefaultListModel<String>()); setNameTemplate(""); setTypeTemplate(""); + setValueTemplate(""); setListTypedef(new DefaultListModel<String>()); myImageIcon = IconManager.imgic1202; @@ -316,9 +320,11 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements sb.append("<Attribute period=\"" + getPeriod()); sb.append("\" time=\"" + getTime()); sb.append("\" processCode=\"" + encode(getProcessCode())); + sb.append("\" constructorCode=\"" + encode(getConstructorCode())); sb.append("\" listStruct=\"" + splitParameters(getListStruct())); sb.append("\" nameTemplate=\"" + getNameTemplate()); sb.append("\" typeTemplate=\"" + getTypeTemplate()); + sb.append("\" valueTemplate=\"" + getValueTemplate()); sb.append("\" listTypedef=\"" + splitParameters(getListTypedef())); sb.append("\" />\n"); sb.append("</extraparam>\n"); @@ -448,7 +454,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements Element elt; double period; - String time, processCode, listStruct, nameTemplate, typeTemplate, listTypedef; + String time, processCode, constructorCode, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -462,14 +468,18 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements period = Double.valueOf(elt.getAttribute("period")).doubleValue(); time = elt.getAttribute("time"); processCode = elt.getAttribute("processCode"); + constructorCode = elt.getAttribute("constructorCode"); listStruct = elt.getAttribute("listStruct"); nameTemplate = elt.getAttribute("nameTemplate"); typeTemplate = elt.getAttribute("typeTemplate"); + valueTemplate = elt.getAttribute("valueTemplate"); listTypedef = elt.getAttribute("listTypedef"); setPeriod(period); setTime(time); processCode = decode(processCode).toString(); setProcessCode(processCode); + constructorCode = decode(constructorCode).toString(); + setConstructorCode(constructorCode); String[] splita = listStruct.split("\\|"); DefaultListModel<String> lista = new DefaultListModel<String>(); for (String s : splita) { @@ -480,6 +490,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements setListStruct(lista); setNameTemplate(nameTemplate); setTypeTemplate(typeTemplate); + setValueTemplate(valueTemplate); String[] splitb = listTypedef.split("\\|"); DefaultListModel<String> listb = new DefaultListModel<String>(); for (String s : splitb) { @@ -591,6 +602,14 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements public void setProcessCode(String _processCode) { processCode = _processCode; } + + public String getConstructorCode() { + return constructorCode; + } + + public void setConstructorCode(String _constructorCode) { + constructorCode = _constructorCode; + } public DefaultListModel<String> getListStruct() { return listStruct; @@ -607,7 +626,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements public void setNameTemplate(String _nameTemplate) { nameTemplate = _nameTemplate; } - + public String getTypeTemplate() { return typeTemplate; } @@ -615,6 +634,14 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements public void setTypeTemplate(String _typeTemplate) { typeTemplate = _typeTemplate; } + + public String getValueTemplate() { + return valueTemplate; + } + + public void setValueTemplate(String _valueTemplate) { + valueTemplate = _valueTemplate; + } public DefaultListModel<String> getListTypedef() { return listTypedef; diff --git a/src/main/java/ui/window/JDialogSelectSysCAMSComponent.java b/src/main/java/ui/window/JDialogSelectSysCAMSComponent.java index ac3c8ab3b3..92443e49dc 100644 --- a/src/main/java/ui/window/JDialogSelectSysCAMSComponent.java +++ b/src/main/java/ui/window/JDialogSelectSysCAMSComponent.java @@ -81,7 +81,7 @@ public class JDialogSelectSysCAMSComponent extends JDialogBase implements Action private JButton allIgnored; protected JCheckBox optimize; - /* Creates new form */ + /** Creates new form */ public JDialogSelectSysCAMSComponent(Frame f, Vector<TGComponent> _back, List<TGComponent> componentList, String title) { super(f, title, true); @@ -132,7 +132,7 @@ public class JDialogSelectSysCAMSComponent extends JDialogBase implements Action for(int i=0; i<list.size(); i++) { tgc = list.get(i); - // + // if (tgc instanceof SysCAMSBlockTDF) { v.addElement(tgc); } @@ -164,7 +164,7 @@ public class JDialogSelectSysCAMSComponent extends JDialogBase implements Action if (((tgc instanceof SysCAMSBlockTDF) || (tgc instanceof SysCAMSBlockDE)) && (!added.contains(tgc)) && (!notSource.contains(tgc))){ added.addElement( tgc ) ; - // + // } } } diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java index 6096eb2903..516e328e0a 100644 --- a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java @@ -75,6 +75,7 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li private DefaultListModel<String> structListModel; private boolean structBool = false; private JTextField nameTemplateTextField; + private JTextField valueTemplateTextField; private String listTypeTemplateString[]; private JComboBox<String> typeTemplateComboBoxString; private JTextField nameTypedefTextField; @@ -394,15 +395,35 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li new Insets(5, 10, 5, 10), 0, 0); templateGridBag.setConstraints(nameTemplateTextField, templateConstraint); templatePanel.add(nameTemplateTextField); + + //CHANGES + JLabel egalTemplateLabel = new JLabel("="); + templateConstraint = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + templateGridBag.setConstraints(egalTemplateLabel, templateConstraint); + templatePanel.add(egalTemplateLabel); + + JLabel valueTemplateLabel = new JLabel("value"); + templateConstraint = new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + templateGridBag.setConstraints(valueTemplateLabel, templateConstraint); + templatePanel.add(valueTemplateLabel); + + valueTemplateTextField = new JTextField(block.getValueTemplate()); + templateConstraint = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + templateGridBag.setConstraints(valueTemplateTextField, templateConstraint); + templatePanel.add(valueTemplateTextField); + //CHANGES JLabel pointsTemplateLabel = new JLabel(":"); - templateConstraint = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + templateConstraint = new GridBagConstraints(3, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 5, 10), 0, 0); templateGridBag.setConstraints(pointsTemplateLabel, templateConstraint); templatePanel.add(pointsTemplateLabel); JLabel typeTemplateLabel = new JLabel("type"); - templateConstraint = new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + templateConstraint = new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 5, 10), 0, 0); templateGridBag.setConstraints(typeTemplateLabel, templateConstraint); templatePanel.add(typeTemplateLabel); @@ -414,7 +435,7 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li typeTemplateComboBoxString.setSelectedIndex(0); } typeTemplateComboBoxString.addActionListener(this); - templateConstraint = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + templateConstraint = new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 5, 10), 0, 0); templateGridBag.setConstraints(typeTemplateComboBoxString, templateConstraint); templatePanel.add(typeTemplateComboBoxString); @@ -1005,8 +1026,8 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li block.setListStruct(structListModel); block.setNameTemplate(nameTemplateTextField.getText()); block.setTypeTemplate((String) typeTemplateComboBoxString.getSelectedItem()); + block.setValueTemplate(valueTemplateTextField.getText()); block.setListTypedef(typedefListModel); - block.setNameFn(nameFnTextField.getText()); block.setCode(codeTextArea.getText()); } @@ -1111,4 +1132,4 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li } } } -} \ No newline at end of file +} diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java index 1a05043233..6073e921f0 100644 --- a/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java +++ b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java @@ -74,6 +74,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L private DefaultListModel<String> structListModel; private boolean structBool = false; private JTextField nameTemplateTextField; + private JTextField valueTemplateTextField; private String listTypeTemplateString[]; private JComboBox<String> typeTemplateComboBoxString; private JTextField nameTypedefTextField; @@ -89,6 +90,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L private JTextArea processCodeTextArea; private String finalString; + private JTextArea constructorCodeTextArea; private SysCAMSBlockTDF block; @@ -190,9 +192,11 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JPanel attributesMainPanel = new JPanel(); JPanel parametersMainPanel = new JPanel(); JPanel processMainPanel = new JPanel(); + JPanel contructorMainPanel = new JPanel(); tabbedPane.add("Attributes", attributesMainPanel); tabbedPane.add("Parameters", parametersMainPanel); tabbedPane.add("Process Code", processMainPanel); + tabbedPane.add("Contructor Code", contructorMainPanel); mainPanel.add(tabbedPane, BorderLayout.NORTH); @@ -387,15 +391,35 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L new Insets(5, 10, 5, 10), 0, 0); templateGridBag.setConstraints(nameTemplateTextField, templateConstraint); templatePanel.add(nameTemplateTextField); + + //CHANGES + JLabel egalTemplateLabel = new JLabel("="); + templateConstraint = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + templateGridBag.setConstraints(egalTemplateLabel, templateConstraint); + templatePanel.add(egalTemplateLabel); + + JLabel valueTemplateLabel = new JLabel("value"); + templateConstraint = new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + templateGridBag.setConstraints(valueTemplateLabel, templateConstraint); + templatePanel.add(valueTemplateLabel); + + valueTemplateTextField = new JTextField(block.getValueTemplate()); + templateConstraint = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + templateGridBag.setConstraints(valueTemplateTextField, templateConstraint); + templatePanel.add(valueTemplateTextField); + //CHANGES JLabel pointsTemplateLabel = new JLabel(":"); - templateConstraint = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + templateConstraint = new GridBagConstraints(3, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 5, 10), 0, 0); templateGridBag.setConstraints(pointsTemplateLabel, templateConstraint); templatePanel.add(pointsTemplateLabel); JLabel typeTemplateLabel = new JLabel("type"); - templateConstraint = new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + templateConstraint = new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 5, 10), 0, 0); templateGridBag.setConstraints(typeTemplateLabel, templateConstraint); templatePanel.add(typeTemplateLabel); @@ -407,7 +431,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L typeTemplateComboBoxString.setSelectedIndex(0); } typeTemplateComboBoxString.addActionListener(this); - templateConstraint = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + templateConstraint = new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 5, 10), 0, 0); templateGridBag.setConstraints(typeTemplateComboBoxString, templateConstraint); templatePanel.add(typeTemplateComboBoxString); @@ -608,7 +632,39 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L codeBox.add(codeBoxPanel); processMainPanel.add(codeBox, BorderLayout.PAGE_START); - + + // --- ContructorCode --- // + contructorMainPanel.setLayout(new BorderLayout()); + + Box codeBox2 = Box.createVerticalBox(); + codeBox2.setBorder(BorderFactory.createTitledBorder("Contructor code of TDF block")); + + JPanel codeBoxPanel2 = new JPanel(new BorderLayout()); + + //StringBuffer stringbuf2 = encode(block.getConstructorCode()); + //String beginString2 = stringbuf2.toString(); + //finalString = beginString2.replaceAll("\t}", "}"); + finalString = block.getConstructorCode(); + + constructorCodeTextArea = new JTextArea(finalString); + constructorCodeTextArea.setSize(100, 100); + constructorCodeTextArea.setTabSize(2); + + constructorCodeTextArea.setFont(new Font("Arial", Font.PLAIN, 16)); + constructorCodeTextArea.setLineWrap(true); + constructorCodeTextArea.setWrapStyleWord(true); + + JScrollPane constructorScrollPane = new JScrollPane(constructorCodeTextArea); + constructorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + constructorScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + constructorScrollPane.setPreferredSize(new Dimension(200, 300)); + constructorScrollPane.setBorder(new EmptyBorder(15, 10, 15, 10)); + + codeBoxPanel2.add(constructorScrollPane, BorderLayout.SOUTH); + + codeBox2.add(codeBoxPanel2); + contructorMainPanel.add(codeBox2, BorderLayout.PAGE_START); + // --- Button --- // JPanel downPanel = new JPanel(new FlowLayout()); @@ -954,9 +1010,11 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L } block.setProcessCode(processCodeTextArea.getText()); + block.setConstructorCode(constructorCodeTextArea.getText()); block.setListStruct(structListModel); block.setNameTemplate(nameTemplateTextField.getText()); block.setTypeTemplate((String) typeTemplateComboBoxString.getSelectedItem()); + block.setValueTemplate(valueTemplateTextField.getText()); block.setListTypedef(typedefListModel); this.dispose(); diff --git a/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java b/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java index c5c80dd073..82f4e5f816 100644 --- a/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java +++ b/src/main/java/ui/window/JDialogSysCAMSExecutableCodeGeneration.java @@ -109,7 +109,8 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i private static int mode; - + Boolean standalone; //are there any GPIO blocks? + //components protected JTextArea jta; protected JButton start; @@ -508,7 +509,8 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i // String cmd; // String list;//, data; hasError = false; - + Boolean has_GPIO = false; + try { if (jp1.getSelectedIndex() == 0) { Vector<SysCAMSComponentTaskDiagramPanel> syscamsDiagramPanels = mgui.getListSysCAMSPanel(); @@ -520,13 +522,9 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i } else { jta.append("\nPerforming Validation for \""+(syscalsspec.getCluster()).getClusterName()+"\".\n"); LinkedList<SysCAMSTConnector> connectors = syscalsspec.getAllConnectorsCluster4Matrix(); - System.out.printf("Connectors4matrix for 1 cluster = %d.\n", connectors.size()); LinkedList<SysCAMSTBlockTDF> tdfBlocks = syscalsspec.getAllBlockTDF(); - System.out.printf("Blocks for 1 cluster = %d.\n", tdfBlocks.size()); LinkedList<SysCAMSTConnector> connectorsTdfDe = syscalsspec.getAllConnectorsTdfDe(); - System.out.printf("ConnectorsTdfDe for 1 cluster = %d.\n", connectorsTdfDe.size()); - LinkedList<SysCAMSTConnector> allConnectors = syscalsspec.getAllConnectorsCluster4Soclib(); - System.out.printf("All Connectors for 1 cluster = %d.\n", allConnectors.size()); + LinkedList<SysCAMSTConnector> allConnectors = syscalsspec.getAllConnectors(); LinkedList<SysCAMSTBlockDE> deBlocks = syscalsspec.getAllBlockDE(); LinkedList<SysCAMSTBlockGPIO2VCI> gpioBlocks = syscalsspec.getAllBlockGPIO2VCI(); //Validate that all ports are connected @@ -539,8 +537,15 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i nbPorts += deBlock.getPortDE().size(); } for(SysCAMSTBlockGPIO2VCI gpioBlock : gpioBlocks) { + has_GPIO=true;//DG + //System.out.println("@@@@ I got here @@@"); nbPorts += gpioBlock.getPortDE().size(); } + if(has_GPIO==true) + standalone=false; + else + standalone=true; + if(nbPorts != (allConnectors.size()*2)) { jta.append("Error: There are unconnected ports.\n"); throw new InterruptedException(); @@ -577,53 +582,140 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i //Validate Block parameters (rate, Tp, Tm, Delay) and propagate timesteps to all blocks //try { propagateTimestep(connectorsTdfDe, tdfBlocks); - - //TODO-DELETE THIS, after debugging: - for(SysCAMSTBlockTDF tdfBlock : tdfBlocks) { - System.out.println("params of Block: " +tdfBlock.getName()); - System.out.println("Tm: " + tdfBlock.getPeriod()); - for(SysCAMSTPortTDF portTdf : tdfBlock.getPortTDF()) { - System.out.println("Port: " + portTdf.getName()); - System.out.println("Tp: " + portTdf.getPeriod()); - System.out.println("Rate: " + portTdf.getRate()); - System.out.println("Delay: " + portTdf.getDelay()); - } - - for(SysCAMSTPortConverter portConverter : tdfBlock.getPortConverter()) { - System.out.println("Port: " + portConverter.getName()); - System.out.println("Tp: " + portConverter.getPeriod()); - System.out.println("Rate: " + portConverter.getRate()); - System.out.println("Delay: " + portConverter.getDelay()); + if(tdfBlocks.size() == 1) { + if(connectors.size() > 0) { //Case when self-loops exist. + for(int i = 0; i < connectors.size(); i++) { + if( (((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getDelay() + ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getDelay()) < ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getRate() ) { + jta.append("Static schedule can not be computed due to missing delays in loops.\n"); + jta.append("The following delays are suggested:\n"); + jta.append("In Port: \"" + ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getName() + "\". Insert delay of " + ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getRate() + "\n"); + } + + } + if(allConnectors.size() > 0) { //Case when connections to DE exist. + boolean recompute = false; + boolean suggest_delays = false; + double[] time_prev = {0.0, 0.0}; //array to store "in" ([0]) and "out" ([1]) previous times + do{ + try { + for(SysCAMSTBlockTDF tdfBlock : tdfBlocks){ + tdfBlock.syncTDFBlockDEBlock(time_prev); + } + recompute = false; + + } catch (SysCAMSValidateException se) { + recompute = true; + suggest_delays = true; + //System.out.println("Causality exception: " + se.getMessage()); + } + } while (recompute); + if(suggest_delays){ + jta.append("The following delays are suggested to solve synchronization issues between DE and TDF modules:\n"); + for(SysCAMSTBlockTDF tdfBlock : tdfBlocks){ + for(SysCAMSTPortConverter portConverter : tdfBlock.getPortConverter()) { + if(portConverter.getRecompute()){ + jta.append("In Block: \"" + tdfBlock.getName() + "\". Port: \"" + portConverter.getName() + "\". Insert delay of " + portConverter.getDelay() + "\n"); + } + } + } + } + } + } else if(allConnectors.size() > 0) { //Case when connections to DE exist - no self-loops + boolean recompute = false; + boolean suggest_delays = false; + double[] time_prev = {0.0, 0.0}; //array to store "in" ([0]) and "out" ([1]) previous times + do{ + try { + for(SysCAMSTBlockTDF tdfBlock : tdfBlocks){ + tdfBlock.syncTDFBlockDEBlock(time_prev); + } + recompute = false; + + } catch (SysCAMSValidateException se) { + recompute = true; + suggest_delays = true; + //System.out.println("Causality exception: " + se.getMessage()); + } + } while (recompute); + if(suggest_delays){ + jta.append("The following delays are suggested to solve synchronization issues between DE and TDF modules:\n"); + for(SysCAMSTBlockTDF tdfBlock : tdfBlocks){ + for(SysCAMSTPortConverter portConverter : tdfBlock.getPortConverter()) { + if(portConverter.getRecompute()){ + jta.append("In Block: \"" + tdfBlock.getName() + "\". Port: \"" + portConverter.getName() + "\". Insert delay of " + portConverter.getDelay() + "\n"); + } + } + } + } } - } - - //TODO: verify trivial case when only 1 block and no connectors. - if(connectors.size() > 0) { - boolean recompute = false; + } else if(connectors.size() > 0) { //Case for more than 1 TDF block. + boolean[] recompute = {false, false}; //[0]-for sync issues [1]-for loop delays boolean suggest_delays = false; + boolean suggest_delays_loops = false; + SysCAMSTPortTDF tdfPort1; + SysCAMSTPortTDF tdfPort2; RealVector buffer = new ArrayRealVector(connectors.size()); RealVectorFormat printFormat = new RealVectorFormat(); RealMatrix topologyMatrix = buildTopologyMatrix(connectors, tdfBlocks, buffer); - System.out.println("Buffer after topMatrix is: " + printFormat.format(buffer) ); - //try { RealVector execRate = solveTopologyMatrix(topologyMatrix, tdfBlocks); - //TODO: to recompute missing delays in loops: modify buffer with the suggested delay, and loop. do { recompute = computeSchedule(execRate, topologyMatrix, buffer, tdfBlocks, connectors); - if(recompute) + if(recompute[0]) suggest_delays = true; - } while (recompute); - if(suggest_delays){ + if(recompute[1]) { + RealVector bufferLoopDelays = new ArrayRealVector(connectors.size()); + bufferLoopDelays = rebuildBuffer(connectors, tdfBlocks, bufferLoopDelays); + buffer = bufferLoopDelays.copy(); + suggest_delays_loops = true; + } + } while (recompute[0] || recompute[1]); + + if(suggest_delays_loops) { + jta.append("Static schedule can not be computed due to missing delays in loops.\n"); + jta.append("The following delays are suggested:\n"); + for(SysCAMSTBlockTDF tdfBlock : tdfBlocks){ + for(SysCAMSTPortTDF tdfPort : tdfBlock.getPortTDF()) { + if(tdfPort.getRecompute()){ + jta.append("In Block: \"" + tdfBlock.getName() + "\". Port: \"" + tdfPort.getName() + "\". Insert delay of " + tdfPort.getDelay() + "\n"); + } + } + for(int j = 0; j < connectors.size(); j++) { + tdfPort1 = ((SysCAMSTPortTDF) connectors.get(j).get_p1().getComponent()); + tdfPort2 = ((SysCAMSTPortTDF) connectors.get(j).get_p2().getComponent()); + if( tdfPort1.getBlockTDF().getName().equals(tdfBlock.getName()) && tdfPort2.getBlockTDF().getName().equals(tdfBlock.getName()) ) { + if( (tdfPort1.getDelay() + tdfPort2.getDelay()) < tdfPort1.getRate() ) { + jta.append("In Block: \"" + tdfBlock.getName() + "\". Port: \"" + tdfPort1.getName() + "\". Insert delay of " + tdfPort1.getRate() + "\n"); + } + } + } + } + } else { + for(SysCAMSTBlockTDF tdfBlock : tdfBlocks){ + for(int j = 0; j < connectors.size(); j++) { + tdfPort1 = ((SysCAMSTPortTDF) connectors.get(j).get_p1().getComponent()); + tdfPort2 = ((SysCAMSTPortTDF) connectors.get(j).get_p2().getComponent()); + if( tdfPort1.getBlockTDF().getName().equals(tdfBlock.getName()) && tdfPort2.getBlockTDF().getName().equals(tdfBlock.getName()) ) { + if( (tdfPort1.getDelay() + tdfPort2.getDelay()) < tdfPort1.getRate() ) { + jta.append("Static schedule can not be computed due to missing delays in loops.\n"); + jta.append("The following delays are suggested:\n"); + jta.append("In Block: \"" + tdfBlock.getName() + "\". Port: \"" + tdfPort1.getName() + "\". Insert delay of " + tdfPort1.getRate() + "\n"); + } + } + } + } + } + + if(suggest_delays) { jta.append("The following delays are suggested to solve synchronization issues between DE and TDF modules:\n"); for(SysCAMSTBlockTDF tdfBlock : tdfBlocks){ for(SysCAMSTPortConverter portConverter : tdfBlock.getPortConverter()) { - if(portConverter.getRecompute()){ + if(portConverter.getRecompute()) { jta.append("In Block: \"" + tdfBlock.getName() + "\". Port: \"" + portConverter.getName() + "\". Insert delay of " + portConverter.getDelay() + "\n"); } } } } - } + } jta.append("Validation for \""+(syscalsspec.getCluster()).getClusterName()+"\" completed.\n"); } catch (InterruptedException ie) { System.err.println("Interrupted"); @@ -631,7 +723,6 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i mode = STOPPED; setButtons(); hasError = true; - //return; } catch (Exception e) { e.printStackTrace(); mode = STOPPED; @@ -675,9 +766,9 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i System.err.println("Saving SysCAMS code in files\n"); pathCode = code2.getText(); - System.err.println("SYSCAMS TOPCELL : " + syscalsspec.getCluster().getClusterName() + "saved in " + code2.getText()); - topCellGenerator.saveFile(pathCode); - topCellGeneratorCluster.saveFile(pathCode); + System.err.println("SYSCAMS TOPCELL : " + syscalsspec.getCluster().getClusterName() + " saved in " + code2.getText()); + topCellGenerator.saveFile(pathCode, standalone); + topCellGeneratorCluster.saveFile(pathCode, standalone); jta.append("Code saved\n"); } catch (Exception e) { @@ -909,7 +1000,7 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i } } } - jta.append("Error: At least one Module or Port Timestep should be entered in at least one TDF block of this cluster.\n"); + jta.append("Error: At least one Module Timestep or Port Timestep should be entered in at least one TDF block of this cluster.\n"); throw new InterruptedException(); } @@ -941,7 +1032,7 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i if(tp > 0) { //validate timestep consistency (rate*tp == tm) if(rate*tp != tm){ - jta.append("Error: In block \""+tdfBlock.getName()+ "\" Timestep Tm is inconsistent with timestep Tp of port \"" + tdfPort.getName()+"\".\n"); + jta.append("Error while propagating Timesteps: In block \""+tdfBlock.getName()+ "\" Timestep Tm is inconsistent with Rate or timestep Tp of port \"" + tdfPort.getName()+"\".\n"); return false; } } else { @@ -962,8 +1053,8 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i } else { //validate timestep consitency between 2 ports. if(p2_tdfPort.getPeriod() != tp) { - jta.append("Error: In block \""+tdfBlock.getName()+"\" Timestep Tp of port \"" +tdfPort.getName() - + "\" is inconsistent with timestep Tp of port \"" + p2_tdfPort.getName()+"\" from block \""+p2_tdfPort.getBlockTDF().getName()+"\".\n"); + jta.append("Error while propagating Timesteps: In block \""+tdfBlock.getName()+"\" Rate or Timestep Tp of port \"" +tdfPort.getName() + + "\" is inconsistent with Rate or timestep Tp of port \"" + p2_tdfPort.getName()+"\" from block \""+p2_tdfPort.getBlockTDF().getName()+"\".\n"); return false; } //if connected block was not visited yet, then propagate timestep @@ -982,8 +1073,8 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i } else { //validate timestep consitency between 2 ports. if(p1_tdfPort.getPeriod() != tp) { - jta.append("Error: In block \""+tdfBlock.getName()+"\" Timestep Tp of port \"" +tdfPort.getName() - + "\" is inconsistent with timestep Tp of port \"" + p1_tdfPort.getName()+"\" from block \""+p1_tdfPort.getBlockTDF().getName()+"\".\n"); + jta.append("Error while propagating Timesteps: In block \""+tdfBlock.getName()+"\" Rate or Timestep Tp of port \"" +tdfPort.getName() + + "\" is inconsistent with Rate or timestep Tp of port \"" + p1_tdfPort.getName()+"\" from block \""+p1_tdfPort.getBlockTDF().getName()+"\".\n"); return false; } //if connected block was not visited yet, then propagate timestep @@ -1004,7 +1095,7 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i if(tp > 0) { //validate timestep consistency (rate*tp == tm) if(rate*tp != tm){ - jta.append("Error: In block \""+tdfBlock.getName()+ "\" Timestep Tm is inconsistent with timestep Tp of port \"" + converterPort.getName()+"\".\n"); + jta.append("Error while propagating Timesteps: In block \""+tdfBlock.getName()+ "\" Timestep Tm is inconsistent with Rate or timestep Tp of port \"" + converterPort.getName()+"\".\n"); return false; } } else { @@ -1029,7 +1120,7 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i int rate = tdfPort.getRate(); if(tm > 0) { if(rate*tp != tm) { - jta.append("Error: In block \""+tdfBlock.getName()+ "\" Timestep Tm is inconsistent with timestep Tp of port \"" + tdfPort.getName()+"\".\n"); + jta.append("Error while propagating Timesteps: In block \""+tdfBlock.getName()+ "\" Timestep Tm is inconsistent with Rate or timestep Tp of port \"" + tdfPort.getName()+"\".\n"); return false; } } else { @@ -1046,7 +1137,7 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i int rate = converterPort.getRate(); if(tm > 0) { if(rate*tp != tm) { - jta.append("Error: In block \""+tdfBlock.getName()+ "\" Timestep Tm is inconsistent with timestep Tp of port \"" + converterPort.getName()+"\".\n"); + jta.append("Error while propagating Timesteps: In block \""+tdfBlock.getName()+ "\" Timestep Tm is inconsistent with Rate or timestep Tp of port \"" + converterPort.getName()+"\".\n"); return false; } } else { @@ -1061,14 +1152,21 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i double [][] tArray = new double[connectors.size()][blocks.size()]; for(int i = 0; i < connectors.size(); i++) { for(int j = 0; j < blocks.size(); j++) { - if( ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(blocks.get(j).getName()) ) { - System.out.println("Inserting in : "+ i + " " + j + " From port: "+ ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getName() +" Rate: " + ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getRate() ); + if( ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(blocks.get(j).getName()) && + ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(blocks.get(j).getName()) ) { + tArray[i][j] = ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getRate() - ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getRate() ; + if(((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getDelay() > 0) { + buffer.addToEntry(i, ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getDelay() ); + } + if(((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getDelay() > 0) { + buffer.addToEntry(i, ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getDelay() ); + } + } else if( ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(blocks.get(j).getName()) ) { tArray[i][j] = ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getRate(); if(((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getDelay() > 0) { buffer.addToEntry(i, ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getDelay() ); } } else if( ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(blocks.get(j).getName()) ) { - System.out.println("Inserting in : "+ i + " " + j + " From port: "+ ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getName() +" Rate: " + -((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getRate() ); tArray[i][j] = -((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getRate(); if(((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getDelay() > 0) { buffer.addToEntry(i, ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getDelay() ); @@ -1076,14 +1174,27 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i } } } - - //double[][] tArray = { { 2, -1, 0 }, { 0, 2, -4 }, { -1, 0, 1 } }; - //double[][] tArray = { { 2, 3, 5 }, { -4, 2, 3} }; - //double[][] tArray = { { 3, -2, 0, 0 }, { 0, 4, 0, -3 }, { 0, 1, -3, 0 }, { -1, 0, 2, 0 }, { -2, 0, 0, 1 } }; - //double[][] tArray = { { 3, -2 } }; RealMatrix tMatrix = new Array2DRowRealMatrix(tArray); return tMatrix; } + + public RealVector rebuildBuffer(LinkedList<SysCAMSTConnector> connectors, LinkedList<SysCAMSTBlockTDF> blocks, RealVector buffer) { + for(int i = 0; i < connectors.size(); i++) { + for(int j = 0; j < blocks.size(); j++) { + if( ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(blocks.get(j).getName()) ) { + if(((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getDelay() > 0) { + buffer.addToEntry(i, ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getDelay() ); + } + } else if( ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(blocks.get(j).getName()) ) { + if(((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getDelay() > 0) { + buffer.addToEntry(i, ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getDelay() ); + } + } + } + } + + return buffer; + } public RealVector solveTopologyMatrix(RealMatrix matrixA, LinkedList<SysCAMSTBlockTDF> blocks) throws InterruptedException { double dropThreshold = 1e-7; @@ -1094,55 +1205,44 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i int rank = qr.getRank(dropThreshold); if(rank != blocks.size()-1){ jta.append("Error: Port sample rates are inconsistent. Topology matrix can not be solved.\n"); - System.err.println("Port sample rates are inconsistent. Topology matrix can not be solved. Rank: " +rank+" != #blocks-1"); throw new InterruptedException(); } - System.out.println("Checking kernel columns ..."); RealMatrix zMatrix = matrixA.multiply(qMatrix); - for (int c = rank; c < matrixA.getColumnDimension(); c++) { - System.out.printf("The product of A with column %d of Q has sup " - + "norm %f.\n", - c, zMatrix.getColumnMatrix(c).getNorm()); - //TODO: verify if norm is not zero, throw error that kernel could not be found. - } - RealMatrix kernelMatrix = qMatrix.getSubMatrix( 0, qMatrix.getRowDimension()-1, rank, qMatrix.getColumnDimension()-1 ); double[] resultArray = new double[kernelMatrix.getRowDimension()]; double result_tmp = 0.0; int v_lcm = 1; BigFraction[] resultFractionArray = new BigFraction[kernelMatrix.getRowDimension()]; for (int i = 0; i < kernelMatrix.getRowDimension(); i++) { - System.out.printf("The kernelMatrix is %f .\n", kernelMatrix.getEntry(i, 0) ); resultArray[i] = kernelMatrix.getEntry(i, 0) / kernelMatrix.getEntry(kernelMatrix.getRowDimension()-1, 0); result_tmp = kernelMatrix.getEntry(i, 0) / kernelMatrix.getEntry(kernelMatrix.getRowDimension()-1, 0); resultFractionArray[i] = new BigFraction(result_tmp, 2147483647); - System.out.println("The resultArray is: "+ resultArray[i] + ", result_tmp: " + result_tmp); - System.out.println("The resultFractionArray is: "+ resultFractionArray[i].toString() + " with num: " + resultFractionArray[i].getNumeratorAsInt() + " and denom: "+ resultFractionArray[i].getDenominatorAsInt() - + " and given as a double: " + resultFractionArray[i].doubleValue()); v_lcm = ArithmeticUtils.lcm(resultFractionArray[i].getDenominatorAsInt() , v_lcm); - System.out.println("The lcm is: "+ v_lcm ); } int[] tmpResult = new int[kernelMatrix.getRowDimension()]; double[] finalResult = new double[kernelMatrix.getRowDimension()]; for (int i = 0; i < kernelMatrix.getRowDimension(); i++) { tmpResult[i] = (resultFractionArray[i].multiply(v_lcm)).intValue(); finalResult[i] = (double)tmpResult[i]; - System.out.println("The finalResult is: "+ finalResult[i] + " - " + blocks.get(i).getName() ); } RealVector xVector = new ArrayRealVector(finalResult); return xVector; } - public boolean computeSchedule(RealVector q, RealMatrix gamma, RealVector buffer, LinkedList<SysCAMSTBlockTDF> tdfBlocks, LinkedList<SysCAMSTConnector> connectors) throws InterruptedException { + public boolean[] computeSchedule(RealVector q, RealMatrix gamma, RealVector buffer, LinkedList<SysCAMSTBlockTDF> tdfBlocks, LinkedList<SysCAMSTConnector> connectors) throws InterruptedException { RealVector q1 = new ArrayRealVector(q.getDimension()); RealVector nu = new ArrayRealVector(q.getDimension()); RealVector tmpBuffer = new ArrayRealVector(gamma.getRowDimension());; RealVectorFormat printFormat = new RealVectorFormat(); + String last_schedule = "Current scheduled modules list is: "; boolean deadlock = false; - boolean recompute = false; + boolean[] recompute = {false, false}; //[0]-for sync issues [1]-for loop delays SysCAMSTBlockTDF tdfBlock; - LinkedList<SysCAMSTPortConverter> portConvertersTmp; + SysCAMSTPortTDF tdfPort; + SysCAMSTPortTDF tdfPort1; + SysCAMSTPortTDF tdfPort2; double[] time_prev = {0.0, 0.0}; //array to store "in" ([0]) and "out" ([1]) previous times + //Reset the number of times all blocks have been executed for(int i = 0; i < tdfBlocks.size(); i++) { tdfBlocks.get(i).setN(0); @@ -1155,18 +1255,14 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i tdfBlock = tdfBlocks.get(i); //check if block is runnable: If it has not run q times //and it won't cause a buffer size to go negative. - System.out.println("q1 is: " + printFormat.format(q1) ); - System.out.println("q is: " + printFormat.format(q) ); if(q1.getEntry(i) != q.getEntry(i)) { nu.setEntry(i, 1); tmpBuffer = buffer.add(gamma.operate(nu)); - System.out.println("tmpBuffer is: " + printFormat.format(tmpBuffer) ); if(tmpBuffer.getMinValue() >= 0) { deadlock = false; q1 = q1.add(nu); buffer = tmpBuffer.copy(); - System.out.println("Schedule " + tdfBlock.getName() ); - System.out.println("Buffer is: " + printFormat.format(buffer) ); + last_schedule += tdfBlock.getName() + " - "; //Validate sync bewtween TDF/DE tdfBlock.syncTDFBlockDEBlock(time_prev); } @@ -1175,23 +1271,24 @@ public class JDialogSysCAMSExecutableCodeGeneration extends javax.swing.JFrame i } } } catch (SysCAMSValidateException se) { - recompute = true; - System.out.println("Causality exception: " + se.getMessage()); + recompute[0] = true; + //System.out.println("Causality exception: " + se.getMessage()); } if (deadlock){ - System.out.println("Static schedule can not be computed due to missing delays in loops" ); - jta.append("Error: Static schedule can not be computed due to missing delays in loops\n" ); + //System.out.println(last_schedule); int minIndex = tmpBuffer.getMinIndex(); - //TODO: for the suggested delay, I need to first detect loops within the graph(DFS?), then recompute recursively with the suggested delay until it can be solved. - /*jta.append("Following delay is suggested:\n" ); - int currentDelay = ((SysCAMSTPortTDF) connectors.get(minIndex).get_p2().getComponent()).getDelay(); - jta.append(currentDelay-(int)tmpBuffer.getMinValue() +" in port \"" - +((SysCAMSTPortTDF) connectors.get(minIndex).get_p2().getComponent()).getName() - +"\" from block \""+ ((SysCAMSTPortTDF) connectors.get(minIndex).get_p2().getComponent()).getBlockTDF().getName()+"\"\n"); - */ - throw new InterruptedException(); - } else { - System.out.println("Schedule complete-STOP" ); + int currentDelay = 0; + int suggestedDelay; + for(int i = 0; i < tmpBuffer.getDimension(); i++) { + if (tmpBuffer.getEntry(i) < 0) { + tdfPort = (SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent(); + currentDelay = tdfPort.getDelay(); + suggestedDelay = tdfPort.getDelay() - (int)tmpBuffer.getEntry(i); + tdfPort.setDelay(suggestedDelay); + tdfPort.setRecompute(true); + } + } + recompute[1] = true; } return recompute; } diff --git a/src/main/java/ui/window/JDialogSysCAMSPortDE.java b/src/main/java/ui/window/JDialogSysCAMSPortDE.java index 2605b466ea..aeb730be44 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortDE.java @@ -215,6 +215,7 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { listArrayTypeString.add("int"); listArrayTypeString.add("bool"); listArrayTypeString.add("double"); + listArrayTypeString.add("sc_uint<32>"); if (port.getFather() != null) { if (port.getFather() instanceof SysCAMSBlockDE) { if (!((SysCAMSBlockDE) port.getFather()).getListTypedef().isEmpty()) { @@ -291,14 +292,17 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { gridBag.setConstraints(sensitivePanel, constraints); boxPanel.add(sensitivePanel); - listSensitiveString = new String[2]; - listSensitiveString[0] = "positive"; - listSensitiveString[1] = "negative"; + listSensitiveString = new String[3]; + listSensitiveString[0] = ""; + listSensitiveString[1] = "positive"; + listSensitiveString[2] = "negative"; sensitiveComboBoxString = new JComboBox<String>(listSensitiveString); - if (port.getSensitiveMethod().equals("") || port.getSensitiveMethod().equals("positive")) { + if (port.getSensitiveMethod().equals("")) { sensitiveComboBoxString.setSelectedIndex(0); + } else if (port.getSensitiveMethod().equals("positive")) { + sensitiveComboBoxString.setSelectedIndex(1); } else if (port.getSensitiveMethod().equals("negative")) { - sensitiveComboBoxString.setSelectedIndex(1); + sensitiveComboBoxString.setSelectedIndex(2); } sensitiveComboBoxString.setActionCommand("Sensitive_method"); sensitiveComboBoxString.setEnabled(port.getSensitive()); @@ -413,4 +417,4 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { this.dispose(); } } -} \ No newline at end of file +} -- GitLab