SlideShare a Scribd company logo
1 of 38
Download to read offline
Digital Logic and Design (EEE-241)
L t 2
Dr M G Abbas Malik
Lecture 2
Dr. M. G. Abbas Malik
abbas.malik@ciitlahore.edu.pk
Picture Source: http://www.vanoast.com/old-portfolio/digital-design-logo-one%5Ba%5D.jpg
P i l tPrevious lecture
Digital Vs AnalogDigital Vs. Analog
Digital System – example digital computer
Di t l d bi lDiscrete values and binary values
Number system (positional and non-positional)
Binary number system
Conversion, addition, subtraction, multiplication,
di i idivision.
Octal number system (conversion)
Hexadecimal number system (conversion)
Dr. M. G. Abbas Malik – COMSATS Lahore2
C l tComplements
Complements are used to simplify the subtractionComplements are used to simplify the subtraction
operation and for logical manipulation
Consider r is the base of a number system, then there
exist two types of complement
1. r‘s complement
2 (r 1)’s complement2. (r-1) s complement
Example
For binary number system there are twoFor binary number system, there are two
complements 2’s (r) complement and 1’s (r-1)
complement
For decimal number system, these are 10’s and 9’s
complements.
Dr. M. G. Abbas Malik – COMSATS Lahore3
C l tComplements
r’s complementsr s complements
r is the base of our number system.
X i b i b th t h di it i itX is a number in base r that has n digits in its
integral part.
Th ’ l t f X i d fi d n X f X 0The r’s complement of X is defined as rn – X for X≠0
and 0 for X=0.
E l 1 D i l bExample 1: Decimal numbers
1234.765 Decimal Number:
Integral Fractional
10’s (r’s) complement
= 104 - 1234.765
Dr. M. G. Abbas Malik – COMSATS Lahore4
Part Part = 8765.235
C l tComplements
r’s complementsr s complements
Example 1: Decimal numbers (cont…)
Th 10’ l t f (0 3456) iThe 10’s complement of (0.3456)10 is
100 – 0.3456 = 1 – 0.3456 = 0.6544
10’ l t f d b l i ll10’s complement can formed by leaving all
least significant ZEROS unchanged,
bt ti th fi t l t i ifi tsubtracting the first non-zero least significant
digit from 10, and then subtracting all other
hi h i ifi t di it f 9higher significant digits from 9.
Dr. M. G. Abbas Malik – COMSATS Lahore5
C l tComplements
r’s complementsr s complements
Example 2: Binary numbers
The 2’s (r’s) complement of (101100)2 isThe 2 s (r s) complement of (101100)2 is
(26)10 – (101100)2 = (1000000 - 101100)2
= (010100)= (010100)2
The 2’s complement of (0.0110)2 is
(20) – (0 0110) = (1 – 0 0110) = 0 1010(2 )10 – (0.0110)2 = (1 – 0.0110)2 = 0.1010
The 2’s complement can be computed by leaving
all least significant ZEROS and first non-zero digitall least significant ZEROS and first non zero digit
unchanged, and then replacing 1’s by 0’s and 0’s
by 1’s in all other higher significant digits.
Dr. M. G. Abbas Malik – COMSATS Lahore6
C l tComplements
(r-1)’s complements(r-1) s complements
r is the base of our number system.
X i b i b th t h di it i itX is a number in base r that has n digits in its
integral part and a fractional part with m digits.
Th ( 1)’ l t f X i d fi d n m XThe (r-1)’s complement of X is defined as rn – r-m – X
Example 1: Decimal numbers
1234.765 Decimal Number:
9’s (r-1’s) complement
4 3
Integral
Part
Fractional
Part
= 104 – 10-3 - 1234.765
= 10000 – 0.001 – 1234.765
= 8765 234
Dr. M. G. Abbas Malik – COMSATS Lahore7
Part Part = 8765.234
C l tComplements
(r-1)’s complements(r-1) s complements
Example 1: Decimal numbers (cont…)
Th 9’ l t f (0 3456) iThe 9’s complement of (0.3456)10 is
100 – 10-4 – 0.3456 = 1 – 0.0001 - 0.3456
0 6543= 0.6543
9’s complement of a decimal number is
formed by subtracting every digit by 9.
Dr. M. G. Abbas Malik – COMSATS Lahore8
C l tComplements
(r-1)’s complements(r 1) s complements
Example 2: Binary numbers
The 1’s complement of (101100)2 isThe 1 s complement of (101100)2 is
(26 – 20)10 – (101100)2 = (1000000 – 1 – 101100)2
= (111111 – 101100) = (010011)= (111111 – 101100)2 = (010011)2
The 1’s complement of (0.0110)2 is
(20 – 2-4) – (0 0110) = (1 – 0 0001 – 0 0110)(2 – 2 )10 – (0.0110)2 = (1 – 0.0001 – 0.0110)2
= (0.1111 – 0.0110)2 = (0.1001)2
The 1’s complement is formed by replacing 1’s byThe 1 s complement is formed by replacing 1 s by
0’s and 0’s by 1’s.
Dr. M. G. Abbas Malik – COMSATS Lahore9
C l tComplements
C iConversions
r’s complement to (r-1)’s complementr s complement to (r 1) s complement
‘ l tr‘s complement – r-m
(r-1)’s complement to r’s complement
(r-1)‘s complement + r-m
Dr. M. G. Abbas Malik – COMSATS Lahore10
S bt tiSubtraction
General SubtractionGeneral Subtraction
246
– 138
Minuend
Subtrahend138
-----
108
Subtrahend
108
In general, when the minuend digit is smaller than
the corresponding subtrahend digit, we borrow 1the corresponding subtrahend digit, we borrow 1
from the higher significant position.
This is easier when people perform subtractionp p p
with paper and pencil.
This method is less efficient in digital systems.
Dr. M. G. Abbas Malik – COMSATS Lahore11
S bt ti ith C l tSubtraction with Complements
With r’s ComplementWith r s Complement
Suppose we have two positive number X and Y,
both of base r.
Subtraction X – Y may be done as follows:
1. Add the minuend X to the r’s compliment of thep
subtrahend Y.
2. Inspect the result obtained in step 1 for an end
carrycarry
a) If an end carry occurs, discard the end carry.
b) If an end carry does not occur, take the r’s complement of
the number obtained in step 1 and place a negative sign
in front.
Dr. M. G. Abbas Malik – COMSATS Lahore12
S bt ti ith C l tSubtraction with Complements
With r’s ComplementWith r s Complement
Example 1 – Decimal numbers
X 72532 72532X = 72532
Y = 3250
72532
10’ complement of 03250 = + 96750
69282E d 1 69282End carry → 1
Answer of X – Y = 69282
Dr. M. G. Abbas Malik – COMSATS Lahore13
S bt ti ith C l tSubtraction with Complements
With r’s ComplementWith r s Complement
Example 1 – Decimal numbers
X 3250 03250X = 3250
Y = 72532
03250
10’ complement of 72532 = + 27468
30718N d 30718No end carry
Answer of X – Y = – 10’s complement of 30718 = – 69282
Dr. M. G. Abbas Malik – COMSATS Lahore14
S bt ti ith C l tSubtraction with Complements
Number of digits in X and Y must beNumber of digits in X and Y must be
same. Before taking the r’s complement
f S ( ) fof Subtrahend (Y), if Y has less number
of digits, then we add ZEROS to the leftg
of the number and take r’s complement
considering newly added ZEROS asconsidering newly added ZEROS as
part of the number.
Dr. M. G. Abbas Malik – COMSATS Lahore15
S bt ti ith C l tSubtraction with Complements
With r’s ComplementWith r s Complement
Example 2 – Binary numbers
X 1010100 1010100X = 1010100
Y = 100100
1010100
2’s complement of 0100100 = + 1011100
0110000E d 1 0110000End carry → 1
Answer of X – Y = 110000
Dr. M. G. Abbas Malik – COMSATS Lahore16
S bt ti ith C l tSubtraction with Complements
With r’s ComplementWith r s Complement
Example 2 – Binary numbers
X 100100 0100100X = 100100
Y = 1010100
0100100
2’s complement of 1010100 = + 0101100
1010000N d 1010000No end carry
Answer = – 2’s complement of 1010000 = – 110000p
Dr. M. G. Abbas Malik – COMSATS Lahore17
S bt ti ith C l tSubtraction with Complements
With (r-1)’s complementWith (r 1) s complement
Suppose we have two positive number X and Y,
both of base r.
Subtraction X – Y may be done as follows:
1. Add the minuend X to the (r-1)’s compliment of( ) p
the subtrahend Y.
2. Inspect the result obtained in step 1 for an end
carrycarry
a) If an end carry occurs, add 1 to the least significant digit
(end around carry).
b) If an end carry does not occur, take the (r-1)’s
complement of the number obtained in step 1 and place a
negative sign in front.
Dr. M. G. Abbas Malik – COMSATS Lahore18
S bt ti ith C l tSubtraction with Complements
With (r-1)’s ComplementWith (r-1) s Complement
Example 1 – Decimal numbers
X 72532 72532X = 72532
Y = 3250
72532
9’s complement of 03250 = + 96749
69281E d 1 69281End carry → 1
+
Answer of X – Y = 69282
Dr. M. G. Abbas Malik – COMSATS Lahore19
S bt ti ith C l tSubtraction with Complements
With (r-1)’s ComplementWith (r-1) s Complement
Example 1 – Decimal numbers
X 3250 03250X = 3250
Y = 72532
03250
9’s complement of 72532 = + 27467
30717N d 30717No end carry
Answer of X – Y = – 9’s complement of 30718 = – 69282
Dr. M. G. Abbas Malik – COMSATS Lahore20
S bt ti ith C l tSubtraction with Complements
Number of digits in X and Y must beNumber of digits in X and Y must be
same. Before taking the r’s complement
f S ( ) fof Subtrahend (Y), if Y has less number
of digits, then we add ZEROS to the leftg
of the number and take r’s complement
considering newly added ZEROS asconsidering newly added ZEROS as
part of the number.
Dr. M. G. Abbas Malik – COMSATS Lahore21
S bt ti ith C l tSubtraction with Complements
With (r-1)’s ComplementWith (r-1) s Complement
Example 2 – Binary numbers
X 1010100 1010100X = 1010100
Y = 100100
1010100
1’ complement of 0100100 = + 1011011
0101111E d 1 0101111End carry → 1
+
Answer of X – Y = 110000
Dr. M. G. Abbas Malik – COMSATS Lahore22
S bt ti ith C l tSubtraction with Complements
With (r-1)’s ComplementWith (r-1) s Complement
Example 2 – Binary numbers
X 100100 0100100X = 100100
Y = 1010100
0100100
1’ complement of 1010100 = + 0101011
1001111N d 1001111No end carry
Answer = – 1’s complement of 1010000 = – 110000p
Dr. M. G. Abbas Malik – COMSATS Lahore23
C l t i Di it l S tComplements in Digital Systems
2’s complement 1’s complement
1. Harder to implement 1. Easier to implement1. Harder to implement
2. Subtraction take only
one arithmetic
p
2. Subtraction takes two
arithmetic additions
addition
3. Possesses only one
3. Possesses two
arithmetic zeros: one
with all 0s and one
arithmetic 0
4. Used only in
with all 0s and one
with all 1s
4. Useful in logical
conjunction with
arithmetic applications
g
manipulation: change
of 1’s to 0’s - inversion
Dr. M. G. Abbas Malik – COMSATS Lahore24
Bi C dBinary Codes
Electronic digital systems use signals that have twoElectronic digital systems use signals that have two
distinct values and Circuit elements that have two
stable states.
A binary number of n-digits may be represented by n
binary circuit elements, each having an output signal
equivalent to 1 or 0.
Digital system not only manipulate binary numbers,
b l h di l f i f ibut also many other discrete elements of information.
o Colors
Decimal digitso Decimal digits
o Alphabets (English, French, Urdu, Hindi, Punjabi, etc.)
Dr. M. G. Abbas Malik – COMSATS Lahore25
Bi C dBinary Codes
A bit is a binary digitA bit is a binary digit.
To represent a group of 2n distinct discrete
elements in a binary code requires a minimum ofelements in a binary code requires a minimum of
n bits.
Example 1: Color CodesExample 1: Color Codes
Consider we have four colors: RED, GREEN,
BLACK and BLUEBLACK and BLUE
We want to assign a binary code to each color, so
that we can represent these information in ourthat we can represent these information in our
digital system
Dr. M. G. Abbas Malik – COMSATS Lahore26
Bi C dBinary Codes
Example 1: Color Codes (cont )Example 1: Color Codes (cont…)
We have total 4 = 22 distinct discrete elements.
It d i i 2 bit t tIt means we need minimum 2 bits to represent
these four colors.
Color Binary Code
Black 00Black 00
Blue 01
Green 10Green 10
Red 11
Dr. M. G. Abbas Malik – COMSATS Lahore27
Bi C dBinary Codes
Example 2: Binary Coded Decimal (BCD)Example 2: Binary Coded Decimal (BCD)
Binary code for decimal digits require a minimum
4 bits as 24 = 16 > 10 > 8 = 234 bits as 24 = 16 > 10 > 8 = 23
Bit required Number of Discrete Elements
0 11 20 ≤ discrete elements ≤ 21
2 21 ≤ discrete elements ≤ 22
3 22 ≤ discrete elements ≤ 23
4 23 ≤ discrete elements ≤ 24
5 24 ≤ discrete elements ≤ 25
8 27 ≤ discrete elements ≤ 256=28
Dr. M. G. Abbas Malik – COMSATS Lahore28
Bi C dBinary Codes
Example 2: Binary Coded Decimal (BCD)Example 2: Binary Coded Decimal (BCD)
Binary code for decimal digits require a minimum
4 bits as 24 = 16 > 10 > 8 = 234 bits as 24 = 16 > 10 > 8 = 23
Decimal Digit BCD Decimal Digit BCD
0 0000 5 0101
1 0001 6 0110
2 0010 7 0111
3 0011 8 1000
4 0100 9 1001
Home Work: Read & Understand the other decimal codes given in table 1-2 and
bi d E D t ti R fl t d & Al h i C d (S ti 1 6)
Dr. M. G. Abbas Malik – COMSATS Lahore29
binary codes: Error-Detection, Reflected & Alphanumeric Codes (Section1-6)
Bi C dBinary Codes
Difference between Binary Codes and Binary ConversionDifference between Binary Codes and Binary Conversion
When we convert a decimal number in binary, it is
a sequence of 1’s and 0’s similar to binary codes,a sequence of 1 s and 0 s similar to binary codes,
but they are different.
Bi C i Bi C dBinary Conversion
Conversion of decimal
number 24 in binary is
Binary Codes
Binary code of decimal
number 24 in BCS isnumber 24 in binary is
(11000)2
number 24 in BCS is
(0010 0100)2
Dr. M. G. Abbas Malik – COMSATS Lahore30
Bi St d R i tBinary Storage and Registers
Binary Cell is a device that possesses two stableBinary Cell is a device that possesses two stable
states and is capable of storing one bit of
informationinformation.
o In Electronics, it is a flip-flop circuit, ferrite core use
in memoryy
o In a Punch-Card, positions punched with a hole or
not punched.
Binary cells are used to store the digital (binary)
information
Register is a group of binary cells
Dr. M. G. Abbas Malik – COMSATS Lahore31
Bi St d R i tBinary Storage and Registers
1 bit = 1 binary cell1 bit 1 binary cell
1 byte = 8 bits
Register size depends on the computer systemRegister size depends on the computer system
architecture.
1. 8 bits architecture – register size is 8 bitsg
2. 16 bits architecture – register size is 16 bits
3. 32 bits architecture – register size is 32 bits
4. 64 bits architecture (latest) – register size is 64 bits
A digital computer is characterized by its
registersregisters.
Assignment # 2 (available on course website)
Dr. M. G. Abbas Malik – COMSATS Lahore32
R i tRegisters
A register with n binary cells can stores anyA register with n binary cells can stores any
discrete quantity of information that contains n
bitsbits.
This is a 16-cells register
1 0 0 0 0 0 1 1 0 1 1 0 1 0 0 1
8 3 6 9
If contains the BCD information then it represent
th d i l b 8369
8 3 6 9
the decimal number 8369
Dr. M. G. Abbas Malik – COMSATS Lahore33
R i tRegister
Memory (RAM) is merely a collection of thousands ofMemory (RAM) is merely a collection of thousands of
registers.
The processor unit composed of various registers that
stores operands on which operations are performed.
o For example for the addition of two numbers, first
number (operand) is stored in the register A and thenumber (operand) is stored in the register A and the
second number (operand) is stored in the register B and
their sum after calculations is stored in the register C
Th t l it i t t k t k fThe control unit uses registers to keep track of
various computer sequences
Every input and output device must have at least oneEvery input and output device must have at least one
register to store the information transferred to or from
the device
Dr. M. G. Abbas Malik – COMSATS Lahore34
R i t T fRegister Transfer
Dr. M. G. Abbas Malik – COMSATS Lahore35
R i t T fRegister Transfer
Dr. M. G. Abbas Malik – COMSATS Lahore36
L iLogic
NOTNOT
AND
OROR
Dr. M. G. Abbas Malik – COMSATS Lahore37
L i G tLogic Gates
Dr. M. G. Abbas Malik – COMSATS Lahore38
Image Source: http://images.wikia.com/bmet/images/a/ab/Logic_gate.gif

