LdpcSyndromeCalculator constructor
Creates a combinational parity-check calculator.
Implementation
LdpcSyndromeCalculator(
Logic codeword, {
required this.code,
super.name = 'ldpc_syndrome_calculator',
}) : super(
definitionName:
'LdpcSyndromeCalculator_N${code.length}_M${code.parityBits}_'
'${code.parityCheckMatrix.configurationSignature}',
) {
if (codeword.width != code.length) {
throw PortWidthMismatchException(codeword, code.length);
}
final localCodeword = addInput('codeword', codeword, width: code.length);
final checked = BinaryLinearTransform(
localCodeword,
matrix: code.parityCheckMatrix,
name: '${name}_checks',
);
final count = Count(checked.result, name: '${name}_unsatisfied_count');
addOutput('syndrome', width: code.parityBits) <= checked.result;
addOutput('validCodeword') <= ~checked.result.or();
addOutput('unsatisfiedCheckCount', width: count.count.width) <= count.count;
}