Theory and Design of Digital Computer Systems Second edition Douglas Lewin Formerly Profe~sor of Digital Processes Bronel University and David Noaks CEE Technology Management Warwickshire SPRINGER-SCIENCE+BUSINESS MEDIA, B.V. First published in 1972 as Theory and Design of Digital Computers New edition published in 1980 as Theory and Design of Digital Computer Systems Reprinted 1981 Second edition 1992 tel 1972, 1980 Douglas Lewin; 1992 The Estate of Douglas Lewin and I>avid Noaks Originally published by Kluwer Academic Publishers in 1992 Typeset in 10/12 pt Times by Excel Typesetters Company, Hong Kong ISBN 978-0-412-42880-7 ISBN 978-94-011-1576-6 (eBook) DOI 10.1007/978-94-011-1576-6 Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the UK Copyright Designs and Patents Act, 1988, this publication may not be reproduced, stored, or transmitted, in any form or by any means, without the prior permission in writing of the publishers, or in the case of reprographic reproduction only in accordance with the terms of the licences lssued by the Copyri2ht Licensing Agency in the UK, or in accordance with the terms of ficences issued by the appropriate Reproduction Rights Organization outside the UK. Enquiries conceming reproduction outside the terms stated here should be sent to the publishers at the London address printed on this page. The publisher makes no representation, express or implied, with regard Co the accuracy of the information contained IR this book and cannot accept any legal responsibility or liability for any errors or omissions that maybe made. A catalogue record for this book is available from the British Library Library of Congress Cataloging-in-Publication data Lewin, Douglas. Theory and design of digital computer systemslDouglas Lewin, David Noaks. - 3rd ed. p. cm. Includes index. ISBN 978-0-412-42880-7 1. Electronic digital computers - Design and construction. I. Noaks, David. 11. Title. TK7888.3.L38 1992 004 - dc20 92-30621 CIP Printed on permanent acid-free text paper, manufactured in accordance with the proposed ANSIINISO Z 39.48-199X-and ANSI Z 39.48-1984 Contents' Preface xi 1 The stored program principle 1 1.1 Introduction 1 1.2 Instruction and number representation 4 1.3 Computer operation 11 1.4 Applications 13 References and bibliography 15 2 Data representation and computer arithmetic 16 2.1 Data types 16 2.2 Binary codes 17 2.3 Error detection 21 2.4 Error-correcting codes 23 2.5 Negative numbers 24 2.6 Binary arithmetic 25 2.7 Floating-point numbers 28 References and bibliography 30 Tutorial problems 31 3 Computer organization and programming 32 3.1 Instruction set and operation codes 32 3.2 Instruction formats 33 3.3 Organization of data and instructions in memory 37 3.4 Addressing modes 38 3.5 Machine-Iangu~.ge programming 43 3.6 Subroutines 56 3.7 Stacks and re-entrant code 57 3.8 Expansion of storage capacity 62 3.9 Assembly-language programming 63 3.10 Procedure-orientated languages 67 3.11 Register transfer languages 68 3.12 Processor structure 71 I I vi CONTENTS 3.13 Instruction execution 74 References and bibliography 74 Tutorial problems 76 4 Control structures and microprogramming 78 4.1 Control unit organization 78 4.2 Logic components 81 4.3 The microprogram concept 99 4.4 Microinstruction formats 107 4.5 Microprogrammable structures 111 4.6 Programming the microprogram control unit 119 References and bibliography 121 Tutorial problems 123 5 Arithmetic algorithms and processors 125 5.-1 Introduction 125 5.2 Binary addition and subtraction circuits 126 5.3 Serial full-adder circuits 131 5.4 Cascaded serial adder circuits 134 5.5 Parallel full-adder circuits 138 5.6 Carry-completion adder circuit 139 5.7 Carry look-ahead adder circuits 142 5.8 Carry-save adders 148 5.9 Overflow and out-of-range circuits 149 5.10 Binary-coded decimal adders 151 5.11 Unsigned binary multiplication 153 5.12 Array multiplication 157 5.13 Fast multiplier circuits 163 5.14 Binary division circuits 170 5.15 Multiplication and division of signed binary numbers 174 5.16 Round-off of binary numbers 178 5.17 Floating-point binary arithmetic 180 5.18 Software implementation 185 5.19 Error-detecting arithmetic logic 185 References and bibliography 193 Tutorial problems 194 6 Memory systems 196 6.1 Introduction 196 6.2 Characteristics of memory devices 197 6.3 Memory hierarchy 199 6.4 Semiconductor memories 201 6.5 Magnetic recording and storage techniques 218 6.6 Optical disk storage 235 I I CONTENTS vii 6.7 Associative memory 236 6.8 Cache memory 237 6.9 Virtual memory 242 6.10 Memory-management systems 244 References and bibliography 249 Tutorial problems 251 7 Input/output systems 252 7.1 Introduction 252 7.2 The input/output function 255 7.3 Peripheral devices 256 7.4 Input/output interfaces and buses 264 7.5 Interrupt mechanisms 271 7.6 Direct memory access 275 7.7 Communications interfaces 277 7.8 Input/output processors 280 7.9 Graphics systems 283 References and bibliography 285 Tutorial problems 286 8 Advanced computer architectures 288 8.1 Introduction 288 8.2 Parallel processing 289 8.3 Digital signal processors (DSPs) 326 8.4 Reduced instruction set computers (RISC) 334 8.5 Associative processors 338 8.6 Languages 343 References and bibliography 346 9 Computer networks 349 9.1 Introduction 349 9.2 Data transmission 351 9.3 Protocols 354 9.4 Local area networks (LANs) 360 9.5 Wide area networks (WANs) 370 References and bibliography 372 Tutorial problems 373 10 Engineering and system aspects 375 10.1 Introduction 375 10.2 Realizing the logic design 378 10.3 Noise problems 388 10.4 System testing procedures 395 10.5 Logic testing and simulation 399 J ~] [--- ___C_ O_N_TENTS _________________ 10.6 Reliability and the use of redundancy 407 10.7 Software tools 419 References and bibliography 426 Tutorial problems 429 Worked solutions to selected problems 431 Appendix 1 Logic symbols 467 Al Introduction 467 A2 Symbol structure 467 A3 Dependency 470 A4 MIL-STD-806B logic symb~ls 474 Appendix 2 Glossary of abbreviations 475 Index 479 Preface Knowledge: A little light expels much darkness _ Bahya ibn Paquda, Duties of the Heart During the early 1970s digital computer techniques concentrated on the computational and interfacing aspects of digital systems and the decade began as the age of both the mainframe computer and the minicomputer. Engineers and system designers needed to know the fundamentals of computer operation and how the practical limitations of the architectures of the day, the memory size, cost and performance could be overcome; it was for this reason that this book was first written. By 1980 the microprocessor revolution had arrived. As a result the microprocessor became a component of a system, rather than a system itself, and the need to understand the behaviour of the device became of even greater importance to the system designer. New developments in mainframe computers were few, with networks of minicomputers taking over their role in many instarices. The 1980 revision of this book took into account the major advances in semiconductor technology that had occurred since it was first published in 1972, and included material relevant to the microprocessor. Perhaps one of the most significant advances in the use of digital techniques in the 1980s was in digital communications and the use of computer networks and public networking for the transmission of digital data. The requirement to understand basic digital system principles in order to develop these systems remains unchanged, as indeed have the computer principles themselves, although greater freedom is available to design more complex computer architectures. The second edition of this book is a complete revision of all chapters of the 1980 edition, updating the material with respect to current practical semiconductor processes and magnetic materials in general use, and adding additional material on digital signal processors and a completely new chapter on computer networks. The outline of this revision was undertaken by Douglas Lewin before _________________ ~_x~1 I~ PR_E_F_A_C_E_ _______________~ his untimely death. It has been my privilege, as both a friend and a colleague for many years and one of many who have used his texts for teaching in university and polytechnic engineering courses, to have been asked by Gerry Musgrave on behalf of Douglas's daughter Terina to complete the revision. David R. Noaks Si quid novisti rectius istis, Candidus imperti; si non, his utere mecum -. HORACE 'Now, brother, if a better system's thine, Impart it frankly, or make use of mine.' The stored program 1 principle 1.1 INTRODUCTION There are two basic types of computer - the analogue computer and the digital computer - together with a combination of the two called the hybrid computer. The technology of the time dictated that the analogue computer predated the digital, and its application was almost entirely in engineering rather than in commerce. Nowadays the situation is reversed and the digital computer, which has a very much broader field of applica tion, predominates. In this book we shall be concerned 'primarily with the digital computer, but before we start it is worth describing the charac teristics of all three types. The analogue computer represents the variaBles (and constants) in its calculations by physical quantities (usually voltage and time): hence the name 'analogue'. The slide rule is a very simple example, where length is used to represent the actual values in a calculation. The accuracy of such calculations is of course limited by the accuracy with which we can measure the physical quantities involved. Usually the computing reference voltage is ± 10 V, and voltmeters, oscilloscopes and X -Y plotters are used to measure and record the values of the variables, generally to within an accuracy of 0.1-1 %. The solution to a mathematical or systems problem is obtained by setting up an analogue of the mathematical equations (or by simulating its transfer functions) using operational amplifier circuits functioning as adders, sign changers, integrators, and so on [1]. Thus each integra tion or addition, etc., in an equation is performed simultaneously by separate operational amplifiers working in parallel. Consequently the answer is in a continuous form; that is, the analogue computer produces a gene~al solution to an equation which is normally displayed as a graph