aboutsummaryrefslogtreecommitdiff
path: root/Node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Node.cpp')
-rw-r--r--Node.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/Node.cpp b/Node.cpp
index 75f94e5..4ba3961 100644
--- a/Node.cpp
+++ b/Node.cpp
@@ -17,8 +17,22 @@ void Node::setOutput(Net * net){
this->output = net;
}
+void Node::sim() {
+ size_t input_size = this->inputs.size();
+ if (this->min_inputs >= 0 && input_size < min_inputs)
+ throw CircuitException("Too few inputs");
+ if (this->max_inputs >= 0 && input_size > max_inputs)
+ throw CircuitException("Too many inputs");
+
+ SignalLevel new_out = this->level();
+
+ if (new_out == UNDEFINED) return;
+ if (this->output->getLevel() == new_out) return;
+
+ this->output->setLevel(new_out);
+}
+
void Node::update(){
- std::cout << "updated" << std::endl;
this->sim();
}