ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 913 microarchs · 15,555 chips · 105 sources
Arch:
Tier:

ATCAS

T1 tenstorrent atomic insn
ATCAS (L1 atomic compare and set)
SourceTenstorrent Official Tensix ISA Documentation (Wormhole & Blackhole) (tenstorrent_tt_isa)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeBlackholeA0 / WormholeB0
Tenstorrent Wormhole B0 & Blackhole A0
License & VersionApache-2.0
main
Upstreamhttps://github.com/tenstorrent/tt-isa-documentation
Privilegeuser
ExtensionsTensix, Scalar Unit, BlackholeA0, WormholeB0
Note: This instruction takes at least 15 cycles to execute, possibly longer if there is L1 access port or bank contention. If the comparison fails, each subsequent attempt takes another 15 (or more) cycles, until the comparison eventually succeeds.

Summary

Block execution of the Tensix thread until a 32-bit field in L1 contains a particular 4-bit value, then atomically change that field to contain a new 4-bit value. The instruction completes execution once the Scalar Unit has received confirmation that the change has been made in L1, at which point the thread's next instruction can execute. Note that the Scalar Unit remains busy for the duration of the instruction…

Syntax / Encoding

TT_ATCAS(0, /* u4 */ SetVal, /* u4 */ CmpVal, /* u2 */ Ofs, 0, /* u6 */ AddrReg)

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32Tensix-32b01100100xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x64000000

Operands

NameDescription
SetVal
CmpVal
Ofs
AddrReg

Reference Notes

# `ATCAS` (L1 atomic compare and set)

**Summary:** Block execution of the Tensix thread until a 32-bit field in L1 contains a particular 4-bit value, then atomically change that field to contain a new 4-bit value. The instruction completes execution once the Scalar Unit has received confirmation that the change has been made in L1, at which point the thread's next instruction can execute. Note that the Scalar Unit remains busy for the duration of the instruction, and that repeated requests are made through the ThCon L1 access port until the comparison succeeds, making this a fairly heavyweight instruction - the facilities of the Sync Unit should be used instead where possible.

This instruction is `UnsupportedFunctionality` and its use is strongly discouraged: it has no known usage.

**Backend execution unit:** [Scalar Unit (ThCon)](ScalarUnit.md)

## Syntax

```c
TT_ATCAS(0, /* u4 */ SetVal, /* u4 */ CmpVal, /* u2 */ Ofs, 0, /* u6 */ AddrReg)
```

## Encoding

![](../../../Diagrams/Out/Bits32_ATCAS.svg)

## Functional model

```c
UnsupportedFunctionality(); // No known usage
retry:

uint32_t* L1Address = GPRs[CurrentThread][AddrReg] * 16 + Ofs * 4;
if (L1Address >= TENSIX_SRAM_SIZE) UndefinedBehavior(); // Address must be in L1

atomic {
  if (*L1Address != CmpVal) {
    goto retry; // Comparison failed
  }
  *L1Address = SetVal;
}
```

## Performance

This instruction takes at least 15 cycles to execute, possibly longer if there is L1 access port or bank contention. If the comparison fails, each subsequent attempt takes another 15 (or more) cycles, until the comparison eventually succeeds.