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/] [DualPathFPAdder/] [ClosePath.v] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 constantin
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: 
5
// 
6
// Create Date:    00:32:10 11/19/2013 
7
// Design Name: 
8
// Module Name:    ClosePath 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: A ± B when |Ea-Eb| < 2
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21 9 constantin
module ClosePath        #(      parameter size_in_mantissa                      = 24, //1.M
22 8 constantin
                                                        parameter size_out_mantissa             = 24,
23
                                                        parameter size_exponent                         = 8,
24
                                                        parameter pipeline                                      = 0,
25
                                                        parameter pipeline_pos                          = 0,     // 8 bits
26 9 constantin
                                                        parameter size_counter                          = 5,    //log2(size_in_mantissa) + 1 = 5)
27
                                                        parameter double_size_in_mantissa   = size_in_mantissa + size_in_mantissa)
28 8 constantin
 
29 10 constantin
                                                (       input [size_in_mantissa - 1     : 0] m_a_number,
30
                                                        input [size_in_mantissa - 1 : 0] m_b_number,
31 9 constantin
                                                        input [size_exponent     : 0] exp_inter,
32 10 constantin
                                                        input exp_difference,
33 8 constantin
                                                        output[size_out_mantissa-1:0] resulted_m_o,
34 10 constantin
                                                        output[size_exponent - 1 : 0] resulted_e_o,
35
                                                        output ovf);
36 8 constantin
 
37 9 constantin
        wire [size_counter - 1 : 0] lzs;
38
        wire [size_exponent- 1 : 0] unadjusted_exponent;
39 13 constantin
        wire [1 : 0] adjust_exponent;
40 10 constantin
        wire [2 : 0] dummy_bits;
41
        wire init_shft_bit, shft_bit;
42
 
43
        wire [size_in_mantissa-1: 0] shifted_m_b;
44
        wire [size_in_mantissa+1: 0] adder_mantissa;
45
        wire [size_in_mantissa  : 0] unnormalized_mantissa;
46
        wire [size_in_mantissa  : 0] rounded_mantissa;
47
        wire [size_in_mantissa-1: 0] r_mantissa;
48
 
49 13 constantin
        assign {shifted_m_b, init_shft_bit} = (exp_difference)? {1'b0, m_b_number[size_in_mantissa-1:0]} : {m_b_number, 1'b0};
50 10 constantin
 
51
        //compute unnormalized_mantissa
52
        assign adder_mantissa = {1'b0, m_a_number} - {1'b0, shifted_m_b};
53
 
54
        assign {unnormalized_mantissa, shft_bit} =
55
                                                                (adder_mantissa[size_in_mantissa + 1])? ({~adder_mantissa[size_in_mantissa : 0], ~init_shft_bit}) :
56
                                                                                                                                                ({adder_mantissa[size_in_mantissa       : 0], init_shft_bit});
57
 
58 8 constantin
        //compute leading_zeros over unnormalized mantissa
59 9 constantin
        leading_zeros #(        .SIZE_INT(size_in_mantissa + 1), .SIZE_COUNTER(size_counter), .PIPELINE(pipeline))
60
                leading_zeros_instance (.a(unnormalized_mantissa[size_in_mantissa : 0]),
61
                                                                                .ovf(unnormalized_mantissa[size_in_mantissa]),
62 8 constantin
                                                                                .lz(lzs));
63
 
64
        //compute shifting over unnormalized_mantissa
65 10 constantin
        shifter #(      .INPUT_SIZE(size_in_mantissa + 2),
66 9 constantin
                                        .SHIFT_SIZE(size_counter),
67 10 constantin
                                        .OUTPUT_SIZE(size_in_mantissa + 3),
68 8 constantin
                                        .DIRECTION(1'b1), //0=right, 1=left
69
                                        .PIPELINE(pipeline),
70
                                        .POSITION(pipeline_pos))
71 10 constantin
                shifter_instance(       .a({unnormalized_mantissa, shft_bit}),//mantissa
72
                                                                .arith(adder_mantissa[size_in_mantissa + 1]),//logical shift
73 8 constantin
                                                                .shft(lzs),
74 10 constantin
                                                                .shifted_a({r_mantissa, dummy_bits}));
75 8 constantin
 
76 13 constantin
        assign rounded_mantissa = (adder_mantissa[size_in_mantissa + 1])? {1'b0, r_mantissa} + 1'b1 : {1'b0, r_mantissa};
77 10 constantin
        assign resulted_m_o = (rounded_mantissa[size_in_mantissa])? rounded_mantissa[size_in_mantissa : 1] :
78
                                                                                                                                rounded_mantissa[size_in_mantissa-1:0];
79
 
80 13 constantin
        assign adjust_exponent = rounded_mantissa[size_in_mantissa]? 2'd2 : 2'd1;
81
 
82 10 constantin
        assign ovf = adder_mantissa[size_in_mantissa+1];
83 9 constantin
        assign unadjusted_exponent = exp_inter - lzs;
84 13 constantin
        assign resulted_e_o =  unadjusted_exponent + adjust_exponent;
85 8 constantin
 
86
endmodule

powered by: WebSVN 2.1.0

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