/SEC-with-Binary-Hamming-Codes

Single-error-correction of messages with binary Hamming Code in Quartus VHDL

Primary LanguageVHDL

SEC-with-Binary-Hamming-Codes

Single-error-correction of messages with binary Hamming Code in Quartus VHDL

Table of Contents

Objective

This is the first assignment of the Advanced Computer Architecture (ACA) course lectured by professor António Borges.

The objective of the project involves the implementation of the Hamming code for 1-bit error correction with the triplet [15, 11, 3], where:

  • n (number of bits of the encoded message) = 15
  • k (number of information bits) = 11
  • d (Hamming distance) = 3.

And in order to closely simulate and describe the hardware, the structural modeling style was adopted.

The module:

  • encoder is implemented with a sequential digital circuit, from the schematics given by the professor
  • decoder is implemented with a combinatorial digital circuit

What's included

Decoder/
    +-- and_2.vhd 	
    +-- decoder.vhd 	
    +-- decoder.vwf
    +-- xnor_2.vhd
    +-- xor_2.vhd
Encoder/
    +-- Flip_flop_bundle.vhd 	
    +-- and_2.vhd 	
    +-- and_4.vhd
    +-- control_unit.vhd 	
    +-- control_unit.vwf
    +-- counter_4bit.vhd 	
    +-- counter_4bits.vhd 	
    +-- encoder.vhd
    +-- encoder.vwf
    +-- flipFlopDSimul.vhd 	
    +-- mux2_1.vhd 	
    +-- mux4_1.vhd 	
    +-- nand_2.vhd 	
    +-- not_1.vhd 	
    +-- or_2.vhd 	
    +-- rom.vhd
    +-- rom.vwf 	
    +-- xnor_2.vhd
    +-- xor_2.vhd

Theoretical Approach

The values for the n and k variables are calculated based on the number of redundant bits r = 4 addressed by the problem:

  • length of the encoded message:

            f1

  • length of the message:

            f2

Encoder

The encoding process of a message is described by the formula:

            f3

where:

  • x is the encoded message
  • m is the message to be encoded
  • G is the k x n generator matrix

To get the generator matrix, the following formula was used:

            f4

where:

  • f5 is the k x k identity matrix

            id_matrix_Ik

  • matrix A is composed of all permutations, of the redundant bits, with 2 or more bits equal to '1' (each column represents one permutation). The permutation order must be the same across both the encoder and decoder:

            matrix_a

  • the transpose of matrix A can now be obtained:

            matrix_a_transpose

Concatenating both matrices results in the generator matrix used to produce the encoded message:

            g_matrix

The multiplication of the message by the last four columns of the G matrix resolves the 4 redundant bits. This operation is the same as using the four parity equations obtained from the A matrix:

            parity_check_matrix_get_bits

Decoder

The decoding process is described by the formula:

            decoder_eq

where:

  • y is the received message, possibly with transmission errors, and y_t is the transpose of y. This message is 15 bits long because it contains the four redundant bits.

  • matrix H is obtained by:

            matrix_h

Matrix H is therefore:

            matrix_h_values

The result of multiplying the H matrix by y_t allows for the detection of transmission errors:

  • if all four parity bits are '0', then the message has no errors

  • if one or more parity bits are '1', then the message has one or more errors

Implementation

Encoder block diagram

encoder_schem

Decoder block diagram

decoder_schem

Component simulation

Simulation of the main components of the project:

Encoder simulation

encoder_sim

Control Unit simulation

control_unit_sim

Decoder simulation

decoder_sim

Improvements

The decoder can be further improved by reducing the number of XOR operations required to calculate the parity bits.

Tools

The software Quartus Prime Lite Edition v18.1 was used to develop this project.

Testing

For testing purposes it's required the creation of new simulation files. This is because the version of Quartus used stores the absolute path of the components, used by the top level entity, in the .vwf files.

Creators

Diogo Guedes

Miguel Carvalho

  • to be filled