Skip to content
Book 7: Computer Systems

Book 7 · Chapter 2

Logic circuits and hardware

§2.1§2.2§2.3Exam craftB7·2

This 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.

Open in the ebook

§2.1 Logic circuits

Short code B7·2·1

§2.2 CPU architecture

Short code B7·2·2

§2.3 Data storage

Short code B7·2·3

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

The Logic Gates Lab's answer for X = (A AND B) OR NOT C. Compare it with the X column of the table above.

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.
Run and checked before printing
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))
Three nested loops count through the eight rows in order, 000 to 111. Notice that the output column matches the table.

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
Run and checked before printing

From an expression to a circuit

Short code B7·2·12

Check your drawing: the circuit for X = (A OR B) AND NOT (B AND C) has this output column.

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.
Run and checked before printing

From a circuit to an expression

Short code B7·2·13

The expression read from the circuit, checked by the Logic Gates Lab.

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.
Run and checked before printing

From a problem statement

Short code B7·2·14

The drone: inputs in the order B, S, W. X is 1 whenever S is 1, and when B is 1 with W at 0.

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.
Run and checked before printing

From a truth table

Short code B7·2·15

The circuit drawn from the truth table gives back exactly the table it came from: 1s in rows 101 and 111 only.

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.
Run and checked before printing

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])
The model CPU: each line is PC, MAR, MDR, CIR and ACC at the end of one fetch-decode-execute cycle; the last line is the value stored at address 7.

Output

1 5 12 105 12
2 6 30 206 42
3 7 42 307 42
4 3 0 0 42
42
Run and checked before printing

What makes a CPU faster

Short code B7·2·20

ghz = 3.2
print(round(ghz * 1000000000), "cycles every second")
From gigahertz to cycles per second: 1 GHz is one billion (10⁹) cycles each second.

Output

3200000000 cycles every second
Run and checked before printing

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.

Ask Z about Logic circuits and hardware
Buy ZAK's books — WhatsApp the books desk: Buy the booksPrint or ebook