createModule method
override
Creates a Module instance as configured.
Implementation
@override
Module createModule() {
final code = BchCode(
field: BinaryExtensionField(
modulus: BinaryPolynomial(BigInt.from(polynomialKnob.value)),
),
designedDistance: designedDistanceKnob.value,
firstRoot: firstRootKnob.value,
shortening: shorteningKnob.value,
);
final encoding = {
BchArchitecture.encoder,
BchArchitecture.iterativeEncoder,
}.contains(architectureKnob.value);
final upstream = ReadyValidCodecInterface(
Logic(width: encoding ? code.messageBits : code.length),
);
final downstream = ReadyValidCodecInterface(
Logic(width: encoding ? code.length : code.messageBits),
);
final clk = Logic(name: 'clk');
final reset = Logic(name: 'reset');
switch (architectureKnob.value) {
case BchArchitecture.encoder:
return BchEncoder(
code: code, upstream: upstream, downstream: downstream);
case BchArchitecture.iterativeEncoder:
return BchIterativeEncoder(
clk: clk,
reset: reset,
code: code,
upstream: upstream,
downstream: downstream,
);
case BchArchitecture.singleErrorDecoder:
return BchSingleErrorDecoder(Logic(width: code.length), code: code);
case BchArchitecture.twoErrorDecoder:
return BchTwoErrorDecoder(Logic(width: code.length), code: code);
case BchArchitecture.generalDecoder:
return BchGeneralDecoder(
Logic(width: code.length),
code: code,
correctionCapacity: correctionCapacityKnob.value,
);
case BchArchitecture.readyValidDecoder:
return BchReadyValidDecoder(
code: code,
upstream: upstream,
downstream: downstream,
);
case BchArchitecture.pipelinedDecoder:
return BchPipelinedDecoder(
clk: clk,
reset: reset,
code: code,
upstream: upstream,
downstream: downstream,
pipelineDepth: pipelineDepthKnob.value,
);
case BchArchitecture.twoErrorPipelinedDecoder:
return BchTwoErrorPipelinedDecoder(
clk: clk,
reset: reset,
code: code,
upstream: upstream,
downstream: downstream,
pipelineDepth: pipelineDepthKnob.value,
);
case BchArchitecture.generalPipelinedDecoder:
return BchGeneralPipelinedDecoder(
clk: clk,
reset: reset,
code: code,
correctionCapacity: correctionCapacityKnob.value,
upstream: upstream,
downstream: downstream,
pipelineDepth: pipelineDepthKnob.value,
);
}
}