import era.mi.logic.wires.WireArray;
import era.mi.logic.wires.WireArray.WireArrayInput;
-public class Clock implements TimelineEventHandler, Component
-{
+public class Clock implements TimelineEventHandler, Component {
private boolean toggle = false;
private WireArrayInput outI;
private int delta;
-
+
/**
*
- * @param out {@link WireArray} the clock's impulses are fed into
+ * @param out {@link WireArray} the clock's impulses are fed into
* @param delta ticks between rising and falling edge
*/
- public Clock(WireArray out, int delta)
- {
+ public Clock(WireArray out, int delta) {
this.delta = delta;
this.outI = out.createInput();
Simulation.TIMELINE.addEvent(this, 50);
}
@Override
- public void handle(TimelineEvent e)
- {
+ public void handle(TimelineEvent e) {
addToTimeline();
outI.feedSignals(new Bit[] { toggle ? Bit.ONE : Bit.ZERO });
toggle = !toggle;
}
- public WireArray getOut()
- {
+ public WireArray getOut() {
return outI.owner;
}
-
- private void addToTimeline()
- {
+
+ private void addToTimeline() {
Simulation.TIMELINE.addEvent(this, delta);
}
@Override
- public List<WireArray> getAllInputs()
- {
+ public List<WireArray> getAllInputs() {
return Collections.unmodifiableList(Arrays.asList());
}
@Override
- public List<WireArray> getAllOutputs()
- {
+ public List<WireArray> getAllOutputs() {
return Collections.unmodifiableList(Arrays.asList(outI.owner));
}
}