aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 17:53:22 +0200
committerUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 17:53:22 +0200
commit40c827da8e00a88a095f99786254493450a57065 (patch)
tree63f76a303d4f4de0bfd446a107c38774d7702a1b
parentd1e381e301bb55432997ff355b5c938e76cd4f20 (diff)
nand
-rw-r--r--GateAnd.h6
-rw-r--r--GateNand.cpp19
-rw-r--r--GateNand.h15
-rw-r--r--NodeInput.h2
4 files changed, 40 insertions, 2 deletions
diff --git a/GateAnd.h b/GateAnd.h
index a8cc3d0..639a93b 100644
--- a/GateAnd.h
+++ b/GateAnd.h
@@ -9,10 +9,14 @@ public:
~GateAnd() = default;
virtual GateAnd * clone() const;
-private:
+protected:
SignalLevel level();
+ int min_inputs = 0;
+ int max_inputs = -1;
GateAnd(const char * type);
+
+private:
constexpr static const char * type = "and";
static GateAnd instance;
};
diff --git a/GateNand.cpp b/GateNand.cpp
new file mode 100644
index 0000000..8ecb90f
--- /dev/null
+++ b/GateNand.cpp
@@ -0,0 +1,19 @@
+#include "GateNand.h"
+
+GateNand GateNand::instance(GateNand::type);
+
+// GateNand::GateNand(const char * type) : GateAnd(type) { }
+
+SignalLevel GateNand::level() {
+ SignalLevel lvl = GateAnd::level();
+ if (lvl == LOW) return HIGH;
+ if (lvl == HIGH) return LOW;
+ return UNDEFINED;
+}
+
+// GateNand::GateNand(const GateNand * prototype) : GateAnd() { }
+
+// GateNand * GateNand::clone() const {
+// return new GateNand(this);
+// }
+
diff --git a/GateNand.h b/GateNand.h
new file mode 100644
index 0000000..7158040
--- /dev/null
+++ b/GateNand.h
@@ -0,0 +1,15 @@
+#pragma once
+
+// #include "Node.h"
+#include "GateAnd.h"
+
+class GateNand : public GateAnd {
+private:
+ SignalLevel level();
+
+ // GateNand(const char * type);
+ using GateAnd::GateAnd;
+ constexpr static const char * type = "nand";
+ static GateNand instance;
+};
+
diff --git a/NodeInput.h b/NodeInput.h
index 71cf36c..82dfd4c 100644
--- a/NodeInput.h
+++ b/NodeInput.h
@@ -14,7 +14,7 @@ public:
private:
NodeInput(const char * type);
-SignalLevel input = UNDEFINED;
+ SignalLevel input = UNDEFINED;
};
// Input LOW and HIGH unicorns: