execute method
override
Executes the functionality of this Conditional and
populates drivenSignals
with all Logics that were driven
during execution.
The drivenSignals
are used by the caller to determine if signals
were driven an appropriate number of times.
The guard
function should be called on drivers prior to any execution
which consumes the current value of those drivers. It is used to check
that signals are not "written after read", for example.
Implementation
@override
void execute(Set<Logic>? drivenSignals, [void Function(Logic)? guard]) {
if (guard != null) {
guard(expression);
for (final item in items) {
guard(item.value);
}
}
if (!expression.value.isValid) {
// if expression has X or Z, then propogate X's!
_driveX(drivenSignals);
return;
}
CaseItem? foundMatch;
for (final item in items) {
// match on the first matchinig item
if (isMatch(driverValue(item.value), driverValue(expression))) {
for (final conditional in item.then) {
conditional.execute(drivenSignals, guard);
}
if (foundMatch != null && conditionalType == ConditionalType.unique) {
_driveX(drivenSignals);
return;
}
foundMatch = item;
if (conditionalType != ConditionalType.unique) {
break;
}
}
}
// no items matched
if (foundMatch == null && defaultItem != null) {
for (final conditional in defaultItem!) {
conditional.execute(drivenSignals, guard);
}
} else if (foundMatch == null &&
(conditionalType == ConditionalType.unique ||
conditionalType == ConditionalType.priority)) {
_driveX(drivenSignals);
return;
}
}