40
Introduction to Electrical Engineering, II Instructor: Andrew B. Kahng (lecture) Email: [email protected] Telephone: 858-822-4884 office, 858-353- 0550 cell Office: 3802 AP&M Lecture: TuThu 3:30pm – 4:50pm, HSS, Room 2250 Discussion: Wed 6:00pm-6:50pm, Peterson Hall, 108 Class Website: http://vlsicad.ucsd.edu/courses/ece20b/wi03 Login: ece20b Password: b02ece ECE 20B, Winter 2003

ECE 20B, Winter 2003

  • Upload
    hanzila

  • View
    28

  • Download
    0

Embed Size (px)

DESCRIPTION

ECE 20B, Winter 2003. - PowerPoint PPT Presentation

Citation preview

Page 1: ECE 20B, Winter 2003

Introduction to Electrical Engineering, II

Instructor: Andrew B. Kahng (lecture)Email: [email protected]: 858-822-4884 office, 858-353-0550 cellOffice: 3802 AP&MLecture: TuThu 3:30pm – 4:50pm, HSS, Room 2250Discussion: Wed 6:00pm-6:50pm, Peterson Hall, 108

Class Website: http://vlsicad.ucsd.edu/courses/ece20b/wi03

Login: ece20bPassword: b02ece

ECE 20B, Winter 2003

Page 2: ECE 20B, Winter 2003

Purpose of Course

Introduction to design of digital systems and computer hardware

Basic to CS, EE, CE Major topics

– Information representation and manipulation– Logic elements and Boolean algebra– Combinational Logic– Arithmetic Logic– Sequential Logic– Registers, Counters, Memories– Control

Page 3: ECE 20B, Winter 2003

Administration

Lab instructor: Prof. Mohan Trivedi Textbook: Mano and Kime, 2nd edition (updated)

– Goal: cover MK Chapters 1-5, (6), 8– Rizzoni (Sections 12.1-2) used only for op amps

Labs– This week: (1) show up and verify partner; (2) if you

need a partner, talk to Prof. Trivedi– If you need to switch lab sections, go to undergrad office

Adding ECE 20B– Must get stamp from undergrad office in EBU I– Prerequisites rigidly enforced

Page 4: ECE 20B, Winter 2003

Course Structure Homework: assigned but not collected

– All problems and solutions posted on web– Exams are based on homework problems– Do problems before looking at solutions!

Discussion: Wed 6:00-6:50pm, Peterson 108– Will typically go over the previous lectures and problems

Grading– 2/5: 2 in-class midterms (Jan 30, Feb 25), – 2/5: 1 final– 1/5: un-announced in-class quizzes– Exams cover both lecture (~3/4) and lab (~1/4)

• For each lab, a set of prelab questions will be assigned. These must be included in your lab notebook.

Page 5: ECE 20B, Winter 2003

Course Conduct Resources

– Email– Discussion session (TA)– Lab sessions (readers)– http://www.prenhall.com/mano/

Questions about course – see me– Broader consultation – see academic advisor

Academic misconduct: do not let this happen

Page 6: ECE 20B, Winter 2003

Introduction

Assigned reading: Chapters 1, 2 of MK (see website for specific sections)

Homework: Check website for problems/solutions Today

– Concept of “digital”– Number systems

Next lecture– Binary logic– Boolean algebra

We will spend ~3 weeks going through the first 3 chapters of MK.

Page 7: ECE 20B, Winter 2003

Digital System Takes a set of discrete information inputs and discrete

internal information (system state) and generates a set of discrete information outputs.

System State

DiscreteInformationProcessingSystem

DiscreteInputs Discrete

Outputs

Page 8: ECE 20B, Winter 2003

Types of Systems With no state present

– Combinational logic system– Output = Function (Input)

With state present– State updated at discrete times (e.g., once per clock tick)

Synchronous sequential system

– State updated at any time

Asynchronous sequential system

Page 9: ECE 20B, Winter 2003

Example: Digital Counter (e.g., Odometer)

1 30 0 5 6 4UP

RESET

Inputs: Count Up, Reset Outputs: Visual Display State: “Value” of stored digits Is this system synchronous or asynchronous?

Page 10: ECE 20B, Winter 2003

Example: Digital Computer

Inputs: keyboard, mouse, modem, microphone Outputs: CRT, LCD, modem, speakers Is this system synchronous or asynchronous?

Page 11: ECE 20B, Winter 2003

Signals Information variables mapped to physical quantities  In digital systems, the quantities take on discrete

values – Two-level, or binary, values are the most prevalent values

in digital systems– Binary values are represented abstractly by digits 0 and 1

Signal examples over time:Analog

Asynchronous

Synchronous

(Time)

Page 12: ECE 20B, Winter 2003

Physical Signal Example - Voltage

Threshold Region

Other physical signals representing 1 and 0– CPU Voltage– Disk Magnetic field direction– CD Surface pits / light– Dynamic RAM Charge

Page 13: ECE 20B, Winter 2003

Threshold in the News

Punched = 1 Not punched = 0 What about the rest?

Page 14: ECE 20B, Winter 2003

Number Systems Decimal Numbers

– What does 5,634 represent?– Expanding 5,634:

5 x 103 = 5,000 + 6 x 102 = 600 + 3 x 101 = 30 + 4 x 100 = 4 5,634

– What is “10” called in the above expansion?The radix.

– What is this type of number system called? Decimal.

– What are the digits for decimal numbers? 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.– What are the digits for radix-r numbers? 0, 1, …, r-1.

Page 15: ECE 20B, Winter 2003

Powers of 2 Noteworthy powers of 2:

• 210 = kilo- = K; • 220 = mega- = M;• 230 = giga- = G;• … tera-, peta-, …

Page 16: ECE 20B, Winter 2003

General Base Conversion

Given a number of radixr of

“n” integer digits an-1,…,a0

nand

“m” fractional digits a-1,…,a-m

written as :

has value:

(Number)r = ( ) ( ) +

j = -1

j = -m

jj

ii = n-1

i = 0i rara

(Integer Portion) + (Fraction Portion)

Number Representation

an-1 an-2 an-3 … a2 a1 a0 . a-1 a-2 … a-m

Page 17: ECE 20B, Winter 2003

Commonly Occurring Bases

Name Radix Digits

Binary 2 0,1

Octal 8 0,1,2,3,4,5,6,7

Decimal 10 0,1,2,3,4,5,6,7,8,9

Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

(= 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)

Page 18: ECE 20B, Winter 2003

To convert to decimal, use decimal arithmetic to sum the weighted powers of two: 

Converting 110102 to N10:

N10 = 1 × 24 + 1 × 23 + 0 × 22 + 1 × 21 + 0 × 20

= 26

Converting Binary to Decimal

Page 19: ECE 20B, Winter 2003

Method 1 (Method 2 – repeated division – next slide)– Subtract the largest power of 2 that gives a positive result and

record the power.– Repeat, subtracting from the prior result, until the remainder is

zero.– Place 1’s in the positions in the binary result corresponding to

the powers recorded; in all other positions place 0’s. Example: 62510 10011100012

• 625 – 512 = 113 9• 113 – 64 = 49 6• 49 – 32 = 17 5• 17 – 16 = 1 4• 1 – 1 = 0 1

– Place 1’s in the the positions recorded and 0’s elsewhere Converting binary to decimal: sum weighted powers of 2 using

decimal arithmetic, e.g., 512 + 64 + 32 + 16 + 1 = 625

Converting Decimal to Binary

Page 20: ECE 20B, Winter 2003

Conversion Between Bases Convert the Integral Part

– Repeatedly divide the number by the radix you want to convert to and save the remainders. The new radix digits are the remainders in reverse order of computation.

Why does this work? This works because, the remainder left in the division is always is the coefficient of the radix’s exponent.

• If the new radix is > 10, then convert all remainders > 10 to digits A, B, …

Convert the Fractional Part– Repeatedly multiply the fraction by the radix and save the integer digits

that result. The new radix fraction digits are the integer numbers in computed order.

Why does this work?To convert fractional part, it should be divided by reciprocal of radix, which is same as multiplying with radix.

• If the new radix is > 10, then convert all integer numbers > 10 to digits A, B, …

Join together with the radix point

Page 21: ECE 20B, Winter 2003

Example: Convert 46.687510 To Base 2

Convert 46 to Base 246/2 = 23 remainder = 0

23/2 = 11 remainder = 1

11/2 = 5 remainder = 1

5/2 = 2 remainder = 1

2/2 = 1 remainder = 0

1/2 = 0 remainder = 1

Read off in reverse order: 1011102

Convert 0.6875 to Base 2:0.6875 * 2 = 1.3750 int = 1

0.3750 * 2 = 0.7500 int = 0

0.7500 * 2 = 1.5000 int = 1

0.5000 * 2 = 1.0000 int = 1

0.0000

Read off in forward order: 0.10112

Join together with the radix point: 1011110.10112

Page 22: ECE 20B, Winter 2003

Converting Among Octal, Hexadecimal, Binary Octal (Hexadecimal) to Binary:

– Restate the octal (hexadecimal) as three (four) binary digits, starting at radix point and going both ways

Binary to Octal (Hexadecimal):– Group the binary digits into three (four) bit groups starting at

the radix point and going both ways, padding with zeros as needed in the fractional part

– Convert each group of three (four) bits to an octal (hexadecimal) digit

Example: Octal to Binary to Hexadecimal

6 3 5 . 1 7 7 8

= 110|011|101 . 001|111|111 2

= 1|1001|1101 . 0011|1111|1(000)2 (regrouping)

= 1 9 D . 3 F 816 (converting)

Page 23: ECE 20B, Winter 2003

Non-numeric Binary Codes Given n binary digits (called bits), a binary code

is a mapping from a subset of the 2n binary numbers to some set of represented elements.

Example: A

binary code

for the seven

colors of the

rainbow

Binary Number Color000 Red001 Orange010 Yellow011 Green100 (Not mapped)101 Blue110 Indigo111 Violet

Flexibility of representation

• can assign binary code word to any numerical or non- numerical data as long as data uniquely encoded.

Page 24: ECE 20B, Winter 2003

Given M elements to be represented by a binary code, the minimum number of bits, n, needed satisfies the following relationships:

– 2n >= M > 2n – 1

– n = ceil(log2 M) where ceil(x) is the smallest integer greater than or equal to x

Example: How many bits are required to represent decimal digits with a binary code?– M = 10 n = 4

Number of Bits Required

Page 25: ECE 20B, Winter 2003

Number of Elements Represented Given n digits in radix r, there are rn distinct elements

that can be represented. But, can represent m elements, m < rn

Examples:– Can represent 4 elements in radix r = 2 with n = 2 digits: (00, 01,

10, 11)– Can represent 4 elements in radix r = 2 with n = 4 digits: (0001,

0010, 0100, 1000)• This code is called a "one hot" code

Page 26: ECE 20B, Winter 2003

Binary Codes for Decimal Digits

Decimal 8,4,2,1 Excess3 8,4,-2,-1 Gray 0 0000 0011 0000 0000 1 0001 0100 0111 0100 2 0010 0101 0110 0101 3 0011 0110 0101 0111 4 0100 0111 0100 0110 5 0101 1000 1011 0010 6 0110 1001 1010 0011 7 0111 1010 1001 0001 8 1000 1011 1000 1001 9 1001 1100 1111 1000

There are over 8,000 ways that you can chose 10 elements from the 16 binary numbers of 4 bits. A few are useful:

Page 27: ECE 20B, Winter 2003

Binary Coded Decimal (BCD) The BCD code is the 8,4,2,1 code. This code is the simplest, most intuitive binary code for

decimal digits and uses the same weights as a binary number, but only encodes the first ten values from 0 to 9.

Example: 1001 (9) = 1000 (8) + 0001 (1) How many “invalid” code words are there? What are the “invalid” code words?

Page 28: ECE 20B, Winter 2003

Excess-3 Code and 8, 4, –2, –1 CodeDecimal Excess-3 8, 4, –2, –1

0 0011 0000

1 0100 0111

2 0101 0110

3 0110 0101

4 0111 0100

5 1000 1011

6 1001 1010

7 1010 1001

8 1011 1000

9 1100 1111

What property is common to these codes?– These are reflected codes; complementing is performed simply by

