@@ -229,13 +229,14 @@ iss::status riscv_hart_mu_p<BASE, FEAT>::read(const addr_t& a, const unsigned le
229229 return iss::Err;
230230 }
231231 auto res = this ->memory .rd_mem ({address_type::PHYSICAL , a.access , a.space , a.val }, length, data);
232- if (unlikely (res != iss::Ok && (access & access_type::DEBUG ) == 0 )) {
233- this ->reg .trap_state = (1UL << 31 ) | traits<BASE >::RV_CAUSE_LOAD_ACCESS << 16 ;
232+ if (unlikely (res != iss::Ok && !is_debug (access))) {
233+ auto trap_id = is_fetch (a.access )?traits<BASE >::RV_CAUSE_FETCH_ACCESS :traits<BASE >::RV_CAUSE_LOAD_ACCESS ;
234+ this ->reg .trap_state = (1UL << 31 ) | trap_id << 16 ;
234235 this ->fault_data = addr;
235236 }
236237 return res;
237238 } catch (trap_access& ta) {
238- if ((access & access_type:: DEBUG ) == 0 ) {
239+ if (! is_debug (access) ) {
239240 this ->reg .trap_state = (1UL << 31 ) | ta.id ;
240241 this ->fault_data = ta.addr ;
241242 }
@@ -245,7 +246,7 @@ iss::status riscv_hart_mu_p<BASE, FEAT>::read(const addr_t& a, const unsigned le
245246 }
246247 return iss::Ok;
247248 } catch (trap_access& ta) {
248- if ((access & access_type:: DEBUG ) == 0 ) {
249+ if (! is_debug (access) ) {
249250 this ->reg .trap_state = (1UL << 31 ) | ta.id ;
250251 this ->fault_data = ta.addr ;
251252 }
@@ -334,7 +335,7 @@ iss::status riscv_hart_mu_p<BASE, FEAT>::write(const addr_t& a, const unsigned l
334335 }
335336 return iss::Ok;
336337 } catch (trap_access& ta) {
337- if ((access & access_type:: DEBUG ) == 0 ) {
338+ if (! is_debug (access) ) {
338339 this ->reg .trap_state = (1UL << 31 ) | ta.id ;
339340 this ->fault_data = ta.addr ;
340341 }
0 commit comments