ENG2410 Digital Design “Introduction to Digital...

66
ENG2410 Digital Design “Introduction to Digital Systems” Fall 2017 S. Areibi School of Engineering University of Guelph

Transcript of ENG2410 Digital Design “Introduction to Digital...

ENG2410Digital Design

“Introduction to Digital Systems”

Fall 2017S. Areibi

School of EngineeringUniversity of Guelph

2

Resources

� Chapter #1, Mano Sections� 1.1 Digital Computers

� 1.2 Number Systems

� 1.3 Arithmetic Operations

� 1.4 Decimal Codes

� 1.5 Alphanumeric Codes

3

Topics

� Computing Devices and VLSI Design

� Signals (Digital vs. Analog)

� Digital Systems and Computers

� Number systems [binary, octal, hex]

� Base Conversion

� Arithmetic Operations

� Decimal Codes [BCD]

� Alphanumeric Codes

4

5

PDA

Body

Entertainment

Household

Communication

Home Networking

Car

Medicine

PC

Super Computer

Computing Devices Everywhere!“Embedded Systems”

Game console

What is the main enabler to such digital systems?

6

The Transistor Revolution

First transistorBell Labs, 1948

Bipolar logic1960’s

• Intel 4004 processor • Designed in 1971• Almost 3000 transistors• Speed:1 MHz operation

n+n+S

GD

+

DEVICE

CIRCUIT

GATE

MODULE

SYSTEMSpecification

Functional design

Circuit design

Physical design

Test/Fabrication

Logic design

The VLSI Design Cycle

© K

LMH

Lien

ig8

1.3 VLSI Design Styles Contact

Vdd

GND

OUT

IN2

IN1OUT

IN2

IN1

OUTIN1

Vdd

GND

IN2

Power (Vdd)-Rail

Ground (GND)-Rail

Diffusion layer

p-typetransistor

n-typetransistor

Metal layer

Poly layer

9

10

Signals

� An information variable represented by a physical quantity (speech, Temp, humidty, noise, …)

11

Signals

Signals can be analogor digital:

1. Analog signals can have an infinite number of values in a range;

2. Digital signals can have only a limited number of values.

12

Analog Signals

Analog

Time

Continuous in

value & time

13

Digital Signals

� For digital systems, the variable takes on discrete values (i.e., not continuous)

Time

DigitalDiscrete in

value

14

Signal Examples Over Time

Asynchronous

Synchronous

Discrete in

value &

continuous in

time

Discrete in

value & time

Digital

� Digital (Binary) values are represented by:

� digits 0 and 1 / False (F) and True (T)

� words (symbols) Low (L) and High (H)

� words On and Off.

Time

15

What are other physical quantities represent 0 and 1?

Binary Values: Other Physical Quantities

CPU: VoltageHard Drive: Magnetic Field Direction

CD: Surface Pits/Light

Dynamic Ram: Electric Charge

16

A Digital Computer Example

Inputs: Keyboard, mouse, modem, microphone

Outputs: CRT, LCD, modem, speakers

Memory

Controlunit Datapath

Input/Output

CPU

Data/Instructions/codeAll in 01010010010

clock

17

18

Number Systems – Representation

� A number with radix r is represented by a string of digits:An - 1An - 2 … A1A0 . A- 1 A- 2 … A- m + 1 A- m

in which 0 ≤ Ai < r and “.” is the radix point.

� The string of digits represents the power series:

( ) ( )(Number)r = ∑∑ +j = - m

jj

i

i = 0i rArA

(Integer Portion) + (Fraction Portion)

i = n - 1 j = - 1

19

Decimal Number System

�Base (also called radix) = 10

● 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }

�Digit Position

● Integer & fraction

�Formal Notation

�Digit Weight

● Weight = (Base) Position

�Magnitude

● Sum of “Digit x Weight”

1 0 -12 -2

5 1 2 7 4

10 1 0.1100 0.01

500 10 2 0.7 0.04

d2*B2+d1*B

1+d0*B0+d-1*B

-1+d-2*B-2

(512.74)10

20

Octal Number System

�Base = 8

● 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }

�Weights

● Weight = (Base) Position

