Skip to content

Commit

Permalink
feat(csr): modify the warp for CSR time (#35)
Browse files Browse the repository at this point in the history
The modification is based on the following facts:
* Both XiangShan and NEMU support Zicntr extension, which includes three CSRs: cycle, time, instret.
* Rocket-chip support Zicntr except CSR time. In other words, Rocket-chip support cycle and instret but does not support time.
* Nutshell does not support Zicntr.
  • Loading branch information
cebarobot authored Sep 10, 2024
1 parent 57c0a81 commit 0a1e34b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions riscv/csr_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void state_t::csr_init(processor_t* const proc, reg_t max_isa)
if (proc->extension_enabled_const(EXT_ZICNTR)) {
add_csr(CSR_INSTRET, std::make_shared<counter_proxy_csr_t>(proc, CSR_INSTRET, minstret));
add_csr(CSR_CYCLE, std::make_shared<counter_proxy_csr_t>(proc, CSR_CYCLE, mcycle));
#ifndef DIFFTEST
#ifndef CPU_ROCKET_CHIP
add_csr(CSR_TIME, time_proxy = std::make_shared<counter_proxy_csr_t>(proc, CSR_TIME, time));
#endif
}
Expand All @@ -58,7 +58,7 @@ void state_t::csr_init(processor_t* const proc, reg_t max_isa)
auto timeh = std::make_shared<rv32_high_csr_t>(proc, CSR_TIMEH, time);
add_csr(CSR_INSTRETH, std::make_shared<counter_proxy_csr_t>(proc, CSR_INSTRETH, minstreth));
add_csr(CSR_CYCLEH, std::make_shared<counter_proxy_csr_t>(proc, CSR_CYCLEH, mcycleh));
#ifndef DIFFTEST
#ifndef CPU_ROCKET_CHIP
add_csr(CSR_TIMEH, std::make_shared<counter_proxy_csr_t>(proc, CSR_TIMEH, timeh));
#endif
}
Expand Down

0 comments on commit 0a1e34b

Please sign in to comment.