+ @Test
+ void xorTest()
+ {
+ Simulation.TIMELINE.reset();
+ Wire a = new Wire(3, 1), b = new Wire(3, 2), c = new Wire(3, 1), d = new Wire(3, 1);
+ new XorGate(1, d.createEnd(), a.createReadOnlyEnd(), b.createReadOnlyEnd(), c.createReadOnlyEnd());
+ a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE);
+ b.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);
+ c.createEnd().feedSignals(Bit.ONE, Bit.ZERO, Bit.ONE);
+
+ Simulation.TIMELINE.executeAll();
+
+ assertBitArrayEquals(d.getValues(), Bit.ZERO, Bit.ONE, Bit.ONE);
+ }
+
+ @Test
+ void notTest()
+ {
+ Simulation.TIMELINE.reset();
+ Wire a = new Wire(3, 1), b = new Wire(3, 2);
+ new NotGate(1, a.createReadOnlyEnd(), b.createEnd());
+ a.createEnd().feedSignals(Bit.ZERO, Bit.ONE, Bit.ONE);
+
+ Simulation.TIMELINE.executeAll();
+
+ assertBitArrayEquals(b.getValues(), Bit.ONE, Bit.ZERO, Bit.ZERO);
+ }
+
+ @Test
+ void rsLatchCircuitTest()
+ {
+ Simulation.TIMELINE.reset();
+ Wire r = new Wire(1, 1), s = new Wire(1, 1), t1 = new Wire(1, 15), t2 = new Wire(1, 1), q = new Wire(1, 1), nq = new Wire(1, 1);
+
+ new OrGate(1, t2.createEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd());
+ new OrGate(1, t1.createEnd(), s.createReadOnlyEnd(), q.createReadOnlyEnd());
+ new NotGate(1, t2.createReadOnlyEnd(), q.createEnd());
+ new NotGate(1, t1.createReadOnlyEnd(), nq.createEnd());
+
+ WireEnd sIn = s.createEnd(), rIn = r.createEnd();
+
+ sIn.feedSignals(Bit.ONE);
+ rIn.feedSignals(Bit.ZERO);
+
+ Simulation.TIMELINE.executeAll();