51013 數位系統導論 (EE2016-B) Chapter 1 2021Sept14th (by E Ray) Ver3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 76

EE2016-B- Fall 2021

數位系統導論
Fundamentals of Logic Design-Chapter 1:
Introduction Number Systems and Convention
Prof. E Ray Hsieh 謝易叡 助理教授

Prof. E Ray Hsieh Fall, 2021


我是謝易叡 (E Ray Hsieh)
• 交大電子博士畢 (2016畢)
• 交大電子博士後研究員(2017~2018) 研發替代役
• 史丹福大學電機系博士後研究員(2018~2020)
• 研究專長:
• 矽奈米電晶體
• 嵌入式記憶體
• 高密度記憶體儲存
• 記憶體內運算晶片設計
• 嵌入式類神經網路晶片設計
• 記憶體強化資訊安全設計
Couse Objectives
• After studying this text, you should be able to apply switching
theory to the solution of logic design problems.
• You will learn both the basic theory of switching circuits and how to
apply it.
• you will study Boolean algebra, which is the basic mathematical tool
needed to analyze and synthesize an important class of switching circuits.
• Starting from a problem statement, you will learn to design circuits of
logic gates that have a specified relationship between signals at the
input and output terminals.
Couse Objectives
• Then you will study the logical properties of flip-flops, which serve
as memory devices in sequential switching circuits.
• By combining flip-flops with circuits of logic gates, you will learn to
design counters, adders, sequence detectors, and similar circuits.
• You will also study the VHDL hardware description language.
• Its application to the design of combinational logic, sequential logic,
and simple digital systems.
Textbooks
 “Fundamentals of Logic Design, Enhanced Edition,
7th Enhanced , “ 2021, by Charles H. Roth, Jr., Larry
L. Kinney, Eugene B. John, Cengage Learning. (ISBN-
13: 9781337620352)
 Grading Policy:
 2 mid terms: 20%, 20%
 1 final exam: 25%
 1 mid-term project (VHDL): 10%
 1 final project (VHDL): 20%
 Attendance: 5%, absence without asking for
leave by E-MAIL ([email protected])
 Deduct one point, if accumulating 5
deductions, YOU FAILED DIRECTLY!!
 CANNOT CHEAT NOR COPY. If you cheat or
copy, YOU FAILED!!
General Information
• Class Hours: Wed. 9:00am to 10:00am; Fri. 15:00 to 17:00
• Professor’s Contact Information:
• Official Room: EECS Blgd. 316 room
• E-mail: [email protected]
• Teaching Assistant’s Contact Information:
電機系大四 孟憲柏同學: [email protected]
電機系大三 辜釩軒同學: [email protected]
課堂助手 電機系大二 史諭澤 同學
Week Date Contents
1 9/15 Ch. 1 – Introduction Number Systems and
(高年級生開課週) 9/17 Convention

2 9/22
Ch. 1 & Ch.2-Boolean Algebra
(新生開課週) 9/24
9/29
Agenda 3
10/01
Ch. 2 & Ch.3-Boolean Algebra (II)

(I) 10/06 Ch. 3 &


4 Ch.4- Boolean Algebra Minterm and Maxterm
10/08 Expansion
10/13 Ch. 4
5
10/15 Ch. 5 – Karnaugh Map
10/20 彈性運用
6
10/22 1st mid-term (Ch. 1~Ch. 4)
Week Date Contents
10/27 Ch. 5 &
7
10/29 Ch.7- Multi-Level Gate Circuits NAND and NOR Gates
11/03 Ch. 7 &
Agenda 8 Ch.8- Combinational Circuit Design and Simulation Using
11/05 Gates
(II) 11/10 Ch. 8 &
9 Ch. 9- Multiplexers, Decoders, and Programmable Logic
11/12 Devices

11/17 Ch. 9 &


10
11/19 Ch.10- Introduction to VHDL
11/24 Ch.10- Introduction to VHDL
11
11/26 2nd mid-term (Ch. 5~Ch. 9)
Week Date Contents
12 12/01,03 Ch.10- Introduction to VHDL
13 12/08, 10 Ch. 11- Latches and Flip-Flops

Agenda 14
12/15
12/17
Ch. 11 &
Ch. 12- Registers and Counters
(III) 12/22 Ch. 12 &
15 Ch. 13- Analysis of Clocked Sequential Circuits
12/24
12/29 Ch. 13- Analysis of Clocked Sequential Circuits
16
12/31 開國紀念日 補假一天
01/05 彈性運用
17
01/07 Final (Ch. 11~Ch. 13)
18 01/14 Demo of Final-project
Fundamentals of Logic Design-Chapter 1:
Introduction Number Systems and Convention
1.1 Digital systems and switching circuits (p.6)
•The design of digital system can be
divided into three parts: system design,
logic design and circuit design.
•System design involves partitioning the
entire system into subsystems and
setting the characteristics of each
subsystem.
1.1 Digital systems and switching circuits (p6)
• Logic design includes examples of deciding how to
link basic logical architecture blocks inside to
perform specific functions, such as determining the
internal links of logical gates and orthotics to
perform binary additions.
• Circuit design includes specifying internal links to
specific components, such as resistors, diodes, and
transistors, to form logic gates, or transverses, or
other logical schema blocks.
1.1 Digital systems and switching circuits (p7)
• Many subsystems of digital systems take the form of Switching circuits,
which have one or more discrete input and output values.


• In this book, you'll learn about two types of switching circuits:
combined and sequential.
Hex to Oct to Dec to Binary Conversion (補充)
23 22 21 20 23 22 21 20

=
=
=
=

=
=
=
=
1.2 Digital systems and transformations (p8)
• Positional notation

Power of 10:
953.7810  9 102  5  101  3  100  7  101  8 102

Power of 2:
1011.112  1 23  0  22  1 21  1 20  1 21  1 22
 8  0  2  1  12  14  11 43  11.7510
1.2 Digital systems and transformations (p9)
• Power of R:
• Any positive integer R (R > 1) can be used as a base of a digital
system

N   a4 a3 a2 a1a0 .a1a2 a3  R


 a4  R 4  a3  R3  a2  R 2  a1  R1  a0  R 0
 a1  R 1  a2  R 2  a3  R 3

Where ai is the coefficient of Ri, and 0 ai R - 1.


1.2 Digital systems and transformations (p9)
• For example:
147.38  1 82  4  81  7  80  3  81  64  32  7  83
 103.37510
Letters are usually used to represent words larger than 9.
For example, in sixteen digits (bottom 16), A is 1010 (10), B is 1011(11),
C is 1100(12), D is 1101 (13), E is 1110 (14), and F is 1111 (15).

A2 F16  10  162  2  161  15 160  2560  32  15  260710


1.2 Digital systems and transformations (p10)
• Use division to convert the decimal integer into a base number R.
N   a n a n  1  a 2 a1 a 0  R  a n R n  a n  1 R n  1    a 2 R 2  a 1 R 1  a 0
N
 a n R n  1  a n  1 R n  2    a 2 R 1  a1  Q 1 , 餘 數 a 0
R
Q1
 a n R n  2  a n  1 R n  3    a 3 R 1  a 2  Q 2 , 餘 數 a1
R
Q2
 a n R n  3  a n 1 R n  4    a 3  Q 3 , 餘 數 a 2
R
……
This step continues until the end.
Note that the remainder of each division is a number to be obtained,
and that is the least (lowest) significant digit is sought first.
1.2 Digital systems and transformations (p10)
• Convert 5310 to binary digits
1.2 Digital systems and transformations (p10)
• You can convert decimal decimals to base R by multiplying them continuously
by R.

F   0.a1a2 a3  a m R  a1 R 1  a2 R 2  a3 R 3    a m R  m


FR  a1  a2 R 1  a3 R 2    a m R  m 1  a1  F1
F1R  a2  a3 R 1    a m R  m  2  a2  F2
F2 R  a3    a m R  m 3  a3  F3
• This step continues until sufficient digits are sought. Notice that the integer
portion of each result is a number you want, and that the most significant
digit is the most significant number first.
1.2 Digital systems and transformations (p11)
• Convert 0.62510 to binary digits.

F  0.625 F1  0.250 F2  0.500


 2  2  2 0.62510  0.1012
1.250 0.500 1.000
 a1  1  a2  0   a3  1
0.7
(p11)
2
1 0.4 <0 • Convert 0.710 to
2 binary digits.
 0  0.8 <0
1.2 Digital 2
systems and 1 0.6 <0
transformations 2
1 0.2 <0
2
 0  0.4  從此處開始循環,因為之前就已經出現0.4
2
 0  0.8 0.710  0.1 0110 0110 01102
1.2 Digital systems and transformations (p12)
• Convert 231.34 to the base 7:
1.2 Digital systems and transformations (p12)
• The conversion from binary to hex (or vice versa).
(補位) (補位)
0 00
(1-1)
1.3 Binary arithmetic (p12)
• The addition table for the binary digits is as follows:

00  0
0 1  1
1 0  1
11  0 同時進位1到下一行
1.3 Binary arithmetic (p13)
• Add 1310 to 1110 in binary :

1 1 1 1 
 進位
1310  1101
1110  1011
11000  2410
1.3 Binary arithmetic (p13)
• The subtraction table for the binary digits is as follows::

00  0
0  1  1 同時從上一行借位1
1 0  1
11  0
1.3 Binary arithmetic (p13)
(a)

02 (從第3行借位)
11101 11101
10011 10011
= 01010 = 01010
(p13)
(b) 10000 12
00011 12 12
=
12 12 12
02 02 02 02
10000 10000 10000 10000
00011 00011 00011 00011
= = = = 01101
(c) 111001 (p13)

001011
= 12
02 02
111001 111001 111001
001011 001011 001011
= 0 = 0 = 110
(c) (p13)

02 02
12 12 12
02 02 02
111001 111001 111001
001011 001011 001011
= 110 = 1110 = 101110
(補充)
(d) 010110
011011
=
02 02
02 02 02 02
010110 010110 010110
011011 011011 011011
= 1 = 011 = 1 011
(d) 010110
011011
02 02 =
沒得借 02 02 沒得借 02 02

010110 010110 沒有負號系統,


無法計算
011011 011011 -> 不可以小減
大,只能大減小。
= 1 011 = ??1 011
1.3 Binary arithmetic (p14)
• The following example illustrates the binary
multiplication of 1310 by 1110: 1101
1011
1101
1101
0000
1101
10001111  14310
1.3 Binary arithmetic (p15)
• The following example illustrates the binary division of
14510 divided by 1110:
14510=100100012

1110=10112

1011 10010001
1.3 Binary arithmetic (p15)
• The following example illustrates the binary division of
14510 divided by 1110: 後退一位

1 12 1
1011 10010001 1011 10010001
02
1011 01011
1001 補0
1011
? 1 10
不可以小減大,
只能大減小。
1.3 Binary arithmetic (p15)
後退一位
12
1
1011 10010001 12 12
01011 02 02 02 02 02 02 02
補0
10010 10010 10010 10010
01011 01011 01011 01011
1 1 1 00111
1.3 Binary arithmetic (p15)
後退一位

11
1011 10010001 02 02
01011 02 02 02
補0
001110 001110 001110 001110
001011 001011 001011 001011
000011 1 011 000011
1.3 Binary arithmetic (p15)
後退一位

11 0 11 0 1
1011 10010001 1011 10010001
01011 01011
補0
001110 001110
001011 001011
00001101 00001101
1011
10
1.4 The number of the complement method (p16)
• 2 Supplement system:
• A positive N notation is a size N that is represented by a symbol + a
size method.
• Negative number (- N) is expressed in its 2 complement N.
• If the word group length is n bits, the 2 complement (N*) of the positive
integer N is defined as follows:

The 2 complement (N*): N*  2  N n (1-2)

Table 1-1 shows the result of n-4, and as shown in Table 1-1, the negative
number of the 2 complement method from -1 to -7 can be obtained by
taking the 2 complements of its positive numbers 1 to 7 (i.e. minus 16).
1.4 Representation of negative numbers (p16)
“1”: 負號
N “0”: 正號

(2n-N)

缺點: Digits減少,可表示的數字範圍變少。
1.4 Representation of negative numbers (p16)
N
-N
10000 – 00000=10000
10000 – 00001=01111 1111 -1
10000 – 00010=01110 1110 -2
10000 – 00011=01101 1101 -3
10000 – 00100=01100 1100 -4
10000 – 00101=01011 1011 -5
10000 – 00110=01010 1010 -6
10000 – 00111=01001 1001 -7
1.4 Representation of negative numbers (p16)
 1’s complement:

0變1,1變0
1.4 Addition of 2’s complement numbers (p17)
• The addition of n-bit binary numbers (signed binary numbers).
• If n is 4,
• The two positive numbers are added together, and < 2n-1.

3 0011
4 0100
7 0111 (正確解)
1.4 Addition of 2 complement numbers (p17)
• The two positive numbers add up, and  2n  1

