Digital Design and Computer Architecture Lecture 1 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007 1 Logistics • Handouts: – Syllabus, Lecture Notes • Lab 1 posted on the website: – www.jlc.tcu.edu.tw • Reading for next Monday (9/29:點名) – 1.6-1.7, 1.9, 2.1-2.3 2 Overview • More Logistics: – Course Objectives – Course Requirements – Schedule • Digital Design – Managing Complexity – Number Systems – Logic Gates 3 Course Objectives • To become a competent digital designer • To learn to recognize and apply the principles of abstraction, modularity, hierarchy, and regularity in digital design • To hone your debugging skills by designing, building, and testing digital circuits • To design, build, and test your own clock • To understand what’s under the hood of a computer • To have fun while you’re doing it! 4 Course Requirements • Class Participation – If you need to miss class, email me beforehand • Assignments: – Weekly problem sets (10%), due Monday Morning – Semester labs (電子鐘15% + 組合語言程式15%) – Reading • Exams – Midterm (25%) – Final (35%) • Team policy for bi-weekly discussion – – – – (75%個人成績+25%團體成績) for Midterm and Final Number of team member 5~6, Bonus for participation: +3; leader +5 5 Syllabus • Read the syllabus! 6 Digital Design General engineering principles for complex systems: – Abstraction – Discipline – The three -Y’s • Hierarchy • Modularity • Regularity 7 Abstraction • Hiding details when they aren’t important Application Software programs Operating Systems device drivers Architecture instructions registers Microarchitecture datapaths controllers Logic adders memories Digital Circuits AND gates NOT gates Analog Circuits amplifiers filters Devices transistors diodes Physics electrons 8 Discipline • Intentionally restricting your design choices (so that you can work more productively at a higher level of abstraction) 9 The Three -Y’s • Hierarchy – Dividing a system into modules and submodules • Modularity – Well-defined functions and interfaces • Regularity – Uniformity, so modules can be easily reused 10 Digital Abstraction • 1’s and 0’s • bits: binary digit 11 Number Systems • Decimal numbers 1's column 10's column 100's column 1000's column 537410 = 5 × 103 + 3 × 102 + 7 × 101 + 4 × 100 five thousands three hundreds seven tens four ones • Binary numbers 1's column 2's column 4's column 8's column 11012 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 1310 one eight one four no two one one 12 Number Conversion • Decimal to binary conversion: – Convert 101012 to decimal • Decimal to binary conversion: – Convert 4710 to binary 13 Hexadecimal Numbers Hex Digit Decimal Equivalent Binary Equivalent 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111 14 Number Conversion • Hexadecimal to binary conversion: – Convert 4AF16 (0x4AF) to binary • Hexadecimal to decimal conversion: – Convert 0x4AF to decimal 15 Bits, Bytes, Nibbles… • Bits 10010110 most significant bit • Bytes & Nibbles least significant bit byte 10010110 nibble • Bytes • (how they are put in memory?) CEBF9AD7 most significant byte least significant byte 16 Addition • Decimal • Binary 11 3734 + 5168 8902 carries 11 1011 + 0011 1110 carries 17 Binary Addition Examples • Add the following 4-bit binary numbers 1001 + 0101 • Add the following 4-bit binary numbers 1011 + 0110 18 Signed Binary Numbers • Sign and Magnitude: – 1 sign bit, N-1 magnitude bits – Example: -5 = 11012 +5 = 01012 • Two’s Complement( why? ) – Same as unsigned binary, but most significant bit (msb) has value of -2N-1 – Most positive 4-bit number: 01112 – Most negative 4-bit number: 10002 19 “Taking the Two’s Complement” • Reversing the sign of a two’s complement number • Method: 1. Invert the bits 2. Add 1 • Example: Reverse the sign of 0111 1. 1000 2. + 1 1001 20 Two’s Complement Examples • Take the two’s complement of 0101. • Take the two’s complement of 1010. 21 Two’s Complement Addition • Add 6 + (-6) using two’s complement numbers. 111 0110 + 1010 10000 • Add -2 + 3 using two’s complement numbers. 22 Logic Gates BUF NOT A Y Y Y=A Y=A A 0 1 A Y 1 0 A 0 1 Y 0 1 23 Two-Input Logic Gates OR AND A B Y A B Y=A+B Y = AB A 0 0 1 1 B 0 1 0 1 Y Y 0 0 0 1 A 0 0 1 1 B 0 1 0 1 Y 0 1 1 1 24 More Two-Input Logic Gates XOR A B NAND A B Y Y=A+B A 0 0 1 1 B 0 1 0 1 NOR Y Y = AB Y 0 1 1 0 A 0 0 1 1 B 0 1 0 1 A B XNOR Y Y=A+B Y 1 1 1 0 A 0 0 1 1 B 0 1 0 1 A B Y Y=A+B Y 1 0 0 0 A 0 0 1 1 B 0 1 0 1 Y 25 Multiple-Input Logic Gates AND4 NOR3 A B C Y Y = A+B+C A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C 0 1 0 1 0 1 0 1 A B C D Y Y = ABCD Y How about 4-input XOR? 26 Next Time • Beneath the digital abstraction • Transistors • Boolean algebra 27