Digital Logic Design: Instructor: Yahya Ali Khan Email: Yahya - Ali@se - Uol.edu - PK

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 46

DIGITAL LOGIC DESIGN

Instructor: Yahya Ali Khan


Email: yahya.ali@se.uol.edu.pk
COURSE TEXTBOOK
• M. Morris Mano, Digital Design, 4th Edition, Prentice-Hall,
Upper Saddle River, New Jersey, 2002.
• NOTE:
• Excellent textbook on digital design
• Textbook covers approximately 90% of the course material
• Digital Version Available on slate.

4/29/21 Lecture Notes - EE 222: Digital Logic Design 2


IMPORTANCE OF DIGITAL LOGIC DESIGN
1. An understanding of computer architecture can lead to better
hardware / software systems
2. Digital design techniques can often be applied to the design of
complex software systems
3. Digital design tools are an example of a real-world application
of complex software systems
4. Engineering design and analysis is an essential component of
any successful digital design project

4/29/21 Lecture Notes - EE 222: Digital Logic Design 3


WHAT IS A COMPUTER?
• Computer
“a programmable device that can store, retrieve, and process data.”
− Merriam-Webster Online Dictionary
• Program
“to work out a sequence of operations to be performed by a mechanism.”
− Merriam-Webster Online Dictionary

4/29/21 Lecture Notes - EE 222: Digital Logic Design 4


WHAT IS A DIGITAL COMPUTER?

Source:
J. von Neumann, First Draft of a Report on the EDVAC. Technical Report W-6700RD-492, Moore School of
Electrical Engineering, University of Pennsylvania, June 1945.

4/29/21 Lecture Notes - EE 222: Digital Logic Design 5


GOALS OF THIS COURSE
• The goals of this course are the following:
1. Learn about the representation of complex information in a digital computer
system
2. Investigate the components that form a digital computer
3. Design and analyze simple digital circuits
4. Understand the fundamental design tradeoffs associated with digital circuit design
• This course introduces digital design and computer architecture
concepts
• Previous knowledge of digital design is not required

4/29/21 Lecture Notes - EE 222: Digital Logic Design 6


NUMBER SYSTEMS AND
INFORMATION REPRESENTATION
DECIMAL NUMBER SYSTEM
• The decimal number system has a base of 10
• When a quantity is written without a base specified, the quantity
is assumed to have a base of 10
• Consider the quanity, 8 192:
8 192 = (8 192)10
= 8 · 103 + 1 · 102 + 9 · 101 + 2 · 100
• For fractional quantities, negative exponents are used
• Consider the quantity, 12.5:
12.5 = (12.5)10
= 1 · 101 + 2 · 100 + 5 · 10-1

4/29/21 Lecture Notes - EE 222: Digital Logic Design 8


DIGITAL INFORMATION REPRESENTATION

• The decimal number system is not ideal for representing digital


information in a digital computer system
• Computers represent data using a binary (two-valued) representation
• Some binary representations of 0’s and 1’s are the following:

Representation of 0 Representation of 1
Voltage (e.g., 0 V) Voltage (e.g., 3.3 V)
Current (e.g., 0 mA) Current (e.g., 10 mA)
Switch Position (e.g., closed) Switch Position (e.g., open)
Capacitor (e.g., discharged) Capacitor (e.g., charged)

4/29/21 Lecture Notes - EE 222: Digital Logic Design 9


BINARY NUMBER SYSTEM
• The binary number system has a base of 2
• In binary, each digit is assigned a weight that is a power of 2

Powers of Two

n 2n n 2n n 2n
-8 0.00390625 0 1 8 256
-7 0.0078125 1 2 9 512 NOTE:
-6 0.015625 2 4 10 1024 This table is similar to
-5 0.03125 3 8 11 2048 Table 1.1 in the
textbook. However, it
-4 0.0675 4 16 12 4096
includes the negative
-3 0.125 5 32 13 8192
powers of two as well.
-2 0.25 6 64 14 16384
-1 0.5 7 128 15 32768

4/29/21 Lecture Notes - EE 222: Digital Logic Design 10


DECIMAL NUMBER SYSTEM
VS. BINARY NUMBER SYSTEM

Decimal Number System Binary Number System


• Base 10 • Base 2
• Digits range from 0 to 9 • Digits range from 0 to 1
• Fewer digits are required to represent • Many digits are required to represent
large quantities large quantities

