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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog2/] [DFPRound128.sv] - Diff between revs 57 and 64

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 57 Rev 64
Line 1... Line 1...
// ============================================================================
// ============================================================================
//        __
//        __
//   \\__/ o\    (C) 2006-2020  Robert Finch, Waterloo
//   \\__/ o\    (C) 2006-2021  Robert Finch, Waterloo
//    \  __ /    All rights reserved.
//    \  __ /    All rights reserved.
//     \/_//     robfinch@finitron.ca
//     \/_//     robfinch@finitron.ca
//       ||
//       ||
//
//
//      DFPRound128.sv
//      DFPRound128.sv
Line 50... Line 50...
parameter N=34;
parameter N=34;
input clk;
input clk;
input ce;
input ce;
input [2:0] rm;                 // rounding mode
input [2:0] rm;                 // rounding mode
input DFP128UN i;               // intermediate format input
input DFP128UN i;               // intermediate format input
output DFP128U o;               // rounded output
output DFP128 o;                // packed rounded output
 
 
parameter ROUND_CEILING = 3'd0;
parameter ROUND_CEILING = 3'd0;
parameter ROUND_FLOOR = 3'd1;
parameter ROUND_FLOOR = 3'd1;
parameter ROUND_HALF_UP = 3'd2;
parameter ROUND_HALF_UP = 3'd2;
parameter ROUND_HALF_EVEN = 3'd3;
parameter ROUND_HALF_EVEN = 3'd3;
Line 69... Line 69...
reg  [N*4-1:0] mo;
reg  [N*4-1:0] mo;
reg [13:0] xo1;
reg [13:0] xo1;
reg [N*4-1:0] mo1;
reg [N*4-1:0] mo1;
wire xInf = i.exp==14'h3FFF;
wire xInf = i.exp==14'h3FFF;
wire so0 = i.sign;
wire so0 = i.sign;
assign o = {so,xo,mo};
 
 
 
assign o.nan = nano;
 
assign o.qnan = qnano;
 
assign o.snan = snano;
 
assign o.infinity = infinity;
 
assign o.sign = so;
 
assign o.exp = xo;
 
assign o.sig = mo;
 
 
 
wire [3:0] l = i.sig[7:4];
wire [3:0] l = i.sig[7:4];
wire [3:0] r = i.sig[3:0];
wire [3:0] r = i.sig[3:0];
 
 
reg rnd;
reg rnd;
Line 178... Line 169...
        4'b1010:        mo <= {4'h1,rounded2[N*4-1: 4]};        // exponent incremented (new MSD generated), number was normalized
        4'b1010:        mo <= {4'h1,rounded2[N*4-1: 4]};        // exponent incremented (new MSD generated), number was normalized
        4'b1011:        mo <= rounded2[N*4-1:0];                                        // exponent incremented (new MSB generated), number was denormalized, number became normalized
        4'b1011:        mo <= rounded2[N*4-1:0];                                        // exponent incremented (new MSB generated), number was denormalized, number became normalized
        4'b11??:        mo <= {N*4{1'd0}};                                                                      // number became infinite, no need to check carry etc., rnd would be zero if input was NaN or infinite
        4'b11??:        mo <= {N*4{1'd0}};                                                                      // number became infinite, no need to check carry etc., rnd would be zero if input was NaN or infinite
        endcase
        endcase
 
 
 
//------------------------------------------------------------
 
// Clock #4
 
// - Pack output
 
//------------------------------------------------------------
 
 
 
DFP128U o1;
 
DFP128 o2;
 
 
 
assign o1.nan = nano;
 
assign o1.qnan = qnano;
 
assign o1.snan = snano;
 
assign o1.infinity = infinity;
 
assign o1.sign = so;
 
assign o1.exp = xo;
 
assign o1.sig = mo;
 
 
 
DFPPack128 u41 (o1, o2);
 
always_ff @(posedge clk)
 
        if (ce) o <= o2;
 
 
endmodule
endmodule

powered by: WebSVN 2.1.0

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