From a7eb10e81568b65c39d6e1d042309916a9180a2b Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:00:51 +0200 Subject: WIP simulate starter --- Circuit.cpp | 6 ++++++ Circuit.h | 7 ++++--- 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 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 nodes); - void new_node(string label, string type); - void new_net(string src, vector dests); + virtual void create(string label, vector nodes); + virtual void new_node(string label, string type); + virtual void new_net(string src, vector dests); + virtual void sim(); private: std::map 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; -- cgit v1.2.3