Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機:62328 課程網頁 http://www.cs.nccu.edu.tw/~raylin/Undergr aduateCourse/ComputerArchitecture/2010. htm 2 2010/9/14 課程目標 本課程旨在介紹計算機硬體的基本概念 與製作方式,利用各種實例,對相關主 題作深入淺出之說明,期能使學生瞭解 電腦的組織架構與重要技術。 3 2010/9/14 課程大綱 1. 學習電子計算機系統設計原理。 2. 熟悉中央處理器單元的結構與運作。 3. 熟悉指令集架構的設計與取捨。 4. 了解 CPU 及其週邊設備的關係及其運 作方式。 4 2010/9/14 上課進度 週次 日期 進 1 9/14 Syllabus Chapter 1: Computer Abstractions and Technology 2 9/21 Chapter 1: Computer Abstractions and Technology 3 9/28 Chapter 2: Instructions: Language of the Computer 4 10/5 Chapter 2: Instructions: Language of the Computer 5 10/12 Chapter 3: Arithmetic for Computers 6 10/19 Chapter 3: Arithmetic for Computers 7 10/26 How to Program 8 11/2 Chapter 4: The Processor 9 11/9 Chapter 4: The Processor 10 11/16 Mid-term Exam 11 11/23 Chapter 4: The Processor 12 11/30 Chapter 4: The Processor 13 12/7 Chapter 5: Large and Fast: Exploiting Memory Hierarchy 14 12/14 Chapter 5: Large and Fast: Exploiting Memory Hierarchy 15 12/21 Chapter 6: Storage and Other I/O Topics 16 12/28 Chapter 6: Storage and Other I/O Topics 17 1/4 Chapter 7: Multicores, Multiprocessors, and Clusters 18 1/11 期末考 度 5 2010/9/14 教學方式 講授(投影片) 作業與測驗 6 2010/9/14 Prerequisite Some background in assembly language Boolean algebra Logic design 7 2010/9/14 評分標準 作業,報告及上課表現 25%, 期中考 35%, 期末考 40% 8 2010/9/14 Textbook D. A. Patterson, J. L. Hennessy. Computer Organization & Design: The Hardware/Software Interface, 4th. ed., Morgan Kaufmann, 2008 9 2010/9/14 Chapter 1 Computer Abstractions and Technology 2010/9/14 Progress in computer technology Underpinned by Moore’s Law Makes novel applications feasible §1.1 Introduction The Computer Revolution Computers in automobiles Cell phones Human genome project World Wide Web Search Engines Computers are pervasive 2010/9/14 Classes of Computers Desktop computers Server computers General purpose, variety of software Subject to cost/performance tradeoff Network based High capacity, performance, reliability Range from small servers to building sized Embedded computers Hidden as components of systems Stringent power/performance/cost constraints 2010/9/14 Characteristics of Embedded Computers A computer inside another device Microprocessors found in a car, a cell phone or PDA, etc. Used for running one predetermined application Have unique application requirements that Combine a minimum performance with stringent limitations on cost or power 13 2010/9/14 The Processor Market 2010/9/14 百 萬 顆 處 理 器 圖1.2 1998至2002年所有的指令集架構為處理器的銷售量。關於「其餘」 的種類是指定應用或客製化的處理器。在ARM的例子裡,大約有80%的 銷售量是使用在手機上,他們結合了ARM和特定應用邏輯在單一晶片上。 15 2010/9/14 What You Will Learn How programs are translated into the machine language The hardware/software interface What determines program performance And how the hardware executes them And how it can be improved How hardware designers improve performance What is parallel processing 2010/9/14 Understanding Performance Hardware or software component How this component affects performance Algorithm Determines both the number of source-level statements and the number of I/O operations executed Programming language, compiler, and architecture Determines the number of machine instructions for each source-level statement Processor and memory system Determines how fast instructions can be executed I/O system (hardware and operating system) Determines how fast I/O operations may be executed 2010/9/14 Below your program A hardware in a computer can only execute low-level instructions Needs several layers of software to interpret or translate high-level operations into simple computer instructions Layers of software are organized primarily in a hierarchical fashion 18 2010/9/14 §1.2 Below Your Program Below Your Program Application software Written in high-level language System software Compiler: translates HLL code to machine code Operating System: service code Handling input/output Managing memory and storage Scheduling tasks & sharing resources Hardware Processor, memory, I/O controllers 2010/9/14 From a High-level Language to the Language of Hardware The machine alphabet is just two letters; “on” and “off” 1 and 0 are the two symbols for these two letters We refer to each letter as a binary digit or bit Instructions are just collections of bits that the computer understands For example: 1000110010100000 20 2010/9/14 The first programmers communicated to computers in binary numbers They quickly invented new notations that were closer to the way humans think Translated to binary by hand Finally, using the machine to help program the machine The first of these programs was named an assembler Assembler: a program that translates a symbolic version of instructions into the binary version 21 2010/9/14 Assembler: a program that translates a symbolic version of instructions into the binary version add A, B 1000110010100000 The name for this symbolic language is called assembly language High-level programming language: a portable language such as C, Fortran, or Java composed of words and algebraic notations that can be translated by a compiler into assembly language A+B add A, B 1000110010100000 22 2010/9/14 Benefits of High-level Programming Languages Allow the programmer to think in a more natural language Improve programmer productivity Allow programs to be independent of the computer on which they were developed 23 2010/9/14 Levels of Program Code High-level language Assembly language Level of abstraction closer to problem domain Provides for productivity and portability Textual representation of instructions Hardware representation Binary digits (bits) Encoded instructions and data 2010/9/14 The BIG Picture The five classic components are input (輸入), output(輸出), memory(記憶體), datapath(資料路徑) and control(控制單元) The last two sometimes combined and called the processor(處理器) §1.3 Under the Covers Components of a Computer 2010/9/14 The BIG Picture Same components for all kinds of computer Desktop, server, embedded §1.3 Under the Covers Components of a Computer Input/output includes User-interface devices Storage devices Display, keyboard, mouse Hard disk, CD/DVD, flash Network adapters For communicating with other computers 2010/9/14 Anatomy of a Computer Output device Network cable Input device Input device 2010/9/14 Anatomy of a Mouse The original mouse was electromechanical It used a large ball that when rolled across a surface would cause an x and y counter to be incremented The amount of increase in each counter told how far the mouse had been moved 28 2010/9/14 Anatomy of a Mouse Optical mouse LED illuminates desktop Tiny black-and-white camera Basic image processor Looks for x, y movement Buttons & wheel Supersedes roller-ball mechanical mouse 2010/9/14 Through the Looking Glass LCD screen: picture elements (pixels) Mirrors content of frame buffer memory 2010/9/14 Opening the Box 2010/9/14 Inside the Processor (CPU) Datapath: performs operations on data Control: sequences datapath, memory, ... Cache memory Small fast SRAM memory for immediate access to data 2010/9/14 Inside the Processor AMD Barcelona: 4 processor cores 2010/9/14 Abstractions The BIG Picture Abstraction helps us deal with complexity Instruction set architecture (ISA) The hardware/software interface Application binary interface Hide lower-level detail The ISA plus system software interface Implementation The details underlying and interface 2010/9/14 A Safe Place for Data Volatile main memory Loses instructions and data when power off Non-volatile secondary memory Magnetic disk Flash memory Optical disk (CDROM, DVD) 2010/9/14 A Safe Place for Data DRAM and SRAM Dynamic random access memory (DRAM): Several DRAMS are used together to contain the instructions and data of a program It provides random access to any location Cache memory A small, fast memory that acts as a buffer for the DRAM memory Built using a different memory technology, static random access memory (SRAM) More expensive than DRAM 36 2010/9/14 A Safe Place for Data The access times for magnetic disks are much slower than for DRAMs About 100,000 times faster The cost per megabyte of disk is about 100 times less expensive than DRAM 2010/9/14 Networks Communicating with other computers Several major advantages of networked computers: Communication Resource sharing Nonlocal access Ethernet is the most popular type of network Local area network (LAN): Ethernet Within a building Wide area network (WAN: the Internet Wireless network: WiFi, Bluetooth 2010/9/14 Technologies for building processors and memories Vacuum tube An electronic component, predecessor of the transistor Transistor An on/off switch controlled by an electric signal Integrated circuit (IC) It combined dozens to hundreds of transistors into a single chip Very large scale integrated (VLSI) circuit A device containing hundreds of thousands to millions of transistors 39 2010/9/14 Technology Trends Electronics technology continues to evolve Increased capacity and performance Reduced cost Year Technology 1951 Vacuum tube 1965 Transistor 1975 Integrated circuit (IC) 1995 Very large scale IC (VLSI) 2005 Ultra large scale IC DRAM capacity Relative performance/cost 1 35 900 2,400,000 6,200,000,000 2010/9/14 千 位 元 容 量 發表時間 圖1.13 動態隨機存取記憶體晶片隨時間演變的容量成長圖。Y軸以千位元 做量測,千指的是1024 (210 )。這二十年來,動態隨機存取記憶體工業幾乎 每三年便會提高四倍的容量,相當每年百分之六十。每三年增加四倍的估 計為動態隨機存取記憶體的成長法則。近年來,成長率已經逐漸趨緩,而 稍微接近每二年倍增或每四年增加四倍。 2010/9/14 41 2010/9/14 Moore’s law Transistor capacity doubles every 18 to 24 months Year of introduction Transistors 4004 1971 2,250 8008 1972 2,500 8080 1974 5,000 8086 1978 29,000 286 1982 120,000 386™ processor 1985 275,000 486™ DX processor 1989 1,180,000 Pentium® processor 1993 3,100,000 Pentium II processor 1997 7,500,000 Pentium III processor 1999 24,000,000 Pentium 4 processor 2000 42 42,000,000 2010/9/14