1 package era.mi.logic.components.gates;
5 import era.mi.logic.components.BasicComponent;
6 import era.mi.logic.types.BitVector.BitVectorMutator;
7 import era.mi.logic.types.MutationOperation;
8 import era.mi.logic.wires.Wire.ReadEnd;
9 import era.mi.logic.wires.Wire.ReadWriteEnd;
11 public abstract class MultiInputGate extends BasicComponent
13 protected ReadEnd[] in;
14 protected ReadWriteEnd out;
15 protected final int length;
16 protected MutationOperation op;
18 protected MultiInputGate(int processTime, MutationOperation op, ReadWriteEnd out, ReadEnd... in)
22 length = out.length();
25 throw new IllegalArgumentException(String.format("Cannot create gate with %d wires.", in.length));
28 if (w.length() != length)
29 throw new IllegalArgumentException("All wires connected to the gate must be of uniform length.");
36 public List<ReadEnd> getAllInputs()
42 public List<ReadWriteEnd> getAllOutputs()
48 protected void compute()
50 BitVectorMutator mutator = BitVectorMutator.empty();
52 op.apply(mutator, w.getValues());
53 out.feedSignals(mutator.get());