-// @Test
-// void circuitExampleTest()
-// {
-// Simulation.TIMELINE.reset();
-// WireArray a = new WireArray(1, 1), b = new WireArray(1, 1), c = new WireArray(1, 10), d = new WireArray(2, 1), 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), j = new WireArray(1, 1), k = new WireArray(1, 1);
-// new AndGate(1, a, b, f);
-// new NotGate(1, f, g);
-// new Merger2(h, c, g);
-// new Mux(1, h, d, e, i);
-// new Splitter(i, k, j);
-//
-// a.createInput().feedSignals(Bit.ZERO);
-// b.createInput().feedSignals(Bit.ONE);
-// c.createInput().feedSignals(Bit.ZERO);
-// d.createInput().feedSignals(Bit.ONE, Bit.ONE);
-// e.createInput().feedSignals(Bit.ONE);
-//
-// while(Simulation.TIMELINE.hasNext())
-// {
-// Simulation.TIMELINE.executeNext();
-// }
-//
-// assertEquals(Simulation.TIMELINE.getSimulationTime(), 14);
-// assertEquals(Bit.ONE, j.getValue());
-// assertEquals(Bit.ZERO, k.getValue());
-// }
-//
-// @Test
-// void splitterTest()
-// {
-// Simulation.TIMELINE.reset();
-// WireArray a = new WireArray(3, 1), b = new WireArray(2, 1), c = new WireArray(3, 1), in = new WireArray(8, 1);
-// in.createInput().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO,Bit.ONE, Bit.ZERO, Bit.ONE);
-// new Splitter(in, a, b, c);
-//
-// while(Simulation.TIMELINE.hasNext())
-// {
-// Simulation.TIMELINE.executeNext();
-// }
-//
-// assertTrue(Arrays.equals(a.getValues(), new Bit[] { Bit.ZERO, Bit.ONE, Bit.ZERO }));
-// assertTrue(Arrays.equals(b.getValues(), new Bit[] { Bit.ONE, Bit.ZERO }));
-// assertTrue(Arrays.equals(c.getValues(), new Bit[] { Bit.ONE, Bit.ZERO, Bit.ONE }));
-// }
-//
-// @Test
-// void mergerTest()
-// {
-// Simulation.TIMELINE.reset();
-// WireArray a = new WireArray(3, 1), b = new WireArray(2, 1), c = new WireArray(3, 1), out = new WireArray(8, 1);
-// a.createInput().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO);
-// b.createInput().feedSignals(Bit.ONE, Bit.ZERO);
-// c.createInput().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);
-//
-// new Merger2(out, a, b, c);
-//
-// while(Simulation.TIMELINE.hasNext())
-// {
-// Simulation.TIMELINE.executeNext();
-// }
-//
-// assertTrue(Arrays.equals(out.getValues(), new Bit[] { Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE }));
-// }
-
+ @Test
+ void circuitExampleTest()
+ {
+ Simulation.TIMELINE.reset();
+ Wire a = new Wire(1, 1), b = new Wire(1, 1), c = new Wire(1, 10), d = new Wire(2, 1), e = new Wire(1, 1), f = new Wire(1, 1),
+ g = new Wire(1, 1), h = new Wire(2, 1), i = new Wire(2, 1), j = new Wire(1, 1), k = new Wire(1, 1);
+ new AndGate(1, f.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd());
+ new NotGate(1, f.createReadOnlyEnd(), g.createEnd());
+ new Merger(h.createEnd(), c.createReadOnlyEnd(), g.createReadOnlyEnd());
+ new Mux(1, i.createEnd(), e.createReadOnlyEnd(), h.createReadOnlyEnd(), d.createReadOnlyEnd());
+ new Splitter(i.createReadOnlyEnd(), k.createEnd(), j.createEnd());
+
+ a.createEnd().feedSignals(Bit.ZERO);
+ b.createEnd().feedSignals(Bit.ONE);
+ c.createEnd().feedSignals(Bit.ZERO);
+ d.createEnd().feedSignals(Bit.ONE, Bit.ONE);
+ e.createEnd().feedSignals(Bit.ZERO);
+
+ Simulation.TIMELINE.executeAll();
+
+ assertEquals(Bit.ONE, j.getValue());
+ assertEquals(Bit.ZERO, k.getValue());
+ }
+
+ @Test
+ void splitterTest()
+ {
+ Simulation.TIMELINE.reset();
+ Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), in = new Wire(8, 1);
+ in.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
+ new Splitter(in.createReadOnlyEnd(), a.createEnd(), b.createEnd(), c.createEnd());
+
+ Simulation.TIMELINE.executeAll();
+
+ assertBitArrayEquals(a.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO);
+ assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO);
+ assertBitArrayEquals(c.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE);
+ }
+
+ @Test
+ void mergerTest()
+ {
+ Simulation.TIMELINE.reset();
+ Wire a = new Wire(3, 1), b = new Wire(2, 1), c = new Wire(3, 1), out = new Wire(8, 1);
+ a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO);
+ b.createEnd().feedSignals(Bit.ONE, Bit.ZERO);
+ c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);
+
+ new Merger(out.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd());
+
+ Simulation.TIMELINE.executeAll();
+
+ assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
+ }
+
+ @Test
+ void triStateBufferTest()
+ {
+ Wire a = new Wire(1, 1), b = new Wire(1, 1), en = new Wire(1, 1), notEn = new Wire(1, 1);
+ new NotGate(1, en.createReadOnlyEnd(), notEn.createEnd());
+ new TriStateBuffer(1, a.createReadOnlyEnd(), b.createEnd(), en.createReadOnlyEnd());
+ new TriStateBuffer(1, b.createReadOnlyEnd(), a.createEnd(), notEn.createReadOnlyEnd());
+
+ WireEnd enI = en.createEnd(), aI = a.createEnd(), bI = b.createEnd();
+ enI.feedSignals(Bit.ONE);
+ aI.feedSignals(Bit.ONE);
+ bI.feedSignals(Bit.Z);
+
+ Simulation.TIMELINE.executeAll();
+
+ assertEquals(Bit.ONE, b.getValue());
+
+ bI.feedSignals(Bit.ZERO);
+
+ Simulation.TIMELINE.executeAll();
+
+ assertEquals(Bit.X, b.getValue());
+ assertEquals(Bit.ONE, a.getValue());
+
+ aI.clearSignals();
+ enI.feedSignals(Bit.ZERO);
+
+ Simulation.TIMELINE.executeAll();
+
+ assertEquals(Bit.ZERO, a.getValue());
+
+ }
+