About

Exam Practice

Cheat sheet, flashcards and quiz covering Lectures 1–7: computer evolution & the von Neumann model, number representation & arithmetic, floating point, character & recording codes, CRC & Hamming codes, Boolean algebra, K-maps, combinational & sequential circuits, and the MARIE processor, assembly language & control unit.

Reference text: The Essentials of Computer Organization and Architecture, Linda Null & Julia Lobur

Need step-by-step recipes and blank templates? Open the Problem-Solving Guide →

1.1 Organization vs. Architecture & Components

Computer organizationComputer architecture
CoversAll the physical aspects of the systemThe logical aspects as seen by the programmer
ExamplesCircuit design, control signals, memory types (SRAM, DRAM, DDR3/DDR4), bus design, clock rate, how a multiplier is builtInstruction set, instruction formats, data types, addressing modes, number of programmer-visible registers, whether a multiply instruction exists
Question answeredHow does each component work and how are components connected?What can the machine do: how components work together to run programs
Quick testProgram runs the same; only speed/cost/physical build changesA programmer must know it to write a correct program
Lecture example: macOSApple M1 chip, Thunderbolt ports, Retina displayUnix-based system, APFS, iCloud/Apple services (App Store)
Lecture example: WindowsIntel or AMD processors, various motherboards, USB peripheralsWindows NT-based system, NTFS, OneDrive, Office 365
Three basic components1. Processor (CPU): interprets and executes programs
2. Memory: stores both data and programs
3. I/O system + buses: transfers data between components and external devices
Same architecture, different organization: every x86-64 chip from Intel and AMD runs the same programs

1.1 Units, Prefixes & Spec-Sheet Reading

Powers of 2 (memory size)K = 2102^{10} = 1,024; M = 2202^{20} = 1,048,576; G = 2302^{30} = 1,073,741,824; T = 2402^{40}; P = 2502^{50}. Used for RAM and cache.
Powers of 10 (speed, data rate, disk)K = 10310^3, M = 10610^6, G = 10910^9, T = 101210^{12}. Used for Hz, bits/s, and advertised disk/SSD capacity.
Small units (time)milli m = 10−310^{-3} (disk, display ms); micro µ = 10−610^{-6}; nano n = 10−910^{-9} (CPU cycles, RAM); pico p = 10−1210^{-12} (gate delays).
Frequency ↔ periodT=1/fT = 1/f. 1 MHz → 1 µs; 1 GHz → 1 ns; 3.9 GHz → 0.256 ns; 1600 MHz → 0.625 ns.
Byte vs bit1 B = 8 b. Storage uses capital B; network speed uses lowercase b (Mbps). 1000 Mbps = 125×106125 \times 10^6 bytes/s.
"1 TB" shows as 931 GB1012/230≈931.310^{12} / 2^{30} \approx 931.3 GiB. Same bytes, bigger unit. IEC binary prefixes: KiB, MiB, GiB, TiB.
Disk rotationrev/s = RPM / 60; time per rev = 1/(rev/s); average rotational delay = half a revolution. 7200 RPM → 8.33 ms/rev, 4.17 ms average.
Frame buffer sizepixels × (bits per pixel / 8). 1920×1200 at 24-bit = 6,912,000 B ≈ 6.59 MB; 24-bit colour = 2242^{24} = 16,777,216 colours.
Ad vocabularyBus: shared wires for data/address/control. Port: connector for an external device (USB, HDMI). Cache: small fast memory of recently used data (L1 smallest/fastest). Hz: cycles per second. DDR = double data rate (both clock edges); SDRAM = synchronous dynamic RAM.
Classifying ad linesi7 Quad Core 3.9 GHz → processor; DDR3 SDRAM, L1/L2 cache → memory; SATA HDD, USB/PCI/PCIe slots, monitor, video/sound card, Ethernet → I/O.

1.2 Generations of Computers (incl. 5th & 6th)

GenerationSwitching technologyKey machines / facts
0 (1642–1945)Mechanical gears, wheels, leversSchickard's Calculating Clock; Pascal's Pascaline (adding machine); Babbage's Difference Engine and Analytical Engine (mill + store + punched cards, never built; Ada Lovelace); Hollerith's punched-card tabulator (1890 US census → IBM)
1 (1945–1953)Vacuum tubesENIAC (Mauchly & Eckert, 1946): ~17,468 tubes, ~30 tons, ~174 kW, programmed by plugs and wires; UNIVAC I (1951, first US commercial); IBM 650 (1955, first mass-produced). WWII: Turing's Bombe (Enigma), Colossus (Lorenz)
2 (1954–1965)Transistors (Bell Labs 1947, germanium)~10× faster, 1/10 power and space; switches in µs; magnetic core RAM; FORTRAN, COBOL, ALGOL, SNOBOL; IBM 7094, DEC PDP-1, CDC 6600 (first supercomputer, Cray); CS becomes a discipline
3 (1965–1980)Integrated circuits (Kilby, Noyce; silicon)~1 MIPS; online systems (airline reservations), time-sharing; IBM + BUNCH (Burroughs, Univac, NCR, Control Data, Honeywell); IBM System/360 (first family sharing one architecture), PDP-8/PDP-11, Cray-1 (1976); UNIX rewritten in C on PDP-11 (1973)
4 (1980– )VLSI (more than 10,000 components/chip)Microprocessor: Intel 4004 (1971, 4-bit, ~2,300 transistors), 8080, 808x (8088 in 1981 IBM PC) → personal computing; parallel architectures
5 (2000– )ULSI (billions of transistors)Multicore and big.LITTLE CPUs, SoCs (Apple M-series), GPUs, AI accelerators (NPU, TPU), multi-level caches, DDR5/LPDDR, HBM, NVMe SSDs, PCIe/USB-C/Thunderbolt, Wi-Fi 6/7, 4G/5G, IoT, cloud; AI/ML software. Still IC technology, so some say still 4th gen
6 (expected)Beyond silicon and beyond von NeumannQuantum processors (qubits), neuromorphic chips (artificial neurons/synapses, non-von Neumann), in-memory computing (memristors, removes the bottleneck), optical/photonic computing, carbon nanotubes/graphene, 3-D chips and chiplets, DNA storage, brain-computer interfaces, AR/VR, 6G, edge computing. Mostly research prototypes

1.2 Integration Scales, Moore's Law & Rock's Law

