RegisterFileRequest constructor

RegisterFileRequest({
  1. required int entryCount,
  2. required List<DataPortInterface<Logic>> writePorts,
  3. required List<DataPortInterface<Logic>> readPorts,
  4. required RegisterFileReadUnderWrite readUnderWrite,
  5. required RegisterFileWriteConflictResolution writeConflictResolution,
})

Creates and validates a register-file request.

Implementation

RegisterFileRequest({
  required this.entryCount,
  required List<DataPortInterface> writePorts,
  required List<DataPortInterface> readPorts,
  required this.readUnderWrite,
  required this.writeConflictResolution,
})  : dataWidth = _firstRegisterFilePort(writePorts, readPorts).dataWidth,
      addrWidth = _firstRegisterFilePort(writePorts, readPorts).addrWidth,
      readPortCount = readPorts.length,
      writePortCount = writePorts.length,
      usesMaskedWrites = writePorts.any(
        (port) => port is MaskedDataPortInterface,
      ) {
  if (entryCount < 1) {
    throw ArgumentError.value(entryCount, 'entryCount', 'Must be positive.');
  }
  if ([...writePorts, ...readPorts].any(
    (port) => port.dataWidth != dataWidth || port.addrWidth != addrWidth,
  )) {
    throw ArgumentError('All register-file ports must have matching widths.');
  }
  if (entryCount > (1 << addrWidth)) {
    throw ArgumentError('The address width cannot represent every entry.');
  }
}