Skip to content

Commit

Permalink
[rtl] Switch multdiv_en to multdiv_sel where possible
Browse files Browse the repository at this point in the history
Signed-off-by: Pirmin Vogel <[email protected]>
  • Loading branch information
vogelpi committed May 1, 2020
1 parent 439513b commit 511c59d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions rtl/ibex_ex_block.sv
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module ibex_ex_block #(
logic [33:0] alu_adder_result_ext;
logic alu_cmp_result, alu_is_equal_result;
logic multdiv_valid;
logic multdiv_en;
logic multdiv_sel;
logic [31:0] alu_imd_val_d;
logic alu_imd_val_we;
logic [33:0] multdiv_imd_val_d;
Expand All @@ -76,12 +76,12 @@ module ibex_ex_block #(
from the multdiv_i module are eliminated
*/
if (RV32M) begin : gen_multdiv_m
assign multdiv_en = mult_en_i | div_en_i;
assign multdiv_sel = multdiv_sel_i;
end else begin : gen_multdiv_no_m
assign multdiv_en = 1'b0;
assign multdiv_sel = 1'b0;
end

assign result_ex_o = multdiv_en ? multdiv_result : alu_result;
assign result_ex_o = multdiv_sel ? multdiv_result : alu_result;

// branch handling
assign branch_decision_o = alu_cmp_result;
Expand Down Expand Up @@ -204,7 +204,9 @@ module ibex_ex_block #(
);
end

// ALU output valid in same cycle, multiplier/divider may require multiple cycles
assign ex_valid_o = multdiv_en ? multdiv_valid : !alu_imd_val_we;
// Multiplier/divider may require multiple cycles. The ALU output is valid in the same cycle
// unless the intermediate result register is being written (which indicates this isn't the
// final cycle of ALU operation).
assign ex_valid_o = multdiv_sel ? multdiv_valid : !alu_imd_val_we;

endmodule
2 changes: 1 addition & 1 deletion rtl/ibex_multdiv_fast.sv
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ module ibex_multdiv_fast #(
if (!rst_ni) begin
mult_state_q <= MULL;
end else begin
if (mult_en_i) begin
if (mult_en_internal) begin
mult_state_q <= mult_state_d;
end
end
Expand Down
2 changes: 1 addition & 1 deletion rtl/ibex_multdiv_slow.sv
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ module ibex_multdiv_slow
op_numerator_q <= 32'h0;
md_state_q <= MD_IDLE;
end else begin
if (~multdiv_hold) begin
if ((mult_en_i || div_en_i) && !multdiv_hold) begin
multdiv_state_q <= multdiv_state_d;
op_b_shift_q <= op_b_shift_d;
op_a_shift_q <= op_a_shift_d;
Expand Down

0 comments on commit 511c59d

Please sign in to comment.