Top Banner
ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering
90

ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Jan 11, 2016

Download

Documents

Charlotte York
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

ECEN 248: INTRODUCTION TO DIGITAL DESIGN

Lecture Set A

Dr. S.G.Choi

Dept. of Electrical and Computer Engineering

Page 2: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Instructor:

Office 333G WERC Office Hours MWF 10-11 AM Email: [email protected] Lab Page: http://

people.tamu.edu/~rajballavdash/ecen_labpage.html

Page 3: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Required textbook:

Required Textbook: "Fundamentals of Digital Logic Design" by Brown and Vranesic. VERILOG VERSION

Supplemental texts: "Digital Design: Principles and Practices" by John Wakerly. "Contemporary Logic Design" by Randy Katz.

Page 4: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Course info

Mailing list: Emails will be sent periodically to neo accounts Announcements:

Lecture cancellations Deadline extension Updates, etc.

Course website http://ece.tamu.edu/~gchoi/248.htm All slides, labs, assignments, etc.

Page 5: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Grading Policy:

Assignments and Labs 25% 3 Hour Exams

20% for 1st exam 25% for 2nd

30% for 3rd No Final Exam Quizzes:

Each quiz 1% of the final Taken into account only if it improves the final grade Can improve the grade, but no extra points

Final grading may or may not be curved up

Page 6: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Quizzes:

3-6 quizzes Multiple choice questions 10-15 minutes Each quiz 1% of the final No quiz makeups

Page 7: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Grading scale

A standard grading scale will be utilized. The tentative grading scale for the course is: 

A       90-100% B         80-89% C        70-79% D         60-69% F        Below 59%

Page 8: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Course Goals

Study methods for Representation, manipulation, and optimization for

both combinatorial and sequential logic Solving digital design problems Study HDL description language (verilog)

Page 9: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Topics

Number bases Logic gates and Boolean Algebra Gate –label minimization Combinational Logic Sequential logic (Latches, Flip-flops,

Registers, and Counters) Memory and Programmable Logic HDL language (Verilog)

Page 10: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Attention over time!t

Page 11: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Attention over time!

~5min

t

Page 12: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Peer Instruction

Increase real-time learning in lecture, test understanding of concepts vs. details

Complete a “segment” with multiple choice questions 1-2 minutes to decide yourself 3 minutes in pairs/triples to reach consensus.

Teach others! 5-7 minute discussion of answers, questions,

clarifications

Page 13: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

The Evolution of Computer Hardware

When was the first transistor invented?

Modern-day electronics began with the invention in 1947 of the transfer resistor - the bi-polar transistor - by Bardeen et.al at Bell Laboratories

Page 14: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

The Evolution of Computer Hardware

When was the first IC (integrated circuit) invented? In 1958 the IC was born when Jack Kilby at Texas

Instruments successfully interconnected, by hand, several transistors, resistors and capacitors on a single substrate

Page 15: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

The Underlying Technologies

Year Technology Relative Perf./Unit Cost

1951 Vacuum Tube 1

1965 Transistor 35

1975 Integrated Circuit (IC) 900

1995 Very Large Scale IC (VLSI) 2,400,000

2005 Ultra VLSI 6,200,000,000

Page 16: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

The PowerPC 750

Introduced in 1999

3.65M transistors 366 MHz clock

rate 40 mm2 die size 250nm

technology

Page 17: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

ECEN 248

Layers of abstraction

I/O systemProcessor

CompilerOperatingSystem(Mac OSX)

Application (ex: browser)

Digital DesignCircuit Design

Instruction Set Architecture

Datapath & Control

transistors

MemoryHardware

Software Assembler

Page 18: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Year

Tra

nsis

tors

1000

10000

100000

1000000

10000000

100000000

1970 1975 1980 1985 1990 1995 2000

i80386

i4004

i8080

Pentium

i80486

i80286

i8086

Technology Trends: Microprocessor Complexity

2X transistors/ChipEvery 1.5 years

Called “Moore’s Law”

Alpha 21264: 15 millionPentium Pro: 5.5 millionPowerPC 620: 6.9 millionAlpha 21164: 9.3 millionSparc Ultra: 5.2 million

Moore’s Law

Athlon (K7): 22 Million

Itanium 2: 41 Million

Page 19: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

DIGITAL SYSTEMS

Page 20: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Overview

Logic functions with 1’s and 0’s. Building digital circuitry.

Truth tables. Logic symbols and waveforms. Boolean algebra. Properties of Boolean Algebra

Reducing functions. Transforming functions.

Page 21: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Digital Systems

Analysis problem:

Determine binary outputs for each combination of inputs

Design problem: given a task, develop a circuit that accomplishes the task

Many possible implementations. Try to develop “best” circuit based on some criterion (size,

power, performance, etc.)

··

··

LogicCircuitInputs Outputs

Page 22: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Toll Booth Controller

Consider the design of a toll booth controller. Inputs: quarter, car sensor. Outputs: gate lift signal, gate close signal

If driver pitches in quarter, raise gate. When car has cleared gate, close gate.

LogicCircuit

$·25

Car?

Raise gate

Close gate

Page 23: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Describing Circuit Functionality: Inverter

Basic logic functions have symbols. The same functionality can be represented with truth

tables· Truth table completely specifies outputs for all input

combinations. The above circuit is an inverter.

An input of 0 is inverted to a 1. An input of 1 is inverted to a 0.

A Y

0 1

1 0

Input Output

A Y

Symbol

Truth Table

Page 24: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

The AND Gate

This is an AND gate. So, if the two inputs signals

are asserted (high) the output will also be asserted.Otherwise, the output willbe deasserted (low).

A B Y

0 0 0

0 1 0

1 0 0

1 1 1

A

BY

Truth Table

Page 25: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

The OR Gate

This is an OR gate. So, if either of the two

input signals are asserted, or both of them are, the output will be asserted.

A B Y

0 0 0

0 1 1

1 0 1

1 1 1

AB

Y

Page 26: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Describing Circuit Functionality: Waveforms

Waveforms provide another approach for representing functionality.

Values are either high (logic 1) or low (logic 0). Can you create a truth table from the waveforms?

A B Y

0 0 0

0 1 0

1 0 0

1 1 1

AND Gate

Page 27: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Consider three-input gates

3 Input OR Gate

Page 28: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Ordering Boolean Functions

How to interpret A · B+C? Is it A · B ORed with C ? Is it A ANDed with B+C ?

Order of precedence for Boolean algebra: AND before OR.

Note that parentheses are needed here :

Page 29: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Boolean Algebra

A Boolean algebra is defined as a closed algebraic system containing a set K or two or more elements and the two operators, · and +·

Useful for identifying and minimizing circuit functionality

Identity elements a + 0 = a a · 1 = a

0 is the identity element for the + operation· 1 is the identity element for the · operation·

Page 30: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Commutativity and Associativity of the Operators

The Commutative Property:

For every a and b in K, a + b = b + a a · b = b · a

The Associative Property:

For every a, b, and c in K, a + (b + c) = (a + b) + c a · (b · c) = (a · b) · c

Page 31: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

The Distributive Property

The Distributive Property:

For every a, b, and c in K, a + ( b · c ) = ( a + b ) · ( a + c ) a · ( b + c ) = ( a · b ) + ( a · c )

Page 32: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Distributivity of the Operators and Complements

The Existence of the Complement:

For every a in K there exists a unique element called a’ (complement of a) such that, a + a’ = 1 a · a’ = 0

To simplify notation, the · operator is frequently omitted. When two elements are written next to each other, the AND (·) operator is implied… a + b · c = ( a + b ) · ( a + c ) a + bc = ( a + b )( a + c )

Page 33: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Duality

