Fixed a bug in the HDL model const merger

This commit is contained in:
hneemann 2018-04-05 19:49:35 +02:00
parent 63f38e6596
commit 53a4ffec96
3 changed files with 18 additions and 0 deletions

View File

@ -7,6 +7,7 @@ package de.neemann.digital.hdl.model2.optimizations;
import de.neemann.digital.hdl.model2.*; import de.neemann.digital.hdl.model2.*;
import de.neemann.digital.hdl.model2.expression.ExprConstant; import de.neemann.digital.hdl.model2.expression.ExprConstant;
import de.neemann.digital.hdl.model2.expression.ExprVar;
import java.util.ArrayList; import java.util.ArrayList;
@ -54,6 +55,8 @@ public class MergeConstants implements Optimization {
for (HDLPort p : ins.toArray(new HDLPort[ins.size()])) for (HDLPort p : ins.toArray(new HDLPort[ins.size()]))
p.setNet(usedNet); p.setNet(usedNet);
circuit.replaceNetByExpression(obsoleteNet, new ExprVar(usedNet));
circuit.removeNet(obsoleteNet); circuit.removeNet(obsoleteNet);
} }

View File

@ -102,6 +102,9 @@ public class CodePrinter implements Closeable {
* @throws IOException IOException * @throws IOException IOException
*/ */
public CodePrinter print(String str) throws IOException { public CodePrinter print(String str) throws IOException {
if (str == null)
str = "null";
for (int i = 0; i < str.length(); i++) for (int i = 0; i < str.length(); i++)
print(str.charAt(i)); print(str.charAt(i));
return this; return this;

View File

@ -88,6 +88,18 @@ public class VHDLSimulatorTest extends TestCase {
} }
} }
public void testMultiplierInSimulator() throws Exception {
File file = new File(Resources.getRoot(), "../../main/dig/combinatorial/Multiply8Bit.dig");
try {
checkVHDLExport(file);
} catch (FileScanner.SkipAllException e) {
// if ghdl is not installed its also ok
} catch (Exception e) {
System.out.println(ExceptionWithOrigin.getOriginOf(e));
throw e;
}
}
public void testGHDLInSimulator() throws Exception { public void testGHDLInSimulator() throws Exception {
try { try {
ProcessStarter.start(null, GHDL, "--help"); ProcessStarter.start(null, GHDL, "--help");