650 likes | 1.27k Views
Computer Architecture 計算機組織與結構. Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328. 課程網頁. http://www.cs.nccu.edu.tw/~ raylin/UndergraduateCourse/ComputerArchitecture/2009.htm. 課程目標. 本課程旨在介紹計算機硬體的基本概念與製作方式,利用各種實例 ,對 相關主題作深入淺出之說明,期能使學生瞭解電腦的組織架構與重要技術。. 課程大綱. 1. 學習電子計算機系統設計原理。
E N D
Computer Architecture計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機:62328
課程網頁 • http://www.cs.nccu.edu.tw/~raylin/UndergraduateCourse/ComputerArchitecture/2009.htm
課程目標 • 本課程旨在介紹計算機硬體的基本概念與製作方式,利用各種實例,對相關主題作深入淺出之說明,期能使學生瞭解電腦的組織架構與重要技術。
課程大綱 1. 學習電子計算機系統設計原理。 2. 熟悉中央處理器單元的結構與運作。 3. 熟悉指令集架構的設計與取捨。 4. 了解 CPU 及其週邊設備的關係及其運作方式。
教學方式 • 講授(投影片) • 作業與測驗
Prerequisite • Some background in assembly language • Boolean algebra • Logic design
評分標準 • 作業,報告及上課表現 30%, • 期中考 30%, • 期末考 40%
Textbook • D. A. Patterson, J. L. Hennessy. Computer Organization & Design: The Hardware/Software Interface, 3rd. ed., Morgan Kaufmann, 2004
Textbook • D. A. Patterson, J. L. Hennessy. Computer Organization & Design: The Hardware/Software Interface, 4th. ed., Morgan Kaufmann, 2009
Introduction • Computer science fiction in the recent past • Automatic teller machines (ATM) • Computers in automobiles • Laptop computers • Human genome project • World Wide Web (WWW) Ubiquitous computing
Computer classification • Desktop computers • Servers • Minicomputers • Mainframes • Supercomputers • Embedded computers
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
百萬台電腦 圖1.1從1988至2002年,不同種類的處理器的銷售量。這些數字的獲得有些許不同,因此需要注意這些結果的解釋。如桌上型電腦和伺服器的總數計算完整的電腦系統,因為其中的一部份為多重處理器,使的處理器的銷售數字較高些,但大約只有全部的10~20%(由於伺服器平均雖有著超過一顆以上的處理器,但僅為單一處理器系統的桌上型電腦銷售量3%)。嵌入式電腦的總數,實際上是計算處理器的數目。有些嵌入式系統是看不見處理器的,更有些單一設備卻有多顆的處理器。
百萬顆處理器 圖1.2 1998至2002年所有的指令集架構為處理器的銷售量。關於「其餘」 的種類是指定應用或客製化的處理器。在ARM的例子裡,大約有80%的 銷售量是使用在手機上,他們結合了ARM和特定應用邏輯在單一晶片上。
Things you’ll be learning • How are programs written in a high-level language translated into the language of the hardware • What is the interface between the software and the hardware • How does software instruct the hardware to perform needed functions • What determines the performance of a program • How to analyze and improve the performance
Why learn this stuff • you want to call yourself a “computer scientist” • you want to build software people use (need performance) • you need to make a purchasing decision or offer “expert” advice
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
應用軟體 系統軟體 硬體 圖1.3 硬體和軟體的階層性概念,此圖以中心為硬體而最外圈為應用軟體的 同心圓表示。
Types of systems software • Operating systems (作業系統) • Handing basic input and output operations • Allocating storage and memory • Providing for sharing the computer among multiple applications using it simultaneously • Compilers (編譯器) • Translating high-level language statements into instructions that the hardware can execute • complex
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
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
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
Benefits of high-level programming languages: • Allow the programmer to thinkin a more natural language • Improve programmer productivity • Allow programs to be independent of the computer on which they were developed
編譯器 組譯器 High-level language (c語言) 圖1.4 C程式編譯成組合語言 再組譯成二位元機械語言。 雖然從高階語言轉譯成二位 元機械語言有兩個步驟,有 些編譯器會將中間過程刪除 ,直接產生二位元機械語言。 這些語言和程式在第二章會 有更為詳細的介紹。 Assembly language (MIPS規格) Binary machine language (MIPS規格)
Under the covers • The five classic components are input (輸入), output(輸出), memory(記憶體), datapath(資料路徑) and control(控制單元) • The last two sometimes combined and called the processor(處理器)
編譯器 介面 電腦 輸入 控制單元 資料路徑 效能評估 輸出 處理器 記憶體 圖1.5 構成電腦五種要素的組織圖。處理器從記憶體中抓取指令和資料。 記憶體中的資料由輸入裝置寫入,並由輸出裝置讀出。控制單元則送出 運作訊號以決定資料流程、記憶體、輸入和輸出裝置的動作。
Input device: a mechanism through which the computer is fed information • keyboard, mouse • Output device: a mechanism that conveys the result of a computation to a user or another computer • screen • Some devices provide both input and output to the computer • Networks, disks
圖1.6 桌上型電腦。液晶顯示螢幕是主要的輸出裝置,鍵盤與滑鼠為主要 的輸入裝置。主機箱內則包含了處理器和額外的輸入/輸出裝置。本圖是 Dell Optiplex GX260系統。
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
All-optical mouse • A miniature optical processor including • An LED to provide lighting • A tiny black-and-white camera • A simple optical processor • It has largely replaced the electromechanical mouse
Through the looking glass • Cathode ray tube (CRT) display • Flat-panel • Liquid crystal displays (LCDs) • The computer hardware support for graphics consists mainly of a raster refresh buffer(光柵更新緩衝器) or frame buffer (畫面緩衝器)to store the bit map(or called pixels,像素)
柵式掃描陰極射線管顯示器 畫面緩衝器 圖1.7 左圖畫面緩衝器的每個座標決定右圖柵式掃描陰極射線管相對應 座標處的影像。在 的像素點的位元圖樣是0011,代表一較為明 亮的灰階值,而 像素點的位元圖樣是1101比較暗。
Opening the box • Motherboard • A plastic board containing packages of integrated circuits or chips • Integrated circuits • Also called chip. A device combining dozens to millions of transistors (電晶體) • The motherboard is composed of • The piece connecting to the I/O devices • The memory • A storage area in which programs are kept when they are running and that contains the data needed by the running programs • The processor • The active part of the computer, which contains the datapath and control and adds numbers, tests numbers, signals I/O devices to activate, and so on
DVD 驅動器 電源 供應器 ZIP 驅動器 有罩子 的風散 主機板 硬碟 圖1.8 在15頁圖1.6的個人電腦內部圖。這種包裝因為它開啟的方式,旁邊有絞鍊 ,所以有時稱做蛤殼式(clamshell)包裝。為了看看裡邊有什麼,我們從左上角開始。 左上角的金屬盒是電源供應器,下方是個有罩子的風散。在風扇的右下方是印刷 電路板(printed circuit (PC)board),在電腦裡稱做主機板,包含了電腦裡大部分的 電子零件。圖1.10是個接近此種板子的圖例。處理器就是在風扇右邊的大型凸起 矩形物。在右手邊我們可以看見擺放各種驅動盤機器的隔間,最上面是DVD驅動 器,中間是ZIP驅動器,下面是硬碟。
控制 單元 控制 單元 輸入/輸 出介面 其它介面邏輯 指令快取記憶體 資料快取 記憶體 增強型浮點 及多媒體運 算單元 第二階 快取及 記憶體 介面 控制單元 控制 單元 進階管線化多執 行緒支援單元 圖1.9 在圖1.8的電路板上所使用的處理器的內部圖。左手邊的是Pentium4處理器晶片 的縮影照片,右手邊則顯示了該處理器內部的主要區塊。
The processor (CPU) comprises two main components: • Datapath • Performs arithmetic operations • Control • Commands the datapath, memory, and I/O devices according to the instructions of the program
處理器 記憶體 碟盤及通 用序列埠 介面 處理器 介面 圖形化介面卡 輸入/輸出裝置 匯流排插槽 圖1.10 貼近個人電腦主機板。這塊板子使用Intel Pentium 4處理器,位 於板子的左上角。它的上面覆蓋了一個似鰭狀的金屬散熱器。這是個散 熱裝置,幫助晶片散去熱量。記憶體部分包含了一個或多個電路板,垂 直插在主機板上,靠近中央。動態隨機存取記憶體鑲嵌在這些小電路板 上(稱之為雙同軸記憶體模組(dual inline memory modules,DIMMS)),然 後插入進接器。主機板上其餘的大部分用來連接外部輸入/輸出裝置, 如音頻信號/MIDI、右邊的平行/序列埠、底部的兩個週邊元件連接介面 (PCI)卡插槽和連接硬碟的進階連接技術(advanced technology attachment,ATA)連接器。
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
A safe place for data • Primary memory (main memory): volatile memory • DRAM • Secondary memory: nonvolatile memory • Magnetic disk (hard disk) • CD • DVD • FLASH • 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
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) • Wide area network (WAN)
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
年 使用於電腦的技術 相對效能/單位成本 • 真空管(vacuum tube) 1 • 電晶體 35 • 積體電路 900 • 超大型積體電路 2,400,000 • 2005 極大型積體電腦 6,200,000,000 圖1.12 長時間以來,使用在電腦的各項技術其單位成本的相對效能。 資料來源:波士頓電腦博物館,2005年為作者推算而得。
千位元容量 發表時間 圖1.13 動態隨機存取記憶體晶片隨時間演變的容量成長圖。Y軸以千位元 做量測,千指的是1024 。這二十年來,動態隨機存取記憶體工業幾乎 每三年便會提高四倍的容量,相當每年百分之六十。每三年增加四倍的估 計為動態隨機存取記憶體的成長法則。近年來,成長率已經逐漸趨緩,而 稍微接近每二年倍增或每四年增加四倍。
Moore’s law • Transistor capacity doubles every 18 to 24 months
The chip manufacturing process • Transistor capacity doubles every 18 to 24 months
空白晶圓 矽碇 薄片 測試過 的晶圓 測試過的晶片 圖樣晶圓 晶圓 測試機 將晶片 封裝 切割機 測試過的 封裝晶片 封裝過的晶片 賣給 顧客 零件 測試機 20到40道的 製程 圖1.14 晶片的製造過程。矽碇在切成薄片後,空白的晶圓會經過20到40道的圖 樣製造,處理過後的晶圓會以晶圓測試機測試,並顯示好的部份的電腦映圖。 之後晶圓會被切成一塊一塊的小方塊。在本圖裡,這片晶圓有20個晶片, 其中有17個通過測試(x表示壞的晶片)。本例中的良率是17/20/即85%, 之後好的晶片會封裝起來,在賣給消費者前在測試 一次。這個例子裡,封裝過後的晶片有一顆是壞的。