diff options
author | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2024-06-12 17:53:22 +0200 |
---|---|---|
committer | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2024-06-12 17:53:22 +0200 |
commit | 40c827da8e00a88a095f99786254493450a57065 (patch) | |
tree | 63f76a303d4f4de0bfd446a107c38774d7702a1b | |
parent | d1e381e301bb55432997ff355b5c938e76cd4f20 (diff) |
nand
-rw-r--r-- | GateAnd.h | 6 | ||||
-rw-r--r-- | GateNand.cpp | 19 | ||||
-rw-r--r-- | GateNand.h | 15 | ||||
-rw-r--r-- | NodeInput.h | 2 |
4 files changed, 40 insertions, 2 deletions
@@ -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: |