Transcript COM249

COM 249 – Computer Organization and
Assembly Language
Chapter 1
Computer Abstraction and Technology
Based on slides from D. Patterson and
www-inst.eecs.berkeley.edu/~cs152/
Modified by S. J. Fritz Spring 2009 (1)
Where are we going??
Input
Multiplier
Input
Multiplicand
32
Multiplicand
Register
<<1
32
34
34
32=>34
signEx
1
0
34x2 MUX
Arithmetic
Multi x2/x1
34
34
Sub/Add
34-bit ALU
Control
Logic
34
32
32
2
ShiftAll
LO register
(16x2 bits)
Prev
2
Booth
Encoder
HI register
(16x2 bits)
LO[1]
Extra
2 bits
2
"LO
[0]"
Single/multicycle
Datapaths
LoadMp
32=>34
signEx
ENC[2]
ENC[1]
ENC[0]
LoadLO
ClearHI
LoadHI
2
32
Result[HI]
LO[1:0]
32
Result[LO]
1000
CPU
“Moore’s Law”
IFetchDcd
WB
Exec Mem
Performance
10
DRAM
9%/yr.
DRAM (2X/10 yrs)
1
198
2
3
198
498
1
5
198
6
198
7
198
8
198
9
199
0
199
199
2
199
3
199
4
199
5
199
699
1
7
199
8
199
9
200
0
Exec Mem
Processor-Memory
Performance Gap:
(grows 50% / year)
198
098
1
1
198
IFetchDcd
COM 249
Spring ‘09
100
WB
Time
IFetchDcd
Exec Mem
IFetchDcd
WB
Exec Mem
WB
Pipelining
I/O
Memory Systems
Modified by S. J. Fritz Spring 2009 (2)
µProc
60%/yr.
(2X/1.5yr)
Y
O
U
R
C
P
U
Where Are We Going?
° Performance issues (Chapter 1)
overview, vocabulary and motivation
° A specific instruction set architecture (Chapter 2)
° Arithmetic and how to build an ALU (Chapter 3)
° Constructing a processor to execute our
instructions (Chapter 4)
° Pipelining to improve performance (Chapter 4)
° Memory: caches and virtual memory (Chapter 5)
° I/O (Chapter 6)
° Multicores, Multiprocessors (Chapter 7)
Key to a good grade: reading the book!
Modified by S. J. Fritz Spring 2009 (3)
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 parallel processing is and what
implications it has for programmers
Modified by S. J. Fritz Spring 2009 (4)
Introduction
° Rapidly changing field:
• vacuum tube -> transistor -> IC -> VLSI (see section 1.3)
• doubling every 1.5 years: (Moore’s Law)
memory capacity
processor speed (Due to advances in technology and organization)
° Things you’ll be learning:
• how computers work, a basic foundation
• how to analyze their performance (or how not to!)
• issues affecting modern processors (caches, pipelines)
° 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
Modified by S. J. Fritz Spring 2009 (5)
Understanding Performance
Algorithm


Determines number of operations executed
Programming language, compiler, architecture

Determine number of machine instructions executed per
operation

Processor and memory system


Determine how fast instructions are executed
I/O system (including OS)


Determines how fast I/O operations are executed
Modified by S. J. Fritz Spring 2009 (6)
COM 249: So what's in it for me?
•Learn some of the big ideas in CS & engineering:
•5 Classic components of a Computer
•Data can be anything (integers, floating point, characters):
the program determines what it is
•Stored program concept: instructions just data
•Principle of Locality, exploited via a memory hierarchy (cache)
•Greater performance by exploiting parallelism
•Principle of abstraction, used to build systems as layers
•Compilation vs. interpretation through system layers
•Principles/Pitfalls of Performance Measurement
•Designer’s “conceptual” toolbox
Modified by S. J. Fritz Spring 2009 (7)
“Conceptual” Tool Box?
° Evaluation Techniques
° Levels of translation (e.g., Compilation)
° Levels of Interpretation (e.g., Microprogramming)
° Hierarchy (e.g, registers, cache, memory, disk, tape)
° Pipelining and Parallelism
° Indirection and Address Translation
° Synchronous /Asynchronous Control Transfer
° Timing, Clocking, and Latching
° CAD Programs, Hardware Description Languages,
Simulation
° Static / Dynamic Scheduling
° Physical Building Blocks (e.g., Carry Lookahead)
° Understanding Technology Trends
Modified by S. J. Fritz Spring 2009 (8)
Our Goals
° To understand modern computer
architecture in its rapidly changing form
° To explore the relationship between
hardware and software
°To design by leading you through the
process of challenging design problems
and by examining real designs
°To learn how to test and to design for
improved performance
Modified by S. J. Fritz Spring 2009 (9)
Where is “Computer Organization and Assembly Language”?
Application (Netscape)
Software
Hardware
Operating
Compiler
System
Assembler (Windows 2K)
Processor Memory I/O system
Instruction Set
Architecture
Datapath & Control
Digital Design
Circuit Design
COM249
transistors
* Coordination of many levels of abstraction
Modified by S. J. Fritz Spring 2009 (10)
Dual Level Abstraction
SOFTWARE
Negation, Add,
Double, Subtract
HARDWARE
Negation,
Add
Modified by S. J. Fritz Spring 2009 (11)
Higher Levels
Lower Levels
Computer Architecture
Includes:
°Instruction set architecture (ISA)
(programmer’s abstraction of a computer)
°Organization or microarchitecture
(internal implementation of a computer at
the register and functional unit level)
°System architecture
(organization of the computer at the cache
and bus level)
° See Computing Curriculum 2001 – pages 97-101
http://www.acm.org/education/education/curric_vols/cc20
01.pdf
Modified by S. J. Fritz Spring 2009 (12)
Instruction Set Architecture (ISA)
° A very important abstraction
• interface between hardware and low-level software
• standardizes instructions, machine language bit
patterns, etc.
• advantage: different implementations of the same
architecture
• disadvantage: sometimes prevents using new
innovations
Modern instruction set architectures:
• 80x86/Pentium/K6, PowerPC, DEC Alpha, MIPS, SPARC, HP
Modified by S. J. Fritz Spring 2009 (13)
Hardware Levels
Level 2
Level 1
Level 0
Modified by S. J. Fritz Spring 2009 (14)
CPU, Memory, Etc.
Digital Logic Circuits
Transistors
Software Levels
Level 6
Level 5
Level 4
Level 3
Modified by S. J. Fritz Spring 2009 (15)
High-Level Languages
Assembly Language
Operating Systems
Machine Language
Software
° At higher levels (above Level 2)
•
•
•
•
Level 3: Machine language
Level 4: Operating system services
Level 5: Assembly language
Level 6: High-level languages
° Most programs are written at Level 6.
° Hardware only understands Level 3
instructions.
Modified by S. J. Fritz Spring 2009 (16)
Below Your Program
• Written in high-level language (HLL)
° 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
Modified by S. J. Fritz Spring 2009 (17)
§1.2 Below Your
Program
° Application software
Levels of Representation
High Level Language
Program (e.g., C)
Compiler
Assembly Language
Program (e.g.,MIPS)
Assembler
Machine Language
Program (MIPS)
Machine
Interpretation
Hardware Architecture Description
(e.g., Verilog Language)
Architecture
Implementation
Logic Circuit Description
(Verilog Language)
Modified by S. J. Fritz Spring 2009 (18)
temp = v[k];
v[k] = v[k+1];
v[k+1] = temp;
lw
lw
sw
sw
0000
1010
1100
0101
$t0, 0($2) #load word
$t1, 4($2)
$t1, 0($2) #store word
$t0, 4($2)
1001
1111
0110
1000
1100
0101
1010
0000
0110
1000
1111
1001
1010
0000
0101
1100
1111
1001
1000
0110
0101
1100
0000
1010
1000
0110
1001
1111
wire [31:0] dataBus;
regFile registers (databus);
ALU ALUBlock (inA, inB, databus);
wire w0;
XOR (w0, a, b);
AND (s, w0, a);
Revolutions
1. Agricultural
2. Industrial
3. Information / computer
Computers have become part of daily life and are
ubiquitous (in cars, ATMs, microwave ovens, cell
phones, etc.)
Classes: desktops, servers, supercomputers, embedded
Software:
• Systems- Operating systems, compilers, assemblers
• Applications- Word processors, databases,
spreadsheets, games, etc...
Modified by S. J. Fritz Spring 2009 (19)
Modified by S. J. Fritz Spring 2009 (20)
Modified by S. J. Fritz Spring 2009 (21)
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
Modified by S. J. Fritz Spring 2009 (22)
Embedded Computers
°Run one set of related applications, such
as those in cell phones, TVs, cars, game
machines, etc.
°Growth of cell phones, with embedded
computers, has been faster than desktop
computers.
°In 2004 there were 1 PC, 2.2 cell phones,
and 2.5 TVs for every 8 people on the
planet.
°In 2006, a US family owned 12 gadgets
(3 TVs, 2 PCs, and others –MP3 players,
cell phones, game consoles.)
Modified by S. J. Fritz Spring 2009 (23)
The Processor Market
Modified by S. J. Fritz Spring 2009 (24)
°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
Modified by S. J. Fritz Spring 2009 (25)
§1.1 Introduction
The Computer Revolution
Moore’s Law
° Moore's Law, states that the number of
transistors on a chip will double about every two
years.
° Almost every measure of the capabilities of
digital electronic devices is linked to Moore's
law: processing speed, memory capacity, even
the number and size of pixels in digital cameras
° http://en.wikipedia.org/wiki/Moore's_law
° http://www.intel.com/technology/mooreslaw/index.htm
Modified by S. J. Fritz Spring 2009 (26)
From High Level to Low Level
Advantages of High Level Languages
° Think in more natural terms about real
world objects
° Improve programmer productivity
° Programmers independent of machine
Advantages of Low Level Language
° Faster
° Communicate directly with hardware
Modified by S. J. Fritz Spring 2009 (27)
Components of a Computer
Same components for
all kinds of computer

