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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog/] [fpLOOUnit.v] - Diff between revs 9 and 26

Show entire file | Details | Blame | View Log

Rev 9 Rev 26
Line 1... Line 1...
`timescale 1ns / 1ps
`timescale 1ns / 1ps
// ============================================================================
// ============================================================================
//        __
//        __
//   \\__/ o\    (C) 2006-2016  Robert Finch, Waterloo
//   \\__/ o\    (C) 2006-2019  Robert Finch, Waterloo
//    \  __ /    All rights reserved.
//    \  __ /    All rights reserved.
//     \/_//     robfinch<remove>@finitron.ca
//     \/_//     robfinch<remove>@finitron.ca
//       ||
//       ||
//
//
//      fpLOOUnit.v
//      fpLOOUnit.v
Line 28... Line 28...
//      i2f - convert integer to floating point
//      i2f - convert integer to floating point
//  f2i - convert floating point to integer
//  f2i - convert floating point to integer
//
//
// ============================================================================
// ============================================================================
 
 
`define FLOAT   6'h36
`define FLT1    4'h1
`define FTOI    6'h02
`define FLT2            4'h2
`define ITOF    6'h03
`define FTOI    5'h02
 
`define ITOF    5'h03
 
`define TRUNC           5'h15
 
`define NXTAFT  5'h0B
 
 
module fpLOOUnit
module fpLOOUnit
#(parameter WID=32)
#(parameter WID=32)
(
(
        input clk,
        input clk,
        input ce,
        input ce,
        input [31:0] ir,
        input [3:0] op4,
 
        input [4:0] func5,
 
        input [2:0] rm,
        input [WID-1:0] a,
        input [WID-1:0] a,
 
        input [WID-1:0] b,
        output reg [WID-1:0] o,
        output reg [WID-1:0] o,
        output done
        output done
);
);
localparam MSB = WID-1;
`include "fpSize.sv"
localparam EMSB = WID==128 ? 14 :
 
                  WID==96 ? 14 :
 
                  WID==80 ? 14 :
 
                  WID==64 ? 10 :
 
                                  WID==52 ? 10 :
 
                                  WID==48 ? 10 :
 
                                  WID==44 ? 10 :
 
                                  WID==42 ? 10 :
 
                                  WID==40 ?  9 :
 
                                  WID==32 ?  7 :
 
                                  WID==24 ?  6 : 4;
 
localparam FMSB = WID==128 ? 111 :
 
                  WID==96 ? 79 :
 
                  WID==80 ? 63 :
 
                  WID==64 ? 51 :
 
                                  WID==52 ? 39 :
 
                                  WID==48 ? 35 :
 
                                  WID==44 ? 31 :
 
                                  WID==42 ? 29 :
 
                                  WID==40 ? 28 :
 
                                  WID==32 ? 22 :
 
                                  WID==24 ? 15 : 9;
 
 
 
wire [WID-1:0] i2f_o;
wire [WID-1:0] i2f_o;
wire [WID-1:0] f2i_o;
wire [WID-1:0] f2i_o;
wire [5:0] op = ir[5:0];
wire [WID-1:0] trunc_o;
wire [5:0] fn = ir[17:12];
wire [WID-1:0] nxtaft_o;
wire [2:0] rm = ir[26:24];
 
wire [1:0] prec = ir[28:27];
delay1 u1 (
 
    .clk(clk),
delay1 u1 (.clk(clk), .ce(ce), .i(op==`FLOAT && (fn==`ITOF||fn==`FTOI)), .o(done) );
    .ce(ce),
i2f #(WID)  ui2fs (.clk(clk), .ce(ce), .rm(rm), .i(a), .o(i2f_o) );
    .i((op4==`FLT1 && (func5==`ITOF||func5==`FTOI||func5==`TRUNC))||(op4==`FLT2 && (func5==`NXTAFT))),
f2i #(WID)  uf2is (.clk(clk), .ce(ce), .i(a), .o(f2i_o) );
    .o(done) );
 
i2f #(WID-4)  ui2fs (.clk(clk), .ce(ce), .rm(rm), .i(a[WID-1:4]), .o(i2f_o) );
 
f2i #(WID-4)  uf2is (.clk(clk), .ce(ce), .i(a[WID-1:4]), .o(f2i_o) );
 
fpTrunc #(WID) urho1 (.clk(clk), .ce(ce), .i(a), .o(trunc_o), .overflow());
 
fpNextAfter #(WID-4) una1 (.clk(clk), .ce(ce), .a(a[WID-1:4]), .b(b[WID-1:4]), .o(nxtaft_o));
 
 
always @*
always @*
        case (op)
        case (op4)
        `FLOAT:
        `FLT1:
       case(fn)
                case(func5)
       `ITOF:   o <= i2f_o;
                `ITOF:   o <= {i2f_o,4'h0};
       `FTOI:   o <= f2i_o;
                `FTOI:   o <= {f2i_o,4'h0};
 
                `TRUNC:  o <= trunc_o;
 
                default: o <= 0;
 
                endcase
 
        `FLT2:
 
                case(func5)
 
                `NXTAFT:        o <= {nxtaft_o,4'h0};
       default: o <= 0;
       default: o <= 0;
       endcase
       endcase
    default:   o <= 0;
    default:   o <= 0;
    endcase
    endcase
 
 

powered by: WebSVN 2.1.0

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