first ide config for basic BASYS3 support.

This commit is contained in:
hneemann 2019-05-15 18:36:00 +02:00
parent 6c2bec3b69
commit 63a3412191
12 changed files with 224 additions and 27 deletions

View File

@ -1,15 +1,16 @@
<ide name="BASYS 3">
<commands>
<command name="Export to Vivado" requires="vhdl" filter="false">
<command name="Export to Vivado" requires="vhdl" filter="true" gui="true" timeout="0">
<arg>vivado</arg>
<arg>vivado/&lt;?=shortname?&gt;.xpr</arg>
</command>
</commands>
<files>
<file name="&lt;?=shortname?&gt;_constraints.xdc" overwrite="true" filter="true">
<content><![CDATA[<?
port := 0;
for (i:=0; i<sizeOf(hdl.ports);i++) {
port=hdl.ports[i];
port:=hdl.ports[i];
if (port.bits=1) {
print("set_property PACKAGE_PIN "+port.pin+" [get_ports "+port.name+"]\n");
print("set_property IOSTANDARD LVCMOS33 [get_ports "+port.name+"]\n\n");
@ -25,7 +26,7 @@ print("set_property CONFIG_VOLTAGE 3.3 [current_design]\n");
?>]]></content>
</file>
<file name="vivado/&lt;?=shortname?&gt;.xpr" overwrite="true" filter="true">
<file name="vivado/&lt;?=shortname?&gt;.xpr" overwrite="false" filter="true">
<content><![CDATA[<?print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");?>
<!-- Created by Digital -->

View File

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<circuit>
<version>1</version>
<attributes/>
<visualElements>
<visualElement>
<elementName>Counter</elementName>
<elementAttributes>
<entry>
<string>Bits</string>
<int>26</int>
</entry>
</elementAttributes>
<pos x="220" y="140"/>
</visualElement>
<visualElement>
<elementName>VDD</elementName>
<elementAttributes/>
<pos x="200" y="120"/>
</visualElement>
<visualElement>
<elementName>Ground</elementName>
<elementAttributes/>
<pos x="200" y="200"/>
</visualElement>
<visualElement>
<elementName>Clock</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>CLK</string>
</entry>
<entry>
<string>Frequency</string>
<int>2147483647</int>
</entry>
<entry>
<string>runRealTime</string>
<boolean>true</boolean>
</entry>
</elementAttributes>
<pos x="180" y="160"/>
</visualElement>
<visualElement>
<elementName>Splitter</elementName>
<elementAttributes>
<entry>
<string>Input Splitting</string>
<string>26</string>
</entry>
<entry>
<string>Output Splitting</string>
<string>21-25</string>
</entry>
</elementAttributes>
<pos x="320" y="140"/>
</visualElement>
<visualElement>
<elementName>ROM</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>SOS</string>
</entry>
<entry>
<string>AddrBits</string>
<int>5</int>
</entry>
<entry>
<string>Data</string>
<data>0,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,1</data>
</entry>
</elementAttributes>
<pos x="380" y="140"/>
</visualElement>
<visualElement>
<elementName>VDD</elementName>
<elementAttributes/>
<pos x="360" y="160"/>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>LED</string>
</entry>
</elementAttributes>
<pos x="480" y="160"/>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>USBPU</string>
</entry>
</elementAttributes>
<pos x="480" y="200"/>
</visualElement>
<visualElement>
<elementName>Ground</elementName>
<elementAttributes/>
<pos x="460" y="220"/>
</visualElement>
</visualElements>
<wires>
<wire>
<p1 x="180" y="160"/>
<p2 x="220" y="160"/>
</wire>
<wire>
<p1 x="440" y="160"/>
<p2 x="480" y="160"/>
</wire>
<wire>
<p1 x="200" y="180"/>
<p2 x="220" y="180"/>
</wire>
<wire>
<p1 x="360" y="180"/>
<p2 x="380" y="180"/>
</wire>
<wire>
<p1 x="460" y="200"/>
<p2 x="480" y="200"/>
</wire>
<wire>
<p1 x="280" y="140"/>
<p2 x="320" y="140"/>
</wire>
<wire>
<p1 x="340" y="140"/>
<p2 x="380" y="140"/>
</wire>
<wire>
<p1 x="200" y="140"/>
<p2 x="220" y="140"/>
</wire>
<wire>
<p1 x="200" y="120"/>
<p2 x="200" y="140"/>
</wire>
<wire>
<p1 x="200" y="180"/>
<p2 x="200" y="200"/>
</wire>
<wire>
<p1 x="360" y="160"/>
<p2 x="360" y="180"/>
</wire>
<wire>
<p1 x="460" y="200"/>
<p2 x="460" y="220"/>
</wire>
</wires>
</circuit>

View File

@ -73,6 +73,8 @@ public class OSExecute {
* @return this for chained calls
*/
public OSExecute setTimeOutSec(int timeOutSec) {
if (timeOutSec == 0)
timeOutSec = Integer.MAX_VALUE;
this.timeOutSec = timeOutSec;
return this;
}
@ -195,9 +197,11 @@ public class OSExecute {
public void run() {
try {
String result = os.startAndWait();
callback.processTerminated(result);
if (callback != null)
callback.processTerminated(result);
} catch (Exception e) {
callback.exception(e);
if (callback != null)
callback.exception(e);
}
}
}

View File

@ -134,8 +134,6 @@ public class Context {
* @throws HGSEvalException HGSEvalException
*/
public Context declareVar(String name, Object value) throws HGSEvalException {
if (map.containsKey(name))
throw new HGSEvalException("Variable '" + name + "' already declared!");
map.put(name, value);
return this;
}

View File

@ -32,9 +32,6 @@ public class ReferenceToArray implements Reference {
final HGSArray array = Value.toArray(parent.get(context));
if (i < 0 || i > array.hgsArraySize())
throw new HGSEvalException("Index out of bounds: " + i);
if (i < array.hgsArraySize())
throw new HGSEvalException("Array field redeclared: " + i);
array.hgsArrayAdd(initial);
}

View File

@ -31,9 +31,6 @@ public class ReferenceToStruct implements Reference {
@Override
public void declareVar(Context context, Object initial) throws HGSEvalException {
final HGSMap hgsMap = Value.toMap(parent.get(context));
if (hgsMap.hgsMapGet(name) != null)
throw new HGSEvalException("Value '" + name + "' redeclared in struct!");
hgsMap.hgsMapPut(name, initial);
}

View File

@ -11,8 +11,10 @@ package de.neemann.digital.ide;
public class Command {
private final String name;
private final boolean filter;
private final boolean gui;
private final String requires;
private final String[] args;
private final int timeout;
/**
* Creates a new command
@ -20,13 +22,17 @@ public class Command {
* @param name the name of the command
* @param requires the hdl which is required, either "verilog" of "vhdl"
* @param filter the true, the commands args are filtered
* @param gui if true the appp has a gui
* @param timeout the timeout value in sec
* @param args the arguments
*/
public Command(String name, String requires, boolean filter, String... args) {
public Command(String name, String requires, boolean filter, boolean gui, int timeout, String... args) {
this.name = name;
this.requires = requires;
this.timeout = timeout;
this.args = args;
this.filter = filter;
this.gui = gui;
}
/**
@ -63,4 +69,18 @@ public class Command {
public boolean isFilter() {
return filter;
}
/**
* @return true if application has a gui
*/
public boolean isGui() {
return gui;
}
/**
* @return timeout in seconds
*/
public int getTimeout() {
return timeout;
}
}

View File

@ -7,7 +7,7 @@ package de.neemann.digital.ide;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import de.neemann.digital.core.extern.ProcessStarter;
import de.neemann.digital.builder.tt2.OSExecute;
import de.neemann.digital.draw.elements.Circuit;
import de.neemann.digital.draw.library.ElementLibrary;
import de.neemann.digital.gui.SaveAsHelper;
@ -20,6 +20,8 @@ import de.neemann.digital.hdl.verilog2.VerilogGenerator;
import de.neemann.digital.hdl.vhdl2.VHDLGenerator;
import de.neemann.digital.lang.Lang;
import de.neemann.gui.ErrorMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import java.awt.event.ActionEvent;
@ -30,6 +32,7 @@ import java.util.ArrayList;
* Used to create the IDE integration
*/
public final class Configuration {
private static final Logger LOGGER = LoggerFactory.getLogger(Configuration.class);
/**
* Loads a configuration
@ -66,6 +69,8 @@ public final class Configuration {
xStream.aliasAttribute(Command.class, "name", "name");
xStream.aliasAttribute(Command.class, "requires", "requires");
xStream.aliasAttribute(Command.class, "filter", "filter");
xStream.aliasAttribute(Command.class, "gui", "gui");
xStream.aliasAttribute(Command.class, "timeout", "timeout");
xStream.addImplicitCollection(Command.class, "args", "arg", String.class);
xStream.alias("file", FileToCreate.class);
xStream.aliasAttribute(FileToCreate.class, "name", "name");
@ -236,7 +241,7 @@ public final class Configuration {
}
}
if (args != null)
getIoInterface().startProcess(digFile.getParentFile(), args);
getIoInterface().startProcess(command, digFile.getParentFile(), command.isGui(), args);
} catch (Exception e) {
getIoInterface().showError(command, e);
}
@ -308,11 +313,13 @@ public final class Configuration {
/**
* Starts a process
*
* @param dir the folder to start the process in
* @param args the arguments
* @param command the command started
* @param dir the folder to start the process in
* @param gui true if app has a gui
* @param args the arguments
* @throws IOException IOException
*/
void startProcess(File dir, String[] args) throws IOException;
void startProcess(Command command, File dir, boolean gui, String[] args) throws IOException;
/**
* Shows an error message
@ -330,14 +337,30 @@ public final class Configuration {
final File parentFile = filename.getParentFile();
if (!parentFile.exists()) {
if (!parentFile.mkdirs())
throw new IOException("could not create "+parentFile);
throw new IOException("could not create " + parentFile);
}
return new FileOutputStream(filename);
}
@Override
public void startProcess(File dir, String[] args) throws IOException {
ProcessStarter.start(dir, args);
public void startProcess(Command command, File dir, boolean gui, String[] args) throws IOException {
OSExecute os = new OSExecute(args)
.setTimeOutSec(command.getTimeout())
.setWorkingDir(dir);
if (gui)
os.startInThread(new OSExecute.ProcessCallback() {
@Override
public void processTerminated(String consoleOut) {
LOGGER.info("process '" + command.getName() + "' says:\n" + consoleOut);
}
@Override
public void exception(Exception e) {
showError(command, e);
}
});
else
os.startAndWait();
}
@Override

View File

@ -75,7 +75,7 @@ public class VerilogSimulatorTest extends TestCase {
File examples = new File(Resources.getRoot(), "../../main/dig/hdl");
try {
int tested = new FileScanner(this::checkVerilogExport).noOutput().scan(examples);
assertEquals(1, tested);
assertEquals(2, tested);
assertEquals(1, testBenches);
} catch (FileScanner.SkipAllException e) {
// if iverilog is not installed its also ok

View File

@ -68,7 +68,7 @@ public class VHDLSimulatorTest extends TestCase {
File examples = new File(Resources.getRoot(), "../../main/dig/hdl");
try {
int tested = new FileScanner(this::checkVHDLExport).noOutput().scan(examples);
assertEquals(1, tested);
assertEquals(2, tested);
assertEquals(1, testBenches);
} catch (FileScanner.SkipAllException e) {
// if ghdl is not installed its also ok

View File

@ -117,7 +117,7 @@ public class ConfigurationTest extends TestCase {
}
@Override
public void startProcess(File dir, String[] args) {
public void startProcess(Command command, File dir, boolean gui, String[] args) {
commands.add(new StartedCommand(dir, args));
}

View File

@ -32,7 +32,7 @@ public class TestExamples extends TestCase {
*/
public void testDistExamples() throws Exception {
File examples = new File(Resources.getRoot().getParentFile().getParentFile(), "/main/dig");
assertEquals(252, new FileScanner(this::check).scan(examples));
assertEquals(253, new FileScanner(this::check).scan(examples));
assertEquals(171, testCasesInFiles);
}