LdpcEncoder constructor

LdpcEncoder(
  1. Logic message, {
  2. required LdpcCode code,
  3. String name = 'ldpc_encoder',
})

Creates a constant-matrix LDPC encoder.

Implementation

LdpcEncoder(
  Logic message, {
  required this.code,
  super.name = 'ldpc_encoder',
}) : super(
        definitionName: 'LdpcEncoder_N${code.length}_K${code.messageBits}_'
            '${code.configurationSignature}',
      ) {
  if (message.width != code.messageBits) {
    throw PortWidthMismatchException(message, code.messageBits);
  }
  final localMessage = addInput('message', message, width: code.messageBits);
  final encoded = BinaryLinearTransform(
    localMessage,
    matrix: code.generatorMatrix,
    name: '${name}_generator',
  );
  addOutput('codeword', width: code.length) <= encoded.result;
}