getCombinationalPaths method Null safety

  1. @protected
Map<Logic, List<Logic>> getCombinationalPaths()

Returns a mapping of purely combinational paths from each input port to all downstream output ports.

Each key of the returned Map is an input of this Module. Each value of the Map is a List of outputs of this Module which may change combinationally (no sequential logic in-between) as a result of the corresponding key input changing.

The default behavior of this function is to search through from all inputs to all potential outputs. If a Module implements custom behavior internally (e.g. a custom gate or a cosimulated module), then it makes sense to override this function to give an accurate picture. If the default behavior doesn't work (because no visible connectivity exists inside the Module), then the return value will end up with all empty Lists in the values of the Map.

The result of this function is intended to be stored at build time, and it should be called at build time. The result is primarily used for calculating valid and complete sensitivity lists for Combinational execution.


Map<Logic, List<Logic>> getCombinationalPaths() {
  final comboPaths = <Logic, List<Logic>>{};
  for (final inputPort in inputs.values) {
    final comboOutputs = <Logic>[];
    final searchList = TraverseableCollection<Logic>()..add(inputPort);
    for (var i = 0; i < searchList.length; i++) {
      for (final dstConnection in inputPort.dstConnections) {
        if (dstConnection.isInput && dstConnection.parentModule != this) {
          // this is an input port of a sub-module, jump over it
        } else if (isOutput(dstConnection)) {
          // this is an output port of this module, store it!
        } else {
          // this is a wire within this module, keep tracing
    comboPaths[inputPort] = comboOutputs;
  return comboPaths;