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/] [FarPath.v] - Blame information for rev 16

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:31:57 11/19/2013 
7
// Design Name: 
8
// Module Name:    FarPath 
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
module FarPath  #(      parameter size_in_mantissa                      = 24, //1.M
22 9 constantin
                                                        parameter size_out_mantissa             = 24,
23
                                                        parameter size_exponent                         = 8,
24
                                                        parameter pipeline                                      = 0,
25
                                                        parameter pipeline_pos                          = 0,     // 8 bits
26
                                                        parameter size_counter                          = 5,    //log2(size_in_mantissa) + 1 = 5)
27
                                                        parameter double_size_in_mantissa   = size_in_mantissa + size_in_mantissa)
28 10 constantin
                                                (       input [size_in_mantissa - 1     : 0] m_a_number,
29
                                                        input [size_in_mantissa - 1 : 0] m_b_number,
30
                                                        input eff_op,
31 9 constantin
                                                        input [size_exponent            : 0] exp_inter,
32 10 constantin
                                                        input [size_exponent - 1 : 0] exp_difference,
33 9 constantin
                                                        output[size_out_mantissa- 1 : 0] resulted_m_o,
34
                                                        output[size_exponent - 1        : 0] resulted_e_o);
35 8 constantin
 
36 9 constantin
        wire [size_exponent- 1 : 0] adjust_mantissa;
37
        wire [size_exponent- 1 : 0] unadjusted_exponent;
38
        wire [double_size_in_mantissa:0] normalized_mantissa;
39 8 constantin
 
40 10 constantin
        wire [size_in_mantissa-1: 0] shifted_m_b;
41
        wire [size_in_mantissa+1: 0] adder_mantissa;
42
        wire [size_in_mantissa  : 0] unnormalized_mantissa;
43
 
44
        wire [size_in_mantissa - 1 : 0] initial_rounding_bits, inter_rounding_bits;
45
 
46 8 constantin
        wire dummy_bit;
47 10 constantin
 
48
        //shift m_b_number                              
49
        shifter #(      .INPUT_SIZE(size_in_mantissa),
50
                                .SHIFT_SIZE(size_exponent),
51
                                .OUTPUT_SIZE(double_size_in_mantissa),
52
                                .DIRECTION(1'b0), //0=right, 1=left
53
                                .PIPELINE(pipeline),
54
                                .POSITION(pipeline_pos))
55
                m_b_shifter_instance(   .a(m_b_number),//mantissa
56
                                                                .arith(1'b0),//logical shift
57
                                                                .shft(exp_difference),
58
                                                                .shifted_a({shifted_m_b, initial_rounding_bits}));
59
 
60
        //compute unnormalized_mantissa
61
        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});
62
 
63
        assign {unnormalized_mantissa, inter_rounding_bits} =
64
                                                                (adder_mantissa[size_in_mantissa + 1])? ({~adder_mantissa[size_in_mantissa : 0], ~initial_rounding_bits}) :
65
                                                                                                                                                ({adder_mantissa[size_in_mantissa       : 0], initial_rounding_bits});
66
 
67 9 constantin
        assign adjust_mantissa = unnormalized_mantissa[size_in_mantissa]? 2'd0 :
68
                                                                                unnormalized_mantissa[size_in_mantissa-1]? 2'd1 : 2'd2;
69 8 constantin
 
70
 
71
        //compute shifting over unnormalized_mantissa
72 9 constantin
        shifter #(      .INPUT_SIZE(double_size_in_mantissa+1),
73 8 constantin
                                        .SHIFT_SIZE(size_exponent),
74 9 constantin
                                        .OUTPUT_SIZE(double_size_in_mantissa+2),
75 8 constantin
                                        .DIRECTION(1'b1),
76
                                        .PIPELINE(pipeline),
77
                                        .POSITION(pipeline_pos))
78 9 constantin
                unnormalized_no_shifter_instance(.a({unnormalized_mantissa, inter_rounding_bits}),
79 8 constantin
                                                                                                        .arith(1'b0),
80
                                                                                                        .shft(adjust_mantissa),
81
                                                                                                        .shifted_a({normalized_mantissa, dummy_bit}));
82
 
83
        //instantiate rounding_component
84
        rounding #(     .SIZE_MOST_S_MANTISSA(size_out_mantissa),
85
                                        .SIZE_LEAST_S_MANTISSA(size_out_mantissa + 2'd1))
86 9 constantin
                rounding_instance(      .unrounded_mantissa(normalized_mantissa[double_size_in_mantissa : double_size_in_mantissa - size_out_mantissa + 1]),
87
                                                                        .dummy_bits(normalized_mantissa[double_size_in_mantissa - size_out_mantissa: 0]),
88 8 constantin
                                                                        .rounded_mantissa(resulted_m_o));
89 9 constantin
 
90
        assign unadjusted_exponent = exp_inter - adjust_mantissa;
91
        assign resulted_e_o = unadjusted_exponent + 1'b1;
92
 
93 8 constantin
endmodule

powered by: WebSVN 2.1.0

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