execute method

  1. @override
void execute(
  1. Set<Logic>? drivenSignals,
  2. [void guard(
    1. Logic
    )?]
)
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) {
    for (final iff in iffs) {
      guard(iff.condition);
    }
  }

  for (final iff in iffs) {
    if (driverValue(iff.condition) == LogicValue.one) {
      for (final conditional in iff.then) {
        conditional.execute(drivenSignals, guard);
      }
      break;
    } else if (driverValue(iff.condition) != LogicValue.zero) {
      // x and z propagation
      _driveX(drivenSignals);
      break;
    }
    // if it's 0, then continue searching down the path
  }
}