Integration scalesSSI 10–100; MSI 100–1,000; LSI 1,000–10,000; VLSI more than 10,000; ULSI more than 1,000,000 components per chip.
Moore's law (1965)Gordon Moore: transistor density in an IC doubles every year. Contemporary version: density of silicon chips doubles every 18 months (Moore revised to 2 years in 1975).
Rock's lawArthur Rock: cost of capital equipment to build semiconductors doubles every 4 years. 1968 plant ≈ USD 12,000; 2012 plants well over USD 5 billion.
Growth formulaN(t)=N0×2t/dN(t) = N_0 \times 2^{t/d}.
1. k=t/dk = t/d doublings (same units).
2. Multiply by 2k2^k.
3. Backwards: k=log⁡2Fk = \log_2 F, t=k×dt = k \times d.
Handy values210=1024≈10002^{10} = 1024 \approx 1000: 10 doublings ≈ ×1000 → 15 years (18-month) or 20 years (2-year). 3 years at 18 months = 2 doublings (×4); 9 years = 6 doublings (×64).
Moore vs. RockFor Moore's law to hold, Rock's law must fail, or vice versa: each density doubling needs costlier fabs, and eventually no one can afford the next plant.
Why Moore's law cannot lastTransistors cannot shrink below a few atoms; heat and quantum effects grow at tiny sizes.
Identifying a generationLook for the switching technology: gears → 0, tubes → 1, transistors/core memory → 2, ICs → 3, single-chip microprocessor (VLSI) → 4, ULSI multicore/AI → 5.

1.3 The von Neumann Model

ENIAC programmingAll programming at the digital logic level: moving plugs and wires, setting switches. A different hardware configuration for every unique problem type.
Stored-program conceptInstructions stored in the same memory as data, as binary numbers. Conceived by Mauchly and Eckert, ascribed to John von Neumann (1945 EDVAC report). Change program = load new numbers, no rewiring.
Von Neumann characteristics1. Three hardware systems: CPU (control unit, ALU, registers, PC), main memory (programs + data), I/O system.
2. Sequential instruction processing.
3. A single data path between CPU and main memory.
Von Neumann bottleneckThe single CPU–memory path: every instruction and operand travels over it one transfer at a time. Max rate = 1 / (transfers per instruction × transfer time). Softened by caches, wider buses, split I/D caches.
Fetch-decode-execute1. Fetch: MAR ← PC, IR ← M[MAR], PC ← PC + 1.
2. Decode: examine opcode; MAR ← IR[11–0].
3. Fetch operand: MBR ← M[MAR].
4. Execute: ALU operates, result to AC or memory. Repeat.
MARIE registersPC = address of next instruction; IR = current instruction; MAR = address sent to memory; MBR = data read/written; AC = accumulator.
Instruction format used16 bits = 4 hex digits: first hex digit = opcode (1 Load, 2 Store, 3 Add, 7 Halt), last three = address. 1104 = Load 104.
Sample traceLoad 104 (0023), Add 105 (FFE9 = −23), Store 106 → 002316+FFE916=1000C16\text{0023}_{16} + \text{FFE9}_{16} = \text{1000C}_{16}, keep 16 bits → M[106] = 000C = 12. PC is incremented during fetch.

1.3 Non-von Neumann Models

ModelDeparture from von NeumannExample / use
HarvardSeparate memories and paths for instructions and data; fetch and data access overlapMicrocontrollers (AVR, PIC), DSPs; modern CPUs are modified Harvard (split L1 I/D caches)
Special-purpose (GPU)Many simple cores in parallel, offloading the CPUGraphics, scientific computing, neural-network training
DataflowNo program counter: an instruction fires when its input data are availableResearch machines; ideas in out-of-order CPUs
QuantumQubits in superpositions of 0 and 1Factoring, molecule simulation
Cellular automataGrid of simple cells updating from neighboursSimulation, theoretical models
Parallel computingMany processors at the same time, not one sequential streamMulticore CPUs, supercomputers, clusters
Machine intelligenceNetworks of artificial neurons instead of explicit instruction sequencesANN, DNN, GPT-style models, neuromorphic chips
Bottleneck exampleVon Neumann: 2 transfers × 10 ns = 20 ns → 50 million instr/sHarvard (two 10 ns buses overlapping): 10 ns → 100 million instr/s

2.1 Bits, Bytes & Units

Bit / Nibble / Byte / Word1 bit; nibble = 4 bits = 1 hex digit; byte = 8 bits = 2 hex digits (smallest addressable unit); word = machine-dependent group of bytes (16, 32, 64 bits).
Address bitslog⁡2(number of addressable units)\log_2(\text{number of addressable units}). 2242^{24} bytes, 32-bit words: byte-addressable 24 bits; word-addressable 224/22=2222^{24}/2^2 = 2^{22} words → 22 bits.
Positional value(dn−1⋯d0.d−1⋯ )b=∑di×bi(d_{n-1}\cdots d_0.d_{-1}\cdots)_b = \sum d_i \times b^{i}, digits 0≤di≤b−10 \le d_i \le b-1.
Digits needednn base-bb digits give bnb^n values (00 to bn−1b^n-1). Digits for NN: ⌊log⁡bN⌋+1\lfloor \log_b N \rfloor + 1; highest power b⌊log⁡bN⌋b^{\lfloor \log_b N \rfloor}. log⁡bN=ln⁡N/ln⁡b\log_b N = \ln N / \ln b.
Any base → decimalMultiply each digit by its weight and add. 102123=81+0+18+3+2=10410212_3 = 81+0+18+3+2 = 104; 101.112=5.75101.11_2 = 5.75.
Decimal integer → base bb1. Divide by bb, record remainder.
2. Repeat on the quotient until 0.
3. Read remainders bottom to top (first remainder = LSD).
(Or subtraction method: subtract largest powers bkb^k.)
Decimal fraction → base bb1. Multiply fraction by bb.
2. Integer part = next digit.
3. Keep fraction, repeat until 0 or enough digits.
4. Read digits top to bottom. 0.8125=0.110120.8125 = 0.1101_2.
Terminating binary fractionsTerminates only if (in lowest terms) the denominator is a power of 2. 0.110=0.00011‾20.1_{10} = 0.0\overline{0011}_2, 0.610=0.1001‾20.6_{10} = 0.\overline{1001}_2 never terminate.
Binary ↔ hex/octal groupingGroup 4 bits (hex) or 3 bits (octal) starting at the radix point: left for the integer, right for the fraction; pad outer groups with 0s. Hex ↔ octal: go through binary.
7A9.C16=0111 1010 1001.11002=011 110 101 001.1102=3651.68=1961.75\text{7A9.C}_{16} = 0111\,1010\,1001.1100_2 = 011\,110\,101\,001.110_2 = 3651.6_8 = 1961.75.

2.1 Grouping: Binary ↔ Hex ↔ Octal

HexBinaryHexBinaryHexBinaryHexBinary
000004010081000C1100
100015010191001D1101
2001060110A1010E1110
3001170111B1011F1111

2.2 Signed Integer Representations

SchemeForm −NRange (n bits)8 bitsZerosArithmetic
Unsigned—00 to 2n−12^n-10 to 255oneplain binary
Signed magnitudesign bit 1 + magnitude−(2n−1−1)-(2^{n-1}-1) to 2n−1−12^{n-1}-1−127 to +127two (+0, −0)worst: compare signs/magnitudes
One's complement(2n−1)−N(2^n-1)-N = flip all bits−(2n−1−1)-(2^{n-1}-1) to 2n−1−12^{n-1}-1−127 to +127two (00…0, 11…1)add + end-around carry
Two's complement2n−N2^n-N = flip + 1−2n−1-2^{n-1} to 2n−1−12^{n-1}-1−128 to +127oneadd, discard carry (best)

