Skip to content

Commit 83d6d49

Browse files
authored
Merge pull request #167 from liujed/fix-pfpu_cmp
Always signal when comparing with signalling NaN
2 parents 7c6f2f5 + 916f9eb commit 83d6d49

File tree

3 files changed

+4
-31
lines changed

3 files changed

+4
-31
lines changed

bench/formal/Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ TESTS := mor1kx_cache_lru \
3737
BROKEN_TESTS := \
3838
mor1kx_lsu_cappuccino \
3939
mor1kx_cpu_cappuccino \
40-
mor1kx \
41-
pfpu32_cmp_snan_bug
40+
mor1kx
4241

4342
all: $(TESTS)
4443
clean:

bench/formal/pfpu32_cmp_snan_bug.sby

-17
This file was deleted.

rtl/verilog/pfpu32/pfpu32_cmp.v

+3-12
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ wire eqne = (generic_cmp_opc_i == GENERIC_SFEQ) |
102102
(generic_cmp_opc_i == GENERIC_SFNE);
103103

104104
// Comparison is invalid if:
105-
// 1) sNaN is an operand of ordered/unordered EQ/NE comparison
105+
// 1) sNaN is an operand of any comparison
106106
// 2) NaN is an operand of ordered LT/LE/GT/GE comparison
107-
wire inv_cmp = (eqne & snan) | ((~eqne) & anan & (~unordered_cmp_bit_i));
107+
wire inv_cmp = snan | ((~eqne) & anan & (~unordered_cmp_bit_i));
108108

109109

110110
////////////////////////////////////////////////////////////////////////
@@ -383,16 +383,7 @@ assign ready_o = fpu_op_is_comp_i;
383383

384384
if (fpu_op_is_comp_i) begin
385385
assert (cmp_flag_o == f_cmp_flag);
386-
`ifndef PFPU32_FCMP_SNAN_BUG
387-
// XXX inv_o diverges from expected behaviour when sNaN is passed to
388-
// sfult, sfule, sfugt, or sfuge.
389-
if (~(f_have_snan & unordered_cmp_bit_i
390-
& (generic_cmp_opc_i == GENERIC_SFLT
391-
| generic_cmp_opc_i == GENERIC_SFLE
392-
| generic_cmp_opc_i == GENERIC_SFGT
393-
| generic_cmp_opc_i == GENERIC_SFGE)))
394-
`endif // PFPU32_FCMP_SNAN_BUG
395-
assert (inv_o == f_have_inv);
386+
assert (inv_o == f_have_inv);
396387
assert (inf_o == f_have_inf);
397388
end
398389
end

0 commit comments

Comments
 (0)