tselect = 0;
for (unsigned int i = 0; i < num_triggers; i++)
mcontrol[i].type = 2;
+#ifdef SPIKE_SIMPLEV
+ // set SV CSR banks to default (full) sizes
+ msv.state_size = 1;
+ ssv.state_size = 1;
+ usv.state_size = 3;
+#endif
}
void sv_shape_t::setup_map()
return max_xlen == 64 ? 50 : 34;
}
+void state_t::get_csr_start_end(int &start, int &end)
+{
+ start = sv().state_bank * 4;
+ end = start + (1 << (sv().state_size+1));
+ start = std::min(sv_csr_sz(), start);
+ end = std::min(sv_csr_sz(), end);
+ fprintf(stderr, "sv state csr start/end: %d %d\n", start, end);
+}
+
void state_t::sv_csr_reg_unpack()
{
// okaaay and now "unpack" the CAM to make it easier to use. this
memset(sv().sv_int_tb, 0, sizeof(sv().sv_int_tb));
memset(sv().sv_fp_tb, 0, sizeof(sv().sv_fp_tb));
// now walk the CAM and unpack it
- for (int i = 0; i < sv_csr_sz(); i++)
+ int start = 0;
+ int end = 0;
+ get_csr_start_end(start, end);
+ for (int i = start; i < end; i++)
{
union sv_reg_csr_entry *c = &sv().sv_csrs[i];
uint64_t idx = c->b.regkey;
{
memset(sv().sv_pred_int_tb, 0, sizeof(sv().sv_pred_int_tb));
memset(sv().sv_pred_fp_tb, 0, sizeof(sv().sv_pred_fp_tb));
- for (int i = 0; i < sv_csr_sz(); i++)
+ int start = 0;
+ int end = 0;
+ get_csr_start_end(start, end);
+ for (int i = start; i < end; i++)
{
union sv_pred_csr_entry *c = &sv().sv_pred_csrs[i];
uint64_t idx = c->b.regkey;
reg_t destoffs = get_field(val, SV_STATE_DESTOFFS);
state.sv().srcoffs = std::min(srcoffs , state.sv().vl-1);
state.sv().destoffs = std::min(destoffs, state.sv().vl-1);
+ int old_bank = state.sv().state_bank;
+ int old_size = state.sv().state_size;
state.sv().state_bank = get_field(val, SV_STATE_BANK);
state.sv().state_size = get_field(val, SV_STATE_SIZE);
+ if (old_bank != state.sv().state_bank ||
+ old_size != state.sv().state_size)
+ {
+ // if the bank or size is changed, the csrs that are enabled
+ // also changes. easiest thing in software: recalculate them all
+ state.sv_csr_pred_unpack();
+ state.sv_csr_reg_unpack();
+ }
break;
}
case CSR_USVVL: