Const constructor

Const(
  1. dynamic val, {
  2. int? width,
  3. bool fill = false,
})

Constructs a Const with the specified value.

val should be processable by LogicValue.of.

If a width is provided, the Const will be that width. If not, and val is a LogicValue, the Const will be the width of val. Otherwise, the Const will be 1 bit wide.

Implementation

Const(dynamic val, {int? width, bool fill = false})
    : super(
        name: 'const_$val',
        width: width ?? (val is LogicValue ? val.width : 1),
        // we don't care about maintaining this node unless necessary
        naming: Naming.unnamed,
      ) {
  _wire.put(val, fill: fill, signalName: name);

  makeUnassignable(reason: '`Const` signals are unassignable.');
}