ReadyValidQueueBank<LogicType extends Logic> constructor

ReadyValidQueueBank<LogicType extends Logic>({
  1. required Logic clk,
  2. required Logic reset,
  3. required ReadyValidInterface<PoolRequest<LogicType>> enqueue,
  4. required List<ReadyValidInterface<LogicType>> downstreams,
  5. required int storageDepth,
  6. List<int>? storageDepths,
  7. int requestedStorageLatency = 1,
  8. int outputBufferDepth = 1,
  9. ReadyValidStorageQueueFunctor<LogicType>? storageImplementation,
  10. Logic? flush,
  11. String name = 'ready_valid_queue_bank',
})

Creates a bank of independently readable queues.

Implementation

factory ReadyValidQueueBank({
  required Logic clk,
  required Logic reset,
  required ReadyValidInterface<PoolRequest<LogicType>> enqueue,
  required List<ReadyValidInterface<LogicType>> downstreams,
  required int storageDepth,
  List<int>? storageDepths,
  int requestedStorageLatency = 1,
  int outputBufferDepth = 1,
  ReadyValidStorageQueueFunctor<LogicType>? storageImplementation,
  Logic? flush,
  String name = 'ready_valid_queue_bank',
}) {
  if (downstreams.isEmpty) {
    throw ArgumentError.value(
        downstreams, 'downstreams', 'Must not be empty.');
  }
  final resolvedDepths =
      storageDepths ?? List.filled(downstreams.length, storageDepth);
  if (resolvedDepths.length != downstreams.length ||
      resolvedDepths.any((depth) => depth < 1)) {
    throw ArgumentError.value(storageDepths, 'storageDepths',
        'Must provide one positive depth for each queue.');
  }
  if (requestedStorageLatency < 1 || outputBufferDepth < 0) {
    throw ArgumentError('requestedStorageLatency must be positive and '
        'outputBufferDepth must not be negative.');
  }
  final selectedImplementation = storageImplementation ??
      readyValidPortableStorageQueueImplementation<LogicType>();
  final bindings = [
    for (final depth in resolvedDepths)
      selectedImplementation.resolve(
        ReadyValidStorageQueueRequest(
          dataWidth: enqueue.data.data.width,
          depth: depth,
          requestedOutputLatency: requestedStorageLatency,
        ),
      ),
  ];
  return ReadyValidQueueBank<LogicType>._(
    clk: clk,
    reset: reset,
    enqueue: enqueue,
    downstreams: downstreams,
    storageDepths: resolvedDepths,
    requestedStorageLatency: requestedStorageLatency,
    outputBufferDepth: outputBufferDepth,
    storageImplementation: selectedImplementation,
    storageBindings: bindings,
    flush: flush,
    name: name,
  );
}