diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-12 12:14:51 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-12 12:14:51 +0200 |
commit | 2b941bc1b28e0a60da50baa0875d7cb05c0632c1 (patch) | |
tree | 495dff0f929cc2588273fb838fc46380fa8578cc /GateAnd.cpp | |
parent | 2acd9a0097bb89e4b10ff77848d314e60f27be54 (diff) |
WIP connect nets
Diffstat (limited to 'GateAnd.cpp')
-rw-r--r-- | GateAnd.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/GateAnd.cpp b/GateAnd.cpp index dc65353..6f19d61 100644 --- a/GateAnd.cpp +++ b/GateAnd.cpp @@ -4,31 +4,28 @@ GateAnd GateAnd::instance(GateAnd::type); GateAnd::GateAnd(const char * type) : Node(type) { } -// Concrete Nodes: void GateAnd::compare() { SignalLevel new_out = HIGH; -// TODO fix segfault somewhere below -// for (int i = 0; i < this->inputs.size(); i++){ -// switch (this->inputs[i]->getLevel()){ -// case LOW: -// new_out = LOW; -// break; -// case HIGH: -// continue; -// break; -// case UNDEFINED: -// default: -// new_out = UNDEFINED; -// exit; -// break; -// } -// } - -// if (this->output->getLevel() == new_out){ -// /* do nothing */ -// } else { -// this->output->setLevel(new_out); -// } + // TODO: fix segfault somewhere below + for (int i = 0; i < this->inputs.size(); i++){ + switch (this->inputs[i]->getLevel()){ + case LOW: + new_out = LOW; + break; + case HIGH: + continue; + break; + case UNDEFINED: + default: + new_out = UNDEFINED; + // TODO: exception!! + break; + } + } + + if (this->output->getLevel() == new_out) return; + + this->output->setLevel(new_out); } GateAnd::GateAnd(const GateAnd * prototype) : Node() { } |