lectures for 3rd edition
play

Lectures for 3rd Edition Note: these lectures are often - PowerPoint PPT Presentation

Lectures for 3rd Edition Note: these lectures are often supplemented with other materials and also problems from the text worked out on the blackboard. Youll want to customize these lectures for your class. The student audience for these


  1. Lectures for 3rd Edition Note: these lectures are often supplemented with other materials and also problems from the text worked out on the blackboard. You’ll want to customize these lectures for your class. The student audience for these lectures have had exposure to logic design and attend a hands-on assembly language programming lab that does not follow a typical lecture format. 1  2004 Morgan Kaufmann Publishers

  2. Chapter 1 2  2004 Morgan Kaufmann Publishers

  3. Introduction • This course is all about how computers work • But what do we mean by a computer? – Different types: desktop, servers, embedded devices – Different uses: automobiles, graphics, finance, genomics… – Different manufacturers: Intel, Apple, IBM, Microsoft, Sun… – Different underlying technologies and different costs! – Different underlying technologies and different costs! • Analogy: Consider a course on “automotive vehicles” – Many similarities from vehicle to vehicle (e.g., wheels) – Huge differences from vehicle to vehicle (e.g., gas vs. electric) • Best way to learn: – Focus on a specific instance and learn how it works – While learning general principles and historical perspectives 3  2004 Morgan Kaufmann Publishers

  4. Why learn this stuff? • You want to call yourself a “computer scientist” • You want to build software for people use (need performance) • You need to make a purchasing decision or offer “expert” advice • Both Hardware and Software affect performance: – Algorithm determines number of source-level statements – Language/Compiler/Architecture determine machine instructions (Chapter 2 and 3) – Processor/Memory determine how fast instructions are executed (Chapter 5, 6, and 7) – I/O system determine how fast I/O operations may be executed (Chapter 8) • Assessing and Understanding Performance in Chapter 4 4  2004 Morgan Kaufmann Publishers

  5. What is a computer? • Components: – input (mouse, keyboard) – output (display, printer) – memory (disk drives, DRAM, SRAM, CD) – network • Our primary focus: the processor (datapath and control) – implemented using millions of transistors – implemented using millions of transistors – Impossible to understand by looking at each transistor – We need... 5  2004 Morgan Kaufmann Publishers

  6. Abstraction • Delving into the depths reveals more information • An abstraction omits unneeded detail, helps us cope with complexity • Both hardware and software consist of hierarchical layers, with each lower layer hiding details from the level above. High-level language: - portable (machine-independent) language. Assembly language: - A symbolic representation of machine instr. 6  2004 Morgan Kaufmann Publishers

  7. Abstraction • A simplified view of hardware and software as hierarchical layers: Operating System Compiler … 7  2004 Morgan Kaufmann Publishers

  8. How do computers work? • Need to understand abstractions such as: – Applications software – Systems software – Assembly Language – Machine Language – Architectural Issues: i.e., Caches, Virtual Memory, Pipelining – Sequential logic, finite state machines – Combinational logic, arithmetic circuits – Boolean logic, 1s and 0s – Transistors used to build logic gates (CMOS) – Semiconductors/Silicon used to build transistors – Properties of atoms, electrons, and quantum dynamics • So much to learn! 8  2004 Morgan Kaufmann Publishers

  9. 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 – True or False: Binary compatibility is extraordinarily important? • Modern instruction set architectures: – IA-32, PowerPC, MIPS, SPARC, ARM, and others 9  2004 Morgan Kaufmann Publishers

  10. Historical Perspective • ENIAC built in World War II was the first general purpose computer – Used for computing artillery firing tables – 80 feet long by 8.5 feet high and several feet wide – Each of the twenty 10 digit registers was 2 feet long – Used 18,000 vacuum tubes – Performed 1900 additions per second – Since then: Moore’s Law: transistor capacity doubles every 18-24 months 10  2004 Morgan Kaufmann Publishers

  11. Historical Perspective – 11  2004 Morgan Kaufmann Publishers

  12. Chapter 2 12  2004 Morgan Kaufmann Publishers

  13. Instructions: • Language of the Machine • We’ll be working with the MIPS instruction set architecture – similar to other architectures developed since the 1980's – Almost 100 million MIPS processors manufactured in 2002 – used by NEC, Nintendo, Cisco, Silicon Graphics, Sony, … 1400 Other Other 1300 1300 SPARC 1200 Hitachi SH PowerPC 1100 Motorola 68K 1000 MIPS 900 IA-32 ARM 800 700 600 500 400 300 200 100 0 1998 1999 2000 2001 2002 13  2004 Morgan Kaufmann Publishers

  14. MIPS Instructions • MIPS Instruction Types – Arithmetic – Data transfer – Logical operation – Flow control • • Design Principles – Design Principle 1: Simplicity favors regularity. – Design Principle 2: Smaller is faster. – Design Principle 3: Good design demands a compromise – Design Principle 4: Make common cast fast. 14  2004 Morgan Kaufmann Publishers

  15. MIPS Arithmetic Instructions • All instructions have 3 operands • Operand order is fixed (destination first) Example: C code: a = b + c MIPS ‘code’: MIPS ‘code’: add a, b, c add a, b, c (we’ll talk about registers in a bit) “The natural number of operands for an operation like addition is three…requiring every instruction to have exactly three operands, no more and no less, conforms to the philosophy of keeping the hardware simple” 15  2004 Morgan Kaufmann Publishers

  16. MIPS Arithmetic Instructions • Design Principle 1: simplicity favors regularity. • Of course this complicates some things... C code: a = b + c + d; MIPS code: add a, b, c add a, a, d • Operands must be registers, only 32 registers provided • Each register contains 32 bits • Design Principle 2: smaller is faster. Why? 16  2004 Morgan Kaufmann Publishers

  17. MIPS Arithmetic Instructions • Register vs. Memory – Arithmetic instructions operands must be registers, — only 32 registers provided – Compiler associates variables with registers – What about programs with lots of variables? Control Input Memory Datapath Output Processor I/O 17  2004 Morgan Kaufmann Publishers

  18. MIPS Arithmetic Instructions • Memory Organization – Viewed as a large, single-dimension array, with an address. – A memory address is an index into the array – "Byte addressing" means that the index points to a byte of memory. 0 8 bits of data 1 8 bits of data 2 8 bits of data 3 8 bits of data 4 8 bits of data 5 8 bits of data 6 8 bits of data ... 18  2004 Morgan Kaufmann Publishers

  19. MIPS Arithmetic Instructions • Memory Organization – Bytes are nice, but most data items use larger "words" – For MIPS, a word is 32 bits or 4 bytes. 0 32 bits of data 4 32 bits of data Registers hold 32 bits of data Registers hold 32 bits of data 8 32 bits of data 12 32 bits of data ... – 2 32 bytes with byte addresses from 0 to 2 32 -1 – 2 30 words with byte addresses 0, 4, 8, ... 2 32 -4 – Words are aligned i.e., what are the least 2 significant bits of a word address? 19  2004 Morgan Kaufmann Publishers

  20. MIPS Data Transfer Instructions • Data Transfer Instruction: Load and store instructions • Example: C code: A[12] = h + A[8]; MIPS code: lw $t0, 32($s3) // A[8]->$t0 add $t0, $s2, $t0 sw $t0, 48($s3) // $t0->A[12] • Can refer to registers by name (e.g., $s2, $t2) instead of number • Store word has destination last • Remember arithmetic operands are registers, not memory! Can’t write: add 48($s3), $s2, 32($s3) 20  2004 Morgan Kaufmann Publishers

  21. Our First Example • Can we figure out the code? swap(int v[], int k); { int temp; temp = v[k] v[k] = v[k+1]; v[k+1] = temp; v[k+1] = temp; swap: swap: } muli $2, $5, 4 add $2, $4, $2 lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) jr $31 21  2004 Morgan Kaufmann Publishers

  22. So far we’ve learned: • MIPS — loading words but addressing bytes — arithmetic on registers only • Instruction Meaning add $s1, $s2, $s3 $s1 = $s2 + $s3 sub $s1, $s2, $s3 sub $s1, $s2, $s3 $s1 = $s2 – $s3 $s1 = $s2 – $s3 lw $s1, 100($s2) $s1 = Memory[$s2+100] sw $s1, 100($s2) Memory[$s2+100] = $s1 22  2004 Morgan Kaufmann Publishers

  23. Machine Language • Instructions, like registers and words of data, are also 32 bits long – Example: add $t1, $s1, $s2 – registers have numbers, $t1=9, $s1=17, $s2=18 • R-type Arithmetic Instruction Format: 6bits 5bits 5bits 5bits 5bits 6bits 6bits 5bits 5bits 5bits 5bits 6bits 000000 10001 10010 01001 00000 100000 op rs rt rd shamt funct • Can you guess what the field names stand for? 23  2004 Morgan Kaufmann Publishers

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend