ReedSolomonSyndromeCalculator constructor
- Logic received, {
- required ReedSolomonCode code,
- String name = 'reed_solomon_syndrome_calculator',
Creates a packed Reed--Solomon syndrome calculator.
Implementation
ReedSolomonSyndromeCalculator(
Logic received, {
required ReedSolomonCode code,
super.name = 'reed_solomon_syndrome_calculator',
}) : super(
definitionName: 'ReedSolomonSyndromeCalculator_N${code.length}_K'
'${code.messageSymbols}_R${code.firstRoot}',
) {
final symbolWidth = code.field.degree;
if (received.width != code.length * symbolWidth) {
throw PortWidthMismatchException(
received,
code.length * symbolWidth,
);
}
final localReceived = addInput(
'received',
received,
width: received.width,
);
final results = <Logic>[];
for (var syndrome = 0; syndrome < code.paritySymbols; syndrome++) {
final point = GfLogic.constant(
code.field.x.pow(
BigInt.from((code.firstRoot + syndrome) % code.fullLength),
),
);
var value = GfLogic.constant(code.field.zero);
for (var index = code.length - 1; index >= 0; index--) {
final symbol = GfLogic.of(
localReceived.slice(
(index + 1) * symbolWidth - 1,
index * symbolWidth,
),
field: code.field,
);
value = value * point + symbol;
}
results.add(value);
}
addOutput('syndromes', width: symbolWidth * code.paritySymbols) <=
results.rconcat();
}