some cleanup

This commit is contained in:
hneemann 2019-05-15 21:12:30 +02:00
parent 63a3412191
commit 914f678b8c
4 changed files with 36 additions and 16 deletions

View File

@ -1,6 +1,7 @@
<ide name="BASYS 3">
<ide name="BASYS3" clock="100000000">
<commands>
<command name="Export to Vivado" requires="vhdl" filter="true" gui="true" timeout="0">
<command name="Export" requires="vhdl" />
<command name="Export &amp; Start Vivado" requires="vhdl" filter="true" gui="true" timeout="0">
<arg>vivado</arg>
<arg>vivado/&lt;?=shortname?&gt;.xpr</arg>
</command>

View File

@ -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<Command> commands;
private ArrayList<FileToCreate> 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<VisualElement> 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!");
}

View File

@ -1332,8 +1332,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="key_enabled">Aktiviert</string>
<string name="key_enabled_tt">Aktiviert oder deaktiviert diese Komponente.</string>
<string name="key_toolChainConfig">Tool Chain</string>
<string name="key_toolChainConfig_tt">Kann für eine Integration einer externen Tool Chain verwendet werden.
<string name="key_toolChainConfig">Toolchain Konfiguration</string>
<string name="key_toolChainConfig_tt">Kann für eine Integration einer externen Toolchain verwendet werden.
Erlaubt den Start externer Tools, um z.B. einen FPGA zu programmieren o.ä.</string>
<string name="mod_insertWire">Leitung eingefügt.</string>

View File

@ -1320,8 +1320,8 @@
<string name="key_enabled">Enabled</string>
<string name="key_enabled_tt">Enables or disables this component.</string>
<string name="key_toolChainConfig">Tool Chain</string>
<string name="key_toolChainConfig_tt">Used to configurate an integration of a tool chain.
<string name="key_toolChainConfig">Toolchain Configuration</string>
<string name="key_toolChainConfig_tt">Used to configurate an integration of a toolchain.
Allows the start of external tools, e.g. to program an FPGA or similar.</string>
<string name="mod_insertWire">Inserted wire.</string>