Decimal vs. Binary Comparison Example

(8 192)10 = (1 0000 0000 0000)2

4 digits vs. 13 digits

4/29/21 11
IMPORTANT POWERS OF 2
• There are certain powers of 2 that are “easier” to remember due
to their importance:
• For example:
210 = 1 024 = Kilo = (1 024)1
220 = 1 048 576 = Mega = (1 024)2
230 = 1 073 741 824 = Giga = (1 024)3
240 = 1 099 511 627 776 = Tera = (1 024)4

4/29/21 Lecture Notes - EE 222: Digital Logic Design 12


AN ASIDE: ADDRESSABLE STORAGE RANGES

• Addressable storage ranges (e.g., memory capacities) are


determined by the number of address bits and the word size:
16 address bits (216 = 65 536 = 64 kbits · Word Size)
32 address bits(232 = 4 294 967 296 = 4 Gbits · Word Size)
• For example, an embedded computer with a 20-bit address bus
and a 32-bit word size can theoretically support:
220 · 32 bits of data = 4 Mbytes
• For example, a typical personal computer with a 32-bit address
bus and a 32-bit word size can theoretically support:
232 · 32 bits of data = 16 Gbytes

4/29/21 Lecture Notes - EE 222: Digital Logic Design 13


UNSIGNED BINARY ARITHMETIC
• For now, assume that all binary numbers are unsigned
• Unsigned binary arithmetic uses the same rules as decimal
arithmetic
Addition Example

Augend: (1101 0110)2 (214)10


Addend: (0011 0010)2 (50)10
______________ ________
Sum: (1 0000 1000)2 (264)10

Subtraction Example

Minuend: (1101 0110)2 (214)10


Subtrahend: (0011 0010)2 (50)10
____________ ________
Difference: (1010 0100)2 (164)10

4/29/21 Lecture Notes - EE 222: Digital Logic Design 14


UNSIGNED BINARY ARITHMETIC
• Multiplication simplifies to replicating and shifting the
multiplicand:

Multiplication Example
Multiplicand: (1010)2 (10)10
Multiplier: (0110)2 (6)10
________ ______
(0000)2 (0)10
(1 010)2 (20)10
(10 10)2 (40)10
(000 0)2 (0)10
______________ ______
Product: (0011 1100)2 (60)10

4/29/21 Lecture Notes - EE 222: Digital Logic Design 15


SOME CONVERSION EXAMPLES
• (12.5)10 = (1100.1)2
• (82.625)10 = (0101 0010.101)2
• (0.0125)10 = (0.0000 0011 0001 1000 1100 011…)2

• The last conversion is quite ugly. The conversion algorithm is


shown on the next slide…

4/29/21 Lecture Notes - EE 222: Digital Logic Design 16


CONVERSION OF (0.0125)10 TO BINARY
Approximate Answer Fraction Remaining
0.0125 · 2 = 0.025 (0.0)2 0.025
0.0250 · 2 = 0.05 (0.00)2 0.05
0.05 · 2 = 0.1 (0.000)2 0.1
0.1 · 2 = 0.2 (0.0000)2 0.2
0.2 · 2 = 0.4 (0.0000 0)2 0.4
0.4 · 2 = 0.8 (0.0000 00)2 0.8
0.8 · 2 = 1.6 (0.0000 001)2 0.6
0.6 · 2 = 1.2 (0.0000 0011)2 0.2
0.2 · 2 = 0.4 (0.0000 0011 0)2 0.4
0.4 · 2 = 0.8 (0.0000 0011 00)2 0.8
… … … …

4/29/21 Lecture Notes - EE 222: Digital Logic Design 17


INTERESTING ASIDES…
1. The MS-Windows Calculator does not convert a fractional
quantity to its equivalent binary representation
• The answer is truncated
• If anyone ever gets a chance to fix the calculator, please do so
2. A decimal fraction with a fixed number of decimal digits may
actually convert to a binary fraction with an infinite number of
binary digits!

4/29/21 Lecture Notes - EE 222: Digital Logic Design 18


OCTAL REPRESENTATION
• Octal is base 8
• Digits range from 0 to 7 {0,1,2,3,4,5,6,7}
• (10 101 011)2 = (253)8 = (171)10

2 5 3

• Octal is rarely used


• Octal representations may be used for specifying file permissions in Unix-based
systems

