ReadyValidLoadStoreIssueBoundary<MetadataType extends Logic> constructor
- required Logic clk,
- required Logic reset,
- required Logic quiesce,
- required Logic selectedLoadValid,
- required Logic selectedLoadTag,
- required ConservativeLoadIssue<
MetadataType> selectedLoad, - required Logic selectedStoreValid,
- required Logic selectedStoreTag,
- required StoreQueueEntry<
MetadataType> selectedStore, - required ReadyValidInterface<
Tagged< loadIssue,ConservativeLoadIssue< >MetadataType> > - required ReadyValidInterface<
Tagged< loadExecutionUpdate,Logic> > - required ReadyValidInterface<
Tagged< storeDrain,StoreQueueEntry< >MetadataType> > - required ReadyValidInterface<
TagRelease> storeRelease, - String name = 'ready_valid_load_store_issue_boundary',
Creates a retained load-issue and store-drain boundary.
Implementation
ReadyValidLoadStoreIssueBoundary({
required Logic clk,
required Logic reset,
required Logic quiesce,
required Logic selectedLoadValid,
required Logic selectedLoadTag,
required ConservativeLoadIssue<MetadataType> selectedLoad,
required Logic selectedStoreValid,
required Logic selectedStoreTag,
required StoreQueueEntry<MetadataType> selectedStore,
required ReadyValidInterface<Tagged<ConservativeLoadIssue<MetadataType>>>
loadIssue,
required ReadyValidInterface<Tagged<Logic>> loadExecutionUpdate,
required ReadyValidInterface<Tagged<StoreQueueEntry<MetadataType>>>
storeDrain,
required ReadyValidInterface<TagRelease> storeRelease,
super.name = 'ready_valid_load_store_issue_boundary',
}) : super(
definitionName: 'ReadyValidLoadStoreIssueBoundary_'
'L${selectedLoadTag.width}_S${selectedStoreTag.width}_'
'${payloadShapesIdentity([
selectedLoad,
selectedStore,
loadIssue.data,
storeDrain.data
])}',
) {
if (loadIssue.data.tagWidth != selectedLoadTag.width ||
loadIssue.data.data.width != selectedLoad.width ||
loadExecutionUpdate.data.tagWidth != selectedLoadTag.width ||
loadExecutionUpdate.data.data.width != 2 ||
storeDrain.data.tagWidth != selectedStoreTag.width ||
storeDrain.data.data.width != selectedStore.width ||
storeRelease.data.tagWidth != selectedStoreTag.width) {
throw ArgumentError(
'Policy selections, outputs, and state updates must match.',
);
}
bool matchingFields(LogicStructure first, LogicStructure second) =>
first.elements.length == second.elements.length &&
Iterable<int>.generate(first.elements.length - 1).every((index) =>
first.elements[index + 1].width ==
second.elements[index + 1].width);
if (!matchingFields(selectedLoad.entry, loadIssue.data.data.entry) ||
selectedLoad.data.width != loadIssue.data.data.data.width ||
!matchingFields(selectedStore, storeDrain.data.data) ||
!rohdPayloadsCompatible(
[selectedLoad.entry.metadata, loadIssue.data.data.entry.metadata],
ignoreConstantNames: true) ||
!rohdPayloadsCompatible(
[selectedStore.metadata, storeDrain.data.data.metadata],
ignoreConstantNames: true)) {
throw ArgumentError('Selected and output payloads must be compatible.');
}
for (final output in [
loadIssue,
loadExecutionUpdate,
storeDrain,
storeRelease,
]) {
output.requireConsumerComposableWith(
ReadyValidContract.readyThenValid,
providerName: name,
);
}
final localClk = addInput('clk', clk);
final localReset = addInput('reset', reset);
final localQuiesce = addInput('quiesce', quiesce);
final localLoadValid = addInput('selectedLoadValid', selectedLoadValid);
final localLoadTag = addInput(
'selectedLoadTag',
selectedLoadTag,
width: selectedLoadTag.width,
);
final localLoad = addTypedInput('selectedLoad', selectedLoad);
final localStoreValid = addInput('selectedStoreValid', selectedStoreValid);
final localStoreTag = addInput(
'selectedStoreTag',
selectedStoreTag,
width: selectedStoreTag.width,
);
final localStore = addTypedInput('selectedStore', selectedStore);
this.loadIssue = addPairInterface(loadIssue, PairRole.provider,
uniquify: (original) => 'load_issue_$original');
this.loadExecutionUpdate = addPairInterface(
loadExecutionUpdate, PairRole.provider,
uniquify: (original) => 'load_update_$original');
this.storeDrain = addPairInterface(storeDrain, PairRole.provider,
uniquify: (original) => 'store_drain_$original');
this.storeRelease = addPairInterface(storeRelease, PairRole.provider,
uniquify: (original) => 'store_release_$original');
addOutput('quiesced');
final retainedLoad =
loadIssue.data.cloneTyped(name: '${name}_retained_load');
final loadBusy = Logic(name: '${name}_load_busy');
final captureLoad = ~loadBusy & ~localQuiesce & localLoadValid;
final loadSource = ReadyAndValidInterface(retainedLoad.cloneTyped());
loadSource.valid <= loadBusy;
loadSource.data <= retainedLoad;
final loadConsumer = ReadyThenValidInterface(retainedLoad.cloneTyped());
final loadUpdateConsumer =
ReadyThenValidInterface(retainedLoad.cloneTyped());
ReadyValidBroadcastFork(
upstream: loadSource,
downstreams: [loadConsumer, loadUpdateConsumer],
name: '${name}_load_broadcast',
);
loadConsumer.ready <= this.loadIssue.ready;
this.loadIssue.valid <= loadConsumer.valid;
this.loadIssue.data <= loadConsumer.data;
loadUpdateConsumer.ready <= this.loadExecutionUpdate.ready;
this.loadExecutionUpdate.valid <= loadUpdateConsumer.valid;
this.loadExecutionUpdate.data.tag <= loadUpdateConsumer.data.tag;
this.loadExecutionUpdate.data.data <=
[~loadUpdateConsumer.data.data.forwarded, Const(1)].concat();
final retainedStore =
storeDrain.data.cloneTyped(name: '${name}_retained_store');
final storeBusy = Logic(name: '${name}_store_busy');
final captureStore = ~storeBusy & ~localQuiesce & localStoreValid;
final storeSource = ReadyAndValidInterface(retainedStore.cloneTyped());
storeSource.valid <= storeBusy;
storeSource.data <= retainedStore;
final storeConsumer = ReadyThenValidInterface(retainedStore.cloneTyped());
final storeReleaseConsumer =
ReadyThenValidInterface(retainedStore.cloneTyped());
ReadyValidBroadcastFork(
upstream: storeSource,
downstreams: [storeConsumer, storeReleaseConsumer],
name: '${name}_store_broadcast',
);
storeConsumer.ready <= this.storeDrain.ready;
this.storeDrain.valid <= storeConsumer.valid;
this.storeDrain.data <= storeConsumer.data;
storeReleaseConsumer.ready <= this.storeRelease.ready;
this.storeRelease.valid <= storeReleaseConsumer.valid;
this.storeRelease.data.tag <= storeReleaseConsumer.data.tag;
quiesced <= localQuiesce & ~loadBusy & ~storeBusy;
Sequential(localClk, reset: localReset, resetValues: {
loadBusy: 0,
retainedLoad: 0,
storeBusy: 0,
retainedStore: 0,
}, [
If(captureLoad, then: [
loadBusy < 1,
retainedLoad.tag < localLoadTag,
retainedLoad.data < localLoad,
]),
If(loadSource.accepted, then: [loadBusy < 0]),
If(captureStore, then: [
storeBusy < 1,
retainedStore.tag < localStoreTag,
retainedStore.data < localStore,
]),
If(storeSource.accepted, then: [storeBusy < 0]),
]);
}