BchReadyValidDecoder<Input extends Logic, Output extends Logic> constructor
- required BchCode code,
- required ReadyValidCodecInterface<
Input> upstream, - required ReadyValidCodecInterface<
Output> downstream, - String name = 'bch_ready_valid_decoder',
Creates a framed ready/valid BCH single-error decoder.
Implementation
BchReadyValidDecoder({
required BchCode code,
required ReadyValidCodecInterface<Input> upstream,
required ReadyValidCodecInterface<Output> downstream,
super.name = 'bch_ready_valid_decoder',
}) : super(
definitionName: schemaQualifiedDefinitionName(
'BchReadyValidDecoder_${code.configurationSignature}_',
[upstream.data, downstream.data],
),
) {
if (upstream.data.data.width != code.length) {
throw PortWidthMismatchException(upstream.data.data, code.length);
}
if (downstream.data.data.width != code.messageBits) {
throw PortWidthMismatchException(
downstream.data.data,
code.messageBits,
);
}
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 decoder =
BchSingleErrorDecoder(this.upstream.data.data.packed, code: code);
final decodedMessage = decoder.message;
this.upstream.ready <= this.downstream.ready;
this.downstream.valid <= this.upstream.valid;
connectPackedPayload(this.downstream.data.data, decodedMessage);
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.corrected;
status.uncorrectable <= decoder.uncorrectable;
status.frameDone <= this.downstream.data.last;
status.iterationCount <= Const(0, width: status.iterationCount.width);
}