Modify Fround Tmask to work for X=1

This commit is contained in:
Jordan Carlin 2024-05-25 12:56:02 -07:00
parent fb77440a64
commit b830d20f2d
No known key found for this signature in database

View File

@ -79,7 +79,7 @@ module fround import cvw::*; #(parameter cvw_t P) (
// Logic for nonnegative mask and rounding bits // Logic for nonnegative mask and rounding bits
assign IMask = {1'b1, {P.NF{1'b0}}} >>> E; assign IMask = {1'b1, {P.NF{1'b0}}} >>> E;
assign Tmasknonneg = ~(IMask >>> 1'b1); assign Tmasknonneg = ~IMask >>> 1'b1;
assign HotE = IMask & ~(IMask << 1'b1); assign HotE = IMask & ~(IMask << 1'b1);
assign HotEP1 = HotE >> 1'b1; assign HotEP1 = HotE >> 1'b1;
assign Lnonneg = |(Xm & HotE); assign Lnonneg = |(Xm & HotE);
@ -139,7 +139,7 @@ module fround import cvw::*; #(parameter cvw_t P) (
else if (Elt0) // 0 <= |X| < 1 rounds to 0 or 1 else if (Elt0) // 0 <= |X| < 1 rounds to 0 or 1
if (RoundUp) W = {Xs, P.BIAS[P.NE-1:0], {P.NF{1'b0}}}; // round to +/- 1 if (RoundUp) W = {Xs, P.BIAS[P.NE-1:0], {P.NF{1'b0}}}; // round to +/- 1
else W = {Xs, {(P.FLEN-1){1'b0}}}; // round to +/- 0 else W = {Xs, {(P.FLEN-1){1'b0}}}; // round to +/- 0
else begin // |X| > 1 rounds to an integer else begin // |X| >= 1 rounds to an integer
if (RoundUp & Two) W = {Xs, Xep1, {(P.NF){1'b0}}}; // Round up to 2.0 if (RoundUp & Two) W = {Xs, Xep1, {(P.NF){1'b0}}}; // Round up to 2.0
else if (RoundUp) W = {Xs, Xe, Rnd[P.NF-1:0]}; // Round up to Rnd else if (RoundUp) W = {Xs, Xe, Rnd[P.NF-1:0]}; // Round up to Rnd
else W = {Xs, Xe, Trunc[P.NF-1:0]}; // Round down to Trunc else W = {Xs, Xe, Trunc[P.NF-1:0]}; // Round down to Trunc