4/29/21 Lecture Notes - EE 222: Digital Logic Design 19


HEXADECIMAL REPRESENTATION
• Hexadecimal is base 16
• Digits range from 0 to F {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}
• (1010 1011)2 = (253)8 = (171)10 = (AB)16

A B

• Hexadecimal is often used in C, C++, and C# to specify large


quantities (constants, addresses, etc.)
• For example, 0xAB represents (171)10
• Hardware designers sometimes use 0xDEAD as a 16-bit constant to indicate a
problem

4/29/21 Lecture Notes - EE 222: Digital Logic Design 20


COMPLEMENTS
• Complements of numbers are often useful to simplify arithmetic
• Two types of complements are popular:
• Diminished Radix Complement (1’s complement for binary)
• Radix Complement (2’s complement for binary)

4/29/21 Lecture Notes - EE 222: Digital Logic Design 21


DIMINISHED RADIX COMPLEMENT
• Given a number N in base r having n digits, the diminished radix
complement is defined as (rn - 1) – N
• This is often called the (r-1)’s complement
• For the binary number system, the diminished radix complement
is referred to as the 1’s complement
• Complement of an 8-bit quantity N is (28 - 1) - N = 255 – N
• To calculate the 1’s complement, simply complement each bit
• For example, the 1’s complement of (1010 0011)2 is (0101 1100)2

4/29/21 Lecture Notes - EE 222: Digital Logic Design 22


RADIX COMPLEMENT
• Given a number N in base r having n digits, the radix
complement is defined as rn – N
• This is often called the r’s complement
• For the binary number system, the radix complement is referred
to as the 2’s complement
• Complement of an 8-bit quantity N is 28 - N = 256 – N
• To calculate the 2’s complement, simply complement each bit and add 1 to the
quantity
• For example, the 2’s complement of (1010 0011)2 is (0101 1101)2

4/29/21 Lecture Notes - EE 222: Digital Logic Design 23


SUBTRACTION WITH R’S COMPLEMENT
• 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 to produce an
intermediate result. This performs M + (rn - N) = M - N + rn.
2. If M ≥ N, the sum produces an end carry, rn, which can be discarded. The final
answer is M - N.
3. If M < N, the sum does not produce an end carry and the sum is equal to rn - (N -
M) which is the r’s complement of (N - M). The final answer is the negative r’s
complement of the sum.

4/29/21 Lecture Notes - EE 222: Digital Logic Design 24


SUBTRACTION EXAMPLE
• Using 2’s complement, subtract (1010)2 – (0110)2
M = (1010)2
N = (0110)2
2’s complement of N = (1010)2

M–N = M + 2’s complement of N (sort of…)


M = (1010)2
2’s complement of N = (1010)2
___________
NOTE:
Intermediate Result = (1 0100)2
The end carry
Final Answer = (0100)2
is discarded to
arrive at the
final result.

4/29/21 Lecture Notes - EE 222: Digital Logic Design 25


SUBTRACTION WITH (R - 1)’S COMPLEMENT

• When using (r-1)’s complement, the end carry is treated


differently
• If M ≥ N, the end carry is truncated and 1 is added to the
intermediate result to produce the final answer
• If M < N, the final answer is the negative (r - 1)’s complement of
the intermediate result

4/29/21 Lecture Notes - EE 222: Digital Logic Design 26


SUBTRACTION EXAMPLE
• Using 1’s complement, subtract (1010)2 – (0110)2
M = (1010)2
N = (0110)2
1’s complement of N = (1001)2

M–N = M + 1’s complement of N (sort of…)


M = (1010)2
1’s complement of N = (1001)2
____________ NOTE:
Intermediate Result = (1 0011)2 A value of 1 is
Final Answer = (0100)2 added to the result
to compensate for
the representation.

4/29/21 Lecture Notes - EE 222: Digital Logic Design 27


SIGNED BINARY NUMBERS
• Signed binary numbers can be represented three different ways:
1. Signed Magnitude Representation
2. Signed 1’s Complement Representation
3. Signed 2’s Complement Representation
• For example, (-36)10 can be represented in binary as follows:
1. (1010 0100)2 in signed magnitude representation
2. (1101 1011)2 in signed 1’s complement representation
3. (1101 1100)2 in signed 2’s complement representation

4/29/21 Lecture Notes - EE 222: Digital Logic Design 28


