0% found this document useful (0 votes)
38 views77 pages

DLD 3 4

The document discusses digital circuits and systems. It covers combinational and sequential circuits, their examples and uses. Programmable logic devices and memory are also introduced. The number systems used in digital circuits like binary, hexadecimal and their arithmetic operations are explained in detail. Conversion between number systems and representation of signed numbers are covered.

Uploaded by

Junii Baloch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views77 pages

DLD 3 4

The document discusses digital circuits and systems. It covers combinational and sequential circuits, their examples and uses. Programmable logic devices and memory are also introduced. The number systems used in digital circuits like binary, hexadecimal and their arithmetic operations are explained in detail. Conversion between number systems and representation of signed numbers are covered.

Uploaded by

Junii Baloch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 77

Lecture No.

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

Num1 Op Num2 Carry Sum

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

Num1 Op Num2 Product


0 x 0 0
0 x 1 0
1 x 0 0
1 x 1 1
Binary Multiplication Example
1101 (13d)
x 101 (5d)
1st partial product 1101
2nd partial product 0000
3rd partial product + 1101
Product 1000001(65d)
Binary Division Example
• Same rules as decimal division

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

• In Binary each right or left shift accomplishes divide or


multiply by 2.
• Right sh: 111012 (29d)  1110.12 (14.5d)
• Left sh: 1101 (13d) -> 11010 (26d)  110100 (52d )
Negative Number Representation
• 3 Options
– Sign-magnitude
– One’s Complement
– Two’s Complement  used in computers and
most digital systems
Sign-magnitude Representation
• Signed Binary Numbers
– Most significant bit represents sign
– MSB of 0 => positive number; MSB of 1 => negative
number
• Problem
– Representing 0 (e.g. +0 0000 and -0 1000)
– Not computation friendly
Sign Magnitude Form
1101 -5
0010 +2
1111 -7!!
1’s & 2’s Complement Form
Representation
• 1’s complement form
– Derived by inverting all bits
• 2’s complement form
– Derived by adding 1 to 1’s complement

Binary number 00001101 (13d)


1’s complement 11110010 (-13d)
+ 1
2’s complement 11110011 (-13d)
Signed Number Example
• +92  01011100 Shortcut to form 2’s
• In sign-magnitude form complement:
-92  11011100 •Do not flip any bits to
• In 1’s complement form the right of and
-92  10100011 including the first “1”
• In 2’s complement form •Flip all bits to the left
-92  10100100
of the first “1”
Decimal Value of Signed Numbers
• Sign-magnitude form
– Sum the weights in all magnitude bit positions where there are
1s
– Sign is determined by examination of the sign bit
110111 - (16 + 4 + 2 + 1) -23d
• 1’s Complement form
– Assign a negative value to the weight of the sign bit
– Sum the weights in all bit positions, where there are 1s
– Add 1 to the result
100110 (-32 +4 +2) +1 -25d
• 2’s Complement form
– Assign a negative value to the weight of sign bit
– Sum the weights in all bit positions, where there are 1s
110111 (-32 +16 + 4 +2 + 1) -9d
Decimal Value of Signed Numbers
Alternate Method
• 1’s Complement form
– Convert Negative Number to Positive
– Attach –ve sign bit
100110 => 011001 (-ve) 25d
• 2’s Complement form
– Convert Negative Number to Positive
– Attach –ve sign bit
110111 => 001001 (-ve) 9d
Range of Binary Numbers
• Unsigned Numbers
Total combos for “n” binary bits = 2n
Range: 0 … + (2n -1)
• Sign Magnitude Form
- (2n-1 -1) … + (2n-1 -1)
• 2’s Complement Form
- (2n-1) … + (2n-1 -1)
Important Info about 2’s Comp #s
• 2’s complement representation is for negative
numbers only
• Before representing 2’s complement numbers,
ensure it can fit in the given range of bits - e.g for
n-bit numbers range is:
- (2n-1) … + (2n-1 -1)
• Overflow occurs only when MSB changes contrary
to result expectation, otherwise discard carry.
Arithmetic Operations w/ Signed Numbers

• 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

• Long binary numbers are difficult to read


and write; easy to transpose or drop a bit
• Most digital systems process binary data in
groups that are multiples of four bits ->
easy to convert
• Base 16 number system
• Ten digits and six alphabetic characters
– 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Hexadecimal Number System
• Counting in Hexadecimal
– Once we get to F, we start over with another column
and continue

