IndexedRecoveryEventDecorator<LogicType extends Logic> constructor

IndexedRecoveryEventDecorator<LogicType extends Logic>({
  1. required LogicType data,
  2. required Logic index,
  3. required int entryCount,
  4. String name = 'indexed_recovery_event_decorator',
})

Creates a combinational indexed recovery-event decorator.

Implementation

IndexedRecoveryEventDecorator({
  required LogicType data,
  required Logic index,
  required this.entryCount,
  super.name = 'indexed_recovery_event_decorator',
}) : super(
        definitionName:
            'IndexedRecoveryEventDecorator_E${entryCount}_W${data.width}_'
            '${payloadShapeIdentity(data)}',
      ) {
  if (entryCount < 1 || index.width != widthFor(entryCount)) {
    throw ArgumentError(
      'Entry count must be positive and index width must match it.',
    );
  }

  this.data = addTypedInput('data', data);
  this.index = addInput('index', index, width: index.width);
  event = addTypedPayloadOutput(
    this,
    'recoveryEvent',
    RecoveryEvent<LogicType>(
      this.data.cloneTyped(),
      indexWidth: index.width,
    ),
  );

  event.data <= this.data;
  event.index <= this.index;
  event.finalEntry <= this.index.eq(entryCount - 1);
  event.writeEnable <= Const(1);
}