Webcentive RISC-V Reference

c.sd

Store double

Extension
C, Zclsd
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
c.sd xs2, imm(xs1)
Length
16-bit (compressed)

Encoding

RV64 form

1513121097654210
111uimm[5:3]rs1′uimm[7:6]rs2′00

Match 0xe000, mask 0xe003. Source: c.sd rs1_p rs2_p c_uimm8hi c_uimm8lo 1..0=0 15..13=7 in riscv-opcodes/extensions/rv64_c.

FieldBitsriscv-opcodes name
uimm[5:3]12:10c_uimm8hi
rs1′9:7rs1_p
uimm[7:6]6:5c_uimm8lo
rs2′4:2rs2_p

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

1513121097654320
111uimm[5:3]rs1′uimm[7:6]rs2′, even values only000

Match 0xe000, mask 0xe007. Source: $pseudo_op rv32_c_f::c.fsw c.sd rs1_p rs2_p_e c_uimm8hi c_uimm8lo 2..0=0 15..13=7 in riscv-opcodes/extensions/rv32_zclsd.

FieldBitsriscv-opcodes name
uimm[5:3]12:10c_uimm8hi
rs1′9:7rs1_p
uimm[7:6]6:5c_uimm8lo
rs2′, even values only4:3rs2_p_e

Description

For RV64, store a 64-bit value in register xs2 to memory. For RV32 with Zclsd extension, store a 64-bit value from the combined values in register pair [xs2, xs2+1] to memory. It computes an effective address by adding the zero-extended offset, scaled by 8, to the base address in register xs1. It expands to sd xs2, 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;

if (xlen() == 32) {
  if (implemented?(ExtensionName::Zclsd)) {
    Bits<64> data = {X[creg2reg(xs2) + 1], X[creg2reg(xs2)]};
    write_memory(64, virtual_address, data, $encoding);
  } else {
    raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
  }
} else {
  write_memory(64, virtual_address, X[creg2reg(xs2)], $encoding);
}

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

Specification and related pages