SlideShare a Scribd company logo
11
Most read
12
Most read
14
Most read
Group: MCA I Year
Subject: Computer Architecture
Semester: I
AVANTHI PG COLLEGE, Hyderabad
Topic: Code conversions
The digital data is represented, stored and transmitted as group
of binary bits. This group is also called as binary code. The binary code
is represented by the number as well as alphanumeric letter.
What is meant by code?
Codes are classified in to 2 types
Weighted
Non-weighted
 In weighted code, each digit position has a weight or
value.
 The sum of all digits multiplied by a weight gives a
total amount being represented.
 BCD or 8421 is a type of weighted code where each
digit position is assigned a specific weight.
WEIGHTED CODE
 In non weighted code there is no positional weight
 i.e., Each position within the binary number is not assigned a
prefix value.
 No specific positions are assigned to bit positions in non
weighted code.
 The non weighted codes are (1) Gray code
(2) Excess-3 code.
NON WEIGHTED CODE
Code converters
Some of the conversions are
Code conversion is used to change the data present in one type
of binary code to another type of binary code. Some of the codes are
BCD, Gray, Excess 3, ASCII and so on.
Binary to Gray code conversion
Gray to Binary code conversion
BCD to Excess-3 code conversion
Excess-3 to BCD code conversion
The Gray code is non-weighted code, as the position of bit does
not contain any weight. The Gray code is a reflective digital code
which has the special property that any two subsequent numbers
codes differ by only one bit. This is also called a unit- distance code.
Binary to Gray code conversion
The generation of 4-bit Gray code can be calculated by
using formula.
G1 = B1
G2 = B1ÅB2
G3 = B2ÅB3
G4 = B3ÅB4
The most significant bit (MSB) of the Gray code is always
equal to the MSB of the given binary code other bits of the output
Gray code can be obtained by Xoring binary code bit at that index
and previous index.
The binary to Gray code conversions can be done by using
xoring logic gate. A four-bit binary code converter is shown above.
The input is binary code and the output is equivalent Gray code.
A four-bit binary to Gray code conversion table is as shown below.
Four Bit Binary Number Four Bit Gray Code
B1 B2 B3 B4 G1 G2 G3 G4
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 0 0 0 1 1
0 0 1 1 0 0 1 0
0 1 0 0 0 1 1 0
0 1 0 1 0 1 1 1
0 1 1 0 0 1 0 1
0 1 1 1 0 1 0 0
1 0 0 0 1 1 0 0
1 0 0 1 1 1 0 1
1 0 1 0 1 1 1 1
1 0 1 1 1 1 1 0
1 1 0 0 1 0 1 0
1 1 0 1 1 0 1 1
1 1 1 0 1 0 0 1
The circuit for Binary to Gray code conversion is
Gray to binary code conversion
In Gray to binary conversion, the input is Gray code and output
is its equivalent binary code.
The generation of four-bit binary equivalent code can be
calculated by using formula.
B1 = G1
B2 = G2 Å B1
B3 = G3 Å B2
B4 = G4 Å B3
 The MSB of binary code is similar to the MSB of Gray code.
 To get next bit, use the xoring operation among the MSB of
binary to the next bit of the Gray code.
 Similarly, to get the third bit, it uses the xoring operation
among the second bit to the third MSB of the Gray code and
so on.
 The Gray to binary conversion method can be done by using
xoring logic gate.
 A four-bit Gray to binary code converter is as shown below.
Four Bit Gray Code Four Bit Binary Number
G1 G2 G3 G4 B1 B2 B3 B4
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 1 0 0 1 0
0 0 1 0 0 0 1 1
0 1 1 0 0 1 0 0
0 1 1 1 0 1 0 1
0 1 0 1 0 1 1 0
0 1 0 0 0 1 1 1
1 1 0 0 1 0 0 0
1 1 0 1 1 0 0 1
1 1 1 1 1 0 1 0
1 1 1 0 1 0 1 1
1 0 1 0 1 1 0 0
1 0 1 1 1 1 0 1
1 0 0 1 1 1 1 0
1 0 0 0 1 1 1 1
A four-bit Gray to binary code conversion table is as shown below.
BCD to Excess 3 code
 Excess-3 codes are unweighted and can be obtained by adding 3 to each
decimal digit then it can be represented by using 4-bit binary number for
each digit.
 To find the decimal equivalent of the given binary number. Add 0011 to
each four-bit group in binary coded decimal number (BCD) to get desired
excess-3 equivalent.
 The variables B0, B1, B2, and B3 represent the bits of the binary numbers.
 The variable 'B0' represents the LSB, and the variable 'B3' represents the
MSB.
 The variables E0, E1, E2, and E3 represent the bits of the Excess-3 code.
 The variable 'E0' represents the LSB, and the variable 'E3' represents the
MSB.
The truth table for BCD to Excess-3 code converter can be determined as shown
in table below.
For impossible four bit Excess-3 code we use output as Don’t care conditions.
The 'don't care conditions' is defined by the variable 'X'.
BCD Number Excess-3 Code Number
Decimal B3 B2 B1 B0 E3 E2 E1 E0
0 0 0 0 0 0 0 1 1
1 0 0 0 1 0 1 0 0
2 0 0 1 0 0 1 0 1
3 0 0 1 1 0 1 1 0
4 0 1 0 0 0 1 1 1
5 0 1 0 1 1 0 0 0
6 0 1 1 0 1 0 0 1
7 0 1 1 1 1 0 1 0
8 1 0 0 0 1 0 1 1
9 1 0 0 1 1 1 0 0
The circuit diagram for BCD to Excess-3 code converter is shown below
Excess-3 to BCD converter
The process of converting Excess-3 to BCD is opposite to the process of
converting BCD to Excess-3.
The BCD code can be calculated by subtracting 3, i.e., 0011 from each four-
digit Excess-3 code.
The variables E0, E1, E2, and E3 represent the bits of the Excess-3 code.
The variable 'E0' represents the LSB, and the variable 'E3' represents the
MSB.
The variables B0, B1, B2, and B3 represent the bits of the binary numbers.
The variable 'B0' represents the LSB, and the variable 'B3' represents the
MSB.
The 'don't care conditions' is defined by the variable 'X'.
The circuit diagram for Excess-3 code to BCD converter is shown below
The truth table for BCD to Excess-3 code converter can be
determined as shown in table below.
Excess-3 Code Number BCD Number
Decimal E3 E2 E1 E0 B3 B2 B1 B0
0 0 0 1 1 0 0 0 0
1 0 1 0 0 0 0 0 1
2 0 1 0 1 0 0 1 0
3 0 1 1 0 0 0 1 1
4 0 1 1 1 0 1 0 0
5 1 0 0 0 0 1 0 1
6 1 0 0 1 0 1 1 0
7 1 0 1 0 0 1 1 1
8 1 0 1 1 1 0 0 0
9 1 1 0 0 1 0 0 1
PREPARED BY
RAMAKRISHNA REDDY BIJJAM
AVANTHI PG COLLEGE
HYDERABAD

More Related Content

PDF
PPTX
Lect 7: Verilog Behavioral model for Absolute Beginners
PPTX
Logic gate
PPT
Arithmetic circuits
PPTX
Multiplexer.pptx
PDF
8051 micro controllers Instruction set
PPTX
Metastability,MTBF,synchronizer & synchronizer failure
PDF
Flip flop
Lect 7: Verilog Behavioral model for Absolute Beginners
Logic gate
Arithmetic circuits
Multiplexer.pptx
8051 micro controllers Instruction set
Metastability,MTBF,synchronizer & synchronizer failure
Flip flop

What's hot (20)

PPT
KARNAUGH MAP(K-MAP)
PPTX
Latch and flip flop
PPTX
synchronous state machine design
PPT
Logic families
PPT
Introduction state machine
PDF
I2C Bus (Inter-Integrated Circuit)
PPTX
The BCD to excess-3 converter
PPTX
Instruction set of 8086
PDF
Digital logic families
PPTX
SEQUENTIAL CIRCUITS [Flip-flops and Latches]
PPTX
Multiplexer and De-Multiplexer
PPTX
Nand and nor
PPT
encoder and decoder in digital electronics
PPTX
System verilog assertions
PDF
Binary codes
PDF
Binary multipliers
PDF
Ee 202 chapter 1 number and code system
PPTX
Introduction to System verilog
PPT
Flip Flop
KARNAUGH MAP(K-MAP)
Latch and flip flop
synchronous state machine design
Logic families
Introduction state machine
I2C Bus (Inter-Integrated Circuit)
The BCD to excess-3 converter
Instruction set of 8086
Digital logic families
SEQUENTIAL CIRCUITS [Flip-flops and Latches]
Multiplexer and De-Multiplexer
Nand and nor
encoder and decoder in digital electronics
System verilog assertions
Binary codes
Binary multipliers
Ee 202 chapter 1 number and code system
Introduction to System verilog
Flip Flop
Ad

Similar to Code conversions binary to Gray vice versa.pptx (20)

PPTX
Code conversions.pptx415.pptx
PPTX
Combinational Circuits digital design logic
PDF
Codes: Binary Codes Weighted codes Binary Coded Decimal (BCD) Non-weighted ...
PPTX
5_2019_01_03!03_33_00_PM.pptx
PPTX
Code Converters & Parity Checker
PPT
BCD,GRAY and EXCESS 3 codes
PPTX
Digital Logic BCA TU Chapter 2.2
PPT
Code conversion r006
PPTX
Module_3_Codes and Arithmetic operation.pptx
PPTX
Codes r005
PPTX
BCDCONVERTER.pptx
PPTX
Bcd with access 3
PDF
W3 Chapter 2B Notes CCB1223 Digital Logic.pdf
PPTX
Digital Logic-Lecture19.pptx
PDF
Lecture5 Chapter1- Binary Codes.pdf
PPTX
Digital Module 1.pptx Digital logic design
PPTX
DLD-W3-L1.pptx
PDF
Information Science in Action Week 3 Codes
PDF
Computer Logical Organization(It refers to how its functional units are arran...
Code conversions.pptx415.pptx
Combinational Circuits digital design logic
Codes: Binary Codes Weighted codes Binary Coded Decimal (BCD) Non-weighted ...
5_2019_01_03!03_33_00_PM.pptx
Code Converters & Parity Checker
BCD,GRAY and EXCESS 3 codes
Digital Logic BCA TU Chapter 2.2
Code conversion r006
Module_3_Codes and Arithmetic operation.pptx
Codes r005
BCDCONVERTER.pptx
Bcd with access 3
W3 Chapter 2B Notes CCB1223 Digital Logic.pdf
Digital Logic-Lecture19.pptx
Lecture5 Chapter1- Binary Codes.pdf
Digital Module 1.pptx Digital logic design
DLD-W3-L1.pptx
Information Science in Action Week 3 Codes
Computer Logical Organization(It refers to how its functional units are arran...
Ad

More from Ramakrishna Reddy Bijjam (20)

PPTX
DataStructures in Pyhton Pandas and numpy.pptx
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
PPTX
Regular expressions,function and glob module.pptx
PPTX
Natural Language processing using nltk.pptx
PPTX
Parsing HTML read and write operations and OS Module.pptx
PPTX
JSON, XML and Data Science introduction.pptx
PPTX
What is FIle and explanation of text files.pptx
PPTX
BINARY files CSV files JSON files with example.pptx
DOCX
VBS control structures for if do whilw.docx
DOCX
Builtinfunctions in vbscript and its types.docx
DOCX
VBScript Functions procedures and arrays.docx
DOCX
VBScript datatypes and control structures.docx
PPTX
Numbers and global functions conversions .pptx
DOCX
Structured Graphics in dhtml and active controls.docx
DOCX
Filters and its types as wave shadow.docx
PPTX
JavaScript Arrays and its types .pptx
PPTX
JS Control Statements and Functions.pptx
PDF
FIXED and FLOATING-POINT-REPRESENTATION.pdf
PPTX
Handling Missing Data for Data Analysis.pptx
PPTX
Data Frame Data structure in Python pandas.pptx
DataStructures in Pyhton Pandas and numpy.pptx
Pyhton with Mysql to perform CRUD operations.pptx
Regular expressions,function and glob module.pptx
Natural Language processing using nltk.pptx
Parsing HTML read and write operations and OS Module.pptx
JSON, XML and Data Science introduction.pptx
What is FIle and explanation of text files.pptx
BINARY files CSV files JSON files with example.pptx
VBS control structures for if do whilw.docx
Builtinfunctions in vbscript and its types.docx
VBScript Functions procedures and arrays.docx
VBScript datatypes and control structures.docx
Numbers and global functions conversions .pptx
Structured Graphics in dhtml and active controls.docx
Filters and its types as wave shadow.docx
JavaScript Arrays and its types .pptx
JS Control Statements and Functions.pptx
FIXED and FLOATING-POINT-REPRESENTATION.pdf
Handling Missing Data for Data Analysis.pptx
Data Frame Data structure in Python pandas.pptx

Recently uploaded (20)

PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Complications of Minimal Access Surgery at WLH
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Lesson notes of climatology university.
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
1_English_Language_Set_2.pdf probationary
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
RMMM.pdf make it easy to upload and study
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Trump Administration's workforce development strategy
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
IGGE1 Understanding the Self1234567891011
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Supply Chain Operations Speaking Notes -ICLT Program
Complications of Minimal Access Surgery at WLH
What if we spent less time fighting change, and more time building what’s rig...
Lesson notes of climatology university.
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
1_English_Language_Set_2.pdf probationary
A systematic review of self-coping strategies used by university students to ...
RMMM.pdf make it easy to upload and study
Practical Manual AGRO-233 Principles and Practices of Natural Farming
History, Philosophy and sociology of education (1).pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Trump Administration's workforce development strategy
Indian roads congress 037 - 2012 Flexible pavement
IGGE1 Understanding the Self1234567891011
202450812 BayCHI UCSC-SV 20250812 v17.pptx

Code conversions binary to Gray vice versa.pptx

  • 1. Group: MCA I Year Subject: Computer Architecture Semester: I AVANTHI PG COLLEGE, Hyderabad
  • 3. The digital data is represented, stored and transmitted as group of binary bits. This group is also called as binary code. The binary code is represented by the number as well as alphanumeric letter. What is meant by code? Codes are classified in to 2 types Weighted Non-weighted
  • 4.  In weighted code, each digit position has a weight or value.  The sum of all digits multiplied by a weight gives a total amount being represented.  BCD or 8421 is a type of weighted code where each digit position is assigned a specific weight. WEIGHTED CODE
  • 5.  In non weighted code there is no positional weight  i.e., Each position within the binary number is not assigned a prefix value.  No specific positions are assigned to bit positions in non weighted code.  The non weighted codes are (1) Gray code (2) Excess-3 code. NON WEIGHTED CODE
  • 6. Code converters Some of the conversions are Code conversion is used to change the data present in one type of binary code to another type of binary code. Some of the codes are BCD, Gray, Excess 3, ASCII and so on. Binary to Gray code conversion Gray to Binary code conversion BCD to Excess-3 code conversion Excess-3 to BCD code conversion
  • 7. The Gray code is non-weighted code, as the position of bit does not contain any weight. The Gray code is a reflective digital code which has the special property that any two subsequent numbers codes differ by only one bit. This is also called a unit- distance code. Binary to Gray code conversion
  • 8. The generation of 4-bit Gray code can be calculated by using formula. G1 = B1 G2 = B1ÅB2 G3 = B2ÅB3 G4 = B3ÅB4
  • 9. The most significant bit (MSB) of the Gray code is always equal to the MSB of the given binary code other bits of the output Gray code can be obtained by Xoring binary code bit at that index and previous index. The binary to Gray code conversions can be done by using xoring logic gate. A four-bit binary code converter is shown above. The input is binary code and the output is equivalent Gray code.
  • 10. A four-bit binary to Gray code conversion table is as shown below. Four Bit Binary Number Four Bit Gray Code B1 B2 B3 B4 G1 G2 G3 G4 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 1 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 1 0 1 1 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1 0 0 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0 0 1
  • 11. The circuit for Binary to Gray code conversion is
  • 12. Gray to binary code conversion In Gray to binary conversion, the input is Gray code and output is its equivalent binary code. The generation of four-bit binary equivalent code can be calculated by using formula. B1 = G1 B2 = G2 Å B1 B3 = G3 Å B2 B4 = G4 Å B3
  • 13.  The MSB of binary code is similar to the MSB of Gray code.  To get next bit, use the xoring operation among the MSB of binary to the next bit of the Gray code.  Similarly, to get the third bit, it uses the xoring operation among the second bit to the third MSB of the Gray code and so on.
  • 14.  The Gray to binary conversion method can be done by using xoring logic gate.  A four-bit Gray to binary code converter is as shown below.
  • 15. Four Bit Gray Code Four Bit Binary Number G1 G2 G3 G4 B1 B2 B3 B4 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 1 1 0 0 1 0 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 1 1 1 0 1 1 0 0 1 1 1 1 0 1 0 0 0 1 1 1 1 A four-bit Gray to binary code conversion table is as shown below.
  • 16. BCD to Excess 3 code  Excess-3 codes are unweighted and can be obtained by adding 3 to each decimal digit then it can be represented by using 4-bit binary number for each digit.  To find the decimal equivalent of the given binary number. Add 0011 to each four-bit group in binary coded decimal number (BCD) to get desired excess-3 equivalent.  The variables B0, B1, B2, and B3 represent the bits of the binary numbers.  The variable 'B0' represents the LSB, and the variable 'B3' represents the MSB.  The variables E0, E1, E2, and E3 represent the bits of the Excess-3 code.  The variable 'E0' represents the LSB, and the variable 'E3' represents the MSB.
  • 17. The truth table for BCD to Excess-3 code converter can be determined as shown in table below. For impossible four bit Excess-3 code we use output as Don’t care conditions. The 'don't care conditions' is defined by the variable 'X'. BCD Number Excess-3 Code Number Decimal B3 B2 B1 B0 E3 E2 E1 E0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 0 0 2 0 0 1 0 0 1 0 1 3 0 0 1 1 0 1 1 0 4 0 1 0 0 0 1 1 1 5 0 1 0 1 1 0 0 0 6 0 1 1 0 1 0 0 1 7 0 1 1 1 1 0 1 0 8 1 0 0 0 1 0 1 1 9 1 0 0 1 1 1 0 0
  • 18. The circuit diagram for BCD to Excess-3 code converter is shown below
  • 19. Excess-3 to BCD converter The process of converting Excess-3 to BCD is opposite to the process of converting BCD to Excess-3. The BCD code can be calculated by subtracting 3, i.e., 0011 from each four- digit Excess-3 code. The variables E0, E1, E2, and E3 represent the bits of the Excess-3 code. The variable 'E0' represents the LSB, and the variable 'E3' represents the MSB. The variables B0, B1, B2, and B3 represent the bits of the binary numbers. The variable 'B0' represents the LSB, and the variable 'B3' represents the MSB. The 'don't care conditions' is defined by the variable 'X'.
  • 20. The circuit diagram for Excess-3 code to BCD converter is shown below
  • 21. The truth table for BCD to Excess-3 code converter can be determined as shown in table below. Excess-3 Code Number BCD Number Decimal E3 E2 E1 E0 B3 B2 B1 B0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 1 2 0 1 0 1 0 0 1 0 3 0 1 1 0 0 0 1 1 4 0 1 1 1 0 1 0 0 5 1 0 0 0 0 1 0 1 6 1 0 0 1 0 1 1 0 7 1 0 1 0 0 1 1 1 8 1 0 1 1 1 0 0 0 9 1 1 0 0 1 0 0 1
  • 22. PREPARED BY RAMAKRISHNA REDDY BIJJAM AVANTHI PG COLLEGE HYDERABAD