aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 14:00:51 +0200
committerUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 14:00:51 +0200
commita7eb10e81568b65c39d6e1d042309916a9180a2b (patch)
treeafb929ada2ce1249ff7b3c9cb3c53c086b671dff
parent064512cb02465ec598e46ae4bc7947395ed66dc2 (diff)
WIP simulate starter
-rw-r--r--Circuit.cpp6
-rw-r--r--Circuit.h7
-rw-r--r--main.cpp12
3 files changed, 16 insertions, 9 deletions
diff --git a/Circuit.cpp b/Circuit.cpp
index 7da9384..23f49a6 100644
--- a/Circuit.cpp
+++ b/Circuit.cpp
@@ -35,6 +35,12 @@ void Circuit::new_net(string src, vector<string> dests) {
node->setOutput(net);
}
+void Circuit::sim() {
+ for (auto & node : nodes) {
+ node.second->sim();
+ }
+}
+
Node * Circuit::find_node(string label) {
auto map_index = this->nodes.find(label);
if (map_index == nodes.end()) return nullptr;
diff --git a/Circuit.h b/Circuit.h
index 1806293..0cc08c6 100644
--- a/Circuit.h
+++ b/Circuit.h
@@ -16,9 +16,10 @@ public:
virtual ~Circuit();
public:
- void create(string label, vector<string> nodes);
- void new_node(string label, string type);
- void new_net(string src, vector<string> dests);
+ virtual void create(string label, vector<string> nodes);
+ virtual void new_node(string label, string type);
+ virtual void new_net(string src, vector<string> dests);
+ virtual void sim();
private:
std::map<string, Node *> nodes = {};
diff --git a/main.cpp b/main.cpp
index 01ddeb7..728155f 100644
--- a/main.cpp
+++ b/main.cpp
@@ -24,12 +24,12 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
- // try {
- // circuit.run();
- // } catch (exception& e) {
- // cout << "Circuit error: " << e.what() << endl;
- // return EXIT_FAILURE;
- // }
+ try {
+ circuit.sim();
+ } catch (CircuitException& e) {
+ cout << "Circuit error: " << e.what() << endl;
+ return EXIT_FAILURE;
+ }
// cout << "Circuit output: " << circuit.getOutput() << endl;