The principle of duality is an important concept. This says that if an expression is valid in Boolean algebra, the dual of that expression is also valid.

To form the dual of an expression, replace all + operators with · operators, all · operators with + operators, all ones with zeros, and all zeros with ones.

Page 34: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Duality

The principle of duality is an important concept· This says that if an expression is valid in Boolean algebra, the dual of that expression is also valid·

To form the dual of an expression, replace all + operators with · operators, all · operators with + operators, all ones with zeros, and all zeros with ones·

Form the dual of the expressiona + (bc) = (a + b)(a + c)

Following the replacement rules…a(b + c) = ab + ac

Take care not to alter the location of the parentheses if they are present·

Page 35: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Duality

The principle of duality is an important concept· This says that if an expression is valid in Boolean algebra, the dual of that expression is also valid·

To form the dual of an expression, replace all + operators with · operators, all · operators with + operators, all ones with zeros, and all zeros with ones·

Form the dual of the expressiona + (bc) = (a + b)(a + c)

Following the replacement rules…a(b + c) = ab + ac

Take care not to alter the location of the parentheses if they are present·

Page 36: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Involution

This theorem states:

a’’ = a Remember that aa’ = 0 and a+a’=1.

Therefore, a’ is the complement of a and a is also the complement of a’.

As the complement of a’ is unique, it follows that a’’=a·

Taking the double inverse of a value will give the initial value.

Page 37: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Absorption

This theorem states:

a + ab = a a(a+b) = a To prove the first half of this theorem:

a + ab = a · 1 + ab

= a (1 + b)

= a (b + 1)

= a (1)

a + ab = a

Page 38: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

DeMorgan’s Theorem

A key theorem in simplifying Boolean algebra expression is DeMorgan’s Theorem. It states:

(a + b)’ = a’b’ (ab)’ = a’ + b’

Complement the expression

a(b + z(x + a’)) and simplify.

(a(b+z(x + a’)))’ = a’ + (b + z(x + a’))’= a’ + b’(z(x + a’))’= a’ + b’(z’ + (x + a’)’)= a’ + b’(z’ + x’a’’)= a’ + b’(z’ + x’a)

Page 39: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Postulates and Basic Theorems

Page 40: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Summary

Basic logic functions can be made from AND, OR, and NOT (invert) functions.

The behavior of digital circuits can be represented with waveforms, truth tables, or symbols.

Primitive gates can be combined to form larger circuits Boolean algebra defines how binary variables can be

combined. Rules for associativity, commutativity, and distribution are

similar to algebra. DeMorgan’s rules are important.

Will allow us to reduce circuit sizes.

Page 41: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

NUMBER SYSTEMS

Page 42: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Overview

Understanding decimal numbers Binary and octal numbers

The basis of computers! Conversion between different number systems

Page 43: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Digital Computer Systems

Digital systems consider discrete amounts of data. Examples

26 letters in the alphabet 10 decimal digits

Larger quantities can be built from discrete values: Words made of letters Numbers made of decimal digits (e.g. 239875.32)

Computers operate on binary values (0 and 1) Easy to represent binary values electrically

Voltages and currents. Can be implemented using circuits Create the building blocks of modern computers

Page 44: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Understanding Decimal Numbers

Decimal numbers are made of decimal digits: (0,1,2,3,4,5,6,7,8,9)

Number representation: 8653 = 8x103 + 6x102 + 5x101 + 3x100

What about fractions? 97654.35 = 9x104 + 7x103 + 6x102 + 5x101 + 4x100 + 3x10-

1 + 5x10-2

Informal notation -> (97654.35)10

Page 45: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Understanding Octal Numbers

Octal numbers are made of octal digits: (0,1,2,3,4,5,6,7)

Number representation: (4536)8 = 4x83 + 5x82 + 3x81 + 6x80 = (1362)10

What about fractions? (465.27)8 = 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2

Octal numbers don’t use digits 8 or 9

