ReadyValidStorageQueue<LogicType extends Logic> constructor

ReadyValidStorageQueue<LogicType extends Logic>({
  1. required Logic clk,
  2. required Logic reset,
  3. required ReadyValidInterface<LogicType> upstream,
  4. required ReadyValidInterface<LogicType> downstream,
  5. required int storageDepth,
  6. int requestedStorageLatency = 1,
  7. int outputBufferDepth = 1,
  8. ReadyValidStorageQueueFunctor<LogicType>? storageImplementation,
  9. int? almostFullThreshold,
  10. int? almostEmptyThreshold,
  11. Logic? flush,
  12. String name = 'ready_valid_storage_queue',
})

Creates a queue from a resolved storage implementation.

Implementation

factory ReadyValidStorageQueue(
    {required Logic clk,
    required Logic reset,
    required ReadyValidInterface<LogicType> upstream,
    required ReadyValidInterface<LogicType> downstream,
    required int storageDepth,
    int requestedStorageLatency = 1,
    int outputBufferDepth = 1,
    ReadyValidStorageQueueFunctor<LogicType>? storageImplementation,
    int? almostFullThreshold,
    int? almostEmptyThreshold,
    Logic? flush,
    String name = 'ready_valid_storage_queue'}) {
  final selectedStorage = storageImplementation ??
      readyValidPortableStorageQueueImplementation<LogicType>();
  final storageBinding = selectedStorage.resolve(
      ReadyValidStorageQueueRequest(
          dataWidth: upstream.data.width,
          depth: storageDepth,
          requestedOutputLatency: requestedStorageLatency));
  final resolvedFullThreshold = almostFullThreshold ??
      storageBinding.contract.capacity + outputBufferDepth;
  return ReadyValidStorageQueue<LogicType>._(
      clk: clk,
      reset: reset,
      upstream: upstream,
      downstream: downstream,
      storageDepth: storageDepth,
      requestedStorageLatency: requestedStorageLatency,
      outputBufferDepth: outputBufferDepth,
      storageImplementation: selectedStorage,
      storageBinding: storageBinding,
      almostFullThreshold: almostFullThreshold,
      almostEmptyThreshold: almostEmptyThreshold,
      flush: flush,
      name: name,
      definitionName: 'ReadyValidStorageQueue_D${storageDepth}_'
          'L${requestedStorageLatency}_B${outputBufferDepth}_'
          'S${selectedStorage.identity}_'
          'AF${resolvedFullThreshold}_'
          'AE${almostEmptyThreshold ?? 0}_'
          '${flush == null ? 'NoFlush' : 'Flush'}_${upstream.data.name}_'
          '${payloadShapesIdentity([upstream.data, downstream.data])}');
}