fpu: sign-extend RV64 FCVT.WU positive overflow results

Open Beginner friendly
#499 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@zzf2024 is already working on this.

Since Nov 29, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
embedded-iot

Research direction

Open hw/rtl/fpu/VX_fcvt_unit.sv at the f2i_u32_pos_ovf branch near lines 682-685 and check how res_val_64 is assembled there versus the other overflow arms; the RV64 path needs the 32-bit 0xffffffff sign-extended while res_val_32 stays as it is. Read the surrounding f2i arms first to see how XLEN selects between the 64- and 32-bit results. Done means an FPU simulation of FCVT.WU.S on 0x4f800000 with frm=RNE yields 0xffffffffffffffff with NV set.

Written by the indexing model from the issue text.

Description

On RV64, FCVT.WU.S and FCVT.WU.D can return a zero-extended result when a finite positive input overflows the unsigned 32-bit range.

For example, FCVT.WU.S of 0x4f800000 (2^32), with frm=RNE, should produce 0xffffffffffffffff: the invalid flag is set and the 32-bit result 0xffffffff is sign-extended to XLEN. The RTL instead returns 0x00000000ffffffff. FCVT.WU.D of a value whose exponent is at least 32 takes the same arm.

This is not #430. #430 is FCVT.S.D overflow rounding, and #432 already fixed that path. This report is the float-to-unsigned-int arm: the overflow is detected and NV is set, but the RV64 result is zero-extended instead of sign-extended.

In hw/rtl/fpu/VX_fcvt_unit.sv, the f2i_u32_pos_ovf branch sets NV but zero-extends the result:

end else if (f2i_u32_pos_ovf) begin
    final_fflags_s5.NV = 1'b1;
    res_val_64 = {32'h00000000, 32'hFFFFFFFF};
    res_val_32 = 32'hFFFFFFFF;
Dominant language
Verilog
Stars
2.4k
Forks
563
Avg merge
1d 7h
Merged PRs (30d)
71

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vortexgpgpu/vortex

All issues in vortexgpgpu/vortex

Similar issues

More Embedded & IoT issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.