# dcd lecture 01

Post on 09-Apr-2018

229 views

Category:

## Documents

TRANSCRIPT

• 8/8/2019 DCD Lecture 01

1/50

Digital Circuit Design

Digital Systems andBinary Numbers

Lan-Da Van (), Ph. D.Department of Computer Science

National Chiao Tung UniversityTaiwan, R.O.C.

Fall, 2010

[email protected]

http://www.cs.nctu.edu.tw/~ldvan/

• 8/8/2019 DCD Lecture 01

2/50

Lecture 1

Digital Circuit Design

Lan-Da Van DCD-01-2

Digital Systems

Binary Numbers

Number-Base Conversion

Signed Binary Numbers

Binary Codes

Binary Storage and Registers

Binary Logic

Outline

• 8/8/2019 DCD Lecture 01

3/50

Lecture 1

Digital Circuit Design

Lan-Da Van DCD-01-3

Digital age and information age

Digital computers

general purposes

many scientific, industrial and commercial applications

Digital systems

telephone switching exchanges digital camera

electronic calculators, PDA's

digital TV

Discrete information-processing systems

manipulate discrete elements of information

Digital System

Di i l Ci i D i

• 8/8/2019 DCD Lecture 01

4/50

Lecture 1

Digital Circuit Design

Lan-Da Van DCD-01-4

A Digital Computer Example

Synchronous or

Asynchronous?

Inputs: Keyboard,

mouse, modem,

microphone

Outputs: CRT,

LCD, modem,

speakers

Memory

Control

unit

Datapath

Input/Output

CPU

Di it l Ci it D i

• 8/8/2019 DCD Lecture 01

5/50

Lecture 1

Digital Circuit Design

Lan-Da Van DCD-01-5

Signal

An information variable represented by physical quantityFor digital systems, the variable takes on digital values

Two level, or binary values are the most prevalent values

Binary values are represented abstractly by:

digits 0 and 1

words (symbols) False (F) and True (T)

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

words On and Off.

Binary values are represented by values or ranges of

values of physical quantities

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

6/50

Lecture 1

Digital Circuit Design

Lan-Da Van DCD-01-6

Signal

Analog signal

t->y: y=f(t), y:C, n:C

Discrete-time signal

n->y: y=f(nT), y:C, n:Z

Digital signal

