ExternalTrueDualPortSynchronousMemory constructor
- required Logic clk,
- required Logic reset,
- required List<
TrueDualPortMemoryPort< ports,Logic> > - required int entryCount,
- required String definitionName,
- int readLatency = 1,
- TrueDualPortWriteConflictPolicy writeConflictPolicy = TrueDualPortWriteConflictPolicy.disallow,
- SynchronousRamReadUnderWrite readUnderWrite = SynchronousRamReadUnderWrite.readFirst,
- Map<
String, String> ? parameters, - String name = 'external_true_dual_port_synchronous_memory',
Creates a late-bound true dual-port memory instance.
Implementation
ExternalTrueDualPortSynchronousMemory({
required Logic clk,
required Logic reset,
required List<TrueDualPortMemoryPort> ports,
required this.entryCount,
required super.definitionName,
this.readLatency = 1,
this.writeConflictPolicy = TrueDualPortWriteConflictPolicy.disallow,
this.readUnderWrite = SynchronousRamReadUnderWrite.readFirst,
Map<String, String>? parameters,
super.name = 'external_true_dual_port_synchronous_memory',
}) : dataWidth = ports.isEmpty ? 0 : ports.first.dataWidth,
addrWidth = ports.isEmpty ? 0 : ports.first.addrWidth,
super(parameters: {
'DEPTH': '$entryCount',
'WIDTH': '${ports.isEmpty ? 0 : ports.first.dataWidth}',
'ADDR_WIDTH': '${ports.isEmpty ? 0 : ports.first.addrWidth}',
'READ_LATENCY': '$readLatency',
'WRITE_CONFLICT_POLICY': '"${writeConflictPolicy.name}"',
'READ_UNDER_WRITE': '"${readUnderWrite.systemVerilogParameter}"',
...?parameters,
}) {
if (ports.length != 2) {
throw ArgumentError('Exactly two true dual-port memory ports required.');
}
if (entryCount < 1 || dataWidth < 1 || addrWidth < 1 || readLatency < 1) {
throw ArgumentError('Memory geometry and latency must be positive.');
}
if ((BigInt.one << addrWidth) < BigInt.from(entryCount)) {
throw ArgumentError('Address width cannot represent memory entry count.');
}
if (ports.any((port) => port.addrWidth != addrWidth)) {
throw ArgumentError(
'All true dual-port ports must have matching address widths.');
}
if (!rohdPayloadsCompatible([
for (final port in ports) ...[port.writeData, port.readData],
])) {
throw ArgumentError(
'All true dual-port ports must share one payload schema.');
}
final maskWidths = ports.map((port) => port.maskWidth).toSet();
if (maskWidths.length != 1) {
throw ArgumentError('All true dual-port ports must have matching masks.');
}
addInput('clk', clk);
addInput('reset', reset);
for (var index = 0; index < 2; index++) {
addInterface(
ports[index],
inputTags: {
TrueDualPortMemoryGroup.request,
TrueDualPortMemoryGroup.writeData,
},
outputTags: {TrueDualPortMemoryGroup.response},
uniquify: (original) => '${original}_$index',
);
}
}