X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2Fgates%2FMultiInputCoreGate.java;fp=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2Fgates%2FMultiInputCoreGate.java;h=0000000000000000000000000000000000000000;hb=7d05144c25daa53e60fc9ed9fd503546a86567f8;hp=010ae74f9cd463d649491f3b90c43878cba4a2e4;hpb=8bed58cd47f4e53a0a83e066d38864aa6875502f;p=Mograsim.git diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/MultiInputCoreGate.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/MultiInputCoreGate.java deleted file mode 100644 index 010ae74f..00000000 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/MultiInputCoreGate.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.mograsim.logic.core.components.gates; - -import java.util.List; - -import net.mograsim.logic.core.components.BasicCoreComponent; -import net.mograsim.logic.core.timeline.Timeline; -import net.mograsim.logic.core.timeline.TimelineEventHandler; -import net.mograsim.logic.core.types.BitVector.BitVectorMutator; -import net.mograsim.logic.core.types.MutationOperation; -import net.mograsim.logic.core.wires.CoreWire.ReadEnd; -import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd; - -public abstract class MultiInputCoreGate extends BasicCoreComponent -{ - protected ReadEnd[] in; - protected ReadWriteEnd out; - protected final int width; - protected MutationOperation op; - protected boolean invert = false; - - protected MultiInputCoreGate(Timeline timeline, int processTime, MutationOperation op, ReadWriteEnd out, ReadEnd... in) - { - super(timeline, processTime); - this.op = op; - width = out.width(); - this.in = in.clone(); - if (in.length < 1) - throw new IllegalArgumentException(String.format("Cannot create gate with %d wires.", in.length)); - for (ReadEnd w : in) - { - if (w.width() != width) - throw new IllegalArgumentException("All wires connected to the gate must be of uniform length."); - w.registerObserver(this); - } - this.out = out; - } - - protected MultiInputCoreGate(Timeline timeline, int processTime, MutationOperation op, boolean invert, ReadWriteEnd out, ReadEnd... in) - { - this(timeline, processTime, op, out, in); - this.invert = invert; - } - - @Override - public List getAllInputs() - { - return List.of(in); - } - - @Override - public List getAllOutputs() - { - return List.of(out); - } - - @Override - public TimelineEventHandler compute() - { - BitVectorMutator mutator = BitVectorMutator.empty(); - for (ReadEnd w : in) - op.apply(mutator, w.getValues()); - return e -> out.feedSignals(invert ? mutator.toBitVector().not() : mutator.toBitVector()); - } -}