mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 08:25:09 -04:00
analyzer is able to analyze the register
This commit is contained in:
parent
0cb457bcd7
commit
b552c81206
@ -44,6 +44,7 @@ public class SubstituteLibrary implements LibraryInterface {
|
|||||||
);
|
);
|
||||||
MAP.put("Counter", new SubstituteGenericHGSParser("Counter.dig"));
|
MAP.put("Counter", new SubstituteGenericHGSParser("Counter.dig"));
|
||||||
MAP.put("CounterPreset", new SubstituteGenericHGSParser("CounterPreset.dig"));
|
MAP.put("CounterPreset", new SubstituteGenericHGSParser("CounterPreset.dig"));
|
||||||
|
MAP.put("Register", new SubstituteGenericHGSParser("Register.dig"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ElementLibrary parent;
|
private final ElementLibrary parent;
|
||||||
|
195
src/main/resources/analyser/Register.dig
Normal file
195
src/main/resources/analyser/Register.dig
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<circuit>
|
||||||
|
<version>1</version>
|
||||||
|
<attributes>
|
||||||
|
<entry>
|
||||||
|
<string>isGeneric</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
|
</attributes>
|
||||||
|
<visualElements>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>In</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>D</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="340" y="200"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>XOr</elementName>
|
||||||
|
<elementAttributes/>
|
||||||
|
<pos x="360" y="240"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Const</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Value</string>
|
||||||
|
<long>0</long>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>generic</string>
|
||||||
|
<string>if (orig.inverterConfig.en) {
|
||||||
|
this.Value=1;
|
||||||
|
}</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="340" y="240"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Clock</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>C</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="340" y="320"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>XOr</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>generic</string>
|
||||||
|
<string>this.Bits=orig.Bits;</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="360" y="160"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Const</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Value</string>
|
||||||
|
<long>0</long>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>generic</string>
|
||||||
|
<string>this.Bits=orig.Bits;
|
||||||
|
if (orig.inverterConfig.D) {
|
||||||
|
this.Value=-1;
|
||||||
|
}</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="340" y="160"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Multiplexer</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>generic</string>
|
||||||
|
<string>this.Bits=orig.Bits;</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="480" y="140"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>In</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>en</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="340" y="280"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>D_FF</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>*</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>generic</string>
|
||||||
|
<string>this.Bits=orig.Bits;</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="560" y="160"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Out</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>Q</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="660" y="160"/>
|
||||||
|
</visualElement>
|
||||||
|
</visualElements>
|
||||||
|
<wires>
|
||||||
|
<wire>
|
||||||
|
<p1 x="340" y="160"/>
|
||||||
|
<p2 x="360" y="160"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="520" y="160"/>
|
||||||
|
<p2 x="560" y="160"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="620" y="160"/>
|
||||||
|
<p2 x="640" y="160"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="640" y="160"/>
|
||||||
|
<p2 x="660" y="160"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="340" y="320"/>
|
||||||
|
<p2 x="540" y="320"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="340" y="240"/>
|
||||||
|
<p2 x="360" y="240"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="420" y="180"/>
|
||||||
|
<p2 x="480" y="180"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="540" y="180"/>
|
||||||
|
<p2 x="560" y="180"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="420" y="260"/>
|
||||||
|
<p2 x="500" y="260"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="460" y="100"/>
|
||||||
|
<p2 x="640" y="100"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="340" y="280"/>
|
||||||
|
<p2 x="360" y="280"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="340" y="200"/>
|
||||||
|
<p2 x="360" y="200"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="460" y="140"/>
|
||||||
|
<p2 x="480" y="140"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="640" y="100"/>
|
||||||
|
<p2 x="640" y="160"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="500" y="180"/>
|
||||||
|
<p2 x="500" y="260"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="540" y="180"/>
|
||||||
|
<p2 x="540" y="320"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="460" y="100"/>
|
||||||
|
<p2 x="460" y="140"/>
|
||||||
|
</wire>
|
||||||
|
</wires>
|
||||||
|
<measurementOrdering/>
|
||||||
|
</circuit>
|
@ -125,6 +125,12 @@ public class ModelAnalyserTest extends TestCase {
|
|||||||
check2BitCounter(tt);
|
check2BitCounter(tt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testAnalyzerRegister() throws Exception {
|
||||||
|
Model model = createModel("dig/analyze/analyzeTestRegister.dig");
|
||||||
|
TruthTable tt = new ModelAnalyser(model).analyse();
|
||||||
|
check2BitCounter(tt);
|
||||||
|
}
|
||||||
|
|
||||||
private void check2BitCounter(TruthTable tt) {
|
private void check2BitCounter(TruthTable tt) {
|
||||||
assertEquals(4, tt.getRows());
|
assertEquals(4, tt.getRows());
|
||||||
assertEquals(4, tt.getCols());
|
assertEquals(4, tt.getCols());
|
||||||
|
120
src/test/resources/dig/analyze/analyzeTestRegister.dig
Normal file
120
src/test/resources/dig/analyze/analyzeTestRegister.dig
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<circuit>
|
||||||
|
<version>1</version>
|
||||||
|
<attributes/>
|
||||||
|
<visualElements>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Clock</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>runRealTime</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>C</string>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="360" y="180"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Register</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Label</string>
|
||||||
|
<string>Q</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>Bits</string>
|
||||||
|
<int>2</int>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="420" y="160"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Const</elementName>
|
||||||
|
<elementAttributes/>
|
||||||
|
<pos x="400" y="200"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Add</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Bits</string>
|
||||||
|
<int>2</int>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="320" y="80"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Ground</elementName>
|
||||||
|
<elementAttributes/>
|
||||||
|
<pos x="300" y="140"/>
|
||||||
|
</visualElement>
|
||||||
|
<visualElement>
|
||||||
|
<elementName>Const</elementName>
|
||||||
|
<elementAttributes>
|
||||||
|
<entry>
|
||||||
|
<string>Bits</string>
|
||||||
|
<int>2</int>
|
||||||
|
</entry>
|
||||||
|
</elementAttributes>
|
||||||
|
<pos x="300" y="100"/>
|
||||||
|
</visualElement>
|
||||||
|
</visualElements>
|
||||||
|
<wires>
|
||||||
|
<wire>
|
||||||
|
<p1 x="300" y="80"/>
|
||||||
|
<p2 x="320" y="80"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="380" y="80"/>
|
||||||
|
<p2 x="400" y="80"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="400" y="160"/>
|
||||||
|
<p2 x="420" y="160"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="480" y="180"/>
|
||||||
|
<p2 x="500" y="180"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="360" y="180"/>
|
||||||
|
<p2 x="420" y="180"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="300" y="100"/>
|
||||||
|
<p2 x="320" y="100"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="400" y="200"/>
|
||||||
|
<p2 x="420" y="200"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="300" y="120"/>
|
||||||
|
<p2 x="320" y="120"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="300" y="60"/>
|
||||||
|
<p2 x="500" y="60"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="400" y="80"/>
|
||||||
|
<p2 x="400" y="160"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="500" y="60"/>
|
||||||
|
<p2 x="500" y="180"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="300" y="60"/>
|
||||||
|
<p2 x="300" y="80"/>
|
||||||
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="300" y="120"/>
|
||||||
|
<p2 x="300" y="140"/>
|
||||||
|
</wire>
|
||||||
|
</wires>
|
||||||
|
<measurementOrdering/>
|
||||||
|
</circuit>
|
Loading…
x
Reference in New Issue
Block a user