The BIG Picture
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

Modified by S. J. Fritz Spring 2009 (28)
Anatomy: 5 components of any Computer
Personal Computer
Computer
Processor
Control
(“brain”)
Datapath
(“brawn”)
Memory
(where
programs,
data
live when
running)
Devices
Input
Output
Keyboard,
Mouse
Disk
(where
programs,
data
live when
not running)
Display,
Printer
Modified by S. J. Fritz Spring 2009 (29)
Anatomy of a Computer
Output
device
Network
cable
Input
device
Modified by S. J. Fritz Spring 2009 (30)
Input
device
Anatomy of a Mouse
° Invented by Doug Englebart
(1967)
° Mechanical (roller ball)
° Optical mouse
• LED illuminates desktop
• Small low-res camera
• Basic image processor
-
Looks for x, y movement
• Buttons & wheel
° Supersedes roller-ball
mechanical mouse
Modified by S. J. Fritz Spring 2009 (31)
Through the Looking Glass
°LCD screen: picture elements (pixels)
• Mirrors content of frame buffer memory
Modified by S. J. Fritz Spring 2009 (32)
LCD Displays
°Liquid Crystal Display- thin, low power
°Uses rod shape molecules in a liquid
forming a twisted helix that bends light.
°Rods straighten when current is applied
and do not bend the light.
°Uses an active matrix of tiny transistors
to control current and form sharper
images.
°Images are composed of red, green and
blue dots.
Modified by S. J. Fritz Spring 2009 (33)
Forming Images
°An image is composed of picture
elements or pixels, represented as a
matrix of bits, called a bit map.
°Display matrix can be 640 x 480 to
2560 x 1600 pixels in size.
°A color display uses 8 bits for each of the
3 (RGB) colors, or 24 bits/pixel, creating
millions of colors.
°A raster refresh or frame buffer is the
hardware to support graphics. It stores
the bit map.
Modified by S. J. Fritz Spring 2009 (34)
Opening the Box
Modified by S. J. Fritz Spring 2009 (35)
Inside the Processor (CPU)
°Datapath: performs operations on data
°Control: sequences datapath, memory,
...
°Cache memory
• Small fast SRAM memory for immediate
access to data
Modified by S. J. Fritz Spring 2009 (36)
Inside the Processor
°AMD Barcelona: 4 processor cores
Modified by S. J. Fritz Spring 2009 (37)
Abstractions
The BIG Picture
°Abstraction helps us deal with complexity
• Hide lower-level detail
°Instruction set architecture (ISA)
• The hardware/software interface
°Application binary interface (ABI)
• The ISA plus system software interface
°Implementation
• The details underlying and interface
Modified by S. J. Fritz Spring 2009 (38)
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)
Modified by S. J. Fritz Spring 2009 (39)
Networks
°Communication and resource sharing
°Local area network (LAN): Ethernet
• Within a building
°Wide area network (WAN: the Internet
°Wireless network: WiFi, Bluetooth
Modified by S. J. Fritz Spring 2009 (40)
Technology Trends
° Electronics
technology continues
to evolve
• Increased capacity
and performance
• Reduced cost
DRAM capacity
Year
Technology
1951
Vacuum tube
1965
Transistor
1975
Integrated circuit (IC)
1995
Very large scale IC (VLSI)
2005
Ultra large scale IC
Modified by S. J. Fritz Spring 2009 (41)
Relative performance/cost
1
35
900
2,400,000
6,200,000,000
Overview of Physical Implementations
The hardware out of which we make systems.
° Integrated Circuits (ICs)
• Combinational logic circuits, memory elements,
analog interfaces.
° Printed Circuits (PC) boards
• substrate for ICs and interconnection, distribution of
CLK, Vdd, and GND signals, heat dissipation.
° Power Supplies
• Converts line AC voltage to regulated DC low voltage
levels.
° Chassis (rack, card case, ...)
• holds boards, power supply, provides physical
interface to user or other systems.
° Connectors and Cables.
Modified by S. J. Fritz Spring 2009 (42)
Review of Major Components
°Mouse ( mechanical, optical)
°Display (CRT, LCD)
°Motherboard
°Integrated Circuits (transistors, CMOS)
°CPU - controls memory, I/O, datapath
according to instructions
°Datapath- performs arithmetic operations
Modified by S. J. Fritz Spring 2009 (43)
Review of Major Components
°Memory
• DRAM - Dynamic RAM - main memory
• SRAM - Static RAM- faster, more
expensive
• Cache- fast buffer for main memory
• DIMM and SIMM - small boards that
contain DRAM chips
• RAM, ROM, volatile, non-volatile,
primary, secondary, magnetic disk,
optical disks (CD, DVD), FLASH based
Modified by S. J. Fritz Spring 2009 (44)
Memory Comparisons
°Main Memory
vs.
Disk
° Volatile
Non Volatile
° Fast(electrical)
Slower(mechanical)
° Expensive (100 * more)
Cheaper
Memory Access
DRAM
Disk
40 -80 nanoseconds
5- 15 milliseconds
10-9
(100,000 times faster)
Modified by S. J. Fritz Spring 2009 (45)
10-3
Computer Technology - Dramatic Change!
°Processor
• 2X in speed every 1.5 years (since ‘85);
100X performance in last decade.
°Memory
• DRAM capacity: 2x / 2 years (since ‘96);
64x size improvement in last decade.
°Disk
• Capacity: 2X / 1 year (since ‘97)
• 250X size in last decade.
Modified by S. J. Fritz Spring 2009 (46)
Performance measure
Technology Trends: Processor Performance
900
800
700
600
500
400
300
200
100
0
Intel P4 2000 MHz
(Fall 2001)
DEC Alpha
21264/600
1.54X/yr
DEC Alpha 5/500
DEC Alpha 5/300
DEC Alpha 4/266
IBM POWER 100
87 88 89 90 91 92 93 94 95 96 97
year
We’ll talk about processor performance later on…
Modified by S. J. Fritz Spring 2009 (47)
Technology Trends: Memory Capacity
(Single-Chip DRAM)
size
1000000000
100000000
Bits
10000000
1000000
100000
10000
1000
1970
1975
1980
1985
1990
1995
Year
• Now 1.4X/yr, or 2X every 2 years.
• 8000X since 1980!
Modified by S. J. Fritz Spring 2009 (48)
2000
year
1980
1983
1986
1989
1992
1996
1998
2000
2002
size (Mbit)
0.0625
0.25
1
4
16
64
128
256
512
Tech. Trends: Microprocessor Complexity
2X transistors/Chip Every 1.5 to 2.0 years
Called “Moore’s Law”
Modified by S. J. Fritz Spring 2009 (49)
Networks
Advantages
° Communication
° Resource Sharing
° Non-local access
Types
° LANs - Ethernet
° WANs
Modified by S. J. Fritz Spring 2009 (50)
Computer Technology - Dramatic Change!
°State-of-the-art PC when you graduate:
(at least…)
• Processor clock speed:
5000 MegaHertz
(5.0 GigaHertz)
• Memory capacity:
4000 MegaBytes
(4.0 GigaBytes)
• Disk capacity:
2000 GigaBytes
(2.0 TeraBytes)
• New units! Mega <= Giga, Giga <= Tera …
(Kilo, Mega, Giga, Tera, Peta, Exa, Zetta, Yotta = 1024)
Come up with a clever mnemonic, fame!
Modified by S. J. Fritz Spring 2009 (51)
• LaCie the first to offer
consumer-level 1.6
Terabyte disk!
• $2,200
• Weighs 11 pounds!
° SMALL
• Pretec is soon offering a
12GB CompactFlash card
• Size of a silver dollar
• Cost??
Modified by S. J. Fritz Spring 2009 (52)
www.engadget.com/entry/4463693158281236/
° BIG
www.lacie.com/products/product.htm?id=10129
Technology in the News
And in conclusion...
°Continued rapid improvement in Computing
• 2X every 1.5 years in processor speed;
every 2.0 years in memory size;
every 1.0 year in disk capacity;
Moore’s Law enables processor, memory
(2X transistors/chip/ ~ 1.5 or 2.0 yrs)
°5 classic components of all computers
Control Datapath Memory Input Output
Processor
Modified by S. J. Fritz Spring 2009 (53)