set up run for tech map to synthesis view
This commit is contained in:
parent
5458c21eb7
commit
ced01407d3
3 changed files with 88 additions and 91 deletions
|
|
@ -22,7 +22,7 @@ public class Executables {
|
|||
public static String reb2sacExecutable = "reb2sac";
|
||||
public static String[] envp = null;
|
||||
public static String geneNetExecutable = "GeneNet";
|
||||
public static String yosysExecutable = "yosys";
|
||||
public static String yosysExecutable = "Yosys";
|
||||
|
||||
public static Boolean libsbmlFound = false;
|
||||
public static Boolean reb2sacFound = false;
|
||||
|
|
|
|||
|
|
@ -219,6 +219,8 @@ import edu.utah.ece.async.ibiosim.gui.util.preferences.EditPreferences;
|
|||
import edu.utah.ece.async.ibiosim.gui.util.preferences.PreferencesDialog;
|
||||
import edu.utah.ece.async.ibiosim.gui.util.tabs.CloseAndMaxTabbedPane;
|
||||
import edu.utah.ece.async.ibiosim.gui.verificationView.VerificationView;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.SBOLNetList;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.TechMapSolution;
|
||||
import edu.utah.ece.async.lema.verification.lpn.LPN;
|
||||
import edu.utah.ece.async.lema.verification.lpn.Translator;
|
||||
import edu.utah.ece.async.lema.verification.platu.platuLpn.io.PlatuGrammarLexer;
|
||||
|
|
@ -342,7 +344,6 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
|
|||
protected SEDMLDocument sedmlDocument = null;
|
||||
|
||||
protected SBOLDocument sbolDocument = null;
|
||||
private Map<String, String> mapFile2TreeId;
|
||||
|
||||
/**
|
||||
* This is the constructor for the Proj class. It initializes all the input
|
||||
|
|
@ -357,7 +358,6 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
|
|||
* @throws Exception
|
||||
*/
|
||||
public Gui() {
|
||||
mapFile2TreeId = new HashMap<>();
|
||||
}
|
||||
|
||||
public void openGui() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||
|
|
@ -7504,28 +7504,19 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
|
|||
actionPerformed(projectSynthesized);
|
||||
if (!synthView.getRootDirectory().equals(root))
|
||||
{
|
||||
List<String> solutionFileIDs = synthView.run(root);
|
||||
List<String> techmap_sols = synthView.run(root);
|
||||
|
||||
if(solutionFileIDs == null) {
|
||||
if(techmap_sols == null) {
|
||||
JOptionPane.showMessageDialog(frame, "Unable to execute synthesis.", "Synthesis Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (solutionFileIDs.size() > 0) {
|
||||
for (String solutionFileID : solutionFileIDs) {
|
||||
addToTree(solutionFileID);
|
||||
}
|
||||
ModelEditor modelEditor;
|
||||
try {
|
||||
modelEditor = new ModelEditor(root + File.separator, solutionFileIDs.get(0), this, log,
|
||||
false, null, null, null, false, false, false);
|
||||
modelEditor.addObserver(this);
|
||||
ActionEvent applyLayout = new ActionEvent(synthView, ActionEvent.ACTION_PERFORMED,
|
||||
"layout_verticalHierarchical");
|
||||
modelEditor.getSchematic().actionPerformed(applyLayout);
|
||||
addTab(solutionFileIDs.get(0), modelEditor, "Model Editor");
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
else if(techmap_sols.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(frame, "No solution was found after perfirming Verilog Synthesis.", "Synthesis Solution Not Found", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
for(String solFilePath : techmap_sols) {
|
||||
importSBOLFile(solFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7554,7 +7545,6 @@ public class Gui implements BioObserver, MouseListener, ActionListener, MouseMot
|
|||
addTab(synthID, synthView, null);
|
||||
addToTree(synthID);
|
||||
}
|
||||
mapFile2TreeId.put(verilogPath, synthID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ import javax.xml.stream.XMLStreamException;
|
|||
|
||||
import org.sbml.jsbml.text.parser.ParseException;
|
||||
import org.sbolstandard.core2.SBOLConversionException;
|
||||
import org.sbolstandard.core2.SBOLDocument;
|
||||
import org.sbolstandard.core2.SBOLValidationException;
|
||||
import org.sbolstandard.core2.SBOLWriter;
|
||||
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
|
||||
import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.BioSimException;
|
||||
|
|
@ -61,6 +63,7 @@ import edu.utah.ece.async.ibiosim.synthesis.GeneticGates.GeneticGatesException;
|
|||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.Cover;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.Match;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.PreSelectedMatch;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.SBOLNetList;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.SBOLTechMapException;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.SBOLTechMapOptions;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.SBOLTechMapping.TechMapSolution;
|
||||
|
|
@ -69,6 +72,8 @@ import edu.utah.ece.async.ibiosim.synthesis.VerilogCompiler.CompilerOptions;
|
|||
import edu.utah.ece.async.ibiosim.synthesis.VerilogCompiler.VerilogCompilerException;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.VerilogCompiler.VerilogParser;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.VerilogCompiler.VerilogToLPNCompiler;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.VerilogCompiler.VerilogToSBOL;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.VerilogCompiler.WrappedSBOL;
|
||||
import edu.utah.ece.async.ibiosim.synthesis.VerilogCompiler.VerilogConstructs.VerilogModule;
|
||||
import edu.utah.ece.async.lema.verification.lpn.LPN;
|
||||
|
||||
|
|
@ -118,7 +123,7 @@ public class VerilogSynthesisView extends JTabbedPane implements ActionListener,
|
|||
this.verilogSpecPath = verilogSpecPath;
|
||||
this.synthDirPath = rootFilePath + File.separator + synthID;
|
||||
new File(synthDirPath).mkdir(); // Create the synthesis directory
|
||||
|
||||
|
||||
JPanel optionsPanel = createVerilogSynthPanel();
|
||||
addTab("Verilog Synthesis Options", optionsPanel);
|
||||
getComponentAt(getComponents().length - 1).setName("Verilog Synthesis Options");
|
||||
|
|
@ -457,20 +462,26 @@ public class VerilogSynthesisView extends JTabbedPane implements ActionListener,
|
|||
|
||||
public List<String> run(String synthFilePath)
|
||||
{
|
||||
List<String> techmapSolPath = new ArrayList<>();
|
||||
Synthesis synthesizer = new Synthesis();
|
||||
VerilogParser verilogParser = new VerilogParser();
|
||||
CompilerOptions compilerOptions = new CompilerOptions();
|
||||
try {
|
||||
File specFile = compilerOptions.addVerilogFile(synthProps.getProperty(GlobalConstants.SBOL_SYNTH_SPEC_PATH_PROPERTY));
|
||||
File testEnvFile = compilerOptions.addVerilogFile(synthProps.getProperty(GlobalConstants.SBOL_SYNTH_TESTBENCH_PROPERTY));
|
||||
VerilogModule specVerilogModule = verilogParser.parseVerilogFile(specFile);
|
||||
VerilogModule testEnvVerilogModule = verilogParser.parseVerilogFile(testEnvFile);
|
||||
VerilogModule testEnvVerilogModule = null;
|
||||
if(synthProps.containsKey(GlobalConstants.SBOL_SYNTH_TESTBENCH_PROPERTY)) {
|
||||
File testEnvFile = compilerOptions.addVerilogFile(synthProps.getProperty(GlobalConstants.SBOL_SYNTH_TESTBENCH_PROPERTY));
|
||||
testEnvVerilogModule = verilogParser.parseVerilogFile(testEnvFile);
|
||||
compilerOptions.setTestbenchModuleId(testEnvVerilogModule.getModuleId());
|
||||
|
||||
}
|
||||
compilerOptions.setImplementationModuleId(specVerilogModule.getModuleId());
|
||||
compilerOptions.setTestbenchModuleId(testEnvVerilogModule.getModuleId());
|
||||
compilerOptions.setOutputDirectory(synthDirPath);
|
||||
String outputFileName = synthID.endsWith(".v")? synthID.replace(".v", "") : synthID;
|
||||
compilerOptions.setOutputFileName(outputFileName);
|
||||
|
||||
|
||||
String yosysInputPath = specFile.getAbsolutePath();
|
||||
if(runAtacs_button.isSelected()) {
|
||||
VerilogToLPNCompiler sbmlLPNConverter = new VerilogToLPNCompiler();
|
||||
sbmlLPNConverter.addVerilog(specVerilogModule);
|
||||
|
|
@ -485,20 +496,61 @@ public class VerilogSynthesisView extends JTabbedPane implements ActionListener,
|
|||
else if(atacsAlgBox.getSelectedItem().toString().equals(GlobalConstants.SBOL_SYNTH_ATACS_GC_GATES)){
|
||||
synthesizer.runGeneralizedCGateSynthesis(lpnPath, compilerOptions.getOutputDirectory());
|
||||
}
|
||||
yosysInputPath = compilerOptions.getOutputDirectory() + File.separator + compilerOptions.getOutputFileName() + "_synthesized.v";
|
||||
}
|
||||
|
||||
|
||||
|
||||
YosysScriptGenerator yosysScript = new YosysScriptGenerator(compilerOptions.getOutputDirectory(), compilerOptions.getOutputFileName() + "_decomposed");
|
||||
yosysScript.read_verilog(compilerOptions.getOutputDirectory() + File.separator + compilerOptions.getOutputFileName() + "_synthesized.v");
|
||||
|
||||
yosysScript.read_verilog(yosysInputPath);
|
||||
|
||||
if(yosysNandDecomp_button.isSelected()) {
|
||||
yosysScript.setAbc_cmd("g", "NAND");
|
||||
}
|
||||
else if(yosysNorDecomp_button.isSelected()) {
|
||||
yosysScript.setAbc_cmd("g", "NOR");
|
||||
}
|
||||
|
||||
|
||||
synthesizer.runSynthesis(compilerOptions.getOutputDirectory(), new String[] {"yosys", "-p", yosysScript.generateScript()});
|
||||
|
||||
File decomposedFile = compilerOptions.addVerilogFile(compilerOptions.getOutputDirectory() + File.separator + compilerOptions.getOutputFileName() + "_decomposed.v");
|
||||
VerilogModule decompVerilog = verilogParser.parseVerilogFile(decomposedFile);
|
||||
VerilogToSBOL sbolConverter = new VerilogToSBOL(true);
|
||||
WrappedSBOL decomposedSbol = sbolConverter.convertVerilog2SBOL(decompVerilog);
|
||||
String decomposedSbolPath = compilerOptions.getOutputDirectory() + File.separator + compilerOptions.getOutputFileName() + "_decomposed.xml";
|
||||
SBOLWriter.write(decomposedSbol.getSBOLDocument(), decomposedSbolPath);
|
||||
|
||||
SBOLTechMapOptions techMapOptions = setVerilogTechMapProperties(decomposedSbolPath);
|
||||
techMapOptions.setOutputDirectory(synthFilePath);
|
||||
techMapOptions.setOutputFileName(outputFileName);
|
||||
|
||||
List<GeneticGate> libGraph = TechMapUtility.createLibraryGraphFromSbolList(techMapOptions.getLibrary());
|
||||
DecomposedGraph specGraph = TechMapUtility.createSpecificationGraphFromSBOL(techMapOptions.getSpefication());
|
||||
|
||||
Match m = new PreSelectedMatch(specGraph, libGraph);
|
||||
Cover c = new Cover(m);
|
||||
List<TechMapSolution> coverSols = new ArrayList<>();
|
||||
|
||||
|
||||
if(techMapOptions.isBranchBound()) {
|
||||
coverSols.add(c.branchAndBoundCover());
|
||||
}
|
||||
else if(techMapOptions.isExhaustive()) {
|
||||
coverSols = c.exhaustiveCover();
|
||||
}
|
||||
else if(techMapOptions.isGreedy()) {
|
||||
coverSols = c.greedyCover(techMapOptions.getNumOfSolutions());
|
||||
}
|
||||
|
||||
int count = 1;
|
||||
for(TechMapSolution sol : coverSols) {
|
||||
if(sol.getScore() != 0.0 && sol.getScore() != Double.POSITIVE_INFINITY) {
|
||||
SBOLNetList sbolSol = new SBOLNetList(specGraph, sol);
|
||||
SBOLDocument result = sbolSol.generateSbol();
|
||||
String solFilePath = techMapOptions.getOutputDir() + File.separator + techMapOptions.getOuputFileName() + "_sol" + count++ + ".xml";
|
||||
SBOLWriter.write(result, solFilePath);
|
||||
techmapSolPath.add(solFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException e1) {
|
||||
JOptionPane.showMessageDialog(Gui.frame,
|
||||
"Unable to locate specification file:" + synthFilePath + ".",
|
||||
|
|
@ -530,74 +582,29 @@ public class VerilogSynthesisView extends JTabbedPane implements ActionListener,
|
|||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
SBOLTechMapOptions techMapOptions = setSequentialTechMapProperties();
|
||||
try {
|
||||
List<GeneticGate> libGraph = TechMapUtility.createLibraryGraphFromSbolList(techMapOptions.getLibrary());
|
||||
DecomposedGraph specGraph = TechMapUtility.createSpecificationGraphFromSBOL(techMapOptions.getSpefication());
|
||||
|
||||
Match m = new PreSelectedMatch(specGraph, libGraph);
|
||||
Cover c = new Cover(m);
|
||||
List<TechMapSolution> coverSols = new ArrayList<>();
|
||||
try {
|
||||
if(techMapOptions.isBranchBound()) {
|
||||
coverSols.add(c.branchAndBoundCover());
|
||||
}
|
||||
else if(techMapOptions.isExhaustive()) {
|
||||
coverSols = c.exhaustiveCover();
|
||||
}
|
||||
else if(techMapOptions.isGreedy()) {
|
||||
coverSols = c.greedyCover(techMapOptions.getNumOfSolutions());
|
||||
}
|
||||
}
|
||||
catch (GeneticGatesException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
catch (SBOLTechMapException e)
|
||||
{
|
||||
} catch (SBOLValidationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (GateGenerationExeception e)
|
||||
{
|
||||
} catch (SBOLConversionException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (SBOLValidationException e)
|
||||
{
|
||||
} catch (SBOLTechMapException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
} catch (GeneticGatesException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (SBOLConversionException e)
|
||||
{
|
||||
} catch (GateGenerationExeception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
return techmapSolPath;
|
||||
}
|
||||
|
||||
private SBOLTechMapOptions setSequentialTechMapProperties() {
|
||||
private SBOLTechMapOptions setVerilogTechMapProperties(String decomposedSbolPath) {
|
||||
SBOLTechMapOptions techMapOptions = new SBOLTechMapOptions();
|
||||
|
||||
// Synthesis synRunner = new Synthesis();
|
||||
// String lpnFile = "";
|
||||
// try {
|
||||
// synRunner.runSynthesis(lpnFile, techMapOptions.getOutputDir());
|
||||
// synRunner.runDecomposition(techMapOptions.getOutputDir(), true);
|
||||
// }
|
||||
// catch (IOException e1) {
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
// catch (InterruptedException e1) {
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
|
||||
//techMapOptions.setSpecificationFile(synthProps.getProperty(GlobalConstants.SBOL_SYNTH_SPEC_PROPERTY));
|
||||
techMapOptions.setSpecificationFile(synthProps.getProperty(GlobalConstants.SBOL_SYNTH_SPEC_PROPERTY) + ".sbol");
|
||||
techMapOptions.setSpecificationFile(decomposedSbolPath);
|
||||
|
||||
for (String libFilePath : libFilePaths) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue