1 chapter 1 digital systems and binary numbers 授課教師 : 張傳育 博士 (chuan-yu chang...
TRANSCRIPT
![Page 1: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/1.jpg)
1
Chapter 1 Digital Systems and Binary Numbers
授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.)E-mail: [email protected]: (05)5342601 ext. 4337Office: EB212http://MIPL.yuntech.edu.tw
![Page 2: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/2.jpg)
2
Digital Logic Design • Text Book
– M. M. Mano and M. D. Ciletti, “Digital Design," 4th Ed., Pearson Prentice Hall, 2007.
• Reference– class notes
• Grade– Quizzes:
– Mid-term:
– Final:
– Appearance:
![Page 3: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/3.jpg)
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
Chapter 1: Digital Systems and Binary Numbers
![Page 4: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/4.jpg)
4
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 of values of physical quantities
![Page 5: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/5.jpg)
5
5.0
4.0
3.0
2.0
1.0
0.0
Volts
HIGH
LOW
HIGH
LOW
OUTPUT INPUT
Signal Example – Physical Quantity: Voltage
Threshold Region
![Page 6: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/6.jpg)
6
Signal Examples Over Time
Analog
Asynchronous
Synchronous
Time
Continuous in value &
time
Discrete in value & continuous
in time
Discrete in value &
time
Digital
![Page 7: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/7.jpg)
7
A Digital Computer Example
Synchronous or Asynchronous?
Inputs: Keyboard, mouse, modem, microphone
Outputs: CRT, LCD, modem, speakers
Memory
Controlunit Datapath
Input/Output
CPU
![Page 8: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/8.jpg)
8
Binary Numbers and Binary Coding
• Information Types– Numeric
» Must represent range of data needed
» Represent data such that simple, straightforward computation for common arithmetic operations
» Tight relation to binary numbers
– Non-numeric
» Greater flexibility since arithmetic operations not applied.
» Not tied to binary numbers
![Page 9: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/9.jpg)
9
Number of Elements Represented
• Given n digits in radix r, there are rn distinct elements that can be represented.
• But, you can represent m elements, m < rn
• Examples:– You can represent 4 elements in radix r = 2 with n = 2
digits: (00, 01, 10, 11).
– You can represent 4 elements in radix r = 2 with n = 4 digits: (0001, 0010, 0100, 1000).
– This second code is called a "one hot" code.
![Page 10: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/10.jpg)
10
• 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 Number 000001010011101110111
ColorRedOrangeYellowGreenBlueIndigoViolet
![Page 11: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/11.jpg)
11
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 12: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/12.jpg)
12
Binary Numbers
Example: 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
Example: Base-8 number
Example: Base-16 number
3 2 1 016 10(B65F) 11 16 6 16 5 16 15 16 (46,687)
10
10123
5
4.5115251525054
2.4021
10
1012
8
5.8784878281
4.127
![Page 13: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/13.jpg)
13
• To convert to decimal, use decimal arithmetic to form (digit × respective power of 2).
• Example:Convert 110102 to N10:
Converting Binary to Decimal
![Page 14: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/14.jpg)
14
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 15: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/15.jpg)
15
Arithmetic operationArithmetic operations with numbers in base r follow the same rules as decimal numbers.
![Page 16: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/16.jpg)
16
Binary Arithmetic
• Single Bit Addition with Carry
• Multiple Bit Addition
• Single Bit Subtraction with Borrow
• Multiple Bit Subtraction
• Multiplication
• BCD Addition
![Page 17: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/17.jpg)
17
Single Bit Binary Addition with Carry
Given 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 18: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/18.jpg)
18
• Extending this to two multiple bit examples:
Carries 0 0
Augend 01100 10110
Addend +10001 +10111
Sum• Note: The 0 is the default Carry-In to the least significant bit.
Multiple Bit Binary Addition
![Page 19: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/19.jpg)
19
Binary Arithmetic• Addition
Augend: 101101
Addend: +100111
Sum: 1010100
• Subtraction
Minuend: 101101
Subtrahend: 100111
Difference: 000110
• Multiplication
![Page 20: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/20.jpg)
20
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) in
hexadecimal represent: 10, 11, 12, 13, 14, and 15, respectively.
![Page 21: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/21.jpg)
21
Number-Base Conversions
Example1.1 Convert decimal 41 to binary. The process is continued until the integer quotient becomes 0.
![Page 22: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/22.jpg)
22
Number-Base Conversions The arithmetic process can be manipulated more conveniently as follows:
![Page 23: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/23.jpg)
23
Number-Base ConversionsExample 1.2 Convert 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 has sufficient accuracy.
![Page 24: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/24.jpg)
24
Number-Base ConversionsExample1.3
To convert a decimal fraction to a number expressed in base r, a similar procedure is used. However, multiplication is by r instead of 2, and the coefficients found from the integers may range in value from 0 to r 1 instead of 0 and 1.
![Page 25: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/25.jpg)
25
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 26: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/26.jpg)
26
Octal and Hexadecimal Numbers Numbers with different bases: Table 1.2.
![Page 27: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/27.jpg)
27
Octal and Hexadecimal Numbers Conversion 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 left and to the right.
Conversion from binary to hexadecimal is similar, except that the binary number is divided 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 preceding procedure.
![Page 28: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/28.jpg)
28
Complements There 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 29: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/29.jpg)
29
Complements (cont.)■ Radix Complement
The r's complement of an n-digit number N in base r is defined as rn – N for N ≠ 0 and as 0 for N = 0. Comparing with the (r 1) 's complement, we note that the r's complement 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 0010100 The 2's complement of 0110111 is 1001001
![Page 30: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/30.jpg)
30
Complements (cont.)■ Subtraction with Complements
The subtraction of two n-digit unsigned numbers M – N in base r can be done as follows:
![Page 31: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/31.jpg)
31
Complements (cont.)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.
![Page 32: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/32.jpg)
32
Complements (cont.)Example 1.7
Given 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 is Y – X = (2's complement of 1101111) = 0010001.
![Page 33: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/33.jpg)
33
Complements (cont.)
Subtraction 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's complement.
Example 1.8
Repeat Example 1.7, but this time using 1's complement.
There is no end carry, Therefore, the answer is Y – X = (1's complement of 1101110) = 0010001.
![Page 34: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/34.jpg)
34
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:
Table 3 lists all possible four-bit signed binary numbers in the three representations.
![Page 35: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/35.jpg)
35
Signed Binary Numbers (cont.)
![Page 36: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/36.jpg)
36
Signed Binary Numbers (cont.)■ Arithmetic Addition
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 and give the sum the common sign. If the signs are different, we subtract the smaller magnitude from the larger and give the difference the sign if the larger magnitude.
The addition of two signed binary numbers with negative numbers represented in signed-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 37: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/37.jpg)
37
Signed Binary Numbers (cont.)■ Arithmetic Subtraction
In 2’s-complement form:
1. Take the 2’s 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)
![Page 38: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/38.jpg)
38
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 powers of 2 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?
6
1010, 1011, 1100, 1101, 1110, 1111
![Page 39: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/39.jpg)
39
Binary Codes■ BCD Code A number with k decimal digits will
require 4k bits in BCD. Decimal 396 is 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 combinations 1010 through 1111 are not used and have no meaning in BCD.
![Page 40: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/40.jpg)
40
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 41: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/41.jpg)
41
BCD Arithmetic
Given a BCD code, we use binary arithmetic to add the digits:8 1000 Eight
+5 +0101 Plus 5 13 1101 is 13 (> 9)
Note that the result is MORE THAN 9, so must be represented by two digits! To correct the digit, subtract 10 by adding 6 modulo 16.
8 1000 Eight +5 +0101 Plus 5 13 1101 is 13 (> 9)
+0110 so add 6 carry = 1 0011 leaving 3 + cy
0001 | 0011 Final answer (two digits) If the digit sum is > 9, add one to the next significant digit
![Page 42: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/42.jpg)
42
Binary CodesExample:
Consider decimal 185 and its corresponding value in BCD and binary:
■ BCD Addition
![Page 43: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/43.jpg)
43
Binary CodesExample:
Consider the addition of 184 + 576 = 760 in BCD:
■ Decimal Arithmetic
![Page 44: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/44.jpg)
44
BCD Addition Example
• Add 2905BCD to 1897BCD showing carries and digit corrections.
0001 1000 1001 0111+ 0010 1001 0000 0101 0011 10001 1001 1100
+011010010
+0001 1010+011010000
+011010111+000111000
+0001 0100
4
8 0
2
![Page 45: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/45.jpg)
45
Binary Codes■ Other Decimal Codes
![Page 46: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/46.jpg)
46
Binary Codes■ Gray Code
0000000100110010011001110101010011001101111111101010101110011000
![Page 47: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/47.jpg)
47
• What special property does the Gray code have in relation to adjacent decimal digits?
Gray Code
Decimal 8,4,2,1 Gray 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
![Page 48: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/48.jpg)
48
• Does this special Gray code property have any value?
• An Example: Optical Shaft Encoder
B0
111
110
000
001
010
011100
101
B1
B2
(a) Binary Code for Positions 0 through 7
G0
G1
G2
111
101
100 000
001
011
010110
(b) Gray Code for Positions 0 through 7
Gray Code (Continued)
![Page 49: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/49.jpg)
49
Binary Codes■ ASCII Character Code
![Page 50: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/50.jpg)
50
Binary Codes■ ASCII Character Code
![Page 51: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/51.jpg)
51
ASCII Character Codes
• American Standard Code for Information Interchange
• A 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).
(Refer to Table 1.7)
![Page 52: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/52.jpg)
52
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 when punched paper tape was used to store messages.
Punching all holes in a row erased a mistake!
![Page 53: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/53.jpg)
53
Binary Codes■ Error-Detecting Code
To 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 54: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/54.jpg)
54
Binary Codes■ Error-Detecting Code
• 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 55: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/55.jpg)
55
4-Bit Parity Code Example
• Fill in the even and odd parity bits:
• The codeword "1111" has even parity and the codeword "1110" has odd parity. Both can be used to represent 3-bit 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 -
01101001
10010110
![Page 56: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/56.jpg)
56
UNICODE
• UNICODE extends ASCII to 65,536 universal characters codes
– For encoding characters in world languages
– Available in many modern applications
– 2 byte (16-bit) code words
– See Reading Supplement – Unicode on the Companion Website http://www.prenhall.com/mano
![Page 57: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/57.jpg)
57
Binary Storage and Registers■ Registers
A binary cell is a device that possesses two stable states and is capable of storing one of the two states.
A register is a group of binary cells. A register with n cells can store any discrete qua
ntity 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 Transfer– a transfer of the information stored in one register to another– one of the major operations in digital system– an example
![Page 58: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/58.jpg)
58
Transfer of information
![Page 59: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/59.jpg)
59
• The other major component of a digital system– circuit elements to manipulate individual bits of information
![Page 60: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/60.jpg)
60
Binary Logic■ Definition of Binary Logic
Binary 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 each variable having two and only two distinct possible values: 1 and 0, There are three basic logical operations: AND, OR, and NOT.
![Page 61: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/61.jpg)
61
Binary Logic
■ The truth tables for AND, OR, and NOT are given in Table 1.8.
![Page 62: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/62.jpg)
62
Binary Logic■ Logic gates Example of binary signals
![Page 63: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/63.jpg)
63
Binary Logic■ Logic gates Graphic Symbols and Input-Output Signals for Logic gates:
Fig. 1.4 Symbols for digital logic circuits
Fig. 1.5 Input-Output signals for gates
![Page 64: 1 Chapter 1 Digital Systems and Binary Numbers 授課教師 : 張傳育 博士 (Chuan-Yu Chang Ph.D.) E-mail: chuanyu@yuntech.edu.twchuanyu@yuntech.edu.tw Tel: (05)5342601](https://reader033.vdocuments.site/reader033/viewer/2022061618/56649e185503460f94b04a3a/html5/thumbnails/64.jpg)
64
Binary Logic■ Logic gates Graphic Symbols and Input-Output Signals for Logic gates:
Fig. 1.6 Gates with multiple inputs