數位系統 Digital Systems

Department of Computer Science and Information Engineering, Chaoyang University of Technology

朝陽科技大學資工系

Speaker: Fuw-Yi Yang

## 楊伏夷

伏夷非征番,

道德經 察政章(Chapter 58)

## 伏

者潛藏也道紀章(Chapter 14) 道無形象, 視之不可見者曰

## 夷

Text Book: Digital Design 4th Ed.

Chap 1 Digital Systems and Binary Numbers

1.1 Digital Systems

1.2 Binary Numbers-- Table 1.1

1.3 Number-Base Conversions-- Example 1.1~1.4 1.4 Octal and Hexadecimal Numbers -- Table 1.2 1.5 Complements -- Example 1.5~1.8

1.6 Signed Binary Numbers -- Table 1.3 1.7 Binary Codes -- Table 1.4~1.7

1.8 Binary Storage and Registers -- Figure 1.1~1.2 1.9 Binary Logic -- Table 1.8, Figure 1.3~1.6

Text Book: Digital Design 4th Ed.

Chap 1 1.2 Binary Numbers

*In general, a number expressed in a base-r system has*
*coefficients multiplied by powers of r: *

*a*_{n}*⋅r*^{n}*+a*_{n-1}*⋅r*^{n-1}*+…+a*_{1}*⋅r*^{1}*+a*_{0}*+a*_{-1}*⋅r*^{-1}*+a*_{-2}*⋅r*^{-2 }*+…+a*_{-m}*⋅r*^{-m}*r is called base or radix.*

*In general, a number expressed in a base-r system has*
*coefficients multiplied by powers of r: *

*a*_{n}*⋅r*^{n}*+a*_{n-1}*⋅r*^{n-1}*+…+a*_{1}*⋅r*^{1}*+a*_{0}*+a*_{-1}*⋅r*^{-1}*+a*_{-2}*⋅r*^{-2 }*+…+a*_{-m}*⋅r*^{-m}*r is called base or radix.*

Text Book: Digital Design 4th Ed.

Chap 1 1.2 Binary Numbers

是否注意到指數為負之值呢?

Ex: 2^{-1}, 2^{-3 },2^{-4}

Text Book: Digital Design 4th Ed.

Chap 1 1.3 Number-Base Conversions

Example1.1 Convert decimal 41 to binary, (41)_{10 }= (?)_{2}
(41)_{D}= (?)_{B}
Example1.2 (153)_{10 }= (?)_{8}

Example1.3 (0.6875)_{10 }= (?)_{2}
Example1.4 (0.513)_{10 }= (?)_{8}

Text Book: Digital Design 4th Ed.

Chap 1 1.4 Octal and Hexadecimal Numbers

See Table 1.2

Text Book: Digital Design 4th Ed.

Chap 1 1.4 Octal and Hexadecimal Numbers

See Table 1.2

Text Book: Digital Design 4th Ed.

Chap 1 1.5 Complements

Diminished Radix Complement

*Given a number N in base r having n digits, the (r - 1)’s *
*complement of N is defined as (r*^{n}*- 1) - N.*

The 1’s complement of 1011000 is 0100111 Radix Complement

*Given a number N in base r having n digits, the r’s*
*complement of N is defined as *

*r*^{n}*- N for N*

## ≠

*0 and as 0 for N = 0 .*The 2’s complement of 1011000 is 0101000

Text Book: Digital Design 4th Ed.

Chap 1 1.5 Complements— Subtraction with Complements

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

*1. M + (r*^{n}*- N ), note that (r*^{n}*- N ) is r’s complement of N. *

*2. If M* *≥ N, the sum will produce an end carry r** ^{n}*, which
can be discarded; what is left is the result M - N.

*3. If M < N, the sum does not produce an end carry and is *
*equal to r*^{n}*- (N - M), which is r’s complement of *

*(N - M). Take the r’s complement of the sum and place a *
negative sign in front.

Text Book: Digital Design 4th Ed.

Chap 1 1.5 Complements— Subtraction with Complements

Example 1.5 Using 10’s complement, subtract 72532 - 3250.

*1. M = 72532, N = 3250, 10’s complement of N = 96750 *
2.

3. answer: 69282

*sum* *addend* *augend*

## ....

## 169282 96750 72532

## ←←

## ←

## + ←

Text Book: Digital Design 4th Ed.

Chap 1 1.5 Complements— Subtraction with Complements

Example 1.6 Using 10’s complement, subtract 3250 - 72532.

*1. M = 3250, N = 72532, 10’s complement of N = 27468 *
2.

3. answer: -(100000 - 30718) = -69282

## 30718

## 27468

## 03250

## +

Text Book: Digital Design 4th Ed.

Chap 1 1.5 Complements— Subtraction with Complements

Example 1.7 Using 2’s complement,

subtract 1010100 - 1000011.

*1. M = 1010100, *

*N = 1000011, 2’s complement of N = 0111101 *
2.

3. answer: 0010001

## 10010001

## 0111101

## 1010100

## +

Text Book: Digital Design 4th Ed.

Chap 1 1.5 Complements— Subtraction with Complements

Example 1.7' Using 2’s complement,

subtract 1000011 - 1010100.

*1. M = 1000011, *

*N = 1010100, 2’s complement of N = 0101100 *
2.

3. answer: - (10000000 - 1101111) = -0010001

## 1101111

## 0101100

## 1000011

## +

Text Book: Digital Design 4th Ed.

Chap 1 1.5 Complements— Subtraction with Complements

Example 1.8 Using 1’s complement,

subtract 1010100 - 1000011.

*1. M = 1010100, *

*N = 1000011, 1’s complement of N = 0111100 *
2.

3. answer: 0010001 (r* ^{n}* carry, call end-around carry)

## 10010000

## 0111100

## 1010100

## +

Text Book: Digital Design 4th Ed.

Chap 1 1.5 Complements— Subtraction with Complements

Example 1.8' Using 1’s complement,

subtract 1000011 - 1010100.

*1. M = 1000011, *

*N = 1010100, 1’s complement of N = 0101011 *
2.

3. answer: - (1111111 - 1101110) = -0010001

## 1101110

## 0101011

## 1000011

## +

Text Book: Digital Design 4th Ed.

Chap 1 1.6 Signed Binary Numbers

Next table shows signed binary numbers

Text Book: Digital Design 4th Ed.

Chap 1 1.6 Signed Binary Numbers

Arithmetic addition Arithmetic subtraction See next table

Text Book: Digital Design 4th Ed.

Chap 1 1.6 Signed Binary Numbers

**Arithmetic addition with comparison:**

The addition of two numbers in the signed magnitude system follows the rules of ordinary arithmetic.

* If the signed are the same, we add the two magnitudes and *
give the sum the common sign.

* If the signed are different, we subtract the smaller magnitude *
from the larger and give the difference the sign of the larger
magnitude. EX. (+25) + (-38) = -(38 - 25) = -13

Text Book: Digital Design 4th Ed.

Chap 1 1.6 Signed Binary Numbers

**Arithmetic addition without comparison:**

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 signed bits. A carry out of the signed bit position is *
discarded (note that the 4th case).

See examples in next page.

Text Book: Digital Design 4th Ed.

Chap 1 1.6 Signed Binary Numbers

**Arithmetic addition without comparison:**

## 11101101 11110011 11111010 19

## 13 06 11111001

## 11110011 00000110 07

## 13 06

## 00000111 00001101 11111010 07

## 13 06 00010011

## 00001101 00000110 19

## 13 06

## + + +

## −

## − − +

## + +

## − + −

## + + + +

## − + +

## + + +

## + +

Text Book: Digital Design 4th Ed.

Chap 1 1.7 Binary Codes

BCD (Binary-Coded Decimal) Code Table 1.4 Decimal codes Table 1.5

(4 different Codes for the Decimal Digits) Gray code Table 1.6

ASCII character code Table 1.7 Error Detecting code

See next tables 1.4~1.7

Text Book: Digital Design 4th Ed.

Chap 1 1.7 Binary Codes

BCD Code

Decimal codes Gray code

ASCII character code Error Detecting code See next tables

Text Book: Digital Design 4th Ed.

Chap 1 1.7 Binary Codes

BCD Code

Decimal codes Gray code

ASCII character code Error Detecting code See next tables

Text Book: Digital Design 4th Ed.

Chap 1 1.7 Binary Codes

BCD Code

Decimal codes Gray code

ASCII character code Error Detecting code See next tables

Text Book: Digital Design 4th Ed.

Chap 1 1.7 Binary Codes

BCD Code

Decimal codes Gray code

ASCII character code Error Detecting code See next tables

Text Book: Digital Design 4th Ed.

Chap 1 1.8 Binary Storage and Registers

A register is a group of binary cells.

A register with n cells can store any discrete quantity of information that contains n bits.

**A digital system is characterized by its registers and the ****components that perform data processing.**

In digital systems, a register transfer operation is a basic
operation that consists of a transfer of binary information
**from one set of registers into another set of registers.**

Text Book: Digital Design 4th Ed.

Chap 1 1.8 Binary Storage and Registers

A register is a group of binary cells.

A register with n cells can store any discrete quantity of information that contains n bits.

**A digital system is characterized by its registers and the ****components that perform data processing.**

In digital systems, a register transfer operation is a basic
operation that consists of a transfer of binary information
**from one set of registers into another set of registers.**

Text Book: Digital Design 4th Ed.

Chap 1 1.8 Binary Storage and Registers

A register is a group of binary cells.

A register with n cells can store any discrete quantity of information that contains n bits.

**A digital system is characterized by its registers and the ****components that perform data processing.**

In digital systems, a register transfer operation is a basic
operation that consists of a transfer of binary information
**from one set of registers into another set of registers.**

Text Book: Digital Design 4th Ed.

Chap 1 1.9 Binary Logic

Binary logic consists of binary variables and a set of
**logical operations.**

**There are three basic logical operations: **

AND, OR, and NOT.

AND, OR, NOT: Table 1.8 Binary signals: Figure 1.3

Logic circuit: Figures 1.4~1.6 Ex 1.35, 1.36

Binary logic consists of binary variables and a set of
**logical operations.**

**There are three basic logical operations: **

AND, OR, and NOT.

See truth table 1.8 next page.