1 package era.mi.logic.components;
3 import era.mi.logic.types.BitVector;
4 import era.mi.logic.wires.Wire;
5 import era.mi.logic.wires.Wire.WireEnd;
6 import era.mi.logic.wires.WireObserver;
8 public class Splitter implements WireObserver
10 private WireEnd input;
11 private WireEnd[] outputs;
13 public Splitter(WireEnd input, WireEnd... outputs)
16 this.outputs = outputs;
17 input.addObserver(this);
19 for (WireEnd out : outputs)
20 length += out.length();
22 if (input.length() != length)
23 throw new IllegalArgumentException(
24 "The input of splitting one into n WireArrays must have length = a1.length() + a2.length() + ... + an.length().");
27 protected void compute()
29 BitVector inputBits = input.getValues();
31 for (int i = 0; i < outputs.length; i++)
33 outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].length()));
34 startIndex += outputs[i].length();
39 public void update(Wire initiator, BitVector oldValues)