Line 23... |
Line 23... |
parameter size_exponent = 8,
|
parameter size_exponent = 8,
|
parameter pipeline = 0,
|
parameter pipeline = 0,
|
parameter pipeline_pos = 0, // 8 bits
|
parameter pipeline_pos = 0, // 8 bits
|
parameter size_counter = 5, //log2(size_in_mantissa) + 1 = 5)
|
parameter size_counter = 5, //log2(size_in_mantissa) + 1 = 5)
|
parameter double_size_in_mantissa = size_in_mantissa + size_in_mantissa)
|
parameter double_size_in_mantissa = size_in_mantissa + size_in_mantissa)
|
( input [size_in_mantissa : 0] unnormalized_mantissa,
|
( input [size_in_mantissa - 1 : 0] m_a_number,
|
input [size_in_mantissa - 1 : 0] inter_rounding_bits,
|
input [size_in_mantissa - 1 : 0] m_b_number,
|
|
input eff_op,
|
input [size_exponent : 0] exp_inter,
|
input [size_exponent : 0] exp_inter,
|
|
input [size_exponent - 1 : 0] exp_difference,
|
output[size_out_mantissa- 1 : 0] resulted_m_o,
|
output[size_out_mantissa- 1 : 0] resulted_m_o,
|
output[size_exponent - 1 : 0] resulted_e_o);
|
output[size_exponent - 1 : 0] resulted_e_o);
|
|
|
wire [size_exponent- 1 : 0] adjust_mantissa;
|
wire [size_exponent- 1 : 0] adjust_mantissa;
|
wire [size_exponent- 1 : 0] unadjusted_exponent;
|
wire [size_exponent- 1 : 0] unadjusted_exponent;
|
wire [double_size_in_mantissa:0] normalized_mantissa;
|
wire [double_size_in_mantissa:0] normalized_mantissa;
|
|
|
|
wire [size_in_mantissa-1: 0] shifted_m_b;
|
|
wire [size_in_mantissa+1: 0] adder_mantissa;
|
|
wire [size_in_mantissa : 0] unnormalized_mantissa;
|
|
|
|
wire [size_in_mantissa - 1 : 0] initial_rounding_bits, inter_rounding_bits;
|
|
|
wire dummy_bit;
|
wire dummy_bit;
|
|
|
|
//shift m_b_number
|
|
shifter #( .INPUT_SIZE(size_in_mantissa),
|
|
.SHIFT_SIZE(size_exponent),
|
|
.OUTPUT_SIZE(double_size_in_mantissa),
|
|
.DIRECTION(1'b0), //0=right, 1=left
|
|
.PIPELINE(pipeline),
|
|
.POSITION(pipeline_pos))
|
|
m_b_shifter_instance( .a(m_b_number),//mantissa
|
|
.arith(1'b0),//logical shift
|
|
.shft(exp_difference),
|
|
.shifted_a({shifted_m_b, initial_rounding_bits}));
|
|
|
|
//compute unnormalized_mantissa
|
|
assign adder_mantissa = (eff_op)? ({1'b0, m_a_number} - {1'b0, shifted_m_b}) : ({1'b0, m_a_number} + {1'b0, shifted_m_b});
|
|
|
|
assign {unnormalized_mantissa, inter_rounding_bits} =
|
|
(adder_mantissa[size_in_mantissa + 1])? ({~adder_mantissa[size_in_mantissa : 0], ~initial_rounding_bits}) :
|
|
({adder_mantissa[size_in_mantissa : 0], initial_rounding_bits});
|
|
|
assign adjust_mantissa = unnormalized_mantissa[size_in_mantissa]? 2'd0 :
|
assign adjust_mantissa = unnormalized_mantissa[size_in_mantissa]? 2'd0 :
|
unnormalized_mantissa[size_in_mantissa-1]? 2'd1 : 2'd2;
|
unnormalized_mantissa[size_in_mantissa-1]? 2'd1 : 2'd2;
|
|
|
|
|
//compute shifting over unnormalized_mantissa
|
//compute shifting over unnormalized_mantissa
|