run method
- 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));
var cycle = 0;
var previousWasStalled = false;
_SampledPayload<ValueType>? previousPayload;
LogicValue? previousReady;
LogicValue? previousValid;
var stalledCycles = 0;
while (!Simulator.simulationHasEnded) {
await clk.nextPosedge;
if (Simulator.simulationHasEnded) {
return;
}
final resetValue = reset.previousValue;
final readyValue = ready.previousValue;
final validValue = valid.previousValue;
if (resetValue == null || readyValue == null || validValue == null) {
cycle++;
continue;
}
final inReset = resetValue.isValid && resetValue.toBool();
final controlsKnown = readyValue.isValid && validValue.isValid;
final currentValid = controlsKnown && validValue.toBool();
final currentStalled = currentValid && !readyValue.toBool();
if (!inReset && configuration.controlsMustBeKnown && !controlsKnown) {
_report(
'rv.controls_known',
cycle,
'Ready and valid must be known after reset.',
{'ready': readyValue, 'valid': validValue});
}
if (inReset &&
configuration.transfersForbiddenDuringReset &&
controlsKnown &&
readyValue.toBool() &&
validValue.toBool()) {
_report(
'rv.no_transfer_during_reset',
cycle,
'A transfer completed while reset was asserted.',
{'ready': readyValue, 'valid': validValue});
}
if (!inReset &&
previousWasStalled &&
configuration.validMustRemainAssertedWhileStalled &&
!currentValid) {
_report('rv.valid_held_while_stalled', cycle,
'Valid was withdrawn before the offer was accepted.', {
'previousReady': previousReady,
'previousValid': previousValid,
'currentValid': validValue
});
}
_SampledPayload<ValueType>? currentPayload;
if (!inReset &&
configuration.payloadMustRemainStableWhileStalled &&
(previousWasStalled || currentStalled)) {
currentPayload = _SampledPayload(codec.sample(data, previous: true));
if (previousWasStalled &&
currentValid &&
previousPayload != null &&
!configuration.payloadEquals(
previousPayload.value, currentPayload.value)) {
_report('rv.payload_stable_while_stalled', cycle,
'Payload changed while the offer remained stalled.', {
'previousPayload': previousPayload.value,
'currentPayload': currentPayload.value
});
}
}
if (inReset || !currentStalled) {
stalledCycles = 0;
} else {
stalledCycles++;
final maximumStallCycles = configuration.maximumStallCycles;
if (maximumStallCycles != null &&
stalledCycles == maximumStallCycles + 1) {
_report('rv.max_stall_cycles', cycle,
'The ready/valid offer exceeded its stall bound.', {
'maximumCycles': maximumStallCycles,
'stalledCycles': stalledCycles
});
}
}
previousWasStalled = !inReset && currentStalled;
previousPayload = previousWasStalled ? currentPayload : null;
previousReady = readyValue;
previousValid = validValue;
cycle++;
}
}