RoundRobinReplacement constructor
- required Logic clk,
- required Logic reset,
- required Logic validMask,
- required Logic eligibleMask,
- required List<
ReplacementAccessInterface> accesses, - required List<
ReplacementAllocationInterface> allocations, - required int entryCount,
- List<
ReplacementCommitInterface> commits = const [], - String name = 'round_robin_replacement',
Creates a round-robin policy.
Implementation
RoundRobinReplacement({
required super.clk,
required super.reset,
required super.validMask,
required super.eligibleMask,
required super.accesses,
required super.allocations,
required super.entryCount,
super.commits,
super.name = 'round_robin_replacement',
}) : super(
definitionName: 'RoundRobinReplacement_E${entryCount}_'
'H${accesses.length}_A${allocations.length}'
'${commits.isEmpty ? '' : '_C${commits.length}'}') {
buildPolicy(
stateWidth: indexWidth,
onAccess: (state, index) => state,
select: (state, candidates) {
final width = entryCount.bitLength;
final pointer = state.zeroExtend(width);
// Keep the existing flattened module ports and generated definition.
// ignore: deprecated_member_use_from_same_package
final selector = AssociativeMatchSelector(
matchVector: candidates,
selectionValues: [
for (var index = 0; index < entryCount; index++)
mux(
Const(index, width: width).gte(pointer),
Const(index, width: width) - pointer,
Const(entryCount, width: width) -
pointer +
Const(index, width: width),
)
],
selectionName: 'roundRobin',
);
return (valid: selector.valid, index: selector.selectedIndex);
},
onAllocation: (state, index) => mux(
storedIndexMatches(index, entryCount - 1),
Const(0, width: indexWidth),
index + Const(1, width: indexWidth)),
);
}