Renamed core components to have the common prefix Core
[Mograsim.git] / net.mograsim.logic.core / src / net / mograsim / logic / core / components / gates / CoreNotGate.java
diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/CoreNotGate.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/CoreNotGate.java
new file mode 100644 (file)
index 0000000..57f3a18
--- /dev/null
@@ -0,0 +1,50 @@
+package net.mograsim.logic.core.components.gates;
+
+import java.util.List;
+
+import net.mograsim.logic.core.components.BasicCoreComponent;
+import net.mograsim.logic.core.timeline.Timeline;
+import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
+import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
+
+public class CoreNotGate extends BasicCoreComponent
+{
+       private ReadEnd in;
+       private ReadWriteEnd out;
+
+       public CoreNotGate(Timeline timeline, int processTime, ReadEnd in, ReadWriteEnd out)
+       {
+               super(timeline, processTime);
+               this.in = in;
+               in.registerObserver(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<ReadEnd> getAllInputs()
+       {
+               return List.of(in);
+       }
+
+       @Override
+       public List<ReadWriteEnd> getAllOutputs()
+       {
+               return List.of(out);
+       }
+}