Chapter-1 - Digital Systems and Binary Numbers PDF
Chapter-1 - Digital Systems and Binary Numbers PDF
Chapter 1
Digital Systems and Binary Numbers
gürtaçyemişçioğlu
2
OUTLINE OF CHAPTER 1
D I G I TA L S Y S T E M S
• Digital age and information age
• Digital computers
– General purposes
– Many scientific, industrial and commercial applications
• Digital systems
– Telephone switching exchanges
– Digital camera
– Electronic calculators, PDA's
– Digital TV
• Discrete information-processing systems
– Manipulate discrete elements of information
– For example, {1, 2, 3, …} and {A, B, C, …}…
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
5
D I G I TA L S Y S T E M S
D I G I TA L S I G N A L ANALOG SIGNAL
• The physical quantities or signals • The physical quantities or signals
can assume only discrete values. may vary continuously over a
t t
D I G I TA L S Y S T E M S
• Binary digital signal
– An information variable represented by physical quantity.
– For digital systems, the variable takes on discrete values.
• Two level, or binary values are the most prevalent values.
D I G I TA L S Y S T E M S
• Binary values are represented by values or ranges of values of
physical quantities.
V(t)
Logic 1
undefine
Logic 0
t
BINARY NUMBERS
Decimal Number System 5 1 2 7 4
• Base (also called radix) = 10
– 10 digits 102 101 100 10-1 10-2
– { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
• Digit Position 100 10 1 0.1 0.01
– Integer & fraction 5x100 1x10 2x1 7x0.1 4x0.01
• Digit Weight
– Weight = (Base) Position 500 + 10 + 2 0.7 + 0.04
• Magnitude
– Sum of “Digit x Weight” 2 1 0 -1 -2
d2 x B + d1 x B + d0 x B +d-1 x B +d-2x B
• Formal Notation
(512.74)10
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
10
BINARY NUMBERS
Octal Number System 5 1 2 7 4
• Base = 8
– 8 digits 82 81 80 8-1 8-2
– { 0, 1, 2, 3, 4, 5, 6, 7}
64 8 1 1/8 1/64
• Weights
5x64 1x8 2x1 7x1/8 4x1/64
– Weight = (Base) Position
• Magnitude
320 + 8 + 2 0.875 + 0.0625
– Sum of “Digit x Weight”
• Formal Notation o2 x B2 + o1 x B1 + o0 x B0 + o-1 x B-1+o-2 x B-2
(330.9375)10
(512.74)8
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
11
BINARY NUMBERS
Hexadecimal Number System 1 E 5 7 A
• Base = 16
– 16 digits { 0, 1, 2, 3, 4, 5, 6, 162 161 160 16-1 16-2
7, 8, 9, A, B, C, D, E, F}
256 16 1 1/16 1/256
• Weights
– Weight = (Base) Position 1x256 14x16 5x1 7x1/16 10x1/256
• Magnitude
– Sum of “bit x Weight” 256 + 224 + 5 0.4375 + 0.039
• Formal Notation H2 x B2 + H1 x B1 + H0 x B0+H-1 x B-1+H-2x B-2
(458.4765625)10
(1E5.7A)16
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
12
BINARY NUMBERS
Binary Number System 1 0 1 0 1
• Base = 2
– 2 digits { 0, 1 }, called binary 22 21 20 2-1 2-2
digits or “bits”
4 2 1 0.5 0.25
• Weights
– Weight = (Base) Position 1x4 0x2 1x1 0x0.5 1x0.25
• Magnitude
– Sum of “bit x Weight” 4 + 0 + 1 0 + 0.25
• Formal Notation b2 x B2 + b1 x B1 + b0 x B0+b-1 x B-1+b-2x B-2
• Groups of bits (5.25)10
– 4 bits = Nibble, 8 bits = Byte (101.01)2
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
13
BINARY NUMBERS
The power of 2
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024
3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M
6 26=64 30 230=1G
7 27=128 40 240=1T
BINARY ARITHMETIC
ADDITION
Decimal Addition
5 5
+ 5 5
= Ten ≥ Base
Subtract a Base
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
16
BINARY ARITHMETIC
ADDITION
Binary Addition - Column Addition
1 1 1 1 0 1
+ 1 0 1 1 1
≥ (2)10
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
17
BINARY ARITHMETIC
SUBTRACTION
Binary Subtraction - Borrow a “Base” when needed
1
0 0 0
1 0 0 1 1 0 1
− 1 0 1 1 1
BINARY ARITHMETIC
MULTIPLICATION
Binary Multiplication – Bit by bit
x 1 0 1 0
N U M B E R BA S E CO N V E R S I O N
Octal
(Base 8)
Evaluate
Decimal Magnitude Binary
(Base 10) (Base 2)
Hexadecimal
(Base 16)
N U M B E R BA S E CO N V E R S I O N
N U M B E R BA S E CO N V E R S I O N
Decimal (integer) to binary conversion
Example: (13)10
Quotient Remainder Coefficient
13 / 2 = 6 1 a0 = 1
6 /2= 3 0 a1 = 0
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (13)10 = (a3 a2 a1 a0)2 = (1101)2
MSB LSB
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
23
N U M B E R BA S E CO N V E R S I O N
N U M B E R BA S E CO N V E R S I O N
Decimal (fraction) to binary conversion
Example: (0.625)10
MSB LSB
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
25
N U M B E R BA S E CO N V E R S I O N
Decimal (integer) to octal conversion
Example: (175)10
Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2/ 8 = 0 2 a2 = 2
MSB LSB
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
26
N U M B E R BA S E CO N V E R S I O N
Decimal (fraction) to octal conversion
Example: (0.3125)10
MSB LSB
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
1.5 OCTAL &
HEXADECIMAL
NUMBERS
28
O C TA L & H E X A D E C I M A L N U M B E R S
• Binary to octal conversion Octal Binary
• 8 = 23 0 000
• Each group of 3 bits represents an octal 1 001
digit 2 010
Example: Assume Zeros
3 011
(01 0 1 1 0 . 0 10)2 4 100
5 101
6 110
7 111
( 2 6 . 2 )8
Works both ways (Binary to Octal & Octal to Binary)
6 October, 2016 DIGITAL INTEGRATED CIRCUIT DESIGN
29
O C TA L & H E X A D E C I M A L N U M B E R S
Hex Binary
1
0000
0001
• 16 = 24 2 0010
3 0011
• Each group of 4 bits represents a 4 0100
7 0111
8 1000
( 0001 0 1 1 0 . 0 1 00 )2 9 1001
A 1010
B 1011
C 1100
D 1101
( 1 6 . 4 )16 E 1110
F 1111
Works both ways (Binary to Hex & Hex to Binary)
6 October, 2016 DIGITAL INTEGRATED CIRCUIT DESIGN
30
O C TA L & H E X A D E C I M A L N U M B E R S
Example: ( 2 6 . 2 )8
• Octal to hexadecimal
conversion
intermediate step
( 0 0 0 1 0 1 1 0 . 0 1 0 0 )2
( 1 6 . 4 )16
O C TA L & H E X A D E C I M A L N U M B E R S
Decimal Octal Hex Binary
00 00 0 0000
01 01 1 0001
02 02 2 0010
03 03 3 0011
04 04 4 0100
05 05 5 0101
06 06 6 0110
07 07 7 0111
08 10 8 1000
09 11 9 1001
10 12 A 1010
11 13 B 1011
12 14 C 1100
13 15 D 1101
14 16 E 1110
15 17 F 1111
CO M P L E M E N T S
CO M P L E M E N T S
(rn –1) – N
CO M P L E M E N T S
CO M P L E M E N T S
CO M P L E M E N T S
• Observation:
CO M P L E M E N T S
1 0 1 1 0 0 0 0
+ 0 1 0 0 1 1 1 1
1 1 1 1 1 1 1 1
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
39
CO M P L E M E N T S
CO M P L E M E N T S
CO M P L E M E N T S
• Example: Base-10
CO M P L E M E N T S
• 2’s Complement (Radix Complement)
– Take 1’s complement then add 1
– Toggle all bits to the left of the first ‘1’ from the right
Example:
Number: 1 0 1 1 0 0 0 0
1’s Comp.: 1 0 1 1 0 0 0 0
0 1 0 0 1 1 1 1
+ 1
0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0
CO M P L E M E N T S
• Example: Base-2
CO M P L E M E N T S
• Example: Base-2
0 1 1 0 1 1 1
0 1 1 0 1 1 1
1 0 0 1 0 0 0
+ 1
1 0 0 1 0 0 1 1 0 0 1 0 0 1
CO M P L E M E N T S
– r n - ( r n - N ) = N original number
CO M P L E M E N T S
• The subtraction of two n-digit unsigned numbers M – N in base r
can be done as follows:
1. Add the minuend M to the r’s complement of the subtrahend N.
o N r’s complement = rn-N
o = M + rn-N
o = M – N+rn
2. If M ≥ N, the sum will produce an end carry rn, which can be
discarded; what is left is the result M – N.
3. If M < N, the sum does not produce an end carry and is equal to rn-
(N-M), which is the r’s complement of (N-M). To obtain the answer in
a familiar form, take the r’s complement of the sum and place
negative sign in front.
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
47
CO M P L E M E N T
• Example 1.5
– Using 10's complement, subtract 72532 – 3250.
M = 72532 N = 3250
Step1: Take 10’s complement of N
9 9 9 10 0
- 3 2 5 0
9 6 7 5 0
CO M P L E M E N T
Step2: To find the SUM, Add 10’s complement of N to M
72532
+ 96750
SUM= 169282
Step3: To find the ANSWER discard end carry 105, Subtract rn from SUM
169282
- 100000
ANSWER= 69282
CO M P L E M E N T
• Example 1.6
– Using 10's complement, subtract 3250 - 72532.
M = 3250 N = 72532
Step1: Take 10’s complement of N
9 9 9 9 10
- 7 2 5 3 2
2 7 4 6 8
CO M P L E M E N T
Step2: To find the SUM, Add 10’s complement of N to M
03250
+ 27468
SUM= 30718
Step3: To find the ANSWER take the –(10’s complement of SUM)
9 9 9 9 10
- 3 0 7 1 8
6 9 2 8 2
ANSWER= - 6 9 2 8 2
CO M P L E M E N T
Example 1.7: Given the two binary numbers X = 1010100 and Y = 1000011,
perform the subtraction (a) X – Y and (b) Y – X using 2’s complements.
(a) Step1: Take the 2’s complement of Y
1 0 0 0 0 1 1
0 1 1 1 1 0 1
Step2: Add 2’s complement of Y to X
1 0 1 0 1 0 0
+ 0 1 1 1 1 0 1
1 0 0 1 0 0 0 1
CO M P L E M E N T
Step3: Discard the end carry.
1 0 0 1 0 0 0 1
+1 0 0 0 0 0 0 0
ANSWER= 0 0 0 1 0 0 0 1
0 1 0 1 1 0 0
CO M P L E M E N T
Step2: Add 2’s complement of X to Y
1 0 0 0 0 1 1
+ 0 1 0 1 1 0 0
SUM= 1 1 0 1 1 1 1
1 1 0 1 1 1 1
-0 0 1 0 0 0 1
CO M P L E M E N T S
• Subtraction of unsigned numbers can also be done by means of
the (r 1)'s complement. Remember that the (r 1) 's
complement is one less then the r's complement.
Example 1.8 :Repeat Example 1.7, but this time using 1's
complement.
(a) X – Y = 1010100 – 1000011(84 – 67 = 17)
Step1: Take the 1’s complement of Y
1 0 0 0 0 1 1
0 1 1 1 1 0 0
CO M P L E M E N T S
Step2: Add1’s complement of Y to the X
1 0 1 0 1 0 0
+ 0 1 1 1 1 0 0
SUM= 1 0 0 1 0 0 0 0 = 16
0 0 1 0 0 0 0
+ 1
ANSWER= 0 0 1 0 0 0 1 = 17
CO M P L E M E N T S
Example 1.8 :Repeat Example 1.7, but this time using 1's
complement.
(a) Y – X = 1000011 – 1010100 (67 – 84 = -17)
Step1: Take the 1’s complement of X
1 0 1 0 1 0 0
0 1 0 1 0 1 1
CO M P L E M E N T S
Step2: Add1’s complement of X to the Y
1 0 0 0 0 1 1
+ 0 1 0 1 0 1 1
SUM= 1 1 0 1 1 1 0
1 1 0 1 1 1 0
ANSWER= -0 0 1 0 0 0 1 = -17
-0 - 1111 1000
-8 1000 - -
• Arithmetic addition
– The addition of two numbers in the signed-magnitude system
follows the rules of ordinary arithmetic.
• If the signs are the same;
– we add the two magnitudes and give the sum the common sign.
• Example:
+ 6 0 0 0 0 0 1 1 0 - 6 1 1 1 1 1 0 1 0
+1 3 +0 0 0 0 1 1 0 1 +1 3 +0 0 0 0 1 1 0 1
+1 9 0 0 0 1 0 0 1 1 + 7 0 0 0 0 0 1 1 1
• Example:
+ 6 0 0 0 0 0 1 1 0 - 6 1 1 1 1 1 0 1 0
- 13 +1 1 1 1 0 0 1 1 - 13 +1 1 1 1 0 0 1 1
- 7 1 1 1 1 1 0 0 1 - 19 1 1 1 0 1 1 0 1
• Arithmetic Subtraction
– In 2’s-complement form:
1. Take the 2’s complement of the subtrahend (including the sign bit) and
add it to the minuend (including sign bit).
2. A carry out of sign-bit position is discarded.
(±A) – (+B) = (±A)+ −B
(±A) – (-B) = (±A)+ +B
- 6 1 1 1 1 1 0 1 0
+1 3 - 0 0 0 0 1 1 0 1
+ 7 0 0 0 0 0 1 1 1
B I N A R Y CO D E S
• BCD Code
– A number with k decimal digits will require 4k bits in BCD.
396
B I N A R Y CO D E S
Decimal Symbol BCD Digit
– A decimal number in BCD is
0 0000
the same as its equivalent 1 0001
binary number only when 2 0010
and 9. 4 0100
5 0101
– The binary combinations
6 0110
1010 through 1111 are not
7 0111
used and have no meaning 8 1000
in BCD. 9 1001
B I N A R Y CO D E S
• Example:
– Consider decimal 185 and its corresponding value in BCD and binary:
(185) 10
B I N A R Y CO D E S
• BCD Addition
– Consider the addition of two decimal digits in BCD
– Since each digit does not exceed 9
– The sum cannot be greater than 9 + 9 + 1 = 19
• the 1 in the sum being a previous carry
B I N A R Y CO D E S
• BCD Addition
– When binary sum is equal to or less than 1001 (without a carry)
• The corresponding BCD digit is correct
– The addition of 6 = (0110)2 to the binary sum converts it to the correct digit and
also produces a carry as required
– This is because the difference between a carry in the most significant bit position
of the binary sum and a decimal carry.
• 16 – 10 = 6
B I N A R Y CO D E S
• BCD Addition
– Consider the following three addition of two decimal digits in BCD
4 0 1 0 0 4 0 1 0 0 8 1 0 0 0
+ 5
9
+ 0
1 1
0
0
0
1
1
+ 8
12
+ 1
1
+ 0
0
1
1
0
0
1
1
0
0
+ 9
17
+ 1
1 0
+ 0
0
0 0 1
1 1 0
0 1
1 0 0 1 0 1 0 1 1 1
Carry Correct BCD Carry Correct BCD
digit sum (2) digit sum (7)
B I N A R Y CO D E S
• The addition of two n-digit unsigned BCD numbers follows the same
procedure.
– Consider the addition of 184 + 576 = 760 in BCD
1 1
0 0 0 1 1 0 0 0 0 1 0 0 1 8 4
+ 0 1 0 1 + 0 1 1 1 + 0 1 1 0 +5 7 6
Binary Sum 0 1 1 1 1 0 0 0 0 1 0 1 0
Add 6 + 0 1 1 0 + 0 1 1 0
BCD Sum 0 1 1 1 0 1 1 0 0 0 0 0 7 6 0
B I N A R Y CO D E S
• We can use either the familiar sign and magnitude system or the signed-
complement system.
B I N A R Y CO D E S
B I N A R Y CO D E S
• This assumes that all negative numbers are in 10’s complement form.
B I N A R Y CO D E S
B I N A R Y CO D E S
B I N A R Y CO D E S
• Gray code:
– The output data of many physical systems produce quantities that
are continuous.
– These data must be converted into digital form before they are
applied to a digital system.
– Continuous or analog information is converted into digital form by
means of an analog-to-digital converter.
X(t)
B I N A R Y CO D E S
Gray Code Decimal Equivalent
0001 1
– It is convenient to use gray 0011 2
code to represent the digital 0010 3
data when it is converted 0110 4
from analog data. 0111 5
1111 10
• Error detection.
1110 11
• Representation of analog 1010 12
data. 1011 13
• Low power design. 1001 14
1000 15
B I N A R Y CO D E S
• American Standard Code for Information Interchange (ASCII)
Character Code (Refer to Table 1.7)
• A popular code used to represent information sent as character-
based data.
• It uses 7-bits to represent 128 characters:
– 94 Graphic printing characters.
– 34 Non-printing characters.
• Some non-printing characters are used for text format (e.g. BS =
Backspace, CR = carriage return).
• Other non-printing characters are used for record marking and
flow control (e.g. STX and ETX start and end text areas).
B I N A R Y CO D E S
B I N A R Y CO D E S
B I N A R Y CO D E S
B I N A R Y CO D E S
• Error-Detecting Code
– To detect errors in data communication and processing, an eighth
bit is sometimes added to the ASCII character to indicate its parity.
– A parity bit is an extra bit included with a message to make the total
number of 1's either even or odd.
• Example:
– Consider the following two characters and their even and odd parity:
B I N A R Y CO D E S
• Error-Detecting Code
– Redundancy (e.g. extra information), in the form of extra bits, can be
incorporated into binary code words to detect and correct errors.
– A simple form of redundancy is parity, an extra bit appended onto the
code word to make the number of 1’s odd or even. Parity can detect all
single-bit errors and some multiple-bit errors.
– A code word has even parity if the number of 1’s in the code word is
even.
– A code word has odd parity if the number of 1’s in the code word is odd.
– Example:
• Message A: 10001001 1 (even parity)
• Message B: 10001001 0 (odd parity)
B I N A R Y S TO R AG E & R E G I S T E R S
• Registers
– A binary cell is a device that possesses two stable states and is
capable of storing one of the two states.
1/0
B I N A R Y S TO R AG E & R E G I S T E R S
• A binary cell
– Two stable state
– Store one bit of information
– Examples: flip-flop circuits, ferrite cores, capacitor
• A register
– A group of binary cells
– AX in x86 CPU
• Register Transfer
– A transfer of the information stored in one register to another.
– One of the major operations in digital system.
– An example in next slides.
B I N A R Y S TO R AG E & R E G I S T E R S
Memory
CPU
Control Unit Datapath
B I N A R Y S TO R AG E & R E G I S T E R
MEMORY UNIT
J O H N
PROCESSOR UNIT
INPUT UNIT
8 cells Input
Register
O
Keyboard H
Control
N
B I N A R Y S TO R AG E & R E G I S T E R S
MEMORY UNIT
SUM
0100100011 • The other major component
Operand1 of a digital system
0011100001
– Circuit elements to
Operand2
0001000010 manipulate individual bits of
information
– Load-store machine
0001000010 R1 LD R1;
Digital logic LD R2;
circuits for 0100100011 R3
binary addition
ADD R3, R2, R1;
SD R3;
0011100001 R2
PROCESSOR UNIT
Figure 1.2 Example of binary information processing
6 October, 2016 DIGITAL INTEGRATED CIRCUIT DESIGN
1.10 BINARY LOGIC
94
B I N A R Y LO G I C
B I N A R Y LO G I C
B I N A R Y LO G I C
“X OR Y is equal to Z”.
Z =1 if X = 1 OR Y = 1 or if both X = 1 OR Y = 1.
B I N A R Y LO G I C
B I N A R Y LO G I C
• Truth tables, Boolean expressions and Logic Gates
AND OR NOT
X Y Z X Y Z X Z
0 0 0 0 0 0 1 0
0 1 0 0 1 1 0 1
1 0 0 1 0 1
1 1 1 1 1 1
Z=X∙Y Z=X+Y X=Z
X X X Z
Z Z
Y Y
B I N A R Y LO G I C
AND OR
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
10
0
B I N A R Y LO G I C
• Example of binary signals
Volts
3
Signal
range for
logic 1 3
2 Logic 1
Transition occurs 2
between these limits
undefined
1
Signal
1
range for Logic 0
logic 0
0
0
6 October, 2016 INTRODUCTION TO LOGIC DESIGN
10
1
B I N A R Y LO G I C
• Graphic Symbols and Input-Output Signals for Logic gates:
X X X Z
Z Z
Y Y
(a) two input AND gate (b) two input OR gate (c) NOT gate or Inverter
0 1 1 0 0
X
0 0 1 1 0
Y
0 0 1 0 0
X∙Y
0 1 1 1 0
X+Y
X 1 0 0 1 0
B I N A R Y LO G I C
• Graphic Symbols and Input-Output Signals for many input logic gates:
A
A B
B F=A∙B∙C F=A+B+C+D
C C
D