createModule method

  1. @override
Module createModule()
override

Creates a Module instance as configured.

Implementation

@override
Module createModule() {
  final code = ReedSolomonCode(
    field: BinaryExtensionField(
      modulus: BinaryPolynomial(BigInt.from(polynomialKnob.value)),
    ),
    length: lengthKnob.value,
    messageSymbols: messageSymbolsKnob.value,
    firstRoot: firstRootKnob.value,
    shortening: shorteningKnob.value,
  );
  final messageWidth = code.messageSymbols * code.field.degree;
  final codewordWidth = code.length * code.field.degree;
  final upstream = ReadyValidCodecInterface(
    Logic(width: _encoding ? messageWidth : codewordWidth),
  );
  final downstream = ReadyValidCodecInterface(
    Logic(width: _encoding ? codewordWidth : messageWidth),
  );
  switch (architectureKnob.value) {
    case ReedSolomonArchitecture.encoder:
      return ReedSolomonEncoder(Logic(width: messageWidth), code: code);
    case ReedSolomonArchitecture.readyValidEncoder:
      return ReedSolomonReadyValidEncoder(
        code: code,
        upstream: upstream,
        downstream: downstream,
      );
    case ReedSolomonArchitecture.decoder:
      return ReedSolomonDecoder(
        Logic(width: codewordWidth),
        code: code,
        correctionCapacity: correctionCapacityKnob.value,
      );
    case ReedSolomonArchitecture.readyValidDecoder:
      return ReedSolomonReadyValidDecoder(
        code: code,
        correctionCapacity: correctionCapacityKnob.value,
        upstream: upstream,
        downstream: downstream,
      );
    case ReedSolomonArchitecture.erasureDecoder:
      return ReedSolomonErasureDecoder(
        Logic(width: codewordWidth),
        Logic(width: code.length),
        code: code,
        erasureCount: erasureCountKnob.value,
        unknownErrorCapacity: correctionCapacityKnob.value,
      );
    case ReedSolomonArchitecture.erasureReadyValidDecoder:
      return ReedSolomonErasureReadyValidDecoder(
        code: code,
        erasureCount: erasureCountKnob.value,
        unknownErrorCapacity: correctionCapacityKnob.value,
        upstream: upstream,
        downstream: downstream,
        erasureMask: Logic(width: code.length),
      );
  }
}