From: Daniel Kirschten Date: Wed, 2 Oct 2019 14:02:42 +0000 (+0200) Subject: Fixed ModelClock's high level state: X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=f1933b06b5fe800902131e4dc34f002ac3fa17f0;p=Mograsim.git Fixed ModelClock's high level state: Was inverted when read before wireTravelTime elapsed --- diff --git a/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/components/CoreClock.java b/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/components/CoreClock.java index 0cccdfdd..84608b4d 100644 --- a/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/components/CoreClock.java +++ b/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/components/CoreClock.java @@ -9,7 +9,7 @@ import net.mograsim.logic.core.LogicObserver; import net.mograsim.logic.core.timeline.Timeline; import net.mograsim.logic.core.timeline.TimelineEvent; import net.mograsim.logic.core.timeline.TimelineEventHandler; -import net.mograsim.logic.core.types.Bit; +import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.core.wires.CoreWire; import net.mograsim.logic.core.wires.CoreWire.ReadEnd; import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd; @@ -17,7 +17,7 @@ import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd; public class CoreClock extends CoreComponent implements TimelineEventHandler, LogicObservable { private Collection observers; - private boolean toggle = false; + private boolean isOn = true;// first update switches to 0 private ReadWriteEnd out; private int delta; @@ -39,19 +39,19 @@ public class CoreClock extends CoreComponent implements TimelineEventHandler, Lo public void handle(TimelineEvent e) { addToTimeline(); - out.feedSignals(toggle ? Bit.ONE : Bit.ZERO); - toggle = !toggle; + isOn = !isOn; + out.feedSignals(getOutValues()); notifyObservers(); } - public ReadWriteEnd getOut() + public BitVector getOutValues() { - return out; + return isOn ? BitVector.SINGLE_1 : BitVector.SINGLE_0; } public boolean isOn() { - return !toggle; + return isOn; } private void addToTimeline() diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java index d84e2027..5c54069a 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java @@ -63,7 +63,7 @@ public class ModelClock extends ModelComponent { case "out": if (clock != null) - return clock.getOut().getInputValues(); + return clock.getOutValues(); return null; default: throw new IllegalArgumentException("No high level state with ID " + stateID);