ReadyValidBankedIndexPool 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,
- List<
int> ? initiallyAvailableIndices, - MemoryBankingPolicy bankingPolicy = MemoryBankingPolicy.interleaved,
- IndexAllocationGenerator allocationGenerator = lowestFreeIndexAllocationGenerator,
- String allocationPolicyName = 'lowestFree',
- RestorableMultiIndexAllocatorFunctor? bankImplementation,
- String name = 'ready_valid_banked_index_pool',
Creates one banked global index pool.
Implementation
ReadyValidBankedIndexPool(
{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,
List<int>? initiallyAvailableIndices,
MemoryBankingPolicy bankingPolicy = MemoryBankingPolicy.interleaved,
IndexAllocationGenerator allocationGenerator =
lowestFreeIndexAllocationGenerator,
this.allocationPolicyName = 'lowestFree',
RestorableMultiIndexAllocatorFunctor? bankImplementation,
super.name = 'ready_valid_banked_index_pool'})
: indexWidth = max(1, capacity.log2Ceil),
allocationLaneCount = allocations.length,
releaseLaneCount = releases.length,
layout = BankedMemoryLayout(
entryCount: capacity,
bankCount: allocations.length,
policy: bankingPolicy),
super(
definitionName: _bankedIndexPoolDefinitionName(
capacity,
allocations.length,
releases.length,
initiallyAvailableIndices,
bankingPolicy,
allocationPolicyName,
bankImplementation?.identity ?? 'flatBitmap')) {
if (allocations.any((allocation) => allocation.data.width != indexWidth) ||
releases.any((release) => release.data.tag.width != indexWidth) ||
restore.data.width != capacity) {
throw ArgumentError(
'Allocation, release, and restore shapes must match capacity.');
}
for (final allocation in allocations) {
allocation.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 = [
for (var bank = 0; bank < allocationLaneCount; bank++)
addPairInterfaceFrom(
IrrevocableReadyValidInterface(allocations[bank].data.clone()),
allocations[bank],
PairRole.provider,
uniquify: (original) => 'allocation_${bank}_$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 = [
for (var bank = 0; bank < allocationLaneCount; bank++)
Logic(name: '${name}_allocate_$bank')
];
final release = [
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);
// The core checks its own configuration: the lane counts, the bank
// policy, and the initially available indices.
final core = BankedIndexPool(
clk: localClk,
reset: localReset,
quiesce: localQuiesce,
allocate: allocate,
release: release,
releaseIndices: [for (final data in releaseData) data.tag],
restore: restoreAction,
restoreMask: restoreMask,
capacity: capacity,
initiallyAvailableIndices: initiallyAvailableIndices,
bankingPolicy: bankingPolicy,
allocationGenerator: allocationGenerator,
allocationPolicyName: allocationPolicyName,
bankImplementation: bankImplementation,
name: '${name}_core',
);
banks = core.banks;
for (var bank = 0; bank < allocationLaneCount; bank++) {
final offer = cloneTypedPayload(this.allocations[bank].data);
connectPackedPayload(offer, core.allocationIndices[bank]);
ReadyValidEgressAttachmentPolicy<Logic>(coreGatesTransfer: true).attach(
downstream: this.allocations[bank],
offerValid: core.allocationValid[bank],
payload: offer,
transfer: allocate[bank],
);
}
for (var lane = 0; lane < releaseLaneCount; lane++) {
ReadyValidIngressAttachmentPolicy<TagRelease>(
supportsSameCycleReplacement: true,
coreGatesAccept: true,
).attach(
upstream: this.releases[lane],
canAccept: core.canRelease[lane],
accept: release[lane],
payload: releaseData[lane],
);
}
ReadyValidIngressAttachmentPolicy<Logic>(
supportsSameCycleReplacement: false,
coreGatesAccept: true,
).attach(
upstream: this.restore,
canAccept: core.canRestore,
accept: restoreAction,
payload: restoreMask,
);
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', width: allocationLaneCount) <=
core.retainedAllocationLanes;
addOutput('invalidReleases', width: releaseLaneCount) <=
core.invalidReleases;
addOutput('doubleReleases', width: releaseLaneCount) <= core.doubleReleases;
addOutput('invalidAllocationSelections', width: allocationLaneCount) <=
core.invalidAllocationSelections;
addOutput('bankExhausted', width: allocationLaneCount) <=
core.bankExhausted;
bankAvailableCounts = [
for (var bank = 0; bank < allocationLaneCount; bank++)
addOutput('bankAvailableCount$bank',
width: core.bankAvailableCounts[bank].width)
..gets(core.bankAvailableCounts[bank])
];
allocatedMasksAfterAllocationPrefixes = [
for (var prefix = 0; prefix <= allocationLaneCount; prefix++)
addOutput('allocatedMaskAfterAllocationPrefix$prefix', width: capacity)
..gets(core.allocatedMasksAfterAllocationPrefixes[prefix])
];
}