ReedSolomonErasureReadyValidDecoder<Input extends Logic, Output extends Logic> constructor
- required ReedSolomonCode code,
- required int erasureCount,
- required int unknownErrorCapacity,
- required ReadyValidCodecInterface<
Input> upstream, - required ReadyValidCodecInterface<
Output> downstream, - required Logic erasureMask,
- String name = 'reed_solomon_erasure_ready_valid_decoder',
Creates a framed ready/valid erasure-aware RS decoder.
Implementation
ReedSolomonErasureReadyValidDecoder({
required ReedSolomonCode code,
required int erasureCount,
required int unknownErrorCapacity,
required ReadyValidCodecInterface<Input> upstream,
required ReadyValidCodecInterface<Output> downstream,
required Logic erasureMask,
super.name = 'reed_solomon_erasure_ready_valid_decoder',
}) : super(
definitionName: schemaQualifiedDefinitionName(
'ReedSolomonErasureReadyValidDecoder_'
'${code.configurationSignature}_E${erasureCount}_'
'T${unknownErrorCapacity}_',
[upstream.data, downstream.data],
),
) {
final width = code.field.degree;
if (upstream.data.data.width != code.length * width) {
throw PortWidthMismatchException(
upstream.data.data,
code.length * width,
);
}
if (downstream.data.data.width != code.messageSymbols * width) {
throw PortWidthMismatchException(
downstream.data.data,
code.messageSymbols * width,
);
}
if (erasureMask.width != code.length) {
throw PortWidthMismatchException(erasureMask, code.length);
}
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 localMask = addInput('erasureMask', erasureMask, width: code.length);
final decoder = ReedSolomonErasureDecoder(
this.upstream.data.data.packed,
localMask,
code: code,
erasureCount: erasureCount,
unknownErrorCapacity: unknownErrorCapacity,
);
this.upstream.ready <= this.downstream.ready;
this.downstream.valid <= this.upstream.valid;
connectPackedPayload(this.downstream.data.data, decoder.message);
this.downstream.data.start <= this.upstream.data.start;
this.downstream.data.last <= this.upstream.data.last;
status = addTypedOutput(
'status',
CodecDecodeStatus(iterationWidth: code.length.bitLength).clone,
);
status.errorDetected <= decoder.errorDetected;
status.corrected <= decoder.errorDetected & decoder.correctedValid;
status.uncorrectable <= decoder.uncorrectable;
status.frameDone <= this.downstream.data.last;
status.iterationCount <= Const(0, width: status.iterationCount.width);
}