Webcentive RISC-V Reference

c.lui

Load Upper Immediate

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

Encoding

1513121176210
011nzimm[17]rd_n2nzimm[16:12]01

Match 0x6001, mask 0xe003. Source: c.lui rd_n2 c_nzimm18hi c_nzimm18lo 1..0=1 15..13=3 in riscv-opcodes/extensions/rv_c.

FieldBitsriscv-opcodes name
nzimm[17]12c_nzimm18hi
rd_n211:7rd_n2
nzimm[16:12]6:2c_nzimm18lo

Description

C.LUI loads the non-zero 6-bit immediate field into bits 17-12 of the destination register, clears the bottom 12 bits, and sign-extends bit 17 into all higher bits of the destination. C.LUI expands into lui xd, imm. C.LUI is only valid when xd≠x0 and xd≠x2, and when the immediate is not equal to zero. The code points with imm=0 are reserved; the remaining code points with xd=x0 are HINTs; and the remaining code points with xd=x2 correspond to the C.ADDI16SP instruction

Description from riscv-unified-db, reformatted.

Operation

if (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
  reserved_instruction($encoding);
}

X[xd] = $signed(imm);

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

Specification and related pages