mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Fixed issue #57 of sign selection for improperly NaN-boxed number
This commit is contained in:
parent
7923d32c3a
commit
adc22235be
@ -85,7 +85,7 @@ module unpackinput (
|
|||||||
PostBox = In;
|
PostBox = In;
|
||||||
|
|
||||||
// choose sign bit depending on format - 1=larger precsion 0=smaller precision
|
// choose sign bit depending on format - 1=larger precsion 0=smaller precision
|
||||||
assign Sgn = Fmt ? In[`FLEN-1] : In[`LEN1-1];
|
assign Sgn = Fmt ? In[`FLEN-1] : (BadNaNBox ? 0 : In[`LEN1-1]); // improperly boxed NaNs are treated as positive
|
||||||
|
|
||||||
// extract the fraction, add trailing zeroes to the mantissa if nessisary
|
// extract the fraction, add trailing zeroes to the mantissa if nessisary
|
||||||
assign Frac = Fmt ? In[`NF-1:0] : {In[`NF1-1:0], (`NF-`NF1)'(0)};
|
assign Frac = Fmt ? In[`NF-1:0] : {In[`NF1-1:0], (`NF-`NF1)'(0)};
|
||||||
@ -151,6 +151,8 @@ module unpackinput (
|
|||||||
|
|
||||||
// extract the sign bit
|
// extract the sign bit
|
||||||
always_comb
|
always_comb
|
||||||
|
if (BadNaNBox) Sgn = 0; // improperly boxed NaNs are treated as positive
|
||||||
|
else
|
||||||
case (Fmt)
|
case (Fmt)
|
||||||
`FMT: Sgn = In[`FLEN-1];
|
`FMT: Sgn = In[`FLEN-1];
|
||||||
`FMT1: Sgn = In[`LEN1-1];
|
`FMT1: Sgn = In[`LEN1-1];
|
||||||
@ -237,6 +239,8 @@ module unpackinput (
|
|||||||
|
|
||||||
// extract sign bit
|
// extract sign bit
|
||||||
always_comb
|
always_comb
|
||||||
|
if (BadNaNBox) Sgn = 0; // improperly boxed NaNs are treated as positive
|
||||||
|
else
|
||||||
case (Fmt)
|
case (Fmt)
|
||||||
2'b11: Sgn = In[`Q_LEN-1];
|
2'b11: Sgn = In[`Q_LEN-1];
|
||||||
2'b01: Sgn = In[`D_LEN-1];
|
2'b01: Sgn = In[`D_LEN-1];
|
||||||
|
Loading…
Reference in New Issue
Block a user