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.WireEnd;
10 public abstract class MultiInputGate extends BasicComponent
12 protected WireEnd[] in;
13 protected WireEnd out;
14 protected final int length;
15 protected MutationOperation op;
17 protected MultiInputGate(int processTime, MutationOperation op, WireEnd out, WireEnd... in)
21 length = out.length();
24 throw new IllegalArgumentException(String.format("Cannot create gate with %d wires.", in.length));
27 if (w.length() != length)
28 throw new IllegalArgumentException("All wires connected to the gate must be of uniform length.");
35 public List<WireEnd> getAllInputs()
41 public List<WireEnd> getAllOutputs()
47 protected void compute()
49 BitVectorMutator mutator = BitVectorMutator.empty();
51 op.apply(mutator, w.getValues());
52 out.feedSignals(mutator.get());