@@ -160,15 +160,22 @@ module ibex_compressed_decoder #(
160160 return rlist;
161161 endfunction
162162
163+ // Combined FSM state register for Zcmp operations.
164+ // This single 4-bit enum represents 4 independent "virtual" FSMs
165+ // that share the CmIdle state.
163166 typedef enum logic [3 : 0 ] {
164167 CmIdle,
168+ // cm.push
165169 CmPushStoreReg,
166170 CmPushDecrSp,
171+ // cm.pop, cm.popret, cm.popretz
167172 CmPopLoadReg,
168173 CmPopIncrSp,
169174 CmPopZeroA0,
170175 CmPopRetRa,
176+ // cm.mvsa01
171177 CmMvSA1,
178+ // cm.mva01s
172179 CmMvA1S
173180 } cm_state_e ;
174181 logic [4 : 0 ] cm_rlist_d, cm_rlist_q;
@@ -529,7 +536,8 @@ module ibex_compressed_decoder #(
529536 // No cm.push instruction is active yet; start a new one.
530537 // Initialize `rlist` to the value provided by the instruction.
531538 cm_rlist_d = cm_rlist_init (instr_i[7 : 4 ]);
532- // Store the register at the top of `rlist`.
539+ // Store the register at the top of `rlist`, which is the highest register in
540+ // the list. Then work our way down by decrementing `rlist` each cycle.
533541 instr_o = cm_push_store_reg (.rlist (cm_rlist_d), .sp_offset (5'd1 ));
534542 if (cm_rlist_d <= 5'd3 ) begin
535543 // Reserved --> illegal instruction.
@@ -544,7 +552,8 @@ module ibex_compressed_decoder #(
544552 // More registers have to be stored.
545553 // Remove the current register from `rlist`.
546554 cm_rlist_d - = 5'd1 ;
547- // Initialize SP offset to 2.
555+ // Initialize SP offset to 2. We just stored at offset 1 this cycle and will
556+ // start incrementing the offset from 2 onwards in CmPushStoreReg next cycle.
548557 cm_sp_offset_d = 5'd2 ;
549558 // Proceed with storing registers.
550559 if (id_in_ready_i) begin
@@ -596,7 +605,8 @@ module ibex_compressed_decoder #(
596605 // Initialize SP offset.
597606 cm_sp_offset_d = cm_stack_adj_word (.rlist (instr_i[7 : 4 ]),
598607 .spimm (instr_i[3 : 2 ])) - 5'd1 ;
599- // Load the register at the top of `rlist`.
608+ // Load the register at the top of `rlist`, which is the highest register in
609+ // the list. Then work our way down by decrementing `rlist` each cycle.
600610 instr_o = cm_pop_load_reg (.rlist (cm_rlist_d), .sp_offset (cm_sp_offset_d));
601611 if (cm_rlist_d <= 5'd3 ) begin
602612 // Reserved --> illegal instruction.
0 commit comments