adjustLdpcCheckMagnitude function
Applies normalized and offset min-sum magnitude adjustment.
Implementation
Logic adjustLdpcCheckMagnitude(
Logic minimum, {
required int normalizationNumerator,
required int normalizationShift,
required int offset,
required String name,
}) {
var normalized = minimum;
if (normalizationNumerator != 1 || normalizationShift != 0) {
final numeratorWidth = normalizationNumerator.bitLength > 0
? normalizationNumerator.bitLength
: 1;
final productWidth = minimum.width + numeratorWidth;
final product = minimum.zeroExtend(productWidth) *
Const(normalizationNumerator, width: productWidth);
normalized = (product >> normalizationShift).getRange(0, minimum.width);
}
if (offset == 0) {
return normalized.named(name);
}
return mux(
normalized.gt(Const(offset, width: minimum.width)),
normalized - Const(offset, width: minimum.width),
Const(0, width: minimum.width),
).named(name);
}