SetAssociativeCacheLayout constructor
Creates set-associative storage geometry.
Implementation
SetAssociativeCacheLayout({
required this.addrWidth,
required this.setCount,
required this.wayCount,
required this.lineWidth,
}) : setWidth = max(1, _cacheLog2Ceil(setCount)),
tagWidth = addrWidth - max(1, _cacheLog2Ceil(setCount)),
assert(addrWidth > 0, 'Address width must be positive.'),
assert(setCount > 0, 'Set count must be positive.'),
assert(wayCount > 0, 'Way count must be positive.'),
assert(lineWidth > 0, 'Line width must be positive.') {
if (addrWidth < 1 ||
setCount < 1 ||
wayCount < 1 ||
lineWidth < 1 ||
(setCount & (setCount - 1)) != 0 ||
tagWidth < 1) {
throw ArgumentError(
'Address width, set count, way count, and line width must be valid; '
'set count must be a power of two and leave tag bits.',
);
}
}