�Formal Notation

�Magnitude

● Sum of “Digit x Weight”

1 0 -12 -2

8 1 1/864 1/64

5 1 2 7 4

5 *8 2+1 *8 1+2 *8 0+7 *8- 1+4 *8 -2

=(330.9375)10

(512.74)8

21

Octal Number System: Example

� For Example, � (27)8 can be expressed as: ( )10

� (17.1)8 can be expressed as: ( )10

22

Hexadecimal Number System

�Base = 16

● 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }

�Weights

● Weight = (Base) Position

�Formal Notation

�Magnitude

● Sum of “Digit x Weight”

1 0 -12 -2

16 1 1/16256 1/256

1 E 5 7 A

1 *162+14 *161+5 *160+7 *16-1+10 *16-2

=(485.4765625)10

(1E5.7A)16

23

Hex to Decimal

� Just multiply each hex digit by decimal value, and add the results.

���� ���� ���� ����

163 162 161 160

4096 256 16 1

(2ac)16

2 • 256 + 10 • 16 + 12 • 1= (684)10

Dec Hex

0 0

1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

10 a

11 b

12 c

13 d

14 e

15 f

24

25

Binary Number System

�Base = 2

● 2 digits { 0, 1 }, called binary dig its or “ bits”

�Weights

● Weight = (Base) Position

�Magnitude

● Sum of “Bit x Weight”

�Formal Notation

�Groups of bits 4 bits = Nibble

8 bits = Byte

1 0 -12 -2

2 1 1/24 1/4

1 0 1 0 1

1 *22+0 *21+1 *20+0 *2-1+1 *2-2

=(5.25)10

(101.01)2

1 0 1 1

1 1 0 0 0 1 0 1

26

Binary → Decimal: Example

7 6 5 4 3 2 1 0

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

1 0 0 1 1 1 0 0

128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = (156)10

What is 10011100 in decimal?

7 6 5 4 3 2 1 0 position

Binary #

position

value

27

Binary Numbers� Examples:

� (00)2 � (0)10

� (01)2 � (1)10

� (0000001)2 � (1)10

� (10)2 � (2)10

� (010)2 � (2)10

� (11)2 � (3)10

� (100)2 � (4)10

� (1001010101000)2

�Strings of binary digits (“bits”)

� One bit can store a number from 0 to 1

� n bits can store numbers from 0 to 2n-1

28

Binary Fractions

bi bi-1 . . . b2 b1 b0 b-1 b-2 b-3 … b-j

1

2

4

2i-1

2i

2-j

1/8

1/4

1/2

Integer Values

Fractional Values

decimal number =

29

Example 1

1 1 0 . 1 12

1 x 22 + 1 x 21 + 0x20 + 1x2-1 + 1x2-2

6 and 3/4

30

Example 2

0 . 1 1 1 1 1 12

63/64

0 x 20 + 1 x 2-1 + 1x2-2 + 1x2-3 + 1x2-4 + 1x2-5 + 1x2-6

Note: (1) Numbers of the form 0.11111…2 are just below 1.0(2) Short form notation for such numbers is 1.0 - ε

Why Binary?

�This is easier to implement in hardware than a unit that can take on 10 different values.

● For instance, it can be represented by a transistor being off (0) or on (1).

● Alternatively, it can be a magnetic stripe that is magnetized with North in one direction (0) or the opposite (1).

�Binary also has a convenient and natural association with logical values of:

● False (0) and

● True (1).31

32

The Power of 2

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

33

34

Number Base Conversions

Decimal(Base 10)

Octal(Base 8)

Binary(Base 2)

Hexadecimal(Base 16)

Evaluate Magnitude

Evaluate Magnitude

Evaluate Magnitude

35

Conversion Between Bases

� To convert from one base to another:

1) Convert the Integer Part

2) Convert the Fraction Part

3) Join the two results with a radix point

Decimal to Binary Conversion

37

Decimal (Integer) to Binary Conversion

�Divide the number by the ‘Base’ (=2)

�Take the remainder (either 0 or 1) as a coefficient

�Take the quotient and repeat the division

Example: (13)10

Quotient Remainder Coefficient

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

