ReplacementPolicy constructor
- required Logic clk,
- required Logic reset,
- required Logic validMask,
- required Logic eligibleMask,
- required List<
ReplacementAccessInterface> accesses, - required List<
ReplacementAllocationInterface> allocations, - required int entryCount,
- required String name,
- required String? definitionName,
- List<
ReplacementCommitInterface> commits = const [],
Connects policy ports.
Implementation
ReplacementPolicy({
required Logic clk,
required Logic reset,
required Logic validMask,
required Logic eligibleMask,
required List<ReplacementAccessInterface> accesses,
required List<ReplacementAllocationInterface> allocations,
required this.entryCount,
required super.name,
required super.definitionName,
List<ReplacementCommitInterface> commits = const [],
}) : indexWidth = max(1, (entryCount - 1).bitLength) {
if (entryCount < 1) {
throw ArgumentError.value(entryCount, 'entryCount', 'Must be positive.');
}
if (validMask.width != entryCount || eligibleMask.width != entryCount) {
throw ArgumentError(
'Validity and eligibility must have one bit per entry.');
}
if (allocations.isEmpty ||
accesses.any((port) => port.entryCount != entryCount) ||
commits.any((port) => port.entryCount != entryCount) ||
allocations.any((port) => port.entryCount != entryCount)) {
throw ArgumentError('Allocation ports are required and all ports must '
'match the policy entry count.');
}
addInput('clk', clk);
addInput('reset', reset);
addInput('validMask', validMask, width: entryCount);
addInput('eligibleMask', eligibleMask, width: entryCount);
addOutput('invalidAccess');
addOutput('invalidCommit');
for (final (index, port) in accesses.indexed) {
localAccesses.add(addInterfacePorts(port,
inputTags: {DataPortGroup.control},
uniquify: (signal) => 'access_${index}_$signal'));
}
for (final (index, port) in commits.indexed) {
localCommits.add(addInterfacePorts(port,
inputTags: {DataPortGroup.control},
uniquify: (signal) => 'commit_${index}_$signal'));
}
for (final (index, port) in allocations.indexed) {
localAllocations.add(addInterfacePorts(port,
inputTags: {DataPortGroup.control},
outputTags: {DataPortGroup.data},
uniquify: (signal) => 'allocation_${index}_$signal'));
}
}