From ce43bdba0131deb7ea6340471fbdad0666166d06 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 19:22:08 +0100 Subject: [PATCH 01/13] :sparkles: Add a function to print a Tristate --- src/IComponent.cpp | 15 ++++++++++++--- src/IComponent.hpp | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/IComponent.cpp b/src/IComponent.cpp index 18bf810..441acdf 100644 --- a/src/IComponent.cpp +++ b/src/IComponent.cpp @@ -8,11 +8,20 @@ #include "IComponent.hpp" -using namespace nts; - -Tristate nts::operator!(Tristate const &tristate) +nts::Tristate nts::operator!(Tristate const &tristate) { if (tristate == UNDEFINED) return UNDEFINED; return (tristate == TRUE) ? FALSE : TRUE; +} + +std::ostream &operator<<(std::ostream &os, nts::Tristate const &a) +{ + if (a == nts::UNDEFINED) + os << "U"; + else if (a == nts::TRUE) + os << "1"; + else + os << "0"; + return os; } \ No newline at end of file diff --git a/src/IComponent.hpp b/src/IComponent.hpp index 46080f2..83120d1 100644 --- a/src/IComponent.hpp +++ b/src/IComponent.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include namespace nts { enum Tristate { @@ -29,3 +30,5 @@ namespace nts { [[nodiscard]] virtual IComponent *clone() const = 0; }; } + +std::ostream &operator<<(std::ostream &os, nts::Tristate const &a); \ No newline at end of file From 2fe4b551d9d5275342fba720f32cabb2922461d7 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 19:23:10 +0100 Subject: [PATCH 02/13] :sparkles: Add a Simulation class to handle the execution of the program --- src/Simulation.cpp | 127 +++++++++++++++++++++++++++++++++++++++++++++ src/Simulation.hpp | 34 ++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 src/Simulation.cpp create mode 100644 src/Simulation.hpp diff --git a/src/Simulation.cpp b/src/Simulation.cpp new file mode 100644 index 0000000..d404726 --- /dev/null +++ b/src/Simulation.cpp @@ -0,0 +1,127 @@ +/* +** EPITECH PROJECT, 2024 +** NanoTekSpice +** File description: +** execSimulation +*/ + +#include "Simulation.hpp" +#include "Error.hpp" +#include "components/InputComponent.hpp" +// #include "OutputComponent.hpp" +// This include is in comments since the Output component is not implemented yet +#include +#include + +nts::Simulation::Simulation(std::map pins) +{ + this->_pins = pins; + this->_exit = false; + this->_commands["exit\n"] = &nts::Simulation::exit; + this->_commands["display\n"] = &nts::Simulation::display; + this->_commands["simulate\n"] = &nts::Simulation::simulate; + this->_commands["loop\n"] = &nts::Simulation::loop; + this->_ticks = 0; +} + +nts::Simulation::~Simulation() +{ +} + +void nts::Simulation::execSimulation() +{ + char *line = NULL; + size_t len = 0; + + while (!this->_exit) { + std::cout << "> " << std::flush; + if (getline(&line, &len, stdin) == -1) + return; + if (isKnownCommand(line)) + continue; + else + std::cout << "Unknown command." << std::endl; + } +} + +void nts::Simulation::stopLoop() +{ + this->_loop = false; +} + +bool nts::Simulation::isKnownCommand(char *line) +{ + std::string str = line; + if (this->_commands[line] != nullptr) { + (this->*_commands[line])(); + return true; + } + return false; +} + +void nts::Simulation::exit() +{ + this->_exit = true; +} + +void nts::Simulation::display() +{ + std::cout << "tick: " << this->_ticks << std::endl; + std::cout << "input(s):" << std::endl; + for (auto &pin : this->_pins) { + if (dynamic_cast(pin.second) != nullptr) + std::cout << " " << pin.first << ": " << pin.second->compute(1) << std::endl; + } + std::cout << "output(s):" << std::endl; + // for (auto &pin : this->_pins) { + // if (dynamic_cast(pin.second) == nullptr) + // std::cout << " " << pin.first << ": " << pin.second->compute(1) << std::endl; + // } + // This part is in comments since the Output component is not implemented yet +} + +void nts::Simulation::simulate() +{ + for (auto &pin : this->_pins) { + pin.second->simulate(this->_ticks); + } + // for (auto &pin : this->_pins) { + // if (dynamic_cast(pin.second) != nullptr) + // pin.second->compute(1); + // } + // This part is in comments since the Output component is not implemented yet + this->_ticks++; +} + +static void handleLoop(void *arg) +{ + static nts::Simulation *sim; + + if (arg == NULL && sim == NULL) + return; + if (arg != NULL) + sim = (nts::Simulation *)arg; + if (arg == NULL) + sim->stopLoop(); +} + +static void signalHandler(int signum) +{ + if (signum == SIGINT) + handleLoop(NULL); +} + +void nts::Simulation::loop() +{ + struct sigaction sigIntHandler; + + sigIntHandler.sa_handler = signalHandler; + this->_loop = true; + handleLoop(this); + while (this->_loop) { + simulate(); + display(); + sleep(1); + sigaction(SIGINT, &sigIntHandler, NULL); + } +} diff --git a/src/Simulation.hpp b/src/Simulation.hpp new file mode 100644 index 0000000..73c60bf --- /dev/null +++ b/src/Simulation.hpp @@ -0,0 +1,34 @@ +/* +** EPITECH PROJECT, 2024 +** NanoTekSpice +** File description: +** Simulation +*/ + +#pragma once + +#include "FileContainer.hpp" + +namespace nts { + class Simulation { + public: + Simulation(std::map); + ~Simulation(); + + void execSimulation(); + void stopLoop(void); + protected: + private: + std::map _pins; + std::unordered_map _commands; + bool _exit; + size_t _ticks; + bool _loop; + + bool isKnownCommand(char *line); + void exit(void); + void display(void); + void simulate(void); + void loop(void); + }; +}; From 7c60b6d50ccf6a0cf19e6f02278d261a039db53c Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 19:23:42 +0100 Subject: [PATCH 03/13] :sparkles: Update the main with the new features --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index bcb420b..7e85927 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,6 +17,7 @@ #include "components/AndComponent.hpp" #include "components/XorComponent.hpp" #include "Error.hpp" +#include "Simulation.hpp" static void registerComponents(nts::ComponentFactory &factory) { @@ -31,7 +32,8 @@ static void registerComponents(nts::ComponentFactory &factory) factory.registerComponent("xor", new nts::Components::XorComponent()); } -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ nts::ComponentFactory factory; registerComponents(factory); @@ -41,6 +43,8 @@ int main(int argc, char **argv) { fileContainer.extractFileContent(); fileContainer.buildMap(factory); fileContainer.setlinks(); + nts::Simulation simulation(fileContainer.getMap()); + simulation.execSimulation(); } catch (nts::Error &e) { std::cerr << e.what() << std::endl; return 84; From 79faf8cbe82af874a8490e20932416f5aa1e232e Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 19:24:48 +0100 Subject: [PATCH 04/13] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Replace=20unordered?= =?UTF-8?q?=5Fmap=20by=20map=20to=20have=20a=20native=20sort=20for=20displ?= =?UTF-8?q?ay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FileContainer.cpp | 4 ++-- src/FileContainer.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/FileContainer.cpp b/src/FileContainer.cpp index 84c39ef..b0814bb 100644 --- a/src/FileContainer.cpp +++ b/src/FileContainer.cpp @@ -18,7 +18,7 @@ nts::FileContainer::FileContainer(const std::string &filename) this->_filename = filename; this->_chipsets = std::vector(); this->_links = std::vector(); - this->_pins = std::unordered_map(); + this->_pins = std::map(); } void nts::FileContainer::extractFileContent() @@ -56,7 +56,7 @@ std::vector nts::FileContainer::getLinks(void) const return _links; } -std::unordered_map nts::FileContainer::getMap(void) const +std::map nts::FileContainer::getMap(void) const { return _pins; } diff --git a/src/FileContainer.hpp b/src/FileContainer.hpp index 3d11d67..5964653 100644 --- a/src/FileContainer.hpp +++ b/src/FileContainer.hpp @@ -24,7 +24,7 @@ namespace nts std::vector getChipsets(void) const; std::vector getLinks(void) const; - std::unordered_map getMap(void) const; + std::map getMap(void) const; void buildMap(ComponentFactory &factory); void setlinks(void); @@ -33,7 +33,7 @@ namespace nts std::string _filename; std::vector _chipsets; std::vector _links; - std::unordered_map _pins; + std::map _pins; std::string removeComments(std::string &content) const; void extractChipsetsAndLinks(const std::string &content); From f2d76751ea2628d7539a471f742248c9b79a681c Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 19:25:36 +0100 Subject: [PATCH 05/13] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20a=20regex=20for=20th?= =?UTF-8?q?e=20file=20parsing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FileContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FileContainer.cpp b/src/FileContainer.cpp index b0814bb..21ba0f3 100644 --- a/src/FileContainer.cpp +++ b/src/FileContainer.cpp @@ -113,7 +113,7 @@ std::string nts::FileContainer::removeComments(std::string &content) const void nts::FileContainer::extractChipsetsAndLinks(const std::string &content) { - std::regex reg("(\\.chipsets:\n([a-zA-Z0-9_ #]+\n?)+\n)\n*(\\.links:\n([a-zA-Z0-9_: #]+\n?)+\n+)$"); + std::regex reg("(\\.chipsets:\n([a-zA-Z0-9_ #]+\n?)+\n)\n*(\\.links:\n([a-zA-Z0-9_: #]+\n?)+)(\n+)?$"); std::smatch match; std::string str1; std::string str2; From daee7067ea52d5c767c24e2082ceeb91e6c0e622 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 19:26:00 +0100 Subject: [PATCH 06/13] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Impro?= =?UTF-8?q?ve=20error=20messages=20in=20the=20file=20parsing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FileContainer.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/FileContainer.cpp b/src/FileContainer.cpp index 21ba0f3..b5062b5 100644 --- a/src/FileContainer.cpp +++ b/src/FileContainer.cpp @@ -70,11 +70,11 @@ void nts::FileContainer::buildMap(ComponentFactory &factory) type = strtok((char *)this->_chipsets[i].c_str(), " "); name = strtok(NULL, " "); if (name == NULL || type == NULL) - throw nts::Error("Invalid file format."); - if (!factory.isRegistered(name)) - throw nts::Error("Component type does not exist."); + throw nts::Error("Invalid file format in the chipset section."); + if (!factory.isRegistered(type)) + throw nts::Error("Component type: " + std::string(name) + " does not exist."); if (this->_pins.find(name) != this->_pins.end()) - throw nts::Error("Component name already exists."); + throw nts::Error("Component name: " + std::string(name) + " already exists."); this->_pins[name] = factory.createComponent(type); } } @@ -92,13 +92,12 @@ void nts::FileContainer::setlinks(void) name2 = strtok(NULL, " "); pin2 = strtok(NULL, " "); if (name == NULL || pin == NULL || name2 == NULL || pin2 == NULL) - throw nts::Error("Invalid file format."); + throw nts::Error("Invalid file format in the links section."); if (this->_pins.find(name) == this->_pins.end()) - throw nts::Error("First component name does not exist."); + throw nts::Error("First component name: " + std::string(name) + " does not exist."); if (this->_pins[name2] == NULL) - throw nts::Error("Second component name does not exist."); + throw nts::Error("Second component name: " + std::string(name2) + " does not exist."); this->_pins[name]->setLink(std::stoi(pin), *this->_pins[name2], std::stoi(pin2)); - // The `setLink` method already has a check for the pin existence and if it is already linked } } @@ -124,7 +123,7 @@ void nts::FileContainer::extractChipsetsAndLinks(const std::string &content) str2 = match[3].str(); this->fillLinks(str2); } else { - throw nts::Error("Invalid file format."); + throw nts::Error("Invalid file format in the chipset and/or links section."); } } @@ -138,14 +137,14 @@ void nts::FileContainer::fillChipsets(std::string &str) token = strtok((char *)str.c_str(), "\n"); token = strtok(NULL, "\n"); if (token == NULL) - throw nts::Error("Invalid file format."); + throw nts::Error("Invalid file format in the chipset section."); while (token != NULL) { str2 = std::string(token); if (std::regex_search(str2, match2, reg)) { str2 = match2[1].str() + " " + match2[2].str(); this->_chipsets.push_back(str2); } else { - throw nts::Error("Invalid file format."); + throw nts::Error("Invalid file format in the chipset section."); } token = strtok(NULL, "\n"); } @@ -161,14 +160,14 @@ void nts::FileContainer::fillLinks(std::string &str) token = strtok((char *)str.c_str(), "\n"); token = strtok(NULL, "\n"); if (token == NULL) - throw nts::Error("Invalid file format."); + throw nts::Error("Invalid file format in the links section."); while (token != NULL) { str2 = std::string(token); if (std::regex_search(str2, match2, reg)) { str2 = match2[1].str() + " " + match2[5].str() + " " + match2[6].str() + " " + match2[10].str(); this->_links.push_back(str2); } else { - throw nts::Error("Invalid file format."); + throw nts::Error("Invalid file format in the links section."); } token = strtok(NULL, "\n"); } From 2435b20d185aa966678c62c04024ed8b58298e96 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 19:26:13 +0100 Subject: [PATCH 07/13] :wrench: Add the new file to the Makefile --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 0c2a72a..f6aca59 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ CXX_SOURCES = src/main.cpp \ src/components/XorComponent.cpp \ src/FileContainer.cpp \ src/Error.cpp \ + src/Simulation.cpp \ # Compiler and linker settings NAME = nanotekspice From 4c11665712170de8b897cd7d8496e2b3c3e939a6 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 19:51:07 +0100 Subject: [PATCH 08/13] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20the=20main=20simulat?= =?UTF-8?q?e()=20in=20accordance=20with=20the=20simulate()=20already=20don?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Simulation.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index d404726..15d57a9 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -82,14 +82,17 @@ void nts::Simulation::display() void nts::Simulation::simulate() { - for (auto &pin : this->_pins) { - pin.second->simulate(this->_ticks); - } + std::unordered_map pins; // for (auto &pin : this->_pins) { // if (dynamic_cast(pin.second) != nullptr) - // pin.second->compute(1); + // pins.push_back(pin); + // else + // pin.second->simulate(1); // } // This part is in comments since the Output component is not implemented yet + for (auto &pin : pins) { + pin.second->simulate(1); + } this->_ticks++; } From 9d4a2aa8a10a1adfaac12b52f687a5e175e80ba0 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Fri, 23 Feb 2024 21:37:56 +0100 Subject: [PATCH 09/13] :construction: Add Work In Progress --- Makefile | 2 +- src/Simulation.cpp | 62 ++++++++++++++++++++++++++++--- src/Simulation.hpp | 3 ++ src/components/ClockComponent.cpp | 4 ++ src/components/ClockComponent.hpp | 3 ++ 5 files changed, 68 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f6aca59..d016cfa 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ CXX_SOURCES = src/main.cpp \ # Compiler and linker settings NAME = nanotekspice XX = g++ -XXFLAGS = -W -Wall -Wextra -std=c++20 +XXFLAGS = -W -Wall -Wextra -std=c++20 -g3 CXX_OBJS = $(CXX_SOURCES:.cpp=.o) LOG = ./build.log diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 15d57a9..584d5ec 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -8,10 +8,12 @@ #include "Simulation.hpp" #include "Error.hpp" #include "components/InputComponent.hpp" +#include "components/ClockComponent.hpp" // #include "OutputComponent.hpp" // This include is in comments since the Output component is not implemented yet #include #include +#include nts::Simulation::Simulation(std::map pins) { @@ -39,8 +41,7 @@ void nts::Simulation::execSimulation() return; if (isKnownCommand(line)) continue; - else - std::cout << "Unknown command." << std::endl; + handleInputs(line); } } @@ -90,9 +91,11 @@ void nts::Simulation::simulate() // pin.second->simulate(1); // } // This part is in comments since the Output component is not implemented yet - for (auto &pin : pins) { + for (auto &pin : this->_pins) pin.second->simulate(1); - } + // for (auto &pin : pins) { + // pin.second->simulate(1); + // } this->_ticks++; } @@ -124,7 +127,56 @@ void nts::Simulation::loop() while (this->_loop) { simulate(); display(); - sleep(1); sigaction(SIGINT, &sigIntHandler, NULL); + sleep(1); + } + sigIntHandler.sa_handler = SIG_DFL; + sigaction(SIGINT, &sigIntHandler, NULL); +} + +void nts::Simulation::handleInputs(char *line) +{ + std::stringstream ss(line); + std::string name; + std::string value; + + if (!getline(ss, name, '=')) { + // std::cout << "Invalid input" << std::endl; + return; + } + if (this->_pins[name] == nullptr || + (dynamic_cast(this->_pins[name]) == nullptr && + dynamic_cast(this->_pins[name]) == nullptr)) { + // std::cout << "Command not found" << std::endl; + return; + } + if (!getline(ss, value)) { + // std::cout << "Invalid input" << std::endl; + return; + } + if (value != "0" && value != "1" && value != "U") { + // std::cout << "Invalid value" << std::endl; + return; + } + setValues(name, value); +} + +void nts::Simulation::setValues(std::string name, std::string value) +{ + if (dynamic_cast(this->_pins[name]) != nullptr) { + if (value == "0") + dynamic_cast(this->_pins[name])->setValue(nts::FALSE); + else if (value == "1") + dynamic_cast(this->_pins[name])->setValue(nts::TRUE); + else + dynamic_cast(this->_pins[name])->setValue(nts::UNDEFINED); + } + if (dynamic_cast(this->_pins[name]) != nullptr) { + if (value == "0") + dynamic_cast(this->_pins[name])->setValue(nts::FALSE); + else if (value == "1") + dynamic_cast(this->_pins[name])->setValue(nts::TRUE); + else + dynamic_cast(this->_pins[name])->setValue(nts::UNDEFINED); } } diff --git a/src/Simulation.hpp b/src/Simulation.hpp index 73c60bf..b60e3f1 100644 --- a/src/Simulation.hpp +++ b/src/Simulation.hpp @@ -30,5 +30,8 @@ namespace nts { void display(void); void simulate(void); void loop(void); + + void handleInputs(char *line); + void setValues(std::string name, std::string value); }; }; diff --git a/src/components/ClockComponent.cpp b/src/components/ClockComponent.cpp index 333bbcc..8749742 100644 --- a/src/components/ClockComponent.cpp +++ b/src/components/ClockComponent.cpp @@ -31,3 +31,7 @@ void ClockComponent::simulate(std::size_t tick) _value = !_value; } } + +void ClockComponent::setValue(nts::Tristate value) { + _value = value; +} \ No newline at end of file diff --git a/src/components/ClockComponent.hpp b/src/components/ClockComponent.hpp index 5928fce..f4ba9a2 100644 --- a/src/components/ClockComponent.hpp +++ b/src/components/ClockComponent.hpp @@ -11,10 +11,13 @@ namespace nts::Components { class ClockComponent: public InputComponent { + protected: + Tristate _value; public: ClockComponent(); ~ClockComponent() override = default; Tristate compute(std::size_t pin) override; + void setValue(Tristate value); [[nodiscard]] ClockComponent *clone() const override; void simulate(std::size_t tick) override; }; From 500350c6b087c2db2799ab3e4c22629e5899e2f7 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Sat, 24 Feb 2024 18:34:43 +0100 Subject: [PATCH 10/13] =?UTF-8?q?=F0=9F=A9=B9=20Remove=20the=20error=20pri?= =?UTF-8?q?nting=20in=20the=20CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Simulation.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 584d5ec..4bf31c4 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -141,21 +141,17 @@ void nts::Simulation::handleInputs(char *line) std::string value; if (!getline(ss, name, '=')) { - // std::cout << "Invalid input" << std::endl; return; } if (this->_pins[name] == nullptr || (dynamic_cast(this->_pins[name]) == nullptr && dynamic_cast(this->_pins[name]) == nullptr)) { - // std::cout << "Command not found" << std::endl; return; } if (!getline(ss, value)) { - // std::cout << "Invalid input" << std::endl; return; } if (value != "0" && value != "1" && value != "U") { - // std::cout << "Invalid value" << std::endl; return; } setValues(name, value); From f6ce47a578747ac753c22d606ba1d662c5a00b67 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Sat, 24 Feb 2024 18:35:08 +0100 Subject: [PATCH 11/13] =?UTF-8?q?=F0=9F=92=A1=20Comment=20a=20part=20in=20?= =?UTF-8?q?the=20code=20that=20can't=20compile=20yet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Simulation.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 4bf31c4..270b13f 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -90,12 +90,10 @@ void nts::Simulation::simulate() // else // pin.second->simulate(1); // } - // This part is in comments since the Output component is not implemented yet - for (auto &pin : this->_pins) - pin.second->simulate(1); // for (auto &pin : pins) { // pin.second->simulate(1); // } + // This part is in comments since the Output component is not implemented yet this->_ticks++; } From 6885a5a67d74d91cb5e5cf92d080636a6a8f0bee Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Mon, 26 Feb 2024 09:57:37 +0100 Subject: [PATCH 12/13] :fire: Remove the useless sleep in the loop instruction --- src/Simulation.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 270b13f..bf59e01 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -126,7 +126,6 @@ void nts::Simulation::loop() simulate(); display(); sigaction(SIGINT, &sigIntHandler, NULL); - sleep(1); } sigIntHandler.sa_handler = SIG_DFL; sigaction(SIGINT, &sigIntHandler, NULL); From d78bc3eaeab4554d442990d45549695b89c1f830 Mon Sep 17 00:00:00 2001 From: Thomaltarix Date: Mon, 26 Feb 2024 19:59:23 +0100 Subject: [PATCH 13/13] =?UTF-8?q?=F0=9F=94=A5=20Remove=20a=20debug=20flag?= =?UTF-8?q?=20in=20the=20Makefile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d016cfa..f6aca59 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ CXX_SOURCES = src/main.cpp \ # Compiler and linker settings NAME = nanotekspice XX = g++ -XXFLAGS = -W -Wall -Wextra -std=c++20 -g3 +XXFLAGS = -W -Wall -Wextra -std=c++20 CXX_OBJS = $(CXX_SOURCES:.cpp=.o) LOG = ./build.log