checkAxi5EndpointCompatibility function

List<String> checkAxi5EndpointCompatibility({
  1. required Axi5SystemInterface managerSys,
  2. required Axi5SystemInterface subordinateSys,
  3. Axi5ReadCluster? managerRead,
  4. Axi5ReadCluster? subordinateRead,
  5. Axi5WriteCluster? managerWrite,
  6. Axi5WriteCluster? subordinateWrite,
  7. Axi5PinProfile profile = Axi5PinProfile.axi5,
})

Checks two ordinary AXI5 or AXI5-Lite endpoints for a direct connection.

Both endpoints must describe the same profile and have matching channel and pin presence and widths, including optional sidebands and credits. Each endpoint is also audited independently for legal directions and pin shapes. An empty result means the checked configurations match.

This does not inspect wiring, tie-offs, capacity declarations, timing, or adapters that translate between different pin layouts.

Implementation

List<String> checkAxi5EndpointCompatibility({
  required Axi5SystemInterface managerSys,
  required Axi5SystemInterface subordinateSys,
  Axi5ReadCluster? managerRead,
  Axi5ReadCluster? subordinateRead,
  Axi5WriteCluster? managerWrite,
  Axi5WriteCluster? subordinateWrite,
  Axi5PinProfile profile = Axi5PinProfile.axi5,
}) {
  final diagnostics = <String>[];
  for (final (role, sys, read, write) in [
    ('Manager', managerSys, managerRead, managerWrite),
    ('Subordinate', subordinateSys, subordinateRead, subordinateWrite),
  ]) {
    if (read == null && write == null) {
      diagnostics.add('$role has no read or write channels to check.');
      continue;
    }
    diagnostics.addAll(checkAxi5PinConfiguration(
            sys: sys, read: read, write: write, profile: profile)
        .map((issue) => '$role: $issue'));
  }

  void matchPins(PairInterface manager, PairInterface subordinate) {
    final mgr = manager.ports;
    final sub = subordinate.ports;
    for (final name in {...mgr.keys, ...sub.keys}) {
      final managerWidth = mgr[name]?.width;
      final subordinateWidth = sub[name]?.width;
      if (managerWidth != subordinateWidth) {
        diagnostics.add('$name differs across endpoints: '
            'manager ${managerWidth ?? 'absent'}, '
            'subordinate ${subordinateWidth ?? 'absent'} (width in bits).');
      }
    }
  }

  matchPins(managerSys, subordinateSys);
  if (managerRead == null || subordinateRead == null) {
    if (managerRead != subordinateRead) {
      diagnostics.add('Read channels must be present on both endpoints.');
    }
  } else {
    matchPins(managerRead.ar, subordinateRead.ar);
    matchPins(managerRead.r, subordinateRead.r);
  }
  if (managerWrite == null || subordinateWrite == null) {
    if (managerWrite != subordinateWrite) {
      diagnostics.add('Write channels must be present on both endpoints.');
    }
  } else {
    matchPins(managerWrite.aw, subordinateWrite.aw);
    matchPins(managerWrite.w, subordinateWrite.w);
    matchPins(managerWrite.b, subordinateWrite.b);
  }
  return List.unmodifiable(diagnostics);
}