diff --git a/testbench/tests/pmp_random/main.c b/testbench/tests/pmp_random/main.c index 327c1478238..2fb11817525 100644 --- a/testbench/tests/pmp_random/main.c +++ b/testbench/tests/pmp_random/main.c @@ -230,6 +230,7 @@ uint32_t generate_napot_mask(uint32_t value) { int get_effective_range(uint32_t *address, enum RegionType region_type, uint32_t **addr_hi, uint32_t **addr_lo){ *address = legalize_address(*address, region_type); + uint32_t mask = generate_napot_mask(*address); switch (region_type) { case OFF: *addr_lo = 0; @@ -244,7 +245,6 @@ int get_effective_range(uint32_t *address, enum RegionType region_type, uint32_t *addr_hi = *addr_lo + 1; break; case NAPOT: - uint32_t mask = generate_napot_mask(*address); *addr_lo = ((uint32_t)address & ~mask) << 2; *addr_hi = *addr_lo + (1 << trailing_ones(*address)); break;