More Related Content

What's hot

Integrals
IntegralsIntegrals
Integralsdean38
 
Functions 1 - Math Academy - JC H2 maths A levels
Functions 1 - Math Academy - JC H2 maths A levelsFunctions 1 - Math Academy - JC H2 maths A levels
Functions 1 - Math Academy - JC H2 maths A levelsMath Academy Singapore
 
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity AnalysisEuclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity AnalysisAmrinder Arora
 
Matrix chain multiplication by MHM
Matrix chain multiplication by MHMMatrix chain multiplication by MHM
Matrix chain multiplication by MHMMd Mosharof Hosen
 
Chap7 2 Ecc Intro
Chap7 2 Ecc IntroChap7 2 Ecc Intro
Chap7 2 Ecc IntroEdora Aziz
 
Polyhedral computations in computational algebraic geometry and optimization
Polyhedral computations in computational algebraic geometry and optimizationPolyhedral computations in computational algebraic geometry and optimization
Polyhedral computations in computational algebraic geometry and optimizationVissarion Fisikopoulos
 
Rational function representation
Rational function representationRational function representation
Rational function representationrey castro
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAAhmed Gamal Abdel Gawad
 
2.9 graphs of factorable rational functions t
2.9 graphs of factorable rational functions t2.9 graphs of factorable rational functions t
2.9 graphs of factorable rational functions tmath260
 
Graphs of trigonometric exponential functions lecture
Graphs of trigonometric exponential functions lectureGraphs of trigonometric exponential functions lecture
Graphs of trigonometric exponential functions lectureAdnanBukhari13
 
Factoring by the trial and-error method
Factoring by the trial and-error methodFactoring by the trial and-error method
Factoring by the trial and-error methodTarun Gehlot
 
5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!A Jorge Garcia
 

What's hot (20)

Statistics Assignment Help
Statistics Assignment HelpStatistics Assignment Help
Statistics Assignment Help
 
Integrals
IntegralsIntegrals
Integrals
 
Functions 1 - Math Academy - JC H2 maths A levels
Functions 1 - Math Academy - JC H2 maths A levelsFunctions 1 - Math Academy - JC H2 maths A levels
Functions 1 - Math Academy - JC H2 maths A levels
 
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity AnalysisEuclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
 
Matrix chain multiplication by MHM
Matrix chain multiplication by MHMMatrix chain multiplication by MHM
Matrix chain multiplication by MHM
 
Chap7 2 Ecc Intro
Chap7 2 Ecc IntroChap7 2 Ecc Intro
Chap7 2 Ecc Intro
 
Polyhedral computations in computational algebraic geometry and optimization
Polyhedral computations in computational algebraic geometry and optimizationPolyhedral computations in computational algebraic geometry and optimization
Polyhedral computations in computational algebraic geometry and optimization
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Data Analysis Assignment Help
Data Analysis Assignment Help Data Analysis Assignment Help
Data Analysis Assignment Help
 
