SlideShare a Scribd company logo
1 of 53
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

Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representationAnil Pokhrel
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbersMOHAN MOHAN
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesstudent
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital ElectronicsJanki Shah
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation Kamal Acharya
 
Encoders and decoders
Encoders and decodersEncoders and decoders
Encoders and decodersDeepikaDG1
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)cs19club
 
Half adder & full adder
Half adder & full adderHalf adder & full adder
Half adder & full adderGaditek
 
Computer instructions
Computer instructionsComputer instructions
Computer instructionsAnuj Modi
 
multiplexers and demultiplexers
 multiplexers and demultiplexers multiplexers and demultiplexers
multiplexers and demultiplexersUnsa Shakir
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmeticgavhays
 
Encoder & Decoder
Encoder & DecoderEncoder & Decoder
Encoder & DecoderSyed Saeed
 

What's hot (20)

Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representation
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
DATA REPRESENTATION
DATA  REPRESENTATIONDATA  REPRESENTATION
DATA REPRESENTATION
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codes
 
Digital Logic circuit
Digital Logic circuitDigital Logic circuit
Digital Logic circuit
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
Basic Computer Organization and Design
Basic  Computer  Organization  and  DesignBasic  Computer  Organization  and  Design
Basic Computer Organization and Design
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital Electronics
 
Sop and pos
Sop and posSop and pos
Sop and pos
 
BOOLEAN ALGEBRA & LOGIC GATE
BOOLEAN ALGEBRA & LOGIC GATEBOOLEAN ALGEBRA & LOGIC GATE
BOOLEAN ALGEBRA & LOGIC GATE
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation
 
Encoders and decoders
Encoders and decodersEncoders and decoders
Encoders and decoders
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
Half adder & full adder
Half adder & full adderHalf adder & full adder
Half adder & full adder
 
Floating point arithmetic
Floating point arithmeticFloating point arithmetic
Floating point arithmetic
 
Encoder
EncoderEncoder
Encoder
 
Computer instructions
Computer instructionsComputer instructions
Computer instructions
 
multiplexers and demultiplexers
 multiplexers and demultiplexers multiplexers and demultiplexers
multiplexers and demultiplexers
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Encoder & Decoder
Encoder & DecoderEncoder & Decoder
Encoder & Decoder
 

Similar to Binary codes

Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfKannan Kanagaraj
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptNumber_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptVEERA BOOPATHY E
 
Number system and codes
Number system and codesNumber system and codes
Number system and codesAbhiraj Bohra
 
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.pptxGobinathAECEJRF1101
 
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 effectsPeriyanayagiS
 
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
 
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.pdfshubhangisonawane6
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdfvijayapraba1
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programJyotiprakashMishra18
 

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
 
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
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and program
 

More from ZareenRauf1

Communication system lec 8
Communication system lec 8Communication system lec 8
Communication system lec 8ZareenRauf1
 
Communication system lec7
Communication system lec7Communication system lec7
Communication system lec7ZareenRauf1
 
Communication system lec6
Communication system  lec6Communication system  lec6
Communication system lec6ZareenRauf1
 
Communication system lec5
Communication system  lec5Communication system  lec5
Communication system lec5ZareenRauf1
 
communication system lec4
communication system lec4 communication system lec4
communication system lec4 ZareenRauf1
 
communication system lec3
 communication system lec3 communication system lec3
communication system lec3ZareenRauf1
 
communication system lec2
 communication system lec2 communication system lec2
communication system lec2ZareenRauf1
 
Communication system
Communication systemCommunication system
Communication systemZareenRauf1
 
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 gatesZareenRauf1
 
Boolean operators
Boolean operatorsBoolean operators
Boolean operatorsZareenRauf1
 
Boolean functions
Boolean functionsBoolean functions
Boolean functionsZareenRauf1
 

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

Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 

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 )