Files
gps/hardware/generated/genesys2-soc-verilog/RoundAnyRawFNToRecFN_4.sv
T
2026-08-06 22:14:52 +03:00

115 lines
5.6 KiB
Systemverilog

// Generated by CIRCT firtool-1.151.0
module RoundAnyRawFNToRecFN_4(
input io_invalidExc,
io_infiniteExc,
io_in_isNaN,
io_in_isInf,
io_in_isZero,
io_in_sign,
input [12:0] io_in_sExp,
input [55:0] io_in_sig,
input [2:0] io_roundingMode,
output [64:0] io_out,
output [4:0] io_exceptionFlags
);
wire roundingMode_near_even = io_roundingMode == 3'h0;
wire roundingMode_odd = io_roundingMode == 3'h6;
wire roundMagUp =
io_roundingMode == 3'h2 & io_in_sign | io_roundingMode == 3'h3 & ~io_in_sign;
wire [11:0] _roundMask_T_1 = ~(io_in_sExp[11:0]);
wire [64:0] roundMask_shift =
$unsigned($signed(65'sh10000000000000000 >>> _roundMask_T_1[5:0]));
wire [31:0] _roundMask_T_12 =
{16'h0, roundMask_shift[44:29]} | {roundMask_shift[28:13], 16'h0};
wire [31:0] _roundMask_T_22 =
{8'h0, _roundMask_T_12[31:8] & 24'hFF00FF}
| {_roundMask_T_12[23:0] & 24'hFF00FF, 8'h0};
wire [31:0] _roundMask_T_32 =
{4'h0, _roundMask_T_22[31:4] & 28'hF0F0F0F}
| {_roundMask_T_22[27:0] & 28'hF0F0F0F, 4'h0};
wire [31:0] _roundMask_T_42 =
{2'h0, _roundMask_T_32[31:2] & 30'h33333333}
| {_roundMask_T_32[29:0] & 30'h33333333, 2'h0};
wire [15:0] _roundMask_T_63 =
{8'h0, roundMask_shift[60:53]} | {roundMask_shift[52:45], 8'h0};
wire [15:0] _roundMask_T_73 =
{4'h0, _roundMask_T_63[15:4] & 12'hF0F} | {_roundMask_T_63[11:0] & 12'hF0F, 4'h0};
wire [15:0] _roundMask_T_83 =
{2'h0, _roundMask_T_73[15:2] & 14'h3333} | {_roundMask_T_73[13:0] & 14'h3333, 2'h0};
wire [64:0] roundMask_shift_1 =
$unsigned($signed(65'sh10000000000000000 >>> _roundMask_T_1[5:0]));
wire [53:0] _roundMask_T_128 =
_roundMask_T_1[11]
? (_roundMask_T_1[10]
? {~(_roundMask_T_1[9] | _roundMask_T_1[8] | _roundMask_T_1[7]
| _roundMask_T_1[6]
? 51'h0
: ~{{1'h0, _roundMask_T_42[31:1] & 31'h55555555}
| {_roundMask_T_42[30:0] & 31'h55555555, 1'h0},
{1'h0, _roundMask_T_83[15:1] & 15'h5555}
| {_roundMask_T_83[14:0] & 15'h5555, 1'h0},
roundMask_shift[61],
roundMask_shift[62],
roundMask_shift[63]}),
3'h7}
: {51'h0,
_roundMask_T_1[9] & _roundMask_T_1[8] & _roundMask_T_1[7]
& _roundMask_T_1[6]
? {roundMask_shift_1[0], roundMask_shift_1[1], roundMask_shift_1[2]}
: 3'h0})
: 54'h0;
wire _common_underflow_T_4 = _roundMask_T_128[0] | io_in_sig[55];
wire [54:0] _GEN = {1'h1, ~(_roundMask_T_128[53:1]), ~_common_underflow_T_4};
wire [54:0] _GEN_0 = {_roundMask_T_128[53:1], _common_underflow_T_4, 1'h1};
wire [54:0] _roundPosBit_T = io_in_sig[55:1] & _GEN & _GEN_0;
wire roundPosBit = |_roundPosBit_T;
wire [54:0] _anyRoundExtra_T = io_in_sig[54:0] & _GEN_0;
wire anyRound = |{_roundPosBit_T, _anyRoundExtra_T};
wire _overflow_roundMagUp_T = roundingMode_near_even | io_roundingMode == 3'h4;
wire [54:0] roundedSig =
_overflow_roundMagUp_T & roundPosBit | roundMagUp & anyRound
? {1'h0, io_in_sig[55:2] | {_roundMask_T_128[53:1], _common_underflow_T_4}} + 55'h1
& ~(roundingMode_near_even & roundPosBit & _anyRoundExtra_T == 55'h0
? {_roundMask_T_128[53:1], _common_underflow_T_4, 1'h1}
: 55'h0)
: {1'h0, io_in_sig[55:2] & {~(_roundMask_T_128[53:1]), ~_common_underflow_T_4}}
| (roundingMode_odd & anyRound ? _GEN & _GEN_0 : 55'h0);
wire [13:0] sRoundedExp = {io_in_sExp[12], io_in_sExp} + {12'h0, roundedSig[54:53]};
wire common_totalUnderflow = $signed(sRoundedExp) < 14'sh3CE;
wire isNaNOut = io_invalidExc | io_in_isNaN;
wire notNaN_isSpecialInfOut = io_infiniteExc | io_in_isInf;
wire commonCase = ~isNaNOut & ~notNaN_isSpecialInfOut & ~io_in_isZero;
wire overflow = commonCase & $signed(sRoundedExp[13:10]) > 4'sh2;
wire overflow_roundMagUp = _overflow_roundMagUp_T | roundMagUp;
wire pegMinNonzeroMagOut =
commonCase & common_totalUnderflow & (roundMagUp | roundingMode_odd);
wire pegMaxFiniteMagOut = overflow & ~overflow_roundMagUp;
wire notNaN_isInfOut = notNaN_isSpecialInfOut | overflow & overflow_roundMagUp;
assign io_out =
{~isNaNOut & io_in_sign,
sRoundedExp[11:0] & ~(io_in_isZero | common_totalUnderflow ? 12'hE00 : 12'h0)
& ~(pegMinNonzeroMagOut ? 12'hC31 : 12'h0) & {1'h1, ~pegMaxFiniteMagOut, 10'h3FF}
& {2'h3, ~notNaN_isInfOut, 9'h1FF} | (pegMinNonzeroMagOut ? 12'h3CE : 12'h0)
| (pegMaxFiniteMagOut ? 12'hBFF : 12'h0) | (notNaN_isInfOut ? 12'hC00 : 12'h0)
| (isNaNOut ? 12'hE00 : 12'h0),
(isNaNOut | io_in_isZero | common_totalUnderflow
? {isNaNOut, 51'h0}
: io_in_sig[55] ? roundedSig[52:1] : roundedSig[51:0])
| {52{pegMaxFiniteMagOut}}};
assign io_exceptionFlags =
{io_invalidExc,
io_infiniteExc,
overflow,
commonCase
& (common_totalUnderflow | anyRound & io_in_sExp[12:11] != 2'h1
& (io_in_sig[55] ? _roundMask_T_128[1] : _common_underflow_T_4)
& ~(~(io_in_sig[55] ? _roundMask_T_128[2] : _roundMask_T_128[1])
& (io_in_sig[55] ? roundedSig[54] : roundedSig[53]) & roundPosBit
& (_overflow_roundMagUp_T & (io_in_sig[55] ? io_in_sig[2] : io_in_sig[1])
| roundMagUp & (|{io_in_sig[55] & io_in_sig[2], io_in_sig[1:0]})))),
overflow | commonCase
& (|{common_totalUnderflow, _roundPosBit_T, _anyRoundExtra_T})};
endmodule