ReadyValidPhysicalRegisterState<LogicType extends Logic> constructor
- required Logic clk,
- required Logic reset,
- required List<
ReadyValidInterface< markBusy,Logic> > - required List<
ReadyValidInterface< writebacks,ExecutionWritebackEvent< >LogicType> > - required List<
Logic> readTags, - required int capacity,
- required int valueWidth,
- List<
ReadyValidInterface< wakeups = const [],WakeupEvent< >Logic> > - ReadyValidInterface<
Logic> ? restore, - PhysicalWritebackPredicate<
LogicType> ? writebackPredicate, - PhysicalWritebackValue<
LogicType> ? wakeupValue, - PhysicalWritebackValue<
LogicType> ? writebackValue, - PhysicalWritePortFactory writePortFactory = _defaultPhysicalWritePortFactory,
- PhysicalWritePortConfigurer<
LogicType> ? writePortConfigurer, - RegisterFileFunctor registerFileFunctor = flopRegisterFileFunctor,
- String policyIdentity = 'default',
- String? definitionNameOverride,
- String name = 'ready_valid_physical_register_state',
Creates a physical-register state composition.
Custom writeback, wakeup, and write-port callbacks require a distinct
policyIdentity or definitionNameOverride.
Implementation
ReadyValidPhysicalRegisterState({
required Logic clk,
required Logic reset,
required List<ReadyValidInterface<Logic>> markBusy,
required List<ReadyValidInterface<ExecutionWritebackEvent<LogicType>>>
writebacks,
required List<Logic> readTags,
required this.capacity,
required this.valueWidth,
List<ReadyValidInterface<WakeupEvent<Logic>>> wakeups = const [],
ReadyValidInterface<Logic>? restore,
PhysicalWritebackPredicate<LogicType>? writebackPredicate,
PhysicalWritebackValue<LogicType>? wakeupValue,
PhysicalWritebackValue<LogicType>? writebackValue,
PhysicalWritePortFactory writePortFactory =
_defaultPhysicalWritePortFactory,
PhysicalWritePortConfigurer<LogicType>? writePortConfigurer,
RegisterFileFunctor registerFileFunctor = flopRegisterFileFunctor,
String policyIdentity = 'default',
String? definitionNameOverride,
super.name = 'ready_valid_physical_register_state',
}) : super(
definitionName: definitionNameOverride ??
schemaQualifiedDefinitionName(
'ReadyValidPhysicalRegisterState_'
'C${capacity}_V${valueWidth}_B${markBusy.length}_'
'W${writebacks.length}_R${readTags.length}_'
'U${wakeups.length}_'
'${restore == null ? '' : 'Restore_'}'
'${registerFileFunctor.identity}_${policyIdentity}_',
[
...writebacks.map((writeback) => writeback.data),
...wakeups.map((wakeup) => wakeup.data),
],
),
) {
final localClk = addInput('clk', clk);
final localReset = addInput('reset', reset);
final localMarkBusy = [
for (var lane = 0; lane < markBusy.length; lane++)
addPairInterface(markBusy[lane], PairRole.consumer,
uniquify: (original) => 'markBusy_${lane}_$original'),
];
this.writebacks = [
for (var lane = 0; lane < writebacks.length; lane++)
addPairInterface(writebacks[lane], PairRole.consumer,
uniquify: (original) => 'writeback_${lane}_$original'),
];
this.wakeups = [
for (var lane = 0; lane < wakeups.length; lane++)
addPairInterface(wakeups[lane], PairRole.provider,
uniquify: (original) => 'wakeup_${lane}_$original'),
];
final localReadTags = [
for (var port = 0; port < readTags.length; port++)
addInput('readTag_$port', readTags[port], width: readTags[port].width),
];
final localRestore = restore == null
? null
: addPairInterface(restore, PairRole.consumer,
uniquify: (original) => 'restore_$original');
final busyActions = [
for (var lane = 0; lane < localMarkBusy.length; lane++)
Logic(name: '${name}_mark_busy_$lane'),
];
final busyTags = [
for (final update in localMarkBusy) cloneInterfacePayload(update.data),
];
final writebackActions = [
for (var lane = 0; lane < this.writebacks.length; lane++)
Logic(name: '${name}_writeback_$lane'),
];
final writebackData = [
for (final writeback in this.writebacks)
cloneTypedPayload(writeback.data),
];
final wakeupTransfers = [
for (var lane = 0; lane < this.wakeups.length; lane++)
Logic(name: '${name}_wakeup_transfer_$lane'),
];
final restoreAction =
localRestore == null ? null : Logic(name: '${name}_restore');
final restoreData =
localRestore == null ? null : cloneInterfacePayload(localRestore.data);
final wakeupEgress = ReadyValidEgressAttachmentPolicy<WakeupEvent<Logic>>(
requiresRetention: false,
coreGatesTransfer: true,
);
final core = PhysicalRegisterState<LogicType>(
clk: localClk,
reset: localReset,
markBusy: busyActions,
busyTags: busyTags,
writebacks: writebackActions,
writebackData: writebackData,
readTags: localReadTags,
capacity: capacity,
valueWidth: valueWidth,
wakeupValue: this.wakeups.isEmpty ? null : wakeupValue,
wakeupTransfers: [
for (var lane = 0; lane < wakeupTransfers.length; lane++)
wakeupEgress.transferControl(wakeupTransfers[lane],
name: 'wakeupTransfer$lane'),
],
restore: restoreAction,
restoreBusyResources: restoreData,
writebackPredicate: writebackPredicate,
writebackValue: writebackValue,
// Only a custom factory needs the shell's port names.
writePortFactory:
identical(writePortFactory, _defaultPhysicalWritePortFactory)
? null
: ({required valueWidth, required tagWidth, required name}) =>
writePortFactory(
valueWidth: valueWidth,
tagWidth: tagWidth,
name: name.replaceFirst(
'${this.name}_core_', '${this.name}_')),
writePortConfigurer: writePortConfigurer,
registerFileFunctor: registerFileFunctor,
policyIdentity: policyIdentity,
definitionNameOverride: definitionNameOverride == null
? null
: '${definitionNameOverride}_Core',
name: '${name}_core',
);
if (this.wakeups.any((wakeup) =>
wakeup.data.tagWidth != core.tagWidth ||
wakeup.data.data.width != valueWidth)) {
throw ArgumentError(
'Busy, writeback, wakeup, read, value, and tag geometry must match.');
}
scoreboard = core.scoreboard;
registerFile = core.registerFile;
readPorts = core.readPorts;
// The core takes every busy update and restore, so those boundaries are
// always ready.
for (var lane = 0; lane < localMarkBusy.length; lane++) {
ReadyValidIngressAttachmentPolicy<Logic>(
supportsSameCycleReplacement: true,
coreGatesAccept: true,
).attach(
upstream: localMarkBusy[lane],
canAccept: Const(1),
accept: busyActions[lane],
payload: busyTags[lane],
);
}
for (var lane = 0; lane < this.writebacks.length; lane++) {
ReadyValidIngressAttachmentPolicy<ExecutionWritebackEvent<LogicType>>(
supportsSameCycleReplacement: true,
coreGatesAccept: true,
).attach(
upstream: this.writebacks[lane],
canAccept: core.canWriteback[lane],
accept: writebackActions[lane],
payload: writebackData[lane],
);
}
for (var lane = 0; lane < this.wakeups.length; lane++) {
final offer = cloneTypedPayload(this.wakeups[lane].data);
final result = core.wakeupData[lane];
if (!rohdPayloadsCompatible([offer.data, result.data],
allowRenamedClones: true)) {
throw ArgumentError(
'Wakeup lane $lane must match its extracted value payload.');
}
connectPackedPayload(offer.data, result.data.packed);
offer.tag <= result.tag;
offer.speculative <= result.speculative;
wakeupEgress.attach(
downstream: this.wakeups[lane],
offerValid: core.wakeupValid[lane],
payload: offer,
transfer: wakeupTransfers[lane],
);
}
if (localRestore != null) {
ReadyValidIngressAttachmentPolicy<Logic>(
supportsSameCycleReplacement: false,
coreGatesAccept: true,
).attach(
upstream: localRestore,
canAccept: Const(1),
accept: restoreAction!,
payload: restoreData!,
);
}
queryBusy = [
for (var port = 0; port < localReadTags.length; port++)
addOutput('queryBusy_$port')..gets(core.queryBusy[port]),
];
readValues = [
for (var port = 0; port < localReadTags.length; port++)
addOutput('readValue_$port', width: valueWidth)
..gets(core.readValues[port]),
];
addOutput('busyResources', width: capacity) <= core.busyResources;
addOutput('suppressedWritebacks', width: this.writebacks.length) <=
core.suppressedWritebacks;
}