X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2Fgates%2FNotGate.java;fp=era.mi%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2Fgates%2FNotGate.java;h=b1cfefee2a4434092f4ef3576becac0add039ead;hb=0009789a8df6b8d4562b6e1cbfa75102a7516ea8;hp=0000000000000000000000000000000000000000;hpb=a28f7aa0dab4248e99159c5a647676170cb17a4e;p=Mograsim.git diff --git a/era.mi/src/net/mograsim/logic/core/components/gates/NotGate.java b/era.mi/src/net/mograsim/logic/core/components/gates/NotGate.java new file mode 100644 index 00000000..b1cfefee --- /dev/null +++ b/era.mi/src/net/mograsim/logic/core/components/gates/NotGate.java @@ -0,0 +1,50 @@ +package net.mograsim.logic.core.components.gates; + +import java.util.List; + +import net.mograsim.logic.core.components.BasicComponent; +import net.mograsim.logic.core.timeline.Timeline; +import net.mograsim.logic.core.wires.Wire.ReadEnd; +import net.mograsim.logic.core.wires.Wire.ReadWriteEnd; + +public class NotGate extends BasicComponent +{ + private ReadEnd in; + private ReadWriteEnd out; + + public NotGate(Timeline timeline, int processTime, ReadEnd in, ReadWriteEnd out) + { + super(timeline, processTime); + this.in = in; + in.addObserver(this); + this.out = out; + } + + @Override + protected void compute() + { + out.feedSignals(in.getValues().not()); + } + + public ReadEnd getIn() + { + return in; + } + + public ReadEnd getOut() + { + return out; + } + + @Override + public List getAllInputs() + { + return List.of(in); + } + + @Override + public List getAllOutputs() + { + return List.of(out); + } +}