OpenCores
URL https://opencores.org/ocsvn/xilinx_virtex_fp_library/xilinx_virtex_fp_library/trunk

Subversion Repositories xilinx_virtex_fp_library

[/] [xilinx_virtex_fp_library/] [trunk/] [GeneralPrecMAF/] [Multiply_Accumulate.v] - Diff between revs 17 and 19

Show entire file | Details | Blame | View Log

Rev 17 Rev 19
Line 30... Line 30...
                                                                                parameter pipeline_pos  = 0,  //8 bits
                                                                                parameter pipeline_pos  = 0,  //8 bits
 
 
                                                                                parameter size = size_exponent + size_mantissa + size_exception_field,
                                                                                parameter size = size_exponent + size_mantissa + size_exception_field,
                                                                                parameter size_mul_mantissa = size_mantissa + size_mantissa,
                                                                                parameter size_mul_mantissa = size_mantissa + size_mantissa,
                                                                                parameter size_mul_counter = size_counter + 1)
                                                                                parameter size_mul_counter = size_counter + 1)
                                                                        (       input clk,
                                                                        (       input [size - 1:0] a_number_i,
                                                                                input rst,
 
                                                                                input [size - 1:0] a_number_i,
 
                                                                                input [size - 1:0] b_number_i,
                                                                                input [size - 1:0] b_number_i,
                                                                                input [size - 1:0] c_number_i,
                                                                                input [size - 1:0] c_number_i,
                                                                                input sub,
                                                                                input sub,
                                                                                output[size - 1:0] resulting_number_o);
                                                                                output[size - 1:0] resulting_number_o);
 
 
Line 52... Line 50...
 
 
        wire [size_exponent - 1 : 0] exp_difference;
        wire [size_exponent - 1 : 0] exp_difference;
        wire [size_exponent - 1 : 0] unadjusted_exponent;
        wire [size_exponent - 1 : 0] unadjusted_exponent;
        wire [size_exponent     : 0] exp_inter;
        wire [size_exponent     : 0] exp_inter;
 
 
 
        wire [size_mantissa - 2 : 0] mul_mantissa;
 
 
        wire [size_mul_mantissa - 1     : 0] m_ab_mantissa, c_mantissa;
        wire [size_mul_mantissa - 1     : 0] m_ab_mantissa, c_mantissa;
        wire [size_exponent                     : 0] e_ab_number_inter, e_ab_number;
        wire [size_exponent                     : 0] e_ab_number_inter, e_ab_number;
        wire [size_mul_counter - 1      : 0] lz_mul;
        wire [size_mul_counter - 1      : 0] lz_mul;
 
 
        wire zero_flag;
        wire zero_flag;
Line 66... Line 66...
        wire [size_mul_mantissa + 1 : 0] normalized_mantissa, adder_mantissa;
        wire [size_mul_mantissa + 1 : 0] normalized_mantissa, adder_mantissa;
        wire [size_mul_mantissa         : 0] unnormalized_mantissa;
        wire [size_mul_mantissa         : 0] unnormalized_mantissa;
        wire [size_mul_mantissa - 1 : 0] shifted_m_ab;
        wire [size_mul_mantissa - 1 : 0] shifted_m_ab;
        wire [size_mul_mantissa - 1 : 0] m_c, m_ab;
        wire [size_mul_mantissa - 1 : 0] m_c, m_ab;
 
 
        wire [size_exception_field - 1 : 0] sp_case_o, sp_case_result_o;
        wire [size_exception_field - 1 : 0] sp_case_mul_result_o;
 
 
 
        wire [size_exception_field - 1 : 0] sp_case_result_o;
        wire [size_mantissa - 2 : 0] final_mantissa;
        wire [size_mantissa - 2 : 0] final_mantissa;
        wire [size_exponent - 1 : 0] final_exponent;
        wire [size_exponent - 1 : 0] final_exponent;
        wire [size_mantissa : 0] rounded_mantissa;
        wire [size_mantissa : 0] rounded_mantissa;
 
 
 
 
