You are on page 1of 684
ELSEVIER COMPUTER ORGANIZATION AND DESIGN THE HARDWARE/SOFTWARE INTERFACE DAVID A. PATTERSON JOHN L. HENNESSY THIRD EDITION Computer Organization Design THE HARDWARE/SOFTWARE INTERFACE ACKNOWLEDGEMENTS igus 19, 1.15 Courtesy of lta, igure 1.11 Courtesy of Storage Technology Cop, Figures 1.7.1, 1.7.2, 6132 Courtesy ofthe Charles Babbage Intute Univesity of Minnesota Libraries, Minneapolis. Figures 173,613, 6133,793, 8.112 Courtesy of IM, Figure 1.7 Couctesyof Cray Ins igure 1.7.5 Courtesy of Apple Compute, nc Figure 1.7.6 Courtesy ofthe Computer History Museum, Figure 7.38 Courtey of AMD. Figares 79.1, 79.2 Courtesy of Museum of Science, Boston, Figure 7.9.4 Courtesy of MIPS Technologies, Inc. Figure 83 Peg Shorpinsi "Figure 8.1.1 Courtesy ofthe Computer Museum of Amerie. igre 8.113 Courtesy ofthe Commercial Computing Museum, [igures9.1.2, 9.18 Courtesy of NASA Ames Research Center "igure 9.114 Courtesy of Lawrence Livermore National Laboratory. Computers in the Rel Wor Photo ofA Laotian village” courtesy of David Sanger Photo ofan “Indian village” property of Encore Software, Lt India Photos of “Block and students" and “a pop-up archiva satelite tag.” courtesy of Profesor Barbara Block. Photos by Scot Taylor, Photes of “Professor Dawson and student” and “the Mica micromote” courtesy of AP/ World Wide Photos. Photos of “images of potery figment” and “a computer rconsta: ‘on courtesy of Anew Wis and David B, Cooper, Brown University, Division of Engineering, Photo ofthe Forostar TGV tan” by fos van de Kal, Photo ofthe interior of a Eurostar TGV cay” by Andy Vite. Photo of"irefighter Ken Whitten? courtesy of Word Economic Foram, Graphic of an “artificial eetina”™ © The San francisco Chronic, inte by permission, Image of “A Taser scan of Michelangelo's statue of David” courtesy of [Mare Levoy and Dr, Franca Falleti director of the Galleria del Aca emis, aly "An image fom the Sistine Chapel” courtesy of Luca Pezat. 1 image recorded ting the seanner for IR reflectography ofthe INOA (National Institute for Applied Optics http//arte not) atthe Opfco ele Petre Daren Florence, THIRD EDITION Computer Organization and Design THE HARDWARE/SOFTWARE INTERFACE David A. Patterson University of California, Berkeley John L. Hennessy Stanford University With a contribution by Peter J. Ashenden. James R. Larus Daniel J. Sorin Ashenden Designs Pty Ltd Microsoft Research Duke University AMSTERDAM + BOSTON + HEIDELBERG * LONDON, NEW YORK + OXFORD + PARIS * SAN DIEGO SAN FRANCISCO - SINGAPORE « SYDNEY - TOKYO MM v iN Morgan Kaufmann isan imprint of Elsevier MORGAN KAUFMANN PUBLISHERS Senior Eitor Denise. M. Penrose Publishing Services Manager Simon Cran Eitorat sant" Summer Bod Caner Design Ross Caron Design Cover and Chapter stration Chris Asimonais ‘rat Design {GG Book Services postion ‘iy Logan ad Durant Pbtshing, a ‘et stration Dartinouth Babin, Ine Copyedior KenDelaFenta Proofreader Jaq Brownstein Index tna Bushs Imrie peicer Courier Cover pater Courier Morgan Kaufmann Publishers isan imprint of levi 500 Sansome Sree, Si 40, Sa Pranic, CA 9411 a Crna or ee ey Pa a eae eee rere actos pps inno capal or al capt lemers Readers were sould cont the appropest compass {Stimore comple afuemation garding Wademarks and epatatin seprepanceoe Nop th pblioton may be pen de ina sera emo amie in any fm o anise lectaonic mechanical photocopying scanang cr otros prior een pt ‘sono the pale aes " s Persons may be sought dec foms Eerie’ Since & Tshnoloy Rights Department in Oxf {GR lon (Tessas fc en8 4958, mal permed Yo ma no damp your rent online via the Elsie homepage peeve com) by selecting aor Ssppor™and en OBnng Femi somes " Library of Congress Cataloging in-Publication Data Applicaton submitted ISBN: 1.55860-604-1 or information on all Morgan Kafnann publicstions ‘iit oue Web sea ware mk. com, Printed inthe United States of America brosur Sas 21 Contents Contents Preface ix CHAPTERS B Computer Abstractions and Technology 2 ra 12 13 14 15 16 @ 7 18 Introduction 3 Below Your Program 11 Underthe Covers 15 Real Stuff: Manufacturing Pentium 4 Chips 28 Fallacies and Pitfalls 33 Concluding Remarks 35 Historical Perspective and Further Reading 36 Exercises 36 COMPUTERS IN THE REAL WORLD Information Technology for the 4 Billion without IT 44 a Instructions: Language of the Computer 46 21 22 23 2 25 26 27 28 29 Introduction 48. Operations of the Computer Hardware 49 Operands of the Computer Hardware 52 Representing Instructions in the Computer 60 Logical Operations 68 Instructions for Making Decisions 72 Supporting Procedures in Computer Hardware 79) ‘Communicating with People 90 MIPS Addressing for 32-Bit Immediates and Addresses 95 2.10 ‘Translating and Starting Program 106 2.11 How Compilers Optimize 116 (@_—-2.12 How Compilers Work: An Introduction 121 contents 2.13 AC Sort Example to Put It All Together 121 2.14 Implementing an Object-Oriented Language 130 2.15 Amrays versus Pointers 130 2.16 Real Stuff: [4-32 Instructions 134 2.17 Fallacies and Pitfalls 143 2.18 Concluding Remarks 145 2.19 Historical Perspective and Further Reading 147 2.20 Exercises 147 COMPUTERS IN THE REAL WORLD Helping Save Our Environment with Data 156 Arithmetic for Computers 158 3.1 Introduction 160 2 Signed and Unsigned Numbers 160 3.3. Addition and Subtraction 170 34 Matkiplication 176 35° Division 183 3.6 Floating Point 189 3.7 Real Stuff Ploating Poin 3.8 Fallacies and Pitfalls 220 Concluding Remarks 225 3.10. Historical Perspective and Further Reading 229 3.11 Exercises 229 the 1A-32. 217 COMPUTERS IN THE REAL WORLD Reconstnucting the Ancient World 236 Assessing and Understanding Performance 238 4.1 Introduction 240 42 CPU Performance and Its Factors 246 43. Evaluating Performance 254 44 _ Real Stuff: Two SPEC Benchmarks and the Performance of Recent Intel Processors 259 45. Fallacies and Pitfalls 266 4.6 Concluding Remarks 270 4.7. Historical Perspective and Further Reading 272 48 Exercises 272 COMPUTERS IN THE REAL WORLD Moving People Faster and More Safely 280 Contents vit The Processor: Datapath and Control 282 5 52 53 54 53 56 37 58 59 5.10 5.11 5.12 5.13 Introduction 284 Logic Design Conventions 289 Building a Datapath 292 ASimple Implementation Scheme 300 AMulticycle Implementation 318 Exceptions 340 Microprogramming: Simplifying Control Design 346 ‘An Introduction to Digital Design Using a Hardware Design Language 346 Real Stuff: The Organization of Recent Pentium, Implementations 347 Fallacies and Pitfalls 350 Concluding Remarks 352 Historical Perspective and Further Reading 353, Exercises 354 COMPUTERS IN THE REAL WORLD Empowering the Disabled 366 Enhancing Performance with Pipelining 368 61 62 63 64 65 66 67 68 69 6.10 oll 62 6.13 ou ‘An Overview of Pipelining 370 APipelined Datapath 384 Pipelined Control 399 Data Hazards and Forwarding 402 Data Hazards and Stalls 413, Branch Hazards 416 Using a Hardware Description Language to Describe and Model a Pipeline 426 Exceptions 427 ‘Advanced Pipelining: Extracting More Performance 432, Real Stuff: The Pentium 4 Pipeline 448 Fallacies and Pitfalls 451 Concluding Remarks 4 Historical Perspective and Further Reading 454 Exercises 454 COMPUTERS IN THE REAL WORLD Mass Communication without Gatekeepers 464 contents Large and Fast: Exploiting Memory Hi Introduction 468 ‘The Basics of Caches 473 Measuring and Improx Virtual Memory 511 A Common Framework for Memory Hierarchies 538 Real Stuff: The Pentium P4 and the AMD Opteron Memory Hierarchies 546 7.7 Fallacies and Pitfalls 550 7.8 Concluding Remarks 552 7.9 Historical Perspective and Further Reading 555 7.10 Exercises 555 Cache Performance 492 COMPUTERS IN THE REAL WORLD Saving the World's Art Treasures 562 Storage, Networks, and Other Peripherals 564 Introduction 566 Disk Storage and Dependability 569 Networks 580 Buses and Other Connections between Processors, Memory, and 1/0 Devices 581 8.5 Interfacing I/O Devices to the Processor, Memory, and Operating system 588 8.6 I/O Performance Measures: Examples from Disk and File systems 597 8.7 Designing an 1/0 System 600 8.8 Real Stuff A Digital Camera 603 8.9 Fallaciesand Pitfalls 606 8.10 Concluding Remarks 609 8.11 Historical Perspective and Further Reading 611 8.12 Exercises 611 COMPUTERS IN THE REAL WORLD Saving Lives through Better Diagnosis 622 Multiprocessors and Clusters 9-2 9.1 Introduction 9-4 9.2 Programming Multiprocessors 9-8 9.3 Multiprocessors Connected by a Single Bus 9-11

You might also like