Skip to content

Commit 9f758cf

Browse files
committed
ebreak and c.ebreak are now correct!
1 parent c9fdd7e commit 9f758cf

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

inc/BASE_ISA.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,28 +1351,28 @@ namespace riscv_tlm {
13511351
std::cout << "Simulation time " << sc_core::sc_time_stamp() << "\n";
13521352
this->perf->dump();
13531353

1354-
this->RaiseException(Exception_cause::CALL_FROM_M_MODE, this->m_instr);
1354+
this->RaiseException(Exception_cause::BREAK, this->m_instr);
13551355

13561356
return false;
13571357
}
13581358

13591359
bool Exec_CSRRW() const {
13601360
unsigned int rd, rs1;
13611361
int csr;
1362-
unsigned_T aux;
1362+
unsigned_T aux, aux2;
13631363

13641364
rd = this->get_rd();
13651365
rs1 = this->get_rs1();
13661366
csr = get_csr();
13671367

1368-
/* These operations must be atomical */
1368+
aux = this->regs->getCSR(csr);
1369+
aux2 = this->regs->getValue(rs1);
1370+
13691371
if (rd != 0) {
1370-
aux = this->regs->getCSR(csr);
13711372
this->regs->setValue(rd, aux);
13721373
}
13731374

1374-
aux = this->regs->getValue(rs1);
1375-
this->regs->setCSR(csr, aux);
1375+
this->regs->setCSR(csr, aux2);
13761376

13771377
this->logger->debug("{} ns. PC: 0x{:x}. CSRRW: CSR #{:d} -> x{:d}(0x{:x})",
13781378
sc_core::sc_time_stamp().value(),

inc/C_extension.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ namespace riscv_tlm {
12891289

12901290
this->RaiseException(Exception_cause::BREAK, this->m_instr);
12911291

1292-
return true;
1292+
return false;
12931293
}
12941294

12951295
bool exec_instruction(Instruction &inst, bool *breakpoint, op_C_Codes code) {
@@ -1388,6 +1388,7 @@ namespace riscv_tlm {
13881388
Exec_C_EBREAK();
13891389
std::cout << "C_EBREAK" << std::endl;
13901390
*breakpoint = true;
1391+
PC_not_affected = false;
13911392
break;
13921393
case OP_C_LD:
13931394
Exec_C_LD();

0 commit comments

Comments
 (0)