checkAxi5PinConfiguration function
- required Axi5SystemInterface sys,
- Axi5ReadCluster? read,
- Axi5WriteCluster? write,
- Axi5PinProfile profile = Axi5PinProfile.axi5,
Checks the actual pins of an ordinary AXI5 or AXI5-Lite link.
Supply at least one of read and write. When both are supplied, they
must describe the same link. Checks cover widths, directions, companion
pins, and shared interface properties from public Arm IHI 0022L, sections
A2 through A6, A12, and B2. Pins outside this baseline are reported
separately from malformed pins. This does not inspect signal activity
or connections.
Returns immutable diagnostics; an empty list means the checked shape passed. No simulation, VF component, or change to the interface is needed.
Implementation
List<String> checkAxi5PinConfiguration({
required Axi5SystemInterface sys,
Axi5ReadCluster? read,
Axi5WriteCluster? write,
Axi5PinProfile profile = Axi5PinProfile.axi5,
}) {
final channels = <Axi5TransportInterface>[
if (read != null) ...[read.ar, read.r],
if (write != null) ...[write.aw, write.w, write.b],
];
if (channels.isEmpty) {
throw ArgumentError('Provide AXI5 read or write channels to check.');
}
final diagnostics = <String>[];
_PinAudit(sys, '', PairDirection.sharedInputs, PairDirection.sharedInputs,
diagnostics)
..width('ACLK', 1, mandatory: true)
..width('ARESETn', 1, mandatory: true)
..checkRemaining();
final lite = profile == Axi5PinProfile.axi5Lite;
final credited = channels.where((channel) => channel.useCrediting).length;
if (credited != 0 && credited != channels.length) {
diagnostics.add('AXI_Transport must match across the supplied channels.');
}
if (lite && credited != 0) {
diagnostics.add('AXI5-Lite does not support credited transport.');
}
for (final channel in channels) {
_checkChannel(channel, profile, diagnostics);
}
void match(String property, String field, Axi5TransportInterface first,
Axi5TransportInterface second) {
final firstName = '${first.prefix}$field';
final secondName = '${second.prefix}$field';
final firstWidth = first.tryPort(firstName)?.width ?? 0;
final secondWidth = second.tryPort(secondName)?.width ?? 0;
if (firstWidth != secondWidth) {
diagnostics.add('$property mismatch: $firstName width $firstWidth '
'differs from $secondName width $secondWidth (0 means absent).');
}
}
if (read != null) {
match('ID_R_WIDTH', 'ID', read.ar, read.r);
match('Unique_ID_Support', 'IDUNQ', read.ar, read.r);
match('LOOP_R_WIDTH', 'LOOP', read.ar, read.r);
}
if (write != null) {
match('ID_W_WIDTH', 'ID', write.aw, write.b);
match('Unique_ID_Support', 'IDUNQ', write.aw, write.b);
match('LOOP_W_WIDTH', 'LOOP', write.aw, write.b);
if (write.aw.useCrediting &&
write.w.useCrediting &&
write.aw.numRp != write.w.numRp) {
diagnostics.add('Num_RP_AWW mismatch: AW has ${write.aw.numRp} planes '
'and W has ${write.w.numRp} planes.');
}
}
if (read != null && write != null) {
match('ADDR_WIDTH', 'ADDR', read.ar, write.aw);
match('DATA_WIDTH', 'DATA', read.r, write.w);
match('Unique_ID_Support', 'IDUNQ', read.ar, write.aw);
match('Busy_Support', 'BUSY', read.r, write.b);
match('USER_REQ_WIDTH', 'USER', read.ar, write.aw);
for (final field in ['SIZE', 'PROT', ..._fullAddressWidths.keys]) {
match('Ax$field', field, read.ar, write.aw);
}
final wUser = write.w.tryPort('WUSER')?.width ?? 0;
final bUser = write.b.tryPort('BUSER')?.width ?? 0;
final rUser = read.r.tryPort('RUSER')?.width ?? 0;
if (rUser != wUser + bUser) {
diagnostics.add('RUSER width $rUser must equal WUSER width $wUser '
'plus BUSER width $bUser (0 means absent).');
}
}
final missingTrace = [
for (final channel in channels)
if (channel.tryPort('${channel.prefix}TRACE') == null)
'${channel.prefix}TRACE',
];
if (missingTrace.isNotEmpty && missingTrace.length != channels.length) {
diagnostics.add('Trace_Signals requires ${missingTrace.join(', ')}.');
}
return List.unmodifiable(diagnostics);
}