diff --git a/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java b/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java index 7e08b1d363bc48a332cf798960a289c8a26242de..2b6f4654d54ce8e89dc9b43d03856df8627999d3 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java @@ -166,7 +166,7 @@ public class ClusterCode { corpsCluster = corpsCluster + CR + "\t// Instantiate clocks." + CR; for (SysCAMSTClock t : clock) { - + System.out.println("@@@@@@@@@@@@@@@@@@@@@ "+t.getName()); corpsCluster = corpsCluster + "\t sc_clock " + t.getName() + " (\"" + t.getName() + "\"," + t.getFrequency()+","+ t.getUnit()+","+ t.getDutyCycle()+","+ t.getStartTime()+","+ t.getUnitStartTime()+","+ t.getPosFirst()+");" + CR; } diff --git a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java index 0b06f8fe9ab52ff09a71388bd2a2c2d466a7ebdf..de822c97f0e21786449932ae72ee07197e3203e3 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/PrimitiveCode.java @@ -468,6 +468,10 @@ public class PrimitiveCode { corpsPrimitiveDE = corpsPrimitiveDE + "\t};" + CR2; } + //DG 17.10. + if(de.getClockName()!="") + corpsPrimitiveDE = corpsPrimitiveDE + "\tsc_core::sc_in <bool>" + de.getClockName() + ";" + CR; + //DG modified, was sca:core //System.out.println("@@@@@@@@@DE ports empty?"); if (!deports.isEmpty()) { @@ -557,7 +561,7 @@ if (t.getOrigin() == 0) { method = true; } - for (SysCAMSTPortDE t : deports) { + /* for (SysCAMSTPortDE t : deports) { if (t.getSensitive() == true) { if (method == false) { corpsPrimitiveDE = corpsPrimitiveDE + "\t{" + CR; @@ -570,7 +574,35 @@ if (t.getOrigin() == 0) { } sensitive = true; } + }*/ + + +//DG 17.10. + if(de.getClockName()!=""){ + corpsPrimitiveDE = corpsPrimitiveDE + "\t\tsensitive << " + de.getClockName() + "."; + if (de.getClockSensitiveMethod().equals("positive")) { + corpsPrimitiveDE = corpsPrimitiveDE + "pos();" + CR; + } else if (de.getClockSensitiveMethod().equals("negative")) { + corpsPrimitiveDE = corpsPrimitiveDE + "neg();" + CR; + } } + //fin ajoute DG + + for (SysCAMSTPortDE t : deports) { + if (t.getSensitive() == true) { + if (method == false) { + corpsPrimitiveDE = corpsPrimitiveDE + "\t{" + CR; + } + corpsPrimitiveDE = corpsPrimitiveDE + "\t\tsensitive << " + t.getName() + ";"; + if (t.getSensitiveMethod().equals("positive")) { + corpsPrimitiveDE = corpsPrimitiveDE + "pos();" + CR; + } else if (t.getSensitiveMethod().equals("negative")) { + corpsPrimitiveDE = corpsPrimitiveDE + "neg();" + CR; + } + sensitive = true; + } + } + if (sensitive == true || method == true) { corpsPrimitiveDE = corpsPrimitiveDE + "\t}" + CR2; } else { @@ -583,6 +615,7 @@ if (t.getOrigin() == 0) { // 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/ui/SysCAMSPanelTranslator.java b/src/main/java/ui/SysCAMSPanelTranslator.java index 8df4e8eeaaeebab9378e2b71b7dd50f32fb04013..224bf55ab24fb87f3fec0e1676f4b38398f4f94d 100644 --- a/src/main/java/ui/SysCAMSPanelTranslator.java +++ b/src/main/java/ui/SysCAMSPanelTranslator.java @@ -123,6 +123,7 @@ System.out.println("@@@ Panel Translator "); String blockDEName = blockDE.getValue(); String clockName = blockDE.getClockName(); + String clockSensitivityMethod = blockDE.getClockSensitivityMethod(); // int periodBlock = blockDE.getPeriod(); // String time = blockDE.getTime(); // String nameFn = blockDE.getNameFn(); @@ -132,7 +133,7 @@ System.out.println("@@@ Panel Translator "); // String typeTemplate = blockDE.getTypeTemplate(); // DefaultListModel<String> listTypedef = blockDE.getListTypedef(); - SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, clockName, "", "", null, "", "", "", null, null); + SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, clockName, clockSensitivityMethod, "", "", null, "", "", "", null, null); List<SysCAMSPortDE> portsDE = blockDE.getAllInternalPortsDE(); for (int i = 0; i < portsDE.size(); i++) { @@ -272,6 +273,7 @@ System.out.println("@@@ Panel Translator "); SysCAMSBlockDE blockDE = blocksDE.get(i); String blockDEName = blockDE.getValue(); String clockName = blockDE.getClockName(); + String clockSensitivityMethod = blockDE.getClockSensitivityMethod(); String nameFn = blockDE.getNameFn(); String code = blockDE.getCode(); DefaultListModel<String> listStruct = blockDE.getListStruct(); @@ -280,7 +282,7 @@ System.out.println("@@@ Panel Translator "); String valueTemplate = blockDE.getValueTemplate(); DefaultListModel<String> listTypedef = blockDE.getListTypedef(); - SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, clockName, nameFn, code, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef, syscamsCluster); + SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, clockName, clockSensitivityMethod, nameFn, code, listStruct, nameTemplate, typeTemplate, valueTemplate, listTypedef, syscamsCluster); List<SysCAMSPortDE> portsDE = blockDE.getAllInternalPortsDE(); for (int j = 0; j < portsDE.size(); j++) { diff --git a/src/main/java/ui/syscams/SysCAMSBlockDE.java b/src/main/java/ui/syscams/SysCAMSBlockDE.java index a07c780529f2d41884f3b83298e903b8a9cf95d5..460749523f266c288e39a4ed95e498c156f0021c 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockDE.java +++ b/src/main/java/ui/syscams/SysCAMSBlockDE.java @@ -65,6 +65,8 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements private String code; private String clock; private String clockName; + private String clockSensitivityMethod; + private boolean sensitive; private DefaultListModel<String> listStruct; private String nameTemplate; private String typeTemplate; @@ -305,6 +307,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements // sb.append(getPeriod()); // sb.append("\" time=\"" + getTime()); sb.append("\" clockName=\"" + getClockName()); + sb.append("\" clockSensitivityMethod\"" + getClockSensitivityMethod()); sb.append("\" code=\"" + encode(getCode())); sb.append("\" listStruct=\"" + splitParameters(getListStruct())); sb.append("\" nameTemplate=\"" + getNameTemplate()); @@ -449,6 +452,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements // period = Integer.decode(elt.getAttribute("period")).intValue(); // time = elt.getAttribute("time"); clockName = elt.getAttribute("clockName"); + clockSensitivityMethod = elt.getAttribute("clockSensitivityMethod"); code = elt.getAttribute("code"); nameFn = elt.getAttribute("name_function"); listStruct = elt.getAttribute("listStruct"); @@ -535,6 +539,23 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements public String getClockName() { return clock; } + + public boolean getSensitive() { + return sensitive; + } + + public void setSensitive(boolean _sensitive) { + sensitive = _sensitive; + } + + public String getClockSensitivityMethod() { + return clockSensitivityMethod; + } + + + public void setClockSensitivityMethod(String _clockSensitivityMethod) { + clockSensitivityMethod = _clockSensitivityMethod; + } public void setNameFn(String nameFn) { this.nameFn = nameFn; diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java index 4e1b9d75eba2bec964cf27023958d7f3966086e6..0837525b20d97f38aa8a5a9ccf463e1008b0489e 100644 --- a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java @@ -61,6 +61,7 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li private JTextField nameTextField; private JTextField clockTextField; + // private JTextField periodTextField; // private String listPeriodString[]; // private JComboBox<String> periodComboBoxString; @@ -82,7 +83,8 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li private JTextField nameTypedefTextField; private String listTypeTypedefString[]; private JComboBox<String> typeTypedefComboBoxString; - private JButton addModifyTypedefButton; + + private JButton addModifyTypedefButton; private ArrayList<String> listTmpTypedef; private JList<String> typedefList; private DefaultListModel<String> typedefListModel; @@ -95,7 +97,11 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li private JButton nameFnButton; private JTextArea codeTextArea; private String finalString; - + + private JRadioButton sensitiveRadioButton; + private String listSensitiveString[]; + private JComboBox<String> sensitiveComboBoxString; + private SysCAMSBlockDE block; public JDialogSysCAMSBlockDE(SysCAMSBlockDE block) { @@ -292,6 +298,27 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li gridBag.setConstraints(clockTextField, constraints); attributesBoxPanel.add(clockTextField); + + listSensitiveString = new String[3]; + listSensitiveString[0] = ""; + listSensitiveString[1] = "positive"; + listSensitiveString[2] = "negative"; + sensitiveComboBoxString = new JComboBox<String>(listSensitiveString); + if (block.getClockSensitivityMethod().equals("")) { + sensitiveComboBoxString.setSelectedIndex(0); + } else if (block.getClockSensitivityMethod().equals("positive")) { + sensitiveComboBoxString.setSelectedIndex(1); + } else if (block.getClockSensitivityMethod().equals("negative")) { + sensitiveComboBoxString.setSelectedIndex(2); + } + sensitiveComboBoxString.setActionCommand("Sensitive_method"); + sensitiveComboBoxString.setEnabled(block.getSensitive()); + sensitiveComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(1, 2, 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); + attributesBoxPanel.add(sensitiveComboBoxString); attributesBox.add(attributesBoxPanel); attributesMainPanel.add(attributesBox, BorderLayout.NORTH); @@ -714,6 +741,13 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li } public void actionPerformed(ActionEvent e) { + if ("Sensitive".equals(e.getActionCommand())) { + if (sensitiveRadioButton.isSelected() == true) { + sensitiveComboBoxString.setEnabled(true); + } else { + sensitiveComboBoxString.setEnabled(false); + } + } if ("Name_OK".equals(e.getActionCommand())) { if (!nameFnTextField.getText().equals("")) { codeTextArea.setText("void " + nameFnTextField.getText() + "() {\n\n}"); @@ -1062,6 +1096,9 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener, Li block.setCode(codeTextArea.getText()); } + block.setSensitive(sensitiveRadioButton.isSelected()); + block.setClockSensitivityMethod((String) sensitiveComboBoxString.getSelectedItem()); + this.dispose(); }