SummationBase constructor
- List<
SumInterface> interfaces, { - dynamic initialValue = 0,
- dynamic maxValue,
- dynamic minValue = 0,
- bool saturates = false,
- bool generateOverflowedOutput = true,
- bool generateUnderflowedOutput = true,
- int? width,
- String name = 'unnamed_module',
- bool reserveName = false,
- bool reserveDefinitionName = false,
- String? definitionName,
Sums the values across the provided interfaces within the bounds of the
saturates behavior, initialValue, maxValue, and minValue, with the
specified width, if provided.
Implementation
SummationBase(List<SumInterface> interfaces,
{dynamic initialValue = 0,
dynamic maxValue,
dynamic minValue = 0,
this.saturates = false,
bool generateOverflowedOutput = true,
bool generateUnderflowedOutput = true,
int? width,
super.name,
super.reserveName,
super.reserveDefinitionName,
String? definitionName})
: width =
_inferWidth([initialValue, maxValue, minValue], width, interfaces),
super(
definitionName: definitionName ??
'SummationBase_L${interfaces.length}_W$width') {
if (interfaces.isEmpty) {
throw RohdHclException('At least one interface must be provided.');
}
this.interfaces = interfaces
.mapIndexed((i, e) => addPairInterfacePorts(e, PairRole.consumer,
uniquify: (original) => '${original}_$i'))
.toList();
initialValue ??= 0;
maxValue ??= biggestVal(this.width);
minValue ??= 0;
final configuredMaxValue = configuredValue(maxValue);
final configuredMinValue = configuredValue(minValue);
if (configuredMaxValue is! Logic) {
constantMaxValue = LogicValue.ofInferWidth(configuredMaxValue).toBigInt();
} else {
constantMaxValue = null;
}
if (configuredMinValue is! Logic) {
constantMinValue = LogicValue.ofInferWidth(configuredMinValue).toBigInt();
} else {
constantMinValue = null;
}
if (constantMaxValue != null &&
constantMinValue != null &&
constantMaxValue! < constantMinValue!) {
throw RohdHclException(
'Max value must be greater or equal to min value.');
}
initialValueLogic = _dynamicInputToLogic('initialValue', initialValue);
minValueLogic = _dynamicInputToLogic('minValue', minValue);
maxValueLogic = _dynamicInputToLogic('maxValue', maxValue);
if (generateOverflowedOutput) {
addOutput('overflowed');
}
if (generateUnderflowedOutput) {
addOutput('underflowed');
}
addOutput('equalsMax');
addOutput('equalsMin');
}