chapter 1: digital systems and binary...

48
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 Chapter 1: Digital Systems and Binary Numbers

Upload: phamque

Post on 14-Mar-2018

226 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

•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

Chapter 1: Digital Systems and Binary Numbers

Page 2: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Signal

•An information variable represented by physical quantity•For digital systems, the variable takes on discrete 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)– and words On and Off.

•Binary values are represented by values or ranges ofvalues of physical quantities

Page 3: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Digital System

•A digital system is an interconnection of digital modules. Tounderstand the operation of each digital module, it isnecessary to have a basic knowledge of digital circuitsand their logical function.

•A major trend in digital design methodology is the use of aHDL to describe and simulate the functionality of a digitalcircuit, it is important that students become familiar withan HDL‐based design methodology.

Page 4: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Numbers

•Decimal number

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

… a5a4a3a2a1.a1a2a3…

Decimal point

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

Example:

jaBase or radix

Power

•General form of base-r system1 2 1 1 2

1 2 1 0 1 2n 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

Page 5: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary NumbersExample: Base-2 number

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

8

3 2 1 0 110

(127.4)

1 8 2 8 1 8 7 8 4 8 (87.5)

Example: Base-16 number3 2 1 0

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

Page 6: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary NumbersExample: 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"Powers of two

Table 1.1

Page 7: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Arithmetic operationArithmetic operations with numbers in base r follow the same rules as decimalnumbers.

Page 8: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Arithmetic

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

Page 9: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Arithmetic•Addition

Augend: 101101

Addend: +100111

Sum: 1010100

•Subtraction

Minuend: 101101

Subtrahend: 100111

Difference: 000110

Multiplicand 1011Multiplier 101Partial Products 1011

0000 -1011 - -

Product 110111

•Multiplication

Page 10: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Number-Base Conversions

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

The six letters (in addition to the 10 integers) inhexadecimal represent: 10, 11, 12, 13, 14, and 15,respectively.

Page 11: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Number-Base Conversions

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

Page 12: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Number-Base ConversionsThe arithmetic process can be manipulated more conveniently as follows:

Page 13: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Number-Base ConversionsExample 1.2Convert decimal 153 to octal. The required base r is 8.

Example1.3Convert (0.6875)10 to binary.

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

Page 14: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Number-Base ConversionsExample1.3

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

