Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 [email protected]...

42
Computer Architecture 計計計計計計計計 Instructor: 左左左 [email protected] Office:200314 左左62328

Transcript of Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 [email protected]...

Page 1: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Computer Architecture計算機組織與結構

Instructor: 左瑞麟[email protected]:200314分機: 62328

Page 2: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

課程網頁 http://www.cs.nccu.edu.tw/~raylin/

UndergraduateCourse/ComputerArchitecture/2010.htm

2010/9/142

Page 3: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

課程目標

本課程旨在介紹計算機硬體的基本概念與製作方式,利用各種實例,對相關主題作深入淺出之說明,期能使學生瞭解電腦的組織架構與重要技術。

32010/9/14

Page 4: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

課程大綱

1. 學習電子計算機系統設計原理。 2. 熟悉中央處理器單元的結構與運作。 3. 熟悉指令集架構的設計與取捨。 4. 了解 CPU 及其週邊設備的關係及其運

作方式。

42010/9/14

Page 5: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

上課進度

5

週次 日 期 進       度

1 9/14 SyllabusChapter 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 期末考

2010/9/14

Page 6: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

教學方式 講授 ( 投影片 ) 作業與測驗

62010/9/14

Page 7: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Prerequisite Some background in assembly language Boolean algebra Logic design

72010/9/14

Page 8: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

評分標準 作業 , 報告及上課表現 25%, 期中考 35%, 期末考 40%

82010/9/14

Page 9: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Textbook

D. A. Patterson,

J. L. Hennessy.

Computer Organization

& Design:

The Hardware/Software

Interface, 4th. ed.,

Morgan Kaufmann, 2008

92010/9/14

Page 10: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Chapter 1

Computer Abstractions and Technology

2010/9/14

Page 11: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

The Computer Revolution Progress in computer technology

Underpinned by Moore’s Law Makes novel applications feasible

Computers in automobiles Cell phones Human genome project World Wide Web Search Engines

Computers are pervasive

§1.1 Introduction

2010/9/14

Page 12: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Classes of Computers Desktop computers

General purpose, variety of software Subject to cost/performance tradeoff

Server computers 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

Page 13: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

132010/9/14

Page 14: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

The Processor Market

2010/9/14

Page 15: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

百萬顆處理

圖 1.2 1998 至 2002 年所有的指令集架構為處理器的銷售量。關於「其餘」的種類是指定應用或客製化的處理器。在 ARM 的例子裡,大約有 80% 的銷售量是使用在手機上,他們結合了 ARM 和特定應用邏輯在單一晶片上。15

2010/9/14

Page 16: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

What You Will Learn How programs are translated into the

machine language And how the hardware executes them

The hardware/software interface What determines program performance

And how it can be improved How hardware designers improve

performance What is parallel processing

2010/9/14

Page 17: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

Page 18: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

182010/9/14

Page 19: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

§1.2 Below

Your P

rogram

2010/9/14

Page 20: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

202010/9/14

Page 21: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

212010/9/14

Page 22: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

222010/9/14

Page 23: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

232010/9/14

Page 24: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Levels of Program Code High-level language

Level of abstraction closer to problem domain

Provides for productivity and portability

Assembly language Textual representation of

instructions Hardware representation

Binary digits (bits) Encoded instructions and

data

2010/9/14

Page 25: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Components of a Computer The five classic components

are

input ( 輸入 ), output (輸出) , memory (記憶體) ,

datapath (資料路徑) and control (控制單元)

The last two sometimes combined and called the processor( 處理器 )

§1.3 Under the C

overs

The BIG Picture

2010/9/14

Page 26: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Components of a Computer Same components for

all kinds of computer Desktop, server,

embedded Input/output includes

User-interface devices Display, keyboard, mouse

Storage devices Hard disk, CD/DVD, flash

Network adapters For communicating with

other computers

§1.3 Under the C

overs

The BIG Picture

2010/9/14

Page 27: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Anatomy of a Computer

Output device

Input device

Input device

Network cable

2010/9/14

Page 28: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

282010/9/14

Page 29: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

Page 30: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Through the Looking Glass LCD screen: picture elements (pixels)

Mirrors content of frame buffer memory

2010/9/14

Page 31: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Opening the Box

2010/9/14

Page 32: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

Page 33: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Inside the Processor AMD Barcelona: 4 processor cores

2010/9/14

Page 34: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Abstractions

Abstraction helps us deal with complexity Hide lower-level detail

Instruction set architecture (ISA) The hardware/software interface

Application binary interface The ISA plus system software interface

Implementation The details underlying and interface

The BIG Picture

2010/9/14

Page 35: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

Page 36: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

A Safe Place for DataDRAM 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

362010/9/14

Page 37: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

Page 38: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

NetworksCommunicating 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

Page 39: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

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

392010/9/14

Page 40: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Technology Trends Electronics

technology continues to evolve Increased capacity

and performance Reduced cost

Year Technology Relative performance/cost

1951 Vacuum tube 1

1965 Transistor 35

1975 Integrated circuit (IC) 900

1995 Very large scale IC (VLSI) 2,400,000

2005 Ultra large scale IC 6,200,000,000

DRAM capacity

2010/9/14

Page 41: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

發表時間

千位元容

圖 1.13 動態隨機存取記憶體晶片隨時間演變的容量成長圖。 Y 軸以千位元做量測,千指的是 1024 。這二十年來,動態隨機存取記憶體工業幾乎每三年便會提高四倍的容量,相當每年百分之六十。每三年增加四倍的估計為動態隨機存取記憶體的成長法則。近年來,成長率已經逐漸趨緩,而稍微接近每二年倍增或每四年增加四倍。

)(210

412010/9/142010/9/14

Page 42: Computer Architecture 計算機組織與結構 Instructor: 左瑞麟 raylin@cs.nccu.edu.tw Office:200314 分機: 62328.

Moore’s law Transistor capacity doubles every 18 to 24 months

42

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,000,0002010/9/14