mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-19 01:44:44 -04:00
in case of a simulation error the response is now faster
This commit is contained in:
parent
fcb62f897c
commit
ac71699351
@ -9,6 +9,7 @@ import de.neemann.digital.core.extern.PortDefinition;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can use GHDL as VHDL simulator.
|
* Can use GHDL as VHDL simulator.
|
||||||
@ -51,4 +52,14 @@ public class GHDLProcess extends VHDLProcess {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConsoleOutNoWarn(LinkedList<String> consoleOut) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String s : consoleOut) {
|
||||||
|
if (!s.contains("(assertion warning)"))
|
||||||
|
sb.append(s).append("\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import java.util.LinkedList;
|
|||||||
public class StdIOProcess implements ProcessHandler {
|
public class StdIOProcess implements ProcessHandler {
|
||||||
private static final String PREFIX = "Digital:";
|
private static final String PREFIX = "Digital:";
|
||||||
private static final int MAX_CONSOLE_LINES = 30;
|
private static final int MAX_CONSOLE_LINES = 30;
|
||||||
|
private static final long TIMEOUT = 5000;
|
||||||
private Process process;
|
private Process process;
|
||||||
private BufferedWriter writer;
|
private BufferedWriter writer;
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
@ -26,6 +27,7 @@ public class StdIOProcess implements ProcessHandler {
|
|||||||
|
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
private String dataFound;
|
private String dataFound;
|
||||||
|
private boolean terminated = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,6 +62,7 @@ public class StdIOProcess implements ProcessHandler {
|
|||||||
private void setReaderWriter(BufferedReader reader, BufferedWriter writer) {
|
private void setReaderWriter(BufferedReader reader, BufferedWriter writer) {
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
consoleOut = new LinkedList<>();
|
consoleOut = new LinkedList<>();
|
||||||
|
terminated = false;
|
||||||
thread = new Thread(() -> {
|
thread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
String line;
|
String line;
|
||||||
@ -79,6 +82,10 @@ public class StdIOProcess implements ProcessHandler {
|
|||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
synchronized (lock) {
|
||||||
|
terminated = true;
|
||||||
|
lock.notify();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
thread.start();
|
thread.start();
|
||||||
@ -88,10 +95,13 @@ public class StdIOProcess implements ProcessHandler {
|
|||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
try {
|
try {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
while (dataFound == null && (System.currentTimeMillis() - startTime) < 5000)
|
long time = 0;
|
||||||
|
while (dataFound == null && !terminated && (time - startTime) < TIMEOUT) {
|
||||||
lock.wait(1000);
|
lock.wait(1000);
|
||||||
|
time = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
if (dataFound == null)
|
if (!((time - startTime) < TIMEOUT))
|
||||||
throw new IOException(Lang.get("err_timeoutReadingData_O", getConsoleOut()));
|
throw new IOException(Lang.get("err_timeoutReadingData_O", getConsoleOut()));
|
||||||
|
|
||||||
String line = dataFound;
|
String line = dataFound;
|
||||||
@ -168,7 +178,18 @@ public class StdIOProcess implements ProcessHandler {
|
|||||||
v.set(value, highZ);
|
v.set(value, highZ);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
throw new IOException(Lang.get("err_processTerminatedUnexpected_O", getConsoleOut()));
|
throw new IOException(Lang.get("err_processTerminatedUnexpected_O", getConsoleOutNoWarn(consoleOut)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the console out without warnings.
|
||||||
|
* Used to remove not needed content which obfuscates the real error cause.
|
||||||
|
*
|
||||||
|
* @param consoleOut the console out
|
||||||
|
* @return the clean error message
|
||||||
|
*/
|
||||||
|
public String getConsoleOutNoWarn(LinkedList<String> consoleOut) {
|
||||||
|
return getConsoleOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getConsoleOut() {
|
private String getConsoleOut() {
|
||||||
|
12
src/test/resources/dig/external/ghdl.dig
vendored
12
src/test/resources/dig/external/ghdl.dig
vendored
@ -44,7 +44,7 @@ end add;
|
|||||||
architecture add_arch of add is
|
architecture add_arch of add is
|
||||||
signal temp : std_logic_vector(4 downto 0);
|
signal temp : std_logic_vector(4 downto 0);
|
||||||
begin
|
begin
|
||||||
temp <= ('0' & a) + ('0' & b) + ('0' & c_i);
|
temp <= ('0' & a) + b + c_i;
|
||||||
|
|
||||||
s <= temp(3 downto 0);
|
s <= temp(3 downto 0);
|
||||||
c_o <= temp(4);
|
c_o <= temp(4);
|
||||||
@ -69,7 +69,7 @@ end add_arch;</string>
|
|||||||
<value v="3" z="false"/>
|
<value v="3" z="false"/>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="240" y="120"/>
|
<pos x="240" y="100"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>In</elementName>
|
<elementName>In</elementName>
|
||||||
@ -144,7 +144,7 @@ end loop
|
|||||||
</testData>
|
</testData>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="260" y="240"/>
|
<pos x="300" y="40"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
</visualElements>
|
</visualElements>
|
||||||
<wires>
|
<wires>
|
||||||
@ -165,8 +165,8 @@ end loop
|
|||||||
<p2 x="380" y="180"/>
|
<p2 x="380" y="180"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="240" y="120"/>
|
<p1 x="240" y="100"/>
|
||||||
<p2 x="260" y="120"/>
|
<p2 x="260" y="100"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="240" y="200"/>
|
<p1 x="240" y="200"/>
|
||||||
@ -181,7 +181,7 @@ end loop
|
|||||||
<p2 x="280" y="140"/>
|
<p2 x="280" y="140"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="260" y="120"/>
|
<p1 x="260" y="100"/>
|
||||||
<p2 x="260" y="140"/>
|
<p2 x="260" y="140"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user