Tuesday, May 6, 2014

All about Computer Architecture

Ever since my undergraduate days, I perceived the need for a new book in computer architecture.Ultimately, I have had the privelege with my publisher, McGrawHill India, of writing it. The reason that I felt that there is a requirement for a new book  is as follows. In the late nineties, the field of computer architecture was very rapidly growing, and textbooks in computer architecture were finding it hard to strike a balance between timeless concepts and recent advances.  We need to understand that recent advances in a field are often controversial and ephemeral. There is typically no broad based consensus between designers and researchers regarding the right way to proceed. Consequently, books that focus more on fundamentals are better suited for early undergraduate education. Secondly, I also found a lot of divergence between books in computer architecture, and books in more mature disciplines such as electrical and mechanical engineering. The latter fields were established since the 50s, and their textbooks reflected this maturity. They derived all the results from first principles, and even design oriented chapters were properly motivated from a theoretical perspective. In comparison, my early interaction with the field of computer architecture did not answer the question, "why is this designed this way?''.

The second important motivation for writing this book, is that most computer architecture books were exclusively targetted to the American undergraduate education system because they were written by American authors. Undergraduate education systems in countries such as India, China, and South Korea are comparatively very different. The background of students, the pedagogical methods, and even the aspirations of students are very different. To put it simply, the education system in these countries is slightly more "strict." Hence, I wanted to design a book that is suitable for all educational systems. It has "strict" parts as well as "liberal" parts. Large parts of a good book should read like a story, and there should be the right amount of rigour at the right places. It has been my constant endeavour to ensure these dual goals.

As an example, let us consider the first chapter. The first chapter answers the question, "what is the difference between a calculator and a computer?'' Both of them can perform mathematical computations. However, there is a basic difference, and it is that we can program a computer to do fairly sophisticated tasks such as predicting the weather after 10 days in Moscow. A calculator cannot do that. What is it that is so fundamentally different in a computer? It turns out that a computer has a little bit of extra circuitry that makes it radically different from a calculator. It is important for readers to understand and appreciate this fact. Secondly, what is this extra circuitry that makes such a big difference? We take recourse to results in theoretical computer science to explain to readers that a computer is fundamentally different from most other devices that can process numbers such as a calculator and an abacus.

The first part deals with the design of the software interface of a processor. A processor needs to be essentially programmed with a sequence of bits. A bit is an electrical signal that can take have two values -- on (1), and off(0). We shall show that it is possible to design an exquisite variety of software by just using a sequence of bits. We start with simple abstractions in Chapter 2. We first try to design a method to represent positive and negative integers using a sequence of bits. Here again, the approach of this book is very different. The book provides a thorough theoretical justification of the design of number systems, their limitations and their properties. This is the "rigour'' aspect of the book. We subsequently, proceed to design representations for floating-point (numbers with a decimal point) numbers, and pieces of text.

The question that arises now is how do we use this information to design an instruction set for a processor. To give the reader a flavor of designing a full computer from scratch, we proceed to design our own custom instruction set called SimpleRisc in Chapter 3. It is very important for the reader to understand that to become a good computer architect, it is necessary to build and design computers. Just reading and appreciating theoretical concepts is not enough. To motivate readers to tread this path, this book devotes 5 chapters to designing a computer for the SimpleRisc instruction set. We discuss different design styles. At this stage, the reader is expected to create her own designs for computers that are compatible with the SimpleRisc instructions. To aid the reader in this process, we provide reference designs with both the Logisim simulator and VHDL in the companion website of the book. In fact, we would further like to challenge the reader to design a more expressive instruction set and extend the reference design of the processor to create more efficient designs.

Another important distinguishing feature of this book will be the emphasis on modern technologies such as multicore processors and I/O systems. We need not go very far. Let us take a look at our cell phones. Most smart phones these days have multiple processors (cores), and have a lot of peripherals such as cameras, sound cards, graphics cards, USB ports, NFC communication devices, and accelerometers. Interfacing with these components is a very important aspect of modern processor design. Most jobs in the field of computer architecture are now in the field of system design, where the job of the designer is to integrate a variety of components including a variety of processors in the same chip. The main challenge is to design efficient mechanisms to transport data between different units in a chip, and talk to third party components. Chapters 10, 11, and 12 look at the design of advanced memory systems, multiprocessor (multicomponent) systems, and I/O systems respectively.

Let me again go back to discussing the big picture. The main idea of this book is two fold: a deep theoretical perspective, and a very immersive practical experience. Both are required in equal measure to make a computer architect. We try to provide both in this book. The theorems, lemmas, proofs, and intuitions provide the theoretical perspective; whereas, the chapters devoted to designing a full computer from scratch provide the practical perspective.

There are several other important aspects of this book also. We have cleanly separated fundamental concepts, assembly languages based on open or proprietary standards, and state of the art processor designs in this book. Each chapter has only one theme. We have not mixed issues in any chapter. For example, the design of state of the art processors by Intel, ARM, AMD, and NVIDIA is confined to Appendices A and B. Later on, when the designs change or become obsolete, we can add more appendices. Secondly, we have separated the discussion on assembly languages into three chapters. The first chapter looks at the theory of assembly languages, and Chapters 4 and 5 discuss vendor specific assembly languages. This separation of topics was greatly appreciated by both reviewers  and students alike.

Another important differentiating aspect is the design of problems at the back of the chapters. In my student days, something that struck me was the astonishing simplicity and banality of problems in computer architecture courses. Most of the problems involved evaluating the results of formulae presented in the book  with a varying set of constants. There were hardly any profound insights to be gathered. In comparison, problems in textbooks in other areas took a long time to solve. I remember thinking about solutions to problems in my formal languages and automata theory course for days at a stretch. It has been our sincere effort to bring a similar culture to a computer architecture textbook. The star marked problems at the back of the chapters are genuinely difficult and will prove to be thoroughly engaging. They might even take days to solve!!!

To summarise, the basic aim of writing this book is to give the computer architecture community something new. Secondly, there has been an implicit desire on the part of myself to bring this book at par with books in other disciplines. While reading this book, the reader should be convinced that results in computer architecture are very deep, are theoretically justified, and there are a variety of engineering choices to make.