diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-15 19:55:38 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-15 19:55:38 +0200 |
commit | bdb2d85a244b5ebb462c8b9763a3b539b0cc68f3 (patch) | |
tree | 509dfba9ebe74c3a128d0ae8c7be56a40b49adf0 | |
parent | cc85e73456fee27236f0fa18ad7bc9ccd6877c19 (diff) |
WIP WIP WIP
-rw-r--r-- | GateAnd.h | 2 | ||||
-rw-r--r-- | GateNot.cpp | 6 | ||||
-rw-r--r-- | GateNot.h | 13 | ||||
-rw-r--r-- | GateOr.h | 4 | ||||
-rw-r--r-- | GateXor.h | 4 | ||||
-rw-r--r-- | Node.h | 4 | ||||
-rw-r--r-- | NodeOutput.cpp | 12 | ||||
-rw-r--r-- | NodeOutput.h | 7 |
8 files changed, 20 insertions, 32 deletions
@@ -11,8 +11,6 @@ public: protected: SignalLevel level(); - int min_inputs = 0; - int max_inputs = -1; using Node::Node; private: diff --git a/GateNot.cpp b/GateNot.cpp index a29744f..04e701d 100644 --- a/GateNot.cpp +++ b/GateNot.cpp @@ -9,8 +9,12 @@ SignalLevel GateNot::level() { return UNDEFINED; } -GateNot::GateNot(const GateNot * prototype) : Node() { } +GateNot::GateNot(const GateNot * prototype) : Node() { + this->min_inputs = 1; + this->max_inputs = 1; +} GateNot * GateNot::clone() const { return new GateNot(this); } + @@ -4,19 +4,14 @@ class GateNot : public Node { public: - GateNot() = default; + GateNot(); GateNot(const GateNot * prototype); - ~GateNot() = default; + virtual ~GateNot() = default; virtual GateNot * clone() const; - -private: SignalLevel level(); +private: using Node::Node; - constexpr static const char * type = "Not"; + constexpr static const char * type = "not"; static GateNot instance; - -private: - int min_inputs = 1; - int max_inputs = 1; }; @@ -16,9 +16,5 @@ private: using Node::Node; constexpr static const char * type = "or"; static GateOr instance; - -private: - int min_inputs = 0; - int max_inputs = -1; }; @@ -15,8 +15,4 @@ private: using Node::Node; constexpr static const char * type = "xor"; static GateXor instance; - -private: - int min_inputs = 1; - int max_inputs = -1; }; @@ -33,8 +33,8 @@ protected: Net * output = nullptr; protected: - int min_inputs = -1; - int max_inputs = -1; + int min_inputs = 1; + int max_inputs = -1; // unlimited public: virtual void accept(NodeVisitor & visitor) { visitor.visit(*this); } diff --git a/NodeOutput.cpp b/NodeOutput.cpp index cf1b979..883868d 100644 --- a/NodeOutput.cpp +++ b/NodeOutput.cpp @@ -3,19 +3,15 @@ NodeOutput NodeOutput::instance(NodeOutput::type); -NodeOutput::NodeOutput(const char * type) : Node(type) { init(); } - -void NodeOutput::init() { - this->min_inputs = 1; - this->max_inputs = 1; -} - void NodeOutput::sim() { Node::sim(); this->input = this->inputs[0]->getLevel(); } -NodeOutput::NodeOutput(const NodeOutput * prototype) : Node() { init(); } +NodeOutput::NodeOutput(const NodeOutput * prototype) : Node() { + this->min_inputs = 1; + this->max_inputs = 1; +} NodeOutput * NodeOutput::clone() const { return new NodeOutput(this); diff --git a/NodeOutput.h b/NodeOutput.h index d2319f1..83a8b34 100644 --- a/NodeOutput.h +++ b/NodeOutput.h @@ -7,16 +7,19 @@ public: NodeOutput(); NodeOutput(const NodeOutput * prototype); ~NodeOutput() = default; + virtual void sim(); virtual SignalLevel level(); virtual NodeOutput * clone() const; virtual void setOutput(Net *); + private: - virtual void init(); - NodeOutput(const char * type); + using Node::Node; constexpr static const char * type = "probe"; static NodeOutput instance; + +private: SignalLevel input; public: |