SpeculationTagManager constructor

SpeculationTagManager({
  1. required Logic clk,
  2. required Logic reset,
  3. required ReadyValidInterface<SpeculationContext> allocation,
  4. required ReadyValidInterface<TagRelease> release,
  5. required int capacity,
  6. IndexAllocationGenerator allocationGenerator = lowestFreeIndexAllocationGenerator,
  7. String allocationPolicyName = 'lowestFree',
  8. String name = 'speculation_tag_manager',
})

Creates a speculation tag and dependency-mask manager.

Implementation

SpeculationTagManager({
  required Logic clk,
  required Logic reset,
  required ReadyValidInterface<SpeculationContext> allocation,
  required ReadyValidInterface<TagRelease> release,
  required this.capacity,
  IndexAllocationGenerator allocationGenerator =
      lowestFreeIndexAllocationGenerator,
  String allocationPolicyName = 'lowestFree',
  super.name = 'speculation_tag_manager',
})  : tagWidth = allocation.data.tagWidth,
      super(
        definitionName: 'SpeculationTagManager_C${capacity}_'
            'P$allocationPolicyName',
      ) {
  if (capacity < 1 ||
      allocation.data.capacity != capacity ||
      release.data.tag.width != tagWidth) {
    throw ArgumentError(
        'Allocation and release must match the positive capacity.');
  }
  allocation.requireConsumerComposableWith(ReadyValidContract.readyAndValid,
      providerName: name);
  release.requireProviderComposableWith(ReadyValidContract.readyAndValid,
      consumerName: name);

  final localClk = addInput('clk', clk);
  final localReset = addInput('reset', reset);
  this.allocation = addPairInterface(allocation, PairRole.provider,
      uniquify: (original) => 'allocation_$original');
  this.release = addPairInterface(release, PairRole.consumer,
      uniquify: (original) => 'release_$original');
  addOutput('activeMask', width: capacity);
  addOutput('availableCount', width: max(1, (capacity + 1).log2Ceil));
  addOutput('exhausted');
  addOutput('invalidRelease');
  addOutput('doubleRelease');

  final indexAllocation = IrrevocableReadyValidInterface<Logic>(
      Logic(name: '${name}_allocated_tag', width: tagWidth));
  final indexRelease = ReadyAndValidInterface<TagRelease>(
      TagRelease(tagWidth: tagWidth, name: '${name}_index_release'));
  final indexPool = ReadyValidIndexPool(
      clk: localClk,
      reset: localReset,
      allocation: indexAllocation,
      release: indexRelease,
      capacity: capacity,
      allocationGenerator: allocationGenerator,
      allocationPolicyName: allocationPolicyName,
      name: '${name}_index_pool');
  indexAllocation.ready <= this.allocation.ready;
  this.allocation.valid <= indexAllocation.valid;
  this.allocation.data.tag <= indexAllocation.data;
  indexRelease.valid <= this.release.valid;
  indexRelease.data <= this.release.data;
  this.release.ready <= indexRelease.ready;

  this.allocation.data.dependencyMask <= indexPool.allocatedMaskAfterReleases;
  activeMask <= indexPool.allocatedMask;
  availableCount <= indexPool.availableCount;
  exhausted <= indexPool.exhausted;
  invalidRelease <= indexPool.invalidRelease;
  doubleRelease <= indexPool.doubleRelease;
}