Fixed bug
This commit is contained in:
parent
7c263419a8
commit
0c25abdb00
|
@ -71,6 +71,7 @@ private:
|
|||
static Log* instance;
|
||||
Log(const char* filename);
|
||||
std::ofstream m_stream;
|
||||
std::ofstream m_sink;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@ bool CPU::cpu_process_IRQ() {
|
|||
/* updated MEPC register */
|
||||
old_pc = register_bank->getPC();
|
||||
register_bank->setCSR(CSR_MEPC, old_pc);
|
||||
// log->SC_log(Log::INFO) << "Old PC Value 0x" << hex << old_pc << endl;
|
||||
log->SC_log(Log::INFO) << "Old PC Value 0x" << hex << old_pc << endl;
|
||||
|
||||
/* update MCAUSE register */
|
||||
register_bank->setCSR(CSR_MCAUSE, 0x8000000);
|
||||
|
@ -46,7 +46,7 @@ bool CPU::cpu_process_IRQ() {
|
|||
/* set new PC address */
|
||||
new_pc = register_bank->getCSR(CSR_MTVEC);
|
||||
new_pc = new_pc & 0xFFFFFFFC; // last two bits always to 0
|
||||
// log->SC_log(Log::DEBUG) << "NEW PC Value 0x" << hex << new_pc << endl;
|
||||
log->SC_log(Log::DEBUG) << "NEW PC Value 0x" << hex << new_pc << endl;
|
||||
register_bank->setPC(new_pc);
|
||||
|
||||
ret_value = true;
|
||||
|
|
|
@ -2152,7 +2152,7 @@ void Execute::RaiseException(uint32_t cause, uint32_t inst) {
|
|||
|
||||
regs->setPC( new_pc);
|
||||
|
||||
log->SC_log(Log::INFO) << "Exception! new PC " << hex << new_pc << endl;
|
||||
log->SC_log(Log::INFO) << "Exception! new PC 0x" << hex << new_pc << endl;
|
||||
|
||||
regs->dump();
|
||||
cout << "Simulation time " << sc_time_stamp() << endl;
|
||||
|
|
15
src/Log.cpp
15
src/Log.cpp
|
@ -2,8 +2,7 @@
|
|||
|
||||
Log* Log::getInstance()
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
if (instance == 0) {
|
||||
instance = new Log("Log.txt");
|
||||
}
|
||||
|
||||
|
@ -16,18 +15,24 @@ Log::Log(const char* filename) {
|
|||
}
|
||||
|
||||
void Log::SC_log(std::string msg, enum LogLevel level) {
|
||||
if (level >= currentLogLevel) {
|
||||
|
||||
if (level <= currentLogLevel) {
|
||||
m_stream << "time " << sc_core::sc_time_stamp() << ": " << msg << std::endl;
|
||||
} else {
|
||||
m_stream << "patata" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream& Log::SC_log(enum LogLevel level) {
|
||||
|
||||
if (level >= currentLogLevel) {
|
||||
if (level <= currentLogLevel) {
|
||||
m_stream << "time " << sc_core::sc_time_stamp() << ": ";
|
||||
return m_stream;
|
||||
} else {
|
||||
return m_sink;
|
||||
}
|
||||
|
||||
return m_stream;
|
||||
|
||||
}
|
||||
|
||||
void Log::setLogLevel(enum LogLevel newLevel) {
|
||||
|
|
Loading…
Reference in New Issue