- @Test
- void muxTest()
- {
- Simulation.TIMELINE.reset();
- WireArray a = new WireArray(4, 3), b = new WireArray(4, 6), c = new WireArray(4, 4),
- select = new WireArray(2, 5), out = new WireArray(4, 1);
- WireArrayInput selectIn = select.createInput();
+ @Test
+ void muxTest()
+ {
+ Simulation.TIMELINE.reset();
+ Wire a = new Wire(4, 3), b = new Wire(4, 6), c = new Wire(4, 4), select = new Wire(2, 5),
+ out = new Wire(4, 1);
+ WireEnd selectIn = select.createEnd();
+
+ selectIn.feedSignals(Bit.ZERO, Bit.ZERO);
+ a.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);
+ c.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
+
+ new Mux(1, out.createEnd(), select.createEnd(), a.createEnd(), b.createEnd(), c.createEnd());
+ Simulation.TIMELINE.executeAll();
+
+ assertBitArrayEquals(out.getValues(), Bit.ONE, Bit.ZERO, Bit.ONE, Bit.ZERO);
+ selectIn.feedSignals(Bit.ZERO, Bit.ONE);
+ Simulation.TIMELINE.executeAll();
+
+ assertBitArrayEquals(out.getValues(), Bit.ZERO, Bit.ONE, Bit.ZERO, Bit.ONE);
+
+ selectIn.feedSignals(Bit.ONE, Bit.ONE);
+ Simulation.TIMELINE.executeAll();
+
+ assertBitArrayEquals(out.getValues(), Bit.Z, Bit.Z, Bit.Z, Bit.Z);
+
+ }