diff options
author | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2024-06-12 14:00:51 +0200 |
---|---|---|
committer | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2024-06-12 14:00:51 +0200 |
commit | a7eb10e81568b65c39d6e1d042309916a9180a2b (patch) | |
tree | afb929ada2ce1249ff7b3c9cb3c53c086b671dff | |
parent | 064512cb02465ec598e46ae4bc7947395ed66dc2 (diff) |
WIP simulate starter
-rw-r--r-- | Circuit.cpp | 6 | ||||
-rw-r--r-- | Circuit.h | 7 | ||||
-rw-r--r-- | main.cpp | 12 |
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; @@ -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 = {}; @@ -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; |