waitCycles method
Returns a Future which completes after the specified numCycles
,
where each cycle is defined as the next occurence of the specified edge
.
width must be 1 or an Exception will be thrown.
Like nextNegedge and nextPosedge, this will only detect valid edge
transitions. If the value is invalid (x
or z
) before or after the
transition, it will not count as a cycle.
Implementation
Future<void> waitCycles(int numCycles, {Edge edge = Edge.pos}) async {
if (width != 1) {
throw Exception('Must be a 1-bit signal, but was $width bits.');
}
for (var i = 0; i < numCycles; i++) {
switch (edge) {
case Edge.pos:
await nextPosedge;
break;
case Edge.neg:
await nextNegedge;
break;
case Edge.any:
await Future.any([
nextPosedge,
nextNegedge,
]);
break;
}
}
}