Rational function representation
Rational function representationRational function representation
Rational function representation
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
 
Operation Research
Operation ResearchOperation Research
Operation Research
 
2.9 graphs of factorable rational functions t
2.9 graphs of factorable rational functions t2.9 graphs of factorable rational functions t
2.9 graphs of factorable rational functions t
 
S1 0 derivadas
S1 0 derivadasS1 0 derivadas
S1 0 derivadas
 
201707 CSE110 Lecture 33
201707 CSE110 Lecture 33  201707 CSE110 Lecture 33
201707 CSE110 Lecture 33
 
Graphs of trigonometric exponential functions lecture
Graphs of trigonometric exponential functions lectureGraphs of trigonometric exponential functions lecture
Graphs of trigonometric exponential functions lecture
 
Factoring by the trial and-error method
Factoring by the trial and-error methodFactoring by the trial and-error method
Factoring by the trial and-error method
 
Operation reasearch
Operation reasearchOperation reasearch
Operation reasearch
 
Operations Research
Operations ResearchOperations Research
Operations Research
 
5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!
 

Similar to Digital logic and design 02

Complement in DLD
Complement in DLDComplement in DLD
Complement in DLDshahzad ali
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersMohammad Bashartullah
 
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptChapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptDavid Louie Bedia
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxSurendra Loya
 
Introduction to Logarithm
Introduction to LogarithmIntroduction to Logarithm
Introduction to LogarithmFellowBuddy.com
 
Ratio and Proportion, Indices and Logarithm Part 4
Ratio and Proportion, Indices and Logarithm Part 4Ratio and Proportion, Indices and Logarithm Part 4
Ratio and Proportion, Indices and Logarithm Part 4FellowBuddy.com
 
digital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxdigital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxRameshK531901
 
Digital Fundamental Learning for the Students
Digital Fundamental Learning for the StudentsDigital Fundamental Learning for the Students
Digital Fundamental Learning for the Studentsshaival
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1Deepak John
 
Complements of numbers
Complements of numbersComplements of numbers
Complements of numbersKiriti Varkur
 
About the computer of the important field
About the computer               of the important fieldAbout the computer               of the important field
About the computer of the important fieldshubhamgupta7133
 
B sc cs i bo-de u-i number system
B sc cs i bo-de u-i number systemB sc cs i bo-de u-i number system
B sc cs i bo-de u-i number systemRai University
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptskatiarrahaman
 
Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic designgoutamkrsahoo
 

Similar to Digital logic and design 02 (20)

Complement
ComplementComplement
Complement
 
Complements
ComplementsComplements
Complements
 
Lecture_5-2.ppt
Lecture_5-2.pptLecture_5-2.ppt
Lecture_5-2.ppt
 
Complement in DLD
Complement in DLDComplement in DLD
Complement in DLD
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
 
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptChapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
 
Lec20
Lec20Lec20
Lec20
 
Introduction to Logarithm
Introduction to LogarithmIntroduction to Logarithm
Introduction to Logarithm
 
Ratio and Proportion, Indices and Logarithm Part 4
Ratio and Proportion, Indices and Logarithm Part 4Ratio and Proportion, Indices and Logarithm Part 4
Ratio and Proportion, Indices and Logarithm Part 4
 
digital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxdigital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptx
 
Digital Fundamental Learning for the Students
Digital Fundamental Learning for the StudentsDigital Fundamental Learning for the Students
Digital Fundamental Learning for the Students
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
 
Complements of numbers
Complements of numbersComplements of numbers
Complements of numbers
 
About the computer of the important field
About the computer               of the important fieldAbout the computer               of the important field
About the computer of the important field
 
B sc cs i bo-de u-i number system
B sc cs i bo-de u-i number systemB sc cs i bo-de u-i number system
B sc cs i bo-de u-i number system
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
4
44
4
 
Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic design
 

Recently uploaded

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 

Recently uploaded (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 

Digital logic and design 02

  • 1. Digital Logic and Design (EEE-241) L t 2 Dr M G Abbas Malik Lecture 2 Dr. M. G. Abbas Malik abbas.malik@ciitlahore.edu.pk Picture Source: http://www.vanoast.com/old-portfolio/digital-design-logo-one%5Ba%5D.jpg
  • 2. P i l tPrevious lecture Digital Vs AnalogDigital Vs. Analog Digital System – example digital computer Di t l d bi lDiscrete values and binary values Number system (positional and non-positional) Binary number system Conversion, addition, subtraction, multiplication, di i idivision. Octal number system (conversion) Hexadecimal number system (conversion) Dr. M. G. Abbas Malik – COMSATS Lahore2
  • 3. C l tComplements Complements are used to simplify the subtractionComplements are used to simplify the subtraction operation and for logical manipulation Consider r is the base of a number system, then there exist two types of complement 1. r‘s complement 2 (r 1)’s complement2. (r-1) s complement Example For binary number system there are twoFor binary number system, there are two complements 2’s (r) complement and 1’s (r-1) complement For decimal number system, these are 10’s and 9’s complements. Dr. M. G. Abbas Malik – COMSATS Lahore3
  • 4. C l tComplements r’s complementsr s complements r is the base of our number system. X i b i b th t h di it i itX is a number in base r that has n digits in its integral part. Th ’ l t f X i d fi d n X f X 0The r’s complement of X is defined as rn – X for X≠0 and 0 for X=0. E l 1 D i l bExample 1: Decimal numbers 1234.765 Decimal Number: Integral Fractional 10’s (r’s) complement = 104 - 1234.765 Dr. M. G. Abbas Malik – COMSATS Lahore4 Part Part = 8765.235
  • 5. C l tComplements r’s complementsr s complements Example 1: Decimal numbers (cont…) Th 10’ l t f (0 3456) iThe 10’s complement of (0.3456)10 is 100 – 0.3456 = 1 – 0.3456 = 0.6544 10’ l t f d b l i ll10’s complement can formed by leaving all least significant ZEROS unchanged, bt ti th fi t l t i ifi tsubtracting the first non-zero least significant digit from 10, and then subtracting all other hi h i ifi t di it f 9higher significant digits from 9. Dr. M. G. Abbas Malik – COMSATS Lahore5
  • 6. C l tComplements r’s complementsr s complements Example 2: Binary numbers The 2’s (r’s) complement of (101100)2 isThe 2 s (r s) complement of (101100)2 is (26)10 – (101100)2 = (1000000 - 101100)2 = (010100)= (010100)2 The 2’s complement of (0.0110)2 is (20) – (0 0110) = (1 – 0 0110) = 0 1010(2 )10 – (0.0110)2 = (1 – 0.0110)2 = 0.1010 The 2’s complement can be computed by leaving all least significant ZEROS and first non-zero digitall least significant ZEROS and first non zero digit unchanged, and then replacing 1’s by 0’s and 0’s by 1’s in all other higher significant digits. Dr. M. G. Abbas Malik – COMSATS Lahore6
  • 7. C l tComplements (r-1)’s complements(r-1) s complements r is the base of our number system. X i b i b th t h di it i itX is a number in base r that has n digits in its integral part and a fractional part with m digits. Th ( 1)’ l t f X i d fi d n m XThe (r-1)’s complement of X is defined as rn – r-m – X Example 1: Decimal numbers 1234.765 Decimal Number: 9’s (r-1’s) complement 4 3 Integral Part Fractional Part = 104 – 10-3 - 1234.765 = 10000 – 0.001 – 1234.765 = 8765 234 Dr. M. G. Abbas Malik – COMSATS Lahore7 Part Part = 8765.234
  • 8. C l tComplements (r-1)’s complements(r-1) s complements Example 1: Decimal numbers (cont…) Th 9’ l t f (0 3456) iThe 9’s complement of (0.3456)10 is 100 – 10-4 – 0.3456 = 1 – 0.0001 - 0.3456 0 6543= 0.6543 9’s complement of a decimal number is formed by subtracting every digit by 9. Dr. M. G. Abbas Malik – COMSATS Lahore8
  • 9. C l tComplements (r-1)’s complements(r 1) s complements Example 2: Binary numbers The 1’s complement of (101100)2 isThe 1 s complement of (101100)2 is (26 – 20)10 – (101100)2 = (1000000 – 1 – 101100)2 = (111111 – 101100) = (010011)= (111111 – 101100)2 = (010011)2 The 1’s complement of (0.0110)2 is (20 – 2-4) – (0 0110) = (1 – 0 0001 – 0 0110)(2 – 2 )10 – (0.0110)2 = (1 – 0.0001 – 0.0110)2 = (0.1111 – 0.0110)2 = (0.1001)2 The 1’s complement is formed by replacing 1’s byThe 1 s complement is formed by replacing 1 s by 0’s and 0’s by 1’s. Dr. M. G. Abbas Malik – COMSATS Lahore9
  • 10. C l tComplements C iConversions r’s complement to (r-1)’s complementr s complement to (r 1) s complement ‘ l tr‘s complement – r-m (r-1)’s complement to r’s complement (r-1)‘s complement + r-m Dr. M. G. Abbas Malik – COMSATS Lahore10
  • 11. S bt tiSubtraction General SubtractionGeneral Subtraction 246 – 138 Minuend Subtrahend138 ----- 108 Subtrahend 108 In general, when the minuend digit is smaller than the corresponding subtrahend digit, we borrow 1the corresponding subtrahend digit, we borrow 1 from the higher significant position. This is easier when people perform subtractionp p p with paper and pencil. This method is less efficient in digital systems. Dr. M. G. Abbas Malik – COMSATS Lahore11
  • 12. S bt ti ith C l tSubtraction with Complements With r’s ComplementWith r s Complement Suppose we have two positive number X and Y, both of base r. Subtraction X – Y may be done as follows: 1. Add the minuend X to the r’s compliment of thep subtrahend Y. 2. Inspect the result obtained in step 1 for an end carrycarry a) If an end carry occurs, discard the end carry. b) If an end carry does not occur, take the r’s complement of the number obtained in step 1 and place a negative sign in front. Dr. M. G. Abbas Malik – COMSATS Lahore12
  • 13. S bt ti ith C l tSubtraction with Complements With r’s ComplementWith r s Complement Example 1 – Decimal numbers X 72532 72532X = 72532 Y = 3250 72532 10’ complement of 03250 = + 96750 69282E d 1 69282End carry → 1 Answer of X – Y = 69282 Dr. M. G. Abbas Malik – COMSATS Lahore13
  • 14. S bt ti ith C l tSubtraction with Complements With r’s ComplementWith r s Complement Example 1 – Decimal numbers X 3250 03250X = 3250 Y = 72532 03250 10’ complement of 72532 = + 27468 30718N d 30718No end carry Answer of X – Y = – 10’s complement of 30718 = – 69282 Dr. M. G. Abbas Malik – COMSATS Lahore14
  • 15. S bt ti ith C l tSubtraction with Complements Number of digits in X and Y must beNumber of digits in X and Y must be same. Before taking the r’s complement f S ( ) fof Subtrahend (Y), if Y has less number of digits, then we add ZEROS to the leftg of the number and take r’s complement considering newly added ZEROS asconsidering newly added ZEROS as part of the number. Dr. M. G. Abbas Malik – COMSATS Lahore15
  • 16. S bt ti ith C l tSubtraction with Complements With r’s ComplementWith r s Complement Example 2 – Binary numbers X 1010100 1010100X = 1010100 Y = 100100 1010100 2’s complement of 0100100 = + 1011100 0110000E d 1 0110000End carry → 1 Answer of X – Y = 110000 Dr. M. G. Abbas Malik – COMSATS Lahore16
  • 17. S bt ti ith C l tSubtraction with Complements With r’s ComplementWith r s Complement Example 2 – Binary numbers X 100100 0100100X = 100100 Y = 1010100 0100100 2’s complement of 1010100 = + 0101100 1010000N d 1010000No end carry Answer = – 2’s complement of 1010000 = – 110000p Dr. M. G. Abbas Malik – COMSATS Lahore17
  • 18. S bt ti ith C l tSubtraction with Complements With (r-1)’s complementWith (r 1) s complement Suppose we have two positive number X and Y, both of base r. Subtraction X – Y may be done as follows: 1. Add the minuend X to the (r-1)’s compliment of( ) p the subtrahend Y. 2. Inspect the result obtained in step 1 for an end carrycarry a) If an end carry occurs, add 1 to the least significant digit (end around carry). b) If an end carry does not occur, take the (r-1)’s complement of the number obtained in step 1 and place a negative sign in front. Dr. M. G. Abbas Malik – COMSATS Lahore18
  • 19. S bt ti ith C l tSubtraction with Complements With (r-1)’s ComplementWith (r-1) s Complement Example 1 – Decimal numbers X 72532 72532X = 72532 Y = 3250 72532 9’s complement of 03250 = + 96749 69281E d 1 69281End carry → 1 + Answer of X – Y = 69282 Dr. M. G. Abbas Malik – COMSATS Lahore19
  • 20. S bt ti ith C l tSubtraction with Complements With (r-1)’s ComplementWith (r-1) s Complement Example 1 – Decimal numbers X 3250 03250X = 3250 Y = 72532 03250 9’s complement of 72532 = + 27467 30717N d 30717No end carry Answer of X – Y = – 9’s complement of 30718 = – 69282 Dr. M. G. Abbas Malik – COMSATS Lahore20
  • 21. S bt ti ith C l tSubtraction with Complements Number of digits in X and Y must beNumber of digits in X and Y must be same. Before taking the r’s complement f S ( ) fof Subtrahend (Y), if Y has less number of digits, then we add ZEROS to the leftg of the number and take r’s complement considering newly added ZEROS asconsidering newly added ZEROS as part of the number. Dr. M. G. Abbas Malik – COMSATS Lahore21
  • 22. S bt ti ith C l tSubtraction with Complements With (r-1)’s ComplementWith (r-1) s Complement Example 2 – Binary numbers X 1010100 1010100X = 1010100 Y = 100100 1010100 1’ complement of 0100100 = + 1011011 0101111E d 1 0101111End carry → 1 + Answer of X – Y = 110000 Dr. M. G. Abbas Malik – COMSATS Lahore22
  • 23. S bt ti ith C l tSubtraction with Complements With (r-1)’s ComplementWith (r-1) s Complement Example 2 – Binary numbers X 100100 0100100X = 100100 Y = 1010100 0100100 1’ complement of 1010100 = + 0101011 1001111N d 1001111No end carry Answer = – 1’s complement of 1010000 = – 110000p Dr. M. G. Abbas Malik – COMSATS Lahore23
  • 24. C l t i Di it l S tComplements in Digital Systems 2’s complement 1’s complement 1. Harder to implement 1. Easier to implement1. Harder to implement 2. Subtraction take only one arithmetic p 2. Subtraction takes two arithmetic additions addition 3. Possesses only one 3. Possesses two arithmetic zeros: one with all 0s and one arithmetic 0 4. Used only in with all 0s and one with all 1s 4. Useful in logical conjunction with arithmetic applications g manipulation: change of 1’s to 0’s - inversion Dr. M. G. Abbas Malik – COMSATS Lahore24
  • 25. Bi C dBinary Codes Electronic digital systems use signals that have twoElectronic digital systems use signals that have two distinct values and Circuit elements that have two stable states. A binary number of n-digits may be represented by n binary circuit elements, each having an output signal equivalent to 1 or 0. Digital system not only manipulate binary numbers, b l h di l f i f ibut also many other discrete elements of information. o Colors Decimal digitso Decimal digits o Alphabets (English, French, Urdu, Hindi, Punjabi, etc.) Dr. M. G. Abbas Malik – COMSATS Lahore25
  • 26. Bi C dBinary Codes A bit is a binary digitA bit is a binary digit. To represent a group of 2n distinct discrete elements in a binary code requires a minimum ofelements in a binary code requires a minimum of n bits. Example 1: Color CodesExample 1: Color Codes Consider we have four colors: RED, GREEN, BLACK and BLUEBLACK and BLUE We want to assign a binary code to each color, so that we can represent these information in ourthat we can represent these information in our digital system Dr. M. G. Abbas Malik – COMSATS Lahore26
  • 27. Bi C dBinary Codes Example 1: Color Codes (cont )Example 1: Color Codes (cont…) We have total 4 = 22 distinct discrete elements. It d i i 2 bit t tIt means we need minimum 2 bits to represent these four colors. Color Binary Code Black 00Black 00 Blue 01 Green 10Green 10 Red 11 Dr. M. G. Abbas Malik – COMSATS Lahore27
  • 28. Bi C dBinary Codes Example 2: Binary Coded Decimal (BCD)Example 2: Binary Coded Decimal (BCD) Binary code for decimal digits require a minimum 4 bits as 24 = 16 > 10 > 8 = 234 bits as 24 = 16 > 10 > 8 = 23 Bit required Number of Discrete Elements 0 11 20 ≤ discrete elements ≤ 21 2 21 ≤ discrete elements ≤ 22 3 22 ≤ discrete elements ≤ 23 4 23 ≤ discrete elements ≤ 24 5 24 ≤ discrete elements ≤ 25 8 27 ≤ discrete elements ≤ 256=28 Dr. M. G. Abbas Malik – COMSATS Lahore28
  • 29. Bi C dBinary Codes Example 2: Binary Coded Decimal (BCD)Example 2: Binary Coded Decimal (BCD) Binary code for decimal digits require a minimum 4 bits as 24 = 16 > 10 > 8 = 234 bits as 24 = 16 > 10 > 8 = 23 Decimal Digit BCD Decimal Digit BCD 0 0000 5 0101 1 0001 6 0110 2 0010 7 0111 3 0011 8 1000 4 0100 9 1001 Home Work: Read & Understand the other decimal codes given in table 1-2 and bi d E D t ti R fl t d & Al h i C d (S ti 1 6) Dr. M. G. Abbas Malik – COMSATS Lahore29 binary codes: Error-Detection, Reflected & Alphanumeric Codes (Section1-6)
  • 30. Bi C dBinary Codes Difference between Binary Codes and Binary ConversionDifference between Binary Codes and Binary Conversion When we convert a decimal number in binary, it is a sequence of 1’s and 0’s similar to binary codes,a sequence of 1 s and 0 s similar to binary codes, but they are different. Bi C i Bi C dBinary Conversion Conversion of decimal number 24 in binary is Binary Codes Binary code of decimal number 24 in BCS isnumber 24 in binary is (11000)2 number 24 in BCS is (0010 0100)2 Dr. M. G. Abbas Malik – COMSATS Lahore30
  • 31. Bi St d R i tBinary Storage and Registers Binary Cell is a device that possesses two stableBinary Cell is a device that possesses two stable states and is capable of storing one bit of informationinformation. o In Electronics, it is a flip-flop circuit, ferrite core use in memoryy o In a Punch-Card, positions punched with a hole or not punched. Binary cells are used to store the digital (binary) information Register is a group of binary cells Dr. M. G. Abbas Malik – COMSATS Lahore31
  • 32. Bi St d R i tBinary Storage and Registers 1 bit = 1 binary cell1 bit 1 binary cell 1 byte = 8 bits Register size depends on the computer systemRegister size depends on the computer system architecture. 1. 8 bits architecture – register size is 8 bitsg 2. 16 bits architecture – register size is 16 bits 3. 32 bits architecture – register size is 32 bits 4. 64 bits architecture (latest) – register size is 64 bits A digital computer is characterized by its registersregisters. Assignment # 2 (available on course website) Dr. M. G. Abbas Malik – COMSATS Lahore32
  • 33. R i tRegisters A register with n binary cells can stores anyA register with n binary cells can stores any discrete quantity of information that contains n bitsbits. This is a 16-cells register 1 0 0 0 0 0 1 1 0 1 1 0 1 0 0 1 8 3 6 9 If contains the BCD information then it represent th d i l b 8369 8 3 6 9 the decimal number 8369 Dr. M. G. Abbas Malik – COMSATS Lahore33
  • 34. R i tRegister Memory (RAM) is merely a collection of thousands ofMemory (RAM) is merely a collection of thousands of registers. The processor unit composed of various registers that stores operands on which operations are performed. o For example for the addition of two numbers, first number (operand) is stored in the register A and thenumber (operand) is stored in the register A and the second number (operand) is stored in the register B and their sum after calculations is stored in the register C Th t l it i t t k t k fThe control unit uses registers to keep track of various computer sequences Every input and output device must have at least oneEvery input and output device must have at least one register to store the information transferred to or from the device Dr. M. G. Abbas Malik – COMSATS Lahore34
  • 35. R i t T fRegister Transfer Dr. M. G. Abbas Malik – COMSATS Lahore35
  • 36. R i t T fRegister Transfer Dr. M. G. Abbas Malik – COMSATS Lahore36
  • 37. L iLogic NOTNOT AND OROR Dr. M. G. Abbas Malik – COMSATS Lahore37
  • 38. L i G tLogic Gates Dr. M. G. Abbas Malik – COMSATS Lahore38 Image Source: http://images.wikia.com/bmet/images/a/ab/Logic_gate.gif