Decimal Binary Hexadecimal Decimal Binary Hexadecimal


0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 10 1010 A
3 0011 3 11 1011 B
4 0100 4 12 1100 C
5 0101 5 13 1101 D
6 0110 6 14 1110 E
7 0111 7 15 1111 F
Hexadecimal Number System
• Counting in Hexadecimal
Decimal Hexa- Decimal Hexa- Decimal Hexa-
Decimal Decimal Decimal
16 10 24 18 32 20
17 11 25 19 33 21
18 12 26 1A 34 22
19 13 27 1B 35 23
20 14 28 1C 36 24
21 15 29 1D 37 25
22 16 30 1E 38 26
23 17 31 1F 39 27
Hexadecimal Number System
• Binary to Hexadecimal Conversion
– Starting from the LSB, replace each 4-bit group with
the equivalent hexadecimal symbol

1101 0110 1011 1001 0110


D 6 B 9 6

• Hexadecimal to binary conversion


– Replace each hexadecimal digit with appropriate four
bits
F D 1 3
1111 1101 0001 0011
Hexadecimal Number System
• Hexadecimal-to-Decimal Conversion
– Sum-of-Weights Method
CA02h
= (C x 163) + (A x 162) + (0 x 161) + (2 x 160)
= (12 x 163) + (10 x 162) + (0 x 161) + (2 x 160)
= (12 x 4096) + (10 x 256) + (0 x 16) + (2 x 1)
= 49152 + 2560 + 0 + 2
= 51714
Hexadecimal Number System
• Decimal to Hexadecimal Conversion
– Repeated Division-by-16 method

Number ÷ 16 x 16 Hex Remainder

859 53.6875 0.6875 Bh (or 11d)


53 3.3125 0.3125 5h
3 0.1875 0.1875 3h
 Result: 35Bh
STOP when 0 reached
Hexadecimal Number System
• Hexadecimal Addition
– In any given column, think of two hexadecimal digits in
terms of their decimal values
– Example
Carry 1
2AC6 6+5=11d Bh
+ 92B5 C+B=23d 17h
B D7 B A+2+1=13d Dh
2+9=11d Bh
Hexadecimal Number System
• Hexadecimal Subtraction
– Example

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

Number Quotient Remainder


2075 259 3 (O0)
259 32 3 (O1)
8 4 0 (O2)
4 0 4 (O3)
Octal Numbers
• Octal Addition
– 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

Binary Gray Code


ASCII Code
• ASCII 7-bit Code
• American Standard Code for Information Interchange
• Represents Numbers, Characters, Symbols
• 10 Numbers (0-9)
• 26 Lower Case Characters (a-z)
• 26 Upper Case Characters (A-Z)
• Punctuation and Symbols
• 32 Control Characters
• From 00h to 7Fh
Extended ASCII Code
• 8th bit was always 0 in ASCII Code
• IBM used this 8th bit for their own PC codes
• Additional 128 Graphic characters
• Non-English characters, Greek letters
• Math, Drawing, Graphing symbols
• From 80h to FFh
Error Detection
• Digital Systems are very Reliable
• Errors during storage or transmission may
creep in
• Use an additional Parity Bit to detect
– Even Parity
– Odd Parity
Parity Method
• Any group of bits contain either an odd or an even
number of 1s
• A parity bit is attached to a group of bits to make the
total number of 1s in a group always even or always odd
• An even parity bit makes total number of 1s in a group,
even
• An odd parity bit makes total number of 1s in a group,
odd
• A parity bit detects a single bit error or any odd number
of errors
• Parity can be used with any number of bits
Odd Parity Error Detection
• Original data 10011010
• With Odd Parity 110011010
• 1-bit error 110111010
• Number of 1s even indicates 1-bit error
• 2-bit error 110110010
• Number of 1s odd no error indicated
• 3-bit error 100110010
• Number of 1s even indicates error
Review Special
1. What is one of the most distinguishing things
about the analog world?
2. What are the two special characteristics of
digital systems?
3. What is Moore’s Law for microprocessors?
4. Under-sampling of analog signals results in
__________________.
5. Two binary digits of digital system fame are
also called two __________________.
Review Special
6. What is Pulse Width & Duty Cycle of a signal?
7. What are basic logic gates?
8. How is a Combinational circuit different from
a Sequential one? Name some examples of
each.
9. What is PLD?
10. What are some advantages of PLD?
11. A-D converter connects ______________
systems to ______________ systems.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy