Skip to content

fix vmulhu/vmulhsu/vwmulu.vx: truncate the .vx scalar operand to SEW - #90

Open
emiliengnr wants to merge 1 commit into
ucb-bar:masterfrom
emiliengnr:fix-mul-vx-scalar-truncate
Open

fix vmulhu/vmulhsu/vwmulu.vx: truncate the .vx scalar operand to SEW#90
emiliengnr wants to merge 1 commit into
ucb-bar:masterfrom
emiliengnr:fix-mul-vx-scalar-truncate

Conversation

@emiliengnr

Copy link
Copy Markdown
Contributor

Hello, here is a pull request for a bug I found.

vmulhu.vx, vmulhsu.vx and vwmulu.vx do not truncate the .vx scalar operand to SEW
before the multiply. In ElementwiseMultiplyPipe.scala the unsigned operands are
passed raw (rvs1_elem / rvs2_elem), whereas the signed path sign-extends them from
the element width. For a .vx op the "element" is the full XLEN scalar, so passing
it raw feeds the multiplier bits above SEW, and the op multiplies by
rs1[2*SEW-1:0] instead of rs1[SEW-1:0]. Plain vmul.vx hides it because the product
is truncated to SEW; vwmaccus.vx is affected too, since its scalar reaches the
second operand.

The fix uses zextElem (the helper added in #87) to zero-extend the unsigned
multiply operands, mirroring the existing sextElem on the signed path. For a .vv
element it is a no-op, so only the .vx scalar is truncated, and it covers both
operand lines (in_vs1 and in_vs2). This is the multiply-pipe counterpart of #87.

Found by differential testing against Spike; a reduced reproducer (vwmulu.vx at
SEW=8) diverges before the fix and matches Spike after it, and the unaffected ops
(vmulh.vx, vmul.vx, vwmaccsu.vx) are unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant