You are on page 1of 5

ICACT CONFERENCE PROCEEDINGS 2019

IMPLEMENTATION OF HAMMING CODE USING VERILOG

CH JAYAPRAKASH*1 V SURENDRA BABU*2, M VAMSIKRISHNA ALLU*3, CH TEJESWARA RAO *4, CH K D S VENU


GOPAL SWAMY *5
jp.chennoju@gmail.com vsb.mtech14@gmail.com *², allu.vamseekrishna@gmail.com*3, teja.chandranki@gmail.com*4
*1

kumarchanapathi123@gmail.com*5
Assistant Professor, SIR C R REDDY COLLEGE OF ENGG

Abstract--– In digital communication while ERROR DETECTION AND CORRECTION :


transmitting the data from source to destination some
corruption in data occurs due to some environmental The phenomenon of detecting the position of error
conditions, which is nothing but the transmitted data from the received data is known as error detection.
is included with some errors. Error coding is the The process of correcting the bit value at that error
method to detect and correct these errors so that the position is nothing but error correction. There are
information is transferred without any errors from various error detecting and correcting methods such
source to destination. There are many error as cyclic redundancy check (CRC), Parity check,
detecting and correcting codes, one of such is Vertical redundancy check (VRC), Longitudinal
Hamming code. Hamming code is single bit error redundancy check (LRC) and Hamming code. This
detecting and correcting method. In this paper we are work mainly focuses on Hamming code.
going to discuss about the implementation of
HAMMING CODE
Hamming code in verilog module which is improved
version of previous existing technique. Both the Hamming code is a linear block code. Hamming code
techniques are implemented with the help of can detect up to 2 bit errors and correct can correct a
redundancy bits (does not carry information). The single bit error. Hamming code includes encoding,
advantage of improved technique over the previous error detection and correction and decoding.
technique is there is decrease in the usage of bits Encoding provides the encryption of data by adding
while calculating the values redundancy bits. redundancy bits to the data. The number of
redundancy bits required are calculated using the
Keywords – Hamming code, Encoder, Decoder, Error
formula
detector and corrector, Verilog HDL, Xilinx
2^r >= d + r + 1 …………. (1).
INTRODUCTION
Where r = number of redundancy bits.
In digital communication systems, environmental d = number of data bits.
effects and other defects can cause random bit errors
during data transmission. Digital data is transmitted The smallest value of ‘r’ that satisfies the above
over a channel and there should be a noise present in relation is considered as the number of required
the channel. The noise may distort the data that is redundancy bits. Encoded data of length d + r bits is
transmitting. Therefore, the data received by the transmitted. In the receiving side, the presence and
receiver is not same as the data that is transmitted by location of single bit error is determined by
the transmitter, so error detection and correction calculating the parities of combinations of received
plays an important role so that the information is data to produce a table of parities each of which
transferred without any errors. corresponds to a particular bit error combination.
Now the value present in this error position is
ERROR : The encoded data is usually transmitted complimented so that the error is removed. Now this
over a channel is not completely error free. Due to the error free encoded data is decoded to get the original
external interference, signal distortion, attenuation information data. Hamming codes are easy to
and noise in channel the manipulation of data occurs. implement and are used in telecommunication, and
The manipulated data is called as error. There are two other applications including data compression. They
types of errors. are also used for low cost and low power
applications.
1. Single bit error
2. Burst error (more than one error in data). PREVIOUS METHOD

ENCODING OF HAMMING CODE :


ICACT CONFERENCE PROCEEDINGS 2019

Here the information data of length d bits that is to be comparing with above obtained encoded data. Now
transmitted is encoded with the addition of the values of c3, c2, c1 and c0 are calculated as
redundancy bits (r) required to correct d data bits. So follows:
a total of d + r bits are transmitted. Here r value is
determined by using the formula 2^r >= d + r + 1. Since the number of 1’s at positions 1, 3, 5, 7, 9, 11 is
Here each r bit is extra bit that does not carry 3. It does not satisfies the even parity condition, so
information. These redundancy bits are added at 2^r the required value of c0 is ‘1’. Since the number of
positions that is 1, 2, 4 and 8 so on. For example, let 1’s at positions 2, 3, 6, 7, 10, 11 is 5. It does not
us take a 7 bit data to be transmitted, so that the value satisfies the even parity condition, so the required
of r that satisfies the above condition (1) is 4. So total value of c1 is ‘1’. Since the number of 1’s at
7+4=11 bits are to be transmitted. Let us take the 4 positions 4, 5, 6, 7 is 1. It does not satisfies the even
redundancy bits are r1, r2, r3 and r4. Each r bit is parity condition, so the required value of c2 is ‘1’.
parity bit for one combination of data bits as shown Since the number of 1’s at positions 8, 9, 10, 11 is 2.
below: It satisfies the even parity condition, so the required
value of c3 is ‘0’. Now the error position is identified
r1 - 1, 3, 5, 7, 9, 11 ……….. (a) with help of c3 c2 c1 c0 as shown below:
r2 - 2, 3, 6, 7, 9, 10, 11 ………. (b)
r3 – 4, 5, 6, 7 ……….. (c) Error
r4 – 8, 9, 10, 11 ……….. (d) position C3 C2 C1 C0

7 0 1 1 1
Now the value at this position 7 is to be
11 10 9 8 7 6 5 4 3 2 1 complimented so that the error can be corrected. So
that we can get the original encoded data. Now this
data is to be decoded to get the original information
d7 d6 d5 r4 d4 d3 d2 r3 d1 r2 r1 data without any errors.
Position of redundancy bits in hamming code
PRESENT TECHNIQUE
Here the d1 to d7 are data bits to be transmitted and
r1 to r4 are redundancy bits. Let the data be 1100110. This process is also similar to previous technique at
Now the values of r1, r2, r3 and r4 are calculated the same steps including encoding, error detection
based on the even parity condition for those positions and correction, decoding. But the only difference is in
given in (a), (b), (c) and (d) respectively. the previous technique redundancy bit positions are
taken at 2^r positions, where as in this proposed
Since the number of 1’s at positions 3, 5, 7, 9, 11 is 2. improved method the redundancy bit positions are
It satisfies the even parity condition, so the required taken at the end of the data. In the previous technique
value of r1 is ‘0’. Since the number of 1’s at positions a total of 20 bits are involved in the process of
3, 6, 7, 10, 11 is 3. It does not satisfies the even parity calculation of redundancy bits, where as in this
condition, so the required value of r2 is ‘1’. Since the proposed improved method a total of 19 bits are
number of 1’s at positions 5, 6, 7 is 2. It satisfies the involved in the process of calculations of redundancy
even parity condition, so the required value of r3 is bits. This is the advantage of this proposed method
‘0’. Since the number of 1’s at positions 9, 10, 11 is over the previous method where there is a reduction
2. It satisfies the even parity condition, so the in the usage of 1 bit.
required value of r4 is ‘0’. So the encoded data
obtained is “11000110010”. ENCODING :

ERROR DETECTION, CORRECTION AND Similar to previous technique here the data bits(d) are
DECODING : encoded with redundancy bits(r) that are to be
transmitted. Here the value of r is obtained by using
If there is any error in received data here we need to the formula
detect and correct. Here the error position is
indentified with the help of c3 c2 c1 c0 whose values 2^r >= d+r+1 ….. (1)
obtained after checking the even parity condition by
considering the parity of the bit positions as given in Where r = number of redundancy bits
(a), (b), (c) and (d). Now let the received data is
“11001110010”, which has error at position 7 by d = number of data bits
ICACT CONFERENCE PROCEEDINGS 2019

Let us consider the same example, The 7-bit data to If there is any error in received data here we need to
be transmitted is “0110010”. For this the smallest detect and correct. Here the error position is
value of r that satisfies the above condition (1) is 4. indentified with the help of c3 c2 c1 c0 whose values
So a total of 11-bit encoded data is transmitted. Here obtained after checking the even parity condition by
let us consider r1, r2, r3 and r4 as 4 redundancy bits. considering the parity of the bit positions as given in
Each r bit is parity bit for one combination of data (a), (b), (c) and (d). Now let the received data is
bits as shown below: “10010100010”, which has error at position 5 by
comparing with above obtained encoded data. Now
r1 - 1, 3, 5, 7 ……….. (a) the values of c3, c2, c1 and c0 are calculated as
r2 - 2, 3, 6, 7 .………. (b) follows:
r3 – 4, 5, 6, 7 ….……. (c) Since the number of 1’s at positions 1, 3, 5, 7, 8 is 1.
r4 – r1, r2, r3 ……….. (d) It does not satisfies the even parity condition, so the
required value of c0 is ‘1’. Since the number of 1’s at
positions 2, 3, 6, 7, 9 is 2. It satisfies the even parity
condition, so the required value of c1 is ‘0’. Since the
11 10 9 8 7 6 5 4 3 2 1 number of 1’s at positions 4, 5, 6, 7, 10 is 1. It does
not satisfies the even parity condition, so the required
value of c2 is ‘1’. Since the number of 1’s at
r4 r3 r2 r1 d7 d6 d5 d4 d3 d2 d1 positions 8, 9, 10, 11 is 2. It satisfies the even parity
Position of redundancy bits in hamming code condition, so the required value of c3 is ‘0’. Now the
error position is identified with help of c3 c2 c1 c0 as
Here in this table the d1 to d7 are data bits to be shown below:
transmitted and r1 to r4 are redundancy bits. Now the
values of r1, r2, r3 and r4 are calculated based on the Error
even parity condition for those positions given in (a), position C3 C2 C1 C0
(b), (c) and (d) respectively.
5 0 1 0 1
Since the number of 1’s at positions 1, 3, 5, 7 is 1. It
Now the value at this position 5 is to be
does not satisfies the even parity condition, so the
complimented so that the error can be corrected. So
required value of r1 is ‘1’. Since the number of 1’s at
that we can get the original encoded data. Now the
positions 2, 3, 6, 7 is 2. It satisfies the even parity
11-bit encoded data is to be decoded to get the
condition, so the required value of r2 is ‘0’. Since the
original 7-bit information data without any errors.
number of 1’s at positions 4, 5, 6, 7 is 2. It satisfies
the even parity condition, so the required value of r3
is ‘0’. Since the number of 1’s at positions 8, 9, 10
is 1. It does not satisfies the even parity condition, so
the required value of r4 is ‘1’. So the encoded data
obtained is “10010110010”.

Fig : Hamming decoder

NOTE :
Fig : Hamming encoder
If we get error at positions 8, 9, 10 or 11. It can noit
ERROR DETECTION, CORRECTION AND able to detect the correct position. Since the bits at
DECODING : these positions are redundancy bits which are just
used for the purpose of encoding and to provide help
ICACT CONFERENCE PROCEEDINGS 2019

11 10 9 8 7 6 5 4 3 2 1 C3 C2 C1 C0 ERRORPOSITION

1 0 0 0 0 1 1 0 0 1 0 F T T F Error in redundancy bit 8

1 0 0 1 0 1 1 0 0 1 0 T T T T No error

Table 2.31 : Encoded data with error at different The above figure shows the simulation waveforms of
positions Hamming encoder(7-bit to 11-bit). Here copy[7:1]
indicates the input data (information data) which is to
be encoded. copy[11:1] indicates the encoded output
data which is to be transmitted. Here the 7-bit data
for error detecting in the original information data, “0110010” is given as input data and the obtained 11-
they does not carry any information. So it is not bit data is “10010110010”.
necessary to detect and correct the errors at these
redundancy positions. It is briefly explained here with
an table.

Suppose the received information is 10000110010,


with an error at redundancy bit position 8. Then the
status of parity check will turn out to be FTTF. [‘F’
indicates bit ‘1’ and ‘T’ indicates ‘0’] If status of
parity check is FXXX, it implies that there is an error
only in a redundancy bit. The actual redundancy bit
in error can easily be identified by the position of the
occurrence of F. However, this is not a data bit there
is no need for any correction.

Suppose the received information is 10010110010,


with no error. Then the status of parity check will Fig : Simulation results of Error position detector
turn out to be TTTT, implying error at bit position The above figure shows the simulation waveforms of
0000 i.e. 0. This is treated as no error. error position detector. Here copy[11:1] indicates
received encoded data with error at one position and
RESULTS y[4:1] indicates the position of error. Here 11-bit data
is “10010100010” is given as input which have error
at position “5”. The output data “0101” indicates the
error at position “5”.

Fig :Simulation results of encoder


ICACT CONFERENCE PROCEEDINGS 2019

CONCLUSION

In this proposed method the redundancy bits are


placed at the end of the data bits. This method has the
advantage of reducing the usage of bits for the
calculation of redundancy bits. Here we are using 19
bits for calculation of redundancy bits while in
previous method we used 20 bits and it includes the
advantage that there is no position change of
information data during the entire process and it is
easy to remove (decode) the redundancy bits from the
encoded data. So that large number of data can be
easily transmitted, corrected and decoded. It is used
only for single bit error correction. Because of these
features this method is most suitable than the
previous existing method.
Fig :Simulation results of Error position correction

The above figure shows the simulation waveforms of


error position correction. Here i0[10:0] indicates the REFERENCES
original encoded data and i1[11:1] indicates the
encoded data with error at one position and d[10:0] [1] W. W. Peterson and E. J. Weldon, Jr., Error-
indicates the original encoded data after correcting Correcting Codes (2nd ed.). Cambridge, MA: MIT
the error present in the data i1[11:1]. Here the input Press, 1972.
data i0[11:1] = “10010110010” and i1[11:1] = [2] T. Fujiwara et al., “Error Detecting Capabilities of
“10010100010” and the output data d[10:0] = the Shortened Hamming Codes Adopted for Error
Detection in IEEE Standard 802.3,” IEEE Trans.
“10010110010”.
Communications, vol. 37, no. 9, pp. 986–989, Sep
1989.
[3] W. Xiong, and D. W. Matolak, “Performance of
Hamming Codes in Systems Employing Different
Code Symbol Energies,” IEEE Communications
Society, pp. 1055–1058 [Wireless and
Communications and Networking Conference
(WCNC)].
[4] Xilinx “Spartan-3 FPGA Family, complete
datasheet”, Xilinx Corp., Aug 2005.
[5] Xilinx “Synthesis and Simulation Design Guide”,
Xilinx Tech UG626 2012.
[6] Leena, Mr. Subham Gandhi and Mr. Jitender
Khurana, “Implementing (7,4) Hamming Code using
CPLD on VHDL” International Journal of New
Trends in Electronics , Vol. 1, Issue 1, Aug. 2013.
Fig : Simulation waveforms for decoder

The above figure shows the simulation waveforms of


Hamming decoder. Here copy1[11:1] indicates the
encoded data and copy[7:1] indicates the original
information data after decoding the encoded data.
Here the 11-bit data “10010110010” is the encoded
input data and the 7-bit data “0110010” is the
obtained original information data.

You might also like