execute method

  1. @override
void execute(
  1. Set<Logic>? drivenSignals,
  2. [void guard(
    1. Logic toGuard
    )?]
)
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 toGuard)? guard]) {
  if (guard != null) {
    guard(driver);
  }

  final currentValue = driverValue(driver);
  if (!currentValue.isValid) {
    // Use bitwise & to turn Z's into X's, but keep valid signals as-is.
    // It's too pessimistic to convert the whole bus to X.
    _receiverOutput.put(currentValue & currentValue);
  } else {
    _receiverOutput.put(currentValue);
  }

  if (drivenSignals != null &&
      (!drivenSignals.contains(receiver) || receiver.value.isValid)) {
    drivenSignals.add(receiver);
  }
}