Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 649 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
649
Dung lượng
9,45 MB
Nội dung
Texts in Computer Science Editors David Gries Fred B Schneider For further volumes: http://www.springer.com/series/3191 Daniel Page A Practical Introduction to Computer Architecture 123 Dr Daniel Page University of Bristol Dept Computer Science Room 3.10, Merchant Venturers Building Woodland Road, Bristol United Kingdom, BS8 1UB page@compsci.bristol.ac.uk Series Editors David Gries Department of Computer Science Upson Hall Cornell University Ithaca, NY 14853-7501, USA Fred B Schneider Department of Computer Science Upson Hall Cornell University Ithaca, NY 14853-7501, USA ISBN 978-1-84882-255-9 e-ISBN 978-1-84882-256-6 DOI 10.1007/978-1-84882-256-6 Springer Dordrecht Heidelberg London New York British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library Library of Congress Control Number: 2009922086 c Springer-Verlag London Limited 2009 Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms of licenses issued by the Copyright Licensing Agency Enquiries concerning reproduction outside those terms should be sent to the publishers The use of registered names, trademarks, etc., in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made Printed on acid-free paper Springer is part of Springer Science+Business Media (www.springer.com) To Kate ♥ Foreword It is a great pleasure to write a preface to this book In my view, the content is unique in that it blends traditional teaching approaches with the use of mathematics and a mainstream Hardware Design Language (HDL) as formalisms to describe key concepts The book keeps the “machine” separate from the “application” by strictly following a bottom-up approach: it starts with transistors and logic gates and only introduces assembly language programs once their execution by a processor is clearly defined Using a HDL, Verilog in this case, rather than static circuit diagrams is a big deviation from traditional books on computer architecture Static circuit diagrams cannot be explored in a hands-on way like the corresponding Verilog model can In order to understand why I consider this shift so important, one must consider how computer architecture, a subject that has been studied for more than 50 years, has evolved In the pioneering days computers were constructed by hand An entire computer could (just about) be described by drawing a circuit diagram Initially, such diagrams consisted mostly of analogue components before later moving toward digital logic gates The advent of digital electronics led to more complex cells, such as half-adders, flip-flops, and decoders being recognised as useful building blocks However, miniaturisation of devices and hence computers has led to the design of single circuits containing millions or even billions of components As a result, handlay-out is only used for specific modules, and circuit diagrams are less useful as a mechanism for describing functionality for real circuits Instead, two formalisms are used in industry: HDLs and mathematics A HDL allows us to tell the component-layout and simulation tools how we would like to implement our circuit; mathematics tells us what the circuit ought to In order to verify whether the circuit does what we want it to, we can (partly mechanically) compare the mathematical description with the HDL description This represents increased use of abstraction to cope with complexity, and an engineer can now be productive by simply understanding and using high-level circuit design (e.g., multiplier design or pipelined processors) and formalisms (e.g., HDLs and mathematics) vii viii Foreword Circuit diagrams are still used in the design flow, but mostly to sketch the physical layout, in order to predict whether a circuit can be laid out sensibly Dealing with gaps in understanding between such a wide range of concepts and techniques is often off-putting for people new to the subject The best way to approach the problem is by placing it within a practical context that enables students to experiment with ideas and discover themselves the advantages and disadvantages of a particular technique In this book, Dan does just that by giving an excellent overview of key concepts and an introduction to formalisms with which they can be explored I hope this book will inspire many readers to follow a career in this fascinating subject Henk Muller Principal Technologist, XMOS Preface In theory there is no difference between theory and practice In practice there is – L.P “Yogi” Berra Overview In my (limited) experience, and although there are a number of genuinely excellent textbooks on the subject, two main challenges exist in relation to delivery of University level taught modules in computer architecture: Such modules are often regarded as unpopular and irrelevant by students who have not been exposed to the subject before, and who view a computer system from the applications level This is compounded by the prevalence of technologies such as Java which place a further layer between the student and actual computer hardware In short, and no matter how one tries to persuade them otherwise, students often see no point in learning about the internals of a computer system because they cannot see the benefit Conventional textbooks teach the subject in a different way than in other modules students are exposed to at the same time For example, conventional wisdom says that one cannot “teach” programming, one has to “do” programming in order to learn This is in stark contrast to textbooks on computer architecture where students are often forced to learn in a more theoretical way, learning by taking facts for granted rather than experimenting to arrive at their own conclusions For example, because of the difficulty in working with large logic designs on paper, any practical work is often limited and hence detached from the more challenging content I would argue that this is a shame: computer architecture represents a broad spectrum of fundamental and exciting topics that underpin computer science in general Aside from the technical challenges and sense of achievement that stem from ix x Preface understanding exactly how high-level programs are actually executed on devices built from simple building blocks, historical developments in computer architecture neatly capture and explain many design decisions that have shaped a landscape we now take for granted The representation of strings in C is a great example: the nullterminated ASCIIZ approach was not adopted for any real reason other than the PDP-7 computer included instructions ideal for processing strings in this form, and yet we still live with this decision years after the PDP-7 became obsolete Seemingly frivolous anecdotes and examples like this are increasingly being consigned to history whereas from an Engineering perspective, one would like to learn and understand previous approaches so as to potentially improve in the future International experts regularly debate tools and techniques for delivering University-level modules in computer architecture; the Workshop on Computer Architecture Education (WCAE), currently held in conjunction with the International Symposium on Computer Architecture (ISCA), is the premier research conference in this area This book represents an attempt at translating my personal philosophy, that theoretical concepts should be accessible for practical experimentation, into a form suitable for use in such modules Put simply, I see computer architecture as a subject in which “getting things done” is paramount; the ability to understand tradeoffs before selecting between and implementing well considered design options is often as important as the study of those options at a more theoretical level This focus is underlined by the book sub-title: a “practical” approach is the aim throughout To enable this, a key feature of this book is inclusion and use of a hardware description language (i.e., Verilog), and a concrete processor (i.e., MIPS32) as practical vehicles for modelling and experimenting with digital logic and processor design Target Audience The content is organised into three parts which contain a total of thirteen core chapters Although some slight disagreement about inclusion of specific topics is inevitable, the chapters represent a compromise between my informal opinion, interests and experience, and more formal curriculum guidelines such as that developed by the UK Quality Assurance Agency (QAA): http://www.qaa.ac.uk/ Of course, international equivalents exist; examples include those developed jointly by the IEEE and ACM, leading professional bodies within this domain: http://www.computer.org/curriculum/ The general aim of this book is to cover topics every computer science student should have at least a basic grasp of, and equip said students with enough knowledge to read and understand more advanced textbooks In this respect, the core target audience is first-year Undergraduate students with a rudimentary knowledge of Preface xi programming in C More generally, the book content is pitched at a level which satisfies most of the demands that have resulted from our degree programmes at the University of Bristol In particular, the more advanced material has proved useful as a bridge toward, or in support of, more specialised textbooks that cover later-year Undergraduate and Postgraduate modules Organisation The book chapters are described briefly below Very roughly the three parts of the book can be viewed as somewhat self-contained, representing three layers or levels of abstraction: the digital logic layer, the instruction set and micro-architecture layer, and the hardware/software interface Part deals with basic tools and techniques which underpin the rest of the book: Chapter Introduces the theoretical background including logic, sets, and number representation Chapter Uses the theory developed in the previous chapter to describe the basics of digital logic including logic gates and their construction using transistors, combinatorial and clocked circuits and their optimisation Chapter As a means of realising the digital logic designs presented in the previous chapter, Verilog is presented in an introductory manner; this content is written with a reader who is a proficient C programmer in mind Part deals with the broad topic of processor design and implementation The content takes a step-by-step approach, starting with a functional description of a computer processor and gradually expanding on the details, issues and techniques that have resulted in modern, high-performance processor designs: Chapter The first step in introducing the design of processors (as an extension to the study of general circuits) is to track historical developments and use them as a means to explain central concepts such as the fetch-decode-execute cycle Chapter Once the core concepts are introduced, a concrete realisation in the form of MIPS32 is discussed; this discussion includes details such as addressing modes and instruction encoding for example Chapter This chapter outlines some basic methods for evaluating processors in terms of various metrics which can be used to defined quality, focusing on performance in particular Chapter As a vital component in any processor, the design of efficient circuits for arithmetic (e.g., addition and multiplication) is introduced and demonstrated using Verilog Chapter In the same way as arithmetic, the design of efficient components in the memory hierarchy is introduced and demonstrated using Verilog Chapter Finally, a number of more advanced topics in processor design are investigated including approaches such as superscalar and vector processors 626 B Example Solutions a = ( x[ ] ) & 0xFF; b = ( x[ ] >> ) & 0xFF; a = a / 2; b = b / 2; x[ ] = ( uint16 )( a ) | ( uint16 )( b > ) & 0xFF; a = a / 2; b = b / 2; x[ ] = ( uint16 )( a ) | ( uint16 )( b > ) & 0xFF; a = a / 2; b = b / 2; x[ ] = ( uint16 )( a ) | ( uint16 )( b