ReadyValidPrefetchedIndexPool constructor
- required Logic clk,
- required Logic reset,
- required Logic quiesce,
- required List<
ReadyValidInterface< allocations,Logic> > - required List<
ReadyValidInterface< releases,TagRelease> > - required ReadyValidInterface<
Logic> restore, - required int capacity,
- SynchronousMemoryFunctor? memoryFunctor,
- MemoryConfiguration? memoryConfiguration,
- int memoryReadLatency = 1,
- int prefetchDepth = 2,
- int? releaseBufferDepth,
- List<
int> ? initiallyAvailableIndices, - String name = 'ready_valid_prefetched_index_pool',
Creates a restorable prefetched index pool.
Implementation
ReadyValidPrefetchedIndexPool(
{required Logic clk,
required Logic reset,
required Logic quiesce,
required List<ReadyValidInterface<Logic>> allocations,
required List<ReadyValidInterface<TagRelease>> releases,
required ReadyValidInterface<Logic> restore,
required this.capacity,
SynchronousMemoryFunctor? memoryFunctor,
MemoryConfiguration? memoryConfiguration,
this.memoryReadLatency = 1,
this.prefetchDepth = 2,
int? releaseBufferDepth,
List<int>? initiallyAvailableIndices,
super.name = 'ready_valid_prefetched_index_pool'})
: indexWidth = max(1, capacity.log2Ceil),
releaseLaneCount = releases.length,
releaseBufferDepth = releaseBufferDepth ?? max(2, releases.length * 2),
super(
definitionName: _prefetchedIndexPoolDefinitionName(
capacity,
releases.length,
memoryReadLatency,
prefetchDepth,
releaseBufferDepth ?? max(2, releases.length * 2),
initiallyAvailableIndices,
memoryFunctor ??
_selectPrefetchedIndexPoolMemoryFunctor(
memoryConfiguration,
capacity: capacity,
indexWidth: max(1, capacity.log2Ceil),
memoryReadLatency: memoryReadLatency,
))) {
this.memoryFunctor = memoryFunctor ??
_selectPrefetchedIndexPoolMemoryFunctor(
memoryConfiguration,
capacity: capacity,
indexWidth: indexWidth,
memoryReadLatency: memoryReadLatency,
);
if (allocations.length != 1) {
throw ArgumentError('Exactly one allocation lane is required.');
}
if (allocations.single.data.width != indexWidth) {
throw ArgumentError('The allocation shape must match capacity.');
}
allocations.single.requireConsumerComposableWith(
ReadyValidContract.irrevocable,
providerName: name);
for (final release in releases) {
release.requireProviderComposableWith(ReadyValidContract.readyAndValid,
consumerName: name);
}
restore.requireProviderComposableWith(ReadyValidContract.readyAndValid,
consumerName: name);
final localClk = addInput('clk', clk);
final localReset = addInput('reset', reset);
final localQuiesce = addInput('quiesce', quiesce);
this.allocations = [
addPairInterfaceFrom(
IrrevocableReadyValidInterface(allocations.single.data.clone()),
allocations.single,
PairRole.provider,
uniquify: (original) => 'allocation_0_$original',
)
];
this.releases = [
for (var lane = 0; lane < releaseLaneCount; lane++)
addPairInterface(releases[lane], PairRole.consumer,
uniquify: (original) => 'release_${lane}_$original')
];
this.restore = addPairInterface(restore, PairRole.consumer,
uniquify: (original) => 'restore_$original');
final allocate = Logic(name: '${name}_allocate');
final releaseActions = [
for (var lane = 0; lane < releaseLaneCount; lane++)
Logic(name: '${name}_release_$lane')
];
final releaseData = [
for (final release in this.releases) cloneTypedPayload(release.data)
];
final restoreAction = Logic(name: '${name}_restore');
final restoreMask = cloneInterfacePayload(this.restore.data);
final core = PrefetchedIndexPool(
clk: localClk,
reset: localReset,
quiesce: localQuiesce,
allocate: allocate,
releases: releaseActions,
releaseIndices: [for (final data in releaseData) data.tag],
restore: restoreAction,
restoreMask: restoreMask,
capacity: capacity,
memoryFunctor: this.memoryFunctor,
memoryReadLatency: memoryReadLatency,
prefetchDepth: prefetchDepth,
releaseBufferDepth: this.releaseBufferDepth,
initiallyAvailableIndices: initiallyAvailableIndices,
name: '${name}_core');
memoryBinding = core.memoryBinding;
ReadyValidEgressAttachmentPolicy<Logic>(coreGatesTransfer: true).attach(
downstream: this.allocations.single,
offerValid: core.allocationValid,
payload: core.allocatedIndex,
transfer: allocate,
);
for (var lane = 0; lane < releaseLaneCount; lane++) {
ReadyValidIngressAttachmentPolicy<TagRelease>(
supportsSameCycleReplacement: false,
coreGatesAccept: true,
).attach(
upstream: this.releases[lane],
canAccept: core.canRelease,
accept: releaseActions[lane],
payload: releaseData[lane],
);
}
ReadyValidIngressAttachmentPolicy<Logic>(
supportsSameCycleReplacement: false,
coreGatesAccept: true,
).attach(
upstream: this.restore,
canAccept: core.canRestore,
accept: restoreAction,
payload: restoreMask,
);
allocatedMasksAfterAllocationPrefixes = [
addOutput('allocatedMaskAfterAllocationPrefix0', width: capacity)
..gets(core.allocatedMaskAfterReleases),
addOutput('allocatedMaskAfterAllocationPrefix1', width: capacity)
..gets(core.allocatedMaskAfterAllocation)
];
addOutput('allocatedMask', width: capacity) <= core.allocatedMask;
addOutput('allocatedCount', width: core.allocatedCount.width) <=
core.allocatedCount;
addOutput('availableCount', width: core.availableCount.width) <=
core.availableCount;
addOutput('exhausted') <= core.exhausted;
addOutput('quiesced') <= core.quiesced;
addOutput('retainedAllocationLanes') <= core.allocationRetained;
addOutput('invalidReleases', width: releaseLaneCount) <=
core.invalidReleases;
addOutput('doubleReleases', width: releaseLaneCount) <= core.doubleReleases;
addOutput('invalidAllocationSelections') <= Const(0);
addOutput('rebuilding') <= core.rebuilding;
addOutput('bufferedReleaseCount', width: core.bufferedReleaseCount.width) <=
core.bufferedReleaseCount;
addOutput('backingCount', width: core.backingCount.width) <=
core.backingCount;
addOutput('outstandingReads', width: core.outstandingReads.width) <=
core.outstandingReads;
addOutput('staleResponse') <= core.staleResponse;
}