Skip to content

Commit 2f341ca

Browse files
committed
[rtl] Optimize the Zcmp FSM
Merge the two cm.mv* states into a single one. This should still be easy to understand and saves us an extra bit in the encoding.
1 parent 3cf93aa commit 2f341ca

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

rtl/ibex_compressed_decoder.sv

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ module ibex_compressed_decoder #(
161161
endfunction
162162

163163
// Combined FSM state register for Zcmp operations.
164-
// This single 4-bit enum represents 4 independent "virtual" FSMs
165-
// that share the CmIdle state.
166-
typedef enum logic [3:0] {
164+
// This single 3-bit enum represents 3 independent FSMs that share the CmIdle state and the
165+
// resources.
166+
typedef enum logic [2:0] {
167167
CmIdle,
168168
// cm.push
169169
CmPushStoreReg,
@@ -173,10 +173,8 @@ module ibex_compressed_decoder #(
173173
CmPopIncrSp,
174174
CmPopZeroA0,
175175
CmPopRetRa,
176-
// cm.mvsa01
177-
CmMvSA1,
178-
// cm.mva01s
179-
CmMvA1S
176+
// cm.mvsa01, cm.mva01s
177+
CmMvSecondReg
180178
} cm_state_e;
181179
logic [4:0] cm_rlist_d, cm_rlist_q;
182180
logic [4:0] cm_sp_offset_d, cm_sp_offset_q;
@@ -691,10 +689,10 @@ module ibex_compressed_decoder #(
691689
// Move a0 to register indicated by r1s'.
692690
instr_o = cm_mvsa01(.a01(1'b0), .rs(instr_i[9:7]));
693691
if (id_in_ready_i) begin
694-
cm_state_d = CmMvSA1;
692+
cm_state_d = CmMvSecondReg;
695693
end
696694
end
697-
CmMvSA1: begin
695+
CmMvSecondReg: begin
698696
// Move a1 to register indicated by r2s'.
699697
instr_o = cm_mvsa01(.a01(1'b1), .rs(instr_i[4:2]));
700698
if (id_in_ready_i) begin
@@ -717,10 +715,10 @@ module ibex_compressed_decoder #(
717715
// Move register indicated by r1s' into a0.
718716
instr_o = cm_mva01s(.rs(instr_i[9:7]), .a01(1'b0));
719717
if (id_in_ready_i) begin
720-
cm_state_d = CmMvA1S;
718+
cm_state_d = CmMvSecondReg;
721719
end
722720
end
723-
CmMvA1S: begin
721+
CmMvSecondReg: begin
724722
// Move register indicated by r2s' into a1.
725723
instr_o = cm_mva01s(.rs(instr_i[4:2]), .a01(1'b1));
726724
if (id_in_ready_i) begin

0 commit comments

Comments
 (0)