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;
while (!Simulator.simulationHasEnded) {
await clk.nextPosedge;
if (Simulator.simulationHasEnded) {
return;
}
final resetValue = reset.previousValue;
final occupancyValue = occupancy.previousValue;
final emptyValue = empty.previousValue;
final fullValue = full.previousValue;
if (resetValue == null ||
occupancyValue == null ||
emptyValue == null ||
fullValue == null) {
cycle++;
continue;
}
final inReset = resetValue.isValid && resetValue.toBool();
final statusesKnown =
occupancyValue.isValid && emptyValue.isValid && fullValue.isValid;
if (!inReset && !statusesKnown) {
_report('storage.status_known', cycle,
'Occupancy, empty, and full must be known after reset.', {
'occupancy': occupancyValue,
'empty': emptyValue,
'full': fullValue,
});
}
if (!inReset && statusesKnown) {
final retainedItems = occupancyValue.toInt();
if (retainedItems > capacity) {
_report('storage.occupancy_in_range', cycle,
'Occupancy exceeded the declared capacity.', {
'occupancy': retainedItems,
'capacity': capacity,
});
}
if (emptyValue.toBool() != (retainedItems == 0)) {
_report('storage.empty_matches_occupancy', cycle,
'Empty did not match zero retained occupancy.', {
'occupancy': retainedItems,
'empty': emptyValue,
});
}
if (fullValue.toBool() != (retainedItems == capacity)) {
_report('storage.full_matches_occupancy', cycle,
'Full did not match capacity retained occupancy.', {
'occupancy': retainedItems,
'capacity': capacity,
'full': fullValue,
});
}
}
cycle++;
}
}