Page 46: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Understanding Binary Numbers

Binary numbers are made of binary digits (bits): 0 and 1

Number representation: (1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10

What about fractions? (110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2

Groups of eight bits are called a byte (11001001) 2

Groups of four bits are called a nibble. (1101) 2

Page 47: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Why Use Binary Numbers?

° Easy to represent 0 and 1 using electrical values.

° Possible to tolerate noise.

° Easy to transmit data

° Easy to build binary circuits.

AND Gate

1

00

Page 48: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Conversion Between Number Bases

Decimal(base 10)

Octal(base 8)

Binary(base 2)

Hexadecimal

(base16)

Page 49: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Convert an Integer from Decimal to Another Base

1. Divide decimal number by the base (e.g. 2)

2. The remainder is the lowest-order digit

3. Repeat first two steps until no divisor remains.

For each digit position:

Example for (13)10:

IntegerQuotient

13/2 = 6 1 a0 = 1 6/2 = 3 0 a1 = 0 3/2 = 1 1 a2 = 1 1/2 = 0 1 a3 = 1

Remainder Coefficient

Answer (13)10 = (a3 a2 a1 a0)2 = (1101)2

Page 50: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Convert an Fraction from Decimal to Another Base

1. Multiply decimal number by the base (e.g. 2)

2. The integer is the highest-order digit

3. Repeat first two steps until fraction becomes zero.

For each digit position:

Example for (0.625)10:

Integer

0.625 x 2 = 1 + 0.25 a-1 = 10.250 x 2 = 0 + 0.50 a-2 = 00.500 x 2 = 1 + 0 a-3 = 1

Fraction Coefficient

Answer (0.625)10 = (0.a-1 a-2 a-3 )2 = (0.101)2

Page 51: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

The Growth of Binary Numbers

n 2n

0 20=1

1 21=2

2 22=4

3 23=8

4 24=16

5 25=32

6 26=64

7 27=128

n 2n

8 28=256

9 29=512

10 210=1024

11 211=2048

12 212=4096

20 220=1M

30 230=1G

40 240=1T

Mega

Giga

Tera

Kilo

Page 52: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Binary Addition

Binary addition is very simple. This is best shown in an example of adding two

binary numbers…

1 1 1 1 0 1+ 1 0 1 1 1---------------------

0

1

0

1

1

1111

1 1 00

carries

Page 53: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Binary Subtraction

° We can also perform subtraction (with borrows in place of carries).

° Let’s subtract (10111)2 from (1001101)2…

1 100 10 10 0 0 10

1 0 0 1 1 0 1- 1 0 1 1 1------------------------ 1 1 0 1 1 0

borrows

Page 54: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Binary Multiplication

Binary multiplication is much the same as decimal multiplication, except that the multiplication operations are much simpler…

1 0 1 1 1X 1 0 1 0----------------------- 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 1----------------------- 1 1 1 0 0 1 1 0

Page 55: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Convert an Integer from Decimal to Octal

1. Divide decimal number by the base (8)

2. The remainder is the lowest-order digit

3. Repeat first two steps until no divisor remains.

For each digit position:

Example for (175)10:

IntegerQuotient

175/8 = 21 7 a0 = 7 21/8 = 2 5 a1 = 5 2/8 = 0 2 a2 = 2

Remainder Coefficient

Answer (175)10 = (a2 a1 a0)2 = (257)8

Page 56: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Convert an Fraction from Decimal to Octal

1. Multiply decimal number by the base (e.g. 8)

2. The integer is the highest-order digit

3. Repeat first two steps until fraction becomes zero.

For each digit position:

Example for (0.3125)10:

Integer

0.3125 x 8 = 2 + 5 a-1 = 20.5000 x 8 = 4 + 0 a-2 = 4

Fraction Coefficient

Answer (0.3125)10 = (0.24)8

Page 57: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Summary

Binary numbers are made of binary digits (bits) Binary and octal number systems Conversion between number systems Addition, subtraction, and multiplication in binary

Page 58: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

HEXADECIMAL NUMBERS

Page 59: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Overview

Hexadecimal numbers Related to binary and octal numbers

Conversion between hexadecimal, octal and binary Value ranges of numbers Representing positive and negative numbers Creating the complement of a number

Make a positive number negative (and vice versa) Why binary?

Page 60: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Understanding Hexadecimal Numbers

Hexadecimal numbers are made of 16 digits: (0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F)

Number representation: (3A9F)16 = 3x163 + 10x162 + 9x161 + 15x160 = 1499910

What about fractions? (2D3.5)16 = 2x162 + 13x161 + 3x160 + 5x16-1 = 723.312510

Note that each hexadecimal digit can be represented with four bits. (1110) 2 = (E)16

Groups of four bits are called a nibble. (1110) 2

Page 61: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Putting It All Together

° Binary, octal, and hexadecimal similar

° Easy to build circuits to operate on these representations

° Possible to convert between the three formats

Page 62: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Converting Between Base 16 and Base 2

° Conversion is easy!

Determine 4-bit value for each hex digit

° Note that there are 24 = 16 different values of four bits

° Easier to read and write in hexadecimal.

° Representations are equivalent!

3A9F16 = 0011 1010 1001 11112

3 A 9 F

Page 63: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Converting Between Base 16 and Base 8

1. Convert from Base 16 to Base 2

2. Regroup bits into groups of three starting from right

3. Ignore leading zeros

4. Each group of three bits forms an octal digit.

352378 = 011 101 010 011 1112

5 2 3 73

3A9F16 = 0011 1010 1001 11112

3 A 9 F

Page 64: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

How To Represent Signed Numbers

• Plus and minus sign used for decimal numbers: 25 (or +25), -16, etc.

• For computers, desirable to represent everything as bits..

• Three types of signed binary number representations: signed magnitude, 1’s complement, 2’s complement.

• In each case: left-most bit indicates sign: positive (0) or negative (1).Consider signed magnitude:

000011002 = 1210

Sign bit Magnitude

100011002 = -1210

Sign bit Magnitude

Page 65: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

One’s Complement Representation

• The one’s complement of a binary number involves inverting all bits.

• 1’s comp of 00110011 is 11001100

• 1’s comp of 10101010 is 01010101

• For an n bit number N the 1’s complement is (2n-1) – N.

• Called diminished radix complement by Mano since 1’s complement for base (radix 2).

• To find negative of 1’s complement number take the 1’s complement.

000011002 = 1210

Sign bit Magnitude

111100112 = -1210

Sign bit Magnitude

Page 66: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Two’s Complement Representation

• The two’s complement of a binary number involves inverting all bits and adding 1.

• 2’s comp of 00110011 is 11001101

• 2’s comp of 10101010 is 01010110

• For an n bit number N the 2’s complement is (2n-1) – N + 1.

• Called radix complement by Mano since 2’s complement for base (radix 2).

• To find negative of 2’s complement number take the 2’s complement.

000011002 = 1210

Sign bit Magnitude

111101002 = -1210

Sign bit Magnitude

Page 67: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Two’s Complement Shortcuts

Algorithm 1 – Simply complement each bit and then add 1 to the result. Finding the 2’s complement of (01100101)2 and of its 2’s

complement… N = 01100101 [N] = 10011011

10011010 01100100 + 1 + 1

--------------- --------------- 10011011 01100101

Algorithm 2 – Starting with the least significant bit, copy all of the bits up to and including the first 1 bit and then complementing the remaining bits. N = 0 1 1 0 0 1 0 1

[N] = 1 0 0 1 1 0 1 1

Page 68: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Finite Number Representation

Machines that use 2’s complement arithmetic can represent integers in the range

-2n-1 <= N <= 2n-1-1where n is the number of bits available for representing N. Note that 2n-1-1 = (011..11)2 and –2n-1 = (100..00)2

o For 2’s complement more negative numbers than positive.

o For 1’s complement two representations for zero.o For an n bit number in base (radix) z there are zn

different unsigned values.(0, 1, …zn-1)

Page 69: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

1’s Complement Addition

Using 1’s complement numbers, adding numbers is easy.

For example, suppose we wish to add +(1100)2 and +(0001)2.

Let’s compute (12)10 + (1)10. (12)10 = +(1100)2 = 011002 in 1’s comp. (1)10 = +(0001)2 = 000012 in 1’s comp.

0 1 1 0 0 + 0 0 0 0 1-------------- 0 0 1 1 0 1 0-------------- 0 1 1 0 1

Add carry

Final Result

Step 1: Add binary numbersStep 2: Add carry to low-order bit

Add

Page 70: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

1’s Complement Subtraction

Using 1’s complement numbers, subtracting numbers is also easy.

For example, suppose we wish to subtract +(0001)2 from +(1100)2.

Let’s compute (12)10 - (1)10. (12)10 = +(1100)2 = 011002 in 1’s comp. (-1)10 = -(0001)2 = 111102 in 1’s comp.

Page 71: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

1’s Complement Subtraction

0 1 1 0 0 - 0 0 0 0 1--------------

0 1 1 0 0 + 1 1 1 1 0-------------- 1 0 1 0 1 0 1-------------- 0 1 0 1 1

Add carry

Final Result

Step 1: Take 1’s complement of 2nd operandStep 2: Add binary numbersStep 3: Add carry to low order bit

1’s comp

Add

Page 72: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

2’s Complement Addition

Using 2’s complement numbers, adding numbers is easy.

For example, suppose we wish to add +(1100)2 and +(0001)2.

Let’s compute (12)10 + (1)10. (12)10 = +(1100)2 = 011002 in 2’s comp. (1)10 = +(0001)2 = 000012 in 2’s comp.

Page 73: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

2’s Complement Addition

0 1 1 0 0 + 0 0 0 0 1-------------- 0 0 1 1 0 1

FinalResult

Step 1: Add binary numbersStep 2: Ignore carry bit

Add

Ignore

Page 74: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

2’s Complement Subtraction

Using 2’s complement numbers, follow steps for subtraction

For example, suppose we wish to subtract +(0001)2 from +(1100)2.

Let’s compute (12)10 - (1)10. (12)10 = +(1100)2 = 011002 in 2’s comp. (-1)10 = -(0001)2 = 111112 in 2’s comp.

Page 75: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

2’s Complement Subtraction

0 1 1 0 0 - 0 0 0 0 1--------------

0 1 1 0 0 + 1 1 1 1 1-------------- 1 0 1 0 1 1

Final Result

Step 1: Take 2’s complement of 2nd operandStep 2: Add binary numbersStep 3: Ignore carry bit

2’s comp

Add

IgnoreCarry

Page 76: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

2’s Complement Subtraction: Example #2

Let’s compute (13)10 – (5)10. (13)10 = +(1101)2 = (01101)2

(-5)10 = -(0101)2 = (11011)2

Adding these two 5-bit codes…

Discarding the carry bit, the sign bit is seen to be zero, indicating a correct result. Indeed,

(01000)2 = +(1000)2 = +(8)10.

0 1 1 0 1 + 1 1 0 1 1-------------- 1 0 1 0 0 0

carry

Page 77: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

2’s Complement Subtraction: Example #3

Let’s compute (5)10 – (12)10. (-12)10 = -(1100)2 = (10100)2

(5)10 = +(0101)2 = (00101)2

Adding these two 5-bit codes…

Here, there is no carry bit and the sign bit is 1. This indicates a negative result, which is what we expect. (11001)2 = -(7)10.

0 0 1 0 1 + 1 0 1 0 0-------------- 1 1 0 0 1

Page 78: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Binary numbers

Binary numbers can also be represented in octal and hexadecimal

Easy to convert between binary, octal, and hexadecimal

Signed numbers represented in signed magnitude, 1’s complement, and 2’s complement

2’s complement most important (only 1 representation for zero).

Important to understand treatment of sign bit for 1’s and 2’s complement.

Page 79: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Binary Coded Decimal

Binary coded decimal (BCD) represents each decimal digit with four bits Ex· 0011 0010 1001 = 32910

This is NOT the same as 0011001010012

Why do this? Because people think in decimal.

Digit BCD Code

Digit BCD Code

0 0000 5 0101

1 0001 6 0110

2 0010 7 0111

3 0011 8 1000

4 0100 9 1001

3 2 9

Page 80: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Putting It All Together

° BCD not very efficient.

° Used in early computers (40s, 50s).

° Used to encode numbers for seven-segment displays.

° Easier to read?

Page 81: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Gray Code

Gray code is not a number system. It is an alternate way to represent

four bit data

Only one bit changes from one decimal digit to the next

Useful for reducing errors in communication.

Can be scaled to larger numbers.

Digit Binary Gray Code

0 0000 0000

1 0001 0001

2 0010 0011

3 0011 0010

4 0100 0110

5 0101 0111

6 0110 0101

7 0111 0100

8 1000 1100

9 1001 1101

10 1010 1111

11 1011 1110

12 1100 1010

13 1101 1011

14 1110 1001

15 1111 1000

Page 82: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

ASCII Code

American Standard Code for Information Interchange

ASCII is a 7-bit code, frequently used with an 8th bit for error detection (more about that in a bit).Character ASCII (bin) ASCII (hex) Decimal Octal

A 1000001 41 65 101

B 1000010 42 66 102

C 1000011 43 67 103

Z

a

1

Page 83: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

ASCII Codes and Data Transmission

° ASCII Codes

° A – Z (26 codes), a – z (26 codes)

° 0-9 (10 codes), others (@#$%^&*…·)

° Complete listing in Mano text

° Transmission susceptible to noise.

° Typical transmission rates (1500 Kbps, 56.6 Kbps)

° How to keep data transmission accurate?

Page 84: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Parity Codes

Parity codes are formed by concatenating a parity bit, P to each code word of C.

In an odd-parity code, the parity bit is specified so that the total number of ones is odd.

In an even-parity code, the parity bit is specified so that the total number of ones is even.

Information BitsP

1 1 0 0 0 0 1 1

Added even parity bit

0 1 0 0 0 0 1 1

Added odd parity bit

Page 85: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Parity Code Example

Concatenate a parity bit to the ASCII code for the characters 0, X, and = to produce both odd-parity and even-parity codes.

Character ASCII Odd-Parity ASCII Even-Parity ASCII

0 0110000 10110000 00110000

X 1011000 01011000 11011000

= 0111100 10111100 00111100

Page 86: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Binary Data Storage

• Binary cells store individual bits of data

• Multiple cells form a register.

• Data in registers can indicate different values

• Hex (decimal)

• BCD

• ASCII

Binary Cell

0 0 1 0 1 0 1 1

Page 87: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Register Transfer

Data can move from register to register. Digital logic used to process data. We will learn to design this logic.

Register A Register B

Register C

Digital Logic Circuits

Page 88: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Transfer of Information

Data input at keyboard Shifted into place Stored in memory

NOTE: Data input in ASCII

Page 89: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Building a Computer

We need processing We need storage We need communication

You will learn to use and design these components.

Page 90: ECEN 248: INTRODUCTION TO DIGITAL DESIGN Lecture Set A Dr. S.G.Choi Dept. of Electrical and Computer Engineering.

Summary

Although 2’s complement most important, other number codes exist.

ASCII code used to represent characters (including those on the keyboard).

Registers store binary data. Next time: Building logic circuits!