MSB LSB

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

38

Decimal (Fraction) to Binary Conversion

�Multiply the number by the ‘Base’ (=2)

�Take the integer (either 0 or 1) as a coefficient

�Take the resultant fraction and repeat multiplication

Example: (0.625)10

Integer Fraction Coefficient

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

MSB LSB

0.625 * 2 = 1 . 250.25 * 2 = 0 . 5 a-2 = 00.5 * 2 = 1 . 0 a-3 = 1

a-1 = 1

39

Decimal to Octal Conversion

Example: (175)10

Quotient Remainder Coefficient

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

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

Example: (0.3125)10

Integer Fraction Coefficient

Answer: ( 0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8

0.3125 * 8 = 2 . 50.5 * 8 = 4 . 0 a-2 = 4

a-1 = 2

40

Decimal to Hex

���� ���� ���� ����

163 162 161 160

4096 256 16 1

Dec Hex

0 0

1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

10 a

11 b

12 c

13 d

14 e

15 f

(684)10

684/16 = 42 rem 12=c c

42/16 = 2 rem 10=a ac

2/16 = 0 rem 2 2ac

41

Hexadecimal (Base 16 )

Dec Bin Hex

0 0000 0

1 0001 1

2 0010 2

3 0011 3

4 0100 4

5 0101 5

6 0110 6

7 0111 7

Dec Bin Hex

8 1000 8

9 1001 9

10 1010 a

11 1011 b

12 1100 c

13 1101 d

14 1110 e

15 1111 f

•Power of 2

•Size of byte

Why usebase 16?

� Strings of 0’s and 1’s too hard to write

� Use base-16 or hexadecimal – 4 bits

42

Hex to Binary

� Convention – write 0x (prefix)

before number

� Hex to Binary – just convert digits

Bin Hex

0000 0

0001 1

0010 2

0011 3

0100 4

0101 5

0110 6

0111 7

1000 8

1001 9

1010 a

1011 b

1100 c

1101 d

1110 e

1111 f

0x2ac

0010 1010 1100

0x2ac = (001010101100)2

No magic – remember hex digit = 4 bits

(2ac)16

43

Binary − Hexadecimal Conversion

�16 = 24

�Each group of 4 bits represents a hexadecimal digit

Hex Binary0 0 0 0 01 0 0 0 12 0 0 1 03 0 0 1 14 0 1 0 05 0 1 0 16 0 1 1 07 0 1 1 18 1 0 0 09 1 0 0 1A 1 0 1 0B 1 0 1 1C 1 1 0 0D 1 1 0 1E 1 1 1 0F 1 1 1 1

Example:

( 1 0 1 1 0 . 0 1 )2

( 1 6 . 4 )16

Pad with Zeros

Works both ways (Binary to Hex & Hex to Binary)

44

Binary to Hex

� Just convert groups of 4 bits

Bin Hex

0000 0

0001 1

0010 2

0011 3

0100 4

0101 5

0110 6

0111 7

1000 8

1001 9

1010 a

1011 b

1100 c

1101 d

1110 e

1111 f

(101001101111011)2

1011

5 3 7 b

(101001101111011)2 = 0x537b = (537b)16

0101 0111 0011

45

Octal − Hexadecimal Conversion

�Convert to Binary as an intermediate step

Example:

( 0 1 0 1 1 0 . 0 1 0 )2

( 1 6 . 4 )16

Assume Zeros

Works both ways (Octal to Hex & Hex to Octal)

( 2 6 . 2 )8

Assume Zeros

46

47

Addition

�Decimal Addition

5 5

55+

011

= Ten ≥ Base

� Subtract a Base

11 Carry

48

Binary Addition�Adding bits:

♦ 0 + 0 = 0

♦ 0 + 1 = 1

♦ 1 + 0 = 1

♦ 1 + 1 = (1) 0

♦ 1 + 1 + 1 = (1) 1

�Adding integers:

carry

0 0 0 . . . . . . 0 1 1 (1)2 = (7)10

+ 0 0 0 . . . . . . 0 1 1 (0)2 = (6)10

= = (13)10

carry

(0) (1)2(1)0 (1)1

0

0 0 0 . . . . . 1

11

49

Binary Addition

�Column Addition

1 0 1111

1111 0+

0000 1 11

≥ (2)10

111111

= (61)10

= (23)10

= (84)10

50

51

Binary Numbers and Binary Coding

� Flexibility of representation� Within constraints below, can assign any

binary combination (called a code word) to any data as long as data is uniquely encoded.

� Information Types� Numeric

� Must represent range of data needed� Very desirable to represent data such that

simple, straightforward computation for common arithmetic operations permitted

� Tight relation to binary numbers

� Non-numeric� Greater flexibility since arithmetic operations

not applied.� Not tied to binary numbers

52

� Given n binary digits (called bits), a binary code is a mapping from a set of represented elements to a subset of the 2n binary numbers.

� Example: Abinary codefor the sevencolors of therainbow

� Code 100 is not used

Non-numeric Binary Codes

Binary Number000001010011101110111

ColorRedOrangeYellowGreenBlueIndigoViolet

53

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

2n > M > 2(n – 1)

n = log2 M where x , is called the ceiling function, i.e the integer greater than or equal to x.

Number of Bits Required

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

� Example: How many bits are required to represent decimal digits with a binary code?• M = 10, hence n = ceiling (log2 10) = ceiling (3.3219) = 4• Checking:

Number of Bits Required

)(loglog

,22

22

1

MceilingMn

whereM nn

==>≥ −

8210162 34 =>≥=54

55

Binary Codes

�Group of n bits

● Up to 2n combinations

● Each combinationrepresents an elementof information

�Binary Coded Decimal (BCD)

● Each Decimal Digit is represented by 4 bits

● (0 – 9) � Valid combinations

● (10 – 15) � Invalid combinations

Decimal BCD0 0 0 0 01 0 0 0 12 0 0 1 03 0 0 1 14 0 1 0 05 0 1 0 16 0 1 1 07 0 1 1 18 1 0 0 09 1 0 0 1

56

Gray Code

� One bit changes fromone code to the nextcode

� Different than Binary

Decimal Gray00 000001 000102 001103 001004 011005 011106 010107 010008 110009 110110 111111 111012 101013 101114 100115 1000

Binary0000000100100011010001010110011110001001101010111100110111101111

57

Binary Representations

� A bit is the most basic unit of information in a computer.

� It is a state of “on” or “off” in a digital circuit.

� Sometimes these states are “high” or “low” voltage instead of “on” or “off..”

� A group of four bits is called a nibble (or nybble).

� Bytes, therefore, consist of two nibbles: a “high-order nibble,” and a “low-order” nibble.

� A byte is a group of eight bits.

� A byte is the smallest possible addressable (can be found via its location) unit of computer storage.

� A word is a contiguous group of bytes.

� Words can be any number of bits (16, 32, 64 bits are common).

58

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.

� (13)10 = (1101)2 (This is conversion)

� (13)BCD ⇔ (0001|0011)BCD (This is coding)

Advantages/Disadvantages?

59

BCD: Advantages/Disadvantages

� Disadvantage:

� It is obvious that a BCD number needs more bits than its equivalent binary value

� (26)10 = (11010)2

� (26)10 = (0010 0110)BCD

� Advantages:

� Computer input/output data are handled by people who use the decimal system. So it is easier to convert back/forth to BCD.

60

61

Character Codes

� From numbers to letters

� ASCII

� Stands for American Standard Code for Information Interchange

� Only 7 bits defined

� Unicode

ASCII Code

American Standard Code for Information Interchange

Info 7-bit CodeA 1000001B 1000010...

.

.

.Z 1011010

a 1100001b 1100010...

.

.

.z 1111010

@ 1000000? 0111111+ 0101011

62

63

ASCII table

64

Reading

� Read Chapter 1

� Make sure you’re comfortable with material

� Check the lecture notes from the

Web site.

� Solve the assignment.

65

Homework

� See Assignment #1 On Web

� I expect you to know number systems well and be able to do conversions and arithmetic� Decimal – Binary

� Binary – Decimal

� Decimal – Hex

� Hex – Decimal

� Will be on test!

66