Skip to content

Commit

Permalink
[ISS] Fixed issues with HW loop when using csr hw loop registers
Browse files Browse the repository at this point in the history
  • Loading branch information
haugoug committed Mar 3, 2022
1 parent 780c441 commit 02621db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 7 additions & 7 deletions models/cpu/iss/include/pulp_v2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions models/cpu/iss/src/csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 02621db

Please sign in to comment.