X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2Fgates%2FMultiInputGate.java;fp=era.mi%2Fsrc%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2Fgates%2FMultiInputGate.java;h=0000000000000000000000000000000000000000;hb=0009789a8df6b8d4562b6e1cbfa75102a7516ea8;hp=40b10780594c0adaa2c9dfa472f6658cc91d0501;hpb=a28f7aa0dab4248e99159c5a647676170cb17a4e;p=Mograsim.git diff --git a/era.mi/src/mograsim/logic/core/components/gates/MultiInputGate.java b/era.mi/src/mograsim/logic/core/components/gates/MultiInputGate.java deleted file mode 100644 index 40b10780..00000000 --- a/era.mi/src/mograsim/logic/core/components/gates/MultiInputGate.java +++ /dev/null @@ -1,56 +0,0 @@ -package mograsim.logic.core.components.gates; - -import java.util.List; - -import mograsim.logic.core.components.BasicComponent; -import mograsim.logic.core.timeline.Timeline; -import mograsim.logic.core.types.MutationOperation; -import mograsim.logic.core.types.BitVector.BitVectorMutator; -import mograsim.logic.core.wires.Wire.ReadEnd; -import mograsim.logic.core.wires.Wire.ReadWriteEnd; - -public abstract class MultiInputGate extends BasicComponent -{ - protected ReadEnd[] in; - protected ReadWriteEnd out; - protected final int length; - protected MutationOperation op; - - protected MultiInputGate(Timeline timeline, int processTime, MutationOperation op, ReadWriteEnd out, ReadEnd... in) - { - super(timeline, processTime); - this.op = op; - length = out.length(); - 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.length() != length) - throw new IllegalArgumentException("All wires connected to the gate must be of uniform length."); - w.addObserver(this); - } - this.out = out; - } - - @Override - public List getAllInputs() - { - return List.of(in); - } - - @Override - public List getAllOutputs() - { - return List.of(out); - } - - @Override - protected void compute() - { - BitVectorMutator mutator = BitVectorMutator.empty(); - for (ReadEnd w : in) - op.apply(mutator, w.getValues()); - out.feedSignals(mutator.get()); - } -}