aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-15 19:55:38 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-15 19:55:38 +0200
commitbdb2d85a244b5ebb462c8b9763a3b539b0cc68f3 (patch)
tree509dfba9ebe74c3a128d0ae8c7be56a40b49adf0
parentcc85e73456fee27236f0fa18ad7bc9ccd6877c19 (diff)
WIP WIP WIP
-rw-r--r--GateAnd.h2
-rw-r--r--GateNot.cpp6
-rw-r--r--GateNot.h13
-rw-r--r--GateOr.h4
-rw-r--r--GateXor.h4
-rw-r--r--Node.h4
-rw-r--r--NodeOutput.cpp12
-rw-r--r--NodeOutput.h7
8 files changed, 20 insertions, 32 deletions
diff --git a/GateAnd.h b/GateAnd.h
index 2991c1d..df456dd 100644
--- a/GateAnd.h
+++ b/GateAnd.h
@@ -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);
}
+
diff --git a/GateNot.h b/GateNot.h
index 55fd9ce..2a185f9 100644
--- a/GateNot.h
+++ b/GateNot.h
@@ -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;
};
diff --git a/GateOr.h b/GateOr.h
index 0668148..bc96b24 100644
--- a/GateOr.h
+++ b/GateOr.h
@@ -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;
};
diff --git a/GateXor.h b/GateXor.h
index 37903e0..b70d552 100644
--- a/GateXor.h
+++ b/GateXor.h
@@ -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;
};
diff --git a/Node.h b/Node.h
index bb41b26..64c5b2b 100644
--- a/Node.h
+++ b/Node.h
@@ -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: