Skip to content

Commit 79e4531

Browse files
author
pascalgouedo
authored
Merge pull request #98 from openhwgroup/develop
Release 0.8.1
2 parents 11659d7 + a98e799 commit 79e4531

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

src/fpnew_cast_multi.sv

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,11 @@ module fpnew_cast_multi #(
443443
// By default right shift mantissa to be an integer
444444
denorm_shamt = unsigned'(MAX_INT_WIDTH - 1 - input_exp_q);
445445
// overflow: when converting to unsigned the range is larger by one
446-
if (input_exp_q >= signed'(fpnew_pkg::int_width(int_fmt_q2) - 1 + op_mod_q2)) begin
446+
if ((input_exp_q >= signed'(fpnew_pkg::int_width(int_fmt_q2) - 1 + op_mod_q2)) // Exponent larger than max int range,
447+
&& !(!op_mod_q2 // unless cast to signed int
448+
&& input_sign_q // and input value is larges negative int value
449+
&& (input_exp_q == signed'(fpnew_pkg::int_width(int_fmt_q2) - 1))
450+
&& (input_mant_q == {1'b1, {INT_MAN_WIDTH-1{1'b0}}}))) begin
447451
denorm_shamt = '0; // prevent shifting
448452
of_before_round = 1'b1;
449453
// underflow

src/fpnew_divsqrt_multi.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ module fpnew_divsqrt_multi #(
207207
// Valid synch with other lanes
208208
// When one divsqrt unit completes an operation, keep its done high, waiting for the other lanes
209209
// As soon as all the lanes are over, we can clear this FF and start with a new operation
210-
`FFLARNC(unit_done_q, unit_done, unit_done, simd_synch_done, 1'b0, clk_i, rst_ni);
210+
`FFLARNC(unit_done_q, unit_done, unit_done, simd_synch_done, 1'b0, clk_i, rst_ni)
211211
// Tell the other units that this unit has finished now or in the past
212212
assign divsqrt_done_o = (unit_done_q | unit_done) & result_vec_op_q;
213213

src/fpnew_fma.sv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,9 @@ module fpnew_fma #(
613613
);
614614

615615
// Classification after rounding
616-
assign uf_after_round = rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0; // exponent = 0
616+
assign uf_after_round = (rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0) // denormal
617+
|| ((pre_round_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0) && (rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == 1) &&
618+
((round_sticky_bits != 2'b11) || (!sum_sticky_bits[MAN_BITS*2 + 4] && ((rnd_mode_i == fpnew_pkg::RNE) || (rnd_mode_i == fpnew_pkg::RMM)))));
617619
assign of_after_round = rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '1; // exponent all ones
618620

619621
// -----------------

src/fpnew_fma_multi.sv

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,10 @@ module fpnew_fma_multi #(
745745

746746
if (FpFmtConfig[fmt]) begin : active_format
747747
always_comb begin : post_process
748-
// detect of / uf
749-
fmt_uf_after_round[fmt] = rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0; // denormal
748+
// detect of / uf
749+
fmt_uf_after_round[fmt] = (rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0) // denormal
750+
|| ((pre_round_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '0) && (rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == 1) &&
751+
((round_sticky_bits != 2'b11) || (!sum_sticky_bits[MAN_BITS*2 + 4] && ((rnd_mode_i == fpnew_pkg::RNE) || (rnd_mode_i == fpnew_pkg::RMM)))));
750752
fmt_of_after_round[fmt] = rounded_abs[EXP_BITS+MAN_BITS-1:MAN_BITS] == '1; // inf exp.
751753

752754
// Assemble regular result, nan box short ones.

vendor/opene906/E906_RTL_FACTORY/gen_rtl/fdsu/rtl/pa_fdsu_pack_single.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ end
222222
assign ex4_rst_norm[31:0] = {fdsu_ex4_result_sign,
223223
ex4_expnt_rst[7:0],
224224
ex4_frac_23[22:0]};
225-
assign ex4_cor_uf = (fdsu_ex4_uf && !ex4_denorm_potnt_norm || ex4_uf_plus)
225+
assign ex4_cor_uf = (fdsu_ex4_uf || ex4_denorm_potnt_norm || ex4_uf_plus)
226226
&& fdsu_ex4_nx;
227227
assign ex4_cor_nx = fdsu_ex4_nx
228228
|| fdsu_ex4_of
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From e441ef74e80c7efe93ccacd60a03cf75e8167394 Mon Sep 17 00:00:00 2001
2+
From: Greg Davill <greg.davill@gmail.com>
3+
Date: Tue, 11 Jul 2023 15:10:57 +0930
4+
Subject: [PATCH] fdsu.pack: Correct Underflow logic
5+
6+
Handle correct behavior when executing DIV instruction.
7+
Flag underflow if result with unbounded exponent would lie between
8+
+/-b^(emin). Even if rounded result is exactly [+/-]01.000000.
9+
Use ex4_denorm_potnt_norm, a flag that is set when a denormal result
10+
rounds to a normal result.
11+
---
12+
E906_RTL_FACTORY/gen_rtl/fdsu/rtl/pa_fdsu_pack_single.v | 2 +-
13+
1 file changed, 1 insertion(+), 1 deletion(-)
14+
15+
diff --git a/E906_RTL_FACTORY/gen_rtl/fdsu/rtl/pa_fdsu_pack_single.v b/E906_RTL_FACTORY/gen_rtl/fdsu/rtl/pa_fdsu_pack_single.v
16+
index 87139a2..d22e85b 100644
17+
--- a/E906_RTL_FACTORY/gen_rtl/fdsu/rtl/pa_fdsu_pack_single.v
18+
+++ b/E906_RTL_FACTORY/gen_rtl/fdsu/rtl/pa_fdsu_pack_single.v
19+
@@ -222,7 +222,7 @@ end
20+
assign ex4_rst_norm[31:0] = {fdsu_ex4_result_sign,
21+
ex4_expnt_rst[7:0],
22+
ex4_frac_23[22:0]};
23+
-assign ex4_cor_uf = (fdsu_ex4_uf && !ex4_denorm_potnt_norm || ex4_uf_plus)
24+
+assign ex4_cor_uf = (fdsu_ex4_uf || ex4_denorm_potnt_norm || ex4_uf_plus)
25+
&& fdsu_ex4_nx;
26+
assign ex4_cor_nx = fdsu_ex4_nx
27+
|| fdsu_ex4_of
28+
--
29+
2.38.0.windows.1
30+

0 commit comments

Comments
 (0)