Book 7 · Chapter 2
Logic circuits and hardware
B7·2This chapter is in the ebook.
Read it in full on cswithzak.com. Every question has its mark scheme and every program is ready to run. The free practice for each section is below, with the short code the book prints beside it.
For the whole chapter
- Topic pageLogic circuits and hardware (2029–2031)
B7·2·T - QuizLogic circuits and hardware
B7·2·Q1 - LabLogic Gates Lab — circuits, expressions and truth tables
B7·2·X1 - LabPython example py-logic-gates
B7·2·X2 - LabSystems Lab — the fetch–decode–execute cycle
B7·2·X3
§2.1 Logic circuits
Short code B7·2·1
- FlashcardsFlashcards §2.1: Logic circuits, truth tables & expressions
B7·2·F1
§2.2 CPU architecture
Short code B7·2·2
- FlashcardsFlashcards §2.2: The CPU and its components
B7·2·F2 - FlashcardsFlashcards §2.2: Von Neumann, FDE cycle & performance
B7·2·F3
§2.3 Data storage
Short code B7·2·3
- FlashcardsFlashcards §2.3: Primary & secondary storage, virtual memory
B7·2·F4
Four ways to show the same logic
Short code B7·2·10
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Truth tables for circuits
Short code B7·2·11
Output
Truth table of X = (A AND B) OR NOT C: output column (rows 000 to 111) = 1, 0, 1, 0, 1, 0, 1, 1.
for a in range(2):
for b in range(2):
for c in range(2):
x = (a and b) or (not c)
print(a, b, c, int(x))Output
0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1
From an expression to a circuit
Short code B7·2·12
Output
Truth table of X = (A OR B) AND NOT (B AND C): output column (rows 000 to 111) = 0, 0, 1, 0, 1, 1, 1, 0.
From a circuit to an expression
Short code B7·2·13
Output
Truth table of X = (A XOR B) NOR NOT C: output column (rows 000 to 111) = 0, 1, 0, 0, 0, 0, 0, 1.
From a problem statement
Short code B7·2·14
Output
Truth table of X = (B AND NOT W) OR S: output column (rows 000 to 111) = 0, 0, 1, 1, 1, 0, 1, 1.
From a truth table
Short code B7·2·15
Output
Truth table of X = ((A AND NOT B) AND C) OR ((A AND B) AND C): output column (rows 000 to 111) = 0, 0, 0, 0, 0, 1, 0, 1.
The CPU and the microprocessor
Short code B7·2·16
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Inside the CPU
Short code B7·2·17
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
The Von Neumann architecture
Short code B7·2·18
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
The fetch-decode-execute cycle
Short code B7·2·19
ram = [105, 206, 307, 0, 0, 12, 30, 0]
pc = 0
acc = 0
running = True
while running:
mar = pc
pc = pc + 1
mdr = ram[mar]
cir = mdr
opcode = cir // 100
address = cir % 100
if opcode == 1:
mar = address
mdr = ram[mar]
acc = mdr
elif opcode == 2:
mar = address
mdr = ram[mar]
acc = acc + mdr
elif opcode == 3:
mar = address
mdr = acc
ram[mar] = mdr
else:
running = False
print(pc, mar, mdr, cir, acc)
print(ram[7])Output
1 5 12 105 12 2 6 30 206 42 3 7 42 307 42 4 3 0 0 42 42
What makes a CPU faster
Short code B7·2·20
ghz = 3.2
print(round(ghz * 1000000000), "cycles every second")Output
3200000000 cycles every second
Instruction sets
Short code B7·2·21
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Primary storage
Short code B7·2·22
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
RAM and ROM compared
Short code B7·2·23
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Secondary storage
Short code B7·2·24
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Magnetic storage
Short code B7·2·25
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Solid-state storage
Short code B7·2·26
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Magnetic or solid-state?
Short code B7·2·27
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Virtual memory
Short code B7·2·28
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Past-paper practice
Short code B7·2·90
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Workbook: Logic circuits and hardware
Short code W7·2 · Computer Systems Workbook
The write-in workbook for this chapter has drills, exam-style practice, trace tables, fix-the-mistake and mark-it-yourself pages. Its full mark schemes and an interactive version arrive here with the chapter.


