mulw
Signed 32-bit multiply
- Extension
- M
- XLEN
- RV64 only
- Assembly (riscv-unified-db)
mulw xd, xs1, xs2- Length
- 32-bit
Encoding
| 3125 | 2420 | 1915 | 1412 | 117 | 62 | 10 | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0000001 | rs2 | rs1 | 000 | rd | 01110 | 11 | |||||||||||||||||||||||||
Match 0x0200003b, mask 0xfe00707f. Source: mulw rd rs1 rs2 31..25=1 14..12=0 6..2=0x0E 1..0=3 in riscv-opcodes/extensions/rv64_m.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rs2 | 24:20 | rs2 |
| rs1 | 19:15 | rs1 |
| rd | 11:7 | rd |
Description
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].
Description from riscv-unified-db, reformatted.
Operation
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};Pseudocode in riscv-unified-db’s IDL, quoted unchanged.