CrcConfiguration constructor
Creates a custom CRC configuration.
Implementation
CrcConfiguration({
required this.polynomial,
BigInt? initialValue,
this.reflectInput = false,
this.reflectOutput = false,
BigInt? finalXor,
this.check,
this.residue,
}) : initialValue = initialValue ?? BigInt.zero,
finalXor = finalXor ?? BigInt.zero {
if (polynomial.degree <= 0 || !polynomial.coefficient(0)) {
throw RohdHclException(
'CRC polynomial must have positive degree and a non-zero constant.',
);
}
for (final (name, value) in [
('initialValue', this.initialValue),
('finalXor', this.finalXor),
('check', check),
('residue', residue),
]) {
if (value != null && (value.isNegative || value > mask)) {
throw RohdHclException(
'CRC $name $value does not fit in $width bits.',
);
}
}
}