ReedSolomonReadyValidEncoder<Input extends Logic, Output extends Logic> constructor

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

Creates a framed ready/valid RS encoder.

Implementation

ReedSolomonReadyValidEncoder({
  required ReedSolomonCode code,
  required ReadyValidCodecInterface<Input> upstream,
  required ReadyValidCodecInterface<Output> downstream,
  super.name = 'reed_solomon_ready_valid_encoder',
}) : super(
        definitionName: schemaQualifiedDefinitionName(
          'ReedSolomonReadyValidEncoder_${code.configurationSignature}_',
          [upstream.data, downstream.data],
        ),
      ) {
  final width = code.field.degree;
  if (upstream.data.data.width != code.messageSymbols * width) {
    throw PortWidthMismatchException(
      upstream.data.data,
      code.messageSymbols * width,
    );
  }
  if (downstream.data.data.width != code.length * width) {
    throw PortWidthMismatchException(
      downstream.data.data,
      code.length * width,
    );
  }
  upstream.requireProviderComposableWith(downstream.contract,
      consumerName: name);
  this.upstream = addPairInterface(upstream, PairRole.consumer,
      uniquify: (original) => 'upstream_$original');
  this.downstream = addPairInterface(downstream, PairRole.provider,
      uniquify: (original) => 'downstream_$original');
  final encoder = ReedSolomonEncoder(
    this.upstream.data.data.packed,
    code: code,
  );
  this.upstream.ready <= this.downstream.ready;
  this.downstream.valid <= this.upstream.valid;
  connectPackedPayload(this.downstream.data.data, encoder.codeword);
  this.downstream.data.start <= this.upstream.data.start;
  this.downstream.data.last <= this.upstream.data.last;
}