Line 78... |
Line 78... |
reg [5:0] count = 'd0;
|
reg [5:0] count = 'd0;
|
reg [5:0] count_nxt;
|
reg [5:0] count_nxt;
|
reg [67:0] product = 'd0;
|
reg [67:0] product = 'd0;
|
reg [67:0] product_nxt;
|
reg [67:0] product_nxt;
|
reg [1:0] flags_nxt;
|
reg [1:0] flags_nxt;
|
reg sum_acc1_carry = 'd0;
|
|
reg sum_acc1_carry_nxt;
|
|
wire [32:0] sum_acc1; // the MSB is the carry out for the upper 32 bit addition
|
wire [32:0] sum_acc1; // the MSB is the carry out for the upper 32 bit addition
|
|
|
|
|
assign enable = i_function[0];
|
assign enable = i_function[0];
|
assign accumulate = i_function[1];
|
assign accumulate = i_function[1];
|
Line 152... |
Line 150... |
|
|
always @*
|
always @*
|
begin
|
begin
|
// Defaults
|
// Defaults
|
count_nxt = count;
|
count_nxt = count;
|
sum_acc1_carry_nxt = sum_acc1_carry;
|
|
product_nxt = product;
|
product_nxt = product;
|
|
|
// update Negative and Zero flags
|
// update Negative and Zero flags
|
// Use registered value of product so this adds an extra cycle
|
// Use registered value of product so this adds an extra cycle
|
// but this avoids having the 64-bit zero comparator on the
|
// but this avoids having the 64-bit zero comparator on the
|
Line 171... |
Line 168... |
else if ( count == 6'd34 && accumulate )
|
else if ( count == 6'd34 && accumulate )
|
begin
|
begin
|
// Note that bit 0 is not part of the product. It is used during the booth
|
// Note that bit 0 is not part of the product. It is used during the booth
|
// multiplication algorithm
|
// multiplication algorithm
|
product_nxt = { product[64:33], sum_acc1[31:0], 1'd0}; // Accumulate
|
product_nxt = { product[64:33], sum_acc1[31:0], 1'd0}; // Accumulate
|
sum_acc1_carry_nxt = sum_acc1[32];
|
|
end
|
end
|
|
|
// Multiplication state counter
|
// Multiplication state counter
|
if (count == 6'd0) // start
|
if (count == 6'd0) // start
|
count_nxt = enable ? 6'd1 : 6'd0;
|
count_nxt = enable ? 6'd1 : 6'd0;
|
Line 190... |
Line 186... |
always @ ( posedge i_clk )
|
always @ ( posedge i_clk )
|
if ( !i_core_stall )
|
if ( !i_core_stall )
|
begin
|
begin
|
count <= i_execute ? count_nxt : count;
|
count <= i_execute ? count_nxt : count;
|
product <= i_execute ? product_nxt : product;
|
product <= i_execute ? product_nxt : product;
|
sum_acc1_carry <= i_execute ? sum_acc1_carry_nxt : sum_acc1_carry;
|
|
o_done <= i_execute ? count == 6'd31 : o_done;
|
o_done <= i_execute ? count == 6'd31 : o_done;
|
end
|
end
|
|
|
// Outputs
|
// Outputs
|
assign o_out = product[32:1];
|
assign o_out = product[32:1];
|