From 06be73ce02cf9b87b053af3e01396334badecba8 Mon Sep 17 00:00:00 2001 From: hneemann Date: Fri, 12 Jan 2018 09:20:16 +0100 Subject: [PATCH] added a 16 bit multiplier example --- src/main/dig/combinatorial/Multiply16Bit.dig | 2612 +++++++++++++++++ .../digital/integration/TestExamples.java | 4 +- 2 files changed, 2614 insertions(+), 2 deletions(-) create mode 100644 src/main/dig/combinatorial/Multiply16Bit.dig diff --git a/src/main/dig/combinatorial/Multiply16Bit.dig b/src/main/dig/combinatorial/Multiply16Bit.dig new file mode 100644 index 000000000..18affc1df --- /dev/null +++ b/src/main/dig/combinatorial/Multiply16Bit.dig @@ -0,0 +1,2612 @@ + + + 1 + + + Description + Einfacher 4-Bit Multiplikator aufgebaut aus drei 4-Bit +Addierern. Die eigentlichen 1-Bit Multiplikationen +werden durch die Und-Gatter implementiert. + + + Width + 4 + + + + + In + + + Label + A + + + Bits + 16 + + + intFormat + hex + + + InDefault + + + + + + + In + + + Label + B + + + Bits + 16 + + + intFormat + hex + + + InDefault + + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + Splitter + + + Input Splitting + 16 + + + Output Splitting + 1*16 + + + + + + Add + + + Bits + 17 + + + + + + Splitter + + + Input Splitting + 1,16 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 16,1 + + + Output Splitting + 17 + + + + + + Const + + + Value + 0 + + + + + + Ground + + + + + Const + + + Value + 0 + + + + + + Add + + + Bits + 17 + + + + + + Const + + + Value + 0 + + + + + + Ground + + + + + Const + + + Value + 0 + + + + + + Add + + + Bits + 17 + + + + + + Const + + + Value + 0 + + + + + + Ground + + + + + Const + + + Value + 0 + + + + + + Add + + + Bits + 17 + + + + + + Const + + + Value + 0 + + + + + + Ground + + + + + Const + + + Value + 0 + + + + + + Add + + + Bits + 20 + + + + + + Splitter + + + Input Splitting + 2,17,1 + + + Output Splitting + 20 + + + + + + Splitter + + + Input Splitting + 17,1,2 + + + Output Splitting + 20 + + + + + + Const + + + Value + 0 + + + Bits + 2 + + + + + + Ground + + + + + Const + + + Value + 0 + + + Bits + 2 + + + + + + Add + + + Bits + 20 + + + + + + Add + + + Bits + 24 + + + + + + Splitter + + + Input Splitting + 20,1,3 + + + Output Splitting + 24 + + + + + + Ground + + + + + Const + + + Value + 0 + + + Bits + 3 + + + + + + Out + + + Label + Y + + + Bits + 32 + + + intFormat + hex + + + + + + Splitter + + + Input Splitting + 4,20 + + + Output Splitting + 24 + + + + + + Const + + + Value + 0 + + + Bits + 4 + + + + + + Const + + + Value + 0 + + + Bits + 2 + + + + + + Ground + + + + + Const + + + Value + 0 + + + Bits + 2 + + + + + + Testcase + + + Testdata + + A B Y +loop(a,1<<4) + loop(b,1<<16) + (a<<8) (b) ((a<<8)*b) + (b) (a<<8) ((a<<8)*b) + (a<<12) (b) ((a<<12)*b) + (b) (a<<12) ((a<<12)*b) + end loop +end loop + + + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + And + + + Bits + 16 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + BitExtender + + + inputBits + 1 + + + + + + Add + + + Bits + 17 + + + + + + Const + + + Value + 0 + + + + + + Ground + + + + + Const + + + Value + 0 + + + + + + Add + + + Bits + 17 + + + + + + Const + + + Value + 0 + + + + + + Ground + + + + + Const + + + Value + 0 + + + + + + Add + + + Bits + 17 + + + + + + Const + + + Value + 0 + + + + + + Ground + + + + + Const + + + Value + 0 + + + + + + Add + + + Bits + 17 + + + + + + Const + + + Value + 0 + + + + + + Ground + + + + + Const + + + Value + 0 + + + + + + Add + + + Bits + 20 + + + + + + Const + + + Value + 0 + + + Bits + 2 + + + + + + Ground + + + + + Const + + + Value + 0 + + + Bits + 2 + + + + + + Add + + + Bits + 20 + + + + + + Add + + + Bits + 24 + + + + + + Ground + + + + + Const + + + Value + 0 + + + Bits + 3 + + + + + + Const + + + Value + 0 + + + Bits + 4 + + + + + + Const + + + Value + 0 + + + Bits + 2 + + + + + + Ground + + + + + Const + + + Value + 0 + + + Bits + 2 + + + + + + Splitter + + + Input Splitting + 1,16 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 16,1 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 1,16 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 16,1 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 1,16 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 16,1 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 1,16 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 16,1 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 1,16 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 16,1 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 1,16 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 16,1 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 1,16 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 16,1 + + + Output Splitting + 17 + + + + + + Splitter + + + Input Splitting + 2,17,1 + + + Output Splitting + 20 + + + + + + Splitter + + + Input Splitting + 17,1,2 + + + Output Splitting + 20 + + + + + + Splitter + + + Input Splitting + 2,17,1 + + + Output Splitting + 20 + + + + + + Splitter + + + Input Splitting + 17,1,2 + + + Output Splitting + 20 + + + + + + Splitter + + + Input Splitting + 2,17,1 + + + Output Splitting + 20 + + + + + + Splitter + + + Input Splitting + 17,1,2 + + + Output Splitting + 20 + + + + + + Splitter + + + Input Splitting + 20,1,3 + + + Output Splitting + 24 + + + + + + Splitter + + + Input Splitting + 4,20 + + + Output Splitting + 24 + + + + + + Splitter + + + Input Splitting + 24,1,7 + + + Output Splitting + 32 + + + + + + Const + + + Value + 0 + + + Bits + 7 + + + + + + Splitter + + + Input Splitting + 8,24 + + + Output Splitting + 32 + + + + + + Const + + + Value + 0 + + + Bits + 8 + + + + + + Add + + + Bits + 32 + + + + + + Ground + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + P_0 + P_1 + P_2 + P_3 + Q_0 + Q_1 + Q_2 + Q_3 + S_0 + S_1 + S_2 + S_3 + S_4 + S_5 + S_6 + S_7 + + \ 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 4b95e1da5..a521f0d74 100644 --- a/src/test/java/de/neemann/digital/integration/TestExamples.java +++ b/src/test/java/de/neemann/digital/integration/TestExamples.java @@ -29,8 +29,8 @@ public class TestExamples extends TestCase { */ public void testDistExamples() throws Exception { File examples = new File(Resources.getRoot().getParentFile().getParentFile(), "/main/dig"); - assertEquals(203, new FileScanner(this::check).scan(examples)); - assertEquals(108, testCasesInFiles); + assertEquals(204, new FileScanner(this::check).scan(examples)); + assertEquals(109, testCasesInFiles); } /**