-package era.mi.logic.tests;\r
-\r
-import era.mi.logic.Bit;\r
-import era.mi.logic.Simulation;\r
-import era.mi.logic.wires.WireArray;\r
-import era.mi.logic.wires.WireArray.WireArrayInput;\r
-import era.mi.logic.wires.WireArrayObserver;\r
-\r
-public class Connector implements WireArrayObserver {\r
- private final WireArray a;\r
-// private final WireArray b;\r
- private final WireArrayInput aI;\r
- private final WireArrayInput bI;\r
-\r
- public Connector(WireArray a, WireArray b) {\r
- if (a.length != b.length)\r
- throw new IllegalArgumentException(String.format("WireArray width does not match: %d, %d", a.length, b.length));\r
- this.a = a;\r
-// this.b = b;\r
- a.addObserver(this);\r
- b.addObserver(this);\r
- aI = a.createInput();\r
- bI = b.createInput();\r
- }\r
-\r
- @Override\r
- public void update(WireArray initiator, Bit[] oldValues) {\r
- Simulation.TIMELINE.addEvent((e) -> {\r
- if (initiator == a)\r
- bI.feedSignals(aI.wireValuesExcludingMe());\r
- else\r
- aI.feedSignals(bI.wireValuesExcludingMe());\r
- }, 1);\r
- }\r
-}\r
+package era.mi.logic.tests;
+
+import era.mi.logic.Bit;
+import era.mi.logic.Simulation;
+import era.mi.logic.wires.Wire;
+import era.mi.logic.wires.Wire.WireEnd;
+import era.mi.logic.wires.WireObserver;
+
+public class Connector implements WireObserver
+{
+ private final Wire a;
+// private final WireArray b;
+ private final WireEnd aI;
+ private final WireEnd bI;
+
+ public Connector(Wire a, Wire b)
+ {
+ if (a.length != b.length)
+ throw new IllegalArgumentException(String.format("WireArray width does not match: %d, %d", a.length, b.length));
+ this.a = a;
+// this.b = b;
+ a.addObserver(this);
+ b.addObserver(this);
+ aI = a.createEnd();
+ bI = b.createEnd();
+ }
+
+ @Override
+ public void update(Wire initiator, Bit[] oldValues)
+ {
+ Simulation.TIMELINE.addEvent((e) ->
+ {
+ if (initiator == a)
+ bI.feedSignals(aI.wireValuesExcludingMe());
+ else
+ aI.feedSignals(bI.wireValuesExcludingMe());
+ }, 1);
+ }
+}