How does a lump of silicon follow instructions?
In Representing data you saw that everything a computer handles is bits. But bits just sit there. Something has to add them, compare them, store them, and decide, billions of times a second, what to do next. That something is built from a single kind of part, a switch that one electrical signal turns on or off, repeated billions of times on a chip the size of a fingernail.
The gap between "a switch" and "a machine that runs your Python program" is bridged by a tower of abstractions, each built only from the one below:
- Transistors act as switches.
- A few transistors make a logic gate, which computes a Boolean function such as AND.
- Gates make combinational circuits: adders, multiplexers, an arithmetic logic unit.
- Gates with feedback make memory: latches, flip-flops, registers.
- Registers, an ALU and a clock make a processor that fetches, decodes and executes instructions.
- The processor's instruction set is the contract that compilers and operating systems are written against.
In this lesson you will climb that tower in Python, simulating each layer with the one below it, and finish with a working processor for a tiny instruction set of our own design. Nothing here is how a modern chip is engineered in detail; all of it is how one works in principle.
Boolean algebra and gates
Definition— Boolean function, gate
A Boolean function takes some inputs, each 0 or 1, and produces an output 0 or 1. It is fully described by its truth table, which lists the output for every combination of inputs (there are rows for inputs). A logic gate is a circuit that computes a small Boolean function: NOT (), AND (), OR (), XOR (1 when exactly one input is 1), NAND (NOT of AND) and NOR (NOT of OR).
Boolean algebra has laws much like ordinary algebra, and circuit designers use them to simplify circuits. The ones you will use most:
| Law | Statement |
|---|---|
| Identity and annihilation | , , , |
| Complement | , , |
| Distributive (both ways) | and |
| De Morgan | and |
These are the laws of propositional logic in different clothes; Lumenary Math's Propositional logic and truth tables proves them.
Theorem— NAND is universal
Every Boolean function, of any number of inputs, can be computed by a circuit made only of NAND gates.
Proof
First, every Boolean function can be built from AND, OR and NOT: for each row of the truth table where the output is 1, form the AND of the inputs (each negated if it is 0 in that row), which is 1 on exactly that row; then OR these terms together. This sum of products is 1 exactly on the rows where the function is 1. (If no row is 1, use .) Second, NOT, AND and OR can each be built from NAND: ; ; and by De Morgan, . Replacing each gate of the sum of products by its NAND version gives a NAND-only circuit.
∎
NOR is universal too. This matters physically: chip makers can perfect one small cell and tile it. In CMOS technology, the basis of essentially every modern chip, a NAND gate needs four transistors, two in series that pull the output low only when both inputs are high, and two in parallel that pull it high otherwise.
Circuits that compute: adders, multiplexers, an ALU
A combinational circuit is a network of gates without loops: its outputs depend only on its current inputs.
Adding two bits gives a sum bit and a carry: the sum is (XOR) and the carry is . That pair is a half adder. To add multi-bit numbers, each column must also accept the carry from the column to its right, which needs a full adder with three inputs: and . Chain full adders, each passing its carry left, and you have an -bit ripple-carry adder, the column addition you learned at school, in hardware.
A multiplexer (mux) is a switch made of gates: outputs when the select input is 0 and when it is 1, namely . Muxes are how a circuit chooses, and an arithmetic logic unit (ALU) is little more than several operations computed side by side, with muxes selecting the one the instruction asked for.
import random
nand_count = 0
def NAND(a, b):
global nand_count
nand_count += 1
return 1 - (a & b)
# Every other gate, built from NAND alone.
def NOT(a): return NAND(a, a)
def AND(a, b): return NOT(NAND(a, b))
def OR(a, b): return NAND(NOT(a), NOT(b)) # De Morgan
def XOR(a, b):
n = NAND(a, b)
return NAND(NAND(a, n), NAND(b, n))
def MUX(a, b, sel):
"""Output a when sel is 0 and b when sel is 1."""
return OR(AND(a, NOT(sel)), AND(b, sel))
def full_adder(a, b, carry_in):
s1 = XOR(a, b)
total = XOR(s1, carry_in)
carry_out = OR(AND(a, b), AND(s1, carry_in))
return total, carry_out
def add(x_bits, y_bits, carry=0):
"""Ripple-carry adder over lists of bits, least significant bit first."""
out = []
for a, b in zip(x_bits, y_bits):
s, carry = full_adder(a, b, carry)
out.append(s)
return out, carry
def bits(n, width): return [(n >> i) & 1 for i in range(width)]
def value(bs): return sum(b << i for i, b in enumerate(bs))
print("a b | AND OR XOR | MUX(a, b, sel=1)")
for a in (0, 1):
for b in (0, 1):
print(f"{a} {b} | {AND(a, b)} {OR(a, b)} {XOR(a, b)} | {MUX(a, b, 1)}")
# Check the 4-bit adder on every input, and the 8-bit adder on a random sample.
for x in range(16):
for y in range(16):
s, c = add(bits(x, 4), bits(y, 4))
assert value(s) + (c << 4) == x + y
rng = random.Random(0)
for _ in range(1000):
x, y = rng.randrange(256), rng.randrange(256)
s, c = add(bits(x, 8), bits(y, 8))
assert value(s) == (x + y) % 256 and c == (x + y >= 256)
print("adders agree with Python's + on every test")
nand_count = 0
s, c = add(bits(100, 8), bits(55, 8))
print(f"100 + 55 = {value(s)} (carry {c}), computed by {nand_count} NAND gates")
def alu(op, x, y, width=8):
"""A tiny ALU. Two select bits: op 0 = add, 1 = subtract, 2 = AND, 3 = OR."""
s0, s1 = op & 1, op >> 1
xb, yb = bits(x, width), bits(y, width)
y_in = [MUX(b, NOT(b), s0) for b in yb] # subtract: invert y ...
summed, _ = add(xb, y_in, carry=s0) # ... and add 1, so x + (~y + 1) = x - y
logic = [MUX(AND(a, b), OR(a, b), s0) for a, b in zip(xb, yb)]
return value([MUX(p, q, s1) for p, q in zip(summed, logic)])
print("ALU:", alu(0, 100, 55), alu(1, 100, 55), alu(1, 55, 100), bin(alu(2, 0b1100, 0b1010)), bin(alu(3, 0b1100, 0b1010)))Notice how the ALU subtracts: it does not have a subtractor. It inverts and feeds a carry of 1 into the adder, computing in two's complement, exactly the identity from the previous lesson. So comes out as the pattern 211, which is read as a signed byte.
Speed is set by the longest path. Each gate takes a few picoseconds to settle. In a ripple-carry adder the carry may have to travel through every column (think of ), so an -bit addition takes time proportional to . Real adders use carry-lookahead designs that compute, for groups of bits, whether a group will generate or propagate a carry, cutting the delay to gate levels at the cost of more gates. Trading circuit area for speed in this way is the daily work of hardware design.
Memory and the clock
A combinational circuit forgets: change its inputs and its old output is gone. To remember, a circuit needs feedback, outputs wired back into its own inputs.
Two NOR gates, each feeding its output into the other, form an SR latch. Pulse the S (set) input and the output Q becomes 1; pulse R (reset) and Q becomes 0; with both inputs at 0, the loop holds whichever value it last had. That holding is memory, made of nothing but gates.
Latches respond whenever their inputs change, which makes large circuits hard to reason about. So designers use edge-triggered D flip-flops: a flip-flop copies its data input D to its output Q only at the instant the clock signal rises from 0 to 1, and ignores D the rest of the time. A register is flip-flops sharing one clock, storing an -bit word.
The clock is a signal that ticks at a fixed rate, 3 GHz meaning three billion rising edges per second, one every third of a nanosecond (light travels only about 10 cm in that time). Between edges, combinational logic computes new values from the registers' current outputs; at the edge, the registers capture those values all at once. This synchronous discipline is what makes a billion-transistor chip predictable: everything changes in lock step. It also sets the speed limit. The clock period must be longer than the slowest path through the logic between two registers, the critical path, so faster adders and shorter paths mean higher clock rates.
def NOR(a, b):
return 1 - (a | b)
def sr_latch(s, r, q):
"""Two cross-coupled NOR gates. Feed the outputs back in until they stop changing."""
q_bar = NOR(s, q)
while True:
new_q = NOR(r, q_bar)
new_q_bar = NOR(s, new_q)
if (new_q, new_q_bar) == (q, q_bar):
return q
q, q_bar = new_q, new_q_bar
q = 0
for s, r, what in [(1, 0, "set"), (0, 0, "hold"), (0, 0, "hold"), (0, 1, "reset"), (0, 0, "hold")]:
q = sr_latch(s, r, q)
print(f"S={s} R={r} ({what:5}) -> Q={q}")
class Register:
"""n D flip-flops sharing a clock: the output changes only at a rising clock edge."""
def __init__(self, width):
self.width, self.q = width, 0
def tick(self, d):
self.q = d & ((1 << self.width) - 1)
# A 4-bit counter: a register whose input is its own output plus one.
counter = Register(4)
seen = []
for cycle in range(20):
seen.append(counter.q)
counter.tick(counter.q + 1) # the adder computes during the cycle; the edge stores the sum
print("counter:", seen)The counter is the simplest state machine: a register holding the state, combinational logic computing the next state from it, and a clock deciding when to move. A processor is the same pattern on a larger scale.
A processor: fetch, decode, execute
A stored-program computer, the design John von Neumann described in 1945, keeps its instructions in the same memory as its data, as numbers. Its core parts:
- the program counter (PC), a register holding the address of the next instruction;
- the register file, a few fast registers that instructions operate on;
- the ALU, which does the arithmetic and logic;
- the control unit, which decodes each instruction into the select signals for all the muxes.
It runs one loop, forever: fetch the instruction word at the address in the PC and advance the PC; decode the word into its fields (which operation, which registers, which constant); execute it, which may compute in the ALU, read or write memory, or overwrite the PC to jump.
The T16 instruction set
To make this concrete we invent an instruction set architecture (ISA), the list of instructions a processor understands and how each is encoded as bits. T16 has four 8-bit registers r0–r3, a memory of 256 words, one zero flag, and 16-bit instruction words with four fields:
| Bits 15–12 | Bits 11–10 | Bits 9–8 | Bits 7–0 |
|---|---|---|---|
| opcode | rd (destination register) | rs (source register) | imm (an 8-bit constant or address) |
| Opcode | Instruction | Meaning |
|---|---|---|
| 0 | HALT | stop |
| 1 | LOADI rd, imm | rd ← imm |
| 2 | ADD rd, rs | rd ← rd + rs (mod 256); set the zero flag |
| 3 | SUB rd, rs | rd ← rd − rs (mod 256); set the zero flag |
| 4 | ADDI rd, imm | rd ← rd + imm (mod 256); set the zero flag |
| 5 | LOAD rd, imm | rd ← memory[imm] |
| 6 | STORE rd, imm | memory[imm] ← rd |
| 7 | JMP imm | PC ← imm |
| 8, 9 | JZ imm, JNZ imm | jump if the zero flag is set (JZ) or clear (JNZ) |
| 10 | OUT rd | output the value of rd |
Example— Encoding ADDI r2, -1
The opcode of ADDI is 4 (0100), rd is 2 (10), rs is unused (00), and the constant is stored as its 8-bit two's complement pattern 1111 1111. Concatenated: 0100 10 00 1111 1111 = 0x48FF. When the processor adds 255 to an 8-bit register, modulo 256, it has subtracted 1: there is no subtraction-by-constant instruction because there does not need to be.
The simulator below has two parts. The assembler translates human-readable assembly into instruction words, resolving labels such as loop to addresses (that is the whole job of an assembler). The CPU class is the fetch–decode–execute loop, with decoding done by exactly the shifts and masks of Representing data.
# T16: a made-up 16-bit instruction set. word = opcode(4) | rd(2) | rs(2) | imm(8)
OPS = ["HALT", "LOADI", "ADD", "SUB", "ADDI", "LOAD", "STORE", "JMP", "JZ", "JNZ", "OUT"]
def assemble(source):
"""Two passes: first find the address of every label, then encode each instruction."""
lines = [l.split(";")[0].strip() for l in source.splitlines()]
labels, program = {}, []
for l in lines:
if l.endswith(":"):
labels[l[:-1]] = len(program)
elif l:
program.append(l)
words = []
for l in program:
op, *args = l.replace(",", " ").split()
rd = rs = imm = 0
regs = [int(a[1]) for a in args if a.startswith("r")]
others = [a for a in args if not a.startswith("r")]
if regs:
rd = regs[0]
if len(regs) > 1:
rs = regs[1]
if others:
imm = labels[others[0]] if others[0] in labels else int(others[0], 0)
words.append(OPS.index(op) << 12 | rd << 10 | rs << 8 | (imm & 0xFF))
return words
class CPU:
def __init__(self, program):
self.mem = program + [0] * (256 - len(program)) # one memory for code and data
self.reg = [0, 0, 0, 0] # four 8-bit registers r0..r3
self.pc, self.zero, self.halted, self.output = 0, False, False, []
def step(self):
word = self.mem[self.pc] # FETCH the instruction at pc
self.pc = (self.pc + 1) % 256
op, rd = word >> 12, (word >> 10) & 3 # DECODE its fields
rs, imm = (word >> 8) & 3, word & 0xFF
name, r = OPS[op], self.reg # EXECUTE
if name == "HALT": self.halted = True
elif name == "LOADI": r[rd] = imm
elif name == "ADD": r[rd] = (r[rd] + r[rs]) & 0xFF
elif name == "SUB": r[rd] = (r[rd] - r[rs]) & 0xFF
elif name == "ADDI": r[rd] = (r[rd] + imm) & 0xFF
elif name == "LOAD": r[rd] = self.mem[imm] & 0xFF
elif name == "STORE": self.mem[imm] = r[rd]
elif name == "JMP": self.pc = imm
elif name == "JZ" and self.zero: self.pc = imm
elif name == "JNZ" and not self.zero: self.pc = imm
elif name == "OUT": self.output.append(r[rd])
if name in ("ADD", "SUB", "ADDI"):
self.zero = r[rd] == 0 # the flag that conditional jumps test
return word, name
fibonacci = """
LOADI r0, 0 ; a = 0
LOADI r1, 1 ; b = 1
LOADI r2, 13 ; how many numbers to print
loop:
OUT r0
LOADI r3, 0
ADD r3, r0
ADD r3, r1 ; r3 = a + b
LOADI r0, 0
ADD r0, r1 ; a = b
LOADI r1, 0
ADD r1, r3 ; b = a + b
ADDI r2, -1 ; -1 is stored as 0xFF: adding 255 mod 256 subtracts 1
JNZ loop
HALT
"""
program = assemble(fibonacci)
print("machine code:", " ".join(f"{w:04X}" for w in program))
cpu = CPU(program)
cycles = 0
while not cpu.halted:
pc = cpu.pc
word, name = cpu.step()
cycles += 1
if cycles <= 6:
print(f"cycle {cycles}: pc={pc:2} fetched {word:04X} = {word:016b} {name:5} registers {cpu.reg}")
print("output:", cpu.output)
print("instructions executed:", cycles)Read the machine code: 48FF is the ADDI r2, -1 we encoded by hand, and 9003 is JNZ loop, opcode 9 with the address 3 where the label loop landed. The program is fourteen numbers in memory, indistinguishable from data until the PC points at them. That is the stored-program idea, and also why a bug that writes over code can be so destructive.
T16 lacks a lot: no MOV (we copy by clearing a register and adding), no call stack, no interrupts, no way to address more than 256 words. Real ISAs add all of these, but every one of them still runs this loop.
Real instruction set architectures
An ISA is a contract. Above it, compilers, operating systems and programs can be written once and run on every processor that implements it; below it, hardware designers are free to build those processors however they like, small and frugal or huge and fast. The same ISA has been implemented by chips that differ in speed by a factor of a thousand. Three ISAs dominate in 2026.
x86-64. The descendant of Intel's 8086 of 1978, extended to 64 bits by AMD (specified in 2000, first shipped in 2003), and the ISA of most laptops, desktops and cloud servers. It is the classic CISC (complex instruction set computer) design: instructions vary from 1 to 15 bytes in length, many can operate directly on memory, and backward compatibility reaches back decades. Internally, modern x86 processors translate these instructions into simpler micro-operations and execute those, so the complexity lives in the front end. Intel and AMD publish the full specification in their architecture manuals.
Arm (AArch64). The ISA of essentially every smartphone, of Apple's M-series Macs, and of a growing share of servers (such as Amazon's Graviton). It follows the RISC (reduced instruction set computer) philosophy that Patterson, Hennessy and others argued for in the early 1980s: fixed-length 32-bit instructions, a large set of registers, and memory accessed only by explicit load and store instructions, which makes decoding and pipelining simpler. Arm Holdings licenses the ISA and designs to chip makers.
RISC-V. An open-standard RISC ISA started at the University of California, Berkeley, in 2010 and now governed by RISC-V International. Anyone may implement it without a licence fee, and its specifications are free to read. It is modular: a small base integer ISA (RV32I or RV64I, a few dozen instructions) plus optional extensions such as M (multiply and divide), A (atomic operations), F and D (floating point), C (compressed 16-bit instructions) and V (vectors). It is widely used in microcontrollers and embedded cores and increasingly in larger processors, and it is the easiest real ISA to learn from.
Here is the same statement, total = total + price[i], as a compiler might emit it for each, with total in a register and the address of price[i] already computed:
x86-64: add rax, qword ptr [rdi] ; one instruction: load from memory and add
AArch64: ldr x1, [x0] ; load ...
add x2, x2, x1 ; ... then add, register to register
RISC-V: ld t1, 0(a0) ; load ...
add t2, t2, t1 ; ... then addThe x86 version is shorter in instructions; the RISC versions are simpler per instruction. Decades of argument have ended mostly in convergence: CISC chips execute RISC-like micro-operations inside, and RISC ISAs have grown rich extensions. What matters most for speed today is the microarchitecture under the ISA, which the next section begins to open.
Pipelining: overlapping instructions
Executing an instruction involves distinct steps, and in a simple processor each step's hardware sits idle while the others work. A classic division has five stages: IF (instruction fetch), ID (decode and read registers), EX (execute in the ALU), MEM (access memory, for loads and stores) and WB (write the result back to a register). Pipelining starts the next instruction's IF while the current one is in ID, and so on, so that up to five instructions are in flight at once.
Analogy, not a formal construction
Picture a cafeteria line with five servers, each adding one dish to a tray. A tray still takes five steps to complete, but once the line is full a finished tray comes out at every step instead of every five. The line is only as fast as its slowest server, and if one diner must wait for a dish that the previous diner's server is still cooking, everyone behind waits too.
Pipelining improves throughput (instructions completed per cycle, ideally one) but not latency (each instruction still takes five cycles from start to finish). With stages and instructions and nothing going wrong, a pipeline takes cycles instead of . Shorter stages also allow a faster clock. Things do go wrong, in three ways called hazards:
- Data hazards: an instruction needs a result that an earlier instruction has not yet written back. The fix is forwarding (or bypassing): extra wires carry a result from the end of EX straight to the next instruction's EX. A value loaded from memory is not ready until after MEM, so an instruction that uses it immediately must still wait one cycle (a load-use stall).
- Control hazards: after a branch, which instruction comes next? The pipeline cannot know until the branch executes, so processors predict the outcome and fetch along the predicted path, throwing that work away if the guess was wrong. Modern predictors are right well over 95% of the time on typical code.
- Structural hazards: two instructions need the same hardware in the same cycle, such as one memory port for both fetching and loading. Separate instruction and data caches are the usual fix.
STAGES = ["IF", "ID", "EX", "MEM", "WB"]
# (text, register written, registers read, is it a load from memory?)
code = [
("LOAD r1, [x]", "r1", [], True),
("ADD r2, r1", "r2", ["r1", "r2"], False),
("ADDI r3, 4", "r3", ["r3"], False),
("SUB r3, r2", "r3", ["r3", "r2"], False),
("STORE r3, [y]", None, ["r3"], False),
]
def schedule(code, forwarding):
"""Cycle in which each instruction enters each stage, for an in-order 5-stage pipeline."""
timing, written_by = [], {}
for i, (text, dest, srcs, is_load) in enumerate(code):
start = timing[-1]["ID"] if timing else 0 # fetch right after the previous one
ex = start + 2
for r in srcs:
if r in written_by:
p = timing[written_by[r]]
if forwarding: # result is passed straight from the end of EX (or of MEM for a load)
ex = max(ex, (p["MEM"] if code[written_by[r]][3] else p["EX"]) + 1)
else: # must wait until the producer has written the register file
ex = max(ex, p["WB"] + 1)
if timing:
ex = max(ex, timing[-1]["EX"] + 1) # stages are used in order, one at a time
timing.append({"IF": start, "ID": ex - 1, "EX": ex, "MEM": ex + 1, "WB": ex + 2})
if dest:
written_by[dest] = i
return timing
for forwarding in (False, True):
t = schedule(code, forwarding)
total = t[-1]["WB"] + 1
print(f"\n{'with' if forwarding else 'without'} forwarding: {total} cycles")
print(" " * 15 + "".join(f"{c + 1:>4}" for c in range(total)))
for (text, *_), row in zip(code, t):
cells = [" ."] * total
for s in STAGES:
cells[row[s]] = f"{s:>4}"
for c in range(row["IF"] + 1, row["ID"]):
cells[c] = " -" # a stall ("bubble")
print(f"{text:15}" + "".join(cells))
print(f"\nno pipeline at all: {len(code) * len(STAGES)} cycles")Without forwarding, each dependent instruction waits (the dashes) until its producer has written the register file: 15 cycles. With forwarding only the load-use stall remains, and five instructions finish in 10 cycles, against 25 without pipelining. (This model assumes the register file is written in the first half of a cycle and read in the second, the usual textbook convention.)
Real processors go much further. They are superscalar, fetching and executing several instructions per cycle; out of order, letting later independent instructions run while an earlier one waits for memory; and speculative, running far ahead down predicted paths. That speculation turned out to leak secrets through the timing of caches, the Spectre and Meltdown attacks disclosed in 2018 (more in Security). And since the mid-2000s, when clock rates stopped rising because of power and heat, chips have added more cores instead of faster ones, which is why Concurrency matters. Most of all, a fast processor is useless if it waits for data, the subject of The memory hierarchy.
Common misconceptions
Misconception
"A higher clock rate always means a faster processor." Speed is instructions per cycle times cycles per second (and how many instructions the program needs). A 3 GHz core that completes four instructions per cycle beats a 4 GHz core that completes one, and either may spend most of its time waiting for memory.
Misconception
"The CPU runs my Python code." It runs machine code. Your Python is compiled to bytecode, which a program called the interpreter, itself compiled to machine code, executes. Compilers and interpreters covers that layer.
Misconception
"A pipeline makes each instruction faster." Each instruction takes as long as before, or slightly longer. The pipeline finishes more instructions per unit time by overlapping them.
Misconception
"Assembly language is the hardware." Assembly is a readable spelling of machine code for one ISA; the ISA is itself an abstraction that the microarchitecture implements in its own way, with micro-operations, renamed registers and predictions the programmer never sees.
A short history
George Boole published his algebra of logic in 1854, as a study of the laws of thought, with no machines in mind. In his 1937 master's thesis Claude Shannon showed that relay circuits obey Boole's algebra, so that circuits could be designed by calculation. In 1945 von Neumann's report on the EDVAC described a computer that stored its program in memory, the organisation almost every computer still follows. The transistor, invented at Bell Labs in 1947, replaced relays and vacuum tubes; the integrated circuit (1958–59) put many transistors on one chip; the Intel 4004 of 1971 put a whole processor on one. Since then the number of transistors per chip has grown from a few thousand to tens of billions. In the 1980s, RISC research at Berkeley and Stanford reshaped processor design, and in 2010 Berkeley began RISC-V, an ISA that anyone may implement. If you want to build every layer of this lesson yourself, the free course From Nand to Tetris starts from a NAND gate and ends with a working computer.
Exercises
1. From logic gates to a processor
Warm-upHumanWhich circuit computes (OR) using only NAND gates?
2. From logic gates to a processor
CoreComputationalImplement XOR(a, b) using only the provided NAND function, with exactly four NAND gates per evaluation. Do not use ^, !=, and, or, not or if. (Hint from the lesson's code: the four-gate XOR shares one gate, NAND(a, b), between two others.)
3. From logic gates to a processor
Warm-upHumanA processor's clock runs at 2.5 GHz. How long is one clock cycle, in picoseconds? (1 ps = s.)
4. From logic gates to a processor
CoreHumanTrace this T16 program by hand (instructions as defined in the lesson). What value is in r1 when it halts?
LOADI r0, 5
LOADI r1, 0
loop:
ADD r1, r0
ADDI r0, -1
JNZ loop
HALT
5. From logic gates to a processor
StretchComputationalWrite a T16 program that multiplies. Before it starts, memory address 200 holds and address 201 holds (each 0 to 255). The program must store at address 202 and then halt. T16 has no multiply instruction: add to a running total times. Make sure works. The assembler and CPU from the lesson are included; edit only the PROGRAM string.
6. From logic gates to a processor
CoreHumanA 5-stage pipeline executes 100 instructions with no hazards or stalls, one stage per clock cycle. How many cycles pass from the first instruction's fetch to the last instruction's write-back, inclusive?
7. From logic gates to a processor
CoreHumanWhich statements about instruction set architectures are true? Select all that apply.
Further reading and resources
- A symbolic analysis of relay and switching circuits · Claude E. Shannon · 1938The master's thesis that connected Boolean algebra to circuits.
- The case for the reduced instruction set computer · David A. Patterson and David R. Ditzel · 1980
- RISC-V specifications · RISC-V InternationalThe open instruction set's ratified specifications, free to read and implement.
- RISC-V International
- From Nand to Tetris · Noam Nisan and Shimon SchockenA free course that builds a whole computer, from NAND gates up to an operating system.