SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
2/21/2011
1
Dr M G Abbas Malik
Digital Logic and Design (EEE-241)
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
Previous lecture
Digital Vs. Analog
Digital System – example digital computer
Discrete values and binary values
Number system (positional and non-positional)
Dr. M. G. Abbas Malik – COMSATS Lahore2
Binary number system
Conversion, addition, subtraction, multiplication,
division.
Octal number system (conversion)
Hexadecimal number system (conversion)
Complements
Complements 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 complement
Dr. M. G. Abbas Malik – COMSATS Lahore3
2. (r-1) s complement
Example
For 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.
2/21/2011
2
Complements
r’s complements
r is the base of our number system.
X 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 0
Dr. M. G. Abbas Malik – COMSATS Lahore4
The r’s complement of X is defined as rn – X for X≠0
and 0 for X=0.
Example 1: Decimal numbers
1234.765
Integral
Part
Fractional
Part
Decimal Number:
10’s (r’s) complement
= 104 - 1234.765
= 8765.235
Complements
r’s complements
Example 1: Decimal numbers (cont…)
The 10’s complement of (0.3456)10 is
100 – 0.3456 = 1 – 0.3456 = 0.6544
10’ l t f d b l i ll
Dr. M. G. Abbas Malik – COMSATS Lahore5
10’s complement can formed by leaving all
least significant ZEROS unchanged,
subtracting the first non-zero least significant
digit from 10, and then subtracting all other
higher significant digits from 9.
Complements
r’s complements
Example 2: Binary numbers
The 2’s (r’s) complement of (101100)2 is
(26)10 – (101100)2 = (1000000 - 101100)2
= (010100)2
Dr. M. G. Abbas Malik – COMSATS Lahore6
= (010100)2
The 2’s complement of (0.0110)2 is
(20)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 digit
unchanged, and then replacing 1’s by 0’s and 0’s
by 1’s in all other higher significant digits.
2/21/2011
3
Complements
(r-1)’s complements
r is the base of our number system.
X 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 X
Dr. M. G. Abbas Malik – COMSATS Lahore7
The (r-1)’s complement of X is defined as rn – r-m – X
Example 1: Decimal numbers
1234.765
Integral
Part
Fractional
Part
Decimal Number:
9’s (r-1’s) complement
= 104 – 10-3 - 1234.765
= 10000 – 0.001 – 1234.765
= 8765.234
Complements
(r-1)’s complements
Example 1: Decimal numbers (cont…)
The 9’s complement of (0.3456)10 is
100 – 10-4 – 0.3456 = 1 – 0.0001 - 0.3456
0 6543
Dr. M. G. Abbas Malik – COMSATS Lahore8
= 0.6543
9’s complement of a decimal number is
formed by subtracting every digit by 9.
Complements
(r-1)’s complements
Example 2: Binary numbers
The 1’s complement of (101100)2 is
(26 – 20)10 – (101100)2 = (1000000 – 1 – 101100)2
= (111111 – 101100)2 = (010011)2
Dr. M. G. Abbas Malik – COMSATS Lahore9
= (111111 – 101100)2 = (010011)2
The 1’s complement of (0.0110)2 is
(20 – 2-4)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 by
0’s and 0’s by 1’s.
2/21/2011
4
Complements
Conversions
r’s complement to (r-1)’s complement
‘ l t
Dr. M. G. Abbas Malik – COMSATS Lahore10
r‘s complement – r-m
(r-1)’s complement to r’s complement
(r-1)‘s complement + r-m
Subtraction
General Subtraction
246
– 138
-----
108
Minuend
Subtrahend
Dr. M. G. Abbas Malik – COMSATS Lahore11
108
In general, when the minuend digit is smaller than
the corresponding subtrahend digit, we borrow 1
from the higher significant position.
This is easier when people perform subtraction
with paper and pencil.
This method is less efficient in digital systems.
Subtraction with Complements
With 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 the
Dr. M. G. Abbas Malik – COMSATS Lahore12
p
subtrahend Y.
2. Inspect the result obtained in step 1 for an end
carry
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.
2/21/2011
5
Subtraction with Complements
With r’s Complement
Example 1 – Decimal numbers
X = 72532
Y = 3250
72532
Dr. M. G. Abbas Malik – COMSATS Lahore13
10’ complement of 03250 = + 96750
69282End carry → 1
Answer of X – Y = 69282
Subtraction with Complements
With r’s Complement
Example 1 – Decimal numbers
X = 3250
Y = 72532
03250
Dr. M. G. Abbas Malik – COMSATS Lahore14
10’ complement of 72532 = + 27468
30718No end carry
Answer of X – Y = – 10’s complement of 30718 = – 69282
Subtraction with Complements
Number of digits in X and Y must be
same. Before taking the r’s complement
of Subtrahend (Y), if Y has less number
of digits, then we add ZEROS to the left
Dr. M. G. Abbas Malik – COMSATS Lahore15
g
of the number and take r’s complement
considering newly added ZEROS as
part of the number.
2/21/2011
6
Subtraction with Complements
With r’s Complement
Example 2 – Binary numbers
X = 1010100
Y = 100100
1010100
Dr. M. G. Abbas Malik – COMSATS Lahore16
2’s complement of 0100100 = + 1011100
0110000End carry → 1
Answer of X – Y = 110000
Subtraction with Complements
With r’s Complement
Example 2 – Binary numbers
X = 100100
Y = 1010100
0100100
Dr. M. G. Abbas Malik – COMSATS Lahore17
2’s complement of 1010100 = + 0101100
1010000No end carry
Answer = – 2’s complement of 1010000 = – 110000
Subtraction with Complements
With (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
Dr. M. G. Abbas Malik – COMSATS Lahore18
( ) p
the subtrahend Y.
2. Inspect the result obtained in step 1 for an end
carry
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.
2/21/2011
7
Subtraction with Complements
With (r-1)’s Complement
Example 1 – Decimal numbers
X = 72532
Y = 3250
72532
Dr. M. G. Abbas Malik – COMSATS Lahore19
9’s complement of 03250 = + 96749
69281End carry → 1
Answer of X – Y = 69282
+
Subtraction with Complements
With (r-1)’s Complement
Example 1 – Decimal numbers
X = 3250
Y = 72532
03250
Dr. M. G. Abbas Malik – COMSATS Lahore20
9’s complement of 72532 = + 27467
30717No end carry
Answer of X – Y = – 9’s complement of 30718 = – 69282
Subtraction with Complements
Number of digits in X and Y must be
same. Before taking the r’s complement
of Subtrahend (Y), if Y has less number
of digits, then we add ZEROS to the left
Dr. M. G. Abbas Malik – COMSATS Lahore21
g
of the number and take r’s complement
considering newly added ZEROS as
part of the number.
2/21/2011
8
Subtraction with Complements
With (r-1)’s Complement
Example 2 – Binary numbers
X = 1010100
Y = 100100
1010100
Dr. M. G. Abbas Malik – COMSATS Lahore22
1’ complement of 0100100 = + 1011011
0101111End carry → 1
Answer of X – Y = 110000
+
Subtraction with Complements
With (r-1)’s Complement
Example 2 – Binary numbers
X = 100100
Y = 1010100
0100100
Dr. M. G. Abbas Malik – COMSATS Lahore23
1’ complement of 1010100 = + 0101011
1001111No end carry
Answer = – 1’s complement of 1010000 = – 110000
Complements in Digital Systems
2’s complement 1’s complement
1. Harder to implement
2. Subtraction take only
one arithmetic
1. Easier to implement
2. Subtraction takes two
arithmetic additions
Dr. M. G. Abbas Malik – COMSATS Lahore24
addition
3. Possesses only one
arithmetic 0
4. Used only in
conjunction with
arithmetic applications
3. Possesses two
arithmetic zeros: one
with all 0s and one
with all 1s
4. Useful in logical
manipulation: change
of 1’s to 0’s - inversion
2/21/2011
9
Binary Codes
Electronic 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
Dr. M. G. Abbas Malik – COMSATS Lahore25
equivalent to 1 or 0.
Digital system not only manipulate binary numbers,
but also many other discrete elements of information.
o Colors
o Decimal digits
o Alphabets (English, French, Urdu, Hindi, Punjabi, etc.)
Binary Codes
A bit is a binary digit.
To represent a group of 2n distinct discrete
elements in a binary code requires a minimum of
n bits.
Example 1: Color Codes
Dr. M. G. Abbas Malik – COMSATS Lahore26
Example 1: Color Codes
Consider we have four colors: RED, GREEN,
BLACK and BLUE
We want to assign a binary code to each color, so
that we can represent these information in our
digital system
Binary Codes
Example 1: Color Codes (cont…)
We have total 4 = 22 distinct discrete elements.
It means we need minimum 2 bits to represent
these four colors.
Dr. M. G. Abbas Malik – COMSATS Lahore27
Color Binary Code
Black 00
Blue 01
Green 10
Red 11
2/21/2011
10
Binary Codes
Example 2: Binary Coded Decimal (BCD)
Binary code for decimal digits require a minimum
4 bits as 24 = 16 > 10 > 8 = 23
Bit required Number of Discrete Elements
0 1
Dr. M. G. Abbas Malik – COMSATS Lahore28
1 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
Binary Codes
Example 2: Binary Coded Decimal (BCD)
Binary code for decimal digits require a minimum
4 bits as 24 = 16 > 10 > 8 = 23
Decimal Digit BCD Decimal Digit BCD
Dr. M. G. Abbas Malik – COMSATS Lahore29
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
binary codes: Error-Detection, Reflected & Alphanumeric Codes (Section1-6)
Binary Codes
Difference 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,
but they are different.
Bi C i Bi C d
Dr. M. G. Abbas Malik – COMSATS Lahore30
Binary Conversion
Conversion of decimal
number 24 in binary is
(11000)2
Binary Codes
Binary code of decimal
number 24 in BCS is
(0010 0100)2
2/21/2011
11
Binary Storage and Registers
Binary Cell is a device that possesses two stable
states and is capable of storing one bit of
information.
o In Electronics, it is a flip-flop circuit, ferrite core use
in memory
Dr. M. G. Abbas Malik – COMSATS Lahore31
y
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
Binary Storage and Registers
1 bit = 1 binary cell
1 byte = 8 bits
Register size depends on the computer system
architecture.
1. 8 bits architecture – register size is 8 bits
Dr. M. G. Abbas Malik – COMSATS Lahore32
g
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
registers.
Assignment # 2 (available on course website)
Registers
A register with n binary cells can stores any
discrete quantity of information that contains n
bits.
This is a 16-cells register
Dr. M. G. Abbas Malik – COMSATS Lahore33
If contains the BCD information then it represent
the decimal number 8369
1 0 0 0 0 0 1 1 0 1 1 0 1 0 0 1
8 3 6 9
2/21/2011
12
Register
Memory (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 the
Dr. M. G. Abbas Malik – COMSATS Lahore34
number (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
The control unit uses registers to keep track of
various computer sequences
Every input and output device must have at least one
register to store the information transferred to or from
the device
Register Transfer
Dr. M. G. Abbas Malik – COMSATS Lahore35
Register Transfer
Dr. M. G. Abbas Malik – COMSATS Lahore36
2/21/2011
13
Logic
NOT
AND
OR
Dr. M. G. Abbas Malik – COMSATS Lahore37
Logic Gates
Dr. M. G. Abbas Malik – COMSATS Lahore38
Image Source: http://images.wikia.com/bmet/images/a/ab/Logic_gate.gif

Mais conteúdo relacionado

Mais procurados

decoder and encoder
 decoder and encoder decoder and encoder
decoder and encoderUnsa Shakir
 
Encoders and decoders
Encoders and decodersEncoders and decoders
Encoders and decodersDeepikaDG1
 
Multiplexer and De-Multiplexer
Multiplexer and De-MultiplexerMultiplexer and De-Multiplexer
Multiplexer and De-MultiplexerAllied TS
 
Design half ,full Adder and Subtractor
Design half ,full Adder and SubtractorDesign half ,full Adder and Subtractor
Design half ,full Adder and SubtractorJaimin@prt.ltd.
 
Complement in DLD
Complement in DLDComplement in DLD
Complement in DLDshahzad ali
 
Latch & Flip-Flop Design.pptx
Latch & Flip-Flop Design.pptxLatch & Flip-Flop Design.pptx
Latch & Flip-Flop Design.pptxGargiKhanna2
 
Sequential Logic Circuit
Sequential Logic CircuitSequential Logic Circuit
Sequential Logic CircuitRamasubbu .P
 
Binary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithmBinary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithmPrasenjit Dey
 
1's and 2's complement
1's and 2's complement 1's and 2's complement
1's and 2's complement Shiraz Azeem
 
Floating point presentation
Floating point presentationFloating point presentation
Floating point presentationSnehalataAgasti
 
Power series convergence ,taylor & laurent's theorem
Power series  convergence ,taylor & laurent's theoremPower series  convergence ,taylor & laurent's theorem
Power series convergence ,taylor & laurent's theoremPARIKH HARSHIL
 

Mais procurados (20)

Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
 
decoder and encoder
 decoder and encoder decoder and encoder
decoder and encoder
 
Encoders and decoders
Encoders and decodersEncoders and decoders
Encoders and decoders
 
Multiplexer and De-Multiplexer
Multiplexer and De-MultiplexerMultiplexer and De-Multiplexer
Multiplexer and De-Multiplexer
 
Design half ,full Adder and Subtractor
Design half ,full Adder and SubtractorDesign half ,full Adder and Subtractor
Design half ,full Adder and Subtractor
 
Presentation On Flip-Flop
Presentation On Flip-FlopPresentation On Flip-Flop
Presentation On Flip-Flop
 
Complement in DLD
Complement in DLDComplement in DLD
Complement in DLD
 
decade counter
decade counterdecade counter
decade counter
 
Latch & Flip-Flop Design.pptx
Latch & Flip-Flop Design.pptxLatch & Flip-Flop Design.pptx
Latch & Flip-Flop Design.pptx
 
Sequential circuits
Sequential circuitsSequential circuits
Sequential circuits
 
1s and 2s complement
1s and 2s complement1s and 2s complement
1s and 2s complement
 
Digital Logic Design
Digital Logic Design Digital Logic Design
Digital Logic Design
 
Sequential Logic Circuit
Sequential Logic CircuitSequential Logic Circuit
Sequential Logic Circuit
 
Binary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithmBinary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithm
 
Flipflop
FlipflopFlipflop
Flipflop
 
1's and 2's complement
1's and 2's complement 1's and 2's complement
1's and 2's complement
 
Logic families
Logic familiesLogic families
Logic families
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
Floating point presentation
Floating point presentationFloating point presentation
Floating point presentation
 
Power series convergence ,taylor & laurent's theorem
Power series  convergence ,taylor & laurent's theoremPower series  convergence ,taylor & laurent's theorem
Power series convergence ,taylor & laurent's theorem
 

Destaque (20)

Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Dld lecture module 03
Dld lecture module 03Dld lecture module 03
Dld lecture module 03
 
Uncdtalk
UncdtalkUncdtalk
Uncdtalk
 
Dld lecture module 05
Dld lecture module 05Dld lecture module 05
Dld lecture module 05
 
English 01 application
English 01 applicationEnglish 01 application
English 01 application
 
Dld lecture module 01
Dld lecture module 01Dld lecture module 01
Dld lecture module 01
 
Number+system (1)
Number+system (1)Number+system (1)
Number+system (1)
 
Dld lecture module 06
Dld lecture module 06Dld lecture module 06
Dld lecture module 06
 
Graphical programming
Graphical programmingGraphical programming
Graphical programming
 
Chapter10
Chapter10Chapter10
Chapter10
 
Dld lecture module 02
Dld lecture module 02Dld lecture module 02
Dld lecture module 02
 
Basic+machine+organization
Basic+machine+organizationBasic+machine+organization
Basic+machine+organization
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
 
Good
GoodGood
Good
 
Dld lecture module 04 01
Dld lecture module 04  01Dld lecture module 04  01
Dld lecture module 04 01
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Internet
InternetInternet
Internet
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
An introduction to software
An introduction to softwareAn introduction to software
An introduction to software
 

Semelhante a Complement

Digital logic and design 02
Digital logic and design 02Digital logic and design 02
Digital logic and design 02ranjit shrestha
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1Deepak John
 
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
 
IRJET- An Extensive Review on Residue Number System for Improving Computer Ar...
IRJET- An Extensive Review on Residue Number System for Improving Computer Ar...IRJET- An Extensive Review on Residue Number System for Improving Computer Ar...
IRJET- An Extensive Review on Residue Number System for Improving Computer Ar...IRJET Journal
 
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
 
digital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxdigital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxRameshK531901
 
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
 
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
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Ra'Fat Al-Msie'deen
 
Physics investigatory project for class 12 logic gates
Physics investigatory project for class 12 logic gatesPhysics investigatory project for class 12 logic gates
Physics investigatory project for class 12 logic gatesbiswanath dehuri
 
Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic designgoutamkrsahoo
 
Digital Fundamental Learning for the Students
Digital Fundamental Learning for the StudentsDigital Fundamental Learning for the Students
Digital Fundamental Learning for the Studentsshaival
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxSurendra Loya
 

Semelhante a Complement (20)

Digital logic and design 02
Digital logic and design 02Digital logic and design 02
Digital logic and design 02
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
 
Lecture_5-2.ppt
Lecture_5-2.pptLecture_5-2.ppt
Lecture_5-2.ppt
 
Number System
Number SystemNumber System
Number System
 
digital-180612132737.pdf
digital-180612132737.pdfdigital-180612132737.pdf
digital-180612132737.pdf
 
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
 
DIGITAL DESIGN
DIGITAL DESIGNDIGITAL DESIGN
DIGITAL DESIGN
 
IRJET- An Extensive Review on Residue Number System for Improving Computer Ar...
IRJET- An Extensive Review on Residue Number System for Improving Computer Ar...IRJET- An Extensive Review on Residue Number System for Improving Computer Ar...
IRJET- An Extensive Review on Residue Number System for Improving Computer Ar...
 
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
 
digital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxdigital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptx
 
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
 
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
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
 
Physics investigatory project for class 12 logic gates
Physics investigatory project for class 12 logic gatesPhysics investigatory project for class 12 logic gates
Physics investigatory project for class 12 logic gates
 
Data Representation
Data RepresentationData Representation
Data Representation
 
Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic design
 
Digital Fundamental Learning for the Students
Digital Fundamental Learning for the StudentsDigital Fundamental Learning for the Students
Digital Fundamental Learning for the Students
 
Digital Systems.pptx
Digital Systems.pptxDigital Systems.pptx
Digital Systems.pptx
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
 
Number Systems
Number SystemsNumber Systems
Number Systems
 

Mais de Bilal Maqbool ツ

Programming assignment 02 (bilal maqbool 10) 2011
Programming assignment 02    (bilal maqbool 10) 2011Programming assignment 02    (bilal maqbool 10) 2011
Programming assignment 02 (bilal maqbool 10) 2011Bilal Maqbool ツ
 
Programming assignment 30 12-11
Programming assignment 30 12-11Programming assignment 30 12-11
Programming assignment 30 12-11Bilal Maqbool ツ
 
Presentation internet programming report
Presentation internet programming reportPresentation internet programming report
Presentation internet programming reportBilal Maqbool ツ
 
How internet technology be used to spread scientific awareness among pakistan...
How internet technology be used to spread scientific awareness among pakistan...How internet technology be used to spread scientific awareness among pakistan...
How internet technology be used to spread scientific awareness among pakistan...Bilal Maqbool ツ
 
Advantages and disadvantages of LCD
Advantages and disadvantages of LCDAdvantages and disadvantages of LCD
Advantages and disadvantages of LCDBilal Maqbool ツ
 
Computing assignment 02 ms access (bilal maqbool 10) se-i
Computing assignment 02   ms access (bilal maqbool 10)          se-iComputing assignment 02   ms access (bilal maqbool 10)          se-i
Computing assignment 02 ms access (bilal maqbool 10) se-iBilal Maqbool ツ
 
Bilal maqbool assignment no.01 computing
Bilal maqbool assignment no.01 computingBilal maqbool assignment no.01 computing
Bilal maqbool assignment no.01 computingBilal Maqbool ツ
 

Mais de Bilal Maqbool ツ (19)

Lecture 3 report writtng
Lecture 3 report writtngLecture 3 report writtng
Lecture 3 report writtng
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1 report writing
Lecture 1 report writingLecture 1 report writing
Lecture 1 report writing
 
Bill gates
Bill gatesBill gates
Bill gates
 
Programming assignment 02 (bilal maqbool 10) 2011
Programming assignment 02    (bilal maqbool 10) 2011Programming assignment 02    (bilal maqbool 10) 2011
Programming assignment 02 (bilal maqbool 10) 2011
 
Programming assignment 30 12-11
Programming assignment 30 12-11Programming assignment 30 12-11
Programming assignment 30 12-11
 
Internet presentation
Internet presentationInternet presentation
Internet presentation
 
Presentation internet programming report
Presentation internet programming reportPresentation internet programming report
Presentation internet programming report
 
Magnetic storage devices
Magnetic storage devicesMagnetic storage devices
Magnetic storage devices
 
How internet technology be used to spread scientific awareness among pakistan...
How internet technology be used to spread scientific awareness among pakistan...How internet technology be used to spread scientific awareness among pakistan...
How internet technology be used to spread scientific awareness among pakistan...
 
Math assignment Program
Math assignment ProgramMath assignment Program
Math assignment Program
 
Final of sentences PPT
Final of sentences PPTFinal of sentences PPT
Final of sentences PPT
 
Advantages and disadvantages of LCD
Advantages and disadvantages of LCDAdvantages and disadvantages of LCD
Advantages and disadvantages of LCD
 
A history of windows
A history of windowsA history of windows
A history of windows
 
Lcd
LcdLcd
Lcd
 
Bluetooth 27 01-12 PPT
Bluetooth 27 01-12 PPTBluetooth 27 01-12 PPT
Bluetooth 27 01-12 PPT
 
Bluetooth PPT Report
Bluetooth PPT ReportBluetooth PPT Report
Bluetooth PPT Report
 
Computing assignment 02 ms access (bilal maqbool 10) se-i
Computing assignment 02   ms access (bilal maqbool 10)          se-iComputing assignment 02   ms access (bilal maqbool 10)          se-i
Computing assignment 02 ms access (bilal maqbool 10) se-i
 
Bilal maqbool assignment no.01 computing
Bilal maqbool assignment no.01 computingBilal maqbool assignment no.01 computing
Bilal maqbool assignment no.01 computing
 

Último

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Último (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Complement

  • 1. 2/21/2011 1 Dr M G Abbas Malik Digital Logic and Design (EEE-241) 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 Previous lecture Digital Vs. Analog Digital System – example digital computer Discrete values and binary values Number system (positional and non-positional) Dr. M. G. Abbas Malik – COMSATS Lahore2 Binary number system Conversion, addition, subtraction, multiplication, division. Octal number system (conversion) Hexadecimal number system (conversion) Complements Complements 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 complement Dr. M. G. Abbas Malik – COMSATS Lahore3 2. (r-1) s complement Example For 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.
  • 2. 2/21/2011 2 Complements r’s complements r is the base of our number system. X 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 0 Dr. M. G. Abbas Malik – COMSATS Lahore4 The r’s complement of X is defined as rn – X for X≠0 and 0 for X=0. Example 1: Decimal numbers 1234.765 Integral Part Fractional Part Decimal Number: 10’s (r’s) complement = 104 - 1234.765 = 8765.235 Complements r’s complements Example 1: Decimal numbers (cont…) The 10’s complement of (0.3456)10 is 100 – 0.3456 = 1 – 0.3456 = 0.6544 10’ l t f d b l i ll Dr. M. G. Abbas Malik – COMSATS Lahore5 10’s complement can formed by leaving all least significant ZEROS unchanged, subtracting the first non-zero least significant digit from 10, and then subtracting all other higher significant digits from 9. Complements r’s complements Example 2: Binary numbers The 2’s (r’s) complement of (101100)2 is (26)10 – (101100)2 = (1000000 - 101100)2 = (010100)2 Dr. M. G. Abbas Malik – COMSATS Lahore6 = (010100)2 The 2’s complement of (0.0110)2 is (20)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 digit unchanged, and then replacing 1’s by 0’s and 0’s by 1’s in all other higher significant digits.
  • 3. 2/21/2011 3 Complements (r-1)’s complements r is the base of our number system. X 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 X Dr. M. G. Abbas Malik – COMSATS Lahore7 The (r-1)’s complement of X is defined as rn – r-m – X Example 1: Decimal numbers 1234.765 Integral Part Fractional Part Decimal Number: 9’s (r-1’s) complement = 104 – 10-3 - 1234.765 = 10000 – 0.001 – 1234.765 = 8765.234 Complements (r-1)’s complements Example 1: Decimal numbers (cont…) The 9’s complement of (0.3456)10 is 100 – 10-4 – 0.3456 = 1 – 0.0001 - 0.3456 0 6543 Dr. M. G. Abbas Malik – COMSATS Lahore8 = 0.6543 9’s complement of a decimal number is formed by subtracting every digit by 9. Complements (r-1)’s complements Example 2: Binary numbers The 1’s complement of (101100)2 is (26 – 20)10 – (101100)2 = (1000000 – 1 – 101100)2 = (111111 – 101100)2 = (010011)2 Dr. M. G. Abbas Malik – COMSATS Lahore9 = (111111 – 101100)2 = (010011)2 The 1’s complement of (0.0110)2 is (20 – 2-4)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 by 0’s and 0’s by 1’s.
  • 4. 2/21/2011 4 Complements Conversions r’s complement to (r-1)’s complement ‘ l t Dr. M. G. Abbas Malik – COMSATS Lahore10 r‘s complement – r-m (r-1)’s complement to r’s complement (r-1)‘s complement + r-m Subtraction General Subtraction 246 – 138 ----- 108 Minuend Subtrahend Dr. M. G. Abbas Malik – COMSATS Lahore11 108 In general, when the minuend digit is smaller than the corresponding subtrahend digit, we borrow 1 from the higher significant position. This is easier when people perform subtraction with paper and pencil. This method is less efficient in digital systems. Subtraction with Complements With 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 the Dr. M. G. Abbas Malik – COMSATS Lahore12 p subtrahend Y. 2. Inspect the result obtained in step 1 for an end carry 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.
  • 5. 2/21/2011 5 Subtraction with Complements With r’s Complement Example 1 – Decimal numbers X = 72532 Y = 3250 72532 Dr. M. G. Abbas Malik – COMSATS Lahore13 10’ complement of 03250 = + 96750 69282End carry → 1 Answer of X – Y = 69282 Subtraction with Complements With r’s Complement Example 1 – Decimal numbers X = 3250 Y = 72532 03250 Dr. M. G. Abbas Malik – COMSATS Lahore14 10’ complement of 72532 = + 27468 30718No end carry Answer of X – Y = – 10’s complement of 30718 = – 69282 Subtraction with Complements Number of digits in X and Y must be same. Before taking the r’s complement of Subtrahend (Y), if Y has less number of digits, then we add ZEROS to the left Dr. M. G. Abbas Malik – COMSATS Lahore15 g of the number and take r’s complement considering newly added ZEROS as part of the number.
  • 6. 2/21/2011 6 Subtraction with Complements With r’s Complement Example 2 – Binary numbers X = 1010100 Y = 100100 1010100 Dr. M. G. Abbas Malik – COMSATS Lahore16 2’s complement of 0100100 = + 1011100 0110000End carry → 1 Answer of X – Y = 110000 Subtraction with Complements With r’s Complement Example 2 – Binary numbers X = 100100 Y = 1010100 0100100 Dr. M. G. Abbas Malik – COMSATS Lahore17 2’s complement of 1010100 = + 0101100 1010000No end carry Answer = – 2’s complement of 1010000 = – 110000 Subtraction with Complements With (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 Dr. M. G. Abbas Malik – COMSATS Lahore18 ( ) p the subtrahend Y. 2. Inspect the result obtained in step 1 for an end carry 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.
  • 7. 2/21/2011 7 Subtraction with Complements With (r-1)’s Complement Example 1 – Decimal numbers X = 72532 Y = 3250 72532 Dr. M. G. Abbas Malik – COMSATS Lahore19 9’s complement of 03250 = + 96749 69281End carry → 1 Answer of X – Y = 69282 + Subtraction with Complements With (r-1)’s Complement Example 1 – Decimal numbers X = 3250 Y = 72532 03250 Dr. M. G. Abbas Malik – COMSATS Lahore20 9’s complement of 72532 = + 27467 30717No end carry Answer of X – Y = – 9’s complement of 30718 = – 69282 Subtraction with Complements Number of digits in X and Y must be same. Before taking the r’s complement of Subtrahend (Y), if Y has less number of digits, then we add ZEROS to the left Dr. M. G. Abbas Malik – COMSATS Lahore21 g of the number and take r’s complement considering newly added ZEROS as part of the number.
  • 8. 2/21/2011 8 Subtraction with Complements With (r-1)’s Complement Example 2 – Binary numbers X = 1010100 Y = 100100 1010100 Dr. M. G. Abbas Malik – COMSATS Lahore22 1’ complement of 0100100 = + 1011011 0101111End carry → 1 Answer of X – Y = 110000 + Subtraction with Complements With (r-1)’s Complement Example 2 – Binary numbers X = 100100 Y = 1010100 0100100 Dr. M. G. Abbas Malik – COMSATS Lahore23 1’ complement of 1010100 = + 0101011 1001111No end carry Answer = – 1’s complement of 1010000 = – 110000 Complements in Digital Systems 2’s complement 1’s complement 1. Harder to implement 2. Subtraction take only one arithmetic 1. Easier to implement 2. Subtraction takes two arithmetic additions Dr. M. G. Abbas Malik – COMSATS Lahore24 addition 3. Possesses only one arithmetic 0 4. Used only in conjunction with arithmetic applications 3. Possesses two arithmetic zeros: one with all 0s and one with all 1s 4. Useful in logical manipulation: change of 1’s to 0’s - inversion
  • 9. 2/21/2011 9 Binary Codes Electronic 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 Dr. M. G. Abbas Malik – COMSATS Lahore25 equivalent to 1 or 0. Digital system not only manipulate binary numbers, but also many other discrete elements of information. o Colors o Decimal digits o Alphabets (English, French, Urdu, Hindi, Punjabi, etc.) Binary Codes A bit is a binary digit. To represent a group of 2n distinct discrete elements in a binary code requires a minimum of n bits. Example 1: Color Codes Dr. M. G. Abbas Malik – COMSATS Lahore26 Example 1: Color Codes Consider we have four colors: RED, GREEN, BLACK and BLUE We want to assign a binary code to each color, so that we can represent these information in our digital system Binary Codes Example 1: Color Codes (cont…) We have total 4 = 22 distinct discrete elements. It means we need minimum 2 bits to represent these four colors. Dr. M. G. Abbas Malik – COMSATS Lahore27 Color Binary Code Black 00 Blue 01 Green 10 Red 11
  • 10. 2/21/2011 10 Binary Codes Example 2: Binary Coded Decimal (BCD) Binary code for decimal digits require a minimum 4 bits as 24 = 16 > 10 > 8 = 23 Bit required Number of Discrete Elements 0 1 Dr. M. G. Abbas Malik – COMSATS Lahore28 1 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 Binary Codes Example 2: Binary Coded Decimal (BCD) Binary code for decimal digits require a minimum 4 bits as 24 = 16 > 10 > 8 = 23 Decimal Digit BCD Decimal Digit BCD Dr. M. G. Abbas Malik – COMSATS Lahore29 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 binary codes: Error-Detection, Reflected & Alphanumeric Codes (Section1-6) Binary Codes Difference 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, but they are different. Bi C i Bi C d Dr. M. G. Abbas Malik – COMSATS Lahore30 Binary Conversion Conversion of decimal number 24 in binary is (11000)2 Binary Codes Binary code of decimal number 24 in BCS is (0010 0100)2
  • 11. 2/21/2011 11 Binary Storage and Registers Binary Cell is a device that possesses two stable states and is capable of storing one bit of information. o In Electronics, it is a flip-flop circuit, ferrite core use in memory Dr. M. G. Abbas Malik – COMSATS Lahore31 y 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 Binary Storage and Registers 1 bit = 1 binary cell 1 byte = 8 bits Register size depends on the computer system architecture. 1. 8 bits architecture – register size is 8 bits Dr. M. G. Abbas Malik – COMSATS Lahore32 g 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 registers. Assignment # 2 (available on course website) Registers A register with n binary cells can stores any discrete quantity of information that contains n bits. This is a 16-cells register Dr. M. G. Abbas Malik – COMSATS Lahore33 If contains the BCD information then it represent the decimal number 8369 1 0 0 0 0 0 1 1 0 1 1 0 1 0 0 1 8 3 6 9
  • 12. 2/21/2011 12 Register Memory (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 the Dr. M. G. Abbas Malik – COMSATS Lahore34 number (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 The control unit uses registers to keep track of various computer sequences Every input and output device must have at least one register to store the information transferred to or from the device Register Transfer Dr. M. G. Abbas Malik – COMSATS Lahore35 Register Transfer Dr. M. G. Abbas Malik – COMSATS Lahore36
  • 13. 2/21/2011 13 Logic NOT AND OR Dr. M. G. Abbas Malik – COMSATS Lahore37 Logic Gates Dr. M. G. Abbas Malik – COMSATS Lahore38 Image Source: http://images.wikia.com/bmet/images/a/ab/Logic_gate.gif