X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2FSplitter.java;fp=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2FSplitter.java;h=0000000000000000000000000000000000000000;hb=4db274c53e53cda8321067eca57d524f188c2e6f;hp=04658fe4ec2077fcf318fdb1489a3c5770bfb63f;hpb=0ab3dafe756a69ff8b1e0137058caf2f5ac564aa;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 deleted file mode 100644 index 04658fe4..00000000 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Splitter.java +++ /dev/null @@ -1,60 +0,0 @@ -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.Wire.ReadEnd; -import net.mograsim.logic.core.wires.Wire.ReadWriteEnd; - -public class Splitter extends Component implements LogicObserver -{ - private ReadEnd input; - private ReadWriteEnd[] outputs; - - public Splitter(Timeline timeline, ReadEnd input, ReadWriteEnd... outputs) - { - super(timeline); - this.input = input; - this.outputs = outputs; - input.registerObserver(this); - int width = 0; - for (ReadEnd out : outputs) - width += out.width(); - - if (input.width() != width) - throw new IllegalArgumentException( - "The input of splitting one into n WireArrays must have width = a1.width() + a2.width() + ... + an.width()."); - } - - protected void compute() - { - BitVector inputBits = input.getValues(); - int startIndex = 0; - for (int i = 0; i < outputs.length; i++) - { - outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].width())); - startIndex += outputs[i].width(); - } - } - - @Override - public void update(LogicObservable initiator) - { - compute(); - } - - @Override - public List getAllInputs() - { - return List.of(input); - } - - @Override - public List getAllOutputs() - { - return List.of(outputs); - } -}