exit cleanup, now closes xterm window, etc.

This commit is contained in:
mariusmonton 2021-01-31 11:38:57 +01:00
parent a48e552926
commit 86b98209ce
5 changed files with 22 additions and 19 deletions

View File

@ -918,8 +918,9 @@ bool BASE_ISA::Exec_ECALL() const {
} else { } else {
std::cout << "GP value is " << gp_value << "\n"; std::cout << "GP value is " << gp_value << "\n";
} }
//SC_REPORT_ERROR("Execute", "ECALL");
sc_core::sc_stop(); sc_core::sc_stop();
return true; return true;
} }
@ -932,8 +933,8 @@ bool BASE_ISA::Exec_EBREAK() {
std::cout << "Simulation time " << sc_core::sc_time_stamp() << "\n"; std::cout << "Simulation time " << sc_core::sc_time_stamp() << "\n";
perf->dump(); perf->dump();
RaiseException(EXCEPTION_CAUSE_BREAKPOINT, m_instr); sc_core::sc_stop();
NOP();
return true; return true;
} }

View File

@ -202,7 +202,7 @@ void CPU::CPU_thread(void) {
m_qk->sync(); m_qk->sync();
} }
#else #else
//sc_core::wait(10, sc_core::SC_NS); sc_core::wait(10, sc_core::SC_NS);
#endif #endif
} // while(1) } // while(1)
} // CPU_thread } // CPU_thread

View File

@ -672,9 +672,9 @@ bool C_extension::Exec_C_EBREAK() {
std::cout << "Simulation time " << sc_core::sc_time_stamp() << "\n"; std::cout << "Simulation time " << sc_core::sc_time_stamp() << "\n";
perf->dump(); perf->dump();
RaiseException(EXCEPTION_CAUSE_BREAKPOINT, m_instr); sc_core::sc_stop();
NOP();
return true; return true;
} }
bool C_extension::process_instruction(Instruction *inst) { bool C_extension::process_instruction(Instruction *inst) {

View File

@ -12,8 +12,9 @@
#include "tlm_utils/simple_initiator_socket.h" #include "tlm_utils/simple_initiator_socket.h"
#include "tlm_utils/simple_target_socket.h" #include "tlm_utils/simple_target_socket.h"
#include <signal.h> #include <csignal>
#include <unistd.h> #include <unistd.h>
#include <chrono>
#include "CPU.h" #include "CPU.h"
#include "Memory.h" #include "Memory.h"
@ -37,10 +38,8 @@ SC_MODULE(Simulator) {
Trace *trace; Trace *trace;
Timer *timer; Timer *timer;
SC_CTOR(Simulator) { SC_CTOR(Simulator) {
uint32_t start_PC; uint32_t start_PC;
MainMemory = new Memory("Main_Memory", filename); MainMemory = new Memory("Main_Memory", filename);
start_PC = MainMemory->getPCfromHEX(); start_PC = MainMemory->getPCfromHEX();
@ -58,8 +57,6 @@ SC_MODULE(Simulator) {
Bus->trace_socket.bind(trace->socket); Bus->trace_socket.bind(trace->socket);
Bus->timer_socket.bind(timer->socket); Bus->timer_socket.bind(timer->socket);
//timer->timer_irq.bind(IRQ);
// cpu->interrupt.bind(IRQ);
timer->irq_line.bind(cpu->irq_line_socket); 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 <debuglevel> (0..3) filename.hex" std::cout << "Call ./RISCV_TLM -D <debuglevel> (0..3) filename.hex"
<< std::endl; << std::endl;
break; break;
default:
std::cout << "unknown" << std::endl;
} }
} }
@ -139,8 +139,13 @@ int sc_main(int argc, char *argv[]) {
process_arguments(argc, argv); process_arguments(argc, argv);
top = new Simulator("top"); top = new Simulator("top");
auto start = std::chrono::steady_clock::now();
sc_core::sc_start(); sc_core::sc_start();
auto end = std::chrono::steady_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Total elapsed time: " << elapsed_seconds.count() << "s" << std::endl;
std::cout << "Press Enter to finish" << std::endl; std::cout << "Press Enter to finish" << std::endl;
std::cin.ignore(); std::cin.ignore();

View File

@ -54,16 +54,13 @@ void extension_base::RaiseException(uint32_t cause, uint32_t inst) {
regs->dump(); regs->dump();
std::cout << "Simulation time " << sc_core::sc_time_stamp() << std::endl; std::cout << "Simulation time " << sc_core::sc_time_stamp() << std::endl;
perf->dump(); perf->dump();
SC_REPORT_ERROR("Exception", "Exception");
sc_core::sc_stop();
} }
bool extension_base::NOP() { 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; return true;
} }