2.2 Two's Complement Toolkit

Negate (flip + 1)19=0001 001119 = 0001\,0011 → flip 1110 11001110\,1100 → +1 → −19=1110 1101-19 = 1110\,1101.
Copy-then-flip shortcutFrom the right, copy bits up to and including the first 1, flip the rest. 44=0010 110044 = 0010\,1100 → −44=1101 0100-44 = 1101\,0100.
Reading a patternMSB weight is −2n−1-2^{n-1}: bn−1⋯b0=−bn−12n−1+∑i<n−1bi2ib_{n-1}\cdots b_0 = -b_{n-1}2^{n-1} + \sum_{i<n-1} b_i 2^i. 1011 0101=−128+53=−751011\,0101 = -128+53 = -75.
Same pattern, 4 readings1011 01011011\,0101: unsigned 181, signed magnitude −53, one's −74, two's −75. Sign bit 0 → all readings equal.
3-bit table (100…111)SM: −0, −1, −2, −3. One's: −3, −2, −1, −0. Two's: −4, −3, −2, −1.
Sign extensionTwo's / one's: copy the sign bit (1101→1111 11011101 → 1111\,1101). Signed magnitude: sign to new MSB, insert 0s after it (1101→1000 01011101 → 1000\,0101). Unsigned: zero-fill.
Why two's complement winsOne zero, widest range, subtraction = addition with carry simply discarded (one extra negative is the only cost).

2.3 Add/Subtract Rules

