ExternalAssociativeMemory constructor
- required Logic clk,
- required Logic reset,
- required List<
AssociativeUpdatePortInterface> updatePorts, - required List<
AssociativeLookupPortInterface> lookupPorts, - required int entryCount,
- required int keyWidth,
- required int indexWidth,
- required int lookupLatency,
- required String definitionName,
- String? matchSelection,
- String? updateCollisionPolicy,
- String? resetBehavior,
- Map<
String, String> ? parameters, - String name = 'external_associative_memory',
Creates an external associative-memory macro adapter.
Implementation
ExternalAssociativeMemory({
required Logic clk,
required Logic reset,
required List<AssociativeUpdatePortInterface> updatePorts,
required List<AssociativeLookupPortInterface> lookupPorts,
required this.entryCount,
required this.keyWidth,
required this.indexWidth,
required this.lookupLatency,
required super.definitionName,
String? matchSelection,
String? updateCollisionPolicy,
String? resetBehavior,
Map<String, String>? parameters,
super.name = 'external_associative_memory',
}) : super(
parameters: {
'ENTRY_COUNT': '$entryCount',
'KEY_WIDTH': '$keyWidth',
'INDEX_WIDTH': '$indexWidth',
'UPDATE_PORTS': '${updatePorts.length}',
'LOOKUP_PORTS': '${lookupPorts.length}',
'LOOKUP_LATENCY': '$lookupLatency',
if (matchSelection != null) 'MATCH_SELECTION': '"$matchSelection"',
if (updateCollisionPolicy != null)
'UPDATE_COLLISION_POLICY': '"$updateCollisionPolicy"',
if (resetBehavior != null) 'RESET_BEHAVIOR': '"$resetBehavior"',
...?parameters,
},
) {
if (entryCount < 1 || keyWidth < 1 || indexWidth < 1 || lookupLatency < 0) {
throw ArgumentError('Associative macro geometry must be valid.');
}
if (updatePorts.any((port) =>
port.keyWidth != keyWidth || port.indexWidth != indexWidth) ||
lookupPorts.any((port) =>
port.keyWidth != keyWidth || port.indexWidth != indexWidth)) {
throw ArgumentError('All associative ports must match macro geometry.');
}
if (lookupPorts.isEmpty) {
throw ArgumentError('At least one lookup port is required.');
}
addInput('clk', clk);
addInput('reset', reset);
for (var index = 0; index < updatePorts.length; index++) {
addInterface<AssociativeUpdatePortInterface, DataPortGroup>(
updatePorts[index],
inputTags: {DataPortGroup.control, DataPortGroup.data},
outputTags: const {},
uniquify: (original) => 'update_${index}_$original',
);
}
for (var index = 0; index < lookupPorts.length; index++) {
addInterface<AssociativeLookupPortInterface, DataPortGroup>(
lookupPorts[index],
inputTags: {DataPortGroup.control},
outputTags: {DataPortGroup.data},
uniquify: (original) => 'lookup_${index}_$original',
);
}
}