poke method

void poke(
  1. BigInt address, {
  2. required LogicValue data,
  3. required LogicValue metadata,
})

Replaces or inserts raw resident state without issuing an eviction.

The cache must have no outstanding transactions. Inserting a new block into a full set is rejected rather than silently discarding a line.

Implementation

void poke(BigInt address,
    {required LogicValue data, required LogicValue metadata}) {
  backingStore._validateAddress(address);
  if (_transactions.isNotEmpty || (_serialized?.busy ?? false)) {
    throw StateError('Raw cache writes require no outstanding transactions.');
  }
  if (data.width != backingStore.dataWidth ||
      metadata.width != backingStore.metadataWidth) {
    throw ArgumentError('Cache block widths do not match.');
  }
  final set = (address % BigInt.from(setCount)).toInt();
  final ways = _lines[set];
  var way = ways.indexWhere((line) => line?.address == address);
  if (way < 0) {
    way = ways.indexOf(null);
    if (way < 0) {
      throw StateError('Raw cache insertion requires an invalid way.');
    }
  }
  ways[way] = _Line(
      address, normalizeStoredValue(data), normalizeStoredValue(metadata));
}