| 1 |
90 |
robfinch |
`timescale 1ns / 1ps
|
| 2 |
|
|
// ============================================================================
|
| 3 |
|
|
// __
|
| 4 |
|
|
// \\__/ o\ (C) 2006-2022 Robert Finch, Waterloo
|
| 5 |
|
|
// \ __ / All rights reserved.
|
| 6 |
|
|
// \/_// robfinch@finitron.ca
|
| 7 |
|
|
// ||
|
| 8 |
|
|
//
|
| 9 |
|
|
// fpCvt32To64.sv
|
| 10 |
|
|
// - decimal floating convert single to double
|
| 11 |
|
|
//
|
| 12 |
|
|
//
|
| 13 |
|
|
// BSD 3-Clause License
|
| 14 |
|
|
// Redistribution and use in source and binary forms, with or without
|
| 15 |
|
|
// modification, are permitted provided that the following conditions are met:
|
| 16 |
|
|
//
|
| 17 |
|
|
// 1. Redistributions of source code must retain the above copyright notice, this
|
| 18 |
|
|
// list of conditions and the following disclaimer.
|
| 19 |
|
|
//
|
| 20 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
| 21 |
|
|
// this list of conditions and the following disclaimer in the documentation
|
| 22 |
|
|
// and/or other materials provided with the distribution.
|
| 23 |
|
|
//
|
| 24 |
|
|
// 3. Neither the name of the copyright holder nor the names of its
|
| 25 |
|
|
// contributors may be used to endorse or promote products derived from
|
| 26 |
|
|
// this software without specific prior written permission.
|
| 27 |
|
|
//
|
| 28 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 29 |
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 30 |
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 31 |
|
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 32 |
|
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 33 |
|
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 34 |
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 35 |
|
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 36 |
|
|
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 37 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 38 |
|
|
//
|
| 39 |
|
|
// ============================================================================
|
| 40 |
|
|
|
| 41 |
|
|
import fp32Pkg::*;
|
| 42 |
|
|
import fp64Pkg::*;
|
| 43 |
|
|
|
| 44 |
|
|
module fpCvt32To64(i, o);
|
| 45 |
|
|
input FP32 i;
|
| 46 |
|
|
output FP64 o;
|
| 47 |
|
|
|
| 48 |
|
|
wire [10:0] bias64 = 11'h3FF;
|
| 49 |
|
|
wire [ 7:0] bias32 = 8'h7F;
|
| 50 |
|
|
|
| 51 |
|
|
always_comb
|
| 52 |
|
|
o.sign = i.sign;
|
| 53 |
|
|
always_comb
|
| 54 |
|
|
if (i.exp==8'hFF) // Keep infinity / nan status
|
| 55 |
|
|
o.exp = 11'h7FF;
|
| 56 |
|
|
else
|
| 57 |
|
|
o.exp = bias64 - bias32 + i.exp;
|
| 58 |
|
|
always_comb
|
| 59 |
|
|
o.sig = {i.sig,29'd0};
|
| 60 |
|
|
|
| 61 |
|
|
endmodule
|