Session 5
Session 5
FUNDAMENTALS OF HARDWARE
AND CIRCUIT
SESSION 5: INTRODUCTION TO CODES
UNIVERSITY OF GHANA
College
CollegeofofBasic and Applied
Education
School
Schoolof
ofPhysical andand
Continuing Mathematical Sciences
Distance Education
2021/2022
2014/2015 – 2016/2017
SESSION OVERVIEW
q Alphanumeric code
0 0 0000
1 1 0001
2 10 0010
3 11 0011
4 100 0100
5 101 0101
6 110 0110
7 111 0111
8 1000 1000
9 1001 1001
Example
• Let us find the BCD equivalent of the decimal number 543.
This number has 3 decimal digits 5, 4 and 3.
• BCD 8421 codes of 5, 4 and 3 are 0101, 0100 and 0011
respectively.
• Joining all the binary numbers obtained, we have
• 54310 = 010101000011BCD
Example
• Let us find the 2421 equivalent of the decimal number 786.
• This number has 3 decimal digits 7, 8 and 6.
• we can write the 2421 codes of 7, 8 and 6 are 1101, 1110 and
1100 respectively.
• Therefore, the 2421 equivalent of the decimal number 786
is 110111101100.
This code also a 4-bit application code where the binary weights
carry 2, 4, 2, 1 from left to right.
This code is also a 4-bit application code where the binary weights carry
5, 2, 1, 1 from left to right.
DECIMAL NUMBER BINARY NUMBER 5211 CODE
0 0 0000
1 1 0001
2 10 0011
3 11 0101
4 100 0111
5 101 1000
6 110 1010
7 111 1100
8 1000 1110
9 1001 1111
Dwumfour Abdullai Aziz Slide 17
Reflective Code
0 0 0000 0000
1 1 0001 0001
2 10 0010 0011
3 11 0011 0101
4 100 0100 0111
5 101 1011 1000
6 110 1100 1010
7 111 1101 1100
8 1000 1110 1110
9 1001 1111 1111
Dwumfour Abdullai Aziz NOTE: 8421 code is not a reflective code.
Sequential Codes
0 0 0000 0011
1 1 0001 0100
2 10 0010 0101
3 11 0011 0110
4 100 0100 0111
5 101 0101 1000
6 110 0110 1001
7 111 0111 1010
8 1000 1000 1011
9 1001 1001 1100
• The Gray code is the code where one bit will be differed to the
preceding number.
• For example, decimal numbers 13 and 14 are represented by
Gray code numbers 1011 and 1001, these numbers differ only
in single position that is the second position from the right.
• In the same way first position on the left changes for 7 and 8
which are 0100 and 1100 and this is also called Unit-distance
code.
• The Gray code has very special place in digital electronics.