From f134abd08ccfdb1ece39df4d4a0e422419bd2fed Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:19:46 +0200 Subject: Created In/output nodes --- NodeInput.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 NodeInput.h (limited to 'NodeInput.h') diff --git a/NodeInput.h b/NodeInput.h new file mode 100644 index 0000000..73ef6e1 --- /dev/null +++ b/NodeInput.h @@ -0,0 +1,43 @@ +#pragma once + +#include "Node.h" + +class NodeInput : public Node { +public: + NodeInput() = default; + NodeInput(const NodeInput * prototype); + ~NodeInput() = default; + virtual void compare(); + virtual NodeInput * clone() const; + +private: + NodeInput(const char * type); + + SignalLevel level = UNDEFINED; +}; + +// Input LOW and HIGH unicorns: + +class NodeInputLow : public NodeInput { +public: + // NodeInputLow(const NodeInputLow * prototype); + // ~NodeInputLow() = default; + // virtual void compare(); + // virtual NodeInputLow * clone() const; + +private: + NodeInputLow(const char * type); + constexpr static const char * type = "input_low"; + static NodeInputLow instance; + + SignalLevel level = LOW; +}; + +class NodeInputHigh : public NodeInput { +private: + NodeInputHigh(const char * type); + constexpr static const char * type = "input_high"; + static NodeInputHigh instance; + + SignalLevel level = HIGH; +}; -- cgit v1.2.3 From 6fd8dcb9e0d33f7660c4e3a602a5c2a2b5091a7c Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:34:39 +0200 Subject: renamed compare function to sim function --- GateAnd.cpp | 2 +- GateAnd.h | 5 +++-- Node.cpp | 2 +- Node.h | 2 +- NodeInput.cpp | 6 ++++-- NodeInput.h | 2 +- NodeOutput.cpp | 6 ++++-- NodeOutput.h | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) (limited to 'NodeInput.h') diff --git a/GateAnd.cpp b/GateAnd.cpp index 6f19d61..93edacb 100644 --- a/GateAnd.cpp +++ b/GateAnd.cpp @@ -4,7 +4,7 @@ GateAnd GateAnd::instance(GateAnd::type); GateAnd::GateAnd(const char * type) : Node(type) { } -void GateAnd::compare() { +void GateAnd::sim() { SignalLevel new_out = HIGH; // TODO: fix segfault somewhere below for (int i = 0; i < this->inputs.size(); i++){ diff --git a/GateAnd.h b/GateAnd.h index 5eedc07..12dad53 100644 --- a/GateAnd.h +++ b/GateAnd.h @@ -4,9 +4,10 @@ class GateAnd : public Node { public: + GateAnd() = default; GateAnd(const GateAnd * prototype); - virtual ~GateAnd() = default; - virtual void compare(); + ~GateAnd() = default; + virtual void sim(); virtual GateAnd * clone() const; private: diff --git a/Node.cpp b/Node.cpp index 1b0b9b8..d3564da 100644 --- a/Node.cpp +++ b/Node.cpp @@ -18,6 +18,6 @@ void Node::setOutput(Net * net){ void Node::update(){ std::cout << "updated" << std::endl; - this->compare(); + this->sim(); } diff --git a/Node.h b/Node.h index e6270a7..36da279 100644 --- a/Node.h +++ b/Node.h @@ -19,7 +19,7 @@ public: void update(); virtual void addInput(Net *); virtual void setOutput(Net *); - virtual void compare() = 0; + virtual void sim() = 0; int gert = 45; protected: diff --git a/NodeInput.cpp b/NodeInput.cpp index 046cd72..17f9ed5 100644 --- a/NodeInput.cpp +++ b/NodeInput.cpp @@ -1,10 +1,12 @@ #include "NodeInput.h" +#include + NodeInput::NodeInput(const char * type) : Node(type) { } -void NodeInput::compare() { +void NodeInput::sim() { if (this->output == nullptr) return; - + std::cout << this->level << " bar\n"; this->output->setLevel(this->level); } diff --git a/NodeInput.h b/NodeInput.h index 73ef6e1..bcca8f4 100644 --- a/NodeInput.h +++ b/NodeInput.h @@ -7,7 +7,7 @@ public: NodeInput() = default; NodeInput(const NodeInput * prototype); ~NodeInput() = default; - virtual void compare(); + virtual void sim(); virtual NodeInput * clone() const; private: diff --git a/NodeOutput.cpp b/NodeOutput.cpp index cff66c0..d47b6a3 100644 --- a/NodeOutput.cpp +++ b/NodeOutput.cpp @@ -5,9 +5,11 @@ NodeOutput NodeOutput::instance(NodeOutput::type); NodeOutput::NodeOutput(const char * type) : Node(type) { } -void NodeOutput::compare() { +void NodeOutput::sim() { if (this->inputs.size() > 0) { - std::cout << this->inputs[0]->getLevel() << std::endl; + std::cout << this->inputs[0]->getLevel() << "foo" << std::endl; + } else { + std::cout << "err: No inputs on probe" << std::endl; } } diff --git a/NodeOutput.h b/NodeOutput.h index 4e7f742..2e92bf0 100644 --- a/NodeOutput.h +++ b/NodeOutput.h @@ -6,7 +6,7 @@ class NodeOutput : public Node { public: NodeOutput(const NodeOutput * prototype); ~NodeOutput() = default; - virtual void compare(); + virtual void sim(); virtual NodeOutput * clone() const; private: -- cgit v1.2.3