X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Fcomponents%2FBasicComponent.java;h=7b4069c6ea9b3c4db4c31f9835c0d32b44e280e4;hb=72b00816f86e5d34d871c87fea76a94ffca25246;hp=ad93dfe2f990929e0c560d76f60a70fa555b5102;hpb=7f0a08228f5c517aa1aa22453c1b0dd533e4cd04;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/components/BasicComponent.java b/era.mi/src/era/mi/logic/components/BasicComponent.java index ad93dfe2..7b4069c6 100644 --- a/era.mi/src/era/mi/logic/components/BasicComponent.java +++ b/era.mi/src/era/mi/logic/components/BasicComponent.java @@ -1,29 +1,34 @@ -package era.mi.logic.components; - -import era.mi.logic.Simulation; -import era.mi.logic.WireArray; -import era.mi.logic.WireArrayObserver; - -public abstract class BasicComponent implements WireArrayObserver -{ - private int processTime; - - /** - * - * @param processTime Amount of time this component takes to update its outputs. Must be more than 0, otherwise 1 is assumed. - * - * @author Fabian Stemmler - */ - public BasicComponent(int processTime) - { - this.processTime = processTime > 0 ? processTime : 1; - } - - @Override - public void update(WireArray initiator) - { - Simulation.TIMELINE.addEvent((e) -> {compute();}, processTime); - } - - protected abstract void compute(); -} +package era.mi.logic.components; + +import era.mi.logic.Bit; +import era.mi.logic.Simulation; +import era.mi.logic.wires.WireArray; +import era.mi.logic.wires.WireArrayObserver; + +/** + * A basic component that recomputes all outputs (with a delay), when it is updated. + * + * @author Fabian Stemmler + */ +public abstract class BasicComponent implements WireArrayObserver, Component { + private int processTime; + + /** + * + * @param processTime Amount of time this component takes to update its outputs. Must be more than 0, otherwise 1 is assumed. + * + * @author Fabian Stemmler + */ + public BasicComponent(int processTime) { + this.processTime = processTime > 0 ? processTime : 1; + } + + @Override + public void update(WireArray initiator, Bit[] oldValues) { + Simulation.TIMELINE.addEvent((e) -> { + compute(); + }, processTime); + } + + protected abstract void compute(); +}