n->y: y=D{f(nT)}, y:Z,n:Z

)3(

)1(

)2(

)1(

2)1110(

2)1000(

2)1011( 2)1000(

t n n

y y y

Analog Signal Discrete-Time Signal Digital Signal

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

7/50

Lecture 1

Digital Circuit Design

Lan-Da Van DCD-01-7

Binary Numbers

Decimal number

5 4 3 2 1 0 1 2 3

5 4 3 2 1 0 1 2 310 10 10 10 10 10 10 10 10a a a a a a a a a

a5a4a3a2a1a0.a1a2a3

Decimal point

3 2 1 07,329 7 10 3 10 2 10 9 10

Example:

ja

Power

General form of base-r system

1 2 1 1 21 2 1 0 1 2

n n m

n n ma r a r a r a r a a r a r a r

Coefficient: aj = 0 to r 1

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

8/50

Lecture 1

Digital Circuit Design

Lan-Da Van DCD-01-8

Example: Base-2 number

Binary Numbers

2 10

4 3 2 1 0 1 2(11010.11) (26.75)

1 2 1 2 0 2 1 2 0 2 1 2 1 2

Example: Base-5 number

5

3 2 1 0 110

(4021.2)

4 5 0 5 2 5 1 5 2 5 (511.5)

Example: Base-8 number

Example: Base-16 number

3 2 1 0

16 10(B65F) 11 16 6 16 5 16 15 16 (46,687)

4

101012

8

)5.87(84878281

)4.127(

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

9/50

Lecture 1

Digital Circuit Design

Lan-Da Van DCD-01-9

Binary Numbers

Example: Base-2 number

2 10(110101) 32 16 4 1 (53)

Special Powers of 2

210 (1024) is Kilo, denoted "K"

220 (1,048,576) is Mega, denoted "M"

230 (1,073, 741,824) is Giga, denoted "G"

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

10/50

Lecture 1

g g

Lan-Da Van DCD-01-10

Arithmetic operations with numbers in base rfollow the same rules as decimalnumbers.

Binary Numbers

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

11/50

Lecture 1

g g

Lan-Da Van DCD-01-11

Binary Arithmetic

Augend: 101101

Sum: 1010100

Subtraction

Minuend: 101101

Subtrahend: 100111

Difference: 000110

Multiplicand 1011

Multiplier 101Partial Products 1011

0000 -1011 - -

Product 110111

Multiplication

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

12/50

Lecture 1

Lan-Da Van DCD-01-12

Numbers with different bases: Table 1.2.

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

13/50

Lecture 1

Lan-Da Van DCD-01-13

Example1.1

Convert decimal 41 to binary. The process is continued until the integer quotientbecomes 0.

Number-Base Conversions

10/2

5/2

2/2

1/2

5

2

1

0

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

14/50

Lecture 1

Lan-Da Van DCD-01-14

The arithmetic process can be manipulated more conveniently as follows:

Number-Base Conversions

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

15/50

Lecture 1

Lan-Da Van DCD-01-15

Example 1.2

Convert decimal 153 to octal. The required base ris 8.

Number-Base Conversions

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

16/50

Lecture 1

Lan-Da Van DCD-01-16

Example1.3

To convert a decimal fraction to a number expressed in base r, a similarprocedure is used. However, multiplication is by rinstead of 2, and thecoefficients found from the integers may range in value from 0 to r 1instead of 0 and 1.

Convert (0.6875)10

to binary.

The process is continued until the fraction becomes 0 or until the number of digits hassufficient accuracy.

Number-Base Conversions

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

17/50

Lecture 1

Lan-Da Van DCD-01-17

Example1.4

Convert (0.513)10 to octal.

From Examples 1.1 and 1.3: (41.6875)10 = (101001.1011)2

From Examples 1.2 and 1.4: (153.513)10 = (231.406517)8

Number-Base Conversions

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

18/50

Lecture 1

Lan-Da Van DCD-01-18

Conversion from binary to octal can be done by positioning the binary number intogroups of three digits each, starting from the binary point and proceeding to the left

and to the right.

Conversion from binary to hexadecimal is similar, except that the binary number isdivided into groups of four digits:

(10 110 001 101 011 111 100 000 110) 2 = (26153.7406)8

2 6 1 5 3 7 4 0 6

Conversion from octal or hexadecimal to binary is done by reversing the precedingprocedure.

Number-Base Conversions

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

19/50

Lecture 1

Lan-Da Van DCD-01-19

There are two types of complements for each base-rsystem: the radix complement anddiminished radix complement.

the r's complement and the second as the (r 1)'s complement.

Example:

For binary numbers, r= 2 and r 1 = 1, so the 1's complement of Nis (2n 1) N.

Example:

Complements

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

20/50

Lecture 1

Lan-Da Van DCD-01-20

Radix ComplementThe r's complement of an n-digit number Nin base r is defined as rn Nfor N 0and as 0 for N= 0. Comparing with the (r 1) 's complement, we note that the r'scomplement is obtained by adding 1 to the (r 1) 's complement, since rn N= [(rn1) N] + 1.

Example: Base-10

The 10's complement of 012398 is 987602The 10's complement of 246700 is 753300

Example: Base-2

The 2's complement of 1101100 is 0010100The 2's complement of 0110111 is 1001001

Complements

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

21/50

Lecture 1

Lan-Da Van DCD-01-21

Subtraction with ComplementsThe subtraction of two n-digit unsigned numbers M Nin base rcan be done as follows:

Complements

an

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

22/50

Lecture 1

Lan-Da Van DCD-01-22

Example 1.5

Using 10's complement, subtract 72532 3250.

Example 1.6

Using 10's complement, subtract 3250 72532

There is no end carry.

Therefore, the answer is (10's complement of 30718) = 69282.

Complements

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

23/50

Lecture 1

Lan-Da Van DCD-01-23

Example 1.7

Given the two binary numbers X= 1010100 and Y= 1000011, perform the subtraction (a)X Y and (b) Y Xby using 2's complement.

There is no end carry.Therefore, the answer is

Y X= (2's complementof 1101111) = 0010001.

Complements

Digital Circuit Design

• 8/8/2019 DCD Lecture 01

24/50

Lecture 1

Lan-Da Van DCD-01-24

Complements

Subtraction of unsigned numbers can also be done by means of the (r 1)'scomplement. Remember that the (r 1) 's complement is one less than the r's

complement.Example 1.8

Repeat Example 1.7, but this time using 1's complement.

There is no end carry,Therefore, the answer isY X= (1's complementof 1101110) = 0010001.

Digital Circuit Design

Si d Bi N b

• 8/8/2019 DCD Lecture 01

25/50

Lecture 1

Lan-Da Van DCD-01-25

Signed Binary Numbers

To represent negative integers, we need a notation for negative values. It is customary to represent the sign with a bit placed in the leftmost position of the

number. The convention is to make the sign bit 0 for positive and 1 for negative.

Example:

Digital Circuit Design

Si d Bi N b

• 8/8/2019 DCD Lecture 01

26/50

Lecture 1

Lan-Da Van DCD-01-26

Signed Binary Numbers

Table 3 lists all possible four-bit signed binary numbers in the three representations.

Digital Circuit Design

Si d Bi N b

• 8/8/2019 DCD Lecture 01

27/50

Lecture 1

Lan-Da Van DCD-01-27

Signed Binary Numbers

The addition of two signed binary numbers with negative numbers represented insigned-2's-complement form is obtained from the addition of the two numbers,including their sign bits.

A carry out of the sign-bit position is discarded.

Example:

The addition of two numbers in the signed-magnitude system follows the rules of

ordinary arithmetic. If the signs are the same, we add the two magnitudes andgive the sum the common sign. If the signs are different, we subtract the smallermagnitude from the larger and give the difference the sign if the larger magnitude.

Digital Circuit Design

Signed Binary Numbers

• 8/8/2019 DCD Lecture 01

28/50

Lecture 1

Lan-Da Van DCD-01-28

Signed Binary Numbers

Arithmetic Subtraction In 2s-complement form:

1. Take the 2s complement of the subtrahend (including the sign bit) and add it to

the minuend (including sign bit).

2. A carry out of sign-bit position is discarded.

( ) ( ) ( ) ( )

( ) ( ) ( ) ( )

A B A B

A B A B

Example:

( 6) ( 13) (11111010 11110011)

(11111010 + 00001101)

00000111 (+ 7)

Digital Circuit Design

BCD Code

• 8/8/2019 DCD Lecture 01

29/50

Lecture 1

Lan-Da Van DCD-01-29

BCD Code

BCD Code A number with kdecimal digits willrequire 4kbits in BCD. Decimal 396is represented in BCD with 12bits as

0011 1001 0110, with each group of

4 bits representing one decimal digit.

A decimal number in BCD is the

same as its equivalent binary

number only when the number is

between 0 and 9. A BCD number

greater than 10 looks different from

its equivalent binary number, even

though both contain 1's and 0's.

Moreover, the binary combinations1010 through 1111 are not used and

have no meaning in BCD.

Digital Circuit Design

BCD Code

• 8/8/2019 DCD Lecture 01

30/50

Lecture 1

Lan-Da Van DCD-01-30

BCD Code

Example:

Consider decimal 185 and its corresponding value in BCD and binary:

Digital Circuit Design

BCD Code

• 8/8/2019 DCD Lecture 01

31/50

Lecture 1

Lan-Da Van DCD-01-31

BCD Code

Example:

Consider the addition of 184 + 576 = 760 in BCD:

Decimal Arithmetic

1

Digital Circuit Design

Other Decimal Codes

• 8/8/2019 DCD Lecture 01

32/50

Lecture 1

Lan-Da Van DCD-01-32

Other Decimal Codes

Other Decimal Codes

Digital Circuit Design

Gray Code

• 8/8/2019 DCD Lecture 01

33/50

Lecture 1

Lan-Da Van DCD-01-33

Gray Code

Gray Code

Digital Circuit Design

Gray Code

• 8/8/2019 DCD Lecture 01

34/50

Lecture 1

Lan-Da Van DCD-01-34

Does this special Gray code property have

any value?An Example: Optical Shaft Encoder

B 0

111

110

000

001

010

011100

101

B 1

B 2

(a) Binary Code for Positions 0 through 7

G 0G 1

G 2

111

101

100 000

001

011

010110

(b) Gray Code for Positions 0 through 7

Gray Code

Digital Circuit Design

ASCII Character Code

• 8/8/2019 DCD Lecture 01

35/50

Lecture 1

Lan-Da Van DCD-01-35

ASCII Character Code

ASCII Character Code

Digital Circuit Design

ASCII Character Code

• 8/8/2019 DCD Lecture 01

36/50

Lecture 1

Lan-Da Van DCD-01-36

ASCII Character Code

ASCII Character Code

Digital Circuit Design

ASCII Character Code

• 8/8/2019 DCD Lecture 01

37/50

Lecture 1

Lan-Da Van DCD-01-37

ASCII Character Code

American Standard Code for Information Interchange (Refer

to Table 1.7)A popular code used to represent information sent ascharacter-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 markingand flow control (e.g. STX and ETX start and end text areas).

Digital Circuit Design

ASCII Character Code

• 8/8/2019 DCD Lecture 01

38/50

Lecture 1

Lan-Da Van DCD-01-38

ASCII Character Code

ASCII has some interesting properties:

Digits 0 to 9 span Hexadecimal values 3016 to 3916 .

Upper case A - Z span 4116to 5A16 .

Lower case a - z span 6116 to 7A16 .

Lower to upper case translation (and vice versa)

occurs by flipping bit 6. Delete (DEL) is all bits set,a carryover from when

punched paper tape was used to store messages.

Punching all holes in a row erased a mistake!

Digital Circuit Design

Error Detection Code

• 8/8/2019 DCD Lecture 01

39/50

Lecture 1

Lan-Da Van DCD-01-39

Error Detection Code

Error-Detecting Code

To detect errors in data communication and processing, an eighth bit is sometimesadded to the ASCII character to indicate its parity.

A paritybit is an extra bit included with a message to make the total number of 1's

either even or odd.

Example:

Consider the following two characters and their even and odd parity:

Digital Circuit Design

Error Detection Code

• 8/8/2019 DCD Lecture 01

40/50

Lecture 1

Lan-Da Van DCD-01-40

Error Detection Code

Error-Detecting CodeRedundancy (e.g. extra information), in the form of extra bits,can be incorporated into binary code words to detect andcorrect errors.

A simple form of redundancy is parity, an extra bit appendedonto the code word to make the number of 1s odd or even.

Parity can detect all single-bit errors and some multiple-biterrors.

A code word has even parity if the number of 1s in the codeword is even.

A code word has odd parity if the number of 1s in the codeword is odd.

Digital Circuit Design

Conversion or Coding?

• 8/8/2019 DCD Lecture 01

41/50

Lecture 1

Lan-Da Van DCD-01-41

Conversion or Coding?

Do NOT mix up conversion of a decimal number to a

binary number with coding a decimal number with aBINARY CODE.

1310 = 11012 (This is conversion)

13 0001|0011 (This is coding)

Digital Circuit Design

Binary Storage and Registers

• 8/8/2019 DCD Lecture 01

42/50

Lecture 1

Lan-Da Van DCD-01-42

Binary Storage and Registers

Registers A binary cellis a device that possesses two stable states and is capable of storing

one of the two states.

A registeris a group of binary cells. A register with ncells can store any discrete

quantity of information that contains nbits.

ncells 2n possible states

A binary cell two stable state store one bit of information examples: flip-flop circuits, ferrite cores, capacitor

A register a group of binary cells AX in x86 CPU

Register Transfer a transfer of the information stored in one register to another one of the major operations in digital system an example

Digital Circuit Design

Transfer of information

• 8/8/2019 DCD Lecture 01

43/50

Lecture 1

Lan-Da Van DCD-01-43

Digital Circuit Design

Example of BinaryInformation Processing

• 8/8/2019 DCD Lecture 01

44/50

Lecture 1

Lan-Da Van DCD-01-44

Information Processing

Digital Circuit Design

Binary Logic

• 8/8/2019 DCD Lecture 01

45/50

Lecture 1

Lan-Da Van DCD-01-45

y g

Binary logic consists of binary variables and a set of logical operations. The variablesare designated by letters of the alphabet, such as A, B, C, x, y, z, etc, with each

variable having two and only two distinct possible values: 1 and 0, There are threebasic logical operations: AND, OR, and NOT.

Digital Circuit Design

Binary Logic

• 8/8/2019 DCD Lecture 01

46/50

Lecture 1

Lan-Da Van DCD-01-46

y g

The truth tables for AND, OR, and NOT are given in Table 1.8.

Digital Circuit Design

Binary Logic

• 8/8/2019 DCD Lecture 01

47/50

Lecture 1

Lan-Da Van DCD-01-47

y g

Logic gates Example of binary signals

Digital Circuit Design

Binary Logic

• 8/8/2019 DCD Lecture 01

48/50

Lecture 1

Lan-Da Van DCD-01-48

g

Logic gates Graphic Symbols and Input-Output Signals for Logic gates:

Input-Output signals

for gates

Digital Circuit Design

Binary Logic

• 8/8/2019 DCD Lecture 01

49/50

Lecture 1

Lan-Da Van DCD-01-49

Logic gates Graphic Symbols and Input-Output Signals for Logic gates:

Digital Circuit Design

Conclusion

• 8/8/2019 DCD Lecture 01

50/50

Lecture 1

Lan-Da Van DCD-01-50

Conclusion

You have learned the following terms:

Binary number Number Conversion

Complement

Simple arithmetic

Binary codes

Storage and register Binary logic