ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Chapter1: Digital Systems and Binary
Numbers
Lecture5- Study Binary Codes
Engr. Arshad Nazir, Asst Prof
Dept of Electrical Engineering
SEECS 1
Fall 2022
Objectives
? Study Binary Codes
? Perform Arithmetic operations in BCD using 10¡¯s
Complement method
2
Fall 2022
Binary Codes
? Digital systems use discrete elements of information represented with
binary codes (i.e., a pattern of 0¡¯s and 1¡¯s). The codes should be in binary
because computers have circuits that represent and manipulate 0¡¯s and
1¡¯s.
? An n-bit binary code is a group of n bits that can represent up to 2n distinct
combinations of 1¡¯s and 0¡¯s.
? Each distinct combination represents a single symbol in the computer.
? The bit combination of an n-bit code is determined from the count in
binary from 0 to 2n-1. Each element must be assigned a unique binary
bit combination, and no two elements can have the same value.
? Although the minimum number of bits required to code 2n distinct
quantities is n, there is no maximum number of bits that can be used for a
binary code.
? Codes can be categorized as numeric and alphanumeric used for numbers
and transmission of textual data. Fall 2022 3
BCD Code (8,4,2,1)
? The most common representation for binary digits is the binary coded
decimal (BCD) form which is a binary assignment of the decimal numbers.
? This code is the simplest, most intuitive binary code for decimal digits
and uses the same weights as a binary number, but only encodes the
first ten values from 0 to 9 (6 out of 16 possible combinations remains
unassigned ).
? A number with k distinct decimal digits will require 4k bits in BCD.
? Each digit of a decimal value is converted to its respective binary
representation.
? BCD number needs more bits than its equivalent binary value?
? Each decimal digit in BCD code can be represented as shown in the next
slide.
Binary Coded Decimal Code (BCD)
Fall 2022 5
BCD Addition
? BCD only represents each of the decimal digitals 0 through 9 as a single 4-bit
binary value. BCD is a numeral code used in arithmetic operations in digital
machines. Addition is the most important operation because the other three
operations (subtraction, multiplication, and division can be accomplished using
addition. Following rules apply:
? Add the two BCD numbers, using the rules of binary addition.
? If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
? If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is generated,
it is an invalid result. Add 6(0110) to the 4-bit sum in order to skip the invalid
states and return the code to 8421. If a carry results when 6 is added, simply
add the carry to the next significant 4-bit group.
? Some BCD addition examples are:
Fall 2022 6
Multi-Digit BCD Addition
Fall 2022 7
BCD Arithmetic
? BCD arithmetic involving negative numbers uses the 10¡¯s complement for
representing the negative numbers including the sign digit.
? 0 (0000) represents a positive sign and 9 (1001) represents a negative
sign
? As an example, imagine we want to add
(+257) + (-160) = +97 Are these signed?
? Note: To obtain 10¡¯s complement of a BCD number, we first take the 9¡¯s
complement (by subtraction of each digit from 9) and then add one to
least significant digit
Perform subtraction (-257) - (+160) both signed and unsigned?
Fall 2022 8
Other Decimal Codes
? There are various other decimal codes that can be used:
? BCD (8, 4, 2, 1)
? 2, 4, 2, 1
? Excess-3 code. (adds binary 0011 to the BCD code)
? 8, 4, -2, -1
? Gray Code
? ASCII Character Code
? Error-Detecting Code
? Each bit has a "weight" associated with it and you can compute the
decimal value by adding the weights where a 1 exists in the code-
word.
Fall 2022 9
Four Different Binary Codes
Fall 2022 10
Gray Code
? The Gray (reflected) code is named after Frank Gray who patented it
for shaft encoders in 1953. It is un-weighted and non-arithmetic code;
that is, there are no specific weights assigned to the bit positions
? Some of the uses of Gray code are:-
? Conversion of physical variables like position or voltage that have a
continuous range of values to a digital representation.
? A different use of Gray codes appears in low-power CMOS logic
circuits that count up or down.
? Gray code is cyclic code i.e any n-bit code can be generated form n-1
bit code by taking reflection along the mirror and padding the two
halves with 0¡¯s and 1¡¯s respectively.
? The advantage of Gray code over straight binary number sequence is
that only one bit in the code group changes when going from one
number to the next (unit distance code).
Fall 2022 11
Gray Code Cont¡­
? This property is important in many applications, such as optical shaft angle
encoders, where error susceptibility increases with the number of bit
changes between adjacent numbers in a sequence.
? Optical shaft encoder is a disc attached to rotating shaft to measure its
rotational position. The disc contains areas that are clear for binary 1 and
opaque for binary 0. An illumination source is placed on one side of the
disc, and optical sensors, one for each of the bits to be encoded are placed
on the other side of the disc. When a clear region lies between the source
and a sensor, the sensor responds to the light with a binary 1 output. When
opaque region lies between the source and the sensor, the sensor
responds to the dark with a binary 0.
? The optical shaft encoder using 3-Bit Gray code for positions 0 through 7 is
shown in the next slide.
Fall 2022 12
Fall 2022 13
Gray Code Vs Binary Code
? Compare the number of bits
changing when going from
one number to the next for a
three-bit Binary and Gray
Code:
? In Gray code it is always
1-bit change (unit-
distance code).
? Can you guess the
applications where this
important property can
be used in digital
applications?
Fall 2022 14
Gray Code
Cont¡­
Fall 2022 15
Conversion from Binary to Gray Code
? Binary to Gray code Conversion: The following rules apply:
? The most significant bit (left-most) in the Gray code is the same as the
corresponding MSB in the binary number.
? Going from left to right, add each adjacent pair of binary code bits to get the
next Gray code bit and discard carries. Which addition?
? For example, the conversion of binary number 10110 to Gray Code is as follows
? The Gray Code is 11101.
Fall 2022 16
Conversion from Gray to Binary Code
? Gray to Binary code Conversion: The following rules apply:
? The most significant bit (left-most) in the Binary code is the same as the
corresponding MSB in the Gray code.
? Add each Binary code bit generated to the Gray code bit in the next adjacent
position and discard carries.
? For example, the conversion of Gray number 11011 to Binary code is as follows
? The binary number is 10010.
Fall 2022 17
More Decimal Codes
0111
0101
0100
1100
1101
Excess-3
Fall 2022 18
Your Turn
? Write 196510 in the following codes:
? 8, 4, 2, 1=
? 8, 4, -2, -1=
? 6, 3, 1, 1=
? Excess-3=
? Gray=
? Which of these codes are self-complementing?
Fall 2022 19
The End
20
Fall 2022
Ad

More Related Content

Similar to Lecture5 Chapter1- Binary Codes.pdf (20)

Number codes students
Number codes studentsNumber codes students
Number codes students
School of Design Engineering Fashion & Technology (DEFT), University of Wales, Newport
?
Codes r005
Codes  r005Codes  r005
Codes r005
arunachalamr16
?
Student IP Addressing Tutorial.ppt
Student IP Addressing Tutorial.pptStudent IP Addressing Tutorial.ppt
Student IP Addressing Tutorial.ppt
johnBronson6
?
Unit 1 Class Notes Printed digital Electronics.pdf
Unit 1 Class Notes Printed digital Electronics.pdfUnit 1 Class Notes Printed digital Electronics.pdf
Unit 1 Class Notes Printed digital Electronics.pdf
drdeepakgupta1307
?
5_2019_01_03!03_33_00_PM.pptx
5_2019_01_03!03_33_00_PM.pptx5_2019_01_03!03_33_00_PM.pptx
5_2019_01_03!03_33_00_PM.pptx
AbijahRoseline1
?
Chapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIChapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSI
Er. Nawaraj Bhandari
?
Combinational Circuits digital design logic
Combinational Circuits digital design logicCombinational Circuits digital design logic
Combinational Circuits digital design logic
Anil Yadav
?
Digital Design Session 2
Digital Design Session 2Digital Design Session 2
Digital Design Session 2
International Institute of Information Technology - Bangalore
?
Unit 1 data representation and computer arithmetic
Unit 1  data representation and computer arithmeticUnit 1  data representation and computer arithmetic
Unit 1 data representation and computer arithmetic
AmrutaMehata
?
Module_3_Codes and Arithmetic operation.pptx
Module_3_Codes and Arithmetic operation.pptxModule_3_Codes and Arithmetic operation.pptx
Module_3_Codes and Arithmetic operation.pptx
earningmoney9595
?
Digital electronics
Digital electronicsDigital electronics
Digital electronics
Sukriti Dhang
?
Unit-1 (DLD) Lecture 2.pptx
Unit-1 (DLD) Lecture 2.pptxUnit-1 (DLD) Lecture 2.pptx
Unit-1 (DLD) Lecture 2.pptx
BunnyYadav7
?
Bcd
BcdBcd
Bcd
Talha Fazal
?
Introduction to Computer Logical Organization
Introduction to Computer Logical OrganizationIntroduction to Computer Logical Organization
Introduction to Computer Logical Organization
BINJAD1
?
Coding Schemes related dld lecture it is dld
Coding Schemes related dld lecture it is dldCoding Schemes related dld lecture it is dld
Coding Schemes related dld lecture it is dld
shayan03239
?
Digital Electronics Codes.pdf
Digital Electronics Codes.pdfDigital Electronics Codes.pdf
Digital Electronics Codes.pdf
PrasenjitKumarDas2
?
Binary to gray converter using xor
Binary to gray converter using xor Binary to gray converter using xor
Binary to gray converter using xor
DINESH DEVIREDDY
?
DEL LAB MANUAL
DEL LAB MANUALDEL LAB MANUAL
DEL LAB MANUAL
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
?
Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes
VandanaPagar1
?
DE and LD [Autosave gyideffgfd] (1).pptx
DE and LD [Autosave gyideffgfd] (1).pptxDE and LD [Autosave gyideffgfd] (1).pptx
DE and LD [Autosave gyideffgfd] (1).pptx
temporarymail958
?
Student IP Addressing Tutorial.ppt
Student IP Addressing Tutorial.pptStudent IP Addressing Tutorial.ppt
Student IP Addressing Tutorial.ppt
johnBronson6
?
Unit 1 Class Notes Printed digital Electronics.pdf
Unit 1 Class Notes Printed digital Electronics.pdfUnit 1 Class Notes Printed digital Electronics.pdf
Unit 1 Class Notes Printed digital Electronics.pdf
drdeepakgupta1307
?
5_2019_01_03!03_33_00_PM.pptx
5_2019_01_03!03_33_00_PM.pptx5_2019_01_03!03_33_00_PM.pptx
5_2019_01_03!03_33_00_PM.pptx
AbijahRoseline1
?
Chapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIChapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSI
Er. Nawaraj Bhandari
?
Combinational Circuits digital design logic
Combinational Circuits digital design logicCombinational Circuits digital design logic
Combinational Circuits digital design logic
Anil Yadav
?
Unit 1 data representation and computer arithmetic
Unit 1  data representation and computer arithmeticUnit 1  data representation and computer arithmetic
Unit 1 data representation and computer arithmetic
AmrutaMehata
?
Module_3_Codes and Arithmetic operation.pptx
Module_3_Codes and Arithmetic operation.pptxModule_3_Codes and Arithmetic operation.pptx
Module_3_Codes and Arithmetic operation.pptx
earningmoney9595
?
Unit-1 (DLD) Lecture 2.pptx
Unit-1 (DLD) Lecture 2.pptxUnit-1 (DLD) Lecture 2.pptx
Unit-1 (DLD) Lecture 2.pptx
BunnyYadav7
?
Introduction to Computer Logical Organization
Introduction to Computer Logical OrganizationIntroduction to Computer Logical Organization
Introduction to Computer Logical Organization
BINJAD1
?
Coding Schemes related dld lecture it is dld
Coding Schemes related dld lecture it is dldCoding Schemes related dld lecture it is dld
Coding Schemes related dld lecture it is dld
shayan03239
?
Binary to gray converter using xor
Binary to gray converter using xor Binary to gray converter using xor
Binary to gray converter using xor
DINESH DEVIREDDY
?
Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes
VandanaPagar1
?
DE and LD [Autosave gyideffgfd] (1).pptx
DE and LD [Autosave gyideffgfd] (1).pptxDE and LD [Autosave gyideffgfd] (1).pptx
DE and LD [Autosave gyideffgfd] (1).pptx
temporarymail958
?

More from UmerKhan147799 (8)

Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
UmerKhan147799
?
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
UmerKhan147799
?
Lecture6 Chapter3- Function Simplification using Quine-MacCluskey Method.pdf
Lecture6 Chapter3- Function Simplification using Quine-MacCluskey Method.pdfLecture6 Chapter3- Function Simplification using Quine-MacCluskey Method.pdf
Lecture6 Chapter3- Function Simplification using Quine-MacCluskey Method.pdf
UmerKhan147799
?
Lecture4 Chapter4- Design 4-bit Lookahead Carry Binary Adder-Subtractor Circu...
Lecture4 Chapter4- Design 4-bit Lookahead Carry Binary Adder-Subtractor Circu...Lecture4 Chapter4- Design 4-bit Lookahead Carry Binary Adder-Subtractor Circu...
Lecture4 Chapter4- Design 4-bit Lookahead Carry Binary Adder-Subtractor Circu...
UmerKhan147799
?
Lecture5 Chapter2- Positive and Negative Logic.pdf
Lecture5 Chapter2- Positive and Negative Logic.pdfLecture5 Chapter2- Positive and Negative Logic.pdf
Lecture5 Chapter2- Positive and Negative Logic.pdf
UmerKhan147799
?
Lecture4 Chapter3- Non-Degenerate Forms.pdf
Lecture4 Chapter3- Non-Degenerate Forms.pdfLecture4 Chapter3- Non-Degenerate Forms.pdf
Lecture4 Chapter3- Non-Degenerate Forms.pdf
UmerKhan147799
?
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdfLecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
UmerKhan147799
?
Lecture5 Chapter3- Exclusive-OR Function and its Applications in Digital Desi...
Lecture5 Chapter3- Exclusive-OR Function and its Applications in Digital Desi...Lecture5 Chapter3- Exclusive-OR Function and its Applications in Digital Desi...
Lecture5 Chapter3- Exclusive-OR Function and its Applications in Digital Desi...
UmerKhan147799
?
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
Lecture6 Chapter1- ASCII Code, Error Detection and Correction Codes, and Bina...
UmerKhan147799
?
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
Lecture6 Chapter4- Design Magnitude Comparator Circuit, Introduction to Decod...
UmerKhan147799
?
Lecture6 Chapter3- Function Simplification using Quine-MacCluskey Method.pdf
Lecture6 Chapter3- Function Simplification using Quine-MacCluskey Method.pdfLecture6 Chapter3- Function Simplification using Quine-MacCluskey Method.pdf
Lecture6 Chapter3- Function Simplification using Quine-MacCluskey Method.pdf
UmerKhan147799
?
Lecture4 Chapter4- Design 4-bit Lookahead Carry Binary Adder-Subtractor Circu...
Lecture4 Chapter4- Design 4-bit Lookahead Carry Binary Adder-Subtractor Circu...Lecture4 Chapter4- Design 4-bit Lookahead Carry Binary Adder-Subtractor Circu...
Lecture4 Chapter4- Design 4-bit Lookahead Carry Binary Adder-Subtractor Circu...
UmerKhan147799
?
Lecture5 Chapter2- Positive and Negative Logic.pdf
Lecture5 Chapter2- Positive and Negative Logic.pdfLecture5 Chapter2- Positive and Negative Logic.pdf
Lecture5 Chapter2- Positive and Negative Logic.pdf
UmerKhan147799
?
Lecture4 Chapter3- Non-Degenerate Forms.pdf
Lecture4 Chapter3- Non-Degenerate Forms.pdfLecture4 Chapter3- Non-Degenerate Forms.pdf
Lecture4 Chapter3- Non-Degenerate Forms.pdf
UmerKhan147799
?
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdfLecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
UmerKhan147799
?
Lecture5 Chapter3- Exclusive-OR Function and its Applications in Digital Desi...
Lecture5 Chapter3- Exclusive-OR Function and its Applications in Digital Desi...Lecture5 Chapter3- Exclusive-OR Function and its Applications in Digital Desi...
Lecture5 Chapter3- Exclusive-OR Function and its Applications in Digital Desi...
UmerKhan147799
?
Ad

Recently uploaded (20)

860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
Pierre Celestin Eyock
?
Zeiss-Ultra-Optimeter metrology subject.pdf
Zeiss-Ultra-Optimeter metrology subject.pdfZeiss-Ultra-Optimeter metrology subject.pdf
Zeiss-Ultra-Optimeter metrology subject.pdf
Saikumar174642
?
Dahua Smart Cityyyyyyyyyyyyyyyyyy2025.pdf
Dahua Smart Cityyyyyyyyyyyyyyyyyy2025.pdfDahua Smart Cityyyyyyyyyyyyyyyyyy2025.pdf
Dahua Smart Cityyyyyyyyyyyyyyyyyy2025.pdf
PawachMetharattanara
?
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
?
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
?
ºÝºÝߣ share PPT of SOx control technologies.pptx
ºÝºÝߣ share PPT of SOx control technologies.pptxºÝºÝߣ share PPT of SOx control technologies.pptx
ºÝºÝߣ share PPT of SOx control technologies.pptx
vvsasane
?
VISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated detailsVISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated details
Vishal Kumar Singh
?
22PCOAM16 Unit 3 Session 23 Different ways to Combine Classifiers.pptx
22PCOAM16 Unit 3 Session 23  Different ways to Combine Classifiers.pptx22PCOAM16 Unit 3 Session 23  Different ways to Combine Classifiers.pptx
22PCOAM16 Unit 3 Session 23 Different ways to Combine Classifiers.pptx
Guru Nanak Technical Institutions
?
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
?
DeFAIMint | ?Mint to DeFAI. Vibe Trading as NFT
DeFAIMint | ?Mint to DeFAI. Vibe Trading as NFTDeFAIMint | ?Mint to DeFAI. Vibe Trading as NFT
DeFAIMint | ?Mint to DeFAI. Vibe Trading as NFT
Kyohei Ito
?
01.????????????????????????_pagenumber.pdf
01.????????????????????????_pagenumber.pdf01.????????????????????????_pagenumber.pdf
01.????????????????????????_pagenumber.pdf
PawachMetharattanara
?
GROUP 2 - MANUFACTURE OF LIME, GYPSUM AND CEMENT.pdf
GROUP 2 - MANUFACTURE OF LIME, GYPSUM AND CEMENT.pdfGROUP 2 - MANUFACTURE OF LIME, GYPSUM AND CEMENT.pdf
GROUP 2 - MANUFACTURE OF LIME, GYPSUM AND CEMENT.pdf
kemimafe11
?
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
?
Working with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to ImplementationWorking with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to Implementation
Alabama Transportation Assistance Program
?
Frontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend EngineersFrontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend Engineers
Michael Hertzberg
?
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
?
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
?
David Boutry - Specializes In AWS, Microservices And Python
David Boutry - Specializes In AWS, Microservices And PythonDavid Boutry - Specializes In AWS, Microservices And Python
David Boutry - Specializes In AWS, Microservices And Python
David Boutry
?
AI-Powered Data Management and Governance in Retail
AI-Powered Data Management and Governance in RetailAI-Powered Data Management and Governance in Retail
AI-Powered Data Management and Governance in Retail
IJDKP
?
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
?
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
Pierre Celestin Eyock
?
Zeiss-Ultra-Optimeter metrology subject.pdf
Zeiss-Ultra-Optimeter metrology subject.pdfZeiss-Ultra-Optimeter metrology subject.pdf
Zeiss-Ultra-Optimeter metrology subject.pdf
Saikumar174642
?
Dahua Smart Cityyyyyyyyyyyyyyyyyy2025.pdf
Dahua Smart Cityyyyyyyyyyyyyyyyyy2025.pdfDahua Smart Cityyyyyyyyyyyyyyyyyy2025.pdf
Dahua Smart Cityyyyyyyyyyyyyyyyyy2025.pdf
PawachMetharattanara
?
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
?
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
?
ºÝºÝߣ share PPT of SOx control technologies.pptx
ºÝºÝߣ share PPT of SOx control technologies.pptxºÝºÝߣ share PPT of SOx control technologies.pptx
ºÝºÝߣ share PPT of SOx control technologies.pptx
vvsasane
?
VISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated detailsVISHAL KUMAR SINGH Latest Resume with updated details
VISHAL KUMAR SINGH Latest Resume with updated details
Vishal Kumar Singh
?
22PCOAM16 Unit 3 Session 23 Different ways to Combine Classifiers.pptx
22PCOAM16 Unit 3 Session 23  Different ways to Combine Classifiers.pptx22PCOAM16 Unit 3 Session 23  Different ways to Combine Classifiers.pptx
22PCOAM16 Unit 3 Session 23 Different ways to Combine Classifiers.pptx
Guru Nanak Technical Institutions
?
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
?
DeFAIMint | ?Mint to DeFAI. Vibe Trading as NFT
DeFAIMint | ?Mint to DeFAI. Vibe Trading as NFTDeFAIMint | ?Mint to DeFAI. Vibe Trading as NFT
DeFAIMint | ?Mint to DeFAI. Vibe Trading as NFT
Kyohei Ito
?
01.????????????????????????_pagenumber.pdf
01.????????????????????????_pagenumber.pdf01.????????????????????????_pagenumber.pdf
01.????????????????????????_pagenumber.pdf
PawachMetharattanara
?
GROUP 2 - MANUFACTURE OF LIME, GYPSUM AND CEMENT.pdf
GROUP 2 - MANUFACTURE OF LIME, GYPSUM AND CEMENT.pdfGROUP 2 - MANUFACTURE OF LIME, GYPSUM AND CEMENT.pdf
GROUP 2 - MANUFACTURE OF LIME, GYPSUM AND CEMENT.pdf
kemimafe11
?
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
?
Frontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend EngineersFrontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend Engineers
Michael Hertzberg
?
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
?
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
?
David Boutry - Specializes In AWS, Microservices And Python
David Boutry - Specializes In AWS, Microservices And PythonDavid Boutry - Specializes In AWS, Microservices And Python
David Boutry - Specializes In AWS, Microservices And Python
David Boutry
?
AI-Powered Data Management and Governance in Retail
AI-Powered Data Management and Governance in RetailAI-Powered Data Management and Governance in Retail
AI-Powered Data Management and Governance in Retail
IJDKP
?
Ad

Lecture5 Chapter1- Binary Codes.pdf

  • 1. Chapter1: Digital Systems and Binary Numbers Lecture5- Study Binary Codes Engr. Arshad Nazir, Asst Prof Dept of Electrical Engineering SEECS 1 Fall 2022
  • 2. Objectives ? Study Binary Codes ? Perform Arithmetic operations in BCD using 10¡¯s Complement method 2 Fall 2022
  • 3. Binary Codes ? Digital systems use discrete elements of information represented with binary codes (i.e., a pattern of 0¡¯s and 1¡¯s). The codes should be in binary because computers have circuits that represent and manipulate 0¡¯s and 1¡¯s. ? An n-bit binary code is a group of n bits that can represent up to 2n distinct combinations of 1¡¯s and 0¡¯s. ? Each distinct combination represents a single symbol in the computer. ? The bit combination of an n-bit code is determined from the count in binary from 0 to 2n-1. Each element must be assigned a unique binary bit combination, and no two elements can have the same value. ? Although the minimum number of bits required to code 2n distinct quantities is n, there is no maximum number of bits that can be used for a binary code. ? Codes can be categorized as numeric and alphanumeric used for numbers and transmission of textual data. Fall 2022 3
  • 4. BCD Code (8,4,2,1) ? The most common representation for binary digits is the binary coded decimal (BCD) form which is a binary assignment of the decimal numbers. ? This code is the simplest, most intuitive binary code for decimal digits and uses the same weights as a binary number, but only encodes the first ten values from 0 to 9 (6 out of 16 possible combinations remains unassigned ). ? A number with k distinct decimal digits will require 4k bits in BCD. ? Each digit of a decimal value is converted to its respective binary representation. ? BCD number needs more bits than its equivalent binary value? ? Each decimal digit in BCD code can be represented as shown in the next slide.
  • 5. Binary Coded Decimal Code (BCD) Fall 2022 5
  • 6. BCD Addition ? BCD only represents each of the decimal digitals 0 through 9 as a single 4-bit binary value. BCD is a numeral code used in arithmetic operations in digital machines. Addition is the most important operation because the other three operations (subtraction, multiplication, and division can be accomplished using addition. Following rules apply: ? Add the two BCD numbers, using the rules of binary addition. ? If a 4-bit sum is equal to or less than 9, it is a valid BCD number. ? If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is generated, it is an invalid result. Add 6(0110) to the 4-bit sum in order to skip the invalid states and return the code to 8421. If a carry results when 6 is added, simply add the carry to the next significant 4-bit group. ? Some BCD addition examples are: Fall 2022 6
  • 8. BCD Arithmetic ? BCD arithmetic involving negative numbers uses the 10¡¯s complement for representing the negative numbers including the sign digit. ? 0 (0000) represents a positive sign and 9 (1001) represents a negative sign ? As an example, imagine we want to add (+257) + (-160) = +97 Are these signed? ? Note: To obtain 10¡¯s complement of a BCD number, we first take the 9¡¯s complement (by subtraction of each digit from 9) and then add one to least significant digit Perform subtraction (-257) - (+160) both signed and unsigned? Fall 2022 8
  • 9. Other Decimal Codes ? There are various other decimal codes that can be used: ? BCD (8, 4, 2, 1) ? 2, 4, 2, 1 ? Excess-3 code. (adds binary 0011 to the BCD code) ? 8, 4, -2, -1 ? Gray Code ? ASCII Character Code ? Error-Detecting Code ? Each bit has a "weight" associated with it and you can compute the decimal value by adding the weights where a 1 exists in the code- word. Fall 2022 9
  • 10. Four Different Binary Codes Fall 2022 10
  • 11. Gray Code ? The Gray (reflected) code is named after Frank Gray who patented it for shaft encoders in 1953. It is un-weighted and non-arithmetic code; that is, there are no specific weights assigned to the bit positions ? Some of the uses of Gray code are:- ? Conversion of physical variables like position or voltage that have a continuous range of values to a digital representation. ? A different use of Gray codes appears in low-power CMOS logic circuits that count up or down. ? Gray code is cyclic code i.e any n-bit code can be generated form n-1 bit code by taking reflection along the mirror and padding the two halves with 0¡¯s and 1¡¯s respectively. ? The advantage of Gray code over straight binary number sequence is that only one bit in the code group changes when going from one number to the next (unit distance code). Fall 2022 11
  • 12. Gray Code Cont¡­ ? This property is important in many applications, such as optical shaft angle encoders, where error susceptibility increases with the number of bit changes between adjacent numbers in a sequence. ? Optical shaft encoder is a disc attached to rotating shaft to measure its rotational position. The disc contains areas that are clear for binary 1 and opaque for binary 0. An illumination source is placed on one side of the disc, and optical sensors, one for each of the bits to be encoded are placed on the other side of the disc. When a clear region lies between the source and a sensor, the sensor responds to the light with a binary 1 output. When opaque region lies between the source and the sensor, the sensor responds to the dark with a binary 0. ? The optical shaft encoder using 3-Bit Gray code for positions 0 through 7 is shown in the next slide. Fall 2022 12
  • 14. Gray Code Vs Binary Code ? Compare the number of bits changing when going from one number to the next for a three-bit Binary and Gray Code: ? In Gray code it is always 1-bit change (unit- distance code). ? Can you guess the applications where this important property can be used in digital applications? Fall 2022 14
  • 16. Conversion from Binary to Gray Code ? Binary to Gray code Conversion: The following rules apply: ? The most significant bit (left-most) in the Gray code is the same as the corresponding MSB in the binary number. ? Going from left to right, add each adjacent pair of binary code bits to get the next Gray code bit and discard carries. Which addition? ? For example, the conversion of binary number 10110 to Gray Code is as follows ? The Gray Code is 11101. Fall 2022 16
  • 17. Conversion from Gray to Binary Code ? Gray to Binary code Conversion: The following rules apply: ? The most significant bit (left-most) in the Binary code is the same as the corresponding MSB in the Gray code. ? Add each Binary code bit generated to the Gray code bit in the next adjacent position and discard carries. ? For example, the conversion of Gray number 11011 to Binary code is as follows ? The binary number is 10010. Fall 2022 17
  • 19. Your Turn ? Write 196510 in the following codes: ? 8, 4, 2, 1= ? 8, 4, -2, -1= ? 6, 3, 1, 1= ? Excess-3= ? Gray= ? Which of these codes are self-complementing? Fall 2022 19