c.lw
Load word
- Extension
- C
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
c.lw xd, imm(xs1)- Length
- 16-bit (compressed)
Encoding
| 1513 | 1210 | 97 | 65 | 42 | 10 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 010 | uimm[5:3] | rs1′ | uimm[2|6] | rd′ | 00 | ||||||||||
Match 0x4000, mask 0xe003. Source: c.lw rd_p rs1_p c_uimm7lo c_uimm7hi 1..0=0 15..13=2 in riscv-opcodes/extensions/rv_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| uimm[5:3] | 12:10 | c_uimm7hi |
| rs1′ | 9:7 | rs1_p |
| uimm[2|6] | 6:5 | c_uimm7lo |
| rd′ | 4:2 | rd_p |
Description
Loads a 32-bit value from memory into register xd.
It computes an effective address by adding the zero-extended offset, scaled by 4,
to the base address in register xs1.
It expands to lw xd, offset(xs1).
Description from riscv-unified-db, reformatted.
Operation
if (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
reserved_instruction($encoding);
}
XReg virtual_address = X[creg2reg(xs1)] + imm;
X[creg2reg(xd)] = sext(read_memory(32, virtual_address, $encoding), 32);Pseudocode in riscv-unified-db’s IDL, quoted unchanged.