addInput method Null safety

  1. @protected
Logic addInput(
  1. String name,
  2. Logic x,
  3. {int width = 1}
)

Registers a signal as an input to this Module and returns an input port that can be consumed.

The return value is the same as what is returned by input().

Implementation

@protected
Logic addInput(String name, Logic x, {int width = 1}) {
  _checkForSafePortName(name);
  if (x.width != width) {
    throw Exception('Port width mismatch, signal "$x" does not'
        ' have specified width "$width".');
  }
  _inputs[name] = Logic(name: name, width: width)..gets(x);

  // ignore: invalid_use_of_protected_member
  _inputs[name]!.parentModule = this;

  return _inputs[name]!;
}