use of de.neemann.digital.builder.Gal16v8.CuplExporter in project Digital by hneemann.
the class TableDialog method createCreateMenu.
private JMenu createCreateMenu() {
JMenu createMenu = new JMenu(Lang.get("menu_table_create"));
createMenu.add(new ToolTipAction(Lang.get("menu_table_createCircuit")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(ExpressionModifier.IDENTITY);
}
}.setToolTip(Lang.get("menu_table_createCircuit_tt")).setAccelerator("F2").enableAcceleratorIn(table).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createCircuitJK")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(true, ExpressionModifier.IDENTITY);
}
}.setToolTip(Lang.get("menu_table_createCircuitJK_tt")).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createTwo")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new TwoInputs());
}
}.setToolTip(Lang.get("menu_table_createTwo_tt")).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createNAnd")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new NAnd());
}
}.setToolTip(Lang.get("menu_table_createNAnd_tt")).createJMenuItem());
if (Main.isExperimentalMode()) {
createMenu.add(new ToolTipAction(Lang.get("menu_table_createNAndTwo")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new TwoInputs(), new NAnd());
}
}.setToolTip(Lang.get("menu_table_createNAndTwo_tt")).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createNOr")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new NOr());
}
}.setToolTip(Lang.get("menu_table_createNOr_tt")).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createNOrTwo")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new TwoInputs(), new NOr());
}
}.setToolTip(Lang.get("menu_table_createNOrTwo_tt")).createJMenuItem());
}
JMenu hardware = new JMenu(Lang.get("menu_table_create_hardware"));
register(hardware, new GenerateCUPL(CuplExporter::new, "GAL16v8/CUPL"));
register(hardware, new GenerateFile("jed", () -> new ExpressionToFileExporter(new Gal16v8JEDECExporter()), "GAL16v8/JEDEC", Lang.get("menu_table_create_jedec_tt")));
register(hardware, new GenerateCUPL(Gal22v10CuplExporter::new, "GAL22v10/CUPL"));
register(hardware, new GenerateFile("jed", () -> new ExpressionToFileExporter(new Gal22v10JEDECExporter()), "GAL22v10/JEDEC", Lang.get("menu_table_create_jedec_tt")));
for (ATFDevice atfDev : ATFDevice.values()) {
register(hardware, new GenerateCUPL(atfDev::getCuplExporter, "ATF150x/" + atfDev.getMenuName() + "/CUPL"));
register(hardware, new GenerateFile("tt2", () -> atfDev.createExpressionToFileExporter(TableDialog.this, getProjectName()), "ATF150x/" + atfDev.getMenuName() + "/TT2, JEDEC", Lang.get("menu_table_createTT2_tt")));
}
createMenu.add(hardware);
return createMenu;
}
use of de.neemann.digital.builder.Gal16v8.CuplExporter in project Digital by hneemann.
the class GenerateCUPL method generate.
@Override
public void generate(JDialog parent, File circuitFile, TruthTable table, ExpressionListenerStore expressions) throws Exception {
File cuplPath;
if (circuitFile == null) {
JFileChooser fc = new MyFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setDialogTitle(Lang.get("msg_selectAnEmptyFolder"));
if (fc.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) {
cuplPath = fc.getSelectedFile();
circuitFile = cuplPath;
} else {
return;
}
} else {
if (circuitFile.isDirectory()) {
cuplPath = circuitFile;
} else {
String name = circuitFile.getName();
if (name.length() > 3 && name.charAt(name.length() - 4) == '.')
name = name.substring(0, name.length() - 4);
cuplPath = new File(circuitFile.getParentFile(), "CUPL_" + name);
}
}
if (!cuplPath.mkdirs())
if (!cuplPath.exists())
throw new IOException(Lang.get("err_couldNotCreateFolder_N0", cuplPath.getPath()));
File f = new File(cuplPath, "CUPL.PLD");
CuplExporter cuplExporter = cuplExporterFactory.create();
cuplExporter.setProjectName(circuitFile.getName());
final ModelAnalyserInfo modelAnalyzerInfo = table.getModelAnalyzerInfo();
if (modelAnalyzerInfo != null)
cuplExporter.getPinMapping().addAll(modelAnalyzerInfo.getPins());
new BuilderExpressionCreator(cuplExporter.getBuilder(), ExpressionModifier.IDENTITY).create(expressions);
try (FileOutputStream out = new FileOutputStream(f)) {
cuplExporter.writeTo(out);
}
}
Aggregations