@@ -193,14 +193,14 @@ void state_t::reset(processor_t* const proc, reg_t max_isa)
193193 csrmap[CSR_MINSTRET] = minstret;
194194 csrmap[CSR_MCYCLE] = mcycle;
195195 }
196- for (reg_t i = 3 ; i < N_HPMCOUNTERS + 3 ; ++i) {
197- const reg_t which_mevent = CSR_MHPMEVENT3 + i - 3 ;
198- const reg_t which_meventh = CSR_MHPMEVENT3H + i - 3 ;
199- const reg_t which_mcounter = CSR_MHPMCOUNTER3 + i - 3 ;
200- const reg_t which_mcounterh = CSR_MHPMCOUNTER3H + i - 3 ;
201- const reg_t which_counter = CSR_HPMCOUNTER3 + i - 3 ;
202- const reg_t which_counterh = CSR_HPMCOUNTER3H + i - 3 ;
203- mevent[i - 3 ] = std::make_shared<mevent_csr_t >(proc, which_mevent);
196+ for (reg_t i = 0 ; i < N_HPMCOUNTERS; ++i) {
197+ const reg_t which_mevent = CSR_MHPMEVENT3 + i;
198+ const reg_t which_meventh = CSR_MHPMEVENT3H + i;
199+ const reg_t which_mcounter = CSR_MHPMCOUNTER3 + i;
200+ const reg_t which_mcounterh = CSR_MHPMCOUNTER3H + i;
201+ const reg_t which_counter = CSR_HPMCOUNTER3 + i;
202+ const reg_t which_counterh = CSR_HPMCOUNTER3H + i;
203+ mevent[i] = std::make_shared<mevent_csr_t >(proc, which_mevent);
204204 auto mcounter = std::make_shared<const_csr_t >(proc, which_mcounter, 0 );
205205 csrmap[which_mcounter] = mcounter;
206206
@@ -209,19 +209,19 @@ void state_t::reset(processor_t* const proc, reg_t max_isa)
209209 csrmap[which_counter] = counter;
210210 }
211211 if (xlen == 32 ) {
212- csrmap[which_mevent] = std::make_shared<rv32_low_csr_t >(proc, which_mevent, mevent[i - 3 ]);;
212+ csrmap[which_mevent] = std::make_shared<rv32_low_csr_t >(proc, which_mevent, mevent[i]);;
213213 auto mcounterh = std::make_shared<const_csr_t >(proc, which_mcounterh, 0 );
214214 csrmap[which_mcounterh] = mcounterh;
215215 if (proc->extension_enabled_const (EXT_ZIHPM)) {
216216 auto counterh = std::make_shared<counter_proxy_csr_t >(proc, which_counterh, mcounterh);
217217 csrmap[which_counterh] = counterh;
218218 }
219219 if (proc->extension_enabled_const (EXT_SSCOFPMF)) {
220- auto meventh = std::make_shared<rv32_high_csr_t >(proc, which_meventh, mevent[i - 3 ]);
220+ auto meventh = std::make_shared<rv32_high_csr_t >(proc, which_meventh, mevent[i]);
221221 csrmap[which_meventh] = meventh;
222222 }
223223 } else {
224- csrmap[which_mevent] = mevent[i - 3 ];
224+ csrmap[which_mevent] = mevent[i];
225225 }
226226 }
227227 csrmap[CSR_MCOUNTINHIBIT] = std::make_shared<const_csr_t >(proc, CSR_MCOUNTINHIBIT, 0 );
0 commit comments