SumInterface constructor

SumInterface({
  1. dynamic fixedAmount,
  2. bool increments = true,
  3. int? width,
  4. bool hasEnable = false,
})

Creates a new SumInterface with a fixed or variable amount, optionally with an enable, in either positive or negative direction based on increments.

If width is null, it can be inferred from fixedAmount if provided with a type that contains width information (e.g. a LogicValue). There must be enough information provided to determine the width.

If a fixedAmount is provided, then amount will be tied to a Const. A provided fixedAmount must be parseable by LogicValue.of. Note that the fixedAmount will always be interpreted as a positive value truncated to width. If no fixedAmount is provided, then amount will be a normal port with width bits.

If hasEnable is true, then an enable port will be added to the interface.

Implementation

SumInterface(
    {this.fixedAmount,
    this.increments = true,
    int? width,
    this.hasEnable = false})
    : width = (width == null && fixedAmount == null)
          ? throw RohdHclException(
              'Must provide either a fixedAmount or width.')
          : width ?? LogicValue.ofInferWidth(fixedAmount).width {
  setPorts([
    if (fixedAmount == null) Port('amount', this.width),
    if (hasEnable) Port('enable'),
  ], [
    PairDirection.fromProvider
  ]);
}