RetirementSelector<LogicType extends Logic> constructor

RetirementSelector<LogicType extends Logic>({
  1. required Logic orderValid,
  2. required Logic orderTag,
  3. required Logic completionValid,
  4. required TaggedCompletion<LogicType> completion,
  5. required Logic retire,
  6. String name = 'retirement_selector',
})

Creates an ordered retirement join driven by a retire action.

Implementation

RetirementSelector({
  required Logic orderValid,
  required Logic orderTag,
  required Logic completionValid,
  required TaggedCompletion<LogicType> completion,
  required Logic retire,
  super.name = 'retirement_selector',
})  : tagWidth = completion.tagWidth,
      super(
        definitionName: 'RetirementSelector_'
            'W${completion.data.width}_TW${completion.tagWidth}_'
            '${payloadShapeIdentity(completion)}',
      ) {
  if (orderTag.width != tagWidth) {
    throw ArgumentError('Order and completion tag widths must match.');
  }

  final localOrderValid = addInput('orderValid', orderValid);
  final localOrderTag = addInput('orderTag', orderTag, width: tagWidth);
  final localCompletionValid = addInput('completionValid', completionValid);
  final localCompletion = addTypedInput('completion', completion);
  final localRetire = addInput('retire', retire);

  final tagsMatch =
      localOrderTag.eq(localCompletion.tag).named('${name}_tags_match');
  addOutput('retirementValid') <=
      localOrderValid & localCompletionValid & tagsMatch;
  final retired =
      (retirementValid & localRetire).named('${name}_completion_retired');

  retirement = addTypedPayloadOutput(this, 'retirement', localCompletion)
    ..gets(localCompletion);
  addOutput('canTakeCompletion') <= localRetire & localOrderValid & tagsMatch;
  addOutput('canReleaseOrder') <= retired & localCompletion.finalBeat;
  addOutput('completionWithoutOrder') <=
      localCompletionValid & ~localOrderValid;
  addOutput('tagMismatch') <=
      localCompletionValid & localOrderValid & ~tagsMatch;
}