diff --git a/models/cpu/iss/include/pulp_v2.hpp b/models/cpu/iss/include/pulp_v2.hpp index 778ab4d..4d23e13 100644 --- a/models/cpu/iss/include/pulp_v2.hpp +++ b/models/cpu/iss/include/pulp_v2.hpp @@ -26,13 +26,13 @@ #define PULPV2_HWLOOP_LPEND0 1 #define PULPV2_HWLOOP_LPCOUNT0 2 -#define PULPV2_HWLOOP_LPSTART1 3 -#define PULPV2_HWLOOP_LPEND1 4 -#define PULPV2_HWLOOP_LPCOUNT1 5 +#define PULPV2_HWLOOP_LPSTART1 4 +#define PULPV2_HWLOOP_LPEND1 5 +#define PULPV2_HWLOOP_LPCOUNT1 6 -#define PULPV2_HWLOOP_LPSTART(x) (PULPV2_HWLOOP_LPSTART0 + (x)*3) -#define PULPV2_HWLOOP_LPEND(x) (PULPV2_HWLOOP_LPEND0 + (x)*3) -#define PULPV2_HWLOOP_LPCOUNT(x) (PULPV2_HWLOOP_LPCOUNT0 + (x)*3) +#define PULPV2_HWLOOP_LPSTART(x) (PULPV2_HWLOOP_LPSTART0 + (x)*4) +#define PULPV2_HWLOOP_LPEND(x) (PULPV2_HWLOOP_LPEND0 + (x)*4) +#define PULPV2_HWLOOP_LPCOUNT(x) (PULPV2_HWLOOP_LPCOUNT0 + (x)*4) static inline iss_insn_t *LB_RR_exec_fast(iss_t *iss, iss_insn_t *insn) { @@ -595,7 +595,7 @@ static inline iss_insn_t *hwloop_check_exec(iss_t *iss, iss_insn_t *insn) static inline void hwloop_set_start(iss_t *iss, iss_insn_t *insn, int index, iss_reg_t start) { iss->cpu.pulpv2.hwloop_regs[PULPV2_HWLOOP_LPSTART(index)] = start; - iss->cpu.state.hwloop_start_insn[index] = insn_cache_get(iss, start); + iss->cpu.state.hwloop_start_insn[index] = insn_cache_get(iss, start); } static inline void hwloop_set_end(iss_t *iss, iss_insn_t *insn, int index, iss_reg_t end) diff --git a/models/cpu/iss/src/csr.cpp b/models/cpu/iss/src/csr.cpp index 8258e80..84f4ca5 100644 --- a/models/cpu/iss/src/csr.cpp +++ b/models/cpu/iss/src/csr.cpp @@ -940,6 +940,18 @@ static bool hwloop_read(iss_t *iss, int reg, iss_reg_t *value) { static bool hwloop_write(iss_t *iss, int reg, unsigned int value) { iss->cpu.pulpv2.hwloop_regs[reg] = value; + + // Since the HW loop is using decode instruction for the HW loop start to jump faster + // we need to recompute it when it is modified. + if (reg == 0) + { + iss->cpu.state.hwloop_start_insn[0] = insn_cache_get(iss, value); + } + else if (reg == 4) + { + iss->cpu.state.hwloop_start_insn[1] = insn_cache_get(iss, value); + } + return false; }