run method

  1. @override
Future<void> run(
  1. Phase phase
)
override

Executes this Component's activities related to running the test.

Overrides of run must call super.run in an unawaited fashion. For example:

@override
Future<void> run(Phase phase) async {
  unawaited(super.run(phase));
  // New code goes here!
}

Implementation

@override
Future<void> run(Phase phase) async {
  unawaited(super.run(phase));

  final creditChecker = _creditChecker;
  final startingCredits = creditChecker?.credits.toList() ?? <int>[];
  if (creditChecker != null) {
    // Capture the balance before VF updates it at the same rising edge.
    final snapshot = Simulator.preTick
        .listen((_) => startingCredits.setAll(0, creditChecker.credits));
    Simulator.registerEndOfSimulationAction(snapshot.cancel);
  }

  var cycle = 0;
  var wasInReset = false;
  LogicValue? previousPending;
  while (!Simulator.simulationHasEnded) {
    await sys.clk.nextPosedge;
    if (Simulator.simulationHasEnded) {
      return;
    }

    final resetN = sys.resetN.previousValue;
    final inReset = resetN == LogicValue.zero;
    final valid = channel.valid.previousValue;
    if (inReset || (wasInReset && resetN == LogicValue.one)) {
      if (valid != LogicValue.zero) {
        _report('axi5.valid_in_reset', cycle,
            'VALID must stay low through reset release ($valid).');
      }
      final returned = creditChecker?.creditReturn.previousValue;
      if (returned != null && returned.or() != LogicValue.zero) {
        _report(
            'axi5.credit_return_in_reset',
            cycle,
            'CRDT and CRDTSH must be low through the first edge out of reset '
                '(returned $returned).');
      }
    } else if (resetN != LogicValue.one) {
      _report('axi5.reset_known', cycle, 'ARESETn must be known ($resetN).');
    } else if (creditChecker != null) {
      if (valid == LogicValue.one) {
        if (previousPending != null && previousPending != LogicValue.one) {
          _report('axi5.pending_before_valid', cycle,
              'VALID requires PENDING one cycle earlier ($previousPending).');
        }
        final plane = channel.rp?.previousValue;
        if (channel.rp != null &&
            (plane == null ||
                !plane.isValid ||
                plane.toInt() >= channel.numRp)) {
          _report('axi5.resource_plane', cycle,
              'Invalid RP $plane for ${channel.numRp} configured planes.');
        }
        _checkConcurrentReturn(creditChecker, startingCredits, cycle);
      } else if (valid != LogicValue.zero) {
        _report('axi5.valid_known', cycle, 'VALID must be known ($valid).');
      }
    }
    wasInReset = inReset;
    previousPending = channel.pending?.previousValue;
    cycle++;
  }
}