amocas.q
Atomic compare-and-swap quadword
- Extension
- Zacas
- XLEN
- RV64 only
- Assembly (riscv-unified-db)
amocas.q xd, xs2, (xs1)- Length
- 32-bit
Encoding
| 3129 | 2827 | 26 | 25 | 2420 | 1915 | 1412 | 117 | 62 | 10 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 001 | 01 | aq | rl | rs2 | rs1 | 100 | rd | 01011 | 11 | ||||||||||||||||||||||
Match 0x2800402f, mask 0xf800707f. Source: amocas.q rd rs1 rs2 aq rl 31..29=1 28..27=1 14..12=4 6..2=0x0B 1..0=3 in riscv-opcodes/extensions/rv64_zacas.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| aq | 26 | aq |
| rl | 25 | rl |
| rs2 | 24:20 | rs2 |
| rs1 | 19:15 | rs1 |
| rd | 11:7 | rd |
Description
Atomically:
- Load the quadword at address xs1
- Write the loaded value into xd
- Compare the loaded value with the value of register xs2
- If equal, write the value of register xs2+1 to the address in xs1
Description from riscv-unified-db, reformatted.
Operation
if (!implemented?(ExtensionName::Zacas)) {
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
}
XReg virtual_address = X[xs1];
# TODO
# X[xd] = amocas128(virtual_address, X[xs2], X[xd], 1'b0, 1'b0, $encoding);Pseudocode in riscv-unified-db’s IDL, quoted unchanged.