數位系統導論 蔡宗漢 (Tsung-Han Tsai) Dept. of E.E., N.C.U. 1 教學目標 : 1 了解數位電子電路的基本原理, 例如資訊的二進位系統 布林代數 2 了解數位電子電路的基本原件, 如 : 組合電路 循序電路 加法器 比較器 等等 授課大綱 : 1 數位邏輯的原理 2 元件的認識( 如 AND/OR 閘, 加法器 ) 3 數位邏輯功能單元 4 數位邏輯的設計 2
Grading & Textbook Homework & Class Participation:30% Midterm exam:30% Final exam:40% Textbook: M. Morris Mano, Digital Design, 3rd, 2002 Prentice-Hall, Inc. 參考書籍 : Randy H. Katz, Contemporary Logic Design, 1995 The Benjamin/Cummings Publishing Company, Inc. 台北圖書代理 M. Morris Mano & Charles R. Kime, Logic and Computer Design Fundamentals, 1997 Prentice-Hall, Inc. 新月代理 3 Outlines Digital computers and information Binary numbers Numbers base conversions Binary arithmetic Complements Binary logic Binary storage and registers 4
Digital Computers & Digital Systems Information familiar to us I/P MEM CU CPU O/P Computer 5 數位電路之實現 Logic Standard Logic ASIC PLD Gate Array Cell-Based IC Full Custom IC PLD CPLD FPGA ASIC:Application-Specific Integrated Circuit PLD:Programmable Logic Device SPLD:Small/Simple Programmable Logic Device CPLD:Complex Programmable Logic Device FPGA:Field Programmable Gate Array 6
常見名詞 TRANSISTOR: 電晶體 Chip: 矽晶片, 微晶片 Integrated Circuit [IC]: 積體電路 Small Scale IC[SSI] Medium Scale IC[MSI] Large Scale IC[LSI] Very Large Scale IC[VLSI] Ultra Large Scale IC[ULSI] Giga Scale IC[GSI] SOC 小型 IC 中型 IC 大型 IC 超大型 IC? 大型 IC?? 型 IC 單晶片系統 Kilo:K 仟 Mega:M 百萬 Giga:G 十億 Tera:T 兆 7 A= B + C IF (A) THEN X =Y Algorithm Level Gate Level RAM ALU ROM CONTROL Functional Level Geometric Level Circuit Level SUBMITTING YOUR LAYOUT DESIGN IN CIF OR GDSII VIA MAGNETIC TAPE OR EMAIL 8
9 10
11 12
TTL Gate and ECL Gate 13 TTL Gate and ECL Gate 14
CMOS Gate 15 Binary Numbers Binary number 2 symbols (0, 1) Binary signal 2 states (Low, High) Decimal numbers: A10 = a n-1 a n-2 a 1 a 0.a -1 a -2 a -m = Binary numbers: A 2 = n 1 i= m n 1 i= m i ai *10 0 ai i ai *2 ai = 0,1 9 16
Binary Numbers In general, base r (radix r) numbers: A r = n 1 i= m ai * r i 0 ai r 1 EX:(11010.11) 2 =1 x 2 4 + 1 x 2 3 + 0 x 2 2 + 1 x 2 1 + 0 x 2 0 + 1 x 2-1 + 1 x 2-2 =(26.75) 10 17 Powers of Two n 2 n n 2 n n 2 n 0 1 8 256 16 65536 1 2 9 512 17 131072 2 4 10 1024 18 262144 3 8 11 2048 19 524288 4 16 12 4096 20 1048576 5 32 13 8192 21 2097152 6 64 14 16384 22 4194304 7 128 15 32768 23 8388608 18
Numbers Base Conversions Let A r = B 10 ai r i = j bj * 10 0 ai r 1 0 bj 9 Conversion from A r to B 10 is straightforward, since it conforms to out experience Conversion from B 10 to A r, however, requires a little bit of extra knowledge:successive divisions (for the integer part ) and multiplications (for the fraction) of B 10 by r, and observe the remainders and carries 19 Numbers Base Conversions Conversion procedure (1) Let B 10 = B1 10 +B2 10 (integer & fraction, respectively), ie.. q 1 j= p bj *10 j q 1 j= 0 (2) B1=B1`*r +a0 B1`=B1``*r+a1 B1 (n-2) =B1 (n-1) *r+a n-2, and B1 (n-1) =a n-1 = bj *10 j + 1 j= p bj *10 j 20
Numbers Base Conversions (3) B2 * r = a -1 * B2` B2` * r = a -2 * B2`` B2 (m-1) * r = a -m * B2 (m) Note that B2 (m) is not necessarily zero, in which case there is a truncation error associated with the conversion 21 Number Base Conversions Convert decimal 41 to binary 41/2 = 20 remainder = 1 20/2 = 10 = 0 10/2 = 5 = 0 5/2 = 2 = 1 2/2 = 1 = 0 1/2 = 0 = 1 Convert decimal 0.6875 to binary 0.6875 x 2 = 1.3750 0.3750 x 2 = 0.7500 0.7500 x 2 = 1.5000 0.5000 x 2 = 1.0000 (41) 10 =(101001) 2 (0.6875) 10 =(0.1011) 2 22
Octal & hexadecimal numbers Base 10 Base2 Base 8 Base16 Base10 Base2 Base 8 Base 16 00 0000 00 0 08 1000 10 8 01 0001 01 1 09 1001 11 9 02 0010 02 2 10 1010 12 A 03 0011 03 3 11 1011 13 B 04 0100 04 4 12 1100 14 C 05 0101 05 5 13 1101 15 D 06 0110 06 6 14 1110 16 E 07 0111 07 7 15 1111 17 F 23 Binary Arithmetic Binary Addition 0+0=0 sum of 0 with a carry of 0 0+1=1 sum of 1 with a carry of 0 1+0=1 sum of 1 with a carry of 0 1+1=10 sum of 0 with a carry of 1 Binary Addition with carry 1+0+0=01 sum of 1 with a carry of 0 1+0+1=10 sum of 0 with a carry of 1 1+1+0=10 sum of 0 with a carry of 1 1+1+1=11 sum of 1 with a carry of 1?carry bit 24
Binary Subtraction Binary Arithmetic 0 0 = 0 1 1 = 0 1 0 = 1 10-1 = 1 borrow 1 from the higher bit EX : 1 0 1-0 1 1 0 1 0 25 Binary Arithmetic Binary Multiplication 0 x 0 = 0 0 x 1 = 0 1 x 0 = 0 1 x 1 = 1 EX : 1 1 1 x 1 0 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 26
Binary Division Binary Arithmetic EX : 110 10 = 11 1 0 1 1 1 1 1 0 0 1 0 1 0 0 0 27 COMPLEMENTS Complements are used in digital computers for simplifying the subtraction operation and logical manipulation There are two types of complements for each base r system:the radix complement and the diminished radix complement. 28
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 9 s complement of 546700 is 999999 546700 = 453299 The 9 s complement of 012398 is 999999 012398 = 987601 The 1 s complement of 1011000 is 0100111 The 1 s complement of 0101101 is 1010010 29 Radix complement The r s complement of an n-digit number N in base r is defined as r n -N, for N 0 and 0 for N=0 The 10 s complement of 012398 is 987602 The 10 s complement of 246700 is 753300 The 2 s complement of 1101100 is 0010100 The 2 s complement of 0110111 is 1001001 30
Subtraction with complements The subtraction of two n-digit unsigned numbers M N in base r can be done as follows: (1):Add the minuend, M, to the subtrahend, N. This performs M+(r n N)=M N + r 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 the r s complement of (N M). To obtain the answer in a familiar form, take the r s complement of the sum and placed a negative sign in front 31 Signed Binary Numbers Decimal Signed 2 s complement Signed 1 s complement Signed magnitude +7 0111 0111 0111 +6 0110 0110 0110 +5 0101 0101 0101 +4 0100 0100 0100 +3 0011 0011 0011 +2 0010 0010 0010 +1 0001 0001 0001 +0 0000 0000 0000-0 1111 1000-1 1111 1110 1001-2 1110 1101 1010-3 1101 1100 1011-4 1100 1011 1100-5 1011 1010 1101-6 1010 1001 1110-7 1001 1000 1111-8 1000 32
Arithmetic addition Note that negative numbers must be initially in 2 s complement and that if the sum obtained after the addition is negative, it is in 2 s complement form + 6 00000110 +13 00001101 +19 00010011 6 11111010 +13 00001101 + 7 00000111 + 6 00000110 13 11110011 7 11111001 6 11111010 13 11110011 19 11101101 33 BCD Code Decimal symbol 0 1 2 3 4 5 6 7 8 9 BCD Digit 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 34
BCD Addition When the binary sum is equal to or less than 1001 (without a carry), the corresponding BCD digit is correct 4 0100 + 5 0101 9 1001 4 0100 + 8 1000 12 1100 + 0110 10010 8 1000 + 9 1001 17 10001 + 0110 10111 35 Other Decimal Codes DECIMAL DIGIT BCD 8421 2421 EXCESS-3 84-2-1 0 0000 0000 0011 0000 1 0001 0001 0100 0111 2 0010 0010 0101 0110 3 0011 0011 0110 0101 4 0100 0100 0111 0100 5 0101 1011 1000 1011 6 0110 1100 1001 1010 7 0111 1101 1010 1001 8 1000 1110 1011 1000 9 Unused bit combinations 1001 1010 1011 1100 1111 0101 0110 0111 1100 0000 0001 0010 1111 0001 0010 0011 1101 1000 1101 1100 1110 1001 1110 1101 1111 1010 1111 1110 36
Gray Code Gray code Decimal equivalent Gray code Decimal equivalent 0000 0 1100 8 0001 1 1101 9 0011 2 1111 10 0010 3 1110 11 0110 4 1010 12 0111 5 1011 13 0101 6 1001 14 0100 7 1000 15 37 ASCII Character Code 38
ASCII Character Code 39 Binary Storage And Registers MEMORY UNIT J O H N 01001010010011111100100011001110 Memory Register PROCESSOR UNIT 8 cells 8 cells 8 cells 8 cells Processor Register INPUT UNIT KEYBOARD J O H N 8 cells CONTROL Input Register 40
Binary Logic 41 Binary Logic 42
Binary Logic 43