Commit d90285ba authored by Daniela Genius's avatar Daniela Genius

merge

parent 0d45b2b0
......@@ -18,8 +18,8 @@ updateruntime:
cp mutekh/libmwmr/include/mwmr/mwmr.h mutekh/examples/avatar
cp mutekh/libsyscams/*.c mutekh/examples/avatar
cp mutekh/libsyscams/*.h mutekh/examples/avatar
cp src/*.c ~/TTool/MPSoC/mutekh/examples/avatar
cp src/*.h ~/TTool/MPSoC/mutekh/examples/avatar
cp src/*.c mutekh/examples/avatar
cp src/*.h mutekh/examples/avatar
updategeneratedcode:
......
......@@ -91,6 +91,7 @@ public class SysCAMSSpecification{
for (SysCAMSTComponent blockGPIO2VCI : components) {
if (blockGPIO2VCI instanceof SysCAMSTBlockGPIO2VCI) {
blocksGPIO2VCI.add((SysCAMSTBlockGPIO2VCI) blockGPIO2VCI);
//System.out.println("@@@@@GPIO block found in spec");
}
}
return blocksGPIO2VCI;
......@@ -238,6 +239,14 @@ public class SysCAMSSpecification{
}
return cons;
}
public LinkedList<SysCAMSTConnector> getAllConnectors(){
LinkedList<SysCAMSTConnector> cons = new LinkedList<SysCAMSTConnector>();
for (SysCAMSTConnector con : connectors) {
cons.add(con);
}
return cons;
}
public int getNbBlockTDF(){
return (getAllBlockTDF()).size();
......
......@@ -59,13 +59,14 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent {
private DefaultListModel<String> listStruct;
private String nameTemplate;
private String typeTemplate;
private String valueTemplate;
private DefaultListModel<String> listTypedef;
private SysCAMSTCluster cluster;
private LinkedList<SysCAMSTPortDE> portDE;
public SysCAMSTBlockDE(String _name, String _nameFn, String _code, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) {
public SysCAMSTBlockDE(String _name, String _nameFn, String _code, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) {
name = _name;
// period = _period;
// time = _time;
......@@ -74,6 +75,7 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent {
listStruct = _listStruct;
nameTemplate = _nameTemplate;
typeTemplate = _typeTemplate;
valueTemplate = _valueTemplate;
listTypedef = _listTypedef;
cluster = _cluster;
portDE = new LinkedList<SysCAMSTPortDE>();
......@@ -110,6 +112,10 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent {
public String getTypeTemplate() {
return typeTemplate;
}
public String getValueTemplate() {
return valueTemplate;
}
public DefaultListModel<String> getListTypedef() {
return listTypedef;
......@@ -126,4 +132,4 @@ public class SysCAMSTBlockDE extends SysCAMSTComponent {
public void addPortDE(SysCAMSTPortDE de){
portDE.add(de);
}
}
\ No newline at end of file
}
......@@ -57,9 +57,11 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
private double period;
private String time;
private String processCode;
private String constructorCode;
private DefaultListModel<String> listStruct;
private String nameTemplate;
private String typeTemplate;
private String valueTemplate;
private DefaultListModel<String> listTypedef;
private SysCAMSTCluster cluster;
......@@ -67,21 +69,25 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
private LinkedList<SysCAMSTPortTDF> portTDF;
private LinkedList<SysCAMSTPortConverter> portConverter;
private SysCAMSTPortConverter localPortConverter;
private LinkedList<SysCAMSTPortConverter> localPortConverterList;
private int n;
private boolean isTimestepPropagated;
public SysCAMSTBlockTDF(String _name, double _period, String _time, String _processCode, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) {
public SysCAMSTBlockTDF(String _name, double _period, String _time, String _processCode, String _constructorCode, DefaultListModel<String> _listStruct, String _nameTemplate, String _typeTemplate, String _valueTemplate, DefaultListModel<String> _listTypedef, SysCAMSTCluster _cluster) {
name = _name;
period = _period;
time = _time;
processCode = _processCode;
constructorCode = _constructorCode;
listStruct = _listStruct;
nameTemplate = _nameTemplate;
typeTemplate = _typeTemplate;
valueTemplate = _valueTemplate;
listTypedef = _listTypedef;
cluster = _cluster;
portTDF = new LinkedList<SysCAMSTPortTDF>();
portConverter = new LinkedList<SysCAMSTPortConverter>();
localPortConverterList = new LinkedList<SysCAMSTPortConverter>();
n = 0;
isTimestepPropagated = false;
}
......@@ -105,6 +111,10 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
public String getProcessCode() {
return processCode;
}
public String getConstructorCode() {
return constructorCode;
}
public DefaultListModel<String> getListStruct() {
return listStruct;
......@@ -117,6 +127,10 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
public String getTypeTemplate() {
return typeTemplate;
}
public String getValueTemplate() {
return valueTemplate;
}
public DefaultListModel<String> getListTypedef() {
return listTypedef;
......@@ -153,8 +167,19 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
public void syncTDFBlockDEBlock(double[] time_prev) throws SysCAMSValidateException {
double tp;
try{
//Order list to have input converter ports first, in case of multirate-multiport single-modules
localPortConverterList.clear();
for(int i = 0; i < portConverter.size(); i++) {
localPortConverter = portConverter.get(i);
if(localPortConverter.getOrigin() == 0) { //Input
localPortConverterList.addFirst(localPortConverter);
} else if (localPortConverter.getOrigin() == 1) { //Output
localPortConverterList.addLast(localPortConverter);
}
}
for(int i = 0; i < localPortConverterList.size(); i++) {
localPortConverter = localPortConverterList.get(i);
if(localPortConverter.getOrigin() == 0) { //Input
check_causality_in(time_prev);
} else if (localPortConverter.getOrigin() == 1) { //Output
......@@ -169,8 +194,7 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
}
private void check_causality_in(double[] time_prev_max) throws SysCAMSValidateException {
double time_now_min_tdf, time_now_max_tdf, time_tmp_tdf, time_tmp_de,
time_now_min_de, time_now_max_de;
double time_now_max_de;
double tm = 0.0;
double tp = 0.0;
int r = 1;
......@@ -185,41 +209,22 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
if(localPortConverter.getDelay() > 0)
d = localPortConverter.getDelay();
time_now_min_tdf = (n*tm)+((k-1)*tp);
time_now_max_tdf = (n*tm)+((k-1)*tp);
time_now_min_de = (n*tm)+((k-1)*tp)-(d*tp);
time_now_max_de = (n*tm)+((k-1)*tp)-(d*tp);
for (k = 1; k <= r; k++) {
time_tmp_tdf = (n*tm)+((k-1)*tp);
time_tmp_de = (n*tm)+((k-1)*tp)-(d*tp);
System.out.println("tmstmp_in_tdf: " + time_tmp_tdf);
System.out.println("tmstmp_in_de: " + time_tmp_de);
time_now_min_tdf = Math.min(time_tmp_tdf, time_now_min_tdf);
time_now_max_tdf = Math.max(time_tmp_tdf, time_now_max_tdf);
time_now_min_de = Math.min(time_tmp_de, time_now_min_de);
time_now_max_de = Math.max(time_tmp_de, time_now_max_de);
System.out.println("time_now_min_de: " + time_now_min_de);
System.out.println("time_now_max_de: " + time_now_max_de);
System.out.println("time_now_min_tdf: " + time_now_min_tdf);
System.out.println("time_now_max_tdf: " + time_now_max_tdf);
}
time_now_max_de = (n*tm)+((r-1)*tp)-(d*tp);
System.out.println("time_prev_max_out: " + time_prev_max[1]);
if(time_now_min_tdf < time_prev_max[1]) {
localPortConverter.setDelay((int)Math.ceil((time_prev_max[1]-time_now_min_de)/tp) + d);
/*if(time_now_min_tdf2 < time_prev_max[1]) {
localPortConverter.setDelay((int)Math.ceil((time_prev_max[1]-time_now_min_tdf2)/tp) + d);
localPortConverter.setRecompute(true);
throw new SysCAMSValidateException("Timestamp of previous write port executed module is: " + time_prev_max[1]
+ " and current timestamp is: " + time_now_min_tdf + ".\n"
+ "Suggested delay in port \"" + localPortConverter.getName() + "\": " + (Math.ceil((time_prev_max[1]-time_now_min_tdf)/tp) + d));
}
+ "Suggested delay in port \"" + localPortConverter.getName() + "\" using time_now_min_tdf: " + (Math.ceil((time_prev_max[1]-time_now_min_tdf)/tp) + d)
+ " and using time_now_min_de: " + (Math.ceil((time_prev_max[1]-time_now_min_de)/tp) + d));
}*/
time_prev_max[0] = Double.valueOf(Math.max(time_prev_max[0],time_now_max_de));
System.out.println("New time_prev_max_in: " + time_prev_max[0]);
}
private void check_causality_out(double[] time_prev_max) throws SysCAMSValidateException {
double time_now_min_tdf, time_now_max_tdf, time_tmp_tdf, time_tmp_de,
time_now_min_de, time_now_max_de;
double time_now_min_tdf, time_now_max_de2;
double tm = 0.0;
double tp = 0.0;
int r = 1;
......@@ -234,36 +239,19 @@ public class SysCAMSTBlockTDF extends SysCAMSTComponent {
if(localPortConverter.getDelay() > 0)
d = localPortConverter.getDelay();
time_now_min_tdf = (n*tm)+((k-1)*tp);
time_now_max_tdf = (n*tm)+((k-1)*tp);
time_now_min_de = (n*tm)+((k-1)*tp)+(d*tp);
time_now_max_de = (n*tm)+((k-1)*tp)+(d*tp);
time_now_min_tdf = (n*tm)+((1-1)*tp)+(d*tp);
time_now_max_de2 = (n*tm)+((r-1)*tp)-(d*tp);
for (k = 1; k <= r; k++) {
time_tmp_tdf = (n*tm)+((k-1)*tp);
time_tmp_de = (n*tm)+((k-1)*tp)+(d*tp);;
System.out.println("tmstmp_out_tdf: " + time_tmp_tdf);
System.out.println("tmstmp_out_de: " + time_tmp_de);
time_now_min_tdf = Math.min(time_tmp_tdf, time_now_min_tdf);
time_now_max_tdf = Math.max(time_tmp_tdf, time_now_max_tdf);
time_now_min_de = Math.min(time_tmp_de, time_now_min_de);
time_now_max_de = Math.max(time_tmp_de, time_now_max_de);
System.out.println("time_now_min_de: " + time_now_min_de);
System.out.println("time_now_max_de: " + time_now_max_de);
System.out.println("time_now_min_tdf: " + time_now_min_tdf);
System.out.println("time_now_max_tdf: " + time_now_max_tdf);
}
System.out.println("time_prev_max_in: " + time_prev_max[0]);
if(time_now_min_de < time_prev_max[0]) {
localPortConverter.setDelay((int)Math.ceil((time_prev_max[0]-time_now_min_de)/tp) + d);
if(time_now_min_tdf < time_prev_max[0]) {
localPortConverter.setDelay((int)Math.ceil((time_prev_max[0]-time_now_min_tdf)/tp) + d);
localPortConverter.setRecompute(true);
throw new SysCAMSValidateException("Timestamp of previous read port executed module is: " + time_prev_max[0]
+ " and current timestamp is: " + time_now_min_de + ".\n"
+ "Suggested delay in port " + localPortConverter.getName() + ": " + (Math.ceil((time_prev_max[0]-time_now_min_de)/tp) + d));
+ " and current timestamp is: " + time_now_min_tdf + ".\n"
+ "Suggested delay in port " + localPortConverter.getName() + ": " + (Math.ceil((time_prev_max[0]-time_now_min_tdf)/tp) + d));
}
time_prev_max[1] = Double.valueOf(Math.max(time_prev_max[1],time_now_max_tdf));
System.out.println("New time_prev_max_out: " + time_prev_max[1]);
time_prev_max[1] = Double.valueOf(Math.max(time_prev_max[1],time_now_max_de2));
}
public void setN(int _n) {
......
......@@ -58,6 +58,7 @@ public class SysCAMSTPortTDF extends SysCAMSTComponent {
private int delay;
private int origin;
private String TDFType;
private boolean recompute;
private SysCAMSTBlockTDF blockTDF;
private ELNTCluster cluster;
......@@ -71,6 +72,7 @@ public class SysCAMSTPortTDF extends SysCAMSTComponent {
delay = _delay;
origin = _origin;
TDFType = _TDFType;
recompute = false;
blockTDF = _blockTDF;
}
......@@ -127,6 +129,14 @@ public class SysCAMSTPortTDF extends SysCAMSTComponent {
public void setDelay(int _delay) {
delay = _delay;
}
public boolean getRecompute() {
return recompute;
}
public void setRecompute(boolean _recompute) {
recompute = _recompute;
}
public int getOrigin() {
return origin;
......
......@@ -104,4 +104,4 @@ public class Header {
}
return headerCluster;
}
}
\ No newline at end of file
}
......@@ -370,7 +370,7 @@ public class PrimitiveCode {
}
}
}
corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_H";
corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_H";
} else {
corpsPrimitiveTDF = "";
}
......@@ -596,10 +596,10 @@ public class PrimitiveCode {
String pc = buffer.toString();
corpsPrimitiveDE = corpsPrimitiveDE + "\t" + pc;
corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_H";
corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_H";
} else {
corpsPrimitiveDE = "";
}
return corpsPrimitiveDE;
}
}
\ No newline at end of file
}
......@@ -63,6 +63,8 @@ public class TopCellGenerator {
private final static String GENERATED_PATH1 = "generated_CPP" + File.separator;
private final static String GENERATED_PATH2 = "generated_H" + File.separator;
private final static String CR = "\n";
private final static String CR2 = "\n\n";
public TopCellGenerator(SysCAMSSpecification sys) {
syscams = sys;
......@@ -94,40 +96,57 @@ public class TopCellGenerator {
return (top);
}
public void saveFile(String path) {
public void saveFile(String path, Boolean standalone) {
SysCAMSTCluster cluster = TopCellGenerator.syscams.getCluster();
LinkedList<SysCAMSTConnector> connectors = TopCellGenerator.syscams.getAllConnectorCluster();
FileWriter fw;
String top;
try {
// Save file .cpp
System.err.println(path + GENERATED_PATH1 + cluster.getClusterName() + ".cpp");
FileWriter fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tb.cpp");
System.err.println(path + cluster.getClusterName() + ".cpp");
if(standalone==true){
//System.out.println("@@@@ topcell standalone @@@@");
fw = new FileWriter(path + "/" + cluster.getClusterName() + "_tb.cpp");}
else{
fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tb.cpp");
}
fw = new FileWriter(path + "/" + cluster.getClusterName() + "_tb.cpp");
top = generateTopCell(cluster, connectors);
fw.write(top);
fw.close();
} catch (Exception ex) {
ex.printStackTrace();
}
// Save files .h
saveFileBlock(path, cluster);
saveFileBlock(path, cluster, standalone);
}
public void saveFileBlock(String path, SysCAMSTCluster c) {
public void saveFileBlock(String path, SysCAMSTCluster c, Boolean standalone) {
String headerTDF, headerDE, codeTDF, codeDE;
LinkedList<SysCAMSTBlockTDF> tdf = c.getBlockTDF();
LinkedList<SysCAMSTBlockDE> de = c.getBlockDE();
FileWriter fw;
for (SysCAMSTBlockTDF t : tdf) {
try {
System.err.println(path + GENERATED_PATH2 + t.getName() + ".h");
FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h");
System.err.println(path + t.getName() + ".h");
if(standalone==true){
//System.out.println("@@@@ TDF standalone @@@@");
fw = new FileWriter(path + "/" + t.getName() + ".h");}
else
fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h");
headerTDF = Header.getPrimitiveHeaderTDF(t);
fw.write(headerTDF);
codeTDF = PrimitiveCode.getPrimitiveCodeTDF(t);
// if(standalone==false)
// codeTDF = codeTDF + CR + "};" + CR2 + "#endif";
fw.write(codeTDF);
fw.close();
} catch (Exception ex) {
ex.printStackTrace();
}
......@@ -135,12 +154,21 @@ public class TopCellGenerator {
for (SysCAMSTBlockDE t : de) {
try {
System.err.println(path + GENERATED_PATH2 + t.getName() + ".h");
FileWriter fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h");
System.err.println(path + t.getName() + ".h");//ajoute DG
if(standalone==true){
//System.out.println("@@@@ DE standalone @@@@");
fw = new FileWriter(path + "/" + t.getName() + ".h");}
else
fw = new FileWriter(path + GENERATED_PATH2 + "/" + t.getName() + ".h");
headerDE = Header.getPrimitiveHeaderDE(t);
fw.write(headerDE);
codeDE = PrimitiveCode.getPrimitiveCodeDE(t);
// if(standalone==false)
// codeDE = codeDE + CR + "};" + CR2 + "#endif";//DG
fw.write(codeDE);
fw.close();
} catch (Exception ex) {
ex.printStackTrace();
}
......
......@@ -45,8 +45,8 @@ import java.util.LinkedList;
import syscamstranslator.*;
/**
* Class Header
* Header of files .h and .cpp
* Class HeaderCluster
* HeaderCluster of files .h and .cpp
* Creation: 14/05/2018
* @version 1.0 14/05/2018
* @author Irina Kit Yan LEE
......@@ -54,7 +54,7 @@ import syscamstranslator.*;
* @author Rodrigo CORTES PORTO
*/
public class Header {
public class HeaderCluster {
static private String headerPrimitiveTDF;
static private String headerPrimitiveDE;
static private String headerCluster;
......@@ -62,7 +62,7 @@ public class Header {
private final static String CR = "\n";
private final static String CR2 = "\n\n";
Header() {}
HeaderCluster() {}
public static String getPrimitiveHeaderTDF(SysCAMSTBlockTDF tdf) {
if (tdf != null) {
......@@ -107,4 +107,4 @@ public class Header {
}
return headerCluster;
}
}
\ No newline at end of file
}
......@@ -50,21 +50,21 @@ import java.util.LinkedList;
import syscamstranslator.*;
/**
* Class MakefileCodeRodrigo Principal code of a makefile Creation: 02/06/2018
* Class MakefileCodeCluster Principal code of a makefile Creation: 02/06/2018
*
* @version 1.0 02/06/2018
* @author Irina Kit Yan LEE
*/
public class MakefileCodeRodrigo {
public class MakefileCodeCluster {
static private String corpsMakefile;
private final static String CR = "\n";
private final static String CR2 = "\n\n";
MakefileCodeRodrigo() {
MakefileCodeCluster() {
}
public static String getMakefileCodeRodrigo(LinkedList<SysCAMSTCluster> clusters) {
public static String getMakefileCode(LinkedList<SysCAMSTCluster> clusters) {
if (clusters != null) {
corpsMakefile = "# Compiler and linker flags" + CR + "CXXFLAGS = -g -Wall -I. $(SYSTEMC_INCLUDE_DIRS)" + CR
+ "LDFLAGS = $(SYSTEMC_LIBRARY_DIRS)" + CR2 + "# List of all ecutables to be compiled" + CR
......
......@@ -50,20 +50,20 @@ import java.util.LinkedList;
import syscamstranslator.*;
/**
* Class PrimitiveCode
* Class PrimitiveCodeCluster
* Principal code of a primive component
* Creation: 14/05/2018
* @version 1.0 14/05/2018
* @author Irina Kit Yan LEE
*/
public class PrimitiveCode {
public class PrimitiveCodeCluster {
static private String corpsPrimitiveTDF;
static private String corpsPrimitiveDE;
private final static String CR = "\n";
private final static String CR2 = "\n\n";
PrimitiveCode() {}
PrimitiveCodeCluster() {}
public static String getPrimitiveCodeTDF(SysCAMSTBlockTDF tdf) {
corpsPrimitiveTDF = "";
......@@ -127,14 +127,12 @@ public class PrimitiveCode {
if (i == 0) {
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t: " + identifier + "(" + value + ")" + CR;
}
if ((i > 0) && (i < tdf.getListStruct().getSize()-1)) {
if ((i > 0)) {
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR;
}
if (i == tdf.getListStruct().getSize()-1 && i != 0) {
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t, " + identifier + "(" + value + ")" + CR + "\t\t{}" + CR;
} else {
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR;
}
if (i == tdf.getListStruct().getSize()-1) {
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t\t{}" + CR;
}
}
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t};" + CR2;
}
......@@ -218,8 +216,9 @@ public class PrimitiveCode {
}
}
}
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t{}" + CR2 + "protected:" + CR;
}
String ctorcode = tdf.getConstructorCode();
corpsPrimitiveTDF = corpsPrimitiveTDF + "\t{\n"+ctorcode+"\n\t}" + CR2 + "protected:" + CR;
if (tdf.getPeriod() != -1) {
corpsPrimitiveTDF = corpsPrimitiveTDF + "\tvoid set_attributes() {" + CR + "\t\t" + "set_timestep(" + tdf.getPeriod() + ", sc_core::SC_" + tdf.getTime().toUpperCase() + ");" + CR;
......@@ -370,7 +369,7 @@ public class PrimitiveCode {
}
}
}
corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_TDF_H";
corpsPrimitiveTDF = corpsPrimitiveTDF + "};" + CR2 + "#endif" + " // " + tdf.getName().toUpperCase() + "_TDF_H";
} else {
corpsPrimitiveTDF = "";
}
......@@ -389,7 +388,7 @@ public class PrimitiveCode {
corpsPrimitiveDE = corpsPrimitiveDE + "template<" + de.getTypeTemplate() + " " + de.getNameTemplate() + ">" + CR;
}
//corpsPrimitive = "SCA_TDF_MODULE(" + de.getName() + ") {" + CR2;
corpsPrimitiveDE = corpsPrimitiveDE + "class " + de.getName() + " : public sca_core::sca_module {" + CR2 + "public:" + CR;
corpsPrimitiveDE = corpsPrimitiveDE + "class " + de.getName() + " : public sc_core::sc_module {" + CR2 + "public:" + CR;
if (!de.getListTypedef().isEmpty()) {
for (int i = 0; i < de.getListTypedef().getSize(); i++) {
......@@ -438,14 +437,12 @@ public class PrimitiveCode {
if (i == 0) {
corpsPrimitiveDE = corpsPrimitiveDE + "\t\t: " + identifier + "(" + value + ")" + CR;
}
if ((i > 0) && (i < de.getListStruct().getSize()-1)) {
if ((i > 0)) {
corpsPrimitiveDE = corpsPrimitiveDE + "\t\t, " + identifier + "(" + value + ")" + CR;
}
if (i == de.getListStruct().getSize()-1 && i != 0) {
corpsPrimitiveDE = corpsPrimitiveDE + "\t\t, " + identifier + "(" + value + ")" + CR + "\t\t{}" + CR;
} else {
corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR;
}
if (i == de.getListStruct().getSize()-1) {
corpsPrimitiveDE = corpsPrimitiveDE + "\t\t{}" + CR;
}
}
corpsPrimitiveDE = corpsPrimitiveDE + "\t};" + CR2;
}
......@@ -453,9 +450,9 @@ public class PrimitiveCode {
if (!deports.isEmpty()) {
for (SysCAMSTPortDE t : deports) {
if (t.getOrigin() == 0) {
corpsPrimitiveDE = corpsPrimitiveDE + "\tsca_core::sca_in<" + t.getDEType() + "> " + t.getName() + ";" + CR;
corpsPrimitiveDE = corpsPrimitiveDE + "\tsc_core::sc_in< " + t.getDEType() + " > " + t.getName() + ";" + CR;
} else if (t.getOrigin() == 1) {
corpsPrimitiveDE = corpsPrimitiveDE + "\tsca_core::sca_out<" + t.getDEType() + "> " + t.getName() + ";" + CR;
corpsPrimitiveDE = corpsPrimitiveDE + "\tsc_core::sc_out< " + t.getDEType() + " > " + t.getName() + ";" + CR;
}
}
}
......@@ -518,12 +515,14 @@ public class PrimitiveCode {
if (method == false) {
corpsPrimitiveDE = corpsPrimitiveDE + "\t{" + CR;
}
corpsPrimitiveDE = corpsPrimitiveDE + "\t\tsensitive << " + t.getName() + ".";
corpsPrimitiveDE = corpsPrimitiveDE + "\t\tsensitive << " + t.getName();
if (t.getSensitiveMethod().equals("positive")) {
corpsPrimitiveDE = corpsPrimitiveDE + "pos();" + CR;
corpsPrimitiveDE = corpsPrimitiveDE + ".pos();" + CR;
} else if (t.getSensitiveMethod().equals("negative")) {
corpsPrimitiveDE = corpsPrimitiveDE + "neg();" + CR;
}
corpsPrimitiveDE = corpsPrimitiveDE + ".neg();" + CR;
} else if (t.getSensitiveMethod().equals("")) {
corpsPrimitiveDE = corpsPrimitiveDE + ";" + CR;
}
sensitive = true;
}
}
......@@ -596,10 +595,10 @@ public class PrimitiveCode {
String pc = buffer.toString();
corpsPrimitiveDE = corpsPrimitiveDE + "\t" + pc;
corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_TDF_H";
corpsPrimitiveDE = corpsPrimitiveDE + CR + "};" + CR2 + "#endif" + " // " + de.getName().toUpperCase() + "_TDF_H";
} else {
corpsPrimitiveDE = "";
}
return corpsPrimitiveDE;
}
}
\ No newline at end of file
}
......@@ -66,6 +66,9 @@ public class TopCellGeneratorCluster {
private final static String GENERATED_PATH1 = "generated_CPP" + File.separator;
private final static String GENERATED_PATH2 = "generated_H" + File.separator;
private final static String CR = "\n";
private final static String CR2 = "\n\n";
public TopCellGeneratorCluster(SysCAMSSpecification sys) {
syscams = sys;
}
......@@ -74,7 +77,7 @@ public class TopCellGeneratorCluster {
if (c == null) {
System.out.println("***Warning: require at least one cluster***");
}
if (TopCellGeneratorCluster.syscams.getNbBlockTDF() == 0) {
/*if (TopCellGeneratorCluster.syscams.getNbBlockTDF() == 0) {
System.out.println("***Warning: require at least one TDF block***");
}
if (TopCellGeneratorCluster.syscams.getNbPortTDF() == 0) {
......@@ -91,58 +94,89 @@ public class TopCellGeneratorCluster {
}
if (TopCellGeneratorCluster.syscams.getNbConnectorCluster() == 0) {
System.out.println("***Warning: require at least one connector***");
}
String top = Header.getClusterHeader(c) + ClusterCode.getClusterCode(c, connectors);
}*/
String top = HeaderCluster.getClusterHeader(c) + ClusterCode.getClusterCode(c, connectors);
return (top);
}
public void saveFile(String path) {
public void saveFile(String path, Boolean standalone) {
SysCAMSTCluster cluster = TopCellGeneratorCluster.syscams.getCluster();
LinkedList<SysCAMSTConnector> connectors = TopCellGeneratorCluster.syscams.getAllConnectorsCluster4Soclib();
LinkedList<SysCAMSTConnector> connectors = TopCellGeneratorCluster.syscams.getAllConnectors();
FileWriter fw;
String top;
try {
// Save file .cpp
System.err.println(path + GENERATED_PATH1 + cluster.getClusterName() + "_tdf.h");
FileWriter fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tdf.h");
System.err.println(path + cluster.getClusterName() + "_tdf.h");
if(standalone==true){
//System.out.println("@@@ Cluster standalone");
fw = new FileWriter(path + cluster.getClusterName() + "_tdf.h");
}
else
fw = new FileWriter(path + GENERATED_PATH1 + "/" + cluster.getClusterName() + "_tdf.h");
top = generateTopCell(cluster, connectors);
fw.write(top);
fw.close();
} catch (Exception ex) {
ex.printStackTrace();