SchemeProcedureOverflow
Signed magnitudeSame signs: add magnitudes, keep common sign. Different signs: subtract smaller magnitude from larger, sign of larger. A−B=A+(−B)A-B = A+(-B) (flip B's sign).Carry out of the leftmost magnitude bit
One's complementAdd all bits incl. sign. Carry out of MSB → add it back to LSB (end-around carry).Same-sign operands give opposite-sign result
Two's complementAdd all bits incl. sign; discard carry out. A−B=A+B′+1A-B = A + B' + 1.V=Cin,MSB⊕Cout,MSBV = C_{\text{in,MSB}} \oplus C_{\text{out,MSB}}; different signs never overflow

2.3 Overflow, Adder/Subtractor & Multiplier

Carry ≠ overflow(−4)+(−1)=1100+1111=1 1011(-4)+(-1) = 1100+1111 = 1\,1011: carry out, but 1011=−51011 = -5 correct (carry in = carry out = 1).
Overflow example (4-bit)5+4=0101+0100=10015+4 = 0101+0100 = 1001: carry in 1, out 0 → overflow (reads −7).
XOR adder/subtractorEach BiB_i passes through XOR with MM; MM is also C0C_0. M=0M=0: A+BA+B. M=1M=1: A+B′+1=A−BA+B'+1 = A-B. V=Cn−1⊕CnV = C_{n-1} \oplus C_n.
Block diagramB register → complementer → switch (SW) → adder ← A register; result back to A; OF bit = overflow flag.
Sequential multiplier registersM = multiplicand (nn), Q = multiplier (nn), A = accumulator (nn, starts 0), C = carry (1 bit), Count = nn.
Multiplier algorithm1. If Q0=1Q_0 = 1: C,A←A+MC,A ← A + M.
2. Shift C,A,Q right 1 (C→An−1C→A_{n-1}, A0→Qn−1A_0→Q_{n-1}, Q0Q_0 dropped).
3. Count ← Count − 1; repeat until 0.
4. Product (2n2n bits) in A,Q.
Example 11 × 13 (4-bit)Cycle 4 add 0110+1011=1 00010110+1011 = 1\,0001 sets C = 1; shift moves it into A3A_3. Final AQ=1000 1111=143AQ = 1000\,1111 = 143.

2.4 Lecture's 14-bit Floating-Point Model

Layout1 sign | 5 exponent (excess-16) | 8 fraction bits. Implicit leading 1: value =(−1)S×1.F×2E−16= (-1)^S \times 1.F \times 2^{E-16}.
NormalizationForm 1.xxx×2e1.\text{xxx} \times 2^e. Point left kk places → exponent +k+k; right kk → −k-k. 1001.101=1.001101×231001.101 = 1.001101 \times 2^3.
Excess-16 exponentStored = true + 16. Stored 0–15 → −16 to −1; 16 → 0; 17–31 → +1 to +15. Unbiased (plain unsigned) exponent cannot hold negatives.
Why bias?Allows negative exponents while the field stays unsigned, so values compare/sort like ordinary binary numbers.
Decimal → 14-bit1. Sign bit.
2. ∣x∣|x| to binary.
3. Normalize 1.f×2e1.f \times 2^e.
4. Exponent field =e+16= e + 16 (5 bits).
5. Fraction ff padded/truncated to 8 bits.
Worked values17→0 10100 0001000017 → 0\ 10100\ 00010000; 9.625→0 10011 001101009.625 → 0\ 10011\ 00110100; −0.375→1 01110 10000000-0.375 → 1\ 01110\ 10000000; 0.1→0 01100 100110010.1 → 0\ 01100\ 10011001 (= 0.099853515625).
LimitsTrue exponents −16 to +15. Largest: 0 11111 11111111=(2−2−8)×215=654080\ 11111\ 11111111 = (2-2^{-8}) \times 2^{15} = 65408.

2.4 IEEE 754

ItemSingle (32)Double (64)
Sign / Exponent / Fraction1 / 8 / 231 / 11 / 52
Bias1271023
Value (normal)(−1)S×1.F×2E−127(-1)^S \times 1.F \times 2^{E-127}(−1)S×1.F×2E−1023(-1)^S \times 1.F \times 2^{E-1023}
E = 0, F = 0±0 (two zeros)±0
E = all 1s, F = 0±∞ (E = 255)±∞ (E = 2047)
E = all 1s, F ≠ 0NaN (e.g. 0/0, √−1)NaN
Approx. rangemax ≈ 3.4×10383.4 \times 10^{38}, min normal 2−126≈1.18×10−382^{-126} \approx 1.18 \times 10^{-38}≈ 10−30810^{-308} to 1030810^{308} (1024log⁡102≈3081024 \log_{10}2 \approx 308)
Examples1.0=3F8000001.0 = \text{3F800000}; −12.375=C1460000-12.375 = \text{C1460000}; 0.15625=3E2000000.15625 = \text{3E200000}; +∞=7F800000+\infty = \text{7F800000}; −0=80000000-0 = \text{80000000}1.0=3FF00000000000001.0 = \text{3FF0000000000000}; −2.5=C004000000000000-2.5 = \text{C004000000000000}

2.5 Floating-Point Arithmetic

OperationSignificandsExponentsSteps
X±YX \pm Yadd/subtract after alignmentmade equal (the larger)1. Check zeros. 2. Shift the smaller-exponent significand right until exponents match. 3. Add/subtract. 4. Normalize. 5. Round/truncate; check over/underflow.
X×YX \times Ymultiplyadd: E=EX+EY−16E = E_X + E_Y - 16Sign =SX⊕SY= S_X \oplus S_Y; product in [1,4)[1,4) needs at most one right shift.
X/YX / Ydividesubtract: E=EX−EY+16E = E_X - E_Y + 16Sign = XOR; normalize (quotient may need a left shift).

2.5 Range, Precision & Errors

Range vs precisionExponent field → range. Significand field → precision.
Overflow / underflowOverflow: exponent too large to store. Underflow: nonzero value whose exponent is too small (too close to 0). 14-bit: 2182^{18} needs field 34 > 31 (overflow); 2−182^{-18} needs field −2 (underflow).
SpacingWith 8 fraction bits, values near 2e2^e are 2e−82^{e-8} apart. Near 128: spacing 0.5, so 128.75128.75 stores as 128.5128.5.
Blatant vs subtle errorBlatant: obvious failure (crash, overflow/underflow). Subtle: plausible but slightly wrong (truncation). Better to crash than give plausible wrong results.
Equality testsNever test x == 0.0 or sum == 1.0; use abs(x - y) < epsilon. Summing 0.1 ten times in double gives 0.9999999999999999.
FP emulationSoftware doing floating point on integer hardware; most CPUs instead have a dedicated FPU (much faster).

3.1 Character Codes: BCD, EBCDIC, ASCII & Unicode

CodeBits / charCharactersNotes
BCD (6-bit)626=642^6 = 64IBM 1950s–60s; each decimal digit = 4 bits (0000–1001); 1010–1111 unused
EBCDIC828=2562^8 = 256IBM mainframes; zone (high nibble) | digit (low nibble); upper + lower case
ASCII7 (+1 parity)27=1282^7 = 128From Telex codes; hex 00–7F; 8th bit = parity or extended set
Unicode21-bit code space17×65,536=1,114,11217 \times 65{,}536 = 1{,}114{,}112U+0000–U+10FFFF; 17 planes; U+0000–U+007F = ASCII

3.1 Key Codes, BCD Signs & Parity

ASCII anchors"0" = 30 hex (48), "A" = 41 hex (65), "a" = 61 hex (97), space = 20, LF = 0A, CR = 0D, DEL = 7F. Upper/lower case differ by 20 hex (bit 5).
EBCDIC landmarksspace 40; a–i 81–89; j–r 91–99; s–z A2–A9; A–I C1–C9; J–R D1–D9; S–Z E2–E9; 0–9 F0–F9 (letters not contiguous).
BCD zone / sign nibble1111 = unsigned, 1100 = +, 1101 = −.
Zoned decimalOne digit per byte. Zone 1111 on every digit except the last, whose zone is the sign. +305+305 = F3 F0 C5.
Packed BCDTwo digits per byte, sign nibble at the right end; pad a leading 0000 if the nibble count is odd. −26-26 = 02 6D; −1265-1265 = 01 26 5D.
Even / odd parityParity bit is the leftmost (8th) bit. Even: total 1s even. Odd: total 1s odd. Detects any odd number of flipped bits, misses an even number, cannot locate the error.
Unicode planePlane = code point ÷65536\div 65536 = hex digits in front of the last four. Plane 0 = BMP (U+0000–U+FFFF); planes 1–16 supplementary. U+1F600 → plane 1.
Encoding formsUTF-16: one 16-bit unit for BMP, surrogate pair otherwise. UTF-8: 1–4 bytes, ASCII unchanged in 1 byte.

3.2 Data Recording & Transmission Codes

CodeRuleTransitions / data bitWeakness / use
NRZ1 = high whole cell, 0 = low whole cell0 – 1Loses sync on long runs of 0s or 1s
NRZI1 = transition (mid-cell), 0 = none; level meaningless0 – 1Loses sync on runs of 0s; RS-232, tape, basic optical
ManchesterMid-cell: 1 = low→high, 0 = high→low; extra boundary flip between equal bits1 – 2Self-clocking, 2× NRZ bandwidth; classic Ethernet
FMClock transition at every cell boundary (end of cell) + mid-cell transition for each 11 – 2Least dense disk code; easy to decode
MFMMid-cell transition for each 1; boundary transition only between two adjacent 0s0.5 – 1Floppies, early hard disks
RLL(2,7)Re-code via table (2 code bits per data bit), then NRZI0.25 – 0.672 to 7 zeros between code 1s; densest

3.2 Counting Transitions & RLL(2,7)

Bit cellTransmission: time for one bit =1/bit rate= 1/\text{bit rate} (2 Kbps → 0.5 ms). Storage: area of surface holding one bit. A flux reversal = change of magnetic polarity.
Counting formulas (nn bits)NRZ = number of adjacent unequal pairs. NRZI = number of 1s. Manchester = nn + adjacent equal pairs. FM = number of 1s + nn (clock at end of each cell). MFM = number of 1s + adjacent 00 pairs. RLL = number of 1s in the code.
Half-cell levelsNRZI (start high) 10011: HL LL LL LH HL. Manchester: 1 = LH, 0 = HL. FM: 1 cell = halves differ, 0 cell = halves equal, level always flips between cells. FM (start low) 1100: LH LH LL HH.
RLL(2,7) table10→0100, 11→1000, 000→000100, 010→100100, 011→001000, 0010→00100100, 0011→00001000.
RLL parsing1. Next bit 1 → take 2 bits. 2. Next bits 01 → take 3. 3. Next 000 → take 3. 4. Next 001 → take 4. 5. Replace by codes, record with NRZI (one transition per code 1).
RLL(d,k)At least dd, at most kk zeros between 1s. (2,7): reversals ≥ 3 code cells apart, at least one every 8 code cells.
"OK" (16 bits) counts11001111 01001011: NRZ 8, NRZI 10, Manchester 23, FM 26, MFM 12, RLL 8. RLL saves (12−8)/16=25%(12-8)/16 = 25\% vs MFM.
Density rankingFor a fixed number of flux reversals per area: RLL >\gt MFM >\gt FM. Modern drives use PRML.

3.3 Check Digits & CRC

UPC-A check digit1. Sum odd positions (1,3,…,11). 2. ×3. 3. Add even positions (2,…,10) → SS. 4. Check =10−(S mod 10)= 10 - (S \bmod 10), or 0 if S mod 10=0S \bmod 10 = 0. 03600024145 → S=53S=53 → 7.
Modulo-2 arithmeticNo carries/borrows: add = subtract = XOR. 1011+0110=11011011 + 0110 = 1101. Divide: XOR the key under each leading 1.
Polynomial keyLeftmost bit = highest power. 1101 = x3+x2+1x^3 + x^2 + 1. Key of n+1n+1 bits (degree nn) → CRC of nn bits.
Sender1. Append nn zeros. 2. Mod-2 divide by key. 3. Remainder (nn bits) replaces the zeros. 1111101, key 1101 → remainder 111 → 1111101111.
ReceiverDivide the whole codeword by the key (no zeros appended). Remainder 0 → accept; non-zero → reject, request retransmission.
Why it worksT(x)=M(x)xn+R(x)T(x) = M(x)x^n + R(x) is a multiple of G(x)G(x). Received remainder = remainder of the error E(x)E(x); missed only if E(x)E(x) is a multiple of G(x)G(x).
DetectsAll single-bit errors; all bursts of length ≤n\le n; all odd-count errors if (x+1)(x+1) divides the key; fraction 1−2−n1 - 2^{-n} of long random errors.
Standard keysCRC-12: x12+x11+x3+x2+x+1x^{12}+x^{11}+x^3+x^2+x+1. CRC-16: x16+x15+x2+1x^{16}+x^{15}+x^2+1 (USB). CRC-16-CCITT: x16+x12+x5+1x^{16}+x^{12}+x^5+1 (XMODEM, X.25, Bluetooth, PPP). CRC-32: Ethernet, MPEG-2.

3.4 Hamming Codes: Rules

Code wordn=m+rn = m + r (data bits + check bits).
Hamming distanceNumber of differing positions = number of 1s in the XOR. D(min⁡)D(\min) = smallest distance over all pairs of legal words.
Detect / correctDetect kk errors: D(min⁡)=k+1D(\min) = k + 1. Correct kk: D(min⁡)=2k+1D(\min) = 2k + 1. So detect D(min⁡)−1D(\min)-1, correct ⌊(D(min⁡)−1)/2⌋\lfloor (D(\min)-1)/2 \rfloor.
Check-bit bound(m+r+1)≤2r(m + r + 1) \le 2^r, smallest rr. m = 4 → 3 (n 7); 8 → 4 (12); 10 → 4 (14); 16 → 5 (21); 32 → 6 (38); 64 → 7 (71).
LayoutPositions 1..n numbered from the right; check bits at 1, 2, 4, 8, …; data fills the other positions from the highest down, leftmost data bit first.
Generate (even parity)Each check bit cc = XOR of the data bits whose position number has the cc bit set. Key KK = P8 P4 P2 P1. 11010110 → K = 1101, code 110110111001.
SyndromeK⊕K′K \oplus K' (stored key XOR recomputed key), read P8 P4 P2 P1. 0 = no error; power of 2 = that check bit is wrong; otherwise = position of the wrong data bit, flip it.
LimitsD(min⁡)=3D(\min) = 3 corrects only 1 error; a 2-bit error gives a misleading syndrome. SEC-DED adds an overall parity bit. Reed-Solomon handles burst errors (CDs).

3.4 Coverage Table (12-bit code, m = 8)

Check bitBinaryCovers positionsContents layout (12 → 1)
P100011, 3, 5, 7, 9, 11d d d d P8 d d d P4 d P2 P1
P200102, 3, 6, 7, 10, 11data positions: 12, 11, 10, 9, 7, 6, 5, 3
P401004, 5, 6, 7, 12position 11 = 8 + 2 + 1 → checked by P8, P2, P1
P810008, 9, 10, 11, 127-bit (m = 4): data at 7, 6, 5, 3; P4 covers 5, 6, 7

4.1 Boolean Operators & Logic Gates

GateExpressionOutput is 1 when…Symbol
ANDxyxy (Boolean product)all inputs are 1D shape: flat back, round front
ORx+yx + y (Boolean sum)at least one input is 1 (1+1=11 + 1 = 1)shield/arrowhead: concave back, pointed front
NOTx′x' (same as x‾\overline{x})input is 0triangle with bubble at the tip
XORx⊕y=xy′+x′yx \oplus y = xy' + x'yinputs differ; multi-input: odd number of 1s (parity)OR shape with extra curved input line
NAND(xy)′(xy)'NOT all inputs are 1 (0 only when all are 1)AND + output bubble
NOR(x+y)′(x + y)'all inputs are 0OR + output bubble

4.1 Truth Tables, Universal Gates, CMOS & SSI

Truth table sizenn inputs → 2n2^n rows, listed in binary counting order. Number of distinct functions of nn variables =22n= 2^{2^n} (16 for n=2n = 2, 256 for n=3n = 3).
PrecedenceNOT, then AND, then OR. xz′+y=(x⋅z′)+yxz' + y = (x \cdot z') + y.
NAND-onlyNOT xx = NAND(x,xx, x). AND = NAND then NAND-inverter. OR = NAND(x′,y′x', y') =(x′y′)′=x+y= (x'y')' = x + y.
NOR-onlyNOT xx = NOR(x,xx, x). OR = NOR then NOR-inverter. AND = NOR(x′,y′x', y') =(x′+y′)′=xy= (x' + y')' = xy.
Why universalAny function can be built from NAND only or NOR only; cheap to mass-produce; faster and lower power than other gate configurations.
SOP → NAND-NANDxy+z=((xy)′⋅z′)′xy + z = ((xy)' \cdot z')': NAND(x,yx,y), NAND(z,zz,z), NAND of the two → 3 NAND gates.
Not associativeNAND(NAND(x,yx,y), zz) =xy+z′= xy + z', not (xyz)′=x′+y′+z′(xyz)' = x' + y' + z'.
CMOSpMOS conducts on 0 (pulls output up to +5 V); nMOS conducts on 1 (pulls down to ground). NOT = 2 transistors; NOR = 2 pMOS in series + 2 nMOS in parallel (4); AND = NAND + inverter (6).
7400 chipSSI, 14 pins: power + ground + 12 pins = 4 two-input NAND gates × 3 pins. Chips needed =⌈gates/4⌉= \lceil \text{gates}/4 \rceil; gate types cannot share a chip.
Parity with XOREven-parity bit P=x⊕y⊕z⊕⋯P = x \oplus y \oplus z \oplus \cdots (makes total number of 1s even); odd parity uses P′P'.

