ReadyValidAssociativeInvalidator constructor
- required Logic clk,
- required Logic reset,
- required ReadyValidInterface<
AssociativeInvalidationRequest> request, - required IrrevocableReadyValidInterface<
AssociativeUpdateRequest< updates,Logic> > - required IrrevocableReadyValidInterface<
Logic> completion, - required int entryCount,
- required int keyWidth,
- String name = 'ready_valid_associative_invalidator',
Creates an associative invalidation sequencer.
Implementation
ReadyValidAssociativeInvalidator({
required Logic clk,
required Logic reset,
required ReadyValidInterface<AssociativeInvalidationRequest> request,
required IrrevocableReadyValidInterface<AssociativeUpdateRequest> updates,
required IrrevocableReadyValidInterface<Logic> completion,
required this.entryCount,
required this.keyWidth,
super.name = 'ready_valid_associative_invalidator',
}) : super(
definitionName:
'ReadyValidAssociativeInvalidator_E${entryCount}_K$keyWidth',
) {
if (entryCount <= 0) {
throw ArgumentError.value(entryCount, 'entryCount', 'Must be positive.');
}
final indexWidth = max(1, entryCount.log2Ceil);
if (request.data.entryMask.width != entryCount ||
updates.data.index.width != indexWidth ||
updates.data.key.width != keyWidth ||
completion.data.width != 1) {
throw ArgumentError(
'Invalidation request, update, and completion shapes must match.');
}
final localClk = addInput('clk', clk);
final localReset = addInput('reset', reset);
this.request = addPairInterface(request, PairRole.consumer,
uniquify: (original) => 'request_$original');
this.updates = addPairInterfaceFrom(
IrrevocableReadyValidInterface<AssociativeUpdateRequest>(
updates.data.clone()),
updates,
PairRole.provider,
uniquify: (original) => 'update_$original',
);
this.completion = addPairInterfaceFrom(
IrrevocableReadyValidInterface<Logic>(completion.data.clone()),
completion,
PairRole.provider,
uniquify: (original) => 'completion_$original',
);
final load = Logic(name: '${name}_load');
final loaded = this.request.data.cloneTyped(name: '${name}_request');
final advance = Logic(name: '${name}_advance');
final consumeCompletion = Logic(name: '${name}_consume_completion');
final updateEgress =
ReadyValidEgressAttachmentPolicy<AssociativeUpdateRequest>();
final completionEgress =
ReadyValidEgressAttachmentPolicy<Logic>(coreGatesTransfer: true);
final core = AssociativeInvalidator(
clk: localClk,
reset: localReset,
load: load,
request: loaded,
advance: updateEgress.transferControl(advance, name: 'advance'),
consumeCompletion: completionEgress.transferControl(consumeCompletion,
name: 'consumeCompletion'),
name: '${name}_core',
);
// The core qualifies the request and the completion itself.
ReadyValidIngressAttachmentPolicy<AssociativeInvalidationRequest>(
supportsSameCycleReplacement: false,
storageDepth: 1,
coreGatesAccept: true,
).attach(
upstream: this.request,
canAccept: core.canLoad,
accept: load,
payload: loaded,
);
final update = this.updates.data.cloneTyped(name: '${name}_update');
update.index <= core.updateIndex;
update.key <= Const(0, width: keyWidth);
update.entryValid <= Const(0);
updateEgress.attach(
downstream: this.updates,
offerValid: core.updateValid,
payload: update,
transfer: advance,
);
completionEgress.attach(
downstream: this.completion,
offerValid: core.completionValid,
payload: Const(1),
transfer: consumeCompletion,
);
addOutput('busy') <= core.busy;
}