import java.util.List;
+import net.mograsim.logic.core.LogicObservable;
+import net.mograsim.logic.core.LogicObserver;
import net.mograsim.logic.core.timeline.Timeline;
import net.mograsim.logic.core.types.BitVector;
-import net.mograsim.logic.core.wires.WireObserver;
import net.mograsim.logic.core.wires.Wire.ReadEnd;
import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
-public class Splitter extends Component implements WireObserver
+public class Splitter extends Component implements LogicObserver
{
private ReadEnd input;
private ReadWriteEnd[] outputs;
super(timeline);
this.input = input;
this.outputs = outputs;
- input.addObserver(this);
- int length = 0;
+ input.registerObserver(this);
+ int width = 0;
for (ReadEnd out : outputs)
- length += out.length();
+ width += out.width();
- if (input.length() != length)
+ if (input.width() != width)
throw new IllegalArgumentException(
- "The input of splitting one into n WireArrays must have length = a1.length() + a2.length() + ... + an.length().");
+ "The input of splitting one into n WireArrays must have width = a1.width() + a2.width() + ... + an.width().");
}
protected void compute()
int startIndex = 0;
for (int i = 0; i < outputs.length; i++)
{
- outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].length()));
- startIndex += outputs[i].length();
+ outputs[i].feedSignals(inputBits.subVector(startIndex, startIndex + outputs[i].width()));
+ startIndex += outputs[i].width();
}
}
@Override
- public void update(ReadEnd initiator, BitVector oldValues)
+ public void update(LogicObservable initiator)
{
compute();
}