addInput method

  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 PortWidthMismatchException(x, width);
  }

  if (x is LogicStructure) {
    // ignore: parameter_assignments
    x = x.packed;
  }

  final inPort = Logic(name: name, width: width, naming: Naming.reserved)
    ..gets(x)
    // ignore: invalid_use_of_protected_member
    ..parentModule = this;

  _inputs[name] = inPort;

  return inPort;
}