From c157bee3a744797b2850d779288a7af7fd09bee3 Mon Sep 17 00:00:00 2001 From: hneemann Date: Sat, 4 Mar 2017 22:32:15 +0100 Subject: [PATCH] added switch multi-bit tests --- distribution/ReleaseNotes.txt | 2 +- .../neemann/digital/core/arithmetic/Mul.java | 5 +- .../digital/core/ObservableValueTest.java | 4 +- .../digital/integration/TestExamples.java | 4 +- src/test/resources/dig/test/fet/multiBit.dig | 188 ++++++++++++++++++ .../resources/dig/test/switch/switch2.dig | 99 +++++++++ 6 files changed, 294 insertions(+), 8 deletions(-) create mode 100644 src/test/resources/dig/test/fet/multiBit.dig create mode 100644 src/test/resources/dig/test/switch/switch2.dig diff --git a/distribution/ReleaseNotes.txt b/distribution/ReleaseNotes.txt index 9d9ed1570..2a21f0c5e 100644 --- a/distribution/ReleaseNotes.txt +++ b/distribution/ReleaseNotes.txt @@ -8,7 +8,7 @@ planned as v0.10 - Added a real bidirectional switch and a relay. - Added N and P channel FETs and some CMOS examples - Improved and documented the file import strategy. -- Easier editing of truth tables. +- Truth tables are easier to edit. v0.9, released on 03. Feb 2017 - improved documentation diff --git a/src/main/java/de/neemann/digital/core/arithmetic/Mul.java b/src/main/java/de/neemann/digital/core/arithmetic/Mul.java index f93ce9c79..06f6c84c9 100644 --- a/src/main/java/de/neemann/digital/core/arithmetic/Mul.java +++ b/src/main/java/de/neemann/digital/core/arithmetic/Mul.java @@ -9,18 +9,17 @@ import de.neemann.digital.core.element.ElementAttributes; import de.neemann.digital.core.element.ElementTypeDescription; import de.neemann.digital.core.element.Keys; - import static de.neemann.digital.core.element.PinInfo.input; /** - * A multiplicator + * A multiplier * * @author hneemann */ public class Mul extends Node implements Element { /** - * The multiplicators description + * The multiplier description */ public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(Mul.class, input("a"), input("b")) diff --git a/src/test/java/de/neemann/digital/core/ObservableValueTest.java b/src/test/java/de/neemann/digital/core/ObservableValueTest.java index 8b5f53d10..4c546dc1a 100644 --- a/src/test/java/de/neemann/digital/core/ObservableValueTest.java +++ b/src/test/java/de/neemann/digital/core/ObservableValueTest.java @@ -16,13 +16,13 @@ public class ObservableValueTest extends TestCase { public void testSetValue2() throws Exception { ObservableValue v = new ObservableValue("z", 63); v.setValue(-1); - assertEquals((1l << 63) - 1, v.getValue()); + assertEquals((1L << 63) - 1, v.getValue()); } public void testSetValue3() throws Exception { ObservableValue v = new ObservableValue("z", 62); v.setValue(-1); - assertEquals((1l << 62) - 1, v.getValue()); + assertEquals((1L << 62) - 1, v.getValue()); } } \ No newline at end of file diff --git a/src/test/java/de/neemann/digital/integration/TestExamples.java b/src/test/java/de/neemann/digital/integration/TestExamples.java index f3eaee1d7..bb9552995 100644 --- a/src/test/java/de/neemann/digital/integration/TestExamples.java +++ b/src/test/java/de/neemann/digital/integration/TestExamples.java @@ -39,8 +39,8 @@ public class TestExamples extends TestCase { */ public void testTestExamples() throws Exception { File examples = new File(Resources.getRoot(), "/dig/test"); - assertEquals(46, new FileScanner(this::check).scan(examples)); - assertEquals(38, testCasesInFiles); + assertEquals(48, new FileScanner(this::check).scan(examples)); + assertEquals(41, testCasesInFiles); } diff --git a/src/test/resources/dig/test/fet/multiBit.dig b/src/test/resources/dig/test/fet/multiBit.dig new file mode 100644 index 000000000..fe1ef61a5 --- /dev/null +++ b/src/test/resources/dig/test/fet/multiBit.dig @@ -0,0 +1,188 @@ + + + 1 + + + In + + + rotation + + + + Label + A + + + + + + Out + + + Label + Y + + + Bits + 8 + + + + + + In + + + Label + B + + + Bits + 8 + + + + + + Testcase + + + Label + n-chan + + + Testdata + + A B Y +0 0 z +0 7 z +1 0 0 +1 7 7 + + + + + + + + + NFET + + + rotation + + + + Bits + 8 + + + + + + In + + + rotation + + + + Label + A1 + + + + + + Out + + + Label + Y1 + + + Bits + 8 + + + + + + In + + + Label + B1 + + + Bits + 8 + + + + + + Testcase + + + Label + p-chan + + + Testdata + + A1 B1 Y1 +0 0 0 +0 7 7 +1 0 z +1 7 z + + + + + + + + + PFET + + + rotation + + + + Bits + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/dig/test/switch/switch2.dig b/src/test/resources/dig/test/switch/switch2.dig new file mode 100644 index 000000000..a75c7bda6 --- /dev/null +++ b/src/test/resources/dig/test/switch/switch2.dig @@ -0,0 +1,99 @@ + + + 1 + + + Relay + + + Bits + 8 + + + + + + In + + + Label + A + + + + + + Out + + + Label + Y + + + Bits + 8 + + + + + + In + + + Label + B + + + Bits + 8 + + + + + + Testcase + + + Testdata + + A B Y +0 0 z +0 7 z +1 0 0 +1 7 7 + + + + + + + + + Ground + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file