Line 94... Line 96...
                                        .size_mul_mantissa(size_mul_mantissa))
                                        .size_mul_mantissa(size_mul_mantissa))
                multiply_instance (     .a_mantissa_i(m_a_number),
                multiply_instance (     .a_mantissa_i(m_a_number),
                                                                        .b_mantissa_i(m_b_number),
                                                                        .b_mantissa_i(m_b_number),
                                                                        .mul_mantissa(m_ab_mantissa));
                                                                        .mul_mantissa(m_ab_mantissa));
 
 
 
        assign mul_mantissa = m_ab_mantissa[size_mul_mantissa-1]?       m_ab_mantissa[size_mul_mantissa-2 : size_mul_mantissa - size_mantissa] :
 
                                                                                                                                m_ab_mantissa[size_mul_mantissa-3 : size_mul_mantissa - size_mantissa - 1];
 
 
        assign c_mantissa       = {1'b0,m_c_number, {(shift_mantissa_0_bits){1'b0}}};
        assign c_mantissa       = {1'b0,m_c_number, {(shift_mantissa_0_bits){1'b0}}};
        assign e_ab_number_inter = e_a_number + e_b_number;
        assign e_ab_number_inter = e_a_number + e_b_number;
        assign e_ab_number = e_ab_number_inter  - {(bias_0_bits){1'b1}};
        assign e_ab_number = e_ab_number_inter  - {(bias_0_bits){1'b1}};
 
 
        //find the greater exponent
        //find the greater exponent
Line 169... Line 174...
                                .SIZE_LEAST_S_MANTISSA(size_mul_mantissa+2))
                                .SIZE_LEAST_S_MANTISSA(size_mul_mantissa+2))
                rounding_instance(      .unrounded_mantissa({1'b0, normalized_mantissa[size_mul_mantissa+1 : size_mantissa + 2]}),
                rounding_instance(      .unrounded_mantissa({1'b0, normalized_mantissa[size_mul_mantissa+1 : size_mantissa + 2]}),
                                    .dummy_bits({normalized_mantissa[size_mantissa + 1 : 0],final_rounding_bits}),
                                    .dummy_bits({normalized_mantissa[size_mantissa + 1 : 0],final_rounding_bits}),
                                    .rounded_mantissa(rounded_mantissa));
                                    .rounded_mantissa(rounded_mantissa));
 
 
        //instantiate special_cases_mul_acc component
        //instantiate special_cases_mul and special_cases_mul_acc components
        special_cases_mul_acc   #(      .size_exception_field(size_exception_field),
        special_cases_mul_acc   #(      .size_exception_field(size_exception_field),
                                                                                .zero(zero),
                                                                                .zero(zero),
                                                                                .normal_number(normal_number),
                                                                                .normal_number(normal_number),
                                                                                .infinity(infinity),
                                                                                .infinity(infinity),
                                                                                .NaN(NaN))
                                                                                .NaN(NaN))
                special_cases_mul_acc_instance  (       .sp_case_a_number(sp_case_a_number),
                special_cases_mul_acc_instance  (       .sp_case_a_number(sp_case_a_number),
                                                                                                                .sp_case_b_number(sp_case_b_number),
                                                                                                                .sp_case_b_number(sp_case_b_number),
                                                                                                                .sp_case_c_number(sp_case_c_number),
                                                                                                                .sp_case_c_number(sp_case_c_number),
                                                                                                                .sp_case_result_o(sp_case_result_o));
                                                                                                                .sp_case_result_o(sp_case_result_o));
 
 
 
        special_cases_mul       #(      .size_exception_field(size_exception_field),
 
                                                        .zero(zero),
 
                                                        .normal_number(normal_number),
 
                                                        .infinity(infinity),
 
                                                        .NaN(NaN))
 
                special_cases_mul_instance(     .sp_case_a_number(sp_case_a_number),
 
                                                                        .sp_case_b_number(sp_case_b_number),
 
                                                                        .sp_case_result_o(sp_case_mul_result_o));
 
 
        //set zero_flag in case of equal numbers
        //set zero_flag in case of equal numbers
        assign zero_flag = ~((|{rounded_mantissa, sp_case_result_o[1]}) & (|sp_case_result_o));
        assign zero_flag = ~(|(rounded_mantissa));
 
 
        //compute resulted_sign
        //compute resulted_sign
        assign sign_res =       (eff_op)?       (!c_greater_exponent[size_exponent]?
        assign sign_res =       (eff_op)?       (!c_greater_exponent[size_exponent]?
                                                                                (!ab_greater_exponent[size_exponent]? ~adder_mantissa[size_mul_mantissa+1] : s_c_number) : ~(s_b_number^s_a_number)) : s_c_number;
                                                                                (!ab_greater_exponent[size_exponent]? ~adder_mantissa[size_mul_mantissa+1] : s_c_number) : ~(s_b_number^s_a_number)) : s_c_number;
 
 
Line 193... Line 207...
                                                                        (rounded_mantissa[size_mantissa : 1]) :
                                                                        (rounded_mantissa[size_mantissa : 1]) :
                                                                        (rounded_mantissa[size_mantissa-1: 0]);
                                                                        (rounded_mantissa[size_mantissa-1: 0]);
 
 
        assign unadjusted_exponent = exp_inter - lz_mul;
        assign unadjusted_exponent = exp_inter - lz_mul;
        assign final_exponent = unadjusted_exponent + 2'd2;
        assign final_exponent = unadjusted_exponent + 2'd2;
        assign resulting_number_o = (zero_flag)? {size{1'b0}} :{sp_case_result_o, sign_res, final_exponent, final_mantissa};
        assign resulting_number_o = (zero_flag)? {size{1'b0}} :
 
                                                                (!sp_case_a_number || !sp_case_b_number)? {c_number_i[size-1 : size-size_exception_field], s_c_number, c_number_i[size-1-size_exception_field-1 : 0]} :
 
                                                                (!sp_case_c_number)?
 
                                                                        (eff_op?
 
                                                                                {sp_case_mul_result_o, ~(s_a_number^s_b_number), e_ab_number[size_exponent-1 : 0], mul_mantissa} :
 
                                                                                {sp_case_mul_result_o, s_a_number^s_b_number, e_ab_number[size_exponent-1 : 0], mul_mantissa}) :
 
                                                                                        {sp_case_result_o, sign_res, final_exponent, final_mantissa};
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.