Skip to content

Commit 9654ec4

Browse files
author
pascalgouedo
authored
Merge pull request #980 from pascalgouedo/dev_dd_pgo_rtl
Better correction for Issue #975
2 parents 30f4d75 + 07050d7 commit 9654ec4

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

rtl/cv32e40p_controller.sv

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,17 @@ module cv32e40p_controller import cv32e40p_pkg::*;
597597

598598
csr_status_i: begin
599599
halt_if_o = 1'b1;
600-
ctrl_fsm_ns = id_ready_i ? FLUSH_EX : DECODE;
600+
if (~id_ready_i) begin
601+
ctrl_fsm_ns = DECODE;
602+
end else begin
603+
ctrl_fsm_ns = FLUSH_EX;
604+
if (hwlp_end0_eq_pc) begin
605+
hwlp_dec_cnt_o[0] = 1'b1;
606+
end
607+
if (hwlp_end1_eq_pc) begin
608+
hwlp_dec_cnt_o[1] = 1'b1;
609+
end
610+
end
601611
end
602612

603613
data_load_event_i: begin
@@ -617,7 +627,7 @@ module cv32e40p_controller import cv32e40p_pkg::*;
617627
ctrl_fsm_ns = hwlp_end0_eq_pc_plus4 || hwlp_end1_eq_pc_plus4 ? DECODE : DECODE_HWLOOP;
618628

619629
// we can be at the end of HWloop due to a return from interrupt or ecall or ebreak or exceptions
620-
if(hwlp_end0_eq_pc && hwlp_counter0_gt_1) begin
630+
if (hwlp_end0_eq_pc && hwlp_counter0_gt_1) begin
621631
pc_mux_o = PC_HWLOOP;
622632
if (~jump_done_q) begin
623633
pc_set_o = 1'b1;
@@ -791,7 +801,17 @@ module cv32e40p_controller import cv32e40p_pkg::*;
791801

792802
csr_status_i: begin
793803
halt_if_o = 1'b1;
794-
ctrl_fsm_ns = id_ready_i ? FLUSH_EX : DECODE_HWLOOP;
804+
if (~id_ready_i) begin
805+
ctrl_fsm_ns = DECODE_HWLOOP;
806+
end else begin
807+
ctrl_fsm_ns = FLUSH_EX;
808+
if (hwlp_end0_eq_pc) begin
809+
hwlp_dec_cnt_o[0] = 1'b1;
810+
end
811+
if (hwlp_end1_eq_pc) begin
812+
hwlp_dec_cnt_o[1] = 1'b1;
813+
end
814+
end
795815
end
796816

797817
data_load_event_i: begin
@@ -1067,16 +1087,10 @@ module cv32e40p_controller import cv32e40p_pkg::*;
10671087
end
10681088

10691089
csr_status_i: begin
1070-
1071-
if(hwlp_end0_eq_pc && hwlp_counter0_gt_1) begin
1072-
pc_mux_o = PC_HWLOOP;
1073-
pc_set_o = 1'b1;
1074-
hwlp_dec_cnt_o[0] = 1'b1;
1075-
end
1076-
if(hwlp_end1_eq_pc && hwlp_counter1_gt_1) begin
1077-
pc_mux_o = PC_HWLOOP;
1078-
pc_set_o = 1'b1;
1079-
hwlp_dec_cnt_o[1] = 1'b1;
1090+
if ((hwlp_end0_eq_pc && !hwlp_counter0_eq_0) ||
1091+
(hwlp_end1_eq_pc && !hwlp_counter1_eq_0)) begin
1092+
pc_mux_o = PC_HWLOOP;
1093+
pc_set_o = 1'b1;
10801094
end
10811095
end
10821096

rtl/cv32e40p_id_stage.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ module cv32e40p_id_stage
13551355
.hwlp_dec_cnt_i(hwlp_dec_cnt)
13561356
);
13571357

1358-
assign hwlp_valid = (instr_valid_i | csr_status) & clear_instr_valid_o;
1358+
assign hwlp_valid = instr_valid_i & clear_instr_valid_o;
13591359

13601360
// hwloop register id
13611361
assign hwlp_regid = instr[7]; // rd contains hwloop register id

0 commit comments

Comments
 (0)