X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Ftests%2FConnector.java;h=39645bfc3af569b92ea2ceea5db06a2517bab56f;hb=6021657564ff698a56c8581a32d842637af31258;hp=99b00689d2d44b0de553ae769a57567bc30a3141;hpb=bc46b5d9664f097be44f5147c5cc774d1410ad93;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/tests/Connector.java b/era.mi/src/era/mi/logic/tests/Connector.java index 99b00689..39645bfc 100644 --- a/era.mi/src/era/mi/logic/tests/Connector.java +++ b/era.mi/src/era/mi/logic/tests/Connector.java @@ -1,39 +1,39 @@ -package era.mi.logic.tests; - -import era.mi.logic.Bit; -import era.mi.logic.Simulation; -import era.mi.logic.wires.WireArray; -import era.mi.logic.wires.WireArray.WireArrayInput; -import era.mi.logic.wires.WireArrayObserver; - -public class Connector implements WireArrayObserver -{ - private final WireArray a; -// private final WireArray b; - private final WireArrayInput aI; - private final WireArrayInput bI; - - public Connector(WireArray a, WireArray 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.createInput(); - bI = b.createInput(); - } - - @Override - public void update(WireArray initiator, Bit[] oldValues) - { - Simulation.TIMELINE.addEvent((e) -> - { - if (initiator == a) - bI.feedSignals(aI.wireValuesExcludingMe()); - else - aI.feedSignals(bI.wireValuesExcludingMe()); - }, 1); - } -} +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); + } +}