From 914f678b8c8264ee1e8afb75ebc4fb8abd37be8d Mon Sep 17 00:00:00 2001 From: hneemann Date: Wed, 15 May 2019 21:12:30 +0200 Subject: [PATCH] some cleanup --- src/main/dig/hdl/BASYS3_Config.xml | 5 ++- .../de/neemann/digital/ide/Configuration.java | 39 ++++++++++++++----- src/main/resources/lang/lang_de.xml | 4 +- src/main/resources/lang/lang_en.xml | 4 +- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/main/dig/hdl/BASYS3_Config.xml b/src/main/dig/hdl/BASYS3_Config.xml index e1b5ae737..754eed663 100644 --- a/src/main/dig/hdl/BASYS3_Config.xml +++ b/src/main/dig/hdl/BASYS3_Config.xml @@ -1,6 +1,7 @@ - + - + + vivado vivado/<?=shortname?>.xpr diff --git a/src/main/java/de/neemann/digital/ide/Configuration.java b/src/main/java/de/neemann/digital/ide/Configuration.java index 24a9e70b3..aff896507 100644 --- a/src/main/java/de/neemann/digital/ide/Configuration.java +++ b/src/main/java/de/neemann/digital/ide/Configuration.java @@ -8,7 +8,10 @@ package de.neemann.digital.ide; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.StaxDriver; import de.neemann.digital.builder.tt2.OSExecute; +import de.neemann.digital.core.element.Keys; +import de.neemann.digital.core.wiring.Clock; import de.neemann.digital.draw.elements.Circuit; +import de.neemann.digital.draw.elements.VisualElement; import de.neemann.digital.draw.library.ElementLibrary; import de.neemann.digital.gui.SaveAsHelper; import de.neemann.digital.hdl.hgs.*; @@ -27,6 +30,7 @@ import javax.swing.*; import java.awt.event.ActionEvent; import java.io.*; import java.util.ArrayList; +import java.util.List; /** * Used to create the IDE integration @@ -65,6 +69,7 @@ public final class Configuration { final XStream xStream = new XStream(new StaxDriver()); xStream.alias("ide", Configuration.class); xStream.aliasAttribute(Configuration.class, "name", "name"); + xStream.aliasAttribute(Configuration.class, "clock", "clock"); xStream.alias("command", Command.class); xStream.aliasAttribute(Command.class, "name", "name"); xStream.aliasAttribute(Command.class, "requires", "requires"); @@ -80,6 +85,7 @@ public final class Configuration { } private String name; + private int clock; private ArrayList commands; private ArrayList files; private transient FilenameProvider filenameProvider; @@ -231,17 +237,18 @@ public final class Configuration { checkFilesToCreate(digFile, hdlModel); String[] args = command.getArgs(); - if (command.isFilter()) { - final int argCount = command.getArgs().length; - Context context = createContext(digFile, hdlModel); - for (int i = 0; i < argCount; i++) { - context.clearOutput(); - new Parser(args[i]).parse().execute(context); - args[i] = context.toString(); + if (args != null) { + if (command.isFilter()) { + final int argCount = command.getArgs().length; + Context context = createContext(digFile, hdlModel); + for (int i = 0; i < argCount; i++) { + context.clearOutput(); + new Parser(args[i]).parse().execute(context); + args[i] = context.toString(); + } } - } - if (args != null) getIoInterface().startProcess(command, digFile.getParentFile(), command.isGui(), args); + } } catch (Exception e) { getIoInterface().showError(command, e); } @@ -266,6 +273,16 @@ public final class Configuration { return commands; } + private int getFrequency() throws HGSEvalException { + List l = circuitProvider.getCurrentCircuit().findElements(v -> v.equalsDescription(Clock.DESCRIPTION)); + if (l.isEmpty()) + throw new HGSEvalException("No clock component found!"); + if (l.size() > 1) + throw new HGSEvalException("More than one clock components found!"); + + return l.get(0).getElementAttributes().get(Keys.FREQUENCY); + } + /** * Interface used to provide a file. */ @@ -369,7 +386,7 @@ public final class Configuration { } } - private static final class ModelAccess implements HGSMap { + private final class ModelAccess implements HGSMap { private final HDLCircuit hdlCircuit; private ModelAccess(HDLCircuit hdlCircuit) { @@ -381,6 +398,8 @@ public final class Configuration { switch (key) { case "ports": return new PortsArray(hdlCircuit.getPorts()); + case "frequency": + return getFrequency(); default: throw new HGSEvalException("field " + key + " not found!"); } diff --git a/src/main/resources/lang/lang_de.xml b/src/main/resources/lang/lang_de.xml index 9b890bd3a..0b98d9f0f 100644 --- a/src/main/resources/lang/lang_de.xml +++ b/src/main/resources/lang/lang_de.xml @@ -1332,8 +1332,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig? Aktiviert Aktiviert oder deaktiviert diese Komponente. - Tool Chain - Kann für eine Integration einer externen Tool Chain verwendet werden. + Toolchain Konfiguration + Kann für eine Integration einer externen Toolchain verwendet werden. Erlaubt den Start externer Tools, um z.B. einen FPGA zu programmieren o.ä. Leitung eingefügt. diff --git a/src/main/resources/lang/lang_en.xml b/src/main/resources/lang/lang_en.xml index f86f09865..042c64636 100644 --- a/src/main/resources/lang/lang_en.xml +++ b/src/main/resources/lang/lang_en.xml @@ -1320,8 +1320,8 @@ Enabled Enables or disables this component. - Tool Chain - Used to configurate an integration of a tool chain. + Toolchain Configuration + Used to configurate an integration of a toolchain. Allows the start of external tools, e.g. to program an FPGA or similar. Inserted wire.