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));
// on reset, clear all buffers
sys.resetN.negedge.listen((event) {
_dataBuffer.clear();
_strbBuffer.clear();
_poisonBuffer.clear();
});
await sys.resetN.nextPosedge;
// TODO(kimmeljo): handle credited!!
sys.clk.posedge.listen((event) {
if (w.valid.previousValue!.isValid &&
w.ready!.previousValue!.isValid &&
w.valid.previousValue!.toBool() &&
w.ready!.previousValue!.toBool()) {
_dataBuffer.add(w.data.value);
if (w.strb != null) {
_strbBuffer.add(w.strb!.value);
}
if (w.poison != null) {
_poisonBuffer.add(w.poison!.value);
}
// capture if the last beat in the transfer
final lastChk1 = w.last == null;
final lastChk2 = !lastChk1 &&
(w.last!.previousValue!.isValid && w.last!.previousValue!.toBool());
if (lastChk1 || lastChk2) {
final dataPkts = <Axi5DataSignalsStruct>[];
for (var i = 0; i < _dataBuffer.length; i++) {
dataPkts.add(Axi5DataSignalsStruct(
data: _dataBuffer[i].toBigInt(),
last: i == _dataBuffer.length - 1,
strb: i < _strbBuffer.length ? _strbBuffer[i].toInt() : null,
poison:
i < _poisonBuffer.length ? _poisonBuffer[i].toInt() : null,
));
}
add(Axi5WChannelPacket(
data: dataPkts,
tag: w.tag != null
? Axi5MemRespDataTagSignalsStruct(
tag: w.tag?.previousValue!.toInt(),
tagUpdate: w.tagUpdate?.previousValue!.toInt(),
tagMatch: w.tagMatch?.previousValue!.toInt(),
comp: w.comp?.previousValue!.toBool(),
persist: w.persist?.previousValue!.toBool(),
)
: null,
debug: Axi5DebugSignalsStruct(
trace: w.trace?.previousValue!.toBool(),
loop: w.loop?.previousValue!.toInt()),
user: w.user != null
? Axi5UserSignalsStruct(user: w.user?.previousValue!.toInt())
: null,
));
_dataBuffer.clear();
_strbBuffer.clear();
_poisonBuffer.clear();
}
}
});
}