diff --git a/src/main/java/de/neemann/digital/analyse/SubstituteLibrary.java b/src/main/java/de/neemann/digital/analyse/SubstituteLibrary.java index b725581c9..532e700cb 100644 --- a/src/main/java/de/neemann/digital/analyse/SubstituteLibrary.java +++ b/src/main/java/de/neemann/digital/analyse/SubstituteLibrary.java @@ -44,6 +44,7 @@ public class SubstituteLibrary implements LibraryInterface { ); MAP.put("Counter", new SubstituteGenericHGSParser("Counter.dig")); MAP.put("CounterPreset", new SubstituteGenericHGSParser("CounterPreset.dig")); + MAP.put("Register", new SubstituteGenericHGSParser("Register.dig")); } private final ElementLibrary parent; diff --git a/src/main/resources/analyser/Register.dig b/src/main/resources/analyser/Register.dig new file mode 100644 index 000000000..93c0a8ffd --- /dev/null +++ b/src/main/resources/analyser/Register.dig @@ -0,0 +1,195 @@ + + + 1 + + + isGeneric + true + + + + + In + + + Label + D + + + + + + XOr + + + + + Const + + + Value + 0 + + + generic + if (orig.inverterConfig.en) { + this.Value=1; +} + + + + + + Clock + + + Label + C + + + + + + XOr + + + generic + this.Bits=orig.Bits; + + + + + + Const + + + Value + 0 + + + generic + this.Bits=orig.Bits; +if (orig.inverterConfig.D) { + this.Value=-1; +} + + + + + + Multiplexer + + + generic + this.Bits=orig.Bits; + + + + + + In + + + Label + en + + + + + + D_FF + + + Label + * + + + generic + this.Bits=orig.Bits; + + + + + + Out + + + Label + Q + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/de/neemann/digital/analyse/ModelAnalyserTest.java b/src/test/java/de/neemann/digital/analyse/ModelAnalyserTest.java index a140b5219..4ed4aa70c 100644 --- a/src/test/java/de/neemann/digital/analyse/ModelAnalyserTest.java +++ b/src/test/java/de/neemann/digital/analyse/ModelAnalyserTest.java @@ -125,6 +125,12 @@ public class ModelAnalyserTest extends TestCase { 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) { assertEquals(4, tt.getRows()); assertEquals(4, tt.getCols()); diff --git a/src/test/resources/dig/analyze/analyzeTestRegister.dig b/src/test/resources/dig/analyze/analyzeTestRegister.dig new file mode 100644 index 000000000..f6c55c1d4 --- /dev/null +++ b/src/test/resources/dig/analyze/analyzeTestRegister.dig @@ -0,0 +1,120 @@ + + + 1 + + + + Clock + + + runRealTime + true + + + Label + C + + + + + + Register + + + Label + Q + + + Bits + 2 + + + + + + Const + + + + + Add + + + Bits + 2 + + + + + + Ground + + + + + Const + + + Bits + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file