Hamming Coder

The purpose of Hamming codes is to detect and correct errors that may occur during digital data transmission. Hamming codes are a type of linear error-correcting code that adds redundant bits to the data message to create a codeword with a specific structure that can detect and correct errors

Hamming coder

This coder can process multiple batches and codewords simultaneous shown in following three examples:

The details about the input-output interface of the Reed Muller modules is provided below.

class toolkit5G.ChannelCoder.HammingCoder.hammingEncoder.HammingEncoder(k, n)[source]

Takes in an array of message Bits and returns a systematic Hamming codeword

Parameters:
  • k (int) – It defines the size of the message that is to Hamming encoded

  • n (int) – It defines the number of parity Bits

Input:

inputBits (np.ndarray) – Array of size k containing message Bits that are to be Hamming Encoded

Output:

Hamming Codeword (np.ndarray) – It is of size k+n

Raises:
  • [Error-HammingEncoder] – ‘k’ should satisfy ‘2**m-m-1’ condition!:

  • [Error-HammingEncoder] – ‘n’ should satisfy ‘2**m-1’ condition!:

  • [Error-HammingEncoder] – ‘inputBits’ should be an array of integer!:

  • [Error-HammingEncoder] – ‘inputBits’ should be of shape […,k]!:

  • [Error-VectorToBinaryArray] – ‘k’ should be a scalar integer:

  • [Error-VectorToBinaryArray] – ‘n’ should be a scalar integer:

Hamming Decoder

Note that, the hardOutput must be set to False if the input codeword contains the log likelihood ratio (LLR) values of each bit and True for returning estimated bits.

class toolkit5G.ChannelCoder.HammingCoder.hammingDecoder.HammingDecoder(k, n)[source]

Takes in a Hamming codeword and returns either decoded bots or LLR based on user requirement

Parameters:
  • k (int) – It defines the size of the message that is to be Hamming encoded

  • n (int) – It defines the number of parity Bits

Input:
  • inputs (np.ndarray) – Array of size k + n containing codeword Bits that are to be decoded

  • decoderType (str) – It defines the type of decoding the codeword undergoes It can either be syndrome or sphere based

  • hardOutput (bool) – It determines whether decoded bits are to be returned or log likelihood ratio of each bit is to be returned

Output:
  • if hardOutput is True Decoded Bits are returned

  • if hardOutput is False log likelihood ratio of each bit is returned

  • in either cases the output is of size k

Raises:
  • [Error-HammingEncoder] – ‘k’ should satisfy ‘2**m-m-1’ condition!:

  • [Error-HammingEncoder] – ‘n’ should satisfy ‘2**m-1’ condition!:

  • [Error-HammingEncoder] – ‘inputBits’ should be an array of integer!:

  • [Error-HammingEncoder] – ‘inputBits’ should be of shape […,k]!:

  • [Error-VectorToBinaryArray] – ‘k’ should be a scalar integer:

  • [Error-VectorToBinaryArray] – ‘n’ should be a scalar integer:

Hamming Decoder - Sphere Decoding

class toolkit5G.ChannelCoder.HammingCoder.hammingDecoder.HammingSphereDecoder(k, n)[source]

Performs sphere Decoding: Hamming sphere decoding is an algorithm used to decode linear block codes by searching for the transmitted codeword that is closest to the received signal within a sphere of a certain radius, based on the minimum distance between codewords.

Parameters:
  • k (int) – It defines the size of the message that is to be hamming encoded

  • n (int) – It defines the number of parity Bits

Input:
  • inputs (np.ndarray) – Array of size k + n containing codeword Bits that are to be decoded

  • hardOutput (bool) – It determines whether decoded bits are to be returned (hard decoding) or log likelihood ratio of each bit is to be returned (soft decoding)

Output:
  • if hardOutput is True Decoded Bits are returned

  • if hardOutput is False log likelihood ratio of each bit is returned

  • in either cases the output is of size k

Hamming Decoder - Syndrome Based Decoding

class toolkit5G.ChannelCoder.HammingCoder.hammingDecoder.HammingSyndromeDecoder(k, n)[source]

Performs syndrome based Decoding: Hamming syndrome based decoding is a decoding technique used to correct errors in linear block codes by calculating the syndrome, which is a vector that represents the parity check equations of the code, and using it to identify the error pattern in the received codeword.

Parameters:
  • k (int) – It defines the size of the message that is to be hamming encoded

  • n (int) – It defines the number of parity Bits

Input:

inputs (np.ndarray) – Array of size k + n containing codeword Bits that are to be decoded

Output:

Array of size k containing Decoded Bits are returned