From 40c827da8e00a88a095f99786254493450a57065 Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:53:22 +0200 Subject: nand --- GateAnd.h | 6 +++++- GateNand.cpp | 19 +++++++++++++++++++ GateNand.h | 15 +++++++++++++++ NodeInput.h | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 GateNand.cpp create mode 100644 GateNand.h 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: -- cgit v1.2.3