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 18

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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