Webcentive RISC-V Reference

srai

Shift right arithmetic immediate

Extension
RV32I/RV64I base integer
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
srai xd, xs1, shamt
Length
32-bit

Encoding

RV64 form

31262520191514121176210
010000shamtrs1101rd0010011

Match 0x40005013, mask 0xfc00707f. Source: srai rd rs1 31..26=16 shamtd 14..12=5 6..2=0x04 1..0=3 in riscv-opcodes/extensions/rv64_i.

FieldBitsriscv-opcodes name
shamt25:20shamtd
rs119:15rs1
rd11:7rd

RV32 form; listed in riscv-opcodes as a pseudo-op of srai

31252420191514121176210
0100000shamtrs1101rd0010011

Match 0x40005013, mask 0xfe00707f. Source: $pseudo_op rv64_i::srai srai rd rs1 shamtw 31..25=32 14..12=5 6..2=0x04 1..0=3 in riscv-opcodes/extensions/rv32_i.

FieldBitsriscv-opcodes name
shamt24:20shamtw
rs119:15rs1
rd11:7rd

Description

Arithmetic shift (the original sign bit is copied into the vacated upper bits) the value in xs1 right by shamt, and store the result in xd.

Description from riscv-unified-db, reformatted.

Operation

# shamt is between 0-63
X[xd] = X[xs1] >>> shamt;

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages