DLD 3 4
DLD 3 4
3, 4
EE106 Computer Logic Design
Digital Computers and Information
Combinational Circuits
• Combination of Logic Gates
• Built for the desired functionality
• Output function of input only
• Memory-less (or state-less)
Functional Devices
• Example of Combinational Circuits
– Adders
– Comparators
– Encoders/Decoders
– Multiplexers/Demultiplexers
– Arithmetic Logic Unit
Sequential Circuits
• Memory Element (state information)
• Output function of input and previous state
• Flip-Flops
• Counters & Registers
Block Diagram of a Sequential
Circuit
Input 1
a1 b1
5
Output
Combinational
2 6
a2 b2
Logic Circuit
1 5
a1 b1
Memory Element
Programmable Logic Devices
(PLDs)
• Configurable Hardware
• Combinational Circuits
• Sequential Circuits
• Low chip count
• Lower Cost
• Short development time
Types of PLD
• Simple Programmable Logic Devices (SPLD)
– PAL, PLA, GAL, PROM
• Complex PLD (CPLD)
– Combo of SPLDs
• Field Programmable Gate Array (FPGA)
– Greatest logic capacity
– Course-grained – large logic blocks
– Fine-grained – small logic blocks
Memory
• Storage
• RAM (Random Access Memory)
– Read-Write
– Volatile
• ROM (Read-Only Memory)
– Read-Only
– Non-Volatile
A/D & D/A Converters
• Interface between real world and digital
systems
• Conversion
– Analog to Digital (A/D)
– Digital to Analog (D/A)
• Industrial Control Application
Analog vs. Digital Systems
• Analog:
– Necessary for interface circuits (i.e. sensors & actuators,
displays)
– Limited precision, error prone, drift problem
• Digital Advantages over Analog:
– Efficient Processing
• DSP
• Filtering
• Compression
• Image enhancements
• Precise & Accurate Reproduction
Analog vs. Digital Systems
• Digital Advantages over Analog:
– Higher Capacity Data Storage
• CD, DVD
– Reliable Transmission
• Error Control Coding
– Easier Design and Implementation
• Higher Density Circuits
• Design Reuse
• Standardized Fab
Digital System ICs
Binary Number System
• Why Study?
• Necessary for:
– Digital Design
– Design Debug and Verification
– Troubleshooting Circuits
– Lab and field instruments
• Its cousin, Boolean Algebra
Number Systems and Codes
• Decimal or Human Number System
• Binary Number System
• Hexadecimal Number System
• Octal Number System
Decimal Number System
• Ten unique numbers 0,1..9
• Combination of digits
• Positional Number System
• 275 = 2 x 102 + 7 x 101 + 5 x 100
– Base or Radix 10
– Weight: powers of 10
1, 10, 100, 1000 ….
Representing Fractions
• Fractions can be represented in decimal
number system in a similar manner
= 3 x 102 + 8 x 101 + 2 x 100 + 9 x 10-1
+ 1 x 10-2
= 300 + 80 + 2 + 0.9 + 0.01
= 382.91
Base r Number System
• r unique numbers:
0, 1 … r-1
• Series of coefficients:
An-1An-2 … A2A1A0 . A-1A-2 … A-m+1A-m
• Weight: powers of r
• Arithmetic value:
An-1 rn-1An-2 rn-2… A2 r2 A1 r1 A0 r0.A-1 r-1 A-2 r-2 … A-m+1 r-m+1
A-m r-m
• MSD: An-1 LSD: A-m
Binary Number System
• Two unique numbers 0 and 1
• Base – 2
• A binary digit is a bit
• Combination of bits to represent larger values
• In computer work, some special titles:
210 – K (kilo)
220 – M (mega)
230 – G (giga)
Binary Number System
Decimal Binary Number Decimal Number Binary Number
Number
0 0 10 1010
1 1 11 1011
2 10 12 1100
3 11 13 1101
4 100 14 1110
5 101 15 1111
6 110 16 10000
7 111 17 10001
8 1000 18 10010
9 1001 19 10011
Combination of Binary Bits
• Combination of Bits
• 100112 = 1910
= (1 x 24) + (0 x 23) + (0 x 22) + (1 x 21) + (1 x 20)
= (1 x 16) + (0 x 8) + (0 x 4) + (1 x 2) + (1 x 1)
= 16 + 0 + 0 + 2 + 1
= 1910
Fractions in Binary
• Fractions in Binary
• 1011.1012 = 11.625
= (1 x 23) + (0 x 22) + (1 x 21) + (1 x 20)
+ (1 x 2-1) + (0 x 2-2) + (1 x 2-3)
= (1 x 8) + (0 x 4) + (1 x 2) + (1 x 1)
+ (1 x 1/2) + (0 x 1/4) + (1 x 1/8)
= 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125
= 11.62510
• Floating Point Notations (to be discussed later)
Binary to Decimal Conversion
• Sum-of-Weights
– Add weights for non-zero terms
– Drop zero terms
Binary to Decimal Conversion
• Example 1
• 101012 = (1 x 24) + (0 x 23) + (1 x 22) +
(0 x 21) + (1 x 20)
= 2 4 + 2 2 + 20
= 16 + 4 + 1
= 2110
Binary to Decimal Conversion
• Example 2
• 1010.1012 = 8 + 2 + 1/2 + 1/8
= 10 + 5/8
= 10.62510
Binary Arithmetic
• Binary Addition
• Binary Subtraction
• Binary Multiplication
• Binary Division
Binary Addition
• Four Basic Rules
0 + 0 0 0
0 + 1 0 1
1 + 0 0 1
1 + 1 1 0
Binary Addition Example
Carry 1 1 1
Num1 1 0 1 1 1110
Num2 + 1 1 1 710
Result 1 0 0 1 0 1810
Binary Subtraction
• Four Basic Rules
Num1 Op Num2 Borrow Difference
0 - 0 0 0
1 - 1 0 0
1 - 0 0 1
0 - 1 1 1
Binary Subtraction Example
Borrow 1
Num1 1 1 0 1 1310
Num2 - 0 1 1 310
Result 1 0 1 0 1010
Binary Multiplication
• Four Basic rules
10 2
101 | 1101 5 | 13
101 10
011
000 ___
11 3
Division/Multiplication by Shifting
• In Decimal a number shifted one place to the right is the
same as divide by 10. e.g. 29 2.9
• Likewise, a number shifted left is multiply by 10. e.g.
13 130
• Addition
– straightforward as we shall see
• Subtraction
– Change sign of Subtrahend and Add
• Multiplication
– Shift and add each partial product term
• Division
– Repetitively subtract Divisor from Dividend – but
subtraction is again addition
Addition with 2’s Complement
1011 -5 0101 +5
0010 +2 1110 -2
1101 -3 0011 +3
1011 -5 0101 +5
1110 -2 0010 +2
1 1001 -7 0111 +7
Discard any final carry bit
Subtraction with 2’s Complement
01011001 89 01011001 89
- 00101101 45 + 11010011 -45
???????? ?? 1 00101100 44
Discard any final carry bit
Overflows
• Overflow conditions
– Indicated by an incorrect sign bit
– There is a carry into the sign bit which produces an
overflow condition
– Can occur only when both numbers are positive or
both numbers are negative
01111101 (+125d)
00111010 (+58d)
10110111 (+183d)
Floating Point Numbers
• To represent very large/very small integers
• Numbers that have both integer and fractional parts
• A Floating point number consists of two parts plus a
sign
– Exponent: Number of places that the binary point is to be
moved (power of 2)
– Mantissa; represents the magnitude of the number
• A format is defined by ANSI/IEEE 754
– Single precision, double precision and extended precision
Floating Point Numbers
• Single Precision Floating Point Binary Number
S Biased Exp Mantissa
• +11011000001112
+1.101100000111 x 212 (Normalized form)
S=0
Biased Exponent = 10001011 (127 + 12 = 139)
Mantissa = 10110000011100000000000 (hidden 1)
0 10001011 10110000011100000000000
Floating Point Numbers
+1.101 x 25
0 10000100 10100000000000000000000
-1.01011 x 2-126
1 00000001 01011000000000000000000
00 00000000 00000000000000000000000
∞
0 11111111 00000000000000000000000
Need for Hexadecimal Number System
Borrow 111
92B5 21-6=15d Fh
- 2AC6 26-C=14d Eh
67EF 17-A=7d 7h
8-2=6d 6h
Octal Numbers
• Composed of eight digits
0,1,2,3,4,5,6,7
• To count above 7, begin another column and start over
Decimal Binary Octal
0 000 0
1 001 1
2 010 2
3 011 3
4 100 4
5 101 5
6 110 6
7 111 7
Octal Numbers
• Counting in Octal
Decimal Octal Decimal Octal Decimal Octal
8 10 16 20 24 30
9 11 17 21 25 31
10 12 18 22 26 32
11 13 19 23 27 33
12 14 20 24 28 34
13 15 21 25 29 35
14 16 22 26 30 36
15 17 23 27 31 37
Octal Numbers
• Binary-to-Octal Conversion
– Start with the right most group of three bits
– Moving from right to left convert each 3-bit group to the
equivalent octal digit
– For the left most group, add zeros to complete the group if
required
– Example
11010110101110010110
011 010 110 101 110 010 110
3 2 6 5 6 2 6
Octal Numbers
• Octal-to-Binary Conversion
– Each octal digit can be represented by a 3-bit binary #
17268
001 111 010 110
• Octal-to-Decimal Conversion
– Sum-of-Weights method
40338
(4 x 83) + (0 x 82) + (3 x 81) + (3 x 80)
(4 x 512) + (0 x 64) + (3 x 8) + (3 x 1)
2048 + 0 + 24 + 3
2075
Octal Numbers
• Decimal-to-Octal Conversion
– Repeated division-by-8 method
– Example
Carry 1
7602 2+1=3d 3O
+ 5771 0+7=7d 7O
15573 6+7=13d 15O
1+7+5=13d 15O
Octal Numbers
• Octal Subtraction
– Example
Borrow 11
7602 2-1=1d 1O
- 5771 8-7=1d 1O
1611 13-7=6d 6O
6-5=1d 1O
Binary Coded Decimal (BCD)
• A way to represent each of the decimal digit with
a unique binary code
• There are only ten codes in the BCD system.
Decimal BCD Decimal BCD
0 0000 5 0101
1 0001 6 0110
2 0010 7 0111
3 0011 8 1000
4 0100 9 1001
Binary Coded Decimal (BCD)
• An excellent interface to binary systems
– Keypad input
• 8421 Code
– A type of BCD code
– Designation 8421 indicates the binary weights of the
four bits
– Invalid codes
• The six codes that are not used
• 1010, 1011,1100,1101,1110,1111 (A-F) h
Binary Coded Decimal (BCD)
• BCD Addition
– If a 4-bit sum is greater than 9 or if a carry- out of the 4-bit
group is generated, it is an invalid result
– Add 6(0110) to the 4-bit sum
– Add the carry to the next 4-bit group
• Multi-digit BCD numbers can be added together
– Example
23 0010 0011
45 0100 0101
68 0110 1000
Binary Coded Decimal (BCD)
• Example of BCD addition
23 0010 0011
48 0100 1000
71 0110 1011 (invalid > 9)
0110 (add 6 and
carry)
0111 0001
Gray Code
• Un-weighted code
• Restricts code changes across more than 1
bit at a time
• Useful in Electromechanical applications of
digital systems such as Shaft encoders
Gray Code
Decimal Binary 3-bit Gray Code
0 000 000
1 001 001
2 010 011
3 011 010
4 100 110
5 101 111
6 110 101
7 111 100
Gray Code Application
A A
B B
C C