ReadyValidMultiIndexPool 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, - List<
Logic> ? allocationRequests, - List<
Logic> ? allocationMasks, - List<
Logic> ? allocationWithdraws, - IndexAllocationGenerator allocationGenerator = lowestFreeIndexAllocationGenerator,
- String allocationPolicyName = 'lowestFree',
- IndexAllocationSelectionMode selectionMode = IndexAllocationSelectionMode.normalized,
- RegisterFileFunctor? storageImplementation,
- String name = 'ready_valid_multi_index_pool',
Creates a multi-lane index pool.
allocationGenerator is instantiated independently for each lane over a
candidate bitmap with earlier offers removed. Its combinational grant
must not depend on the supplied accepted signal; that signal is only for
advancing policy state on a clock edge.
storageImplementation optionally backs ownership with a register file.
Retained irrevocable offers remain flops. The default is synthesizable;
registerFileModelFunctor selects a simulation-only implementation.
Implementation
ReadyValidMultiIndexPool(
{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,
List<Logic>? allocationRequests,
List<Logic>? allocationMasks,
List<Logic>? allocationWithdraws,
IndexAllocationGenerator allocationGenerator =
lowestFreeIndexAllocationGenerator,
this.allocationPolicyName = 'lowestFree',
this.selectionMode = IndexAllocationSelectionMode.normalized,
RegisterFileFunctor? storageImplementation,
super.name = 'ready_valid_multi_index_pool'})
: indexWidth = max(1, capacity.log2Ceil),
allocationLaneCount = allocations.length,
releaseLaneCount = releases.length,
super(
definitionName: _multiIndexPoolDefinitionName(
capacity,
allocations.length,
releases.length,
initiallyAvailableIndices,
allocationPolicyName,
allocationRequests != null,
allocationMasks != null,
allocationWithdraws != null,
selectionMode,
storageImplementation?.identity)) {
if (allocations.any((allocation) => allocation.data.width != indexWidth) ||
releases.any((release) => release.data.tag.width != indexWidth) ||
restore.data.width != capacity) {
throw ArgumentError(
'Allocation and release widths must represent every index, and the '
'restore payload must contain one bit per index.');
}
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);
// The core checks the number and width of the sidebands it is given.
this.allocationRequests = allocationRequests == null
? null
: [
for (final (lane, request) in allocationRequests.indexed)
addInput('allocationRequest$lane', request, width: request.width),
];
this.allocationMasks = allocationMasks == null
? null
: [
for (final (lane, mask) in allocationMasks.indexed)
addInput('allocationMask$lane', mask, width: mask.width),
];
this.allocationWithdraws = allocationWithdraws == null
? null
: [
for (final (lane, withdraw) in allocationWithdraws.indexed)
addInput('allocationWithdraw$lane', withdraw,
width: withdraw.width),
];
this.allocations = [
for (var lane = 0; lane < allocationLaneCount; lane++)
addPairInterfaceFrom(
IrrevocableReadyValidInterface<Logic>(allocations[lane].data.clone()),
allocations[lane],
PairRole.provider,
uniquify: (original) => 'allocation_${lane}_$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 lane = 0; lane < allocationLaneCount; lane++)
Logic(name: '${name}_allocate_$lane')
];
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);
final core = MultiIndexPool(
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,
allocationRequests: this.allocationRequests,
allocationMasks: this.allocationMasks,
allocationWithdraws: this.allocationWithdraws,
allocationGenerator: allocationGenerator,
allocationPolicyName: allocationPolicyName,
selectionMode: selectionMode,
storageImplementation: storageImplementation,
name: '${name}_core',
);
for (var lane = 0; lane < allocationLaneCount; lane++) {
final offer = cloneTypedPayload(this.allocations[lane].data);
connectPackedPayload(offer, core.allocationIndices[lane]);
ReadyValidEgressAttachmentPolicy<Logic>(coreGatesTransfer: true).attach(
downstream: this.allocations[lane],
offerValid: core.allocationValid[lane],
payload: offer,
transfer: allocate[lane],
);
}
for (var lane = 0; lane < releaseLaneCount; lane++) {
// The core takes every release, so the boundary is always ready.
ReadyValidIngressAttachmentPolicy<TagRelease>(
supportsSameCycleReplacement: true,
coreGatesAccept: true,
).attach(
upstream: this.releases[lane],
canAccept: Const(1),
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;
allocatedMasksAfterAllocationPrefixes = [
for (var prefix = 0; prefix <= allocationLaneCount; prefix++)
addOutput('allocatedMaskAfterAllocationPrefix$prefix', width: capacity)
..gets(core.allocatedMasksAfterAllocationPrefixes[prefix])
];
}