Computer Organization
Download PDFBoolean Logic
Boolean logic is the foundation of all digital computing. Every decision a computer makes is expressed as a combination of Boolean operations on binary values (0 = false, 1 = true).
Basic Logic Operations and Truth Tables
NOT — inverts a single input:
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
AND — output is 1 only when both inputs are 1:
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR — output is 1 when at least one input is 1:
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
XOR (Exclusive OR) — output is 1 when inputs differ (exactly one is 1):
| A | B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NAND — NOT AND; output is 0 only when both inputs are 1:
| A | B | A NAND B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NOR — NOT OR; output is 1 only when both inputs are 0:
| A | B | A NOR B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Quick rules for all six operations:
- NOT: flip the bit
- AND: 1 only if BOTH are 1
- OR: 1 if AT LEAST ONE is 1
- XOR: 1 if inputs DIFFER (not equal)
- NAND: opposite of AND (0 only if both are 1)
- NOR: opposite of OR (1 only if both are 0)
NAND and NOR are “universal gates” — any Boolean circuit can be built using only NAND gates or only NOR gates. The IB may ask you to verify a NAND or NOR truth table. Always compute the underlying AND/OR first, then invert (NOT) the result.
Logic Gates
A logic gate is a physical electronic circuit that implements a Boolean operation. Gates take binary inputs (voltage high = 1, voltage low = 0) and produce a binary output. Digital circuits are built by connecting gates together.
Gate Symbols (described)
Each gate has a standardised symbol used in circuit diagrams:
| Gate | Symbol description | IEC symbol |
|---|---|---|
| NOT | Triangle with a small circle (bubble) at the output | Labelled “1” with output bubble |
| AND | D-shaped body (flat input side, curved output side) | Labelled ”&“ |
| OR | Curved input and output sides (shield shape) | Labelled “≥1” |
| XOR | Same as OR but with an extra curved line on the input side | Labelled “=1” |
| NAND | AND symbol with a bubble at the output | ”&” with output bubble |
| NOR | OR symbol with a bubble at the output | ”≥1” with output bubble |
Combining Gates
Gates are combined to build more complex logic. The output of one gate feeds into the input of another.
Worked Example — Implement XOR using AND, OR, and NOT gates:
XOR can be expressed as:
Circuit: feed A and B into an OR gate and separately into an AND gate. Feed the AND output into a NOT gate. Finally, feed the OR output and the NOT-AND output into a final AND gate.
Verify with truth table (A=1, B=1): OR = 1; AND = 1; NOT(AND) = 0; final AND = 1 AND 0 = 0. Correct — XOR(1,1) = 0.
Operating Systems
The operating system (OS) is system software that acts as an intermediary between the hardware and user applications. It manages all hardware resources and provides services to application programs.
OS Functions
| Function | Description |
|---|---|
| Memory management | Allocates RAM to running processes; handles virtual memory (using secondary storage as an extension of RAM) and paging to prevent processes from interfering with each other |
| File management | Organises files in a hierarchical directory structure; controls read, write, and execute permissions for files and folders |
| Peripheral management | Communicates with input/output devices (printers, keyboards, screens) through device drivers; manages I/O queues |
| Multitasking | Allows multiple processes to run concurrently by rapidly switching CPU time between them (time-slicing); uses scheduling algorithms (e.g., round-robin) to allocate CPU time fairly |
| Security | Manages user authentication (login); enforces access control lists to determine which users can access which resources; maintains system logs for audit purposes |
When describing an OS function in an exam, always state what the OS does AND why it is needed. For example: “The OS manages memory by allocating RAM to each process — this prevents one process from overwriting another’s data, which would cause system crashes.”
User Interface Types
The OS provides a user interface — the means by which users interact with the computer:
- GUI (Graphical User Interface) — windows, icons, menus, pointer (WIMP). Intuitive for non-technical users; requires more processing power and memory.
- CLI (Command-Line Interface) — text-based commands typed by the user. Precise, efficient for experienced users; requires knowledge of command syntax; uses less memory than a GUI.
System Software vs Application Software
All software falls into one of two broad categories.
System Software
System software manages and controls the hardware, providing a platform for application software to run. It operates largely in the background, invisible to most users.
Examples: operating system, device drivers, utilities (disk defragmenter, antivirus, file compression), programming language compilers and interpreters.
Application Software
Application software is designed to perform specific tasks for end users. It depends on system software to access hardware.
Examples: word processors, web browsers, spreadsheets, games, email clients, ERP systems, graphic design tools.
| Attribute | System Software | Application Software |
|---|---|---|
| Purpose | Manages hardware and provides platform | Performs user tasks |
| User interaction | Mostly background | Direct user interaction |
| Examples | OS, drivers, compilers | Word processor, browser, game |
| Dependency | Runs on hardware directly | Requires OS to function |
System software serves the system. Application software serves the user.
CPU Architecture
The Central Processing Unit (CPU) is the component that executes program instructions. It consists of three main sub-units, connected internally and to the rest of the computer via a set of electrical pathways called buses.
The Von Neumann Architecture
The von Neumann architecture (also called the stored-program concept) is the foundation of modern computers. Key features:
- Single shared memory stores both data and instructions (not in separate memories)
- Instructions are fetched and executed sequentially (one at a time)
- The CPU contains: ALU, CU, registers, and connects to memory via buses
Von Neumann features (exam favourite):
- Data and instructions stored in the same memory
- Instructions executed sequentially
- CPU has ALU + CU + registers
- Connected via address, data, and control buses
Von Neumann bottleneck: Since data and instructions share the same bus, the CPU can only fetch one thing at a time — this limits processing speed.
ALU, Control Unit, and Registers
| Component | Full Name | Function |
|---|---|---|
| ALU | Arithmetic Logic Unit | Performs arithmetic (add, subtract, multiply) and logical (AND, OR, NOT, XOR, compare) operations |
| CU | Control Unit | Fetches instructions from memory, decodes them, and coordinates execution across the CPU |
| Registers | — | Ultra-fast temporary storage locations inside the CPU; each has a specific role |
Key Registers
| Register | Name | Role |
|---|---|---|
| PC | Program Counter | Holds the memory address of the next instruction to be fetched |
| IR | Instruction Register | Holds the current instruction being decoded and executed |
| MAR | Memory Address Register | Holds the memory address the CPU wants to read from or write to |
| MDR | Memory Data Register | Holds the data just read from memory or about to be written to memory |
| ACC | Accumulator | General-purpose register storing the result of ALU operations |
Register roles — PC points ahead, IR holds now: PC = next instruction’s address; IR = current instruction; MAR = address on the bus; MDR = data on the bus; ACC = ALU result.
System Buses
The CPU communicates with memory and I/O devices through three buses:
| Bus | Direction | Carries |
|---|---|---|
| Address bus | CPU → memory / I/O (one-way) | The memory address to be accessed |
| Data bus | Bidirectional | The actual data or instruction being transferred |
| Control bus | Bidirectional | Control signals (read/write, clock, interrupt, reset) |
The clock generates a regular pulse that synchronises all CPU operations. Clock speed is measured in GHz (gigahertz); more pulses per second means more instructions can be executed per second. However, more cores, cache size, and instruction set efficiency also affect overall performance.
The IB exam sometimes asks about factors that affect CPU performance. The standard three are: clock speed (GHz), number of cores, and cache size. Do not confuse clock speed with bus speed — they are separate specifications.
Memory Hierarchy
Memory is organised in a hierarchy from fastest/smallest/most expensive to slowest/largest/cheapest.
The memory hierarchy from fastest to slowest is: Registers → Cache → RAM → Secondary Storage
| Level | Speed | Capacity | Cost per GB | Volatile? |
|---|---|---|---|---|
| Registers | Fastest | Bytes | Very high | Yes |
| Cache (L1/L2/L3) | Very fast | KB – MB | High | Yes |
| RAM | Fast | GB | Moderate | Yes |
| SSD | Moderate | GB – TB | Low-moderate | No |
| HDD | Slow | GB – TB | Low | No |
| Optical / USB | Slow | GB | Very low | No |
Why the hierarchy exists: Faster memory is physically more expensive to manufacture. The CPU uses a small amount of very fast memory (registers and cache) for immediate work, backed by larger but slower RAM for active programs, and even larger secondary storage for persistent data.
In Paper 1 questions, if asked to “compare two levels of the memory hierarchy”, structure your answer as: speed (faster/slower), capacity (more/less), cost (higher/lower), and volatility (volatile/non-volatile). Four attributes — four marks.
Cache Memory
Cache is a small, very fast volatile memory that sits between the CPU and RAM. When the CPU needs data, it checks the cache first (cache hit). If not found (cache miss), it retrieves from RAM and stores a copy in cache for future use.
- L1 cache — smallest and fastest; inside the CPU core
- L2 cache — larger, slightly slower; often still inside the CPU
- L3 cache — largest, shared between cores
Secondary Storage
Secondary storage is non-volatile and retains data when power is removed. It is used for long-term storage of files, programs, and the operating system.
| Type | Technology | Typical Use | Advantage | Disadvantage |
|---|---|---|---|---|
| HDD | Magnetic spinning platters | Bulk data storage, OS | Low cost per GB, large capacity | Mechanical parts = slower, fragile if dropped |
| SSD | NAND flash (no moving parts) | OS drive, fast applications | Fast access, silent, durable | More expensive per GB than HDD |
| Optical (CD/DVD/Blu-ray) | Laser reads/writes pits on disc | Distribution, archiving | Cheap per disc, long shelf life | Slow, low capacity, easily scratched |
| USB Flash | NAND flash | Portable transfer | Compact and portable | Small capacity vs. HDD, wears out over many writes |
“State one advantage of an SSD over an HDD” is a common short-answer question. Accept: faster read/write speeds; no moving parts so more durable/reliable; quieter; lower power consumption. Do NOT simply write “better” — the mark scheme requires a specific attribute.
The Fetch-Execute Cycle
The CPU continuously repeats a three-stage cycle to process instructions stored in RAM. Each iteration processes one instruction.
The Three Stages
1. Fetch
- The address stored in the PC is copied to the MAR
- The instruction at that memory address is retrieved and placed in the MDR
- The instruction is copied from MDR to the IR
- The PC is incremented to point to the next instruction
2. Decode
- The Control Unit interprets the binary instruction held in the IR
- It identifies the operation type (load, store, add, jump, etc.) and any operands
3. Execute
- The CU activates the appropriate hardware:
- If arithmetic/logic: data is sent to the ALU; result stored in ACC
- If memory read: MAR gets the data address; data arrives in MDR, then moves to ACC or a register
- If memory write: data from ACC is placed in MDR; MAR holds the destination address; write signal sent
- If jump: PC is updated to the jump target address instead of incrementing
Worked Example — Full cycle trace:
Memory contents:
| Address | Contents |
|---|---|
| 100 | LOAD 200 (load the value at address 200 into ACC) |
| 101 | ADD 201 (add the value at address 201 to ACC) |
| 200 | 15 |
| 201 | 7 |
PC starts at 100.
Cycle 1 — LOAD 200:
- Fetch: MAR ← 100; MDR ← LOAD 200; IR ← LOAD 200; PC ← 101
- Decode: CU identifies a memory-read instruction, operand = 200
- Execute: MAR ← 200; MDR ← 15; ACC ← 15
Cycle 2 — ADD 201:
- Fetch: MAR ← 101; MDR ← ADD 201; IR ← ADD 201; PC ← 102
- Decode: CU identifies an addition, operand = 201
- Execute: MAR ← 201; MDR ← 7; ALU computes 15 + 7 = 22; ACC ← 22
A common Paper 1 error is forgetting that the PC is incremented during the fetch stage, not after the execute stage. Also remember: the MAR always receives an address; the MDR always receives data. Swapping these in an answer loses marks.
Binary and Hexadecimal Representation
All data and instructions inside a computer are stored and processed in binary — patterns of 0s and 1s (bits). Hexadecimal (base 16) is used as a compact human-readable shorthand for binary.
Unsigned Binary
Each bit position represents a power of 2, from (rightmost) upward.
8-bit place values:
Binary to decimal — convert 10110011:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
Value =
Decimal to binary — convert 45:
remainder 1 (LSB) remainder 0 remainder 1 remainder 1 remainder 0 remainder 1 (MSB)
Read remainders from bottom to top: 101101 = 45
Hexadecimal
Hexadecimal uses base 16, with digits 0–9 and A–F (where A = 10, B = 11, C = 12, D = 13, E = 14, F = 15). One hex digit represents exactly 4 binary bits (a nibble), making hex a compact notation for binary.
Hex–binary nibble table (memorise these):
| Hex | Binary | Decimal |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| … | … | … |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| B | 1011 | 11 |
| C | 1100 | 12 |
| D | 1101 | 13 |
| E | 1110 | 14 |
| F | 1111 | 15 |
Binary to hex — convert 11001010:
Split into nibbles: 1100 1010
1100 = C, 1010 = A
Result: CA (or 0xCA)
Hex to binary — convert 3F:
3 = 0011, F = 1111
Result: 00111111
Hex to decimal — convert 2B:
Two’s Complement
Two’s complement is the standard method computers use to represent negative integers in binary.
Representing Negative Numbers
For an -bit two’s complement system:
- Positive numbers: represented normally in binary (leading bit = 0)
- Negative numbers: the most significant bit (MSB) has a negative place value of
- Range for bits: to
For 8-bit two’s complement: range is to .
Converting a Positive Integer to Its Negative Two’s Complement
Method: invert all bits, then add 1
Find the 8-bit two’s complement of :
Step 1 — Represent +35 in binary: 00100011
Step 2 — Invert all bits: 11011100
Step 3 — Add 1: 11011101
Verification: ✓
Reading a two’s complement number 11110000:
MSB place value =
The range of an 8-bit two’s complement system is to — NOT to . The negative range extends one further than the positive because zero occupies one of the positive slots. Students frequently get the boundary wrong; learn it explicitly.
Logical Operations
The ALU performs logical (Boolean) operations on binary values. These operations work bit by bit across corresponding bit positions.
Truth Tables
| A | B | AND | OR | XOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
Quick rules:
- AND: both must be 1 to get 1
- OR: at least one must be 1 to get 1
- XOR: exactly one must be 1 to get 1 (differs)
- NOT: flips the bit
Bit Manipulation with Logical Operations
Logical operations are used to manipulate specific bits within a byte:
- AND with a mask — used to clear (force to 0) specific bits. Apply mask with 0 where you want to clear.
- OR with a mask — used to set (force to 1) specific bits. Apply mask with 1 where you want to set.
- XOR with a mask — used to toggle specific bits. Apply mask with 1 where you want to flip.
Clear bits 3 and 4 of 10111110 using AND:
Mask: 11100111 (0s in positions 3 and 4)
10111110 AND 11100111 = 10100110
Machine Instruction Concepts
A machine instruction is a binary-encoded command that the CPU can execute directly. Students do not need to learn a full assembly language, but should understand the concept.
Every machine instruction consists of:
- Opcode — specifies the operation (e.g., LOAD, STORE, ADD, JUMP)
- Operand — specifies the data or memory address involved
Common instruction types:
- Data transfer: LOAD (memory → register), STORE (register → memory)
- Arithmetic: ADD, SUBTRACT
- Logical: AND, OR, NOT
- Branch/Jump: unconditional jump (always jump to address), conditional jump (jump if result = 0, etc.)
- Halt: stop execution
Programs stored in memory as binary machine code are fetched and executed by the CPU one instruction at a time via the fetch-decode-execute cycle.
HL Transistors and Boolean Algebra
Transistors
A transistor is the fundamental electronic switch used to build logic gates. A transistor has three terminals: the base (or gate in a MOSFET), collector, and emitter.
- When the base receives a sufficient voltage (logic 1), the transistor switches on — current flows from collector to emitter (output = 1 for certain configurations).
- When the base receives no voltage (logic 0), the transistor switches off — no current flows (output = 0).
A NOT gate uses a single transistor: when the input is high (1), the transistor pulls the output low (0); when the input is low (0), the output is high (1). A NAND gate uses two transistors in series; a NOR gate uses two transistors in parallel.
Modern CPUs contain billions of transistors fabricated at the nanometre scale, enabling the density and speed of contemporary processors.
Boolean Algebra Simplification
Boolean algebra provides algebraic rules to simplify logic expressions, reducing the number of gates needed in a circuit.
Key laws:
| Law | Expression |
|---|---|
| Identity | ; |
| Null | ; |
| Idempotent | ; |
| Complement | ; |
| De Morgan’s (1) | |
| De Morgan’s (2) | |
| Double negation |
Worked Example — Simplify the expression NOT(A AND B) AND (A OR B):
Step 1 — Apply De Morgan’s to NOT(A AND B): NOT(A) OR NOT(B)
Step 2 — Expression becomes: (NOT(A) OR NOT(B)) AND (A OR B)
Step 3 — Expand using distribution: = (NOT(A) AND A) OR (NOT(A) AND B) OR (NOT(B) AND A) OR (NOT(B) AND B)
Step 4 — Apply complement law: (NOT(A) AND A) = 0 and (NOT(B) AND B) = 0: = 0 OR (NOT(A) AND B) OR (NOT(B) AND A) OR 0
Step 5 — Simplified result: (NOT(A) AND B) OR (NOT(B) AND A)
This is exactly the XOR expression — confirming that NOT(A AND B) AND (A OR B) = A XOR B.
De Morgan’s laws are the most tested Boolean algebra rules at HL. To apply De Morgan’s: break the NOT across the brackets AND flip the operator (AND becomes OR, OR becomes AND). Common mistake: students flip the operator but forget to apply NOT to each individual variable.
Practice Questions
Q1 — Complete the truth table for a NOR gate with inputs A and B. [2 marks]
Model answer:
| A | B | A NOR B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Award 1 mark for the first row (0,0 → 1) and 1 mark for the remaining three rows all correct.
Q2 — State two differences between system software and application software. [4 marks]
Model answer:
Difference 1: System software manages hardware and provides a platform for other software to run (1 mark), whereas application software performs specific tasks directly for end users (1 mark).
Difference 2: System software runs mostly in the background, often without direct user interaction (1 mark), whereas application software is the software the user directly opens and uses (1 mark).
Q3 — Describe how an operating system manages multitasking on a single-core CPU. [3 marks]
Model answer:
The OS uses a scheduling algorithm (such as round-robin) to allocate CPU time to processes in turn (1 mark). The CPU rapidly switches between processes — each receives a short time slice before control passes to the next process (1 mark). This switching is fast enough that users perceive all processes as running simultaneously, even though the CPU executes only one process at a time (1 mark).
Q4 — State the function of the MAR and MDR during a memory read operation. [4 marks]
Model answer:
The MAR (Memory Address Register) holds the memory address that the CPU wishes to read from (1 mark). The MDR (Memory Data Register) holds the data retrieved from that memory address (1 mark). During a read, the CU copies the required address into the MAR (1 mark); the memory system then places the data at that address into the MDR for the CPU to use (1 mark).
Q5 — Convert the binary number 01101001 to decimal and to hexadecimal. [4 marks]
Model answer:
Binary to decimal:
(2 marks: 1 for correct working, 1 for 105)
Binary to hex:
Split into nibbles: 0110 1001
0110 = 6, 1001 = 9
Hexadecimal = 69 (2 marks: 1 for correct split, 1 for 69)
Q6 — Find the 8-bit two’s complement representation of −23. Show all working. [3 marks]
Model answer:
Step 1 — Write +23 in 8-bit binary: 00010111 (1 mark)
Step 2 — Invert all bits: 11101000 (1 mark)
Step 3 — Add 1: 11101001 (1 mark)
Answer: 11101001
Q7 — State the range of values that can be stored in a 4-bit two’s complement system. [2 marks]
Model answer:
Minimum: (1 mark)
Maximum: (1 mark)
Range: −8 to +7
Q8 — Trace the fetch-decode-execute cycle for the instruction STORE 300, where the accumulator currently holds the value 42 and the PC contains 105. [4 marks]
Model answer:
Fetch: MAR ← 105; MDR ← instruction STORE 300; IR ← STORE 300; PC ← 106 (1 mark)
Decode: CU identifies a memory-write instruction; operand address = 300 (1 mark)
Execute: MAR ← 300 (1 mark); MDR ← 42 (value from ACC) (1 mark); write signal sent; value 42 is written to memory address 300
Q9 — A byte has the value 10101100. Apply an OR operation with mask 00001111. State the result and explain what this operation achieves. [3 marks]
Model answer:
10101100 OR 00001111 = 10101111 (1 mark)
The OR operation sets bits 0–3 (the lower nibble) to 1 (1 mark), while leaving the upper four bits unchanged (1 mark).
Q10 (HL) — Apply De Morgan’s law to simplify NOT(A OR B) and verify using a truth table. [4 marks]
Model answer:
By De Morgan’s second law: NOT(A OR B) = NOT(A) AND NOT(B) (1 mark)
Verification truth table:
| A | B | A OR B | NOT(A OR B) | NOT(A) | NOT(B) | NOT(A) AND NOT(B) |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
All four rows of NOT(A OR B) match NOT(A) AND NOT(B) (3 marks: 1 per correct pair of equivalent columns verified, up to 3).