From b35cce111e7b41d5d28c7057fc4f1166d435cc3a Mon Sep 17 00:00:00 2001 From: "helmut.neemann" Date: Mon, 15 Jan 2018 15:24:08 +0100 Subject: [PATCH] adds a new backtrack test --- .../analyse/DependencyAnalyserTest.java | 32 + .../resources/dig/backtrack/AllComponents.dig | 1511 +++++++++++++++++ 2 files changed, 1543 insertions(+) create mode 100644 src/test/resources/dig/backtrack/AllComponents.dig diff --git a/src/test/java/de/neemann/digital/analyse/DependencyAnalyserTest.java b/src/test/java/de/neemann/digital/analyse/DependencyAnalyserTest.java index 0227f11a6..8f41baa96 100644 --- a/src/test/java/de/neemann/digital/analyse/DependencyAnalyserTest.java +++ b/src/test/java/de/neemann/digital/analyse/DependencyAnalyserTest.java @@ -1,10 +1,20 @@ package de.neemann.digital.analyse; import de.neemann.digital.core.*; +import de.neemann.digital.core.element.Element; +import de.neemann.digital.core.element.ElementAttributes; +import de.neemann.digital.draw.elements.Circuit; +import de.neemann.digital.draw.elements.PinException; +import de.neemann.digital.draw.elements.VisualElement; +import de.neemann.digital.draw.library.ElementLibrary; +import de.neemann.digital.draw.library.ElementNotFoundException; import de.neemann.digital.integration.ToBreakRunner; import junit.framework.TestCase; +import java.io.IOException; import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; /** * @author hneemann @@ -75,4 +85,26 @@ ExpressionCreator - s0 reduced from 17 to 2 variables ([Q_1n, Q_0n]) assertEquals(1, da.getInputs(m.getOutputs().get(1)).size()); } + public void testBacktrackCompleteness() throws Exception { + ToBreakRunner toBreakRunner = new ToBreakRunner("dig/backtrack/AllComponents.dig", false); + Circuit circuit = toBreakRunner.getCircuit(); + Set set = new HashSet<>(); + for (VisualElement e : circuit.getElements()) + set.add(e.getElementName()); + + // ensure all components are included in test circuit + for (ElementLibrary.ElementContainer c : toBreakRunner.getLibrary()) { + if (!set.contains(c.getDescription().getName())) { + // nodes with state are allowed to be missing + Element n = c.getDescription().createElement(new ElementAttributes()); + boolean ok = (n instanceof Node) && ((Node) n).hasState(); + assertTrue("component " + c.getDescription().getName() + " is missing in test/resources/dig/backtrack/AllComponents.dig!", ok); + } + } + + // check if backtracking is ok at all components! + ModelAnalyser m = new ModelAnalyser(toBreakRunner.getModel()); + new DependencyAnalyser(m); + } + } diff --git a/src/test/resources/dig/backtrack/AllComponents.dig b/src/test/resources/dig/backtrack/AllComponents.dig new file mode 100644 index 000000000..1a7567d87 --- /dev/null +++ b/src/test/resources/dig/backtrack/AllComponents.dig @@ -0,0 +1,1511 @@ + + + 1 + + + + In + + + Label + in8 + + + Bits + 8 + + + + + + In + + + Label + in1 + + + + + + LED + + + + + And + + + + + In + + + Label + in1b + + + + + + NAnd + + + + + Or + + + + + NOr + + + + + XOr + + + + + XNOr + + + + + Not + + + + + LookUpTable + + + + + Delay + + + + + Out + + + Label + U + + + + + + Clock + + + + + Button + + + + + Text + + + Description + All Components available in Digital + + + + + + Probe + + + + + LightBulb + + + + + Seven-Seg + + + + + Seven-Seg-Hex + + + + + Ground + + + + + LedMatrix + + + colAddrBits + 4 + + + + + + Data + + + + + RotEncoder + + + + + Keyboard + + + + + Terminal + + + + + VDD + + + + + Const + + + + + Tunnel + + + NetName + zz + + + + + + Splitter + + + + + PullUp + + + + + PullDown + + + + + Driver + + + Bits + 4 + + + + + + DriverInvSel + + + Bits + 4 + + + + + + Multiplexer + + + Bits + 4 + + + + + + Demultiplexer + + + + + BitSelector + + + Selector Bits + 2 + + + + + + In + + + Label + in4 + + + Bits + 4 + + + + + + In + + + Label + in2 + + + Bits + 2 + + + + + + PriorityEncoder + + + + + Decoder + + + + + JK_FF + + + + + D_FF + + + + + T_FF + + + + + ROM + + + AddrBits + 8 + + + Bits + 8 + + + + + + GraphicCard + + + graphicHeight + 10 + + + graphicWidth + 10 + + + Bits + 8 + + + + + + Add + + + Bits + 8 + + + + + + Sub + + + Bits + 8 + + + + + + Mul + + + Bits + 8 + + + + + + BarrelShifter + + + Bits + 8 + + + + + + Comparator + + + Bits + 8 + + + + + + Neg + + + Bits + 8 + + + + + + BitExtender + + + + + BitCount + + + Bits + 8 + + + + + + DiodeForward + + + + + DiodeBackward + + + + + Switch + + + + + Fuse + + + + + Relay + + + + + PFET + + + + + NFET + + + + + FGPFET + + + + + FGNFET + + + + + TransGate + + + + + Not + + + rotation + + + + + + + Testcase + + + + + PowerSupply + + + + + Reset + + + + + Break + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file