ece 0142 computer organizationjuy9/142/slides/l1-introduction.pdf · who uses assembly language the...

29
1 ECE 0142 Computer Organization Lecture 1 Introduction Professor Jun Yang Department of Electrical and Computer Engineering University of Pittsburgh

Upload: others

Post on 28-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

  • 1

    ECE 0142 Computer Organization

    Lecture 1 Introduction

    Professor Jun Yang

    Department of Electrical and Computer EngineeringUniversity of Pittsburgh

  • Logistics

    Course Material:http://www.pitt.edu/~juy9/142/142.html

    Book: Hennessy and Patterson, “Computer Organization and Design, The

    Hardware/Software Interface”, 5th Ed, MK. Requirements:

    Homework 20% Quizzes 20% (weekly during recitations) Midterm 1 15% (2/4, in class) Midterm 2 15% (3/17, in class) Final 30% (comprehensive, time TBD)

    Office Hours: Jun Tu 2:30-4 1111 Ben Amr Mo 12-2 1142 Ben Chang Th 2-4 1109 Ben 2

  • 3

    Prerequisites

    Some experience with a high level language C, etc.

    Digital logic circuits Covered in ECE/CoE 0132 Digital Logic

  • Computer systems

    Three general classes of “computer”

    “Desktop computers” Examples include PC, Mac, Chrome, Linux… Notebooks, netbooks, tablets (smart phones), … Interact with a user – applications Handful of central processing units (4-12?), gigabytes (109 bytes)

    memory, few terabytes (1012 bytes) of disk 35 gigaflops (35×109 “floating-point math calculations” per second

    for Intel Ivy Bridge)

  • Computer systems

    Three general classes of “computer”

    “Desktop computers” “Servers”

    Web servers, Computational servers, Supercomputers Interact with other computers to “solve a problem” or “provide services” Dozens to thousands of CPUs (Tianhe-2: 3,120,000 CPUs, 33.9

    petaflops, or 33.9×1015 calculations per second vs. 35×109 for PC) Gigabytes to terabytes memory (Sequoia: 1,024,000GB [1.0 petabyte!]) Petabytes (1015 bytes) of storage Connected (network) to work together Power hungry but efficient (Tianhe-2: 17.8 MW vs. Three Mile Island

    ~800 MW output). Data centers: 1.7% to 2.2% of total electricity in US.)

  • Computer systems

    Three general classes of “computer”

    “Desktop computers” “Servers” “Embedded computers”

    Hidden inside something not computer Applications that run on these computers interact with the “real

    world” Multiple different processors for different functions Kilobytes (103 bytes) to gigabytes of memory Kilobytes to gigabytes of storage Slow speed to fast speed Widest range of design!

    Chart1

    $14B Microcontroller

    $4B DSP

    Sales

    Embedded Processing Market (2010)

    14

    4

    Sheet1

    Sales

    $14B Microcontroller14

    $4B DSP4

    To update the chart, enter data into this table. The data is automatically saved in the chart.

  • Layers or views

    Our view of a computer system in this course is centered around the interface between the lowest level in software and the hardware

    antique!E

    CE

    142

    App 1 App 2 App 3 App 4

    System Software (Compiler, Assembler, Linker)

    Operating System

    Instruction Set Architecture (ISA)

    Subsystems, Microarchiture

    Circuits, Electronics, Devices

  • 8

    High-level language, e.g. Cswap (int v[], int k){ int temp;

    temp = v[k];v[k] = v[k+1];v[k+1] = temp;

    }

    Assembly language, e.g. MIPSswap:

    muli $2, $5, 4add $2, $4, $2lw $15, 0($2)lw $16, 4($2)sw $16, 0($2)sw $15, 4($2)jr $31

    Binary machine language 00000000101000010000000000011000000000001000111000011000001000011000110001100010000000000000000010001100111100100000000000000100101011001111001000000000000000001010110001100010000000000000010000000011111000000000000000001000

    C Compiler

    Assembler

  • Assembly Language, Machine Code

    High-level programming languages are a convenience CPU does not “understand” the high-level language!

    CPU understands “binary numbers” Binary number represents a command A command makes CPU take some action (e.g., addition) Commands known as “machine instructions” (code)

    Who wants to program in binary numbers??? Assembly language is convenience Programming in machine instructions

  • A Day in the Life of a C (Java) Program

    hello.c

    compiler

    hello.s

    assembler

    hello.o

    linker

    crt0.o

    hello

    loader

    #include

    int main (void){

    printf(“Hello ECE 142!\n”);}

    hello.c

    Basic runtim library

    usr{1} helloHello ECE 142!usr{2}

  • Assembling, Loading, Running

    Assembly language program is assembled Assembler is tool to create machine code from assembly language

    Assembled program placed in main memory Loader is tool to put the machine instructions into memory Loader is automatically used when you run the program

    CPU gets access to machine instructions in memory CPU does the command for each instruction

  • Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    assembled

    loaded

    04812162024

    machine code address

  • Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    assembled

    loaded

    04812162024address

  • Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    fetch 04812162024address

    Processor accesses instructions only through memory

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    execute01284820

    04812162024address

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    fetch04812162024address

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    execute21080001

    04812162024address

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    fetch

    04812162024address

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    execute290a000a

    04812162024address

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    fetch

    04812162024address

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    execute01540fffc

    04812162024address

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    fetch 04812162024address

  • Processor accesses instructions only through memory

    Assembling, Loading, Running

    loop: add $t1,$t1,$t0addi $t0,$t0,1slti $t2,$t0,10bne $t2,$0,loop

    0128482021080001290a000a01540fffc

    ...0128482021080001290a000a01540fffc...

    assembly language machine code

    memory

    execute01284820

    04812162024address

  • 24

    Who Uses Assembly Language

    The compiler writer must generate machine language from a HLL

    The writer of time or space critical code Performance goals may force program specific optimizations of the

    assembly language Special purpose or embedded processor programmers

    Special functions and heavy dependence on unique I/O devices can make HLL’s useless

    The processor designer must implement and trade-off instruction functionality

  • 25

    An Assembly Language Uses anInstruction Set Architecture (ISA)

    Instruction set: the collection of all machine operations. ISA is a programmer interface to the hardware Programmer sees set of instructions, along with the machine

    resources manipulated by them. ISA includes

    instruction set, programmer accessible registers of the system, and Memory

    “Architecture” == ISA, “Microarchitecture” == Implementation

    System SoftwareApplication Software

    Hardware

  • Layers or views

    Our view of a computer system in this course is centered around the interface between the lowest level in software and the hardware

    antique!E

    CE

    142

    App 1 App 2 App 3 App 4

    System Software (Compiler, Assembler, Linker)

    Operating System

    Instruction Set Architecture (ISA)

    Subsystems, Microarchiture

    Circuits, Electronics, Devices

  • 27

    Sample System Architecture

  • 28

    The Memory Hierarchy

    Modern computers have a hierarchy of memories Allows tradeoffs of speed/cost/volatility/size, etc.

    CPU sees common view of levels of the hierarchy.

    CPU CacheMemory Main Memory Disk Memory

    TapeMemory

  • 29

    Some Basics before We Move onScales, Units, and Conventions

    Term

    K (kilo-)

    M (mega-)

    G (giga-)

    T (tera-)

    10 3

    10 6

    10 9

    10 12

    2 10 = 1024

    2 20 = 1,048,576

    2 30 = 1,073,741,824

    2 40 = 1,099,511,627,776

    Normal Usage As a power of 2

    Term Usage

    m (milli-)µ (micro-)

    n (nano-)

    p (pico-)

    10 -3

    10 -6

    10 -9

    10 -12

    Units: Bit (b), Byte (B), Nibble, Word (w), Double Word, Long WordSecond (s), Hertz (Hz)

    Powers of 2 are used to describe sizes in a computer, e.g. memory sizes.

    ECE 0142 Computer OrganizationLogisticsPrerequisitesComputer systemsComputer systemsComputer systemsLayers or viewsSlide Number 8Assembly Language, Machine CodeA Day in the Life of a C (Java) ProgramAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningAssembling, Loading, RunningWho Uses Assembly LanguageAn Assembly Language Uses an�Instruction Set Architecture (ISA)Layers or viewsSample System ArchitectureThe Memory HierarchySome Basics before We Move on�Scales, Units, and Conventions