Skip to content
Snippets Groups Projects
Commit 0f1731dc authored by Daniela Genius's avatar Daniela Genius
Browse files

added clocks in SystamC-AMS part

parent cf4780d6
No related branches found
No related tags found
3 merge requests!223New lip6,!222New lip6,!219New lip6
...@@ -43,7 +43,11 @@ import java.util.LinkedList; ...@@ -43,7 +43,11 @@ import java.util.LinkedList;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
/** /**
* Class SysCAMSTClock * Class SysCAMSTClock
* Parameters of a SystemC-AMS Clock
* Creation: 08/07/2019
* @version 1.0 08/07/2019
* @author Daniela Genius
*/ */
public class SysCAMSTClock extends SysCAMSTComponent{ public class SysCAMSTClock extends SysCAMSTComponent{
...@@ -54,6 +58,10 @@ public class SysCAMSTClock extends SysCAMSTComponent{ ...@@ -54,6 +58,10 @@ public class SysCAMSTClock extends SysCAMSTComponent{
private String startTime; private String startTime;
private String posFirst; private String posFirst;
//private SysCAMSTCluster cluster;
private LinkedList<SysCAMSTPortClock> portClock;
public SysCAMSTClock(String _name, String _frequency, String _unit, String _dutyCycle, String _startTime, String _posFirst) { public SysCAMSTClock(String _name, String _frequency, String _unit, String _dutyCycle, String _startTime, String _posFirst) {
name = _name; name = _name;
...@@ -61,7 +69,9 @@ public class SysCAMSTClock extends SysCAMSTComponent{ ...@@ -61,7 +69,9 @@ public class SysCAMSTClock extends SysCAMSTComponent{
unit = _unit; unit = _unit;
dutyCycle = _dutyCycle; dutyCycle = _dutyCycle;
startTime = _startTime; startTime = _startTime;
posFirst = _posFirst; posFirst = _posFirst;
//cluster = _cluster;
portClock = new LinkedList<SysCAMSTPortClock>();
} }
...@@ -116,5 +126,14 @@ public class SysCAMSTClock extends SysCAMSTComponent{ ...@@ -116,5 +126,14 @@ public class SysCAMSTClock extends SysCAMSTComponent{
public void setPosFirst(String _posFirst) { public void setPosFirst(String _posFirst) {
posFirst = _posFirst; posFirst = _posFirst;
} }
public LinkedList<SysCAMSTPortClock> getPortClock(){
return portClock;
}
public void addPortClock(SysCAMSTPortClock cl){
portClock.add(cl);
}
} }
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.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.
*/
package syscamstranslator;
import elntranslator.*;
/**
* Class SysCAMSTPortClock
* Parameters of a SystemC-AMS port Clock
* Creation: 07/05/2018
* @version 1.0 07/05/2018
* @author Irina Kit Yan LEE
*/
public class SysCAMSTPortClock extends SysCAMSTComponent {
private String name;
// private int period;
// private String time;
// private int rate;
// private int delay;
private int origin;
private String ClockType;
private boolean sensitive;
private String sensitiveMethod;
private SysCAMSTBlockClock blockClock;
private SysCAMSTBlockGPIO2VCI blockGPIO2VCI;
private ELNTCluster cluster;
private ELNTModule module;
public SysCAMSTPortClock(String _name, int _origin, String _ClockType, boolean _sensitive, String _sensitiveMethod, SysCAMSTBlockClock _blockClock) {
name = _name;
// period = _period;
// time = _time;
// rate = _rate;
// delay = _delay;
origin = _origin;
ClockType = _ClockType;
sensitive = _sensitive;
sensitiveMethod = _sensitiveMethod;
blockClock = _blockClock;
}
public SysCAMSTPortClock(String _name, int _origin, String _ClockType, boolean _sensitive, String _sensitiveMethod, SysCAMSTBlockGPIO2VCI _blockGPIO2VCI) {
name = _name;
// period = _period;
// time = _time;
// rate = _rate;
// delay = _delay;
origin = _origin;
ClockType = _ClockType;
sensitive = _sensitive;
sensitiveMethod = _sensitiveMethod;
blockGPIO2VCI = _blockGPIO2VCI;
}
public SysCAMSTPortClock(String _name, int _origin, String _ClockType, boolean _sensitive, String _sensitiveMethod, ELNTCluster _cluster) {
name = _name;
// period = _period;
// time = _time;
// rate = _rate;
// delay = _delay;ELNTCluster
origin = _origin;
ClockType = _ClockType;
sensitive = _sensitive;
sensitiveMethod = _sensitiveMethod;
cluster = _cluster;
}
public SysCAMSTPortClock(String _name, int _origin, String _ClockType, boolean _sensitive, String _sensitiveMethod, ELNTModule _module) {
name = _name;
// period = _period;
// time = _time;
// rate = _rate;
// delay = _delay;ELNTCluster
origin = _origin;
ClockType = _ClockType;
sensitive = _sensitive;
sensitiveMethod = _sensitiveMethod;
module = _module;
}
public String getName() {
return name;
}
// public int getPeriod() {
// return period;
// }
//
// public String getTime() {
// return time;
// }
//
// public int getRate() {
// return rate;
// }
//
// public int getDelay() {
// return delay;
// }
public int getOrigin() {
return origin;
}
public String getClockType() {
return ClockType;
}
public boolean getSensitive() {
return sensitive;
}
public String getSensitiveMethod() {
return sensitiveMethod;
}
public SysCAMSTBlockClock getBlockClock() {
return blockClock;
}
public SysCAMSTBlockGPIO2VCI getBlockGPIO2VCI() {
return blockGPIO2VCI;
}
public ELNTCluster getCluster() {
return cluster;
}
public ELNTModule getModule() {
return module;
}
}
...@@ -73,6 +73,7 @@ public class ClusterCode { ...@@ -73,6 +73,7 @@ public class ClusterCode {
if (cluster != null) { if (cluster != null) {
LinkedList<SysCAMSTBlockTDF> tdf = cluster.getBlockTDF(); LinkedList<SysCAMSTBlockTDF> tdf = cluster.getBlockTDF();
LinkedList<SysCAMSTBlockDE> de = cluster.getBlockDE(); LinkedList<SysCAMSTBlockDE> de = cluster.getBlockDE();
LinkedList<SysCAMSTClock> clock = cluster.getClock();
corpsCluster = "// Simulation entry point." + CR + "int sc_main(int argc, char *argv[]) {" + CR2 corpsCluster = "// Simulation entry point." + CR + "int sc_main(int argc, char *argv[]) {" + CR2
+ "\tusing namespace sc_core;" + CR + "\tusing namespace sca_util;" + CR2; + "\tusing namespace sc_core;" + CR + "\tusing namespace sca_util;" + CR2;
...@@ -202,6 +203,52 @@ public class ClusterCode { ...@@ -202,6 +203,52 @@ public class ClusterCode {
nb_block++; nb_block++;
} }
//ajoute DG
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;
LinkedList<SysCAMSTPortClock> portClock = t.getPortClock();
for (SysCAMSTPortClock p : portClock) {
for (int i = 0; i < connectors.size(); i++) {
if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortClock && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortClock) {
if (((SysCAMSTPortClock) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortClock) connectors.get(i).get_p1().getComponent()).getClock().getName().equals(t.getName())) {
corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR;
} else if (((SysCAMSTPortClock) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortClock) connectors.get(i).get_p2().getComponent()).getClock().getName().equals(t.getName())) {
corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR;
}
} else if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortClock) {
if (((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(t.getName())) {
corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR;
} else if (((SysCAMSTPortClock) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortClock) connectors.get(i).get_p2().getComponent()).getClock().getName().equals(t.getName())) {
corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR;
}
} else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortClock) {
if (((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(t.getName())) {
corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR;
} else if (((SysCAMSTPortClock) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortClock) connectors.get(i).get_p1().getComponent()).getClock().getName().equals(t.getName())) {
corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR;
}
}
}
}
corpsCluster = corpsCluster + CR;
nb_block++;
}
//fin ajoute DG
corpsCluster = corpsCluster + "\t// Configure signal tracing." + CR corpsCluster = corpsCluster + "\t// Configure signal tracing." + CR
+ "\tsca_trace_file* tfp = sca_create_tabular_trace_file(\"" + cluster.getClusterName() + "_tb\");" + CR; + "\tsca_trace_file* tfp = sca_create_tabular_trace_file(\"" + cluster.getClusterName() + "_tb\");" + CR;
......
...@@ -602,4 +602,232 @@ public class PrimitiveCode { ...@@ -602,4 +602,232 @@ public class PrimitiveCode {
} }
return corpsPrimitiveDE; return corpsPrimitiveDE;
} }
public static String getPrimitiveCodeClock(SysCAMSTBlockClock de) {
corpsPrimitiveClock = "";
if (de != null) {
LinkedList<SysCAMSTPortClock> deports = de.getPortClock();
int cpt = 0;
int cpt2 = 0;
if ((!de.getTypeTemplate().equals("")) && (!de.getNameTemplate().equals(""))) {
corpsPrimitiveClock = corpsPrimitiveClock + "template<" + de.getTypeTemplate() + " " + de.getNameTemplate() + ">" + CR;
}
//corpsPrimitive = "SCA_TDF_MODULE(" + de.getName() + ") {" + CR2;
corpsPrimitiveClock = corpsPrimitiveClock + "class " + de.getName() + " : public sca_core::sca_module {" + CR2 + "public:" + CR;
if (!de.getListTypedef().isEmpty()) {
for (int i = 0; i < de.getListTypedef().getSize(); i++) {
String select = de.getListTypedef().get(i);
String[] split = select.split(" : ");
corpsPrimitiveClock = corpsPrimitiveClock + "\ttypedef " + split[1] + "<" + de.getNameTemplate() + "> " + split[0] + ";" + CR;
if (i == de.getListTypedef().getSize()-1) {
corpsPrimitiveClock = corpsPrimitiveClock + CR;
}
}
}
if (de.getListStruct().getSize() != 0) {
corpsPrimitiveClock = corpsPrimitiveClock + "\tstruct parameters {" + CR;
String identifier, value, type;
for (int i = 0; i < de.getListStruct().size(); i++) {
String select = de.getListStruct().get(i);
String[] splita = select.split(" = ");
identifier = splita[0];
String[] splitb = splita[1].split(" : ");
value = splitb[0];
String[] splitc = splitb[1].split(" ");
if (splitc[0].equals("const")) {
type = splitc[1];
} else {
type = splitc[0];
}
corpsPrimitiveClock = corpsPrimitiveClock + "\t\t" + type + " " + identifier + ";" + CR;
}
corpsPrimitiveClock = corpsPrimitiveClock + "\t\tparameters()" + CR;
for (int i = 0; i < de.getListStruct().size(); i++) {
String select = de.getListStruct().get(i);
String[] splita = select.split(" = ");
identifier = splita[0];
String[] splitb = splita[1].split(" : ");
value = splitb[0];
String[] splitc = splitb[1].split(" ");
if (splitc[0].equals("const")) {
type = splitc[1];
} else {
type = splitc[0];
}
if (i == 0) {
corpsPrimitiveClock = corpsPrimitiveClock + "\t\t: " + identifier + "(" + value + ")" + CR;
}
if ((i > 0) && (i < de.getListStruct().getSize()-1)) {
corpsPrimitiveClock = corpsPrimitiveClock + "\t\t, " + identifier + "(" + value + ")" + CR;
}
if (i == de.getListStruct().getSize()-1 && i != 0) {
corpsPrimitiveClock = corpsPrimitiveClock + "\t\t, " + identifier + "(" + value + ")" + CR + "\t\t{}" + CR;
} else {
corpsPrimitiveClock = corpsPrimitiveClock + "\t\t{}" + CR;
}
}
corpsPrimitiveClock = corpsPrimitiveClock + "\t};" + CR2;
}
if (!deports.isEmpty()) {
for (SysCAMSTPortClock t : deports) {
if (t.getOrigin() == 0) {
corpsPrimitiveClock = corpsPrimitiveClock + "\tsca_core::sca_in<" + t.getClockType() + "> " + t.getName() + ";" + CR;
} else if (t.getOrigin() == 1) {
corpsPrimitiveClock = corpsPrimitiveClock + "\tsca_core::sca_out<" + t.getClockType() + "> " + t.getName() + ";" + CR;
}
}
}
corpsPrimitiveClock = corpsPrimitiveClock + CR + "\tSC_HAS_PROCESS(" + de.getName() + ");" + CR +
"\texplicit " + de.getName() + "(sc_core::sc_module_name nm";
if (de.getListStruct().getSize() != 0) {
corpsPrimitiveClock = corpsPrimitiveClock + ", const parameters& p = parameters())" + CR;
} else {
corpsPrimitiveClock = corpsPrimitiveClock + ")" + CR;
}
if (!deports.isEmpty() || !de.getListStruct().isEmpty()) {
corpsPrimitiveClock = corpsPrimitiveClock + "\t: ";
if (!deports.isEmpty()) {
for (int i = 0; i < deports.size(); i++) {
if (deports.size() >= 1) {
if (cpt == 0) {
corpsPrimitiveClock = corpsPrimitiveClock + deports.get(i).getName() + "(\"" + deports.get(i).getName() + "\")" + CR;
cpt++;
} else {
corpsPrimitiveClock = corpsPrimitiveClock + "\t, " + deports.get(i).getName() + "(\"" + deports.get(i).getName() + "\")" + CR;
}
} else {
corpsPrimitiveClock = corpsPrimitiveClock + deports.get(i).getName() + "(\"" + deports.get(i).getName() + "\")" + CR;
cpt++;
}
}
}
String identifier;
if (!de.getListStruct().isEmpty()) {
for (int i = 0; i < de.getListStruct().size(); i++) {
String select = de.getListStruct().get(i);
String[] splita = select.split(" = ");
identifier = splita[0];
if (de.getListStruct().getSize() >= 1) {
if (cpt == 0) {
corpsPrimitiveClock = corpsPrimitiveClock + identifier + "(p." + identifier + ")" + CR;
cpt++;
} else {
corpsPrimitiveClock = corpsPrimitiveClock + "\t, " + identifier + "(p." + identifier + ")" + CR;
}
} else {
corpsPrimitiveClock = corpsPrimitiveClock + identifier + "(p." + identifier + ")" + CR;
cpt++;
}
}
}
}
boolean sensitive = false, method = false;
if (!de.getCode().equals("")) {
corpsPrimitiveClock = corpsPrimitiveClock + "\t{" + CR + "\t\tSC_METHOD(" + de.getNameFn() + ");" + CR;
method = true;
}
for (SysCAMSTPortClock t : deports) {
if (t.getSensitive() == true) {
if (method == false) {
corpsPrimitiveClock = corpsPrimitiveClock + "\t{" + CR;
}
corpsPrimitiveClock = corpsPrimitiveClock + "\t\tsensitive << " + t.getName() + ".";
if (t.getSensitiveMethod().equals("positive")) {
corpsPrimitiveClock = corpsPrimitiveClock + "pos();" + CR;
} else if (t.getSensitiveMethod().equals("negative")) {
corpsPrimitiveClock = corpsPrimitiveClock + "neg();" + CR;
}
sensitive = true;
}
}
if (sensitive == true || method == true) {
corpsPrimitiveClock = corpsPrimitiveClock + "\t}" + CR2;
} else {
corpsPrimitiveClock = corpsPrimitiveClock + "\t{}" + CR2;
}
corpsPrimitiveClock = corpsPrimitiveClock + "private:" + CR;
if (de.getListStruct().getSize() != 0) {
String identifier, type, constant;
for (int i = 0; i < de.getListStruct().size(); i++) {
String select = de.getListStruct().get(i);
String[] splita = select.split(" = ");
identifier = splita[0];
String[] splitb = splita[1].split(" : ");
String[] splitc = splitb[1].split(" ");
if (splitc[0].equals("const")) {
constant = splitc[0];
type = splitc[1];
} else {
constant = "";
type = splitc[0];
}
if (constant.equals("")) {
corpsPrimitiveClock = corpsPrimitiveClock + "\t" + type + " " + identifier + ";" + CR;
} else {
corpsPrimitiveClock = corpsPrimitiveClock + "\t" + constant + " " + type + " " + identifier + ";" + CR;
}
if (i == de.getListStruct().size()-1) {
corpsPrimitiveClock = corpsPrimitiveClock + CR;
}
}
}
StringBuffer pcbuf = new StringBuffer(de.getCode());
StringBuffer buffer = new StringBuffer("");
int tab = 0;
int begin = 0;
for(int pos = 0; pos != de.getCode().length(); pos++) {
char c = pcbuf.charAt(pos);
switch(c) {
case '\t':
begin = 1;
tab++;
break;
default:
if (begin == 1) {
int i = tab;
while (i >= 0) {
buffer.append("\t");
i--;
}
buffer.append(pcbuf.charAt(pos));
begin = 0;
tab = 0;
} else {
if (c == '}') {
buffer.append("\t");
}
buffer.append(pcbuf.charAt(pos));
}
break;
}
}
String pc = buffer.toString();
corpsPrimitiveClock = corpsPrimitiveClock + "\t" + pc;
corpsPrimitiveClock = corpsPrimitiveClock + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_H";
} else {
corpsPrimitiveClock = "";
}
return corpsPrimitiveClock;
}
} }
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.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.
*/
package ui.syscams;
import java.awt.Graphics;
import ui.TDiagramPanel;
import ui.TGComponent;
/**
* Class SysCAMSPortClock
* Primitive port. To be used in SystemC-AMS diagrams
* Creation: 14/05/2018
* @version 1.0 14/05/2018
* @author Irina Kit Yan LEE
*/
public class SysCAMSPortClock extends SysCAMSPrimitivePort {
// private int period;
// private String time;
// private int rate;
// private int delay;
private int nbits;//DG
private String ClockType;
private boolean sensitive;
private String sensitiveMethod;
public SysCAMSPortClock(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) {
super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
}
// public int getPeriod() {
// return period;
// }
//
// public void setPeriod(int period) {
// this.period = period;
// }
//
// public String getTime() {
// return time;
// }
//
// public void setTime(String time) {
// this.time = time;
// }
//
// public int getRate() {
// return rate;
// }
//
// public void setRate(int rate) {
// this.rate = rate;
// }
//
// public int getDelay() {
// return delay;
// }
//
// public void setDelay(int delay) {
// this.delay = delay;
// }
public void drawParticularity(Graphics g) {
}
public String getClockType() {
return ClockType;
}
public void setClockType(String _ClockType) {
ClockType = _ClockType;
}
public boolean getSensitive() {
return sensitive;
}
public int getNbits() {
return nbits;
}
public void setSensitive(boolean _sensitive) {
sensitive = _sensitive;
}
public String getSensitiveMethod() {
return sensitiveMethod;
}
public void setSensitiveMethod(String _sensitiveMethod) {
sensitiveMethod = _sensitiveMethod;
}
}
This diff is collapsed.
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.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.
*/
package ui.window;
import ui.syscams.*;
import ui.util.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
/**
* Class JDialogSystemCAMSPortClock
* Dialog for managing of SystemC-AMS Clock Port
* Creation: 07/05/2018
* @version 1.0 07/05/2018
* @author Irina Kit Yan LEE
*/
@SuppressWarnings("serial")
public class JDialogSysCAMSPortClock extends JDialog implements ActionListener {
private JTextField nameTextField;
// private JTextField periodTextField;
// private String listPeriodString[];
// private JComboBox<String> periodComboBoxString;
// private JTextField rateTextField;
// private JTextField delayTextField;
private JTextField nbitsTextField;
private ArrayList<String> listArrayTypeString;
private JComboBox<String> typeComboBoxString;
private String listOriginString[];
private JComboBox<String> originComboBoxString;
private JRadioButton sensitiveRadioButton;
private String listSensitiveString[];
private JComboBox<String> sensitiveComboBoxString;
private SysCAMSPortClock port;
public JDialogSysCAMSPortClock(SysCAMSPortClock port) {
this.setTitle("Setting Clock Ports");
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setAlwaysOnTop(true);
this.setResizable(false);
this.port = port;
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
getRootPane().getActionMap().put("close", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
dialog();
}
public void dialog() {
JPanel mainPanel = new JPanel(new BorderLayout());
this.add(mainPanel);
JPanel attributesMainPanel = new JPanel(new GridLayout());
mainPanel.add(attributesMainPanel, BorderLayout.NORTH);
Box box = Box.createVerticalBox();
box.setBorder(BorderFactory.createTitledBorder("Setting Clock port attributes"));
GridBagLayout gridBag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
JPanel boxPanel = new JPanel();
boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14));
boxPanel.setLayout(gridBag);
JLabel labelName = new JLabel("Name : ");
constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(15, 10, 5, 10), 0, 0);
gridBag.setConstraints(labelName, constraints);
boxPanel.add(labelName);
if (port.getPortName().toString().equals("")) {
nameTextField = new JTextField(10);
} else {
nameTextField = new JTextField(port.getPortName().toString(), 10);
}
constraints = new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(15, 10, 5, 10), 0, 0);
gridBag.setConstraints(nameTextField, constraints);
boxPanel.add(nameTextField);
JLabel nbitsLabel = new JLabel("Nbits : ");
constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(5, 10, 5, 10), 0, 0);
gridBag.setConstraints(nbitsLabel, constraints);
boxPanel.add(nbitsLabel);
if (port.getNbits() == -1) {
nbitsTextField = new JTextField(10);
} else {
nbitsTextField = new JTextField("" + port.getNbits(), 10);
}
constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(5, 10, 5, 10), 0, 0);
gridBag.setConstraints(nbitsTextField, constraints);
boxPanel.add(nbitsTextField);
//
// listPeriodString = new String[3];
// listPeriodString[0] = "us";
// listPeriodString[1] = "ms";
// listPeriodString[2] = "s";
// periodComboBoxString = new JComboBox<String>(listPeriodString);
// if (port.getTime().equals("") || port.getTime().equals("us")) {
// periodComboBoxString.setSelectedIndex(0);
// } else if (port.getTime().equals("ms")){
// periodComboBoxString.setSelectedIndex(1);
// } else {
// periodComboBoxString.setSelectedIndex(2);
// }
// periodComboBoxString.setActionCommand("time");
// periodComboBoxString.addActionListener(this);
// constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0,
// GridBagConstraints.CENTER,
// GridBagConstraints.BOTH,
// new Insets(5, 10, 5, 10), 0, 0);
// gridBag.setConstraints(periodComboBoxString, constraints);
// boxPanel.add(periodComboBoxString);
//
// JLabel rateLabel = new JLabel("Rate : ");
// constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0,
// GridBagConstraints.CENTER,
// GridBagConstraints.BOTH,
// new Insets(5, 10, 5, 10), 0, 0);
// gridBag.setConstraints(rateLabel, constraints);
// boxPanel.add(rateLabel);
//
// if (port.getRate() == -1) {
// rateTextField = new JTextField(10);
// } else {
// rateTextField = new JTextField("" + port.getRate(), 10);
// }
// constraints = new GridBagConstraints(1, 2, 2, 1, 1.0, 1.0,
// GridBagConstraints.CENTER,
// GridBagConstraints.BOTH,
// new Insets(5, 10, 5, 10), 0, 0);
// gridBag.setConstraints(rateTextField, constraints);
// boxPanel.add(rateTextField);
//
// JLabel delayLabel = new JLabel("Delay : ");
// constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
// GridBagConstraints.CENTER,
// GridBagConstraints.BOTH,
// new Insets(5, 10, 5, 10), 0, 0);
// gridBag.setConstraints(delayLabel, constraints);
// boxPanel.add(delayLabel);
//
// if (port.getDelay() == -1) {
// delayTextField = new JTextField(10);
// } else {
// delayTextField = new JTextField("" + port.getDelay(), 10);
// }
// constraints = new GridBagConstraints(1, 3, 2, 1, 1.0, 1.0,
// GridBagConstraints.CENTER,
// GridBagConstraints.BOTH,
// new Insets(5, 10, 5, 10), 0, 0);
// gridBag.setConstraints(delayTextField, constraints);
// boxPanel.add(delayTextField);
JLabel typeLabel = new JLabel("Type : ");
constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(5, 10, 5, 10), 0, 0);
gridBag.setConstraints(typeLabel, constraints);
boxPanel.add(typeLabel);
listArrayTypeString = new ArrayList<String>();
listArrayTypeString.add("int");
listArrayTypeString.add("bool");
listArrayTypeString.add("double");
listArrayTypeString.add("sc_uint<N>");
if (port.getFather() != null) {
if (port.getFather() instanceof SysCAMSClock) {
if (!((SysCAMSClock) port.getFather()).getListTypedef().isEmpty()) {
for (int i = 0; i < ((SysCAMSClock) port.getFather()).getListTypedef().getSize(); i++) {
String select = ((SysCAMSClock) port.getFather()).getListTypedef().get(i);
String[] split = select.split(" : ");
listArrayTypeString.add(split[0]);
}
}
if ((!((SysCAMSClock) port.getFather()).getNameTemplate().equals("")) && (!((SysCAMSClock) port.getFather()).getTypeTemplate().equals(""))
&& ((SysCAMSClock) port.getFather()).getListTypedef().isEmpty()) {
listArrayTypeString.add("sc_dt::sc_int<"+((SysCAMSClock) port.getFather()).getNameTemplate()+">");
}
}
}
typeComboBoxString = new JComboBox<String>();
for (int i = 0; i < listArrayTypeString.size(); i++) {
typeComboBoxString.addItem(listArrayTypeString.get(i));
}
for (int i = 0; i < listArrayTypeString.size(); i++) {
if (port.getClockType().equals("")) {
typeComboBoxString.setSelectedIndex(0);
}
if (port.getClockType().equals(listArrayTypeString.get(i))) {
typeComboBoxString.setSelectedIndex(i);
}
}
typeComboBoxString.addActionListener(this);
constraints = new GridBagConstraints(1, 2, 2, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(5, 10, 5, 10), 0, 0);
gridBag.setConstraints(typeComboBoxString, constraints);
boxPanel.add(typeComboBoxString);
JLabel orginLabel = new JLabel("Origin : ");
constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(5, 10, 15, 10), 0, 0);
gridBag.setConstraints(orginLabel, constraints);
boxPanel.add(orginLabel);
listOriginString = new String[2];
listOriginString[0] = "Input";
listOriginString[1] = "Output";
originComboBoxString = new JComboBox<String>(listOriginString);
if (port.getOrigin() == 0 || port.getOrigin() == -1) {
originComboBoxString.setSelectedIndex(0);
} else {
originComboBoxString.setSelectedIndex(1);
}
originComboBoxString.setActionCommand("origin");
originComboBoxString.addActionListener(this);
constraints = new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(5, 10, 15, 10), 0, 0);
gridBag.setConstraints(originComboBoxString, constraints);
boxPanel.add(originComboBoxString);
box.add(boxPanel);
attributesMainPanel.add(box);
JPanel sensitivePanel = new JPanel(new FlowLayout());
sensitiveRadioButton = new JRadioButton();
sensitiveRadioButton.setActionCommand("Sensitive");
sensitiveRadioButton.setSelected(port.getSensitive());
sensitiveRadioButton.addActionListener(this);
sensitivePanel.add(sensitiveRadioButton);
JLabel sensitiveLabel = new JLabel("Sensitive");
sensitivePanel.add(sensitiveLabel);
constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(15, 10, 5, 10), 0, 0);
gridBag.setConstraints(sensitivePanel, constraints);
boxPanel.add(sensitivePanel);
listSensitiveString = new String[3];
listSensitiveString[0] = "";
listSensitiveString[1] = "positive";
listSensitiveString[2] = "negative";
sensitiveComboBoxString = new JComboBox<String>(listSensitiveString);
if (port.getSensitiveMethod().equals("")) {
sensitiveComboBoxString.setSelectedIndex(0);
} else if (port.getSensitiveMethod().equals("positive")) {
sensitiveComboBoxString.setSelectedIndex(1);
} else if (port.getSensitiveMethod().equals("negative")) {
sensitiveComboBoxString.setSelectedIndex(2);
}
sensitiveComboBoxString.setActionCommand("Sensitive_method");
sensitiveComboBoxString.setEnabled(port.getSensitive());
sensitiveComboBoxString.addActionListener(this);
constraints = new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(15, 10, 5, 10), 0, 0);
gridBag.setConstraints(sensitiveComboBoxString, constraints);
boxPanel.add(sensitiveComboBoxString);
// -- Button -- //
JPanel downPanel = new JPanel(new FlowLayout());
JButton saveCloseButton = new JButton("Save and close");
saveCloseButton.setIcon(IconManager.imgic25);
saveCloseButton.setActionCommand("Save_Close");
saveCloseButton.addActionListener(this);
saveCloseButton.setPreferredSize(new Dimension(200, 30));
downPanel.add(saveCloseButton);
JButton cancelButton = new JButton("Cancel");
cancelButton.setIcon(IconManager.imgic27);
cancelButton.setActionCommand("Cancel");
cancelButton.addActionListener(this);
cancelButton.setPreferredSize(new Dimension(200, 30));
downPanel.add(cancelButton);
mainPanel.add(downPanel, BorderLayout.CENTER);
pack();
this.getRootPane().setDefaultButton(saveCloseButton);
}
public void actionPerformed(ActionEvent e) {
if ("Sensitive".equals(e.getActionCommand())) {
if (sensitiveRadioButton.isSelected() == true) {
sensitiveComboBoxString.setEnabled(true);
} else {
sensitiveComboBoxString.setEnabled(false);
}
}
if ("Save_Close".equals(e.getActionCommand())) {
port.setPortName(new String(nameTextField.getText()));
if (!(nbitsTextField.getText().isEmpty())) {
Boolean nbitsValueInteger = false;
try {
Integer.parseInt(nbitsTextField.getText());
} catch (NumberFormatException e1) {
JDialog msg = new JDialog(this);
msg.setLocationRelativeTo(null);
JOptionPane.showMessageDialog(msg, "Nbits is not a Integer", "Warning !",
JOptionPane.WARNING_MESSAGE);
nbitsValueInteger = true;
}
/* if (nbitsValueInteger == false) {
port.setNbits(Integer.parseInt(nbitsTextField.getText()));
}
} else {
port.setNbits(-1);
}*/
}
// if (!(periodTextField.getText().isEmpty())) {
// Boolean periodValueInteger = false;
// try {
// Integer.parseInt(periodTextField.getText());
// } catch (NumberFormatException e1) {
// JDialog msg = new JDialog(this);
// msg.setLocationRelativeTo(null);
// JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !",
// JOptionPane.WARNING_MESSAGE);
// periodValueInteger = true;
// }
// if (periodValueInteger == false) {
// port.setPeriod(Integer.parseInt(periodTextField.getText()));
// }
// } else {
// port.setPeriod(-1);
// }
//
// if (!(rateTextField.getText().isEmpty())) {
// Boolean rateValueInteger = false;
// try {
// Integer.parseInt(rateTextField.getText());
// } catch (NumberFormatException e1) {
// JDialog msg = new JDialog(this);
// msg.setLocationRelativeTo(null);
// JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !",
// JOptionPane.WARNING_MESSAGE);
// rateValueInteger = true;
// }
// if (rateValueInteger == false) {
// port.setRate(Integer.parseInt(rateTextField.getText()));
// }
// } else {
// port.setRate(-1);
// }
//
// if (!(delayTextField.getText().isEmpty())) {
// Boolean delayValueInteger = false;
// try {
// Integer.parseInt(delayTextField.getText());
// } catch (NumberFormatException e1) {
// JDialog msg = new JDialog(this);
// msg.setLocationRelativeTo(null);
// JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !",
// JOptionPane.WARNING_MESSAGE);
// delayValueInteger = true;
// }
// if (delayValueInteger == false) {
// port.setDelay(Integer.parseInt(delayTextField.getText()));
// }
// } else {
// port.setDelay(-1);
// }
if(typeComboBoxString.getSelectedItem()=="sc_uint"){
port.setClockType("sc_uint<"+nbitsTextField.getText()+">");
}
else{
port.setClockType((String) typeComboBoxString.getSelectedItem());
// port.setTime((String) periodComboBoxString.getSelectedItem());
}
if ((String) originComboBoxString.getSelectedItem() == "Output") {
port.setOrigin(1);
} else {
port.setOrigin(0);
}
port.setSensitive(sensitiveRadioButton.isSelected());
port.setSensitiveMethod((String) sensitiveComboBoxString.getSelectedItem());
this.dispose();
}
if ("Cancel".equals(e.getActionCommand())) {
this.dispose();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment