fpu: detect RV64 FCVT.WU.D overflow on a round-up to 2^32

未关闭
#500 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
embedded-iot

调研方向

Start in hw/rtl/fpu/VX_fcvt_unit.sv around lines 632-634, at round_carry_out_s5 and f2i_u32_pos_ovf. Trace how input_sign_s5, unpacked_exp_s5, dst_l_s5, and rounded_abs_s5 are formed for RV64 FCVT.WU.D; the pre-round exponent is 31 while rounding carries the magnitude to 2^32. Reproduce with input 0x41effffffff00000 and frm=RNE, then extend the unsigned overflow condition to cover a rounded value of 2^32, expecting 0xffffffffffffffff and NV set. Done means that case and the (2^32-1,2^32) interval are covered by the FPU tests.

由索引模型根据 Issue 内容生成。

描述

On RV64 at commit 1061088aa, FCVT.WU.D of 4294967295.5 (0x41effffffff00000) with frm=RNE returns 0 and raises only NX. RNE rounds this value to 2^32, which is outside the unsigned 32-bit range. The result should be 0xffffffffffffffff and NV should be set.

The overflow check misses this case. On RV64, S_MAN_WIDTH is at least 64, so rounding to 2^32 does not wrap rounded_abs_s5 to zero; meanwhile, the pre-round exponent is 31. The conversion therefore takes the in-range path and writes the low 32 bits of 2^32, which are zero. The same issue affects values in (2^32-1, 2^32) that round to 2^32.

This is distinct from #430, which concerns FCVT.S.D overflow rounding and was fixed by #432. It is also distinct from the f2i_u32_pos_ovf zero-extension issue: that branch is reached only when overflow is detected, while this input does not trigger it.

In hw/rtl/fpu/VX_fcvt_unit.sv, round-up carry is counted as overflow only when the rounded magnitude wraps to zero:

wire round_carry_out_s5 = (rounded_abs_s5 == '0) && (|pre_round_abs_s5);
wire f2i_u32_pos_ovf = !is_signed_s5 && !dst_l_s5 && !input_sign_s5
                    && ((unpacked_exp_s5 >= S_EXP_WIDTH'(32)) || round_carry_out_s5);
主要语言
Verilog
星标
2.4k
派生
563
平均合并
2 天 12 小时
30 天内合并 PR
33

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

vortexgpgpu/vortex 的其他 Issue

查看 vortexgpgpu/vortex 的全部 Issue

相似的 Issue

更多 Embedded & IoT Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。