← Home

mulw

Signed 32-bit multiply

Multiplies the lower 32 bits of the source registers, placing the sign-extension of the lower 32 bits of the result into the destination register.

Any overflow is thrown away.

Note: In RV64, MUL can be used to obtain the upper 32 bits of the 64-bit product, but signed arguments must be proper 32-bit signed values, whereas unsigned arguments must have their upper 32 bits clear. If the arguments are not known to be sign- or zero-extended, an alternative is to shift both arguments left by 32 bits, then use MULH[[S]U].

This instruction has data-independent execution timing.

Assembly format

mulw xd, xs1, xs2

Encoding

313029282726252423222120191817161514131211109876543210
0000001xs2xs1000xd0111011

Decode variables

VariableBitsWidth
xs2[24:20]5
xs1[19:15]5
xd[11:7]5

Execution

Bits<32> src1 = X[xs1][31:0];
Bits<32> src2 = X[xs2][31:0];

Bits<32> result = src1 * src2;
Bits<1> sign_bit = result[31];

# return the sign-extended result
X[xd] = {{32{sign_bit}}, result};

Defined by

RV64 and Zmmul

Access

SUVSVU
AlwaysAlwaysAlwaysAlways

Version af3eaf9+cheriot.f635218

Data from the RISC-V Unified Database, copyright RISC-V International and contributors.

CHERIoT extensions from the CHERIoT specification and Sail model, copyright Microsoft and the CHERIoT Platform contributors.

This site is provided as a community resource and is NOT affiliated with nor endorsed by RISC-V International.