BchEncoder<Input extends Logic, Output extends Logic> constructor

BchEncoder<Input extends Logic, Output extends Logic>({
  1. required BchCode code,
  2. required ReadyValidCodecInterface<Input> upstream,
  3. required ReadyValidCodecInterface<Output> downstream,
  4. String name = 'bch_encoder',
})

Creates a BCH encoder from code.

Implementation

BchEncoder({
  required BchCode code,
  required ReadyValidCodecInterface<Input> upstream,
  required ReadyValidCodecInterface<Output> downstream,
  String name = 'bch_encoder',
}) : super(
        name: name,
        definitionName: schemaQualifiedDefinitionName(
          'BchEncoder_${code.configurationSignature}_',
          [upstream.data, downstream.data],
        ),
      ) {
  if (upstream.data.data.width != code.messageBits) {
    throw PortWidthMismatchException(
      upstream.data.data,
      code.messageBits,
    );
  }
  if (downstream.data.data.width != code.length) {
    throw PortWidthMismatchException(
      downstream.data.data,
      code.length,
    );
  }

  final input = addPairInterface(upstream, PairRole.consumer,
      uniquify: (original) => 'upstream_$original');
  final output = addPairInterface(downstream, PairRole.provider,
      uniquify: (original) => 'downstream_$original');
  ReadyValidMetadataAdapter<CodecFrame<Input>, CodecFrame<Output>>(
    upstream: input,
    downstream: output,
    transform: (frame) => _encodeFrame(frame, code, output.data),
    transformName: 'bch_${code.configurationSignature}',
    name: name,
  );
}