Fixed issue that hardware loops with same endpoint did not work

This commit is contained in:
Andreas Traber 2015-11-27 11:25:28 +01:00
parent 116379e098
commit 45ceee59f7
2 changed files with 18 additions and 8 deletions

View file

@ -73,10 +73,11 @@ module riscv_hwloop_controller
hwlp_targ_addr_o = 'x;
hwlp_dec_cnt_o = '0;
for (j = N_REGS-1; j >= 0; j--) begin
for (j = 0; j < N_REGS; j++) begin
if (pc_is_end_addr[j]) begin
hwlp_targ_addr_o = hwlp_start_addr_i[j];
hwlp_dec_cnt_o[j] = 1'b1;
break;
end
end
end

View file

@ -115,18 +115,27 @@ module riscv_hwloop_regs
begin
hwlp_counter_q <= '{default: 32'b0};
end
else if (hwlp_we_i[2] == 1'b1) // potential contention problem here!
begin
hwlp_counter_q[hwlp_regid_i] <= hwlp_cnt_data_i;
end
else
begin
for (i = 0; i < N_REGS; i++)
if (hwlp_we_i[2] == 1'b1) // potential contention problem here!
begin
if (hwlp_dec_cnt_i[i] && valid_i)
hwlp_counter_q[i] <= hwlp_counter_n;
hwlp_counter_q[hwlp_regid_i] <= hwlp_cnt_data_i;
end else begin
for (i = 0; i < N_REGS; i++)
begin
if (hwlp_dec_cnt_i[i] && valid_i)
hwlp_counter_q[i] <= hwlp_counter_n[i];
end
end
end
end
//----------------------------------------------------------------------------
// Assertions
//----------------------------------------------------------------------------
// do not decrement more than one counter at once
assert property (
@(posedge clk) (valid_i) |-> ($countones(hwlp_dec_cnt_i) <= 1) );
endmodule