in case of a simulation error the response is now faster

This commit is contained in:
hneemann 2018-03-08 17:31:54 +01:00
parent fcb62f897c
commit ac71699351
3 changed files with 41 additions and 9 deletions

View File

@ -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();
}
} }

View File

@ -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() {

View File

@ -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 &lt;= (&apos;0&apos; &amp; a) + (&apos;0&apos; &amp; b) + (&apos;0&apos; &amp; c_i); temp &lt;= (&apos;0&apos; &amp; a) + b + c_i;
s &lt;= temp(3 downto 0); s &lt;= temp(3 downto 0);
c_o &lt;= temp(4); c_o &lt;= 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>