From 1babf6cb881a5835ba607d5f53bdc69d0bac86b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A0rius=20Mont=C3=B3n?= Date: Sun, 8 Sep 2019 11:41:30 +0200 Subject: [PATCH] added sc_stop at the end of the simulation to call destructors --- src/Execute.cpp | 4 ++-- src/Simulator.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Execute.cpp b/src/Execute.cpp index 22ab26f..30d2e6b 100644 --- a/src/Execute.cpp +++ b/src/Execute.cpp @@ -876,8 +876,8 @@ bool Execute::ECALL(Instruction &inst) { cout << "Simulation time " << sc_time_stamp() << endl; perf->dump(); - SC_REPORT_ERROR("Execute", "ECALL"); - + //SC_REPORT_ERROR("Execute", "ECALL"); + sc_stop(); return true; } diff --git a/src/Simulator.cpp b/src/Simulator.cpp index 41aa47d..8c24c68 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -68,7 +68,6 @@ SC_MODULE(Simulator) } ~Simulator() { - cout << "Simulator destructor" << endl; delete cpu; delete MainMemory; delete Bus; @@ -120,7 +119,7 @@ void process_arguments(int argc, char* argv[]) { filename = std::string(optarg); break; case '?' : - std::cout << "Call ./RISCV_TLM -D (0..4) filename.hex" << std::endl; + std::cout << "Call ./RISCV_TLM -D (0..3) filename.hex" << std::endl; break; } } @@ -144,5 +143,12 @@ int sc_main(int argc, char* argv[]) top = new Simulator("top"); sc_start(); + + cout << "Press Enter to finish" << endl; + cin.ignore(); + + // call all destructors, clean exit. + delete top; + return 0; }