X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2FSplitter.java;h=04658fe4ec2077fcf318fdb1489a3c5770bfb63f;hb=3e6ac3d7fd389191d02c1c6982fbf093421ce4f2;hp=9eb5b2c04f7a40ffec936dd15bf7c43a6d5f21cb;hpb=07faf07e3acb8b2afdc2bf65a46bc868faaed0f8;p=Mograsim.git diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Splitter.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Splitter.java index 9eb5b2c0..04658fe4 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Splitter.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Splitter.java @@ -2,13 +2,14 @@ package net.mograsim.logic.core.components; import java.util.List; +import net.mograsim.logic.core.LogicObservable; +import net.mograsim.logic.core.LogicObserver; import net.mograsim.logic.core.timeline.Timeline; import net.mograsim.logic.core.types.BitVector; -import net.mograsim.logic.core.wires.WireObserver; import net.mograsim.logic.core.wires.Wire.ReadEnd; import net.mograsim.logic.core.wires.Wire.ReadWriteEnd; -public class Splitter extends Component implements WireObserver +public class Splitter extends Component implements LogicObserver { private ReadEnd input; private ReadWriteEnd[] outputs; @@ -18,14 +19,14 @@ public class Splitter extends Component implements WireObserver super(timeline); this.input = input; this.outputs = outputs; - input.addObserver(this); - int length = 0; + input.registerObserver(this); + int width = 0; for (ReadEnd out : outputs) - length += out.length(); + width += out.width(); - if (input.length() != length) + if (input.width() != width) throw new IllegalArgumentException( - "The input of splitting one into n WireArrays must have length = a1.length() + a2.length() + ... + an.length()."); + "The input of splitting one into n WireArrays must have width = a1.width() + a2.width() + ... + an.width()."); } protected void compute() @@ -34,13 +35,13 @@ public class Splitter extends Component implements WireObserver int startIndex = 0; for (int i = 0; i < outputs.length; i++) { - outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].length())); - startIndex += outputs[i].length(); + outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].width())); + startIndex += outputs[i].width(); } } @Override - public void update(ReadEnd initiator, BitVector oldValues) + public void update(LogicObservable initiator) { compute(); }