diff --git a/src/BASE_ISA.cpp b/src/BASE_ISA.cpp index 67ca4cc..a611c88 100644 --- a/src/BASE_ISA.cpp +++ b/src/BASE_ISA.cpp @@ -918,8 +918,9 @@ bool BASE_ISA::Exec_ECALL() const { } else { std::cout << "GP value is " << gp_value << "\n"; } - //SC_REPORT_ERROR("Execute", "ECALL"); + sc_core::sc_stop(); + return true; } @@ -932,8 +933,8 @@ bool BASE_ISA::Exec_EBREAK() { std::cout << "Simulation time " << sc_core::sc_time_stamp() << "\n"; perf->dump(); - RaiseException(EXCEPTION_CAUSE_BREAKPOINT, m_instr); - NOP(); + sc_core::sc_stop(); + return true; } diff --git a/src/CPU.cpp b/src/CPU.cpp index 4fd535c..1a3719c 100644 --- a/src/CPU.cpp +++ b/src/CPU.cpp @@ -202,7 +202,7 @@ void CPU::CPU_thread(void) { m_qk->sync(); } #else - //sc_core::wait(10, sc_core::SC_NS); + sc_core::wait(10, sc_core::SC_NS); #endif } // while(1) } // CPU_thread diff --git a/src/C_extension.cpp b/src/C_extension.cpp index 2df5b30..8efc661 100644 --- a/src/C_extension.cpp +++ b/src/C_extension.cpp @@ -672,9 +672,9 @@ bool C_extension::Exec_C_EBREAK() { std::cout << "Simulation time " << sc_core::sc_time_stamp() << "\n"; perf->dump(); - RaiseException(EXCEPTION_CAUSE_BREAKPOINT, m_instr); - NOP(); - return true; + sc_core::sc_stop(); + + return true; } bool C_extension::process_instruction(Instruction *inst) { diff --git a/src/Simulator.cpp b/src/Simulator.cpp index 67871b1..6b7dadc 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -12,8 +12,9 @@ #include "tlm_utils/simple_initiator_socket.h" #include "tlm_utils/simple_target_socket.h" -#include +#include #include +#include #include "CPU.h" #include "Memory.h" @@ -37,10 +38,8 @@ SC_MODULE(Simulator) { Trace *trace; Timer *timer; - - SC_CTOR(Simulator) { - uint32_t start_PC; + uint32_t start_PC; MainMemory = new Memory("Main_Memory", filename); start_PC = MainMemory->getPCfromHEX(); @@ -58,8 +57,6 @@ SC_MODULE(Simulator) { Bus->trace_socket.bind(trace->socket); Bus->timer_socket.bind(timer->socket); - //timer->timer_irq.bind(IRQ); - // cpu->interrupt.bind(IRQ); timer->irq_line.bind(cpu->irq_line_socket); } @@ -119,6 +116,9 @@ void process_arguments(int argc, char *argv[]) { std::cout << "Call ./RISCV_TLM -D (0..3) filename.hex" << std::endl; break; + default: + std::cout << "unknown" << std::endl; + } } @@ -139,8 +139,13 @@ int sc_main(int argc, char *argv[]) { process_arguments(argc, argv); top = new Simulator("top"); + + auto start = std::chrono::steady_clock::now(); sc_core::sc_start(); + auto end = std::chrono::steady_clock::now(); + std::chrono::duration elapsed_seconds = end - start; + std::cout << "Total elapsed time: " << elapsed_seconds.count() << "s" << std::endl; std::cout << "Press Enter to finish" << std::endl; std::cin.ignore(); diff --git a/src/extension_base.cpp b/src/extension_base.cpp index f3e91ba..666fa8b 100644 --- a/src/extension_base.cpp +++ b/src/extension_base.cpp @@ -54,16 +54,13 @@ void extension_base::RaiseException(uint32_t cause, uint32_t inst) { regs->dump(); std::cout << "Simulation time " << sc_core::sc_time_stamp() << std::endl; perf->dump(); - SC_REPORT_ERROR("Exception", "Exception"); + + sc_core::sc_stop(); } bool extension_base::NOP() { - std::cout << std::endl; - regs->dump(); - std::cout << "Simulation time " << sc_core::sc_time_stamp() << std::endl; - perf->dump(); - SC_REPORT_ERROR("Execute", "NOP"); + log->SC_log(Log::INFO) << "NOP" << "\n"; return true; }