COMPARISON OF SIGNED BINARY NUMBERS

Decimal Signed Magnitude Signed 1’s Complement Signed 2’s Complement


+7 0111 0111 0111

+6 0110 0110 0110

+5 0101 0101 0101

+4 0100 0100 0100

+3 0011 0011 0011

+2 0010 0010 0010

+1 0001 0001 0001

+0 0000 0000 0000

-0 1000 1111 N/A

-1 1001 1110 1111

-2 1010 1101 1110

-3 1011 1100 1101

-4 1100 1011 1100

-5 1101 1010 1011

-6 1110 1001 1010

-7 1111 1000 1001

-8 N/A N/A 1000

4/29/21 Lecture Notes - EE 222: Digital Logic Design 29


IMPORTANT OBSERVATIONS
FOR SIGNED BINARY NUMBERS

• If the most significant bit is a 0, the number is positive


• If the most significant bit is a 1, the number is negative
• The signed binary number representation is irrelevant for the
purpose of determining whether a value is positive or negative

4/29/21 Lecture Notes - EE 222: Digital Logic Design 30


SIGNED ARITHMETIC
• Signed arithmetic obeys the same basic rules as unsigned
arithmetic
• Carries beyond the width of the number representation should be
discarded
• Width of number representation must be large enough to avoid
an overflow condition
• Overflow occurs if both number possess the same sign and the result possesses a
different sign
• Overflow can be accommodated by making the result 1 bit larger

4/29/21 Lecture Notes - EE 222: Digital Logic Design 31


SIGNED ARITHMETIC EXAMPLES
• Consider the following examples:
Addition Example 1 Addition Example 2
Augend: (0110)2 (6)10 Augend: (1110)2 (-2)10
Addend: (1010)2 (-6)10 Addend: (1010)2 (-6)10
_________ _____ _________ _____
Sum: (1 0000)2 (16)10 Sum: (1 1000)2 (-8)10

Discarding the carry… Discarding the carry…


Sum: (0000)2 (0)10 Sum: (1000)2 (-8)10

NOTE:
2’s complement arithmetic has
been used in these examples.

4/29/21 Lecture Notes - EE 222: Digital Logic Design 32


BINARY CODED DECIMAL (BCD)
• Binary coded decimal is an “obvious” Decimal Digit BCD Digit
representation of decimal digits 0 0000

• BCD uses 4-bits to represent a decimal 1 0001

digit 2 0010

• Bit patterns 1010 through 1111 are not 3 0011

4 0100
used by BCD
5 0101
• BCD to decimal conversion is trivial
6 0110

7 0111

8 1000

9 1001

4/29/21 Lecture Notes - EE 222: Digital Logic Design 33


UNSIGNED BCD ADDITION
• It is possible to add two numbers specified in BCD
• To compensate for the unused bit patterns, a value of (6)10 is
added to each BCD digit greater than (9)10 to account for the true
value of carries between BCD digits
• BCD addition is prone to errors when done by hand

4/29/21 Lecture Notes - EE 222: Digital Logic Design 34


UNSIGNED BCD ADDITION EXAMPLE
BCD Carry (1)BCD (1)BCD
(0010)BCD (1000)BCD (0100)BCD (284)10
(0110)BCD (0111)BCD (0110)BCD (676)10
_____________ ________________ _____________ __________

Binary Sum (1001)BCD (1 0000)BCD (1010)BCD (960)10


Add (6)10 (0110)BCD (0110)BCD
_____________ ________________ _____________ __________

BCD Sum (1001)BCD (0110)BCD (0000)BCD (960)10

4/29/21 Lecture Notes - EE 222: Digital Logic Design 35


GRAY CODE
• Gray code is a binary code that minimizes the number of bits
that change values during incrementing or decrementing
• Extremely useful code for systems that process continuous
signals (e.g., sampled analog signals) and for low-power
computer systems (e.g., cellular phones)
• Fewer bits changing provides the following benefits:
1. Lower dynamic power consumption
2. Faster data transitions
3. Greater reliability of data

4/29/21 Lecture Notes - EE 222: Digital Logic Design 36


GRAY CODE
Decimal Gray Decimal Gray
Number Code Number Code
0 0000 8 1100
1 0001 9 1101
2 0011 10 1111
3 0010 11 1110
4 0110 12 1010
5 0111 13 1011
6 0101 14 1001
7 0100 15 1000

