SynchronousMemoryRequest constructor

SynchronousMemoryRequest({
  1. required int dataWidth,
  2. required int addrWidth,
  3. required int entryCount,
  4. required int writePortCount,
  5. required int readPortCount,
  6. required List<bool> maskedWritePorts,
  7. required int readLatency,
  8. required SynchronousRamReadUnderWrite readUnderWrite,
  9. int writeLatency = 0,
  10. SynchronousMemoryResetBehavior requiredResetBehavior = SynchronousMemoryResetBehavior.none,
  11. ProtectedPartialWritePolicy protectedPartialWritePolicy = ProtectedPartialWritePolicy.none,
  12. SynchronousMemoryBankConflictPolicy bankConflictPolicy = SynchronousMemoryBankConflictPolicy.disallow,
  13. int bankCount = 1,
  14. SynchronousMemoryBankMapping bankMapping = SynchronousMemoryBankMapping.lowAddressBits,
})

Creates a synchronous-memory request.

Implementation

SynchronousMemoryRequest(
    {required this.dataWidth,
    required this.addrWidth,
    required this.entryCount,
    required this.writePortCount,
    required this.readPortCount,
    required List<bool> maskedWritePorts,
    required this.readLatency,
    required this.readUnderWrite,
    this.writeLatency = 0,
    this.requiredResetBehavior = SynchronousMemoryResetBehavior.none,
    this.protectedPartialWritePolicy = ProtectedPartialWritePolicy.none,
    this.bankConflictPolicy = SynchronousMemoryBankConflictPolicy.disallow,
    this.bankCount = 1,
    this.bankMapping = SynchronousMemoryBankMapping.lowAddressBits})
    : maskedWritePorts = List.unmodifiable(maskedWritePorts) {
  if (dataWidth < 1 || addrWidth < 1 || entryCount < 1) {
    throw ArgumentError(
        'Memory width, address width, and entry count must be '
        'positive.');
  }
  if (bankCount < 1) {
    throw ArgumentError.value(bankCount, 'bankCount', 'Must be positive.');
  }
  if (writePortCount < 0 ||
      readPortCount < 0 ||
      writePortCount + readPortCount == 0) {
    throw ArgumentError('A memory request requires at least one port.');
  }
  if (this.maskedWritePorts.length != writePortCount) {
    throw ArgumentError('maskedWritePorts must describe every write port.');
  }
  if (readLatency < 1 || writeLatency < 0) {
    throw ArgumentError('Read latency must be positive and write latency '
        'must not be negative.');
  }
  if ((BigInt.one << addrWidth) < BigInt.from(entryCount)) {
    throw ArgumentError(
        'Address width $addrWidth cannot represent entry count '
        '$entryCount.');
  }
  if (protectedPartialWritePolicy != ProtectedPartialWritePolicy.none &&
      !maskedWritePorts.contains(true)) {
    throw ArgumentError(
        'A protected partial-write policy requires a masked write port.');
  }
}