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));
await sys.resetN.nextPosedge;
// on reset, clear all buffers
sys.resetN.negedge.listen((event) {
_dataBuffer.clear();
_poisonBuffer.clear();
});
// TODO(kimmeljo): handle credited!!
sys.clk.posedge.listen((event) {
if (r.valid.previousValue!.isValid &&
r.ready!.previousValue!.isValid &&
r.valid.previousValue!.toBool() &&
r.ready!.previousValue!.toBool()) {
_dataBuffer.add(r.data.value);
if (r.poison != null) {
_poisonBuffer.add(r.poison!.value);
}
// capture if the last beat in the transfer
final lastChk1 = r.last == null;
final lastChk2 = !lastChk1 &&
(r.last!.previousValue!.isValid && r.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,
poison:
i < _poisonBuffer.length ? _poisonBuffer[i].toInt() : null,
));
}
add(Axi5RChannelPacket(
data: dataPkts,
id: r.id != null
? Axi5IdSignalsStruct(
id: r.id?.previousValue!.toInt(),
idUnq: r.idUnq?.previousValue!.toBool())
: null,
tag: r.tag != null
? Axi5MemRespDataTagSignalsStruct(
tag: r.tag?.previousValue!.toInt(),
tagUpdate: r.tagUpdate?.previousValue!.toInt(),
tagMatch: r.tagMatch?.previousValue!.toInt(),
comp: r.comp?.previousValue!.toBool(),
persist: r.persist?.previousValue!.toBool(),
)
: null,
debug: Axi5DebugSignalsStruct(
trace: r.trace?.previousValue!.toBool(),
loop: r.loop?.previousValue!.toInt()),
response: r.resp != null || r.busy != null
? Axi5ResponseSignalsStruct(
resp: r.resp?.previousValue!.toInt(),
busy: r.busy?.previousValue!.toBool())
: null,
chunk: r.chunkEn != null
? Axi5ChunkSignalsStruct(
chunkEn: r.chunkEn?.previousValue!.toBool(),
chunkV: r.chunkV?.previousValue!.toBool(),
chunkNum: r.chunkNum?.previousValue!.toInt(),
chunkStrb: r.chunkStrb?.previousValue!.toInt(),
)
: null,
user: r.user != null
? Axi5UserSignalsStruct(user: r.user?.previousValue!.toInt())
: null,
));
_dataBuffer.clear();
_poisonBuffer.clear();
}
}
});
}