@@ -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
0 commit comments