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/] [DualPathFPAdderMappedConversions/] [rounding.v] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 constantin
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3 19 constantin
// Company:     UPT
4
// Engineer:    Constantina-Elena Gavriliu
5 11 constantin
// 
6
// Create Date:    16:09:49 11/04/2013 
7
// Design Name: 
8
// Module Name:    rounding 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12 19 constantin
// Description: A ± B rounding
13 11 constantin
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
 
22
module rounding #(      parameter SIZE_MOST_S_MANTISSA = 24,
23
                                        parameter SIZE_LEAST_S_MANTISSA= 25)
24
                                (       input [SIZE_MOST_S_MANTISSA - 1 : 0] unrounded_mantissa,
25
                                        input [SIZE_LEAST_S_MANTISSA- 1 : 0] dummy_bits,
26 19 constantin
                                        input correction,
27 11 constantin
                                        output[SIZE_MOST_S_MANTISSA - 1 : 0] rounded_mantissa);
28 19 constantin
 
29 11 constantin
        wire g, sticky, round_dec;
30 19 constantin
 
31
        assign g                = dummy_bits[SIZE_LEAST_S_MANTISSA - 1];
32
        assign sticky   = (|(dummy_bits[SIZE_LEAST_S_MANTISSA - 3 : 0]));
33
        assign round    = dummy_bits[SIZE_LEAST_S_MANTISSA - 2];
34
 
35
        assign round_dec                = g & (unrounded_mantissa[0] | sticky | round);
36
        assign rounded_mantissa = correction? (round_dec? unrounded_mantissa : unrounded_mantissa - 1'b1) : (round_dec? unrounded_mantissa + 1 : unrounded_mantissa);
37 11 constantin
 
38
endmodule

powered by: WebSVN 2.1.0

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