c.ld
Load double
- Extension
- C, Zclsd
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
c.ld xd, imm(xs1)- Length
- 16-bit (compressed)
Encoding
RV64 form
| 1513 | 1210 | 97 | 65 | 42 | 10 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011 | uimm[5:3] | rs1′ | uimm[7:6] | rd′ | 00 | ||||||||||
Match 0x6000, mask 0xe003. Source: c.ld rd_p rs1_p c_uimm8lo c_uimm8hi 1..0=0 15..13=3 in riscv-opcodes/extensions/rv64_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| uimm[5:3] | 12:10 | c_uimm8hi |
| rs1′ | 9:7 | rs1_p |
| uimm[7:6] | 6:5 | c_uimm8lo |
| rd′ | 4:2 | rd_p |
RV32 form; listed in riscv-opcodes as a pseudo-op of c.flw
| 1513 | 1210 | 97 | 65 | 43 | 20 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011 | uimm[5:3] | rs1′ | uimm[7:6] | rd′, even values only | 000 | ||||||||||
Match 0x6000, mask 0xe007. Source: $pseudo_op rv32_c_f::c.flw c.ld rd_p_e rs1_p c_uimm8lo c_uimm8hi 2..0=0 15..13=3 in riscv-opcodes/extensions/rv32_zclsd.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| uimm[5:3] | 12:10 | c_uimm8hi |
| rs1′ | 9:7 | rs1_p |
| uimm[7:6] | 6:5 | c_uimm8lo |
| rd′, even values only | 4:3 | rd_p_e |
Description
Loads a 64-bit value from memory into register xd.
It computes an effective address by adding the zero-extended offset, scaled by 8,
to the base address in register xs1.
It expands to ld xd, offset(xs1).
For RV32, if the Zclsd extension is enabled, this instruction loads a 64-bit value into registers xd and xd+1. It computes an effective address by adding the zero-extended imm, scaled by 8, to the base address in register xs1.
Description from riscv-unified-db, reformatted.
Operation
if (implemented?(ExtensionName::C) && MISA_CSR_IMPLEMENTED && (CSR[misa].C == 1'b0)) {
reserved_instruction($encoding);
}
if (xlen() == 32) {
if (implemented?(ExtensionName::Zclsd)) {
Bits<64> val = read_memory(64, X[creg2reg(xs1)] + imm, $encoding);
X[creg2reg(xd)] = val[31:0];
X[creg2reg(xd + 1)] = val[63:32];
} else {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
} else {
XReg virtual_address = X[creg2reg(xs1)] + imm;
X[creg2reg(xd)] = sext(read_memory(64, virtual_address, $encoding), 64);
}Pseudocode in riscv-unified-db’s IDL, quoted unchanged.