Page 15: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Number-Base ConversionsExample1.4Convert (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

Page 16: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Octal and Hexadecimal NumbersNumbers with different bases: Table 1.2.

Page 17: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Octal and Hexadecimal NumbersConversion from binary to octal can be done by positioning the binary number into

groups of three digits each, starting from the binary point and proceeding to the leftand 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.

Page 18: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Complements of NumbersThere are two types of complements for each base-r system: the radix complement and

diminished radix complement.

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

■ Diminished Radix Complement

Example:

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

Example:

Page 19: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Complements of Numbers■ Radix Complement

The r's complement of an n-digit number N in base r is defined as rn –N for 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 = [(rn 1) –N] + 1.

Example: Base-10

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

Example: Base-10

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

Page 20: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Complements of Numbers■ Subtraction with Complements

The subtraction of two n-digit unsigned numbers M –N in base r can be done as follows:

Page 21: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Complements of NumbersExample 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.

Page 22: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Complements of NumbersExample 1.7Given the two binary numbers X = 1010100 and Y = 1000011, perform the subtraction (a)X –Y and (b) Y X by using 2's complement.

There is no end carry.Therefore, the answer isY –X = (2's complementof 1101111) = 0010001.

Page 23: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Complements of NumbersSubtraction of unsigned numbers can also be done by means of the (r 1)'s

complement. Remember that the (r 1) 's complement is one less then the r'scomplement.

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.

Page 24: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Signed Binary NumbersTo 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:

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

Page 25: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Signed Binary Numbers

Page 26: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Signed Binary Numbers■ Arithmetic Addition

The addition of two numbers in the signed-magnitude system follows the rules ofordinary arithmetic. If the signs are the same, we add the two magnitudes and givethe 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.

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:

Page 27: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Codes■ BCD Code A number with k decimal digits will

require 4k bits in BCD. Decimal 396is represented in BCD with 12bits as0011 1001 0110, with each groupof 4 bits representing one decimaldigit. A decimal number in BCD isthe same as its equivalent binarynumber only when the number isbetween 0 and 9. A BCD numbergreater than 10 looks different fromits equivalent binary number, eventhough both contain 1's and 0's.Moreover, the binary combinations1010 through 1111 are not usedand have no meaning in BCD.

Page 28: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Signed Binary Numbers■ Arithmetic Subtraction

In 2’s-complement form:

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

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

( ) ( ) ( ) ( )( ) ( ) ( ) ( )

A B A BA B A B

Example:

(6) (13) (11111010 11110011)

(11111010 + 00001101)

00000111 (+ 7)

Page 29: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

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

■ BCD Addition

Page 30: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

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

■ Decimal Arithmetic

Page 31: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Codes■ Other Decimal Codes

Page 32: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Codes■ Gray Code

Page 33: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Codes■ ASCII Character Code

Page 34: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Codes■ ASCII Character Code

Page 35: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Codes■ ASCII Character Code

Page 36: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

ASCII Character Codes

•American Standard Code for InformationInterchange

•A popular code used to represent information sentas character-based data.

•It uses 7-bits to represent:–94 Graphic printing characters.–34 Non-printing characters

•Some non-printing characters are used for textformat (e.g. BS = Backspace, CR = carriage return)

•Other non-printing characters are used for recordmarking and flow control (e.g. STX and ETX startand end text areas).

(Refer to Table 1.7)

Page 37: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

ASCII Properties

ASCII has some interesting properties:Digits 0 to 9 span Hexadecimal values 3016 to 3916 .Upper case A - Z span 4116 to 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 whenpunched paper tape was used to store messages.

Punching all holes in a row erased a mistake!

Page 38: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Codes■ Error-Detecting CodeTo detect errors in data communication and processing, an eighth bit is sometimes

added to the ASCII character to indicate its parity.A parity bit 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:

Page 39: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Codes■ Error-Detecting Code

•Redundancy (e.g. extra information), in the form of extrabits, can be incorporated into binary code words to detectand correct errors.

•A simple form of redundancy is parity, an extra bitappended onto the code word to make the number of 1’sodd or even. Parity can detect all single-bit errors andsome multiple-bit errors.

•A code word has even parity if the number of 1’s in thecode word is even.

•A code word has odd parity if the number of 1’s in thecode word is odd.

Page 40: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Storage and Registers■ Registers

A binary cell is a device that possesses two stable states and is capable of storingone of the two states.

A register is a group of binary cells. A register with n cells can store any discretequantity of information that contains n bits.

n cells 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 Transfera transfer of the information stored in one register to anotherone of the major operations in digital systeman example

Page 41: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Transfer of information

Page 42: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

•The other major component of a digital system–circuit elements to manipulate individual bits of information

Page 43: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Logic■ Definition of Binary LogicBinary logic consists of binary variables and a set of logical operations. The variables

are designated by letters of the alphabet, such as A, B, C, x, y, z, etc, with eachvariable having two and only two distinct possible values: 1 and 0, There are threebasic logical operations: AND, OR, and NOT.

Page 44: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Logic

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

Page 45: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Logic■ Logic gatesExample of binary signals

Page 46: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Logic■ Logic gatesGraphic Symbols and Input-Output Signals for Logic gates:

Fig. 1.4 Symbols for digital logic circuits

Fig. 1.5Input-Output signalsfor gates

Page 47: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Binary Logic■ Logic gatesGraphic Symbols and Input-Output Signals for Logic gates:

Fig. 1.6 Gates with multiple inputs

Page 48: Chapter 1: Digital Systems and Binary Numbersmyweb.utaipei.edu.tw/~cyang/class/Digital_System/ch_01.pdfA binary cell is a device that possesses two stable states and is capable of

Web Search Topic•BCD code•ASCII•Storage register•Binary logic•BCD addition•Binary codes•Binary numbers•Excess‐3 code