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.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 NodeInput.cpp (limited to 'NodeInput.cpp') diff --git a/NodeInput.cpp b/NodeInput.cpp new file mode 100644 index 0000000..046cd72 --- /dev/null +++ b/NodeInput.cpp @@ -0,0 +1,26 @@ +#include "NodeInput.h" + +NodeInput::NodeInput(const char * type) : Node(type) { } + +void NodeInput::compare() { + if (this->output == nullptr) return; + + this->output->setLevel(this->level); +} + +NodeInput::NodeInput(const NodeInput * prototype) : Node() { } + +NodeInput * NodeInput::clone() const { + return new NodeInput(this); +} + +// INPUT_LOW +NodeInputLow NodeInputLow::instance(NodeInputLow::type); +NodeInputLow::NodeInputLow(const char * type) : NodeInput() { } + +// NodeInputLow::NodeInputLow(const NodeInputLow * prototype) : NodeInput() { } + +// // INPUT_HIGH +// NodeInputHigh NodeInputHigh::instance(NodeInputHigh::type); +// NodeInputHigh::NodeInputHigh(const char * type) : NodeInput(type) { } +// NodeInputHigh::NodeInputHigh(const NodeInputHigh * prototype) : NodeInput() { } -- 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.cpp') 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