4.2 Boolean Identities

LawAND formOR form
Identity1x=x1x = x0+x=x0 + x = x
Null (dominance)0x=00x = 01+x=11 + x = 1
Idempotentxx=xxx = xx+x=xx + x = x
Inversexx′=0xx' = 0x+x′=1x + x' = 1
Commutativexy=yxxy = yxx+y=y+xx + y = y + x
Associative(xy)z=x(yz)(xy)z = x(yz)(x+y)+z=x+(y+z)(x + y) + z = x + (y + z)
Distributivex+yz=(x+y)(x+z)x + yz = (x + y)(x + z)x(y+z)=xy+xzx(y + z) = xy + xz
Absorptionx(x+y)=xx(x + y) = xx+xy=xx + xy = x
DeMorgan(xy)′=x′+y′(xy)' = x' + y'(x+y)′=x′y′(x + y)' = x'y'
Double complement(x′)′=x(x')' = x

4.2 DeMorgan, Patterns & Canonical Forms

Complement of a whole function1. Complement every variable. 2. Swap AND ↔ OR. 3. Keep each old product grouped in parentheses.
(xy+x′z+yz′)′=(x′+y′)(x+z′)(y′+z)(xy + x'z + yz')' = (x' + y')(x + z')(y' + z).
Patternsxy+xy′=xxy + xy' = x; (x+y)(x+y′)=x(x + y)(x + y') = x; x+x′y=x+yx + x'y = x + y; x(x′+y)=xyx(x' + y) = xy.
Consensusxy+x′z+yz=xy+x′zxy + x'z + yz = xy + x'z (multiply yzyz by x+x′x + x', then absorb).
Canonical SOPFor each row with F=1F = 1 write a minterm (variable if 1, complement if 0) and OR them: F=Σm(…)F = \Sigma m(\ldots).
Canonical POSFor each row with F=0F = 0 write a maxterm (variable if 0, complement if 1) and AND them: F=ΠM(…)F = \Pi M(\ldots). E.g. row 101 → x′+y+z′x' + y + z'.
Σm ↔ ΠMThe ΠM list is exactly the rows missing from the Σm list: Σm(0,2,4,5,6)=ΠM(1,3,7)\Sigma m(0,2,4,5,6) = \Pi M(1,3,7).
Full adderSum =x⊕y⊕z=Σm(1,2,4,7)= x \oplus y \oplus z = \Sigma m(1,2,4,7); Cout=xy+z(x⊕y)=Σm(3,5,6,7)C_{out} = xy + z(x \oplus y) = \Sigma m(3,5,6,7).
Proving an equalityEither compare truth-table columns in every row, or transform one side with identities, naming the law at each step.

4.3 Karnaugh Map Layout & Rules

Gray orderColumns (and 4-var rows) are labelled 00, 01, 11, 10, so adjacent cells differ in one variable. Cell order: m0 m1 m3 m2 / m4 m5 m7 m6.
4-var map rowswxwx = 00: m0 m1 m3 m2; 01: m4 m5 m7 m6; 11: m12 m13 m15 m14; 10: m8 m9 m11 m10.
Grouping rules1. Only 1s (and d's). 2. Rectangles only, no diagonals. 3. Size a power of 2. 4. As large as possible. 5. Overlap and wrap-around allowed (left↔right, top↔bottom; four corners form a group). Cover every 1 with as few groups as possible.
Reading a groupKeep only variables that are constant over the group (1 → xx, 0 → x′x'); variables that change drop out.
Group size → literals3-var map: 1→3, 2→2, 4→1, 8→F=1F = 1. 4-var map: 1→4, 2→3, 4→2, 8→1, 16→F=1F = 1.
Don't cares (d / X)Input combinations that never occur. Treat d as 1 only if it makes a bigger group; never needs to be covered.
Procedure1. Draw Gray-labelled map. 2. Enter 1s and d's. 3. Circle largest groups, starting with 1s that can be covered only one way. 4. Add groups until all 1s covered. 5. OR the group terms.
Classic resultsΣm(1,3,5,7)=z\Sigma m(1,3,5,7) = z; Σm(0,2,4,6)=z′\Sigma m(0,2,4,6) = z'; corners Σm(0,2,8,10)=x′z′\Sigma m(0,2,8,10) = x'z'; Σm(0,2,5,7,8,10,13,15)=x′z′+xz\Sigma m(0,2,5,7,8,10,13,15) = x'z' + xz.

4.4 Adders, Decoder, MUX

CircuitInputs → outputsEquations / key facts
Half adderx,yx, y → Sum, CarrySum =x⊕y= x \oplus y, Carry =xy= xy (1 XOR + 1 AND)
Full adderx,y,Cinx, y, C_{in} → Sum, CoutC_{out}Sum =x⊕y⊕Cin= x \oplus y \oplus C_{in}; Cout=xy+Cin(x⊕y)C_{out} = xy + C_{in}(x \oplus y); = 2 half adders + 1 OR (2 XOR, 2 AND, 1 OR)
Ripple-carry addernn full addersEach CoutC_{out} feeds the next CinC_{in}; bit 0 has Cin=0C_{in} = 0. Simple but slow: carry ripples through all stages. Final carry 1 = unsigned overflow.
Decodernn → 2n2^nExactly one output active (the one numbered by the input); each output is a minterm. Used for memory address decoding. Inputs =log⁡2(outputs)= \log_2(\text{outputs}).
Multiplexer2s2^s data + ss select → 1Select value chooses the input passed to the output. Select lines =log⁡2(inputs)= \log_2(\text{inputs}). 4-to-1: S1′S0′I0+S1′S0I1+S1S0′I2+S1S0I3S_1'S_0'I_0 + S_1'S_0I_1 + S_1S_0'I_2 + S_1S_0I_3.
Decoder + ORany functionOR the decoder outputs of the function's minterms, e.g. full adder: Sum =D1+D2+D4+D7= D_1 + D_2 + D_4 + D_7, Cout=D3+D5+D6+D7C_{out} = D_3 + D_5 + D_6 + D_7.

4.4 Simple 2-bit ALU & Circuit Building

ALU operations (f1f0f_1f_0)00 ADD, 01 OR, 10 NOT AA, 11 AND. Result C1C0C_1C_0 + overflow (carry out of bit 1).
ALU structure2-to-4 decoder on f1f0f_1f_0 gives one enable line; per bit an AND, OR, NOT unit; half adder (bit 0) + full adder (bit 1); each result ANDed with its enable, then ORed per bit.
AND-OR circuit from SOP1 inverter per complemented variable, 1 AND per product term (single literal needs none), 1 OR combining them. Simplify first to save gates.
Address decodingHigh address bits → decoder selects the chip; low bits select the word in the chip. 8 chips → 3-to-8 decoder.
CombinationalOutput depends only on current inputs; no memory, no feedback.

4.5 Flip-Flop Characteristic Tables

Flip-flopInputs → Q(t+1)Q(t+1)Characteristic equationBuilt from
SR00 hold, 01 reset (0), 10 set (1), 11 undefinedQ+=S+R′QQ^+ = S + R'Q (with SR=0SR = 0)2 cross-coupled NOR gates: Q′=(S+Q)′Q' = (S + Q)', Q=(R+Q′)′Q = (R + Q')'
JK00 hold, 01 reset, 10 set, 11 toggle (Q′Q')Q+=JQ′+K′QQ^+ = JQ' + K'QSR with S=JQ′S = JQ', R=KQR = KQ (never both 1)
DQ+=DQ^+ = DQ+=DQ^+ = DSR with S=DS = D, R=D′R = D'; basic 1-bit memory cell
T0 hold, 1 toggleQ+=T⊕QQ^+ = T \oplus QJK with J=K=TJ = K = T

4.5 Clocks, Counters & Circuit Analysis

Sequential vs combinationalSequential output depends on inputs and current state; memory comes from feedback; state changes only on clock ticks.
ClockPeriod = 1/frequency (800 MHz → 1.25 ns). Edge-triggered: changes at rising or falling edge. Level-triggered: changes while the clock is high.
Registernn D flip-flops with a shared clock; all bits loaded at once on the edge, held between edges.
4-bit JK counterJ=KJ = K: B0B_0 = Count Enable; B1B_1 = CE·B0B_0; B2B_2 = CE·B0B1B_0B_1; B3B_3 = CE·B0B1B2B_0B_1B_2. A bit toggles when all lower bits are 1. Output Carry = CE·B0B1B2B3B_0B_1B_2B_3.
JK excitation0→0: J=0,K=dJ = 0, K = d. 0→1: J=1,K=dJ = 1, K = d. 1→0: J=d,K=1J = d, K = 1. 1→1: J=d,K=0J = d, K = 0.
Analysis procedure1. Identify state variables and inputs. 2. Write input equations (JAJ_A, KAK_A, DBD_B…). 3. One row per state+input combination. 4. Evaluate equations with present values. 5. Apply characteristic tables.
Simultaneous updateAll flip-flops share the clock: every input equation uses present state values, never the value another flip-flop is changing to.
MN flip-flop exampleM=1M = 1 complement, M=0M = 0 load NN: Q+=M′N+MQ′Q^+ = M'N + MQ'; from JK: J=M+NJ = M + N, K=M+N′K = M + N'.

6.1 CPU Basics, Buses & Clocks

Four componentsCPU (control unit + ALU + registers), main memory (stored program: code and data), I/O subsystem, buses.
Datapath vs control unitDatapath = ALU + registers + bus wiring (the muscle). Control unit = decides which datapath actions happen and when, using the instruction, PC and status register (flags).
Register = D flip-flopsAn n-bit register = n D flip-flops on one clock (Q(t+1)=DQ(t+1) = D). MARIE total: 16+12+16+12+16+8+8 = 88 flip-flops.
Bus line groupsData lines: the value (both ways). Address lines: where (CPU → memory/device). Control lines: what/when (read/write, clock, arbitration, interrupts).
Point-to-point vs multipointPoint-to-point links exactly 2 devices, no arbitration, n devices need n(n−1)/2n(n-1)/2 links. Multipoint (shared) bus: one set of wires, cheap, but needs hardware protocols (bus arbitration) and can be a bottleneck. MARIE uses one common bus.
Clockt=1/ft = 1/f. Shortcut: t [ns]=1000/f [MHz]t\,[\text{ns}] = 1000 / f\,[\text{MHz}]. 800 MHz → 1.25 ns; 2.5 GHz → 0.4 ns; 0.5 ns → 2 GHz.
Execution timeinstructions × cycles per instruction × cycle time. A faster clock alone does not guarantee a faster program.
Bus bandwidth(data lines / 8) bytes × transfers per second. 32 lines at 100 MHz → 4 B × 10810^8 = 400 MB/s.
I/O interfacesRS-232 serial ≈ 115.2 kbit/s; USB(-C) up to ≈ 10 Gbit/s; RJ-45 Ethernet 100 Mbit/s – 10 Gbit/s; Wi-Fi hundreds of Mbit/s+. MARIE I/O = 8-bit InREG and OutREG.

6.1 Memory Organization & Chips

Length × width(number of addressable locations) × (bits per location). Length → address lines; width → data lines.
Address lines⌈log⁡2N⌉\lceil \log_2 N \rceil for N addressable units. 4M × 16 word-addr: 2222^{22} → 22. Same, byte-addr: 222×2=2232^{22} \times 2 = 2^{23} → 23. MARIE 4K words → 12.
Prefixes1K = 2102^{10}, 1M = 2202^{20}, 1G = 2302^{30}; 4K = 2122^{12}, 64K = 2162^{16}, 256K = 2182^{18}, 2M = 2212^{21}.
Building L × W from l × w chips1. Chips per row = W / w.
2. Rows = L / l.
3. Total = (L/l)(W/w).
4. log⁡2l\log_2 l address bits go to every chip; log⁡2(L/l)\log_2(L/l) high-order bits feed a decoder (chip select).
MARIE 4K × 16 from 1K × 84 rows × 2 chips = 8 chips. 12 address bits: A11 A10 → 2-to-4 decoder; A9–A0 to every chip. Rows: 000–3FF, 400–7FF, 800–BFF, C00–FFF.
InterleavingHigh-order: chip select from the leftmost bits, consecutive addresses stay in one row. Low-order: chip select from the low bits, consecutive addresses spread across rows (parallel access).

6.2 MARIE Architecture & Registers

RegisterBitsHoldsBus no.
Memory4K × 16program + data, word-addressable 000–FFF0 (000)
MAR12address being accessed1 (001)
PC12address of next instruction2 (010)
MBR16data to/from memory3 (011)
AC16operand / result (two's complement, −32768..32767)4 (100)
InREG8data from input device5 (101)
OutREG8data for output device6 (110)
IR16instruction being executed7 (111)

6.2 MARIE Instruction Set (opcode + 12-bit address)

HexBinaryInstructionRTN
00000JnS XMBR ← PC; MAR ← X; M[MAR] ← MBR; MBR ← X; AC ← 1; AC ← AC + MBR; PC ← AC
10001Load XMAR ← X; MBR ← M[MAR]; AC ← MBR
20010Store XMAR ← X, MBR ← AC; M[MAR] ← MBR
30011Add XMAR ← X; MBR ← M[MAR]; AC ← AC + MBR
40100Subt XMAR ← X; MBR ← M[MAR]; AC ← AC − MBR
50101InputAC ← InREG
60110OutputOutREG ← AC
70111Halt(stop)
81000SkipcondIR[11–10]: 00 → skip if AC < 0 (8000); 01 → AC = 0 (8400); 10 → AC > 0 (8800)
91001Jump XPC ← IR[11–0]
A1010ClearAC ← 0
B1011AddI XMAR ← X; MBR ← M[MAR]; MAR ← MBR; MBR ← M[MAR]; AC ← AC + MBR
C1100JumpI XMAR ← X; MBR ← M[MAR]; PC ← MBR
D1101LoadI XMAR ← X; MBR ← M[MAR]; MAR ← MBR; MBR ← M[MAR]; AC ← MBR
E1110StoreI XMAR ← X; MBR ← M[MAR]; MAR ← MBR; MBR ← AC; M[MAR] ← MBR

6.2 Encoding, Skipcond & Indirection

Encodeopcode hex digit + 3-digit address. Store 1A3 → 21A3; AddI 20F → B20F; Halt → 7000; Clear → A000; Input → 5000; Output → 6000.
DecodeSplit 16 bits into 4 + 12: 0100 0000 1111 1111 → 40FF → Subt 0FF. 0000 0011 0000 0000 → 0300 → JnS 300.
SkipcondSkips next instruction (one extra PC ← PC + 1). AC is read as 16-bit two's complement: FFFB = −5, 8000 = −32768. 0 is not > 0.
Indirect resultsLoadI X: AC ← M[M[X]]; AddI X: AC ← AC + M[M[X]]; StoreI X: M[M[X]] ← AC; JumpI X: PC ← M[X]. One extra memory read vs direct.
JnS XM[X] ← return address (PC, already incremented); PC ← X + 1; AC is overwritten with X + 1. Return with JumpI X.
Format limits4 opcode bits → 16 opcodes, 15 used (0–E), F free. 12 address bits → 4K words reachable directly.

6.3 Fetch–Decode–Execute

Fetch1. MAR ← PC
2. IR ← M[MAR]
3. PC ← PC + 1
DecodeMAR ← IR[11–0]; decode opcode IR[15–12].
Get operandMBR ← M[MAR], only if the instruction reads memory (Load, Add, Subt, AddI, LoadI, JumpI, StoreI pointer). Not for Store, Halt, Jump, Clear, Input, Output, Skipcond.
ExecuteOpcode-specific RTN, then back to fetch. Real CPUs check for interrupts after execute (save PC, run ISR, restore).
PC during executeAlready holds the address of the next instruction (incremented during fetch).
Trace table rulesOne row per microoperation; write values after the step; only the register left of ← changes; copy others down.
Memory accessesEach instruction: 1 fetch read. Load/Add/Subt +1 read; Store +1 write; LoadI/AddI +2 reads; StoreI +1 read +1 write; JumpI +1 read.
Addition program100: 1104 Load 104; 101: 3105 Add 105; 102: 2106 Store 106; 103: 7000 Halt; 104: 0023; 105: FFE9 → M[106] = 000C (35 − 23 = 12).

6.4 Assembly Language & Two-Pass Assembler

Line formatLabel, Mnemonic Operand / comment. Label (with comma) = address of that line.
DirectivesORG n start at hex n; DEC n decimal word; HEX n hex word; END. Directives produce no CPU instruction; DEC/HEX take one word each.
Pass 1LC starts at ORG. For each line: record label → LC in symbol table, translate opcode (address left blank), LC + 1.
Pass 2Replace label operands with symbol-table addresses, convert DEC/HEX constants to 16-bit hex, output each word.
Why two passesForward references: a label can be used before it is defined.
Negative DECTwo's complement: DEC −23 → 0017 → invert FFE8 → +1 → FFE9. DEC −12 → FFF4. DEC −40 → FFD8.
Data placementPut data after Halt: the CPU cannot tell data from code (0023 would execute as JnS 023).

6.4 Control-Structure Templates

ConditionAC holdsSkipcond to enter bodyPattern
X > YX − YSkipcond 800 (8800)Load X / Subt Y / Skipcond 800 / Jump Else / THEN...
X < YX − YSkipcond 000 (8000)While: Load X / Subt Y / Skipcond 000 / Jump EndW / body / Jump While
X = YX − YSkipcond 400 (8400)Skip the Jump that bypasses the body
X > 1X − 1Skipcond 800Load X / Subt One / Skipcond 800 / Jump EndIf
Count N > 0NSkipcond 800Loop: Load N / Skipcond 800 / Jump Done / body / N ← N − 1 / Jump Loop
X ≥ YX − Ytest X < Y (Skipcond 000)swap THEN and ELSE parts
Subroutine——JnS Sub / ... / Sub, HEX 0000 / body / JumpI Sub

7.1 Control Signals & Execute-Phase Signal Lists

Instr.T3T4T5
SignalsP2P1P0P_2P_1P_0 = source read onto bus; P5P4P3P_5P_4P_3 = destination (memory 0, MAR 1, PC 2, MBR 3, AC 4, InREG 5, OutREG 6, IR 7)A1A0A_1A_0: 00 none, 01 add, 10 subtract, 11 clear; LALTL_{ALT} = AC loads from ALU (also P5P_5)MRM_R memory source, MWM_W memory dest; TnT_n timing (exactly one high); CrC_r reset counter on last step
RecipeFetch/decode = T0T_0–T2T_2; execute from T3T_3, one microop per cycle (single bus: one transfer per cycle)List only the bits that are 1Timing diagram: each signal high exactly in the cycles whose list contains it
Load XP3 P2 P1 P0 T3 (MAR ← X)P4 P3 T4 MR (MBR ← M[MAR])P5 P1 P0 T5 Cr (AC ← MBR)
Add XP3 P2 P1 P0 T3P4 P3 T4 MRCr A0 P5 T5 LALT (AC ← AC + MBR)
Subt XP3 P2 P1 P0 T3P4 P3 T4 MRCr A1 P5 T5 LALT (AC ← AC − MBR)
Store XP3 P2 P1 P0 T3P4 P3 P2 T4 (MBR ← AC)P1 P0 T5 MW Cr (M[MAR] ← MBR)
JumpI XP3 P2 P1 P0 T3P4 P3 T4 MRP4 P1 P0 T5 Cr (PC ← MBR)
Jump XP4 P2 P1 P0 T3 Cr (PC ← IR[11–0])
InputP5 P2 P0 T3 Cr (AC ← InREG)
OutputP5 P4 P2 T3 Cr (OutREG ← AC)
ClearA1 A0 P5 T3 LALT Cr (AC ← 0)

7.1 Hardwired vs Microprogrammed Control

HardwiredMicroprogrammed
Built frominstruction decoder (AND of opcode bits) + ring counter (TnT_n) + AND/OR logicmicroprogram (firmware) in a control store ROM
Signal equationOR of (instruction · TnT_n), e.g. Add = IR15′IR14′IR13IR12IR_{15}'IR_{14}'IR_{13}IR_{12}; MR=(Load+Add)T4M_R = (\text{Load}+\text{Add})T_4one microinstruction fetched per clock, decoded into signals
Speedfastslower (extra fetch/decode level, jump-table lookups)
Change ISA / fix bugredesign circuitrewrite microprogram
Complex instructionslogic grows largejust a longer microroutine
TypicalRISCCISC
RISC vs CISCfew, fixed-length instructions; easy pipelining; short opcode (15 instr → 4 bits, 12 address bits)many instructions; denser code; 509 instr → 9 opcode bits, only 7 address bits in 16-bit word

7.1 Microinstruction Format & Microop Codes (Table 4.9)

CodeMicrooperationCodeMicrooperation
00000NOP01101MBR ← M[MAR]
00001AC ← 001110OutREG ← AC
00010AC ← MBR01111PC ← IR[11–0]
00011AC ← AC − MBR10000PC ← MBR
00100AC ← AC + MBR10001PC ← PC + 1
00101AC ← InREG10010If AC = 00
00110IR ← M[MAR]10011If AC > 0
00111M[MAR] ← MBR10100If AC < 0
01000MAR ← IR[11–0]10101If IR[11–10] = 00
01001MAR ← MBR10110If IR[11–10] = 01
01010MAR ← PC10111If IR[11–10] = 10
01011MAR ← X11000If IR[15–12] = MicroOp2[4–1]
01100MBR ← AC
Format18 bits = MicroOp1 (5) | MicroOp2 (5) | Jump (1) | Dest (7)Store01011 01100 0 0000000 / 00111 00000 1 0000000
Fetch lines 0–301010, 00110, 10001, 01000 (each with NOP, Jump 0)Jump tableJnS → 32 (0100000), Load → 39, Store → 42, Add → 44, Subt → 47; routine ends Jump = 1, Dest = 0000000
Control store128 lines × 18 bits = 2304 bits; Dest 7 bits since 27=1282^7 = 128Add01011 00000 0 / 01101 00000 0 / 00100 00000 1 0000000