Commit 846e6764 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Adding drawing of TML from TMAP file

parent 2fab82fd
......@@ -382,9 +382,8 @@ public class TMLMappingTextSpecification<E> {
public boolean makeTMLMapping(String _spec, String path) {
DIPLOElement.resetID();
spec = _spec;
//tmlmap = new TMLMappingodeling();
errors = new ArrayList<TMLTXTError>();
warnings = new ArrayList<TMLTXTError>();
......@@ -858,10 +857,11 @@ public class TMLMappingTextSpecification<E> {
split = s1.split("\\s");
if (split.length > 0) {
if ((split[0].equals("#include")) && (split.length == 2)) {
TraceManager.addDev("Include found: " + s);
s1 = split[1];
if ((s1.charAt(0) == '\"') && (s1.charAt(s1.length() - 1) == '\"')) {
s1 = s1.substring(1, s1.length() - 1).trim();
//TraceManager.addDev("Loading file:" + path + s1);
TraceManager.addDev("Loading file:" + path + s1);
try {
content = FileUtils.loadFile(path + s1);
output += content + CR;
......@@ -886,6 +886,8 @@ public class TMLMappingTextSpecification<E> {
addError(0, lineNb, 0, "Exception when reading specification", null);
}
TraceManager.addDev("New output=" + output);
return output;
}
}
......@@ -54,6 +54,7 @@ import myutilsvg.SVGGeneration;
import org.xml.sax.SAXException;
import proverifspec.ProVerifOutputAnalyzer;
import tmltranslator.TMLMapping;
import tmltranslator.TMLMappingTextSpecification;
import tmltranslator.TMLModeling;
import tmltranslator.TMLTextSpecification;
import tmltranslator.simulation.SimulationTransaction;
......@@ -485,7 +486,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per
jfclib.setFileFilter(filterLib);
TMLFilter tmlFilterLib = new TMLFilter();
jfctml.setFileFilter(tmlFilterLib);
jfctml.setFileFilter( new FileNameExtensionFilter("Select TML or TMAP Files","tml","tmap"));
//jfctml.setFileFilter(new FileNameExtensionFilter("Select TML/TMAP Files","tml","tmap"));
TImgFilter filterImg = new TImgFilter();
......@@ -5385,29 +5386,59 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per
public void loadAndDrawTMLTxt() {
File tmlfile;
int returnVal = jfctml.showDialog(frame, "Load TML Specification (Text format)");
int returnVal = jfctml.showDialog(frame, "Load TML / TMAP Specification (Text format)");
if (returnVal != JFileChooser.APPROVE_OPTION) {
return;
}
tmlfile = jfctml.getSelectedFile();
tmlfile = FileUtils.addFileExtensionIfMissing(tmlfile, TMLFilter.getExtension());
//tmlfile = FileUtils.addFileExtensionIfMissing(tmlfile, TMLFilter.getExtension());
String content = loadFile(tmlfile);
// Get TML Modeling from content
TMLTextSpecification ts = new TMLTextSpecification(tmlfile.getName());
boolean b = ts.makeTMLModeling(content);
if (!b) {
TraceManager.addDev("Error in loaded spec");
return;
}
// tml or tmap?
if (tmlfile.getName().endsWith("tml")) {
// Get TML Modeling from content
TMLTextSpecification ts = new TMLTextSpecification(tmlfile.getName());
boolean b = ts.makeTMLModeling(content);
if (!b) {
TraceManager.addDev("Error in loaded spec");
return;
}
try {
drawTMLSpecification(ts.getTMLModeling(), tmlfile.getName());
} catch (MalformedTMLDesignException e) {
TraceManager.addDev("Error in drawing spec: " + e.getMessage());
status.setText("ERROR: " + e.getMessage());
}
} else {
// TMAP file
TraceManager.addDev("Handling TMAP file: " + tmlfile.getName());
TMLMappingTextSpecification ts = new TMLMappingTextSpecification(tmlfile.getName());
boolean b = ts.makeTMLMapping(content, tmlfile.getParent() + File.separator);
if (!b) {
TraceManager.addDev("Error in loaded spec");
return;
}
TraceManager.addDev("Now drawing TML spec");
TMLMapping tmap = ts.getTMLMapping();
try {
drawTMLSpecification(tmap.getTMLModeling(), tmlfile.getName());
} catch (MalformedTMLDesignException e) {
TraceManager.addDev("Error in drawing spec: " + e.getMessage());
status.setText("ERROR: " + e.getMessage());
}
try {
drawTMLSpecification(ts.getTMLModeling(), tmlfile.getName());
} catch (MalformedTMLDesignException e) {
TraceManager.addDev("Error in drawing spec: " + e.getMessage());
status.setText("ERROR: " + e.getMessage());
}
}
......@@ -5424,7 +5455,6 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per
return null;
}
return ts;
}
......
......@@ -54,11 +54,7 @@ import java.io.File;
*/
public class TMLFilter extends FileFilter {
//Accept all directories and xml files
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String extension = FileUtils.getExtension(f);
if (extension != null) {
......@@ -69,7 +65,7 @@ public class TMLFilter extends FileFilter {
}
public String getDescription() {
return "TML / TMAP";
return "TML";
}
public static String getExtension() {
......
......@@ -36,8 +36,8 @@ public class FpgaClockDividerTest extends AbstractTest {
private String SIM_DIR;
private final int [] NB_OF_FCD_STATES = {21};
private final int [] NB_OF_FCD_TRANSTIONS = {20};
private final int [] MIN_FCD_CYCLES = {230};
private final int [] MAX_FCD_CYCLES = {230};
private final int [] MIN_FCD_CYCLES = {128};
private final int [] MAX_FCD_CYCLES = {128};
private static String CPP_DIR = "../../../../simulators/c++2/";
private static String mappingName = "ArchitectureSimple";
......@@ -203,11 +203,11 @@ public class FpgaClockDividerTest extends AbstractTest {
// Min and max cycles
int minValue = graph.getMinValue("allCPUsFPGAsTerminated");
System.out.println("executing: minvalue of " + s + " " + minValue);
System.out.println("executing: minvalue of " + s + " " + minValue + " expecting: " + MIN_FCD_CYCLES[i]);
assertTrue(MIN_FCD_CYCLES[i] == minValue);
int maxValue = graph.getMaxValue("allCPUsFPGAsTerminated");
System.out.println("executing: maxvalue of " + s + " " + maxValue);
System.out.println("executing: maxvalue of " + s + " " + maxValue + " expecting:" + MAX_FCD_CYCLES[i]);
assertTrue(MAX_FCD_CYCLES[i] == maxValue);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment