mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-29 16:01:19 -04:00
added two more backtracking tests
This commit is contained in:
parent
2dd750dd69
commit
c5b686ffa7
@ -4,6 +4,8 @@ import de.neemann.digital.core.*;
|
|||||||
import de.neemann.digital.integration.ToBreakRunner;
|
import de.neemann.digital.integration.ToBreakRunner;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hneemann
|
* @author hneemann
|
||||||
*/
|
*/
|
||||||
@ -22,10 +24,7 @@ public class DependencyAnalyserTest extends TestCase {
|
|||||||
assertEquals("" + i, VAL[i], da.getInputs(m.getOutputs().get(i)).size());
|
assertEquals("" + i, VAL[i], da.getInputs(m.getOutputs().get(i)).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
ExpressionCreator - p0n+1 reduced from 17 to 1 variables ([Count])
|
ExpressionCreator - p0n+1 reduced from 17 to 1 variables ([Count])
|
||||||
ExpressionCreator - p1n+1 reduced from 17 to 1 variables ([p0n])
|
ExpressionCreator - p1n+1 reduced from 17 to 1 variables ([p0n])
|
||||||
ExpressionCreator - Q_1n+1 reduced from 17 to 1 variables ([Q_0n])
|
ExpressionCreator - Q_1n+1 reduced from 17 to 1 variables ([Q_0n])
|
||||||
@ -52,5 +51,28 @@ ExpressionCreator - f0 reduced from 17 to 14 variables ([Q_1n, Q_0n, C0Q_3n, C0Q
|
|||||||
ExpressionCreator - g0 reduced from 17 to 14 variables ([Q_1n, Q_0n, C0Q_3n, C0Q_2n, C0Q_1n, C0Q_0n, C1Q_3n, C1Q_2n, C1Q_1n, C1Q_0n, C2Q_3n, C2Q_2n, C2Q_1n, C2Q_0n])
|
ExpressionCreator - g0 reduced from 17 to 14 variables ([Q_1n, Q_0n, C0Q_3n, C0Q_2n, C0Q_1n, C0Q_0n, C1Q_3n, C1Q_2n, C1Q_1n, C1Q_0n, C2Q_3n, C2Q_2n, C2Q_1n, C2Q_0n])
|
||||||
ExpressionCreator - s1 reduced from 17 to 2 variables ([Q_1n, Q_0n])
|
ExpressionCreator - s1 reduced from 17 to 2 variables ([Q_1n, Q_0n])
|
||||||
ExpressionCreator - s0 reduced from 17 to 2 variables ([Q_1n, Q_0n])
|
ExpressionCreator - s0 reduced from 17 to 2 variables ([Q_1n, Q_0n])
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public void testInputInvert() throws Exception {
|
||||||
|
Model model = new ToBreakRunner("dig/backtrack/InputInvert.dig").getModel();
|
||||||
|
ModelAnalyser m = new ModelAnalyser(model);
|
||||||
|
DependencyAnalyser da = new DependencyAnalyser(m);
|
||||||
|
|
||||||
|
assertEquals(1, m.getOutputs().size());
|
||||||
|
Signal out = m.getOutputs().get(0);
|
||||||
|
|
||||||
|
ArrayList<Signal> inputs = da.getInputs(out);
|
||||||
|
assertEquals(2, inputs.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSplitter() throws Exception {
|
||||||
|
Model model = new ToBreakRunner("dig/backtrack/Splitter.dig").getModel();
|
||||||
|
ModelAnalyser m = new ModelAnalyser(model);
|
||||||
|
DependencyAnalyser da = new DependencyAnalyser(m);
|
||||||
|
assertEquals(2, m.getOutputs().size());
|
||||||
|
assertEquals(1, da.getInputs(m.getOutputs().get(0)).size());
|
||||||
|
assertEquals(1, da.getInputs(m.getOutputs().get(1)).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
64
src/test/resources/dig/backtrack/InputInvert.dig
Normal file
64
src/test/resources/dig/backtrack/InputInvert.dig
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<circuit>
|
||||||
|
<version>1</version>
|
||||||
|
<attributes/>
|
||||||
|
<visualElements>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>And</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>inverterConfig</string>
|
||||||
|
<inverterConfig>
|
||||||
|
<string>In_1</string>
|
||||||
|
<string>In_2</string>
|
||||||
|
</inverterConfig>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="420" y="220"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Out</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>Y</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="500" y="240"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>In</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>A</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="380" y="220"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>In</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>B</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="380" y="260"/>
|
||||||
|
</visualElement>
|
||||||
|
</visualElements>
|
||||||
|
<wires>
|
||||||
|
<wire>
|
||||||
|
<p1 x="480" y="240"/>
|
||||||
|
<p2 x="500" y="240"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="380" y="260"/>
|
||||||
|
<p2 x="400" y="260"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="380" y="220"/>
|
||||||
|
<p2 x="400" y="220"/>
|
||||||
|
</wire>
|
||||||
|
</wires>
|
||||||
|
</circuit>
|
95
src/test/resources/dig/backtrack/Splitter.dig
Normal file
95
src/test/resources/dig/backtrack/Splitter.dig
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<circuit>
|
||||||
|
<version>1</version>
|
||||||
|
<attributes/>
|
||||||
|
<visualElements>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Out</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>Y</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="520" y="220"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>In</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>A</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="380" y="220"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>In</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>B</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="380" y="260"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Splitter</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Input Splitting</string>
|
||||||
|
<string>1,1</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>Output Splitting</string>
|
||||||
|
<string>1,1</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="440" y="220"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Out</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>Z</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="520" y="260"/>
|
||||||
|
</visualElement>
|
||||||
|
</visualElements>
|
||||||
|
<wires>
|
||||||
|
<wire>
|
||||||
|
<p1 x="400" y="240"/>
|
||||||
|
<p2 x="440" y="240"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="460" y="240"/>
|
||||||
|
<p2 x="500" y="240"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="380" y="260"/>
|
||||||
|
<p2 x="400" y="260"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="500" y="260"/>
|
||||||
|
<p2 x="520" y="260"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="380" y="220"/>
|
||||||
|
<p2 x="440" y="220"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="460" y="220"/>
|
||||||
|
<p2 x="520" y="220"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="400" y="240"/>
|
||||||
|
<p2 x="400" y="260"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="500" y="240"/>
|
||||||
|
<p2 x="500" y="260"/>
|
||||||
|
</wire>
|
||||||
|
</wires>
|
||||||
|
</circuit>
|
Loading…
x
Reference in New Issue
Block a user