Hamming Code
Hamming Code
By:
Semester – IV
1. Objective
• Abstract
• Keywords
2. Literature Survey
• Hamming code
• Limitations
3. Methodology
4. Schematic diagram
5. Algorithm
• Flow of code
• Flowcharts
7. Conclusion
8. Appendix
• Verilog code
• FPGA implementation
❖ Objective:
The objective of this report is to understand and implement a Hamming code encoder and
decoder module in Verilog. The report aims to explore the principles of error detection and
correction using Hamming codes, focusing on a specific implementation. Through this,
readers will learn how to encode a 4-bit data input into a 7-bit codeword with added parity
bits, and then decode the received 7-bit message to detect and potentially correct errors. This
includes algorithmic details of the encoder and the decoder. By the end of this report, readers
will gain a practical understanding of Hamming codes and their application in error detection
and correction.
❖ Abstract:
❖ Keywords:
Hamming Code, FPGA, Error Detection-Correction, Verilog, Encoder, Decoder, RTL, TTL,
Waveforms.
❖ Literature Survey:
❖ Limitations:
While Hamming codes offer efficient error detection and correction capabilities, they have
certain limitations. One significant drawback is their inability to correct multiple errors
within the same code word. Additionally, the redundancy introduced by Hamming codes
increases with the length of the data word, leading to higher overhead in terms of bandwidth
and storage. Moreover, existing implementations of Hamming codes may suffer from
complexity, especially in hardware designs, which can impact performance and scalability.
Therefore, there is a need for efficient and scalable implementations of Hamming codes to
address these limitations.
❖ Methodology:
The proposed solution involves designing a Hamming Code Encoder and Decoder using
Verilog. The methodology includes developing modules for encoding and decoding
processes, adhering to the principles of Hamming codes.
The Encoder module takes an input data word, adds parity bits according to the Hamming
code algorithm, and generates the encoded output. On the other hand, the Decoder module
receives the encoded data word, detects and corrects errors using the parity bits, and produces
the decoded output. The design focuses on optimizing resource utilization and ensuring
scalability for different data word lengths.
Hamming(7,4) is a linear error-correcting code that encodes four bits of data into seven bits
by adding three parity bits.
❖ Schematic diagrams:[3]
❖ Flow of code:
1. Encoding:
- The input data (4 bits) is used to calculate three parity bits (p1, p2, p3).
- The encoded_data is formed by concatenating the parity bits and the input data in a
specific order: {p1, p2, data_in[0], p3, data_in[1], data_in[2], data_in[3]}.
2. Decoding:
- The received encoded_data is used to calculate three syndrome bits (x[0], x[1], x[2]).
- The error_detected output is set based on whether any of the syndrome bits are non-zero.
start
end
❖ Hamming code decoding flow chart:
Calculate syndromes
If syndrome is
zero
❖ TTL:
❖ Waveform:
❖ Conclusion:
In conclusion, the design and implementation of a Hamming Code Encoder and Decoder
using Verilog offer an efficient and scalable solution for error detection and correction in
digital communication systems. Hamming codes find applications in fields such as
computing, telecommunication services, like satellite communication, modems, embedded
processors, etc. By leveraging the principles of Hamming codes and the capabilities of
Verilog, the proposed methodology addresses the limitations of existing technologies and
provides a reliable mechanism for data integrity.
1) Advantages:
• Easy encoding and decoding offer simplicity in error detection and correction.
2) Disadvantages:
• It is not suitable for correcting multiple error bits.
• The requirement of transmission bandwidth is high.
❖ References:
module hammingcode (
output error_detected
);
// Parity bits
// Encoder
// Decoder
wire [6:0] x;
wire error;
assign error = x;
endmodule
❖ FPGA implementation result: