SlideShare a Scribd company logo
LECTURE - 4
Ms. Maria Saleemi
BINARY CODES
• BCD CODE
• BCD ADDITION
• EXCESS – 3 CODE
• 2421 CODE
• 842’1’ CODE
• GRAY CODE
• ASCII CODE
CODES
• Information given to computer
• Data
• Instructions
• Code must be in Binary
• Computer understand Binary (0 and 1)
CODES
• n-bit Binary Code
• Combination of bits (0’s and 1’s) = 2n
• Each Combination represents a different value
BINARY CODED DECIMAL
Decimal (0,1,..9)
binary
Binary code
conversion
Computations
in binary
Results are
decoded
Decimal (0,1,..9)
BCD
• 4-bit Code
• Each decimal digit (0,1,..9) is written as a 4-bit binary
number
CONVERSION
DECIMAL BCD
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
REPRESENTATION IN BCD
FOR VALUES > 9
(11)10 = (?)BCD
From Table write:
BCD value of 1 (space) BCD value of 1
(11)10 = (0001 0001)BCD
• BCD is not same as Binary No.s
(16)10 = (0001 0110)BCD = (10000)2
LIMITATIONS OF BCD
• BCD uses 4 places for each decimal digit
ADVANTAGES OF BCD
• Can be easily converted to Decimal
• Can be understood by Computers
EXERCISE
Convert :
• (146)10 = (?)BCD
• (1001 0111 0110)BCD = (?)10
• (1010 1001 1000)BCD = (?)10
BCD ADDITION
• How computer will perform Addition of two
numbers using BCD Code ??
Decimal BCD Decimal BCD
4 0100 4 0100
+ 5 + 0101 + 8 1000
9 = 1001 12 1100
Invalid BCD No.
ADDITION WHEN SUM > 9
• If sum becomes Greater than 9:
• ADD 6 (0110) to the Binary Sum
• WHY add 6 ??
• We have 4-bits for BCD.
• n = 4
• Possible Combinations are: 2n = 24 = 16
• Used Combinations = 10 (0,1,..9)
• Unused Combinations = 16 – 10 = 6
EXAMPLESDecimal BCD
8 1000
+9 +1001
17 10001
+ 0110
= 10111
Thus,
(17)10 = (0001 0111)BCD
EXAMPLES
(184 + 576)10 = (?)BCD
• Solve Units, Tens, Hundreds place separately
• Transfer Carry’s to the previous bits
• If sum exceeds 1001, ADD 6 (0110) to it
OTHER DECIMAL CODES (4-bit)
• BCD – 23222120 – 8421
• 2421
• EXCESS – 3
• 842’1’
2421 CODE
• Till decimal value 4 write the code
• Decimal value 5 is the 1’s Complement of Decimal
Value 4
• 6 is the complement of 3
• 7 is the complement of 2
• 8 is the complement of 1
• 9 is the complement of 0
EXCESS – 3 CODE
• Add 3 (0011)BCD to every decimal value
• Example:
Decimal BCD Excess-3
0 0000 (0000 + 0011) = 0011
1 0001 (0001 + 0011) = 0100
… … …
842’1’ CODE
• Against each decimal value
• Add 8 and 4
• Subtract 2 and 1 to make the appropriate code
PROPERTIES
• BCD , 2421, and 842’1’ are WEIGHTED Codes
• BCD has weights = 8421
• 2421 has weights = 2421
• 842’1’ has weights = 8 4 -2 -1
Lecture 6
GRAY CODE
• Like simple Binary Numbers
• Difference:
• Only 1 bit changes at a time
• ADVANTAGE
• Error Detection and Error Correction
• USES
• Rotating Shaft of an aero plane
ROTATING SHAFT OF AN
AERO PLANE
0º
90º
180º
270º
0
0
1
1
1
..
CONVERSIONS
• Binary to Gray Code
• Gray Code to Binary
BINARY TO GRAY CODE• First bit of Gray is same as First bit of Binary
• Compare the MSB of Binary with its next bit.
• If bits compared are same, write gray bit 0
• If bits compared are different, write gray bit1
• Number of bits should be Equal
(1 0 1 1 0 1)2 = (?)Gray
(1 1 1 0 1 1)Gray
ERROR DETECTION
• Detection of Errors during transmission
• Binary information is sent through WIRES
• Noise in the Wires can change 0 to 1 and 1 to
0
• A PARITY-BIT is added for error-detection
GRAY TO BINARY CODE• Start with MSB
• Binary bits are same as Gray bits up to and including first
1
• If Gray bit is 0, repeat the previous binary bit
• If Gray bit is 1, complement the previous binary bit
(0 0 1 1 1 0 1 1 )Gray = (?)2
(0 0 1 0 1 1 0 1)2
PARITY BIT
• An extra bit added to the information
• Added to make the total no. of 1’s in the coded group,
either ODD or EVEN
• Even Parity
• choose parity bit such that # of 1’s is even
• Odd Parity
• choose parity bit such that # of 1’s is odd
EXAMPLE
• Data=1000001, even parity=0, odd parity=1
• Data=1010100, even parity=1, odd parity=0
• Only one parity bit is used
ALPHANUMERIC CODES
• Upper Case Alphabets (A,B,..,Z)
• Lower Case Alphabets (a,b,..,z)
• Numeric Values (0,1,2…)
• Special Characters (@,$,*,%,#,^,…etc)
TYPES OF ALPHANUMERIC
CODES• ASCII (American Standard Code for Information
Interchange)
• 7-bit code
• EBCDIC (Extended BCD Interchange Code)
• 8-bit code
Lecture 7
BINARY LOGIC
• Describes the Processing of Binary Information
• Is also called Boolean Algebra
• Uses 2 possible values:
• ‘1’ and ‘0’
• ‘yes’ and ‘no’
• ‘true’ and ‘false’
• Can be represented by variables: A, B, C, x, y, z, …
LOGICAL OPERATIONS
3 basic logical operations
• AND
• OR
• NOT
• Others can be derived from those (NAND, XOR, etc.)
AND Function• Operation:
• Two inputs
• Output = 1 if and only if both inputs are 1
• Symbolized by dot or absence of operator
x·y or xy
• Truth table
• Needs to consider 22 = 4 input combinations
• Graphic symbol
• AND gate
111
001
010
000
zyx
inputs output
OR Function
• Two inputs
• Output = 1 if any one or both inputs are 1
• Symbolized by “plus” sign: x + y
• Truth table
• Graphic symbol
• OR gate
x y z
0 0 0
0 1 1
1 0 1
1 1 1
NOT Function
• Complement operation
• Single input
• Inverts value of input
• Symbolized by prime x’ or over bar
• Truth table
• Input combinations on the left
• Output of function on the right
• Graphic symbol
• NOT gate
• Little circle indicates inversion
x x'
0 1
1 0
x
input output
MULTIPLE INPUTS
• Two inputs might not be enough
• 3-input AND gate:
• 4-input OR gate:
ALGEBRAS
• What is an algebra?
• Mathematical system consisting of
• Set of elements
• Set of operators
• Axioms or postulates
• Why is it important?
• Defines rules of “calculations”
• Example: arithmetic on natural numbers
• Set of elements: N = {1,2,3,4,…}
• Operator: +, –, *
• Axioms: associativity, distributivity, closure, identity elements, etc.
• Note: operators with two inputs are called binary
• Does not mean they are restricted to binary numbers!
CHAPTER – 2
BOOLEAN ALGEBRA AND
LOGIC GATES
GEORGE BOOLE
• Father of Boolean algebra
George Boole (1815 - 1864)
TOPICS
• Boolean algebra
• Algebra axioms, postulates
• Boolean functions
• Algebraic expression
• Boolean Theorems
• Comparison of Boolean functions
• Canonical and standard forms
• sum of minterms
• Duality: DeMorgan’s theorem
• Dual canonical form (product of maxterms)
• Digital logic gates and integrated circuits
BOOLEAN ALGEBRA• Axioms and Postulates
1. Value of Variables
Variable x may have two values:
 x = 0 or x = 1
2. IDENTITY
(+) OR: 0 + x = x + 0 = x
(.) AND: 1 . x = x . 1 = x
******* ALSO *******
1 + x = 1
0 . x = 0
BOOLEAN ALGEBRA3. Commutative Law
OR (+):x + y = y + x
AND(.): x . y = y + x
3. Distributive Law
OR/AND: x + (y . z) = (x + y) . (x + z)
AND/OR: x . (y + z) = (x . y) + (x . z)
3. Complement
OR: x + x’ = 1
AND: x . x’ = 0
• Redundance Law
OR/AND: x + (x’ . y) = x + y (using distributive law)
BOOLEAN ALGEBRA –
DE-MORGAN’S THEOREM1. x + y + z + … = x . y . z . …
2. x . y . z . … = x + y + z + …
ABSORPTION LAW
1. x + x . y = x
2. x . (x + y) = x
**** ALSO ****
x + x = x
x . x = x
VERIFICATION USING TRUTH
TABLES
• Using Truth Table, Verify Distributive Law:
 x . (y + z ) = ( x . y ) + ( x . z )
We have 3 variables:
x , y, z
Possible Combinations: 23 = 8
SOLUTION: TRUTH TABLE
x y z y + z x . (y + z) x . y x . z (x . y) + (x . z)
0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 0 0 0 0
1 0 0 0 0 0 0 0
1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1
EXERCISE
Prove:
• De-Morgan’s Law
• Commutative Law
BOOLEAN FUNCTIONS
• EXPRESSIONS that contain:
• Binary Variable
• Values = 0,1
• Binary Operators
• OR, AND, NOT
• Parenthesis
• Equal Sign
BOOLEAN FUNCTIONS -
REPRESENTATION• Truth Table
• Boolean Expression
TRUTH TABLE
Listing of all possible combinations of INPUTS
and
their resulting OUTPUTS
BOOLEAN EXPRESSION
• Represented as:
Output = Logic Operators ( Inputs )

More Related Content

What's hot

3.codes( binary code ,excess 3, gray code )
3.codes( binary code ,excess 3, gray code )3.codes( binary code ,excess 3, gray code )
3.codes( binary code ,excess 3, gray code )
MdFazleRabbi18
 
review of number systems and codes
review of number systems and codesreview of number systems and codes
review of number systems and codes
srinu247
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
pyingkodi maran
 
Binary codes
Binary codesBinary codes
Binary codes
GargiKhanna1
 
Floating point presentation
Floating point presentationFloating point presentation
Floating point presentation
SnehalataAgasti
 
Sop and pos
Sop and posSop and pos
Sop and pos
shubhamprajapat23
 
Presentation on Karnaugh Map
Presentation  on Karnaugh MapPresentation  on Karnaugh Map
Presentation on Karnaugh Map
Kawsar Ahmed
 
FYBSC IT Digital Electronics Unit II Chapter I Boolean Algebra and Logic Gates
FYBSC IT Digital Electronics Unit II Chapter I Boolean Algebra and Logic GatesFYBSC IT Digital Electronics Unit II Chapter I Boolean Algebra and Logic Gates
FYBSC IT Digital Electronics Unit II Chapter I Boolean Algebra and Logic Gates
Arti Parab Academics
 
Binary Arithmetic Operations
Binary Arithmetic OperationsBinary Arithmetic Operations
Binary Arithmetic Operations
Digital System Design
 
Bcd to excess 3 code converter
Bcd to excess 3 code converterBcd to excess 3 code converter
Bcd to excess 3 code converter
Ushaswini Chowdary
 
Decoder Full Presentation
Decoder Full Presentation Decoder Full Presentation
Decoder Full Presentation
Adeel Rasheed
 
Binary number ppt
Binary number pptBinary number ppt
Binary number ppt
Ankit Gupta
 
Digital Logic circuit
Digital Logic circuitDigital Logic circuit
Digital Logic circuit
kavitha muneeshwaran
 
Chap ii.BCD code,Gray code
Chap ii.BCD code,Gray codeChap ii.BCD code,Gray code
Chap ii.BCD code,Gray codeBala Ganesh
 
The BCD to excess-3 converter
The BCD to excess-3 converterThe BCD to excess-3 converter
The BCD to excess-3 converter
Mahady Hasan
 
Number System
Number SystemNumber System
Number System
Meenakshi Paul
 
Binary code
Binary codeBinary code
Binary code
Juzen1600101
 
Boolean Algebra
Boolean AlgebraBoolean Algebra
Boolean Algebra
blaircomp2003
 
Design half ,full Adder and Subtractor
Design half ,full Adder and SubtractorDesign half ,full Adder and Subtractor
Design half ,full Adder and Subtractor
Jaimin@prt.ltd.
 

What's hot (20)

3.codes( binary code ,excess 3, gray code )
3.codes( binary code ,excess 3, gray code )3.codes( binary code ,excess 3, gray code )
3.codes( binary code ,excess 3, gray code )
 
review of number systems and codes
review of number systems and codesreview of number systems and codes
review of number systems and codes
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
Binary codes
Binary codesBinary codes
Binary codes
 
Floating point presentation
Floating point presentationFloating point presentation
Floating point presentation
 
Sop and pos
Sop and posSop and pos
Sop and pos
 
Codes
CodesCodes
Codes
 
Presentation on Karnaugh Map
Presentation  on Karnaugh MapPresentation  on Karnaugh Map
Presentation on Karnaugh Map
 
FYBSC IT Digital Electronics Unit II Chapter I Boolean Algebra and Logic Gates
FYBSC IT Digital Electronics Unit II Chapter I Boolean Algebra and Logic GatesFYBSC IT Digital Electronics Unit II Chapter I Boolean Algebra and Logic Gates
FYBSC IT Digital Electronics Unit II Chapter I Boolean Algebra and Logic Gates
 
Binary Arithmetic Operations
Binary Arithmetic OperationsBinary Arithmetic Operations
Binary Arithmetic Operations
 
Bcd to excess 3 code converter
Bcd to excess 3 code converterBcd to excess 3 code converter
Bcd to excess 3 code converter
 
Decoder Full Presentation
Decoder Full Presentation Decoder Full Presentation
Decoder Full Presentation
 
Binary number ppt
Binary number pptBinary number ppt
Binary number ppt
 
Digital Logic circuit
Digital Logic circuitDigital Logic circuit
Digital Logic circuit
 
Chap ii.BCD code,Gray code
Chap ii.BCD code,Gray codeChap ii.BCD code,Gray code
Chap ii.BCD code,Gray code
 
The BCD to excess-3 converter
The BCD to excess-3 converterThe BCD to excess-3 converter
The BCD to excess-3 converter
 
Number System
Number SystemNumber System
Number System
 
Binary code
Binary codeBinary code
Binary code
 
Boolean Algebra
Boolean AlgebraBoolean Algebra
Boolean Algebra
 
Design half ,full Adder and Subtractor
Design half ,full Adder and SubtractorDesign half ,full Adder and Subtractor
Design half ,full Adder and Subtractor
 

Similar to Binary codes

Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
Kannan Kanagaraj
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptNumber_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.ppt
VEERA BOOPATHY E
 
Number System
Number SystemNumber System
Number System
imtiyaz khan
 
Number system and codes
Number system and codesNumber system and codes
Number system and codes
Abhiraj Bohra
 
data representation
 data representation data representation
data representation
Haroon_007
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
GnanaDeepikaMeduri
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
Sukriti Dhang
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx
GobinathAECEJRF1101
 
De boolean algebra
De boolean algebraDe boolean algebra
De boolean algebra
VinodKataria5
 
Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:
Asif Iqbal
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effects
PeriyanayagiS
 
UGC NET Paper 1 ICT Memory and data
UGC NET Paper 1 ICT Memory and data  UGC NET Paper 1 ICT Memory and data
UGC NET Paper 1 ICT Memory and data
Megha V
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).ppt
Krishnavenimanickam2
 
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdfCDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
shubhangisonawane6
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdf
vijayapraba1
 

Similar to Binary codes (20)

UNIT-1_CSA.pdf
UNIT-1_CSA.pdfUNIT-1_CSA.pdf
UNIT-1_CSA.pdf
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptNumber_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.ppt
 
Basics of digital electronics
Basics of digital electronicsBasics of digital electronics
Basics of digital electronics
 
Number System
Number SystemNumber System
Number System
 
Decppt
DecpptDecppt
Decppt
 
Number system and codes
Number system and codesNumber system and codes
Number system and codes
 
data representation
 data representation data representation
data representation
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx
 
De boolean algebra
De boolean algebraDe boolean algebra
De boolean algebra
 
Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:
 
1. basic theories of information
1. basic theories of information1. basic theories of information
1. basic theories of information
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effects
 
UGC NET Paper 1 ICT Memory and data
UGC NET Paper 1 ICT Memory and data  UGC NET Paper 1 ICT Memory and data
UGC NET Paper 1 ICT Memory and data
 
combinational-circuit (1).ppt
combinational-circuit (1).pptcombinational-circuit (1).ppt
combinational-circuit (1).ppt
 
2dig circ
2dig circ2dig circ
2dig circ
 
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdfCDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdf
 

More from ZareenRauf1

Communication system lec 8
Communication system lec 8Communication system lec 8
Communication system lec 8
ZareenRauf1
 
Communication system lec7
Communication system lec7Communication system lec7
Communication system lec7
ZareenRauf1
 
Communication system lec6
Communication system  lec6Communication system  lec6
Communication system lec6
ZareenRauf1
 
Communication system lec5
Communication system  lec5Communication system  lec5
Communication system lec5
ZareenRauf1
 
communication system lec4
communication system lec4 communication system lec4
communication system lec4
ZareenRauf1
 
communication system lec3
 communication system lec3 communication system lec3
communication system lec3
ZareenRauf1
 
communication system lec2
 communication system lec2 communication system lec2
communication system lec2
ZareenRauf1
 
Communication system
Communication systemCommunication system
Communication system
ZareenRauf1
 
1's and 2's Complements
1's and 2's Complements 1's and 2's Complements
1's and 2's Complements
ZareenRauf1
 
Boolean algebra and logic gates
Boolean algebra and logic gatesBoolean algebra and logic gates
Boolean algebra and logic gates
ZareenRauf1
 
Boolean operators
Boolean operatorsBoolean operators
Boolean operators
ZareenRauf1
 
Boolean functions
Boolean functionsBoolean functions
Boolean functions
ZareenRauf1
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
ZareenRauf1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
ZareenRauf1
 

More from ZareenRauf1 (14)

Communication system lec 8
Communication system lec 8Communication system lec 8
Communication system lec 8
 
Communication system lec7
Communication system lec7Communication system lec7
Communication system lec7
 
Communication system lec6
Communication system  lec6Communication system  lec6
Communication system lec6
 
Communication system lec5
Communication system  lec5Communication system  lec5
Communication system lec5
 
communication system lec4
communication system lec4 communication system lec4
communication system lec4
 
communication system lec3
 communication system lec3 communication system lec3
communication system lec3
 
communication system lec2
 communication system lec2 communication system lec2
communication system lec2
 
Communication system
Communication systemCommunication system
Communication system
 
1's and 2's Complements
1's and 2's Complements 1's and 2's Complements
1's and 2's Complements
 
Boolean algebra and logic gates
Boolean algebra and logic gatesBoolean algebra and logic gates
Boolean algebra and logic gates
 
Boolean operators
Boolean operatorsBoolean operators
Boolean operators
 
Boolean functions
Boolean functionsBoolean functions
Boolean functions
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 

Recently uploaded

ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 

Recently uploaded (20)

ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 

Binary codes

  • 1. LECTURE - 4 Ms. Maria Saleemi
  • 2. BINARY CODES • BCD CODE • BCD ADDITION • EXCESS – 3 CODE • 2421 CODE • 842’1’ CODE • GRAY CODE • ASCII CODE
  • 3. CODES • Information given to computer • Data • Instructions • Code must be in Binary • Computer understand Binary (0 and 1)
  • 4. CODES • n-bit Binary Code • Combination of bits (0’s and 1’s) = 2n • Each Combination represents a different value
  • 5. BINARY CODED DECIMAL Decimal (0,1,..9) binary Binary code conversion Computations in binary Results are decoded Decimal (0,1,..9)
  • 6. BCD • 4-bit Code • Each decimal digit (0,1,..9) is written as a 4-bit binary number
  • 7. CONVERSION DECIMAL BCD 0 0 0 0 0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 0 0 9 1 0 0 1
  • 8. REPRESENTATION IN BCD FOR VALUES > 9 (11)10 = (?)BCD From Table write: BCD value of 1 (space) BCD value of 1 (11)10 = (0001 0001)BCD
  • 9. • BCD is not same as Binary No.s (16)10 = (0001 0110)BCD = (10000)2
  • 10. LIMITATIONS OF BCD • BCD uses 4 places for each decimal digit
  • 11. ADVANTAGES OF BCD • Can be easily converted to Decimal • Can be understood by Computers
  • 12. EXERCISE Convert : • (146)10 = (?)BCD • (1001 0111 0110)BCD = (?)10 • (1010 1001 1000)BCD = (?)10
  • 13. BCD ADDITION • How computer will perform Addition of two numbers using BCD Code ?? Decimal BCD Decimal BCD 4 0100 4 0100 + 5 + 0101 + 8 1000 9 = 1001 12 1100 Invalid BCD No.
  • 14. ADDITION WHEN SUM > 9 • If sum becomes Greater than 9: • ADD 6 (0110) to the Binary Sum • WHY add 6 ?? • We have 4-bits for BCD. • n = 4 • Possible Combinations are: 2n = 24 = 16 • Used Combinations = 10 (0,1,..9) • Unused Combinations = 16 – 10 = 6
  • 15. EXAMPLESDecimal BCD 8 1000 +9 +1001 17 10001 + 0110 = 10111 Thus, (17)10 = (0001 0111)BCD
  • 16. EXAMPLES (184 + 576)10 = (?)BCD • Solve Units, Tens, Hundreds place separately • Transfer Carry’s to the previous bits • If sum exceeds 1001, ADD 6 (0110) to it
  • 17. OTHER DECIMAL CODES (4-bit) • BCD – 23222120 – 8421 • 2421 • EXCESS – 3 • 842’1’
  • 18. 2421 CODE • Till decimal value 4 write the code • Decimal value 5 is the 1’s Complement of Decimal Value 4 • 6 is the complement of 3 • 7 is the complement of 2 • 8 is the complement of 1 • 9 is the complement of 0
  • 19. EXCESS – 3 CODE • Add 3 (0011)BCD to every decimal value • Example: Decimal BCD Excess-3 0 0000 (0000 + 0011) = 0011 1 0001 (0001 + 0011) = 0100 … … …
  • 20. 842’1’ CODE • Against each decimal value • Add 8 and 4 • Subtract 2 and 1 to make the appropriate code
  • 21. PROPERTIES • BCD , 2421, and 842’1’ are WEIGHTED Codes • BCD has weights = 8421 • 2421 has weights = 2421 • 842’1’ has weights = 8 4 -2 -1
  • 23. GRAY CODE • Like simple Binary Numbers • Difference: • Only 1 bit changes at a time • ADVANTAGE • Error Detection and Error Correction • USES • Rotating Shaft of an aero plane
  • 24. ROTATING SHAFT OF AN AERO PLANE 0º 90º 180º 270º 0 0 1 1 1 ..
  • 25. CONVERSIONS • Binary to Gray Code • Gray Code to Binary
  • 26. BINARY TO GRAY CODE• First bit of Gray is same as First bit of Binary • Compare the MSB of Binary with its next bit. • If bits compared are same, write gray bit 0 • If bits compared are different, write gray bit1 • Number of bits should be Equal (1 0 1 1 0 1)2 = (?)Gray (1 1 1 0 1 1)Gray
  • 27. ERROR DETECTION • Detection of Errors during transmission • Binary information is sent through WIRES • Noise in the Wires can change 0 to 1 and 1 to 0 • A PARITY-BIT is added for error-detection
  • 28. GRAY TO BINARY CODE• Start with MSB • Binary bits are same as Gray bits up to and including first 1 • If Gray bit is 0, repeat the previous binary bit • If Gray bit is 1, complement the previous binary bit (0 0 1 1 1 0 1 1 )Gray = (?)2 (0 0 1 0 1 1 0 1)2
  • 29. PARITY BIT • An extra bit added to the information • Added to make the total no. of 1’s in the coded group, either ODD or EVEN • Even Parity • choose parity bit such that # of 1’s is even • Odd Parity • choose parity bit such that # of 1’s is odd
  • 30. EXAMPLE • Data=1000001, even parity=0, odd parity=1 • Data=1010100, even parity=1, odd parity=0 • Only one parity bit is used
  • 31. ALPHANUMERIC CODES • Upper Case Alphabets (A,B,..,Z) • Lower Case Alphabets (a,b,..,z) • Numeric Values (0,1,2…) • Special Characters (@,$,*,%,#,^,…etc)
  • 32. TYPES OF ALPHANUMERIC CODES• ASCII (American Standard Code for Information Interchange) • 7-bit code • EBCDIC (Extended BCD Interchange Code) • 8-bit code
  • 34. BINARY LOGIC • Describes the Processing of Binary Information • Is also called Boolean Algebra • Uses 2 possible values: • ‘1’ and ‘0’ • ‘yes’ and ‘no’ • ‘true’ and ‘false’ • Can be represented by variables: A, B, C, x, y, z, …
  • 35. LOGICAL OPERATIONS 3 basic logical operations • AND • OR • NOT • Others can be derived from those (NAND, XOR, etc.)
  • 36. AND Function• Operation: • Two inputs • Output = 1 if and only if both inputs are 1 • Symbolized by dot or absence of operator x·y or xy • Truth table • Needs to consider 22 = 4 input combinations • Graphic symbol • AND gate 111 001 010 000 zyx inputs output
  • 37. OR Function • Two inputs • Output = 1 if any one or both inputs are 1 • Symbolized by “plus” sign: x + y • Truth table • Graphic symbol • OR gate x y z 0 0 0 0 1 1 1 0 1 1 1 1
  • 38. NOT Function • Complement operation • Single input • Inverts value of input • Symbolized by prime x’ or over bar • Truth table • Input combinations on the left • Output of function on the right • Graphic symbol • NOT gate • Little circle indicates inversion x x' 0 1 1 0 x input output
  • 39. MULTIPLE INPUTS • Two inputs might not be enough • 3-input AND gate: • 4-input OR gate:
  • 40. ALGEBRAS • What is an algebra? • Mathematical system consisting of • Set of elements • Set of operators • Axioms or postulates • Why is it important? • Defines rules of “calculations” • Example: arithmetic on natural numbers • Set of elements: N = {1,2,3,4,…} • Operator: +, –, * • Axioms: associativity, distributivity, closure, identity elements, etc. • Note: operators with two inputs are called binary • Does not mean they are restricted to binary numbers!
  • 41. CHAPTER – 2 BOOLEAN ALGEBRA AND LOGIC GATES
  • 42. GEORGE BOOLE • Father of Boolean algebra George Boole (1815 - 1864)
  • 43. TOPICS • Boolean algebra • Algebra axioms, postulates • Boolean functions • Algebraic expression • Boolean Theorems • Comparison of Boolean functions • Canonical and standard forms • sum of minterms • Duality: DeMorgan’s theorem • Dual canonical form (product of maxterms) • Digital logic gates and integrated circuits
  • 44. BOOLEAN ALGEBRA• Axioms and Postulates 1. Value of Variables Variable x may have two values:  x = 0 or x = 1 2. IDENTITY (+) OR: 0 + x = x + 0 = x (.) AND: 1 . x = x . 1 = x ******* ALSO ******* 1 + x = 1 0 . x = 0
  • 45. BOOLEAN ALGEBRA3. Commutative Law OR (+):x + y = y + x AND(.): x . y = y + x 3. Distributive Law OR/AND: x + (y . z) = (x + y) . (x + z) AND/OR: x . (y + z) = (x . y) + (x . z) 3. Complement OR: x + x’ = 1 AND: x . x’ = 0 • Redundance Law OR/AND: x + (x’ . y) = x + y (using distributive law)
  • 46. BOOLEAN ALGEBRA – DE-MORGAN’S THEOREM1. x + y + z + … = x . y . z . … 2. x . y . z . … = x + y + z + … ABSORPTION LAW 1. x + x . y = x 2. x . (x + y) = x **** ALSO **** x + x = x x . x = x
  • 47. VERIFICATION USING TRUTH TABLES • Using Truth Table, Verify Distributive Law:  x . (y + z ) = ( x . y ) + ( x . z ) We have 3 variables: x , y, z Possible Combinations: 23 = 8
  • 48. SOLUTION: TRUTH TABLE x y z y + z x . (y + z) x . y x . z (x . y) + (x . z) 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1
  • 50. BOOLEAN FUNCTIONS • EXPRESSIONS that contain: • Binary Variable • Values = 0,1 • Binary Operators • OR, AND, NOT • Parenthesis • Equal Sign
  • 51. BOOLEAN FUNCTIONS - REPRESENTATION• Truth Table • Boolean Expression
  • 52. TRUTH TABLE Listing of all possible combinations of INPUTS and their resulting OUTPUTS
  • 53. BOOLEAN EXPRESSION • Represented as: Output = Logic Operators ( Inputs )