replacing 0’s by 1’s and vice-versa

Page 29: ECE 20B, Winter 2003

What property does this Gray code have?– Counting up or down changes only one bit at a time

(including counting between 9 and 0)

Gray Code

Decimal 8,4,2,1 Gray 0 0000 0000 1 0001 0100 2 0010 0101 3 0011 0111 4 0100 0110 5 0101 0010 6 0110 0011 7 0111 0001 8 1000 1001 9 1001 1000

Page 30: ECE 20B, Winter 2003

Gray Code: Optical Shaft Encoder

Shaft encoder: Capture angular position (e.g., compass) For binary code, what values can be read if the shaft

position is at boundary of “3” and “4” (011 and 100) ? For Gray code, what values can be read ?

Page 31: ECE 20B, Winter 2003

Warning: Conversion or Coding? Do NOT mix up conversion of a decimal number to a

binary number with coding a decimal number with a BINARY CODE. 

1310 = 11012 (This is conversion) 

13 0001|0011 (This is coding)

Page 32: ECE 20B, Winter 2003

Binary Arithmetic

Single Bit Addition with Carry Multiple Bit Addition Single Bit Subtraction with Borrow Multiple Bit Subtraction Multiplication BCD Addition

Page 33: ECE 20B, Winter 2003

Single Bit Binary Addition with CarryGiven two binary digits (X,Y), a carry in (Z) we get the following sum (S) and carry (C):

Carry in (Z) of 0:

Carry in (Z) of 1: Z 1 1 1 1

X 0 0 1 1

+ Y + 0 + 1 + 0 + 1

C S 0 1 1 0 1 0 1 1

Z 0 0 0 0

X 0 0 1 1

+ Y + 0 + 1 + 0 + 1

C S 0 0 0 1 0 1 1 0

Page 34: ECE 20B, Winter 2003

Extending this to two multiple bit examples:

Carries 00000 01100

Augend 01100 10110

Addend +10001 +10111

Sum 11101 101101 Note: The 0 is the default Carry-In to the least

significant bit.

Multiple Binary Addition

Page 35: ECE 20B, Winter 2003

Given two binary digits (X,Y), a borrow in (Z) we get the following difference (S) and borrow (B):

Borrow in (Z) of 0:

Borrow in (Z) of 1:

Single Bit Binary Subtraction with Borrow

1

1

- Y 

-0 

-1 

-0 

-1

BS 

11 

1 0 

0 0 

1 1

0

1

- Y 

-0 

-1 

-0 

-1

BS 

0 0 

1 1 

0 1 

0 0

Page 36: ECE 20B, Winter 2003

Extending this to two multiple bit examples:

Borrows 0000 0 00110

Minuend 10110 10110

Subtrahend - 10010 - 10011

Difference 00100 00011 Notes: The 0 is a Borrow-In to the least significant bit.

If the Subtrahend > the Minuend, interchange and append a – to the result.

Multiple Bit Binary Subtraction

Page 37: ECE 20B, Winter 2003

Binary MultiplicationThe binary multiplication table is simple:

0 0 = 0 | 1 0 = 0 | 0 1 = 0 | 1 1 = 1

Extending multiplication to multiple digits:

Multiplicand 1011 Multiplier x 101 Partial Products 1011 0000 - 1011 - - Product 110111

Page 38: ECE 20B, Winter 2003

Error-Detection Codes 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.

Page 39: ECE 20B, Winter 2003

3-Bit Parity Code Example Fill in the even and odd parity bits:

The binary codeword "1111" has even parity and the binary code "1110" has odd parity. Both could be used to represent data.

Even Parity Odd Parity Message - Parity Message - Parity

000 - 000 - 001 - 001 - 010 - 010 - 011 - 011 - 100 - 100 - 101 - 101 - 110 - 110 - 111 - 111 -

Page 40: ECE 20B, Winter 2003

ASCII Character Codes American Standard Code for Information Interchange This code is the most popular code used to represent

information sent as character-based data. It uses 7-bits to represent:– 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).

ASCII is a 7-bit code, but most computers manipulate 8-bit quantity called byte. To detect errors, the 8th bit is used as a parity bit.