diff --git a/src/main/java/syscamstranslator/SysCAMSTBlockDE.java b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java index ea5bc822604116ba9bd47e4b1d19e211cc1dfd12..9bcb3fe91ba7ed78cd13369a0c9ad4c05d7d843c 100644 --- a/src/main/java/syscamstranslator/SysCAMSTBlockDE.java +++ b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java @@ -52,6 +52,7 @@ import javax.swing.DefaultListModel; public class SysCAMSTBlockDE extends SysCAMSTComponent { private String name; + private String clockName; // private int period; // private String time; private String nameFn; @@ -66,8 +67,9 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent { private LinkedList<SysCAMSTPortDE> portDE; - public SysCAMSTBlockDE(String _name, String _nameFn, String _code, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) { + public SysCAMSTBlockDE(String _name, String _clockName, String _nameFn, String _code, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) { name = _name; + clockName = _clockName; // period = _period; // time = _time; nameFn = _nameFn; @@ -93,6 +95,11 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent { return name; } + public String getClockName() { + return clockName; + } + + public String getNameFn() { return nameFn; } diff --git a/src/main/java/syscamstranslator/SysCAMSTClock.java b/src/main/java/syscamstranslator/SysCAMSTClock.java index 07fd8383c779e366d5969925fc14bf00743ab925..3144723f9daf0ef8907240aa3744d8abf4cd2319 100644 --- a/src/main/java/syscamstranslator/SysCAMSTClock.java +++ b/src/main/java/syscamstranslator/SysCAMSTClock.java @@ -52,15 +52,17 @@ public class SysCAMSTClock extends SysCAMSTComponent{ private String unit; private double dutyCycle; private double startTime; + private String unitStartTime; private boolean posFirst; - public SysCAMSTClock(String _name, double _frequency, String _unit, double _dutyCycle, double _startTime, boolean _posFirst) { + public SysCAMSTClock(String _name, double _frequency, String _unit, double _dutyCycle, double _startTime, String _unitStartTime, boolean _posFirst) { name = _name; frequency = _frequency; unit = _unit; dutyCycle = _dutyCycle; startTime = _startTime; + unitStartTime = _unitStartTime; posFirst = _posFirst; } @@ -77,6 +79,10 @@ public class SysCAMSTClock extends SysCAMSTComponent{ return unit; } + public String getUnitStartTime() { + return unitStartTime; + } + public double getDutyCycle() { return dutyCycle; } @@ -103,6 +109,10 @@ public class SysCAMSTClock extends SysCAMSTComponent{ unit = _unit; } + public void setUnitStartTime(String _unitStartTime) { + unitStartTime = _unitStartTime; + } + public void setDutyCycle(double _dutyCycle) { dutyCycle = _dutyCycle; } diff --git a/src/main/java/syscamstranslator/SysCAMSTCluster.java b/src/main/java/syscamstranslator/SysCAMSTCluster.java index 17b8059778c918b3b4ec2e8c3b92869f70639d08..6f9f7593e53cfd7dc31e901c4fbcbd5c1b80e88e 100644 --- a/src/main/java/syscamstranslator/SysCAMSTCluster.java +++ b/src/main/java/syscamstranslator/SysCAMSTCluster.java @@ -81,13 +81,13 @@ public class SysCAMSTCluster extends SysCAMSTComponent { public void addBlockDE(SysCAMSTBlockDE _blockDE){ blockDE.add(_blockDE); } + + public void addClock(SysCAMSTClock _clock){ + clock.add(_clock); + } public LinkedList<SysCAMSTClock> getClock(){ return clock; } - public void addBlockDE(SysCAMSTClock _clock){ - clock.add(_clock); - } - } diff --git a/src/main/java/syscamstranslator/SysCAMSTPortConverter.java b/src/main/java/syscamstranslator/SysCAMSTPortConverter.java index 98a45a4148ee7243d01f7628da5ca4823cb0d501..1997ea6b746ca362e685bae5b80c984e19c91ca7 100644 --- a/src/main/java/syscamstranslator/SysCAMSTPortConverter.java +++ b/src/main/java/syscamstranslator/SysCAMSTPortConverter.java @@ -54,18 +54,20 @@ public class SysCAMSTPortConverter extends SysCAMSTComponent { private int rate; private int delay; private int origin; + private int nbits; private String ConvType; private boolean recompute; private SysCAMSTBlockTDF blockTDF; - public SysCAMSTPortConverter(String _name, double _period, String _time, int _rate, int _delay, int _origin, String _ConvType, SysCAMSTBlockTDF _blockTDF) { + public SysCAMSTPortConverter(String _name, double _period, String _time, int _rate, int _delay, int _origin, int _nbits, String _ConvType, SysCAMSTBlockTDF _blockTDF) { name = _name; period = _period; time = _time; rate = _rate; delay = _delay; origin = _origin; + nbits = _nbits; ConvType = _ConvType; blockTDF = _blockTDF; recompute = false; @@ -90,6 +92,11 @@ public class SysCAMSTPortConverter extends SysCAMSTComponent { public int getRate() { return rate; } + + public int getNbits() { + return nbits; + } + public void setRate(int _rate) { rate = _rate; @@ -119,6 +126,10 @@ public class SysCAMSTPortConverter extends SysCAMSTComponent { return ConvType; } + public void setConvType(String _ConvType) { + ConvType = _ConvType; + } + public SysCAMSTBlockTDF getBlockTDF() { return blockTDF; } diff --git a/src/main/java/syscamstranslator/SysCAMSTPortDE.java b/src/main/java/syscamstranslator/SysCAMSTPortDE.java index 961db9e4e08a851feb59bb8e1ac5cc10ec3eba2e..22633316eac89fdb83942997db4e49794fab0d43 100644 --- a/src/main/java/syscamstranslator/SysCAMSTPortDE.java +++ b/src/main/java/syscamstranslator/SysCAMSTPortDE.java @@ -56,6 +56,7 @@ public class SysCAMSTPortDE extends SysCAMSTComponent { // private int rate; // private int delay; private int origin; + private int nbits; private String DEType; private boolean sensitive; private String sensitiveMethod; @@ -65,52 +66,56 @@ public class SysCAMSTPortDE extends SysCAMSTComponent { private ELNTCluster cluster; private ELNTModule module; - public SysCAMSTPortDE(String _name, int _origin, String _DEType, boolean _sensitive, String _sensitiveMethod, SysCAMSTBlockDE _blockDE) { + public SysCAMSTPortDE(String _name, int _origin, int _nbits, String _DEType, boolean _sensitive, String _sensitiveMethod, SysCAMSTBlockDE _blockDE) { name = _name; // period = _period; // time = _time; // rate = _rate; // delay = _delay; origin = _origin; + nbits= _nbits; DEType = _DEType; sensitive = _sensitive; sensitiveMethod = _sensitiveMethod; blockDE = _blockDE; } - public SysCAMSTPortDE(String _name, int _origin, String _DEType, boolean _sensitive, String _sensitiveMethod, SysCAMSTBlockGPIO2VCI _blockGPIO2VCI) { + public SysCAMSTPortDE(String _name, int _origin, int _nbits, String _DEType, boolean _sensitive, String _sensitiveMethod, SysCAMSTBlockGPIO2VCI _blockGPIO2VCI) { name = _name; // period = _period; // time = _time; // rate = _rate; // delay = _delay; - origin = _origin; + origin = _origin; + nbits= _nbits; DEType = _DEType; sensitive = _sensitive; sensitiveMethod = _sensitiveMethod; blockGPIO2VCI = _blockGPIO2VCI; } - public SysCAMSTPortDE(String _name, int _origin, String _DEType, boolean _sensitive, String _sensitiveMethod, ELNTCluster _cluster) { + public SysCAMSTPortDE(String _name, int _origin, int _nbits, String _DEType, boolean _sensitive, String _sensitiveMethod, ELNTCluster _cluster) { name = _name; // period = _period; // time = _time; // rate = _rate; // delay = _delay;ELNTCluster origin = _origin; + nbits= _nbits; DEType = _DEType; sensitive = _sensitive; sensitiveMethod = _sensitiveMethod; cluster = _cluster; } - public SysCAMSTPortDE(String _name, int _origin, String _DEType, boolean _sensitive, String _sensitiveMethod, ELNTModule _module) { + public SysCAMSTPortDE(String _name, int _origin, int _nbits, String _DEType, boolean _sensitive, String _sensitiveMethod, ELNTModule _module) { name = _name; // period = _period; // time = _time; // rate = _rate; // delay = _delay;ELNTCluster origin = _origin; + nbits= _nbits; DEType = _DEType; sensitive = _sensitive; sensitiveMethod = _sensitiveMethod; @@ -141,10 +146,18 @@ public class SysCAMSTPortDE extends SysCAMSTComponent { return origin; } + public int getNbits() { + return nbits; + } + public String getDEType() { return DEType; } + public void setDEType(String _DEType) { + DEType = _DEType; + } + public boolean getSensitive() { return sensitive; } @@ -168,4 +181,4 @@ public class SysCAMSTPortDE extends SysCAMSTComponent { public ELNTModule getModule() { return module; } -} \ No newline at end of file +} diff --git a/src/main/java/syscamstranslator/toSysCAMS/#Header.java# b/src/main/java/syscamstranslator/toSysCAMS/#Header.java# new file mode 100644 index 0000000000000000000000000000000000000000..382661ce99d5efb0749bcd71f3272ee7910fe480 --- /dev/null +++ b/src/main/java/syscamstranslator/toSysCAMS/#Header.java# @@ -0,0 +1,115 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * Daniela Genius, Lip6, UMR 7606 + * + * ludovic.apvrille AT enst.fr + * daniela.genius@lip6.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +/* this class produces the lines containing essentially the initial #includes; we include all potential components event if they are not used in the deployment diagram*/ + +/* authors: v1.0 Raja GATGOUT 2014 + v2.0 Daniela GENIUS, Julien HENON 2015 */ + +package syscamstranslator.toSysCAMS; + +import java.util.LinkedList; + +import syscamstranslator.*; + +/** + * Class Header + * Header of files .h and .cpp + * Creation: 14/05/2018 + * @version 1.0 14/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class Header { + static private String headerPrimitiveTDF; + static private String headerPrimitiveDE; + static private String headerCluster; + + private final static String CR = "\n"; + private final static String CR2 = "\n\n"; + + Header() {} + + public static String getPrimitiveHeaderTDF(SysCAMSTBlockTDF tdf) { + if (tdf != null) { + headerPrimitiveTDF = "#ifndef " + tdf.getName().toUpperCase() + "_H"+ CR + + "#define " + tdf.getName().toUpperCase() + "_H" + CR2 + + "#include <cmath>" + CR + "#include <iostream>" + CR + "#include <systemc-ams>" + CR2; + } else { + headerPrimitiveTDF = ""; + } + return headerPrimitiveTDF; + } + + public static String getPrimitiveHeaderDE(SysCAMSTBlockDE de) { + if (de != null) { + headerPrimitiveDE = "#ifndef " + de.getName().toUpperCase() + "_H"+ CR + + "#define " + de.getName().toUpperCase() + "_H" + CR2 + + "#include <cmath>" + CR + "#include <iostream>" + CR + "#include <systemc>" + CR2; + } else { + headerPrimitiveDE = ""; + } + return headerPrimitiveDE; + } + + public static String getClusterHeader(SysCAMSTCluster cluster) { + if (cluster != null) { + headerCluster = "#include <systemc-ams>" + CR; + LinkedList<SysCAMSTBlockTDF> blocks = cluster.getBlockTDF(); + + for (SysCAMSTBlockTDF b : blocks) { + headerCluster = headerCluster + "#include \"generated_H/" + b.getName() + ".h\"" + CR;//modification DG + } + + //ajoute DG + LinkedList<SysCAMSTBlockDE> blocksDE = cluster.getBlockDE(); + + for (SysCAMSTBlockDE b : blocksDE) { + headerCluster = headerCluster + "#include \"generated_H/" + b.getName() + ".h\"" + CR;//DG + } + + headerCluster = headerCluster + CR; + } else { + headerCluster = ""; + } + + return headerCluster; + } +} diff --git a/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java b/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java index d6bc3f5da8ced7acf574948b7a5e74f88db87412..25b63678b3295fc6e6b38cbbdfaf4d975fb963df 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java @@ -85,64 +85,62 @@ public class ClusterCode { if ((c.get_p1().getComponent() instanceof SysCAMSTPortTDF && c.get_p2().getComponent() instanceof SysCAMSTPortTDF) || (c.get_p1().getComponent() instanceof SysCAMSTPortTDF && c.get_p2().getComponent() instanceof SysCAMSTPortTDF)) { if (c.getName().equals("")) { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + "> " + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + " > " + "sig_" + nb_con + ";" + CR; names.add("sig_" + nb_con); nb_con++; } else { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + "> " + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + " > " + c.getName() + ";" + CR; names.add(c.getName()); } } else if ((c.get_p1().getComponent() instanceof SysCAMSTPortConverter && c.get_p2().getComponent() instanceof SysCAMSTPortDE)) { if (c.getName().equals("")) { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p1().getComponent()).getConvType() + "> " + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p1().getComponent()).getConvType() + " > " + "sig_" + nb_con + ";" + CR; names.add("sig_" + nb_con); nb_con++; } else { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p1().getComponent()).getConvType() + "> " + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p1().getComponent()).getConvType() + " > " + c.getName() + ";" + CR; names.add(c.getName()); } } else if ((c.get_p2().getComponent() instanceof SysCAMSTPortConverter && c.get_p1().getComponent() instanceof SysCAMSTPortDE)) { if (c.getName().equals("")) { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p2().getComponent()).getConvType() + "> " + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p2().getComponent()).getConvType() + " > " + "sig_" + nb_con + ";" + CR; names.add("sig_" + nb_con); nb_con++; } else { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p2().getComponent()).getConvType() + "> " + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p2().getComponent()).getConvType() + " > " + c.getName() + ";" + CR; names.add(c.getName()); } } else if ((c.get_p1().getComponent() instanceof SysCAMSTPortDE && c.get_p2().getComponent() instanceof SysCAMSTPortDE) || (c.get_p2().getComponent() instanceof SysCAMSTPortDE && c.get_p1 ().getComponent() instanceof SysCAMSTPortDE)) { if (c.getName().equals("")) { - corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) c.get_p1().getComponent()).getDEType() + "> " + corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) c.get_p1().getComponent()).getDEType() + " > " + "sig_" + nb_con + ";" + CR; names.add("sig_" + nb_con); nb_con++; } else { - corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) c.get_p1().getComponent()).getDEType() + "> " + corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) c.get_p1().getComponent()).getDEType() + " > " + c.getName() + ";" + CR; names.add(c.getName()); } } } - corpsCluster = corpsCluster + CR + "\t// Instantiate headers files as well as bind their ports to the signal." + CR; - - - + corpsCluster = corpsCluster + CR + "\t// Instantiate clocks." + CR; + for (SysCAMSTClock t : clock) { + corpsCluster = corpsCluster + "\t sc_clock " + t.getName() + " (\"" + t.getName() + "\"," + t.getFrequency()+","+ t.getUnit()+","+ t.getDutyCycle()+","+ t.getStartTime()+","+ t.getUnit()+","+ t.getPosFirst()+");" + CR; } - //ToDo 9.7.2019: add lines for reading (several) clock ports and sensitivity lists - - - + + corpsCluster = corpsCluster + CR + "\t// Instantiate headers files as well as bind their ports to the signal." + CR; + for (SysCAMSTBlockTDF t : tdf) { corpsCluster = corpsCluster + "\t" + t.getName() + " " + t.getName() + "_" + nb_block + "(\"" + t.getName() + "_" + nb_block + "\");" + CR; diff --git a/src/main/java/syscamstranslator/toSysCAMS/Header.java b/src/main/java/syscamstranslator/toSysCAMS/Header.java index c5a14792643758157ea7f9e114eeb9566bc7144f..382661ce99d5efb0749bcd71f3272ee7910fe480 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/Header.java +++ b/src/main/java/syscamstranslator/toSysCAMS/Header.java @@ -91,17 +91,25 @@ public class Header { public static String getClusterHeader(SysCAMSTCluster cluster) { if (cluster != null) { - LinkedList<SysCAMSTBlockTDF> blocks = cluster.getBlockTDF(); - - headerCluster = "#include <systemc-ams>" + CR; + headerCluster = "#include <systemc-ams>" + CR; + LinkedList<SysCAMSTBlockTDF> blocks = cluster.getBlockTDF(); for (SysCAMSTBlockTDF b : blocks) { - headerCluster = headerCluster + "#include \"" + b.getName() + ".h\"" + CR; + headerCluster = headerCluster + "#include \"generated_H/" + b.getName() + ".h\"" + CR;//modification DG + } + + //ajoute DG + LinkedList<SysCAMSTBlockDE> blocksDE = cluster.getBlockDE(); + + for (SysCAMSTBlockDE b : blocksDE) { + headerCluster = headerCluster + "#include \"generated_H/" + b.getName() + ".h\"" + CR;//DG } + headerCluster = headerCluster + CR; } else { headerCluster = ""; } + return headerCluster; - } + } } diff --git a/src/main/java/syscamstranslator/toSysCAMS/Header.java-orig b/src/main/java/syscamstranslator/toSysCAMS/Header.java-orig new file mode 100644 index 0000000000000000000000000000000000000000..c5a14792643758157ea7f9e114eeb9566bc7144f --- /dev/null +++ b/src/main/java/syscamstranslator/toSysCAMS/Header.java-orig @@ -0,0 +1,107 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * Daniela Genius, Lip6, UMR 7606 + * + * ludovic.apvrille AT enst.fr + * daniela.genius@lip6.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +/* this class produces the lines containing essentially the initial #includes; we include all potential components event if they are not used in the deployment diagram*/ + +/* authors: v1.0 Raja GATGOUT 2014 + v2.0 Daniela GENIUS, Julien HENON 2015 */ + +package syscamstranslator.toSysCAMS; + +import java.util.LinkedList; + +import syscamstranslator.*; + +/** + * Class Header + * Header of files .h and .cpp + * Creation: 14/05/2018 + * @version 1.0 14/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class Header { + static private String headerPrimitiveTDF; + static private String headerPrimitiveDE; + static private String headerCluster; + + private final static String CR = "\n"; + private final static String CR2 = "\n\n"; + + Header() {} + + public static String getPrimitiveHeaderTDF(SysCAMSTBlockTDF tdf) { + if (tdf != null) { + headerPrimitiveTDF = "#ifndef " + tdf.getName().toUpperCase() + "_H"+ CR + + "#define " + tdf.getName().toUpperCase() + "_H" + CR2 + + "#include <cmath>" + CR + "#include <iostream>" + CR + "#include <systemc-ams>" + CR2; + } else { + headerPrimitiveTDF = ""; + } + return headerPrimitiveTDF; + } + + public static String getPrimitiveHeaderDE(SysCAMSTBlockDE de) { + if (de != null) { + headerPrimitiveDE = "#ifndef " + de.getName().toUpperCase() + "_H"+ CR + + "#define " + de.getName().toUpperCase() + "_H" + CR2 + + "#include <cmath>" + CR + "#include <iostream>" + CR + "#include <systemc>" + CR2; + } else { + headerPrimitiveDE = ""; + } + return headerPrimitiveDE; + } + + public static String getClusterHeader(SysCAMSTCluster cluster) { + if (cluster != null) { + LinkedList<SysCAMSTBlockTDF> blocks = cluster.getBlockTDF(); + + headerCluster = "#include <systemc-ams>" + CR; + + for (SysCAMSTBlockTDF b : blocks) { + headerCluster = headerCluster + "#include \"" + b.getName() + ".h\"" + CR; + } + headerCluster = headerCluster + CR; + } else { + headerCluster = ""; + } + return headerCluster; + } +} diff --git a/src/main/java/syscamstranslator/toSysCAMS/MakefileCode.java b/src/main/java/syscamstranslator/toSysCAMS/MakefileCode.java index 6080c5e4dd30844b5e12be61e623727f1f168627..e9ca713066f640ce01c3d618c6dd39e4358fd0c0 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/MakefileCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/MakefileCode.java @@ -54,6 +54,8 @@ import syscamstranslator.*; * * @version 1.0 02/06/2018 * @author Irina Kit Yan LEE + * @version 1.1 10/07/2019 + * @author Daniela GENIUS */ public class MakefileCode { @@ -93,11 +95,11 @@ public class MakefileCode { + clusters.get(i).getClusterName() + "_tb.cpp"; for (SysCAMSTBlockTDF t : tdf) { - corpsMakefile = corpsMakefile + " " + t.getName() + ".h"; + corpsMakefile = corpsMakefile+ " generated_H/" + t.getName() + ".h"; } for (SysCAMSTBlockDE t : de) { - corpsMakefile = corpsMakefile + " " + t.getName() + ".h"; + corpsMakefile = corpsMakefile + " generated_H/" + t.getName() + ".h"; } corpsMakefile = corpsMakefile + CR + "\t$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -lsystemc-ams -lsystemc | c++filt" + CR2; @@ -110,4 +112,4 @@ public class MakefileCode { } return corpsMakefile; } -} \ 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 03552b4092f251ceeabe8f429f9be362d2a813ee..97235c72543a58afffd5883c08b86c8f5d7bddd4 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java @@ -38,11 +38,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ -/* this class produces the lines containing essentially the initial #includes; we include all potential components event if they are not used in the deployment diagram*/ - -/* authors: v1.0 Raja GATGOUT 2014 - v2.0 Daniela GENIUS, Julien HENON 2015 */ - package syscamstranslator.toSysCAMS; import java.util.LinkedList; @@ -55,6 +50,8 @@ import syscamstranslator.*; * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE + * @version 1.1 12/07/2019 + * @author Irina Kit Yan LEE, Daniela GENIUS */ public class PrimitiveCode { @@ -67,7 +64,7 @@ public class PrimitiveCode { public static String getPrimitiveCodeTDF(SysCAMSTBlockTDF tdf) { corpsPrimitiveTDF = ""; - + System.out.println("TDF block"); if (tdf != null) { LinkedList<SysCAMSTPortTDF> tdfports = tdf.getPortTDF(); LinkedList<SysCAMSTPortConverter> convports = tdf.getPortConverter(); @@ -131,30 +128,36 @@ public class PrimitiveCode { 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; + // corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR + "\t\t{}" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR; } else { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR; + //corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR; } } + corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR;//correction DG corpsPrimitiveTDF = corpsPrimitiveTDF + "\t};" + CR2; } if (!tdfports.isEmpty()) { for (SysCAMSTPortTDF t : tdfports) { if (t.getOrigin() == 0) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_in<" + t.getTDFType() + "> " + t.getName() + ";" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_in <" + t.getTDFType() + "> " + t.getName() + ";" + CR; } else if (t.getOrigin() == 1) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_out<" + t.getTDFType() + "> " + t.getName() + ";" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_out <" + t.getTDFType() + "> " + t.getName() + ";" + CR; } } } + System.out.println("@@@@@ Conv ports empty?"); if (!convports.isEmpty()) { + System.out.println("@@@@@ Conv ports non empty"); for (SysCAMSTPortConverter conv : convports) { if (conv.getOrigin() == 0) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_in<" + conv.getConvType() + "> " + conv.getName() + ";" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_in <" + conv.getConvType()+"<" + conv.getNbits()+"> > " + conv.getName() + ";" + CR; System.out.println("@@@@@@@@@@@@@@@@@@2conv"+conv.getConvType()+conv.getNbits()); + } else if (conv.getOrigin() == 1) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_out<" + conv.getConvType() + "> " + conv.getName() + ";" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_out <" + conv.getConvType()+"<" + conv.getNbits()+"> > "+ conv.getName() + ";" + CR; System.out.println("@@@@@@@@@@@@@@@2conv"+conv.getConvType()+conv.getNbits()); } + } } @@ -379,7 +382,7 @@ public class PrimitiveCode { public static String getPrimitiveCodeDE(SysCAMSTBlockDE de) { corpsPrimitiveDE = ""; - + System.out.println("DE block"); if (de != null) { LinkedList<SysCAMSTPortDE> deports = de.getPortDE(); int cpt = 0; @@ -441,21 +444,29 @@ public class PrimitiveCode { if ((i > 0) && (i < de.getListStruct().getSize()-1)) { 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 && i != 0) { + corpsPrimitiveDE = corpsPrimitiveDE + "\t\t, " + identifier + "(" + value + ")" + CR;//DG + // } else { + // corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR; + // } } + corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR;//correction DG corpsPrimitiveDE = corpsPrimitiveDE + "\t};" + CR2; } + //DG modified, was sca:core + System.out.println("@@@@@@@@@DE ports empty?"); if (!deports.isEmpty()) { + System.out.println("@@@@@@@@@DE ports non empty"); 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.getNbits()+"> >" + t.getName() + ";" + CR; + + System.out.println("@@@@@@@@@2DE "+t.getDEType()+t.getNbits()); } 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.getNbits() +"> >"+ t.getName() + ";" + CR; + + System.out.println("@@@@@@@@@2DE "+t.getDEType()+t.getNbits()); } } } @@ -533,8 +544,10 @@ public class PrimitiveCode { corpsPrimitiveDE = corpsPrimitiveDE + "\t{}" + CR2; } - corpsPrimitiveDE = corpsPrimitiveDE + "private:" + CR; - + corpsPrimitiveDE = corpsPrimitiveDE + "private:" + CR +CR; + if(de.getClockName()!=""){ + corpsPrimitiveDE = corpsPrimitiveDE +"sc_in<bool> "+de.getClockName()+";"+CR; + } if (de.getListStruct().getSize() != 0) { String identifier, type, constant; for (int i = 0; i < de.getListStruct().size(); i++) { diff --git a/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java b/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java index 7bb2dc6ebefaa6cbb2480b21a17bfc721d5d555e..64b646d1724f4a674d5e501926608704f95f6d90 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java +++ b/src/main/java/syscamstranslator/toSysCAMS/TopCellGenerator.java @@ -56,6 +56,8 @@ import java.util.LinkedList; * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE + * @version 1.1 12/07/2018 + * @author Irina Kit Yan LEE, Daniela GENIUS */ public class TopCellGenerator { @@ -105,13 +107,9 @@ public class TopCellGenerator { try { // Save file .cpp System.err.println(path + GENERATED_PATH1 + cluster.getClusterName() + ".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{ + System.err.println(path + cluster.getClusterName() + ".cpp"); 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); @@ -132,18 +130,13 @@ public class TopCellGenerator { for (SysCAMSTBlockTDF t : tdf) { try { System.err.println(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 + System.err.println(path + t.getName() + ".h"); 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(); @@ -154,18 +147,13 @@ public class TopCellGenerator { for (SysCAMSTBlockDE t : de) { try { System.err.println(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 + System.err.println(path + t.getName() + ".h"); + 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(); diff --git a/src/main/java/syscamstranslator/toSysCAMSCluster/ClusterCode.java b/src/main/java/syscamstranslator/toSysCAMSCluster/ClusterCode.java index b9411223f4dc42f6864f1e925663cdf8c214e41a..8477757c5d8aed9909cf75b58da1aad183552d5f 100644 --- a/src/main/java/syscamstranslator/toSysCAMSCluster/ClusterCode.java +++ b/src/main/java/syscamstranslator/toSysCAMSCluster/ClusterCode.java @@ -79,6 +79,7 @@ public class ClusterCode { for (SysCAMSTClock t : clock) { + System.out.println("Cluster clock"); corpsCluster = corpsCluster + "\t sc_clock " + t.getName() + " (\"" + t.getName() + "\"," + t.getFrequency()+","+ t.getUnit()+","+ t.getDutyCycle()+","+ t.getStartTime()+","+ t.getUnit()+","+ t.getPosFirst()+");" + CR; } //ToDo 9.7.2019: add lines for reading (several) clock ports and sensitivity lists diff --git a/src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCodeCluster.java b/src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCodeCluster.java index e8a1b1e4f94ccc50f2f4a17d0a3f66e276a209d4..6c5508653e828077bbe710d25167b9054b14ac7f 100644 --- a/src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCodeCluster.java +++ b/src/main/java/syscamstranslator/toSysCAMSCluster/PrimitiveCodeCluster.java @@ -38,11 +38,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ -/* this class produces the lines containing essentially the initial #includes; we include all potential components event if they are not used in the deployment diagram*/ - -/* authors: v1.0 Raja GATGOUT 2014 - v2.0 Daniela GENIUS, Julien HENON 2015 */ - package syscamstranslator.toSysCAMSCluster; import java.util.LinkedList; @@ -55,6 +50,8 @@ import syscamstranslator.*; * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE + * @version 1.1 12/07/2019 + * @author Irina Kit Yan LEE, Daniela GENIUS */ public class PrimitiveCodeCluster { @@ -130,10 +127,11 @@ public class PrimitiveCodeCluster { if ((i > 0)) { corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR; } - if (i == tdf.getListStruct().getSize()-1) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR; - } + // if (i == tdf.getListStruct().getSize()-1) { + // corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR; + // }//deleted DG } + corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR;//moved DG corpsPrimitiveTDF = corpsPrimitiveTDF + "\t};" + CR2; } @@ -440,9 +438,9 @@ public class PrimitiveCodeCluster { if ((i > 0)) { corpsPrimitiveDE = corpsPrimitiveDE + "\t\t, " + identifier + "(" + value + ")" + CR; } - if (i == de.getListStruct().getSize()-1) { - corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR; - } + if (i == de.getListStruct().getSize()-1) { + corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR; + } } corpsPrimitiveDE = corpsPrimitiveDE + "\t};" + CR2; } @@ -533,6 +531,10 @@ public class PrimitiveCodeCluster { } corpsPrimitiveDE = corpsPrimitiveDE + "private:" + CR; + + if(de.getClockName()!=""){ + corpsPrimitiveDE = corpsPrimitiveDE +"sc_in<bool> "+de.getClockName()+";"+CR; + } if (de.getListStruct().getSize() != 0) { String identifier, type, constant; diff --git a/src/main/java/syscamstranslator/toSysCAMSCluster/TopCellGeneratorCluster.java b/src/main/java/syscamstranslator/toSysCAMSCluster/TopCellGeneratorCluster.java index b19109685986197382b2547516727067d684d040..132a4a05bf23b18c87bf8181f8de87bcba758577 100644 --- a/src/main/java/syscamstranslator/toSysCAMSCluster/TopCellGeneratorCluster.java +++ b/src/main/java/syscamstranslator/toSysCAMSCluster/TopCellGeneratorCluster.java @@ -38,11 +38,7 @@ knowledge of the CeCILL license and that you accept its terms. */ -/* Generator of the top cell for simulation with SoCLib virtual component - library */ - -/* authors: v1.0 Raja GATGOUT 2014 - v2.0 Daniela GENIUS, Julien HENON 2015 */ +/* Generator of the top cell for simulation with SystemC-AMS */ package syscamstranslator.toSysCAMSCluster; @@ -57,7 +53,9 @@ import java.util.LinkedList; * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE * @version 1.1 30/07/2018 - * @author Rodrigo CORTES PORTO + * @author Irina Kit Yan LEE, Rodrigo CORTES PORTO + * @version 1.2 12/07/2019 + * @author Irina Kit Yan LEE, Rodrigo CORTES PORTO, Daniela GENIUS */ public class TopCellGeneratorCluster { @@ -76,25 +74,7 @@ public class TopCellGeneratorCluster { public String generateTopCell(SysCAMSTCluster c, LinkedList<SysCAMSTConnector> connectors) { if (c == null) { System.out.println("***Warning: require at least one cluster***"); - } - /*if (TopCellGeneratorCluster.syscams.getNbBlockTDF() == 0) { - System.out.println("***Warning: require at least one TDF block***"); - } - if (TopCellGeneratorCluster.syscams.getNbPortTDF() == 0) { - System.out.println("***Warning: require at least one TDF port***"); - } - if (TopCellGeneratorCluster.syscams.getNbBlockDE() == 0) { - System.out.println("***Warning: require at least one DE block***"); - } - if (TopCellGeneratorCluster.syscams.getNbPortDE() == 0) { - System.out.println("***Warning: require at least one DE port***"); - } - if (TopCellGeneratorCluster.syscams.getNbPortConverter() == 0) { - System.out.println("***Warning: require at least one converter port***"); - } - if (TopCellGeneratorCluster.syscams.getNbConnectorCluster() == 0) { - System.out.println("***Warning: require at least one connector***"); - }*/ + } String top = HeaderCluster.getClusterHeader(c) + ClusterCode.getClusterCode(c, connectors); return (top); } @@ -108,13 +88,8 @@ public class TopCellGeneratorCluster { try { // Save file .cpp System.err.println(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"); + System.err.println(path + cluster.getClusterName() + "_tdf.h"); + fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tdf.h"); top = generateTopCell(cluster, connectors); fw.write(top); @@ -137,13 +112,7 @@ public class TopCellGeneratorCluster { for (SysCAMSTBlockTDF t : tdf) { try { System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); - System.err.println(path + t.getName() + "_tdf.h"); - if(standalone==true){ - - fw = new FileWriter(path + "/" + t.getName() + "_tdf.h"); - } - - else + System.err.println(path + t.getName() + "_tdf.h"); fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); headerTDF = HeaderCluster.getPrimitiveHeaderTDF(t); fw.write(headerTDF); @@ -158,15 +127,9 @@ public class TopCellGeneratorCluster { } for (SysCAMSTBlockDE t : de) { try { - System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); + System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); - - if(standalone==true) - { - - fw = new FileWriter(path +"/" + t.getName() + "_tdf.h");} - else - fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); + fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); headerDE = HeaderCluster.getPrimitiveHeaderDE(t); fw.write(headerDE); diff --git a/src/main/java/syscamstranslator/toSysCAMSSoclib/ClusterCodeSoclib.java b/src/main/java/syscamstranslator/toSysCAMSSoclib/ClusterCodeSoclib.java index 3e0c261ce731ab18d3cfc5314818ee74ab390cca..a5af80e70445fec27d39e0d32fe4a9a446198c4f 100644 --- a/src/main/java/syscamstranslator/toSysCAMSSoclib/ClusterCodeSoclib.java +++ b/src/main/java/syscamstranslator/toSysCAMSSoclib/ClusterCodeSoclib.java @@ -87,15 +87,15 @@ public class ClusterCodeSoclib { 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() + "> " + 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() + "> " + 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() + "> " + corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getDEType() + " > " + "sig_" + nb_con + ";" + CR; //nb_con++; } diff --git a/src/main/java/syscamstranslator/toSysCAMSSoclib/PrimitiveCodeSoclib.java b/src/main/java/syscamstranslator/toSysCAMSSoclib/PrimitiveCodeSoclib.java index f32342d03a41b591cbc0a55117e569effaf81de6..256f7c3699df7fd3c70cdbbca193ee69abd63519 100644 --- a/src/main/java/syscamstranslator/toSysCAMSSoclib/PrimitiveCodeSoclib.java +++ b/src/main/java/syscamstranslator/toSysCAMSSoclib/PrimitiveCodeSoclib.java @@ -38,11 +38,6 @@ * knowledge of the CeCILL license and that you accept its terms. */ -/* this class produces the lines containing essentially the initial #includes; we include all potential components event if they are not used in the deployment diagram*/ - -/* authors: v1.0 Raja GATGOUT 2014 - v2.0 Daniela GENIUS, Julien HENON 2015 */ - package syscamstranslator.toSysCAMS; import java.util.LinkedList; @@ -55,6 +50,8 @@ import syscamstranslator.*; * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE + * @version 1.0 12/07/2019 + * @author Irina Kit Yan LEE, Daniela GENIUS */ public class PrimitiveCodeSoclib { @@ -131,29 +128,33 @@ public class PrimitiveCodeSoclib { 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; + // corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR + "\t\t{}" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR; } else { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR; + // corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR; } } + corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR;//moved DG corpsPrimitiveTDF = corpsPrimitiveTDF + "\t};" + CR2; } if (!tdfports.isEmpty()) { for (SysCAMSTPortTDF t : tdfports) { if (t.getOrigin() == 0) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_in< " + t.getTDFType() + " > " + t.getName() + ";" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_in < " + t.getTDFType() + " > " + t.getName() + ";" + CR; } else if (t.getOrigin() == 1) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_out< " + t.getTDFType() + " > " + t.getName() + ";" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_out < " + t.getTDFType() + " > " + t.getName() + ";" + CR; } } } if (!convports.isEmpty()) { for (SysCAMSTPortConverter conv : convports) { if (conv.getOrigin() == 0) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_in< " + conv.getConvType() + " > " + conv.getName() + ";" + CR; + // corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_in < " + conv.getConvType() + " > " + conv.getName() + ";" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_in <" + conv.getConvType()+"<" + conv.getNbits()+"> > " + conv.getName() + ";" + CR; System.out.println("@@@@@@@@@2SoclibConv"+conv.getConvType()+conv.getNbits()); } else if (conv.getOrigin() == 1) { - corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_out< " + conv.getConvType() + " > " + conv.getName() + ";" + CR; + // corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_out < " + conv.getConvType() + " > " + conv.getName() + ";" + CR; + corpsPrimitiveTDF = corpsPrimitiveTDF + "\tsca_tdf::sca_de::sca_out <" + conv.getConvType()+"<" + conv.getNbits()+"> > "+ conv.getName() + ";" + CR; System.out.println("@@@@@@@@@2SoclibConv"+conv.getConvType()+conv.getNbits()); } } } @@ -441,21 +442,23 @@ public class PrimitiveCodeSoclib { if ((i > 0) && (i < de.getListStruct().getSize()-1)) { 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 && i != 0) { + // corpsPrimitiveDE = corpsPrimitiveDE + "\t\t, " + identifier + "(" + value + ")" + CR + "\t\t{}" + CR; + corpsPrimitiveDE = corpsPrimitiveDE + "\t\t, " + identifier + "(" + value + ")" + CR; + // } else { + // corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR; + // } } + corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR; corpsPrimitiveDE = corpsPrimitiveDE + "\t};" + CR2; } if (!deports.isEmpty()) { for (SysCAMSTPortDE t : deports) { if (t.getOrigin() == 0) { - corpsPrimitiveDE = corpsPrimitiveDE + "\tsca_core::sca_in<" + t.getDEType() + "> " + t.getName() + ";" + CR; + corpsPrimitiveDE = corpsPrimitiveDE + "\tsca_core::sca_in <" + t.getDEType() + " > " + t.getName() + ";" + CR; } else if (t.getOrigin() == 1) { - corpsPrimitiveDE = corpsPrimitiveDE + "\tsca_core::sca_out<" + t.getDEType() + "> " + t.getName() + ";" + CR; + corpsPrimitiveDE = corpsPrimitiveDE + "\tsca_core::sca_out <" + t.getDEType() + " > " + t.getName() + ";" + CR; } } } @@ -534,6 +537,10 @@ public class PrimitiveCodeSoclib { } corpsPrimitiveDE = corpsPrimitiveDE + "private:" + CR; + + if(de.getClockName()!=""){ + corpsPrimitiveDE = corpsPrimitiveDE +"sc_in<bool> "+de.getClockName()+";"+CR; + } if (de.getListStruct().getSize() != 0) { String identifier, type, constant; diff --git a/src/main/java/syscamstranslator/toSysCAMSSoclib/TopCellGeneratorSoclib.java b/src/main/java/syscamstranslator/toSysCAMSSoclib/TopCellGeneratorSoclib.java index 119ea536cd41ed6af7e7076d4c4fbe0d084187b0..6e9b2edc79b53e22b46160f871291b030031c8c9 100644 --- a/src/main/java/syscamstranslator/toSysCAMSSoclib/TopCellGeneratorSoclib.java +++ b/src/main/java/syscamstranslator/toSysCAMSSoclib/TopCellGeneratorSoclib.java @@ -56,6 +56,8 @@ import java.util.LinkedList; * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE + * @version 1.1 12/07/2019 + * @author Irina Kit Yan LEE, Daniela Genius */ public class TopCellGeneratorSoclib { @@ -106,11 +108,7 @@ public class TopCellGeneratorSoclib { try { // Save file .cpp System.err.println(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 + System.err.println(path + cluster.getClusterName() + "_tdf.h"); fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tdf.h"); top = generateTopCell(cluster, connectors); fw.write(top); @@ -132,20 +130,13 @@ public class TopCellGeneratorSoclib { for (SysCAMSTBlockTDF t : tdf) { try { System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); - 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 + System.err.println(path + t.getName() + "_tdf.h"); fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); headerTDF = HeaderSoclib.getPrimitiveHeaderTDF(t); fw.write(headerTDF); - codeTDF = PrimitiveCodeSoclib.getPrimitiveCodeTDF(t); - // if(standalone==false) - // codeTDF = codeTDF + CR + "};" + CR2 + "#endif"+CR;//DG + codeTDF = PrimitiveCodeSoclib.getPrimitiveCodeTDF(t); fw.write(codeTDF); fw.close(); @@ -156,19 +147,12 @@ public class TopCellGeneratorSoclib { } for (SysCAMSTBlockDE t : de) { try { - System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); - - 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"); + System.err.println(path + GENERATED_PATH2 + t.getName() + "_tdf.h"); + fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + "_tdf.h"); headerDE = HeaderSoclib.getPrimitiveHeaderDE(t); fw.write(headerDE); - codeDE = PrimitiveCodeSoclib.getPrimitiveCodeDE(t); - //if(standalone==false) - // codeDE = codeDE + CR + "};" + CR2 + "#endif" +CR; + codeDE = PrimitiveCodeSoclib.getPrimitiveCodeDE(t); fw.write(codeDE); fw.close(); diff --git a/src/main/java/ui/SysCAMSPanelTranslator.java b/src/main/java/ui/SysCAMSPanelTranslator.java index 333194b077f42b6d8d2cc149d0894b099ac6c405..0a1a5649b78b5092dc4356965c7c128bc09d7087 100644 --- a/src/main/java/ui/SysCAMSPanelTranslator.java +++ b/src/main/java/ui/SysCAMSPanelTranslator.java @@ -51,6 +51,7 @@ import javax.swing.DefaultListModel; * Creation: 19/05/2018 * @version 1.0 19/05/2018 * @author Irina Kit Yan LEE + * @version 1.1 10/07/2019 Daniela GENIUS */ public class SysCAMSPanelTranslator { @@ -104,10 +105,11 @@ public class SysCAMSPanelTranslator { String portName = portDE.getPortName(); String type = portDE.getDEType(); int origin = portDE.getOrigin(); + int nbits = portDE.getNbits(); boolean sensitive = portDE.getSensitive(); String sensitiveMethod = portDE.getSensitiveMethod(); - SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, type, sensitive, sensitiveMethod, syscamsBlockGPIO2VCI); + SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, nbits, type, sensitive, sensitiveMethod, syscamsBlockGPIO2VCI); syscamsMap.put(portDE, syscamsPortDE); syscamsBlockGPIO2VCI.addPortDE(syscamsPortDE); @@ -120,6 +122,7 @@ public class SysCAMSPanelTranslator { SysCAMSBlockDE blockDE = (SysCAMSBlockDE) dp; String blockDEName = blockDE.getValue(); + String clockName = blockDE.getClockName(); // int periodBlock = blockDE.getPeriod(); // String time = blockDE.getTime(); // String nameFn = blockDE.getNameFn(); @@ -129,7 +132,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, clockName, "", "", null, "", "", "", null, null); List<SysCAMSPortDE> portsDE = blockDE.getAllInternalPortsDE(); for (int i = 0; i < portsDE.size(); i++) { @@ -143,10 +146,11 @@ public class SysCAMSPanelTranslator { int nbits = portDE.getNbits();//DG String type = portDE.getDEType(); int origin = portDE.getOrigin(); + boolean sensitive = portDE.getSensitive(); String sensitiveMethod = portDE.getSensitiveMethod(); - SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, type, sensitive, sensitiveMethod, syscamsBlockDE); + SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, nbits, type, sensitive, sensitiveMethod, syscamsBlockDE); syscamsMap.put(portDE, syscamsPortDE); syscamsBlockDE.addPortDE(syscamsPortDE); @@ -156,6 +160,25 @@ public class SysCAMSPanelTranslator { syscamsMap.put(blockDE, syscamsBlockDE); // System.out.println("@@@ DE block put in map @@@"); syscamsComponents.add(syscamsBlockDE); + + } else if (dp instanceof SysCAMSClock) { + SysCAMSClock clock = (SysCAMSClock) dp; + + String clockName = clock.getName(); + double frequency = clock.getFrequency(); + String unit = clock.getUnit(); + double dutyCycle = clock.getDutyCycle(); + double startTime = clock.getStartTime(); + String unitStartTime = clock.getUnitStartTime(); + boolean posFirst = clock.getPosFirst(); + + SysCAMSTClock syscamsClock = new SysCAMSTClock(clockName, frequency, unit, dutyCycle, startTime, unitStartTime, posFirst); + + + syscamsMap.put(clock, syscamsClock); + //System.out.println("@@@ Clock put in map @@@"); + syscamsComponents.add(syscamsClock); + } else if (dp instanceof SysCAMSCompositeComponent) { SysCAMSCompositeComponent cluster = (SysCAMSCompositeComponent) dp; @@ -165,6 +188,8 @@ public class SysCAMSPanelTranslator { List<SysCAMSBlockTDF> blocksTDF = cluster.getAllBlockTDFComponents(); List<SysCAMSBlockDE> blocksDE = cluster.getAllBlockDEComponents(); + List<SysCAMSClock> clocks = cluster.getAllClockComponents(); + for (int i = 0; i < blocksTDF.size(); i++) { SysCAMSBlockTDF blockTDF = blocksTDF.get(i); @@ -227,32 +252,29 @@ public class SysCAMSPanelTranslator { String type = portConverter.getConvType(); int origin = portConverter.getOrigin(); - SysCAMSTPortConverter syscamsPortConverter = new SysCAMSTPortConverter(portName, periodPort, time, rate, delay, origin, type, syscamsBlockTDF); + SysCAMSTPortConverter syscamsPortConverter = new SysCAMSTPortConverter(portName, periodPort, time, rate, delay, origin, nbits, type, syscamsBlockTDF); syscamsMap.put(portConverter, syscamsPortConverter); syscamsBlockTDF.addPortConverter(syscamsPortConverter); syscamsComponents.add(syscamsPortConverter); } - syscamsMap.put(blockTDF, syscamsBlockTDF); - //System.out.println("@@@ TDF block put in map @@@"); + syscamsMap.put(blockTDF, syscamsBlockTDF); syscamsCluster.addBlockTDF(syscamsBlockTDF); syscamsComponents.add(syscamsBlockTDF); } for (int i = 0; i < blocksDE.size(); i++) { SysCAMSBlockDE blockDE = blocksDE.get(i); - String blockDEName = blockDE.getValue(); -// int periodBlock = blockDE.getPeriod(); -// String time = blockDE.getTime(); + String blockDEName = blockDE.getValue(); String clockName = blockDE.getClockName(); String nameFn = blockDE.getNameFn(); String code = blockDE.getCode(); DefaultListModel<String> listStruct = blockDE.getListStruct(); String nameTemplate = blockDE.getNameTemplate(); String typeTemplate = blockDE.getTypeTemplate(); - String valueTemplate = blockDE.getValueTemplate(); + String valueTemplate = blockDE.getValueTemplate(); DefaultListModel<String> listTypedef = blockDE.getListTypedef(); - SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, nameFn, code, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef, syscamsCluster); + SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, clockName, nameFn, code, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef, syscamsCluster); List<SysCAMSPortDE> portsDE = blockDE.getAllInternalPortsDE(); for (int j = 0; j < portsDE.size(); j++) { @@ -265,10 +287,11 @@ public class SysCAMSPanelTranslator { // int delay = portDE.getDelay(); String type = portDE.getDEType(); int origin = portDE.getOrigin(); + int nbits = portDE.getNbits(); boolean sensitive = portDE.getSensitive(); String sensitiveMethod = portDE.getSensitiveMethod(); - SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, type, sensitive, sensitiveMethod, syscamsBlockDE); + SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, origin, nbits, type, sensitive, sensitiveMethod, syscamsBlockDE); syscamsMap.put(portDE, syscamsPortDE); syscamsBlockDE.addPortDE(syscamsPortDE); @@ -278,6 +301,26 @@ public class SysCAMSPanelTranslator { syscamsCluster.addBlockDE(syscamsBlockDE); syscamsComponents.add(syscamsBlockDE); } + + + for (int i = 0; i < clocks.size(); i++) { + SysCAMSClock clock = clocks.get(i); + + String clockName = clock.getName(); + double frequency = clock.getFrequency(); + String unit = clock.getUnit(); + double dutyCycle = clock.getDutyCycle(); + double startTime = clock.getStartTime(); + String unitStartTime = clock.getUnitStartTime(); + boolean posFirst = clock.getPosFirst(); + + SysCAMSTClock syscamsClock = new SysCAMSTClock(clockName, frequency, unit, dutyCycle, startTime, unitStartTime, posFirst); + + syscamsMap.put(clock, syscamsClock); + syscamsCluster.addClock(syscamsClock); + syscamsComponents.add(syscamsClock); + } + syscamsMap.put(cluster, syscamsCluster); syscamsComponents.add(syscamsCluster); } else if (dp instanceof SysCAMSPortConnector) { diff --git a/src/main/java/ui/syscams/SysCAMSBlockDE.java b/src/main/java/ui/syscams/SysCAMSBlockDE.java index 0e5b6e7c41da7ed5773ff499e560fc7ee4cba8b7..a07c780529f2d41884f3b83298e903b8a9cf95d5 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockDE.java +++ b/src/main/java/ui/syscams/SysCAMSBlockDE.java @@ -64,10 +64,11 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements private String nameFn; private String code; private String clock; + private String clockName; private DefaultListModel<String> listStruct; private String nameTemplate; private String typeTemplate; - private String valueTemplate; + private String valueTemplate; private DefaultListModel<String> listTypedef; private int maxFontSize = 14; @@ -303,6 +304,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements sb.append("<Attribute name_function=\"" + getNameFn()); // sb.append(getPeriod()); // sb.append("\" time=\"" + getTime()); + sb.append("\" clockName=\"" + getClockName()); sb.append("\" code=\"" + encode(getCode())); sb.append("\" listStruct=\"" + splitParameters(getListStruct())); sb.append("\" nameTemplate=\"" + getNameTemplate()); @@ -446,13 +448,15 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements if (elt.getTagName().equals("Attribute")) { // period = Integer.decode(elt.getAttribute("period")).intValue(); // time = elt.getAttribute("time"); + clockName = elt.getAttribute("clockName"); code = elt.getAttribute("code"); nameFn = elt.getAttribute("name_function"); listStruct = elt.getAttribute("listStruct"); nameTemplate = elt.getAttribute("nameTemplate"); typeTemplate = elt.getAttribute("typeTemplate"); - valueTemplate = elt.getAttribute("valueTemplate"); + valueTemplate = elt.getAttribute("valueTemplate"); listTypedef = elt.getAttribute("listTypedef"); + setClockName(clockName); // setPeriod(period); // setTime(time); setNameFn(nameFn); @@ -468,7 +472,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements setListStruct(lista); setNameTemplate(nameTemplate); setTypeTemplate(typeTemplate); - setValueTemplate(valueTemplate); + setValueTemplate(valueTemplate); String[] splitb = listTypedef.split("\\|"); DefaultListModel<String> listb = new DefaultListModel<String>(); for (String s : splitb) { diff --git a/src/main/java/ui/syscams/SysCAMSClock.java b/src/main/java/ui/syscams/SysCAMSClock.java index faaaadd2d2eba1d658fd93e46fd72df61528a2bf..f6096ea7701fda071e49a0ffb15fb0684615ca6e 100644 --- a/src/main/java/ui/syscams/SysCAMSClock.java +++ b/src/main/java/ui/syscams/SysCAMSClock.java @@ -68,6 +68,7 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw private String valueTemplate; private String name; private String unit; + private String unitStartTime; private double frequency; private double dutyCycle; private double startTime; @@ -116,8 +117,7 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw setCode(""); setListStruct(new DefaultListModel<String>()); setNameTemplate(""); - // setTypeTemplate(""); - //setValueTemplate(""); + setListTypedef(new DefaultListModel<String>()); myImageIcon = IconManager.imgic1202; @@ -173,19 +173,10 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw g.setFont(f.deriveFont(Font.BOLD)); g.drawString(value, x + textX + 1, y + currentFontSize + textX); g.setFont(f.deriveFont(Font.PLAIN)); -// if (this.getPeriod() != -1) { -// String s = "Tm = " + this.getPeriod() + " " + this.getTime(); -// g.drawString(s, x + textX + 1, y + height - currentFontSize - textX); -// } } else { g.setFont(f.deriveFont(Font.BOLD)); g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); - g.setFont(f.deriveFont(Font.PLAIN)); -// if (this.getPeriod() != -1) { -// String s = "Tm = " + this.getPeriod() + " " + this.getTime(); -// w = g.getFontMetrics().stringWidth(s); -// g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX); -// } + g.setFont(f.deriveFont(Font.PLAIN)); } g.setFont(fold); @@ -307,7 +298,7 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw //sb.append("\" code=\"" + encode(getCode())); //sb.append("\" listStruct=\"" + splitParameters(getListStruct())); sb.append("\" nameTemplate=\"" + getNameTemplate()); - sb.append("\" name=\"" + getName()); + //sb.append("\" name=\"" + getName()); sb.append("\" frequency =\"" + getFrequency()); sb.append("\" unit=\"" + getUnit()); sb.append("\" dutyCycle=\"" + getDutyCycle()); @@ -451,27 +442,22 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw if (n2.getNodeType() == Node.ELEMENT_NODE) { elt = (Element) n2; if (elt.getTagName().equals("Attribute")) { -// unit = elt.getAttribute("unit"); +// unit = elt.getAttribute("unit"); - //frequency = elt.getAttribute("frequency"); + unit = elt.getAttribute("unitStartTime"); + frequency = Double.valueOf(elt.getAttribute("frequency")).doubleValue(); dutyCycle = Double.valueOf(elt.getAttribute("dutyCycle")).doubleValue(); startTime = Double.valueOf(elt.getAttribute("startTime")).doubleValue(); - //posFirst = elt.getAttribute("posFirst");//ToDo boolean - //posFirst = true; - //dutyCycle = elt.getAttribute("dutyCycle"); - //startTime = elt.getAttribute("startTime"); - //listStruct = elt.getAttribute("listStruct"); + posFirst = Boolean.valueOf(elt.getAttribute("posFirst")).booleanValue(); nameTemplate = elt.getAttribute("nameTemplate"); - //typeTemplate = elt.getAttribute("typeTemplate"); - //valueTemplate = elt.getAttribute("valueTemplate"); - //listTypedef = elt.getAttribute("listTypedef"); + setFrequency(frequency); setDutyCycle(dutyCycle); setStartTime(startTime); - + setPosFirst(posFirst); //String[] splita = listStruct.split("\\|"); - DefaultListModel<String> lista = new DefaultListModel<String>(); + //DefaultListModel<String> lista = new DefaultListModel<String>(); /* for (String s : splita) { if (!s.equals("")) { lista.addElement(s); @@ -483,7 +469,7 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw //setTypeTemplate(typeTemplate); //setValueTemplate(valueTemplate); //String[] splitb = listTypedef.split("\\|"); - DefaultListModel<String> listb = new DefaultListModel<String>(); + //DefaultListModel<String> listb = new DefaultListModel<String>(); /*for (String s : splitb) { if (!s.equals("")) { listb.addElement(s); @@ -562,9 +548,9 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw listStruct = _listStruct; } - /* public String getName() { - return name; - }*/ + //public String getName() { + // return name; + // } public double getFrequency() { return frequency; @@ -574,6 +560,11 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw return unit; } + public String getUnitStartTime() { + return unitStartTime; + } + + public double getDutyCycle() { return dutyCycle; } @@ -604,6 +595,10 @@ public class SysCAMSClock extends TGCScalableWithInternalComponent implements Sw unit = _unit; } + public void setUnitStartTime(String _unitStartTime) { + unitStartTime = _unitStartTime; + } + public void setDutyCycle(double _dutyCycle) { dutyCycle = _dutyCycle; } diff --git a/src/main/java/ui/syscams/SysCAMSPortConverter.java b/src/main/java/ui/syscams/SysCAMSPortConverter.java index b423c50a09cb5fca18e01b5b3f8af59d2c35becb..fc382782ea0445f4b62afb62dca777ccc62f78ca 100644 --- a/src/main/java/ui/syscams/SysCAMSPortConverter.java +++ b/src/main/java/ui/syscams/SysCAMSPortConverter.java @@ -86,6 +86,11 @@ public class SysCAMSPortConverter extends SysCAMSPrimitivePort { public int getNbits() { return nbits; } + + public void setNbits(int nbits) { + this.nbits = nbits; + } + public void setRate(int rate) { this.rate = rate; } diff --git a/src/main/java/ui/syscams/SysCAMSPortDE.java b/src/main/java/ui/syscams/SysCAMSPortDE.java index 5c2478ae454f28817ff40103ad3989fcf81c56b9..dc4a1ab271bd0471bbea7694b47ed63ea57dc086 100644 --- a/src/main/java/ui/syscams/SysCAMSPortDE.java +++ b/src/main/java/ui/syscams/SysCAMSPortDE.java @@ -115,6 +115,11 @@ public class SysCAMSPortDE extends SysCAMSPrimitivePort { public int getNbits() { return nbits; } + + public void setNbits(int _nbits) { + nbits = _nbits; + } + public void setSensitive(boolean _sensitive) { sensitive = _sensitive; diff --git a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java index 80f14a1992b0044d2df8a042acc5b7d901b05cd9..8d063cafd1ed550125fffb2d6bfa3dc7c8034b37 100644 --- a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java +++ b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java @@ -565,7 +565,7 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple sb.append("\" nbits=\"" + ((SysCAMSPortConverter) this).getNbits());//DG sb.append("\" delay=\"" + ((SysCAMSPortConverter) this).getDelay()); - sb.append("\" type=\"" + encode(((SysCAMSPortConverter) this).getConvType())); + sb.append("\" type=\"" + encode(((SysCAMSPortConverter) this).getConvType())); } sb.append("\" />\n"); sb.append("</extraparam>\n"); @@ -579,9 +579,9 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple Element elt; double period; - int rate, delay; + int rate, delay, nbits; String type, time, sensitiveMethod; - Boolean sensitive; + Boolean sensitive, posFirst; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -608,27 +608,27 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple ((SysCAMSPortTDF) this).setDelay(delay); ((SysCAMSPortTDF) this).setTDFType(type); } else if (this instanceof SysCAMSPortDE) { - // ((SysCAMSPortDE)this).setPeriod(period); - // ((SysCAMSPortDE)this).setTime(time); - // ((SysCAMSPortDE)this).setRate(rate); - // ((SysCAMSPortDE)this).setDelay(delay); type = elt.getAttribute("type"); sensitive = Boolean.parseBoolean(elt.getAttribute("sensitive")); + nbits = Integer.decode(elt.getAttribute("nbits")).intValue(); sensitiveMethod = elt.getAttribute("sensitive_method"); ((SysCAMSPortDE) this).setDEType(type); ((SysCAMSPortDE) this).setSensitive(sensitive); ((SysCAMSPortDE) this).setSensitiveMethod(sensitiveMethod); + ((SysCAMSPortDE) this).setNbits(nbits); } else if (this instanceof SysCAMSPortConverter) { period = Double.valueOf(elt.getAttribute("period")).doubleValue(); time = elt.getAttribute("time"); rate = Integer.decode(elt.getAttribute("rate")).intValue(); delay = Integer.decode(elt.getAttribute("delay")).intValue(); type = elt.getAttribute("type"); + nbits = Integer.decode(elt.getAttribute("nbits")).intValue(); ((SysCAMSPortConverter) this).setPeriod(period); ((SysCAMSPortConverter) this).setTime(time); ((SysCAMSPortConverter) this).setRate(rate); - ((SysCAMSPortConverter)this).setDelay(delay); - ((SysCAMSPortConverter)this).setConvType(type); + ((SysCAMSPortConverter) this).setNbits(nbits); + ((SysCAMSPortConverter)this).setDelay(delay); + ((SysCAMSPortConverter)this).setConvType(type); } } makeValue(); diff --git a/src/main/java/ui/window/JDialogSysCAMSClock.java b/src/main/java/ui/window/JDialogSysCAMSClock.java index 7addeaaf47bdaf8b402ce98c3e1be22de5b59731..4f7346aa24f5e2f634851369472df64d1042ff69 100644 --- a/src/main/java/ui/window/JDialogSysCAMSClock.java +++ b/src/main/java/ui/window/JDialogSysCAMSClock.java @@ -295,7 +295,7 @@ public class JDialogSysCAMSClock extends JDialog implements ActionListener { gridBag.setConstraints(dutyCycleTextField, constraints); attributesBoxPanel.add(dutyCycleTextField); - listDutyCycleString = new String[4]; + /* listDutyCycleString = new String[4]; listDutyCycleString[0] = "s"; listDutyCycleString[1] = "ms"; listDutyCycleString[2] = "\u03BCs"; @@ -314,7 +314,7 @@ public class JDialogSysCAMSClock extends JDialog implements ActionListener { constraints = new GridBagConstraints(2, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(dutyCycleComboBoxString, constraints); - attributesBoxPanel.add(dutyCycleComboBoxString); + attributesBoxPanel.add(dutyCycleComboBoxString); */ // JLabel startTimeLabel = new JLabel("StartTime Tm : "); @@ -369,12 +369,12 @@ public class JDialogSysCAMSClock extends JDialog implements ActionListener { } constraints = new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 15, 10), 0, 0); - gridBag.setConstraints(posFirstTextField, constraints); - attributesBoxPanel.add(posFirstTextField); + //gridBag.setConstraints(posFirstTextField, constraints); + //attributesBoxPanel.add(posFirstTextField); listPosFirstString = new String[2]; - listPosFirstString[0] = "no"; - listPosFirstString[1] = "yes"; + listPosFirstString[0] = "false"; + listPosFirstString[1] = "true"; posFirstComboBoxString = new JComboBox<String>(listPosFirstString); if (clock.getUnit().equals("") || clock.getUnit().equals("no")) { @@ -388,408 +388,10 @@ public class JDialogSysCAMSClock extends JDialog implements ActionListener { gridBag.setConstraints(posFirstComboBoxString, constraints); attributesBoxPanel.add(posFirstComboBoxString); // - // - - + attributesBox.add(attributesBoxPanel); attributesMainPanel.add(attributesBox, BorderLayout.NORTH); - // --- Parameters ---// - /* parametersMainPanel.setLayout(new BorderLayout()); - - Box parametersBox = Box.createVerticalBox(); - parametersBox.setBorder(BorderFactory.createTitledBorder("Setting TDF clock parameters")); - - JPanel clockPanel = new JPanel(new GridLayout(3, 1)); - - // Struct - JPanel structPanel = new JPanel(); - structPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - GridBagLayout gridBagParameter = new GridBagLayout(); - GridBagConstraints constraintParameter = new GridBagConstraints(); - structPanel.setLayout(gridBagParameter); - TitledBorder border = new TitledBorder("Struct :"); - border.setTitleJustification(TitledBorder.CENTER); - border.setTitlePosition(TitledBorder.TOP); - structPanel.setBorder(border); - - JLabel nameParameterLabel = new JLabel("identifier"); - constraintParameter = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(nameParameterLabel, constraintParameter); - structPanel.add(nameParameterLabel); - - nameStructTextField = new JTextField(); - constraintParameter = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(nameStructTextField, constraintParameter); - structPanel.add(nameStructTextField); - - JLabel egalLabel = new JLabel("="); - constraintParameter = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(egalLabel, constraintParameter); - structPanel.add(egalLabel); - - JLabel valueParameterLabel = new JLabel("value"); - constraintParameter = new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(valueParameterLabel, constraintParameter); - structPanel.add(valueParameterLabel); - - valueStructTextField = new JTextField(); - constraintParameter = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(valueStructTextField, constraintParameter); - structPanel.add(valueStructTextField); - - JLabel pointsLabel = new JLabel(":"); - constraintParameter = new GridBagConstraints(3, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(pointsLabel, constraintParameter); - structPanel.add(pointsLabel); - - JLabel constantLabel = new JLabel("const"); - constraintParameter = new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(constantLabel, constraintParameter); - structPanel.add(constantLabel); - - constantStructRadioButton = new JRadioButton(); - constantStructRadioButton.setActionCommand("Const"); - constantStructRadioButton.setSelected(false); - constantStructRadioButton.addActionListener(this); - constraintParameter = new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(constantStructRadioButton, constraintParameter); - structPanel.add(constantStructRadioButton); - - JLabel typeParameterLabel = new JLabel("type"); - constraintParameter = new GridBagConstraints(5, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(typeParameterLabel, constraintParameter); - structPanel.add(typeParameterLabel); - - listTypeStructString = new String[6]; - listTypeStructString[0] = "bool"; - listTypeStructString[1] = "double"; - listTypeStructString[2] = "float"; - listTypeStructString[3] = "int"; - listTypeStructString[4] = "long"; - listTypeStructString[5] = "short"; - typeStructComboBoxString = new JComboBox<String>(listTypeStructString); - typeStructComboBoxString.setSelectedIndex(0); - typeStructComboBoxString.addActionListener(this); - constraintParameter = new GridBagConstraints(5, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(typeStructComboBoxString, constraintParameter); - structPanel.add(typeStructComboBoxString); - - JButton addModifyButton = new JButton("Add / Modify parameter"); - addModifyButton.setActionCommand("Add_Modify_Struct"); - addModifyButton.addActionListener(this); - constraintParameter = new GridBagConstraints(0, 2, 6, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - gridBagParameter.setConstraints(addModifyButton, constraintParameter); - structPanel.add(addModifyButton); - - clockPanel.add(structPanel); - - // Template - JPanel templatePanel = new JPanel(); - templatePanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - GridBagLayout templateGridBag = new GridBagLayout(); - GridBagConstraints templateConstraint = new GridBagConstraints(); - templatePanel.setLayout(templateGridBag); - TitledBorder templateBorder = new TitledBorder("Template :"); - templateBorder.setTitleJustification(TitledBorder.CENTER); - templateBorder.setTitlePosition(TitledBorder.TOP); - templatePanel.setBorder(templateBorder); - - JLabel nameTemplateLabel = new JLabel("identifier"); - templateConstraint = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - templateGridBag.setConstraints(nameTemplateLabel, templateConstraint); - templatePanel.add(nameTemplateLabel); - - nameTemplateTextField = new JTextField(clock.getNameTemplate()); - templateConstraint = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - 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(clock.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(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(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); - - listTypeTemplateString = new String[1]; - listTypeTemplateString[0] = "int"; - typeTemplateComboBoxString = new JComboBox<String>(listTypeTemplateString); - if (clock.getTypeTemplate().equals("int") || clock.getTypeTemplate().equals("")) { - typeTemplateComboBoxString.setSelectedIndex(0); - } - typeTemplateComboBoxString.addActionListener(this); - 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); - - JButton OKButton = new JButton("OK"); - OKButton.setActionCommand("OK"); - OKButton.addActionListener(this); - templateConstraint = new GridBagConstraints(0, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - templateGridBag.setConstraints(OKButton, templateConstraint); - templatePanel.add(OKButton); - - clockPanel.add(templatePanel); - - // Typedef - JPanel typedefPanel = new JPanel(); - typedefPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - GridBagLayout typedefGridBag = new GridBagLayout(); - GridBagConstraints typedefConstraint = new GridBagConstraints(); - typedefPanel.setLayout(typedefGridBag); - TitledBorder typedefBorder = new TitledBorder("Typedef :"); - typedefBorder.setTitleJustification(TitledBorder.CENTER); - typedefBorder.setTitlePosition(TitledBorder.TOP); - typedefPanel.setBorder(typedefBorder); - - JLabel nameTypedefLabel = new JLabel("identifier"); - typedefConstraint = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - typedefGridBag.setConstraints(nameTypedefLabel, typedefConstraint); - typedefPanel.add(nameTypedefLabel); - - nameTypedefTextField = new JTextField(); - if (clock.getListTypedef().isEmpty()) { - nameTypedefTextField.setEditable(false); - } else { - nameTypedefTextField.setEditable(true); - } - typedefConstraint = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - typedefGridBag.setConstraints(nameTypedefTextField, typedefConstraint); - typedefPanel.add(nameTypedefTextField); - - JLabel pointsTypedefLabel = new JLabel(":"); - typedefConstraint = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - typedefGridBag.setConstraints(pointsTypedefLabel, typedefConstraint); - typedefPanel.add(pointsTypedefLabel); - - JLabel typeTypedefLabel = new JLabel("type"); - typedefConstraint = new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - typedefGridBag.setConstraints(typeTypedefLabel, typedefConstraint); - typedefPanel.add(typeTypedefLabel); - - listTypeTypedefString = new String[1]; - listTypeTypedefString[0] = "sc_dt::sc_int"; - typeTypedefComboBoxString = new JComboBox<String>(listTypeTypedefString); - typeTypedefComboBoxString.setSelectedIndex(0); - if (clock.getListTypedef().isEmpty()) { - typeTypedefComboBoxString.setEnabled(false); - } else { - typeTypedefComboBoxString.setEnabled(true); - } - typeTypedefComboBoxString.addActionListener(this); - typedefConstraint = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - typedefGridBag.setConstraints(typeTypedefComboBoxString, typedefConstraint); - typedefPanel.add(typeTypedefComboBoxString); - - addModifyTypedefButton = new JButton("Add / Modify typedef"); - addModifyTypedefButton.setActionCommand("Add_Modify_Typedef"); - addModifyTypedefButton.addActionListener(this); - if (clock.getListTypedef().isEmpty()) { - addModifyTypedefButton.setEnabled(false); - } else { - addModifyTypedefButton.setEnabled(true); - } - typedefConstraint = new GridBagConstraints(0, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - typedefGridBag.setConstraints(addModifyTypedefButton, typedefConstraint); - typedefPanel.add(addModifyTypedefButton); - - clockPanel.add(typedefPanel); - - parametersBox.add(clockPanel); - parametersMainPanel.add(parametersBox, BorderLayout.WEST); - - Box managingParametersBox = Box.createVerticalBox(); - - JPanel managingParameterBoxPanel = new JPanel(new GridLayout(3, 1)); - managingParameterBoxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - - JPanel listStructPanel = new JPanel(); - TitledBorder listStructBorder = new TitledBorder("Managing struct :"); - listStructBorder.setTitleJustification(TitledBorder.CENTER); - listStructBorder.setTitlePosition(TitledBorder.TOP); - listStructPanel.setBorder(listStructBorder); - - structListModel = clock.getListStruct(); - structList = new JList<String>(structListModel); - structList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - structList.setLayoutOrientation(JList.VERTICAL); - structList.setSelectedIndex(-1); - structList.setVisibleRowCount(5); - structList.addListSelectionListener(this); - JScrollPane scrollPane = new JScrollPane(structList); - scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane.setPreferredSize(new Dimension(300, 100)); - listStructPanel.add(scrollPane); - managingParameterBoxPanel.add(listStructPanel); - - JPanel listTypedefPanel = new JPanel(); - TitledBorder listTypedefBorder = new TitledBorder("Managing typedef :"); - listTypedefBorder.setTitleJustification(TitledBorder.CENTER); - listTypedefBorder.setTitlePosition(TitledBorder.TOP); - listTypedefPanel.setBorder(listTypedefBorder); - - typedefListModel = clock.getListTypedef(); - typedefList = new JList<String>(typedefListModel); - typedefList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - typedefList.setLayoutOrientation(JList.VERTICAL); - typedefList.setSelectedIndex(-1); - typedefList.setVisibleRowCount(5); - typedefList.addListSelectionListener(this); - JScrollPane typedefScrollPane = new JScrollPane(typedefList); - typedefScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - typedefScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - typedefScrollPane.setPreferredSize(new Dimension(300, 100)); - listTypedefPanel.add(typedefScrollPane); - managingParameterBoxPanel.add(listTypedefPanel); - - GridBagLayout buttonGridBag = new GridBagLayout(); - GridBagConstraints buttonconstraints = new GridBagConstraints(); - JPanel buttonPanel = new JPanel(); - buttonPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - buttonPanel.setLayout(buttonGridBag); - - upButton = new JButton("Up"); - upButton.setActionCommand("Up"); - upButton.setEnabled(false); - upButton.addActionListener(this); - buttonconstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - buttonGridBag.setConstraints(upButton, buttonconstraints); - buttonPanel.add(upButton); - - downButton = new JButton("Down"); - downButton.setActionCommand("Down"); - downButton.setEnabled(false); - downButton.addActionListener(this); - buttonconstraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); - buttonGridBag.setConstraints(downButton, buttonconstraints); - buttonPanel.add(downButton); - - removeButton = new JButton("Remove parameter"); - removeButton.setActionCommand("Remove"); - removeButton.setEnabled(false); - removeButton.addActionListener(this); - buttonconstraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 15, 10), 0, 0); - buttonGridBag.setConstraints(removeButton, buttonconstraints); - buttonPanel.add(removeButton); - - managingParameterBoxPanel.add(buttonPanel); - - managingParametersBox.add(managingParameterBoxPanel); - parametersMainPanel.add(managingParametersBox, BorderLayout.EAST); - - // --- ProcessCode ---// - processMainPanel.setLayout(new BorderLayout()); - - Box codeBox = Box.createVerticalBox(); - codeBox.setBorder(BorderFactory.createTitledBorder("Behavior function of TDF clock")); - - JPanel codeBoxPanel = new JPanel(new BorderLayout()); - - StringBuffer stringbuf = encode(clock.getProcessCode()); - String beginString = stringbuf.toString(); - finalString = beginString.replaceAll("\t}", "}"); - - processCodeTextArea = new JTextArea(finalString); - processCodeTextArea.setSize(100, 100); - processCodeTextArea.setTabSize(2); - - processCodeTextArea.setFont(new Font("Arial", Font.PLAIN, 16)); - processCodeTextArea.setLineWrap(true); - processCodeTextArea.setWrapStyleWord(true); - - JScrollPane processScrollPane = new JScrollPane(processCodeTextArea); - processScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - processScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - processScrollPane.setPreferredSize(new Dimension(200, 300)); - processScrollPane.setBorder(new EmptyBorder(15, 10, 15, 10)); - - codeBoxPanel.add(processScrollPane, BorderLayout.SOUTH); - - 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 clock")); - - JPanel codeBoxPanel2 = new JPanel(new BorderLayout()); - - //StringBuffer stringbuf2 = encode(clock.getConstructorCode()); - //String beginString2 = stringbuf2.toString(); - //finalString = beginString2.replaceAll("\t}", "}"); - finalString = clock.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()); @@ -815,11 +417,14 @@ public class JDialogSysCAMSClock extends JDialog implements ActionListener { public void actionPerformed(ActionEvent e) { clock.setName(nameTextField.getText()); - // clock.setFrequency(frequencyTextField.getText()); - //clock.setDutyCycle(dutyCycleTextField.getText()); - //clock.setStartTime(startTimeTextField.getText()); - clock.setPosFirst((boolean)posFirstComboBoxString.getSelectedItem()); //ToDo boolean - clock.setUnit((String) unitComboBoxString.getSelectedItem()); + + if(posFirstComboBoxString.getSelectedIndex()==0){ + clock.setPosFirst(false); + } + else{ + clock.setPosFirst(true); + } + // clock.setUnit((String) unitComboBoxString.getSelectedItem()); ToDo if ("Save_Close".equals(e.getActionCommand())) { @@ -858,11 +463,11 @@ public class JDialogSysCAMSClock extends JDialog implements ActionListener { } if (dutyCycleValueInteger == false) { clock.setDutyCycle(Double.parseDouble(dutyCycleTextField.getText())); - clock.setUnit((String) dutyCycleComboBoxString.getSelectedItem()); + //clock.setUnit((String) dutyCycleComboBoxString.getSelectedItem()); } } else { clock.setDutyCycle(-1); - clock.setUnit(""); + //clock.setUnit(""); } if (!(startTimeTextField.getText().isEmpty())) { @@ -876,34 +481,34 @@ public class JDialogSysCAMSClock extends JDialog implements ActionListener { JOptionPane.WARNING_MESSAGE); startTimeValueInteger = true; } - if (startTimeValueInteger == false) { + if (startTimeValueInteger == false) { clock.setStartTime(Double.parseDouble(startTimeTextField.getText())); clock.setUnit((String) startTimeComboBoxString.getSelectedItem()); } } else { clock.setStartTime(-1); - clock.setUnit(""); - } + clock.setUnitStartTime(""); + } //clock.setProcessCode(processCodeTextArea.getText()); // clock.setConstructorCode(constructorCodeTextArea.getText()); clock.setListStruct(structListModel); - clock.setNameTemplate(nameTemplateTextField.getText()); - clock.setTypeTemplate((String) typeTemplateComboBoxString.getSelectedItem()); - clock.setValueTemplate(valueTemplateTextField.getText()); - clock.setListTypedef(typedefListModel); + //clock.setNameTemplate(nameTemplateTextField.getText()); + //clock.setTypeTemplate((String) typeTemplateComboBoxString.getSelectedItem()); + //clock.setValueTemplate(valueTemplateTextField.getText()); + //clock.setListTypedef(typedefListModel); this.dispose(); } - /* if ("Save_Close".equals(e.getActionCommand())) { + if ("Save_Close".equals(e.getActionCommand())) { clock.setValue(new String(nameTextField.getText())); this.dispose(); - }* + } if ("Cancel".equals(e.getActionCommand())) { this.dispose(); - }*/ + } } } diff --git a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java index f9a78ca4d500993b94a47dd246abfbac7a0587d1..98fe87481d423e8fd81970d41cf74af3ed811be8 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java @@ -268,6 +268,9 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen if (port.getConvType().equals(listArrayTypeString.get(i))) { typeComboBoxString.setSelectedIndex(i); } + if (port.getConvType().equals("sc_uint") { + typeComboBoxString.setSelectedIndex(3); + } } typeComboBoxString.addActionListener(this); constraints = new GridBagConstraints(1, 5, 2, 1, 1.0, 1.0, @@ -275,6 +278,7 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeComboBoxString, constraints); + // System.out.println("@@@@@ Converter port type " +typeComboBoxString); boxPanel.add(typeComboBoxString); JLabel orginLabel = new JLabel("Origin : "); @@ -377,12 +381,12 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen JOptionPane.WARNING_MESSAGE); nbitsValueInteger = true; } - /* if (nbitsValueInteger == false) { + //if (nbitsValueInteger == false) { port.setNbits(Integer.parseInt(nbitsTextField.getText())); - } - } else { - port.setNbits(-1); - }*/ + //} + // } else { + // port.setNbits(-1); + // } } @@ -404,13 +408,21 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen port.setDelay(-1); } - if(typeComboBoxString.getSelectedItem()=="sc_uint"){ - port.setConvType("sc_uint<"+nbitsTextField.getText()+">"); - } - else{ + if(typeComboBoxString.getSelectedItem()=="sc_uint<N>"){ + port.setConvType((String)"sc_uint<"+nbitsTextField.getText()+"> "); + port.setConvType((String)"sc_uint"); + port.setNbits(Integer.parseInt(nbitsTextField.getText())); + // System.out.println("@@@@@@@@@"+port.getConvType()); + // System.out.println("@@@@@@@@@"+port.getNbits()); + + } + else{ port.setConvType((String) typeComboBoxString.getSelectedItem()); - // port.setTime((String) periodComboBoxString.getSelectedItem()); - } + port.setNbits(Integer.parseInt(nbitsTextField.getText())); + //System.out.println("@@@@@@@@@"+port.getConvType()); + //System.out.println("@@@@@@@@@"+port.getNbits()); + port.setTime((String) periodComboBoxString.getSelectedItem()); + } port.setTime((String) periodComboBoxString.getSelectedItem()); diff --git a/src/main/java/ui/window/JDialogSysCAMSPortDE.java b/src/main/java/ui/window/JDialogSysCAMSPortDE.java index 9833b2e905926f5aee0baac9cc7dc97aceb6b6e0..24b9c282e8fe5aea63dee1b77d5fa2935b3ba4d1 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortDE.java @@ -214,10 +214,11 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { boxPanel.add(typeLabel); listArrayTypeString = new ArrayList<String>(); - listArrayTypeString.add("int"); - listArrayTypeString.add("bool"); - listArrayTypeString.add("double"); - listArrayTypeString.add("sc_uint<N>"); + listArrayTypeString.add("int"); + listArrayTypeString.add("bool"); + listArrayTypeString.add("double"); + listArrayTypeString.add("sc_uint<N>"); + if (port.getFather() != null) { if (port.getFather() instanceof SysCAMSBlockDE) { if (!((SysCAMSBlockDE) port.getFather()).getListTypedef().isEmpty()) { @@ -239,11 +240,18 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { } for (int i = 0; i < listArrayTypeString.size(); i++) { if (port.getDEType().equals("")) { + typeComboBoxString.setSelectedIndex(0); } if (port.getDEType().equals(listArrayTypeString.get(i))) { typeComboBoxString.setSelectedIndex(i); + } + if (port.getDEType().equals("sc_uint")) { + typeComboBoxString.setSelectedIndex(3); + + } + } typeComboBoxString.addActionListener(this); constraints = new GridBagConstraints(1, 2, 2, 1, 1.0, 1.0, @@ -251,6 +259,7 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeComboBoxString, constraints); + // System.out.println("@@@@@ DE port type " +typeComboBoxString); boxPanel.add(typeComboBoxString); JLabel orginLabel = new JLabel("Origin : "); @@ -358,12 +367,13 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { JOptionPane.WARNING_MESSAGE); nbitsValueInteger = true; } - /* if (nbitsValueInteger == false) { + // if (nbitsValueInteger == false) { port.setNbits(Integer.parseInt(nbitsTextField.getText())); - } - } else { - port.setNbits(-1); - }*/ + //System.out.println("@@@@@@@@@1"+port.getNbits()); + // } + // } else { + // port.setNbits(-1); + // }*/ } // if (!(periodTextField.getText().isEmpty())) { @@ -421,14 +431,22 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { // } + - if(typeComboBoxString.getSelectedItem()=="sc_uint"){ - port.setDEType("sc_uint<"+nbitsTextField.getText()+">"); - } - else{ - port.setDEType((String) typeComboBoxString.getSelectedItem()); - // port.setTime((String) periodComboBoxString.getSelectedItem()); - } + if(typeComboBoxString.getSelectedItem()=="sc_uint<N>"){ + // port.setDEType((String)"sc_uint<"+nbitsTextField.getText()+"> "); + port.setDEType((String)"sc_uint"); + + // System.out.println("@@@@@@@@@1"+port.getDEType()); + } + else{ + port.setDEType((String) typeComboBoxString.getSelectedItem()); + + // System.out.println("@@@@@@@@@1"+port.getDEType()); + } + + // port.setTime((String) periodComboBoxString.getSelectedItem()); + if ((String) originComboBoxString.getSelectedItem() == "Output") { port.setOrigin(1);