Skip to content

Commit

Permalink
Fix pmp cosim
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryz123 committed Feb 4, 2023
1 parent 071ba76 commit b88e583
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions generators/chipyard/src/main/resources/csrc/cospike.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,16 @@ extern "C" void cospike_cosim(long long int cycle,
// 4 => csr
if ((rd != 0 && type == 0) || type == 1) {
// Override reads from some CSRs
if ((insn & 0xfff0007f) == 0xf1300073 || // mimpid
(insn & 0xfff0007f) == 0xf1200073 || // marchid
(insn & 0xfff0007f) == 0xf1100073 || // mvendorid
(insn & 0xfff0007f) == 0xb0000073 || // mcycle
(insn & 0xfff0007f) == 0xb0200073 // minstret
) {
uint64_t csr_addr = insn >> 20;
bool csr_read = (insn & 0x7f) == 0x73;
if (csr_read && (
(csr_addr == 0xf13) || // mimpid
(csr_addr == 0xf12) || // marchid
(csr_addr == 0xf11) || // mvendorid
(csr_addr == 0xb00) || // mcycle
(csr_addr == 0xb02) || // minstret
(csr_addr >= 0x3b0 && csr_addr <= 0x3ef) // pmpaddr
)) {
printf("CSR override\n");
s->XPR.write(rd, wdata);
} else if (!mem_read.empty() &&
Expand Down

0 comments on commit b88e583

Please sign in to comment.