Skip to content

Commit 8108903

Browse files
authored
Added a test case to show the 1.0 + -1.0 instruction time-out under f… (#592)
2 parents 882ddbb + f54c61d commit 8108903

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ mimpid = 0x01080200 => Version 01.08.02.00 => v1.8.2
3333

3434
| Date (*dd.mm.yyyy*) | Version | Comment |
3535
|:-------------------:|:-------:|:--------|
36+
| 21.04.2023 | 1.8.3.9 | :bug: fix timeout bug in **FPU** normalizer; [#592](https://github.com/stnolting/neorv32/pull/592) |
3637
| 19.04.2023 | 1.8.3.8 | minor processor bus system optimizations and clean-ups; [#591](https://github.com/stnolting/neorv32/pull/591) |
3738
| 15.04.2023 | 1.8.3.7 | :bug: :warning: `wfi` and XIRQ bug fixes; massive RTL code cleanup and optimization of CPU control; [#586](https://github.com/stnolting/neorv32/pull/586) |
3839
| 14.04.2023 | 1.8.3.6 | [UARTs] software can now retrieve the configured RX/TX FIFO sizes from the `DATA` register; [#581](https://github.com/stnolting/neorv32/pull/581) |

rtl/core/neorv32_cpu_cp_fpu.vhd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,14 @@ begin
13581358
ctrl.flags(fp_exc_of_c) or -- overflow
13591359
ctrl.flags(fp_exc_nv_c)) = '1') then -- invalid
13601360
ctrl.state <= S_FINALIZE;
1361+
-- The normalizer only checks the class of the inputs and not the result.
1362+
-- Check whether adder result is 0.0 which can happen if eg. 1.0 - 1.0
1363+
-- Set the ctrl.cnt to 0 to force the resulting exponent to be 0
1364+
-- Do not change sreg.lower as that is already all 0s
1365+
-- Do not change sign as that should be the right sign from the add/sub
1366+
elsif (unsigned(mantissa_i(47 downto 0)) = 0) then
1367+
ctrl.cnt <= (others => '0');
1368+
ctrl.state <= S_FINALIZE;
13611369
else
13621370
ctrl.state <= S_PREPARE_SHIFT;
13631371
end if;

rtl/core/neorv32_package.vhd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ package neorv32_package is
6060

6161
-- Architecture Constants -----------------------------------------------------------------
6262
-- -------------------------------------------------------------------------------------------
63-
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01080308"; -- hardware version
63+
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01080309"; -- hardware version
6464
constant archid_c : natural := 19; -- official RISC-V architecture ID
6565
constant XLEN : natural := 32; -- native data path width, do not change!
6666

sw/example/float_corner_test/main.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,35 @@ int main() {
150150
neorv32_cpu_csr_write(CSR_FFLAGS, 0); // real hardware
151151
feclearexcept(FE_ALL_EXCEPT); // software runtime (GCC floating-point emulation)
152152

153+
// ----------------------------------------------------------------------------
154+
// Floating point add/sub Instruction Time-out test
155+
// ----------------------------------------------------------------------------
156+
157+
neorv32_uart0_printf("\n#%u: FADD.S (Floating point add)...\n", test_cnt);
158+
159+
// Test the addition of 1.0 + (-1.0) to trigger long normalizer times
160+
// +1.0 e0
161+
// 0_011 1111 1_000 0000 0000 0000 0000 0000
162+
// sign 0, exp 0111_1111/0x7F, mant 0 => 1.0
163+
// 0x3F80_0000
164+
165+
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
166+
opa.binary_value = 0x3F800000;
167+
168+
// -1.0 e0
169+
// 1_011 1111 1_000 0000 0000 0000 0000 0000
170+
// sign 1, exp 0111_1111/0x7F, mant 0 => 1.0
171+
// 0xBF80_0000
172+
173+
opb.binary_value = 0xBF800000;
174+
riscv_intrinsic_fadds(opa.float_value,opb.float_value);
175+
176+
if (neorv32_cpu_csr_read(CSR_MCAUSE) == TRAP_CODE_I_ILLEGAL) {
177+
neorv32_uart0_printf("%c[1m[FAILED]%c[0m\n", 27, 27);
178+
neorv32_uart0_printf("Addition of 1.0 + (-1.0) timed out\n");
179+
err_cnt_total++;
180+
}
181+
test_cnt++;
153182

154183
// ----------------------------------------------------------------------------
155184
// Conversion Tests Instruction Time-out test

0 commit comments

Comments
 (0)