Search in sources :

Example 1 with CuplExporter

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;
}
Also used : Gal16v8JEDECExporter(de.neemann.digital.builder.Gal16v8.Gal16v8JEDECExporter) GenerateFile(de.neemann.digital.gui.components.table.hardware.GenerateFile) ActionEvent(java.awt.event.ActionEvent) NAnd(de.neemann.digital.analyse.expression.modify.NAnd) ATFDevice(de.neemann.digital.builder.ATF150x.ATFDevice) NOr(de.neemann.digital.analyse.expression.modify.NOr) ToolTipAction(de.neemann.gui.ToolTipAction) GenerateCUPL(de.neemann.digital.gui.components.table.hardware.GenerateCUPL) ExpressionToFileExporter(de.neemann.digital.builder.ExpressionToFileExporter) Gal22v10JEDECExporter(de.neemann.digital.builder.Gal22v10.Gal22v10JEDECExporter) TwoInputs(de.neemann.digital.analyse.expression.modify.TwoInputs)

Example 2 with CuplExporter

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);
    }
}
Also used : MyFileChooser(de.neemann.gui.MyFileChooser) ModelAnalyserInfo(de.neemann.digital.analyse.ModelAnalyserInfo) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) BuilderExpressionCreator(de.neemann.digital.gui.components.table.BuilderExpressionCreator) CuplExporter(de.neemann.digital.builder.Gal16v8.CuplExporter)

Aggregations

ModelAnalyserInfo (de.neemann.digital.analyse.ModelAnalyserInfo)1 NAnd (de.neemann.digital.analyse.expression.modify.NAnd)1 NOr (de.neemann.digital.analyse.expression.modify.NOr)1 TwoInputs (de.neemann.digital.analyse.expression.modify.TwoInputs)1 ATFDevice (de.neemann.digital.builder.ATF150x.ATFDevice)1 ExpressionToFileExporter (de.neemann.digital.builder.ExpressionToFileExporter)1 CuplExporter (de.neemann.digital.builder.Gal16v8.CuplExporter)1 Gal16v8JEDECExporter (de.neemann.digital.builder.Gal16v8.Gal16v8JEDECExporter)1 Gal22v10JEDECExporter (de.neemann.digital.builder.Gal22v10.Gal22v10JEDECExporter)1 BuilderExpressionCreator (de.neemann.digital.gui.components.table.BuilderExpressionCreator)1 GenerateCUPL (de.neemann.digital.gui.components.table.hardware.GenerateCUPL)1 GenerateFile (de.neemann.digital.gui.components.table.hardware.GenerateFile)1 MyFileChooser (de.neemann.gui.MyFileChooser)1 ToolTipAction (de.neemann.gui.ToolTipAction)1 ActionEvent (java.awt.event.ActionEvent)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1