4/29/21 Lecture Notes - EE 222: Digital Logic Design 37


GRAY CODE VS. ORDINARY BINARY CODE

• Consider the example of a transition from (7)10 to (8)10:


• Using an ordinary binary code, 4 bits change
• For example, (0111)2 becomes (1000)2
• Using a Gray code, only 1 bit changes
• For example, (0100)2 becomes (1100)2

4/29/21 Lecture Notes - EE 222: Digital Logic Design 38


AMERICAN STANDARD CODE
FOR INFORMATION INTERCHANGE (ASCII)

• ASCII is the standard binary code for alphanumeric characters


• Standard ASCII is a 7-bit code
• Extended ASCII is a 8-bit code
• Each alphanumeric character is assigned to a unique binary code

For more information on ASCII,


refer to www.asciitable.com

4/29/21 Lecture Notes - EE 222: Digital Logic Design 39


UNICODE
• Unicode is a code for representing multiple alphanumeric
character sets
• UTF-16 is a 16-bit Unicode representation of alphanumeric
characters from many diverse character sets
• Most significant byte specifies the code set
• Least significant byte specifies the character within the block
• 8-bit (UTF-8) and 32-bit (UTF-32) Unicode representations also
exist
• Code set for Basic Latin resembles the extended (8-bit) ASCII
character set

4/29/21 Lecture Notes - EE 222: Digital Logic Design 40


UNICODE
• Unicode supports many code charts including the following:
00xx Basic Latin
20xx General Punctuation
21xx Arrows
22xx Mathematical Operators
26xx Miscellaneous Symbols
27xx Dingbats
• A complete summary of all Unicode code charts can be found at
http://www.unicode.org/charts/

4/29/21 Lecture Notes - EE 222: Digital Logic Design 41


UNICODE
• For further information on Unicode:
The Unicode Consortium. The Unicode Standard, Version 4.0 (Boston, MA, Addison-
Wesley, 2003. ISBN 0-321-18578-1

For more information on Unicode,


refer to www.unicode.org

4/29/21 Lecture Notes - EE 222: Digital Logic Design 42


PARITY
• Parity is a simple form of error detection that uses a single bit to
uncover errors in data bits
• Standard ASCII only uses 7-bits so the 8th bit may be used for
error detection
• Four types of parity bits:
1. Even Parity 8th bit is a 0 if the number of 1’s is already even
2. Odd Parity 8th bit is a 0 if the number of 1’s is already odd
3. Mark Parity 8th bit is always a 1
4. Space Parity 8th bit is always a 0

4/29/21 Lecture Notes - EE 222: Digital Logic Design 43


PARITY EXAMPLES

ASCII Bit Even Odd Mark Space


Character Pattern Parity Parity Parity Parity
0 011 0000 0 1 1 0
1 011 0001 1 0 1 0
2 011 0010 1 0 1 0
3 011 0011 0 1 1 0
A 100 0001 0 1 1 0
B 100 0010 0 1 1 0
C 100 0011 1 0 1 0
D 100 0100 0 1 1 0

4/29/21 Lecture Notes - EE 222: Digital Logic Design 44


COMMENTS ON ERROR DETECTION
WITH PARITY

• Parity bits are particularly useful when transmitting data over a


wire in a noisy environment
• Even parity and odd parity can successfully detect 1, 3, 5, and 7
bit errors in a 7-bit ASCII bit pattern with 1 parity bit
• 2 bit, 4 bit, 6 bit, and 8 bit errors are masked (e.g., two wrongs make a right)
• Mark parity and space parity can successfully detect errors in the
parity bit only
• Errors in the parity bit may indicate a problem during data transmission
• Mark and space parity are reasonably good for detecting burst errors in a noisy
environment

4/29/21 Lecture Notes - EE 222: Digital Logic Design 45


ADVANCED ERROR DETECTION AND CORRECTION

• What if you need to send data to MARS and you can’t afford to
waste 14 minutes (e.g., the round-trip delay) to resend the data?
• Advanced error detection and correction techniques
• Techniques exist for detecting and/or correcting multiple bit
errors
• Advanced techniques are beyond the scope of this course
• ECE 324 (Microprocessor Systems and Interfacing) dedicates 3 lectures to error
detection and correction

4/29/21 Lecture Notes - EE 222: Digital Logic Design 46

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