Fixed bug

This commit is contained in:
mariusmonton 2019-01-22 12:33:32 +01:00
parent 7c263419a8
commit 0c25abdb00
4 changed files with 14 additions and 8 deletions

View File

@ -71,6 +71,7 @@ private:
static Log* instance; static Log* instance;
Log(const char* filename); Log(const char* filename);
std::ofstream m_stream; std::ofstream m_stream;
std::ofstream m_sink;
}; };
#endif #endif

View File

@ -38,7 +38,7 @@ bool CPU::cpu_process_IRQ() {
/* updated MEPC register */ /* updated MEPC register */
old_pc = register_bank->getPC(); old_pc = register_bank->getPC();
register_bank->setCSR(CSR_MEPC, old_pc); 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 */ /* update MCAUSE register */
register_bank->setCSR(CSR_MCAUSE, 0x8000000); register_bank->setCSR(CSR_MCAUSE, 0x8000000);
@ -46,7 +46,7 @@ bool CPU::cpu_process_IRQ() {
/* set new PC address */ /* set new PC address */
new_pc = register_bank->getCSR(CSR_MTVEC); new_pc = register_bank->getCSR(CSR_MTVEC);
new_pc = new_pc & 0xFFFFFFFC; // last two bits always to 0 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); register_bank->setPC(new_pc);
ret_value = true; ret_value = true;

View File

@ -2152,7 +2152,7 @@ void Execute::RaiseException(uint32_t cause, uint32_t inst) {
regs->setPC( new_pc); 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(); regs->dump();
cout << "Simulation time " << sc_time_stamp() << endl; cout << "Simulation time " << sc_time_stamp() << endl;

View File

@ -2,8 +2,7 @@
Log* Log::getInstance() Log* Log::getInstance()
{ {
if (instance == 0) if (instance == 0) {
{
instance = new Log("Log.txt"); instance = new Log("Log.txt");
} }
@ -16,18 +15,24 @@ Log::Log(const char* filename) {
} }
void Log::SC_log(std::string msg, enum LogLevel level) { 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; 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) { std::ofstream& Log::SC_log(enum LogLevel level) {
if (level >= currentLogLevel) { if (level <= currentLogLevel) {
m_stream << "time " << sc_core::sc_time_stamp() << ": "; m_stream << "time " << sc_core::sc_time_stamp() << ": ";
return m_stream;
} else {
return m_sink;
} }
return m_stream;
} }
void Log::setLogLevel(enum LogLevel newLevel) { void Log::setLogLevel(enum LogLevel newLevel) {