Added project specific format; Default values in WireArray are now U
[Mograsim.git] / era.mi / src / era / mi / logic / tests / ComponentTest.java
index 3bdaed2..81a2e1f 100644 (file)
@@ -19,12 +19,14 @@ import era.mi.logic.components.gates.NotGate;
 import era.mi.logic.components.gates.OrGate;\r
 import era.mi.logic.components.gates.XorGate;\r
 import era.mi.logic.wires.WireArray;\r
-import era.mi.logic.wires.WireArray.WireArrayInput;\r
+import era.mi.logic.wires.WireArray.WireArrayEnd;\r
 \r
-class ComponentTest {\r
+class ComponentTest\r
+{\r
 \r
        @Test\r
-       void circuitExampleTest() {\r
+       void circuitExampleTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray a = new WireArray(1, 1), b = new WireArray(1, 1), c = new WireArray(1, 10), d = new WireArray(2, 1),\r
                                e = new WireArray(1, 1), f = new WireArray(1, 1), g = new WireArray(1, 1), h = new WireArray(2, 1), i = new WireArray(2, 1),\r
@@ -48,7 +50,8 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void splitterTest() {\r
+       void splitterTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray a = new WireArray(3, 1), b = new WireArray(2, 1), c = new WireArray(3, 1), in = new WireArray(8, 1);\r
                in.createInput().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);\r
@@ -62,7 +65,8 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void mergerTest() {\r
+       void mergerTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray a = new WireArray(3, 1), b = new WireArray(2, 1), c = new WireArray(3, 1), out = new WireArray(8, 1);\r
                a.createInput().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO);\r
@@ -78,13 +82,14 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void triStateBufferTest() {\r
+       void triStateBufferTest()\r
+       {\r
                WireArray a = new WireArray(1, 1), b = new WireArray(1, 1), en = new WireArray(1, 1), notEn = new WireArray(1, 1);\r
                new NotGate(1, en, notEn);\r
                new TriStateBuffer(1, a, b, en);\r
                new TriStateBuffer(1, b, a, notEn);\r
 \r
-               WireArrayInput enI = en.createInput(), aI = a.createInput(), bI = b.createInput();\r
+               WireArrayEnd enI = en.createInput(), aI = a.createInput(), bI = b.createInput();\r
                enI.feedSignals(Bit.ONE);\r
                aI.feedSignals(Bit.ONE);\r
 \r
@@ -109,11 +114,12 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void muxTest() {\r
+       void muxTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray a = new WireArray(4, 3), b = new WireArray(4, 6), c = new WireArray(4, 4), select = new WireArray(2, 5),\r
                                out = new WireArray(4, 1);\r
-               WireArrayInput selectIn = select.createInput();\r
+               WireArrayEnd selectIn = select.createInput();\r
 \r
                selectIn.feedSignals(Bit.ZERO, Bit.ZERO);\r
                a.createInput().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
@@ -136,11 +142,12 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void demuxTest() {\r
+       void demuxTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray a = new WireArray(4, 3), b = new WireArray(4, 6), c = new WireArray(4, 4), select = new WireArray(2, 5),\r
                                in = new WireArray(4, 1);\r
-               WireArrayInput selectIn = select.createInput();\r
+               WireArrayEnd selectIn = select.createInput();\r
 \r
                selectIn.feedSignals(Bit.ZERO, Bit.ZERO);\r
                in.createInput().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
@@ -149,26 +156,27 @@ class ComponentTest {
                Simulation.TIMELINE.executeAll();\r
 \r
                assertBitArrayEquals(a.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
-               assertBitArrayEquals(b.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
-               assertBitArrayEquals(c.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
+               assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);\r
+               assertBitArrayEquals(c.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);\r
                selectIn.feedSignals(Bit.ZERO, Bit.ONE);\r
                Simulation.TIMELINE.executeAll();\r
 \r
                assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
-               assertBitArrayEquals(b.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
+               assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);\r
                assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);\r
 \r
                selectIn.feedSignals(Bit.ONE, Bit.ONE);\r
                Simulation.TIMELINE.executeAll();\r
 \r
                assertBitArrayEquals(a.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
-               assertBitArrayEquals(b.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
+               assertBitArrayEquals(b.getValues(), Bit.U, Bit.U, Bit.U, Bit.U);\r
                assertBitArrayEquals(c.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);\r
 \r
        }\r
 \r
        @Test\r
-       void andTest() {\r
+       void andTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray a = new WireArray(4, 1), b = new WireArray(4, 3), c = new WireArray(4, 1);\r
                new AndGate(1, c, a, b);\r
@@ -181,7 +189,8 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void orTest() {\r
+       void orTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray a = new WireArray(4, 1), b = new WireArray(4, 3), c = new WireArray(4, 1);\r
                new OrGate(1, c, a, b);\r
@@ -194,7 +203,8 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void xorTest() {\r
+       void xorTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray a = new WireArray(3, 1), b = new WireArray(3, 2), c = new WireArray(3, 1), d = new WireArray(3, 1);\r
                new XorGate(1, d, a, b, c);\r
@@ -208,7 +218,8 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void rsLatchCircuitTest() {\r
+       void rsLatchCircuitTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray r = new WireArray(1, 1), s = new WireArray(1, 1), t1 = new WireArray(1, 15), t2 = new WireArray(1, 1),\r
                                q = new WireArray(1, 1), nq = new WireArray(1, 1);\r
@@ -218,7 +229,7 @@ class ComponentTest {
                new NotGate(1, t2, q);\r
                new NotGate(1, t1, nq);\r
 \r
-               WireArrayInput sIn = s.createInput(), rIn = r.createInput();\r
+               WireArrayEnd sIn = s.createInput(), rIn = r.createInput();\r
 \r
                sIn.feedSignals(Bit.ONE);\r
                rIn.feedSignals(Bit.ZERO);\r
@@ -243,7 +254,8 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void numericValueTest() {\r
+       void numericValueTest()\r
+       {\r
                Simulation.TIMELINE.reset();\r
 \r
                WireArray a = new WireArray(4, 1);\r
@@ -256,10 +268,11 @@ class ComponentTest {
        }\r
 \r
        @Test\r
-       void multipleInputs() {\r
+       void multipleInputs()\r
+       {\r
                Simulation.TIMELINE.reset();\r
                WireArray w = new WireArray(2, 1);\r
-               WireArrayInput wI1 = w.createInput(), wI2 = w.createInput();\r
+               WireArrayEnd wI1 = w.createInput(), wI2 = w.createInput();\r
                wI1.feedSignals(Bit.ONE, Bit.Z);\r
                wI2.feedSignals(Bit.Z, Bit.X);\r
                Simulation.TIMELINE.executeAll();\r
@@ -279,8 +292,9 @@ class ComponentTest {
                assertBitArrayEquals(w.getValues(), Bit.ONE, Bit.Z);\r
        }\r
 \r
-       @Test\r
-       void wireConnections() {\r
+//     @Test\r
+       void wireConnections()\r
+       {\r
                // Nur ein Experiment, was über mehrere 'passive' Bausteine hinweg passieren würde\r
 \r
                Simulation.TIMELINE.reset();\r
@@ -288,9 +302,9 @@ class ComponentTest {
                WireArray a = new WireArray(1, 2);\r
                WireArray b = new WireArray(1, 2);\r
                WireArray c = new WireArray(1, 2);\r
-               WireArrayInput aI = a.createInput();\r
-               WireArrayInput bI = b.createInput();\r
-               WireArrayInput cI = c.createInput();\r
+               WireArrayEnd aI = a.createInput();\r
+               WireArrayEnd bI = b.createInput();\r
+               WireArrayEnd cI = c.createInput();\r
 \r
                TestBitDisplay test = new TestBitDisplay(c);\r
                TestBitDisplay test2 = new TestBitDisplay(a);\r
@@ -352,7 +366,8 @@ class ComponentTest {
                test2.assertAfterSimulationIs(Bit.ONE);\r
        }\r
 \r
-       private static void assertBitArrayEquals(Bit[] actual, Bit... expected) {\r
+       private static void assertBitArrayEquals(Bit[] actual, Bit... expected)\r
+       {\r
                assertArrayEquals(expected, actual);\r
        }\r
 }\r