Webcentive RISC-V Reference

c.srai

Shift right arithmetical immediate

Extension
C
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
c.srai xd, shamt
Length
16-bit (compressed)

Encoding

RV64 form

1513121110976210
100nzuimm[5]01rs1′/rs2′nzuimm[4:0]01

Match 0x8401, mask 0xec03. Source: c.srai rd_rs1_p c_nzuimm6lo c_nzuimm6hi 1..0=1 15..13=4 11..10=1 in riscv-opcodes/extensions/rv64_c.

FieldBitsriscv-opcodes name
nzuimm[5]12c_nzuimm6hi
rs1′/rs2′9:7rd_rs1_p
nzuimm[4:0]6:2c_nzuimm6lo

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

15131210976210
100001rs1′/rs2′nzuimm[4:0]01

Match 0x8401, mask 0xfc03. Source: $pseudo_op rv64_c::c.srai c.srai rd_rs1_p c_nzuimm5 1..0=1 15..13=4 12..10=1 in riscv-opcodes/extensions/rv32_c.

FieldBitsriscv-opcodes name
rs1′/rs2′9:7rd_rs1_p
nzuimm[4:0]6:2c_nzuimm5

Description

Arithmetic shift (the original sign bit is copied into the vacated upper bits) the value in xd right by shamt, and store the result in xd. The xd register index should be used as xd+8 (registers x8-x15). C.SRAI expands into srai xd, xd, shamt.

Description from riscv-unified-db, reformatted.

Operation

# shamt is between 0-63
X[creg2reg(xd)] = X[creg2reg(xd)] >>> shamt;

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

Specification and related pages