CreditConservationChecker constructor

CreditConservationChecker(
  1. String name,
  2. Component? parent, {
  3. required Logic clk,
  4. required Logic reset,
  5. required List<Logic> available,
  6. required List<Logic> forwardInFlight,
  7. required List<Logic> receiverOccupied,
  8. required List<Logic> returnsInFlight,
  9. required List<int> provisioned,
  10. String endpoint = 'creditPath',
  11. bool reportViolations = true,
})

Creates an end-to-end conservation checker.

Implementation

CreditConservationChecker(super.name, super.parent,
    {required this.clk,
    required this.reset,
    required List<Logic> available,
    required List<Logic> forwardInFlight,
    required List<Logic> receiverOccupied,
    required List<Logic> returnsInFlight,
    required List<int> provisioned,
    this.endpoint = 'creditPath',
    this.reportViolations = true})
    : available = List.unmodifiable(available),
      forwardInFlight = List.unmodifiable(forwardInFlight),
      receiverOccupied = List.unmodifiable(receiverOccupied),
      returnsInFlight = List.unmodifiable(returnsInFlight),
      provisioned = List.unmodifiable(provisioned) {
  final lengths = {
    this.available.length,
    this.forwardInFlight.length,
    this.receiverOccupied.length,
    this.returnsInFlight.length,
    this.provisioned.length,
  };
  if (lengths.length != 1 || this.provisioned.isEmpty) {
    throw ArgumentError(
        'Every conservation term must contain one signal per pool.');
  }
  if (this.provisioned.any((capacity) => capacity < 0)) {
    throw ArgumentError('Provisioned capacities must not be negative.');
  }
}