@@ -182,6 +182,17 @@ module ibex_compressed_decoder #(
182182 logic [4 : 0 ] cm_sp_offset_d, cm_sp_offset_q;
183183 cm_state_e cm_state_d, cm_state_q;
184184
185+ // Gate the `gets_expanded_o` to ensure that a invalid instruction looking like expandable cm.*
186+ // instructions will not be stalled/blocked in later control logic because it is waiting for
187+ // `INSTR_EXPANDED_LAST`.
188+ ibex_pkg :: instr_exp_e gets_expanded;
189+ if (RV32ZC == RV32ZcaZcbZcmp || RV32ZC == RV32ZcaZcmp) begin : gen_gets_expanded
190+ assign gets_expanded_o = valid_i ? gets_expanded : INSTR_NOT_EXPANDED ;
191+ end else begin : gen_gets_expanded
192+ // `gets_expanded` will be tied to INSTR_NOT_EXPANDED in this case
193+ assign gets_expanded_o = gets_expanded;
194+ end
195+
185196 // //////////////////////
186197 // Compressed decoder //
187198 // //////////////////////
@@ -190,7 +201,7 @@ module ibex_compressed_decoder #(
190201 // By default, forward incoming instruction, mark it as legal, and don't expand.
191202 instr_o = instr_i;
192203 illegal_instr_o = 1'b0 ;
193- gets_expanded_o = INSTR_NOT_EXPANDED ;
204+ gets_expanded = INSTR_NOT_EXPANDED ;
194205
195206 // Maintain state of CM FSM.
196207 cm_rlist_d = cm_rlist_q;
@@ -531,7 +542,7 @@ module ibex_compressed_decoder #(
531542 // cm.push
532543 5'b11000 : begin
533544 // This compressed instruction gets expanded into multiple instructions.
534- gets_expanded_o = INSTR_EXPANDED ;
545+ gets_expanded = INSTR_EXPANDED ;
535546 unique case (cm_state_q)
536547 CmIdle: begin
537548 // No cm.push instruction is active yet; start a new one.
@@ -583,7 +594,7 @@ module ibex_compressed_decoder #(
583594 instr_o = cm_sp_addi (.rlist (instr_i[7 : 4 ]), .spimm (instr_i[3 : 2 ]), .decr (1'b1 ));
584595 if (id_in_ready_i) begin
585596 // This is the final operation, so stop expanding and return to idle.
586- gets_expanded_o = INSTR_EXPANDED_LAST ;
597+ gets_expanded = INSTR_EXPANDED_LAST ;
587598 cm_state_d = CmIdle;
588599 end
589600 end
@@ -596,7 +607,7 @@ module ibex_compressed_decoder #(
596607 5'b11100 ,
597608 5'b11110 : begin
598609 // This compressed instruction gets expanded into multiple instructions.
599- gets_expanded_o = INSTR_EXPANDED ;
610+ gets_expanded = INSTR_EXPANDED ;
600611 unique case (cm_state_q)
601612 CmIdle: begin
602613 // No cm.pop instruction is active yet; start a new one.
@@ -654,7 +665,7 @@ module ibex_compressed_decoder #(
654665 5'b11110 : cm_state_d = CmPopRetRa; // cm.popret
655666 default : begin // cm.pop
656667 // This is the final operation, so stop expanding and return to idle.
657- gets_expanded_o = INSTR_EXPANDED_LAST ;
668+ gets_expanded = INSTR_EXPANDED_LAST ;
658669 cm_state_d = CmIdle;
659670 end
660671 endcase
@@ -670,7 +681,7 @@ module ibex_compressed_decoder #(
670681 instr_o = cm_ret_ra ();
671682 if (id_in_ready_i) begin
672683 // This is the final operation, so stop expanding and return to idle.
673- gets_expanded_o = INSTR_EXPANDED_LAST ;
684+ gets_expanded = INSTR_EXPANDED_LAST ;
674685 cm_state_d = CmIdle;
675686 end
676687 end
@@ -684,7 +695,7 @@ module ibex_compressed_decoder #(
684695 // cm.mvsa01
685696 2'b01 : begin
686697 // This compressed instruction gets expanded into multiple instructions.
687- gets_expanded_o = INSTR_EXPANDED ;
698+ gets_expanded = INSTR_EXPANDED ;
688699 unique case (cm_state_q)
689700 CmIdle: begin
690701 // No cm.mvsa01 instruction is active yet; start a new one.
@@ -699,7 +710,7 @@ module ibex_compressed_decoder #(
699710 instr_o = cm_mvsa01 (.a01 (1'b1 ), .rs (instr_i[4 : 2 ]));
700711 if (id_in_ready_i) begin
701712 // This is the final operation, so stop expanding and return to idle.
702- gets_expanded_o = INSTR_EXPANDED_LAST ;
713+ gets_expanded = INSTR_EXPANDED_LAST ;
703714 cm_state_d = CmIdle;
704715 end
705716 end
@@ -710,7 +721,7 @@ module ibex_compressed_decoder #(
710721 // cm.mva01s
711722 2'b11 : begin
712723 // This compressed instruction gets expanded into multiple instructions.
713- gets_expanded_o = INSTR_EXPANDED ;
724+ gets_expanded = INSTR_EXPANDED ;
714725 unique case (cm_state_q)
715726 CmIdle: begin
716727 // No cm.mva01s instruction is active yet; start a new one.
@@ -725,7 +736,7 @@ module ibex_compressed_decoder #(
725736 instr_o = cm_mva01s (.rs (instr_i[4 : 2 ]), .a01 (1'b1 ));
726737 if (id_in_ready_i) begin
727738 // This is the final operation, so stop expanding and return to idle.
728- gets_expanded_o = INSTR_EXPANDED_LAST ;
739+ gets_expanded = INSTR_EXPANDED_LAST ;
729740 cm_state_d = CmIdle;
730741 end
731742 end
0 commit comments