Correction
負號
overflow
(補位)
由於溢位,所以答案錯誤
( 包括符號共須 位元方能表示) (更正 -> 多一個最左邊的digit)

“溢位”就要”補位”
1.4 Addition of 2’s complement numbers (p18)
• The positive and negative numbers are added (when the value
of the negative number is larger).
5 0101
負號 6 1010
1 1111 (正確解)
2補數還原: 10000-01111= 00001 (正數) * (-1)
(看到2補數負數要還原成正數再加負號)
1.4 Addition of 2’s complement numbers (p18)
• The two negative numbers are added, and > 2n -1.
(補位)

Correction

由於溢位,所以答案錯誤 “溢位”就要”補位”
(−11包括符號共須5位元方能表示) 11
2補數還原: 100000-010101= 0001011 (正數) * (-1)
-11
1.4 Addition of 2’s complement numbers (p18)
 When the sum < 2n-1,
this sum is the final answer.

 When the sum > 2n-1,


over-flow (溢位)  fill a bit (補位)
1.4 Addition of 2’s complement numbers (p18)
• The two negative numbers are added, and > 2n -1.
• The proof is as follows:

A + B (if B > A); (補位)


A* + B = (2n  A) + B = 2n + (B  A
• Discarding the final digit is equivalent to subtracting 2n,
so the result is (B - A) as the correct solution!
1.4 Addition of 2’s complement numbers (p18)
• The two negative numbers are added, and > 2n -1.
A  B (if A + B  2n1 )
A* + B* = (2n  A) + (2n  B) = 2n + 2n  (A + B)
(溢位)

• Discard the last digit and get 2n - (A + B) = (A + B)*, which is


the correct representation of the -(A + B).
1.4 Addition of 2’s complement numbers (p18)
• The addition of -8 and + 19 is performed by 2 complements.
1: +8 = 00001000; 3:
+19 = 00010011; 11111000  8 
2: Take the 2 complement 00010011 19
100000000
00001000 +8
1 00001011  11
11111000 -8 (捨棄最後之進位)
1.4 Addition of 1’s complement numbers (p19)
• In a 1 complement system, a negative number - N is
represented by a 1 complement of , as defined as follows:

N  (2  1)  N
n
(1-4)

1’s compliment = 2’s compliment - 1


1.4 Addition of 1’s complement numbers (p19)
(1-4)

“-0”和“+0”表示法不
一樣

1補數的負數的最
左邊位元皆為1
0變1,1變0
1.4 Addition of 1’s complement numbers (p19)
• The addition of 1 complement numbers is very similar to the
addition of 2 complements, except that
“the addition of 1 complements does not abandon
the final digit but adds the incoming bit to the n-
bit sum of the minimum bits, which is called end-
around carry.” (末位遞迴進位)
1.4 Addition of 1’s complement numbers (p19)
• The case of positive sum is exactly the same as in Examples 1 and 2 of the 2
complements, with the other examples described below (n=4).
Eq. 1 The positive and negative numbers are added (when the value of
the negative number is larger).

(正確解)
1補數還原: 1110  0001 * (-1) -1
(01)
1.4 Addition of 1’s complement numbers (p19)
 When the positive value is larger.

5 1010
(溢位)
6 0110
Step1: 1 0000
Step2: 1 (末位遞迴進位)
Step3: 0001 (正確解,沒有溢位)
1.4 Addition of 1’s complement numbers (p20)
 The two negative numbers are added, and < 2n-1.
3 1100
4 1011
-7 1 0111

(溢位) 1 (末位遞迴進位)
1000 (正確解,沒有溢位)
1補數還原: 1000  0111 * (-1)  -7
(01)
1.4 Addition of 1’s complement numbers (p20)
 The two negative numbers are added, and > 2n-1.
(補位)
5 1010
6 1001
-11 1 0011 Correction
 -11
1 (末位遞迴進位)
(溢位) 0100 (錯誤解,因為有溢位)
1補數還原: 10100  01011 * (-1) -11
(01)
1.4 Addition of 1’s complement numbers (p20)
 The two positive numbers are added, and > 2n-1.

Correction (補位)

+8 < +11 -4 of 1’
+16> +11 (正確解)

(溢位)
1.4 Addition of 1’s complement numbers (p20)
 When the sum < 2n-1,
the end-around carry. (末位遞迴進位)

 When the sum > 2n-1,


over-flow (溢位)  fill a bit (補位)
 Addition of 1 complement numbers
 When the sum < 2n-1,
the end-around carry. (末位遞迴進位)
 When the sum > 2n-1,
over-flow (溢位)  fill a bit (補位)
 Addition of 2 complement numbers
 When the sum < 2n-1,
this sum is the final answer.
 When the sum > 2n-1,
over-flow (溢位)  fill a bit (補位)

2’ is easier to do calculation than 1’.


1.4 Addition of 1’s complement numbers (p20)
 The proof is as follows:

Eq. : A + B (if B > A)

The last recursive bit is equivalent to subtracting 2n


and adding 1, so the result is (B - A) correct solution.
1.4 Addition of 1’s complement numbers (p20)
 The proof is as follows:
Eq. : A - B (if A+B 2n-1)

=
1.4 Addition of 1’s complement numbers (p20)
A=5 = -5
B=6 = -6
+
(補位) (正確解)
11000110010011
1’
=A+B=5+6=11
1.4 Addition of 1’s complement numbers (p21)
The following example illustrates the addition of 1 complement
when the length of the word group n is 8 respectively:
 The addition of -11 and -20 is performed by 1 complement.
1: +11 = 00001011; 3: 11110100 (11)
+20 = 00010100
11101011  (20)
2: Take the 1 complement
1 11011111
11 11110100;
1 (末位遞迴進位)
20 11101011
11100000  31
(01)
1.5 Encoded Binary Codes and 美國資訊交換標
準碼(American Standard Code for Information
Interchange, ASCII)
(p23)
Table 1-3 lists a portion of the ASCII code that is not listed as a (p23)

combination of codes used for special control functions such as


"form feed" or "end of transmission". The word "Start" is
represented by an ASCII code as follows:

1010011 1110100 1100001 1110010 1110100


S t a r t
(p22)
8 4 2 1
(補充) Decimal
(乘以)
0= 0 0 0 0
BCD 1= 0 0 0 1
8-4-2-1 2= 0 0 1 0
3= 0 0 1 1
Codes 4= 0 1 0 0
5= 0 1 0 1
6= 0 1 1 0
7= 0 1 1 1
8= 1 0 0 0
9= 1 0 0 1
(補充) Decimal 8 4 2 1 Ex-3
0= 0 0 0 0 0011
Exceed 1= 0 0 0 1 0100
2= 0 0 1 0 0101
3
3= 0 0 1 1 0110
Codes 4= 0 1 0 0 0011 0111
5= 0 1 0 1 1000
6= 0 1 1 0 1001
7= 0 1 1 1 1010
8= 0 0 0 0 1011
9= 1 0 0 1 1100
6 3 1 1
(補充) Decimal

0= 0 0 0 0
BCD 1= 0 0 0 1
6-3-1-1 2= 0 0 1 1
3= 0 1 0 0
Codes 4= 0 1 0 1
5= 0 1 1 1
6= 1 0 0 0
7= 1 0 0 1
8= 1 0 1 1
9= 1 1 0 0
Decimal 2 out 5 codes

2 0= 0 0 0 1 1
Out 1= 0 0 1 0 1
2= 0 0 1 1 0
5 3= 0 1 0 0 1
Codes 4= 0 1 0 1 0
5= 0 1 1 0 0
(你跑我追) 6= 1 0 0 0 1
7= 1 0 0 1 0
(補充) 8= 1 0 1 0 0
9= 1 1 0 0 0
Gray Codes (補充)
Gray code after Frank Gray, is an ordering of the binary
numeral system such that two successive values differ in
only one bit (binary digit).
 Encoding Method:
1. Keep MSB of the binary;
2. Comparing two neighboring bits:
a. if same (S), produce “0”
b. if different (D), produce “1”
D S
Gray
4= 0 1 0 0 0 1 1 0 Frank Gray (13 September
codes 1887 – 23 May 1969)
D
(補充) Decimal Binary Gray
0= 0 0 0 0 0000
1= 0 0 0 1 0001
2= 0 0 1 0 0011
3= 0 0 1 1 0010
Gray Codes 4= 0 1 0 0 0110
5= 0 1 0 1 0111
6= 0 1 1 0 0101
7= 0 1 1 1 0100
8= 1 0 0 0 1100
9= 1 0 0 1 1101
(補充)

Gray Codes

 Encoding Method:
The Symmetric Approach

You might also like