Webcentive RISC-V Reference

ld

Load doubleword

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

Encoding

RV64 form

3120191514121176210
imm[11:0]rs1011rd0000011

Match 0x00003003, mask 0x0000707f. Source: ld rd rs1 imm12 14..12=3 6..2=0x00 1..0=3 in riscv-opcodes/extensions/rv64_i.

FieldBitsriscv-opcodes name
imm[11:0]31:20imm12
rs119:15rs1
rd11:7rd

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

3120191514121187210
imm[11:0]rs1011rd, even values only00000011

Match 0x00003003, mask 0x000070ff. Source: $pseudo_op rv64_i::ld ld rd_e rs1 imm12 14..12=3 7..2=0x00 1..0=3 in riscv-opcodes/extensions/rv32_zilsd.

FieldBitsriscv-opcodes name
imm[11:0]31:20imm12
rs119:15rs1
rd, even values only11:8rd_e

Description

For RV64, load 64 bits of data into register xd from an address formed by adding xs1 to a signed offset.

When Zilsd is implemented:

For RV32, Loads a 64-bit value into registers xd and xd+1. The effective address is obtained by adding register xs1 to the sign-extended 12-bit offset.

Description from riscv-unified-db, reformatted.

Operation

XReg virtual_address = X[xs1] + $signed(imm);

if (xlen() == 64) {
  X[xd] = read_memory(64, virtual_address, $encoding);
} else if (implemented?(ExtensionName::Zilsd)) {
  if (endianness() == Endian::Big) {
    X[xd+1] = read_memory(32, virtual_address, $encoding);
    X[xd] = read_memory(32, virtual_address + 4, $encoding);
  } else {
    X[xd] = read_memory(32, virtual_address, $encoding);
    X[xd+1] = read_memory(32, virtual_address + 4, $encoding);
  }
} else {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}

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

Specification and related pages