Preface¶
An instruction set tells you what a processor does. Microarchitecture decides how fast, how cheaply and how safely it does it. This book is about that second layer: the pipelines, schedulers, caches, buses and peripheral interfaces that sit between the instruction set and the silicon, and the real open-source cores in which all of them can be read, simulated and measured.
Who this book is for¶
The book is written for students of computer architecture and hardware design who already know what a processor does at the level of the instruction set. You should be comfortable with binary numbers, with the idea of a register and a memory address, and with reading a few lines of assembly language. The examples use RISC-V because its specification is open and because several complete, readable implementations exist; nothing in the argument depends on that choice, and the ideas carry over unchanged to x86-64 and Arm.
You do not need to have designed a circuit. Where a chapter touches on hardware description languages, the text says what is needed and no more. A reader who has met Verilog or VHDL will get more from the last two chapters, in which real cores are generated and simulated, but the earlier chapters can be read without it.
What the book covers¶
The book follows the path a designer takes when asked to make a processor fast and then to put it on a chip with everything else it needs.
| Part | Chapters | The question it answers |
|---|---|---|
| I. The processor core | 1 to 3 | How is performance measured, and how do pipelining and out-of-order execution raise it? |
| II. Memory | 4 and 5 | How do caches hide the distance to DRAM, and how do many cores share one memory? |
| III. Connecting the chip | 6 and 7 | How do the blocks of a chip talk to each other, and how does the chip talk to the outside world? |
| IV. Real cores and measurement | 8 and 9 | What do real cores look like inside, and how do you compare them honestly? |
| V. Security and practice | 10 and 11 | How can the tricks that make a chip fast leak secrets, and how do you run and measure real cores yourself? |
Chapter 1 sets out the vocabulary and the equation that governs everything else, the Iron Law of processor performance. Chapters 2 and 3 take the processor core from a five-stage pipeline to an out-of-order superscalar machine. Chapters 4 and 5 turn to memory: caches, virtual memory, coherence and consistency. Chapters 6 and 7 are about the wires between blocks, first on the chip (buses, AXI, TileLink, networks-on-chip) and then at its pins (GPIO, UART, SPI and I²C). Chapter 8 shows how these ideas appear in real open cores, from SERV to BOOM. Chapter 9 explains how performance is measured and how the numbers are bent. Chapter 10 treats hardware side channels from a defensive point of view. Chapter 11 turns to the free tools with which you can see and measure everything the earlier chapters describe, and collects a set of measured exercises and a design study.
How the chapters are built¶
Each chapter opens with a short statement of what it covers and why it matters. The body is divided into numbered sections. Definitions and cautions appear in boxes; worked examples are set out step by step in boxes headed "Example". Every chapter ends with a summary of its key points and a set of exercises. The answer to each exercise is folded away beneath it. Work the exercise on paper first, then open the answer.
Several of the exercises have a second life. In the platform from which this book grew, they were small simulators: a pipeline with a switch for forwarding, a branch predictor, a cache, a handshake stepper, a bus-protocol animator. A book cannot move, so each of these has become a worked example with every cycle written out, and a matching exercise in which you repeat the trace on different numbers. If you have a pencil, you have the simulator.
How to use it¶
For a one-semester course on microarchitecture, Chapters 1 to 7 form the core and Chapters 8 and 9 round it off. Chapter 10 can stand alone for a seminar on hardware security; it assumes only the caches of Chapter 4 and the speculation of Chapter 3. Chapter 11 is for the laboratory: its first two labs need only a laptop and take an afternoon.
Three habits will help more than any amount of rereading.
- Predict before you measure. In each lab and each exercise that involves a simulator, write down what you expect first. A measurement teaches you something only when it can surprise you.
- Keep the Iron Law in view. Almost every design decision in the book moves one of three numbers (instruction count, cycles per instruction, clock period), and many decisions help one while hurting another.
- Ask what it costs. Each technique in the book buys speed with something: area, power, complexity, or, as Chapter 10 shows, secrecy. A technique whose cost you cannot name is one you have not yet understood.
A note on facts and figures¶
Numbers in the worked examples are either given in the text with their arithmetic or computed from numbers given in the text. Figures quoted for real products, such as typical cache sizes and latencies, accuracy ranges for branch predictors, typical CoreMark per MHz values and the speed of the buses, are orders of magnitude for orientation, not data-sheet values; exact figures depend on the product, the compiler and the configuration. Names of tools and cores are those in use at the time of writing, and command-line options of the simulators change between releases, so check the current documentation of each tool before relying on a command. The sections on security are conceptual and defence-oriented; they describe mechanisms and mitigations and contain no working exploit code.