LtiComplianceChecker constructor

LtiComplianceChecker({
  1. required Axi5SystemInterface sys,
  2. required LtiCluster link,
  3. required Component? parent,
  4. bool reportViolations = true,
  5. String name = 'ltiComplianceChecker',
})

Checks a link with matching LA/LR VC counts and LR/LC/LT tag widths.

Implementation

LtiComplianceChecker({
  required this.sys,
  required this.link,
  required Component? parent,
  this.reportViolations = true,
  String name = 'ltiComplianceChecker',
}) : super(name, parent) {
  final vcs = link.la.vcCount;
  if (vcs < 1 || vcs > 8 || vcs != link.lr.vcCount) {
    throw ArgumentError('LTI LA and LR must use the same 1-8 VCs.');
  }
  final idWidth = link.la.id?.width ?? 0;
  if (idWidth > 32 || idWidth != (link.lr.id?.width ?? 0)) {
    throw ArgumentError('LTI LA and LR must have equal ID widths (0-32).');
  }
  final tagWidth = link.lr.ctag.width;
  if (tagWidth < 1 ||
      tagWidth > 16 ||
      link.lc.ctag.width != tagWidth ||
      (link.lt?.ctag.width ?? tagWidth) != tagWidth) {
    throw ArgumentError('LTI LR, LC, and any LT need equal 1-16-bit tags.');
  }

  // ACK is low both in CLOSED and while opening, before any valid grants.
  final reset = ~(sys.resetN & link.lm.openAck);
  for (final channel in <LtiTransportInterface>[
    link.la,
    link.lr,
    link.lc,
    if (link.lt case final lt?) lt,
  ]) {
    final flow = channel.creditFlow!;
    final checker = CreditChannelChecker(
      '${channel.prefix}Credits',
      this,
      clk: sys.clk,
      reset: reset,
      debit: flow.debit,
      creditReturn: flow.creditReturn,
      configuration: CreditChannelCheckConfiguration.uniform(
        poolCount: flow.poolCount,
        initialCredits: 0,
        maximumCredits: LtiTransportInterface.maxCreditsPerVc,
      ),
      endpoint: channel.prefix,
      reportViolations: false,
    );
    checker.violationStream.listen((violation) => _record('$violation'));
    _creditChecks.add((
      channel: channel,
      checker: checker,
      startingCredits: List.filled(flow.poolCount, 0),
    ));
  }
}