Introduction to computers — practice with guided problems step by step: tracing the instruction cycle, the clock and a question in the exam format (and the counter that ended up with 226 photos)

The first time I did an instruction-cycle trace on paper, the gallery photo counter came out as 226. There were 199 photos, 3 came in and 1 was deleted: 201 should have been left. What happened? When executing the LOAD I copied the address into the accumulator (0E0, which is 224) instead of the data stored at that address (00C7, 199). Then I added 3 and subtracted 1: 224 + 3 − 1 = 226. Everything done right… on the wrong number. Since then, in every row of a trace I ask myself: «is this an address or data?».

This is the practice for the first paper topic of IC1. In the theory we saw what a computer is, the Von Neumann architecture, the instruction cycle, digital signals and the clock, always with the photo of the whiteboard. Here we solve three problems step by step, the way they are done in the written exam: the result alone is not enough, you have to show the way. For each one you will see the method, the reason for every step, how to check it and the mistakes that come up most. The data still comes from the phone: the gallery counter, sending the photo to the laptop and the parts involved in taking it.

Before you start

Make sure you are clear on:

  • What PC, MAR, MBR and IR do and the four steps of fetch.
  • The kinds of execution of an instruction (processor-memory, processor-I/O, processing, control and combinations).
  • That f=1/T f = 1/T and the prefixes: ms ↔ kHz, µs ↔ MHz, ns ↔ GHz.
  • How a timing diagram is drawn: one bit per clock period, in positive logic.

If any of them feels shaky, review the theory before carrying on.

Have squared paper and a pencil at hand. Timing diagrams and trace tables are much easier on a grid, and there is no calculator in the exam: the arithmetic in this topic is designed to be done by hand.

How to solve a paper problem

The three problems follow the same four-step method. I put it here once so I do not repeat it:

  1. Write down the data with its units and in the format given (hexadecimal, µs…). Underline what is being asked.
  2. Decide the method before calculating: a trace table? A formula? A drawing? Write the formula in general before plugging in numbers.
  3. Solve in order, showing every step. In a written exam, a result with no working is worth little, and well-done working with a slip at the end is worth almost everything.
  4. Check with something independent: a calculation in decimal, the order of magnitude, the number of rows in the table.

Problem 1: tracing the instruction cycle

Statement. A simple computer has 16-bit words: the 4 most significant bits are the operation code and the remaining 12, a memory address. It has an accumulator (AC) and the registers PC, MAR, MBR and IR. The codes are: 1 LOAD (AC ← M[addr]), 2 STORE (M[addr] ← AC), 5 ADD (AC ← AC + M[addr]), 6 SUB (AC ← AC − M[addr]) and F HALT. To update the gallery photo counter, memory holds this (all in hexadecimal):

AddressContentsMeaning
04010E0
04150E1
04260E2
04320E0
044F000
0E000C7photos in the gallery
0E10003new photos
0E20001deleted photos

PC is 040. a) Write what each instruction does. b) Trace it: the value of PC, MAR, MBR, IR and AC at the end of each phase (fetch and execute). c) What is left at address 0E0? d) How many memory accesses does the program make?

The idea

A trace is a table: one row per phase and one column per register. Since fetch is always the same, you can almost do it from memory; the thinking happens in execute, by looking at the operation code. The order is:

  1. Decode every instruction before you start (part a): that way you know when to stop.
  2. Fill in the table phase by phase, changing only the registers that phase touches. The others are copied from the previous row.
  3. At the end, look at what changed in memory and count the accesses.

Before tracing, think about what should come out: 199 photos + 3 − 1 = 201. If you do not end up with 00C9 (201 in hexadecimal), there is a mistake in some step.

Step by step

a) Decode. The first hexadecimal digit (4 bits) is the code; the other three, the address:

AddressInstructionCodeOperand addressWhat it does
04010E01 = LOAD0E0AC ← M[0E0]: loads the photos there were
04150E15 = ADD0E1AC ← AC + M[0E1]: adds the new ones
04260E26 = SUB0E2AC ← AC − M[0E2]: subtracts the deleted ones
04320E02 = STORE0E0M[0E0] ← AC: stores the result over the counter
044F000F = HALT—Halts

Why is it enough to cover the first digit? Because every hexadecimal digit is exactly 4 bits. A 16-bit word is 4 digits: the 4 most significant bits are the first digit and the remaining 12 are the other three. For example, 10E0 = 0001 0000 1110 0000: the first group, 0001, is code 1 (LOAD), and 0000 1110 0000 is the address 0E0. In hexadecimal you do not need to go through binary to decode.

b) The trace. We start with PC = 040. In every fetch: MAR ← PC, MBR ← M[MAR], IR ← MBR, PC ← PC + 1.

Before the whole table, the first instruction slowly. Each step is a single transfer between registers:

StepTransferResultWhy
1MAR ← PCMAR = 040Memory only receives addresses through the MAR, and the instruction’s address is in PC
2MBR ← M[MAR]MBR = 10E0Everything that comes from memory enters through the MBR
3IR ← MBRIR = 10E0The control unit needs the instruction to sit still in IR so it can decode it
4PC ← PC + 1PC = 041That way PC already points to the next instruction; this is where fetch ends
5Decode IR1 = LOAD, address 0E0First digit, the code; the other three, the operand address
6MAR ← address in IRMAR = 0E0Now we are asking for data, so the MAR carries the data’s address, not PC’s
7MBR ← M[MAR]MBR = 00C7The data arrives, once again, through the MBR
8AC ← MBRAC = 00C7LOAD copies the data (199), not the address (0E0, which is 224)

Steps 1-4 are the «Fetch 1» row of the table and steps 5-8, the «Execute LOAD» row: the table only records how the registers end up at the end of each phase. The other four instructions repeat the same fetch and only the execution changes: in ADD and SUB the last step is AC ← AC + MBR or AC ← AC − MBR, and in STORE the data travels the other way, from AC to the MBR and from there to memory.

PhasePCMARMBRIRACWhat happened
Fetch 104104010E010E0—LOAD 0E0 is fetched; PC already points to 041
Execute LOAD0410E000C710E000C7MAR ← 0E0, MBR ← M[0E0], AC ← MBR
Fetch 204204150E150E100C7ADD 0E1 is fetched
Execute ADD0420E1000350E100CA00C7 + 0003 = 00CA
Fetch 304304260E260E200CASUB 0E2 is fetched
Execute SUB0430E2000160E200C900CA − 0001 = 00C9
Fetch 404404320E020E000C9STORE 0E0 is fetched
Execute STORE0440E000C920E000C9MAR ← 0E0, MBR ← AC, M[0E0] ← MBR
Fetch 5045044F000F00000C9HALT is fetched: the CPU halts

The AC sums are done in hexadecimal without converting to decimal. In 00C7 + 0003, the last digit is 7 + 3 = 10, which in hexadecimal is written A, and nothing is carried (you only carry one when the digit reaches 16): 00CA. In 00CA − 0001, A − 1 = 9: 00C9. It works just like decimal, but the «ten» here is 16.

The diagram freezes one moment of the table, right after fetch 3:

The trace of problem 1, frozenState of memory and registers right after fetching the SUB instruction at address 042.Memory04010E0LOAD 0E004150E1ADD 0E104260E2SUB 0E204320E0STORE 0E0044F000HALT0E000C7photos0E10003new0E20001deletedCPU after fetching SUBPC043already points to the next oneMAR042address requestedMBR60E2what came over the busIR60E2SUB 0E2, ready to decodeAC00CA199 + 3 = 202 (so far)data bus
After fetching: PC is already 043, MAR holds 042 and the instruction has travelled through MBR into IR. AC has not subtracted yet.

Notice three details the exam looks at:

  • In every fetch, PC ends up one more than MAR.
  • In execute, MAR holds the operand address (the low part of IR), not PC.
  • In STORE, MBR is not filled from memory: it is filled from AC and goes to memory.

c) 0E0 held 00C7 and STORE overwrites it with 00C9. The counter is now 00C9.

d) Five fetches (one per instruction, HALT included) and four data accesses (LOAD, ADD, SUB and STORE): 9 accesses.

Check

Convert to decimal: 00C7 = 12 · 16 + 7 = 199; 00CA = 12 · 16 + 10 = 202; 00C9 = 201. And 199 + 3 − 1 = 201. It adds up. Besides, the table has 9 rows: 5 fetches + 4 executes (HALT’s does nothing), which matches part d) if you count that each execution of LOAD, ADD, SUB and STORE goes to memory once.

Questions you might ask

Why is PC 041 if the instruction at 040 is being executed? Because step 4 of fetch (PC ← PC + 1) happens before executing. PC always points to the next one.

Why does MAR change to 0E1 when executing ADD? Because ADD needs data from memory: the address of that data is in IR (50E1 → 0E1) and it is copied to MAR to request it over the bus.

Does IR change during execute? No. It is loaded during fetch and stays put until the next fetch: the control unit needs it to know what to do.

What if they ask for the values in decimal? Do the trace in hexadecimal (that is how memory is) and convert only the final result. Mixing bases inside the table is the quickest way to get it wrong.

What happens to AC during fetch? Nothing: fetch does not touch it. That is why it is copied from the previous row in the table.

What would happen if 041 held 50E0 instead of 50E1?

The fetches do not change, because they only depend on PC. What changes is the execution of ADD: its operand is now at 0E0, so in that row MAR is 0E0 and MBR is 00C7, instead of 0E1 and 0003.

  • ADD: AC = 00C7 + 00C7 = 018E (199 + 199 = 398).
  • SUB: AC = 018E − 0001 = 018D (397).
  • STORE: 0E0 ends up holding 018D.

The gallery would say 397 photos. There are still 9 accesses: the program makes the same reads, just to a different address. A single digit of the address changes which data gets added, and the trace shows it right in the «Execute ADD» row. It is the same «where or what?» slip, seen from the other side.

Loading the address (0E0) into AC instead of the contents (00C7). That is what happened to me: 224 + 3 − 1 = 226 photos. Ask yourself at every step «is this where or what?».

Try it yourself

  • Change 0E1 to 0010 (16 new photos) and redo only the rows that change. What is left at 0E0?
  • Swap the instructions at 041 and 042 (first SUB, then ADD). Does the result change? And the trace?

Problem 2: the clock and timing diagrams

Statement. The phone sends the photo to the laptop over a cable that transmits one bit per clock period. The bit period is 250 ns. a) What frequency does the clock run at? b) Draw the timing diagram of the clock and of two positive-logic signals: A = 10110010 and B = 01100110. c) In which cycles are both 1 at the same time? How many rising edges does A have? d) How long does it take to send the 8 bits of A? And a 3 MB photo (megabytes, 1 MB = 106 10^6 bytes)? e) The phone’s processor runs at 2.4 GHz. What is its clock period?

The idea

Everything comes from one formula and one drawing rule:

  • f=1/T f = 1/T and T=1/f T = 1/f , being careful with prefixes.
  • One bit per period: the total time is the number of bits times the bit period, and in the timing diagram each bit takes up one clock column.

Without a calculator, work with powers of 10: 250 ns = 250⋅10−9 250 \cdot 10^{-9} s = 2.5⋅10−7 2.5 \cdot 10^{-7} s. And remember that dividing by 250 is multiplying by 4 and dividing by 1000.

Step by step

a) Frequency.

f=1T=1250⋅10−9 s=109250 Hz=4⋅106 Hz=4 MHz f = \frac{1}{T} = \frac{1}{250 \cdot 10^{-9}\ s} = \frac{10^{9}}{250}\ \text{Hz} = 4 \cdot 10^{6}\ \text{Hz} = 4\ \text{MHz}

Quick check with the prefix rule: 250 ns = 0.25 µs, so the frequency is 1/0.25=4 1/0.25 = 4 MHz.

b) Timing diagram. First draw the clock: 8 equal periods. Then, underneath, each signal: one bit per period, high if it is 1 and low if it is 0. Write the bit inside each column so you do not get lost:

Problem 2: timing diagram of A and BClock, A = 10110010 and B = 01100110 with a 250 ns period; shaded, cycles 2 and 6, where A and B are both 1.clockA10110010B01100110period
The shaded cycles (counting from 0) are the only ones with A = B = 1.

c) Column by column (counting from 0):

Cycle01234567
A10110010
B01100110
A and B at 1NoNoYesNoNoNoYesNo

They are both 1 in cycles 2 and 6. Rising edges of A: every time it goes from 0 to 1. If we assume it was at 0 before the first cycle, it rises in cycle 0, in cycle 2 and in cycle 6: 3 rising edges.

To make sure you do not miss one, compare each cycle with the previous one:

CycleBeforeNowRises?Why
00 (assumed)1YesGoes from 0 to 1
110NoFalls: it is a falling edge
201YesGoes from 0 to 1
311NoStays high: no edge
410NoFalls
500NoStays low
601YesGoes from 0 to 1
710NoFalls

Every rising edge starts a group of consecutive ones. A = 1 0 11 00 1 0 has three groups of ones (1, 11 and 1), so it has three rising edges.

d) Times. 8 bits · 250 ns = 2000 ns = 2 µs. For the photo: 3 MB = 3⋅106⋅8=24⋅106 3 \cdot 10^{6} \cdot 8 = 24 \cdot 10^{6} bits, and

t=24⋅106⋅250⋅10−9 s=6000⋅10−3 s=6 s t = 24 \cdot 10^{6} \cdot 250 \cdot 10^{-9}\ s = 6000 \cdot 10^{-3}\ s = 6\ s

The same calculation slowly, without a calculator:

StepCalculationWhy
13 MB = 3 · 10610^{6} bytesThe statement fixes 1 MB = 10610^{6} bytes
23 · 10610^{6} · 8 = 24 · 10610^{6} bitsEvery byte is 8 bits
3t = 24 · 10610^{6} · 250 · 10−910^{-9} sOne bit per period: time = bits · bit period
4(24 · 250) · (10610^{6} · 10−910^{-9})The numbers on one side and the powers of 10 on the other
524 · 250 = 6000250 is 1000 / 4: 24 / 4 = 6, then times 1000
610610^{6} · 10−910^{-9} = 10−310^{-3}When multiplying powers of 10 you add the exponents: 6 + (−9) = −3
76000 · 10−310^{-3} s = 6 sMultiplying by 10−310^{-3} is dividing by 1000

e)

T=12.4⋅109 Hz≈0.417⋅10−9 s=0.417 ns T = \frac{1}{2.4 \cdot 10^{9}\ \text{Hz}} \approx 0.417 \cdot 10^{-9}\ s = 0.417\ \text{ns}

1 / 2.4 by hand: multiply top and bottom by 10 and simplify, 10 / 24 = 5 / 12. And 5 / 12 = 0.4166…, which rounds to 0.417. To check it without dividing: 2.4 is a bit more than 2, so the period has to be a bit less than 1 / 2 = 0.5 ns. And the prefix comes for free: GHz ↔ ns.

Check

Order of magnitude: a cable at 4 MHz is very slow compared with a processor at 2.4 GHz (about 600 times slower: 2400/4=600 2400/4 = 600 ), so it makes sense that sending a photo takes seconds and that a CPU cycle lasts less than a nanosecond. And 6 s · 4 MHz = 24 million periods = 24 million bits. It adds up.

Questions you might ask

Why are 3 MB 24 million bits and not 24? Because M is a million and every byte is 8 bits. In the exam, if they give MB, check whether they say 106 10^6 or 220 2^{20} bytes; here the statement fixes it.

Does the start of the signal count as a rising edge? It depends on what was there before. That is why I stated it: «assuming it was at 0 before». If the statement does not say, write down your assumption.

Does the clock have to be high for half the period? In the drawings we show it that way (50 % duty cycle), but what matters for the bits is the whole period.

What would happen if the statement said 1 MB = 2²⁰ bytes?

Only the number of bits to send changes; the frequency and the bit period stay the same.

  • 2202^{20} = 1,048,576 bytes, so 3 MB = 3,145,728 bytes.
  • Times 8: 25,165,824 bits.
  • Times 250 ns: 6,291,456,000 ns, about 6.29 s.

That is about 0.29 s more than with 10610^{6}: 2202^{20} is 4.9 % bigger than 10610^{6}, and the time grows in the same proportion. That is why, if the statement does not say, you should write down which value you are using before you start the calculation.

Saying that 2.4 GHz gives a period of 2.4 ns. If the frequency goes up, the period goes down: you have to invert.

Try it yourself

  • Redo a), d) and e) with a bit period of 125 ns and a 3.2 GHz processor.
  • Draw the timing diagram of A and B with their AND (a third signal that is 1 only when both are 1). Does it match the table in part c)?

Problem 3: a question in the exam format

In the IC1 theory exam (2 hours, 7-9 questions adding up to 11 marks out of 10) each question comes with its marks and some boxes for the answer, with space below for the working. Topics 1 and 2 of the notes do not have a fixed question of their own, but their ideas show up inside others (classifying peripherals, understanding a trace, the clock in performance). This question is original and written in that format, so you can practice answering quickly and well.

Question (1 mark). The phone executes, among others, the instructions in the table. a) Give the kind of execution of each one (processor-memory, processor-I/O, data processing, control or combination) [0.5 marks]. b) Say which level of the memory hierarchy each piece of data will be in [0.25 marks]. c) With the logic levels VL(max)=0.8 V_{L(max)} = 0.8 V and VH(min)=2.0 V_{H(min)} = 2.0 V, give the logic value of each voltage [0.25 marks].

a) InstructionKind of execution
LOAD 0E0 (our machine)___
STORE 0E0___
add $t2, $t0, $t1 (MIPS)___
JUMP 204___
ADD 0E1 (our machine: adds a value from memory)___
b) DataLevel
The index of a loop used in every iteration___
The row of the photo the filter is going through___
The whole photo while you edit it___
The photo in the gallery after switching the phone off___
c) VoltageLogic value
0.5 V___
2.4 V___
1.1 V___
3.0 V___

The idea

It is a classification question, and in classification marks are lost for two reasons: not knowing the criterion or not reading the row properly. The method: for each row, ask yourself what the instruction moves and between whom (a), how long and how often that data is used (b) and which range the voltage falls into (c).

Step by step

a) InstructionKindWhy
LOAD 0E0Processor ↔ memoryBrings data from memory into the CPU
STORE 0E0Processor ↔ memoryTakes data from the CPU to memory
add $t2, $t0, $t1Data processingOperates on registers; does not touch memory
JUMP 204ControlOnly changes PC
ADD 0E1CombinationReads data from memory and operates on it

The last row is the trap: the name «ADD» invites you to say «processing», but in our machine the second operand comes from memory, so it does two kinds of thing. In MIPS, on the other hand, add only works with registers: that is why MIPS separates lw (memory) from add (processing). You saw it in MIPS load, arithmetic and logic.

What would happen if our machine had an ADD that added two registers, like the MIPS one?

It would simply be data processing: during execution it would not go to memory. What decides the kind is not the instruction’s name, but what its execution touches:

  • Only CPU registers: data processing.
  • Memory: processor-memory.
  • An I/O module: processor-I/O.
  • Only PC: control.
  • More than one of these: combination.

Our machine’s ADD 0E1 touches memory and also operates, which is why it is a combination.

b) DataLevelWhy
Loop indexRegistersUsed in every iteration: the most used goes to the fastest
Row the filter is going throughCacheFew data, close together and reused (locality)
The whole photo while editingMain memoryThe program has it open, but it does not fit in the cache
The photo after switching offSecondary memoryMain memory is erased when powered off; only secondary keeps it
c) VoltageValueWhy
0.5 V00.5≤0.8 0.5 \le 0.8 : low level
2.4 V12.4≥2.0 2.4 \ge 2.0 : high level
1.1 VNeither 0 nor 1Between 0.8 and 2.0: forbidden zone
3.0 V1High level

Checking and how it is marked

Make sure every box has something in it: in these questions each box is usually worth the same (in a, 0.5 / 5 = 0.1 each; in b and c, 0.25 / 4 = 0.0625), so an empty box is a part lost for sure. And if you are unsure about one, write a line of justification: in a written exam, correct reasoning can save a debatable answer (like ADD 0E1).

Answering «0» for the 1.1 V voltage because «it is closer to 0.8». The forbidden zone is not rounded.

Try it yourself

  • Add to table a) an instruction that reads the key pressed from an I/O module and another that adds and also jumps if the result is zero. What kind are they?
  • In b), where would the camera app be while you use it? And its downloaded installer?

Common mistakes in this practice

  • Loading the address instead of the data: MAR holds addresses; MBR and AC, data.
  • Incrementing PC during execute: it is incremented at the end of fetch.
  • Not copying the registers that do not change: in a trace table, an empty box does not mean «same as before» to whoever marks it. Copy them.
  • Forgetting to invert when going from frequency to period, or getting the prefix wrong (ns ↔ GHz, µs ↔ MHz).
  • Drawing signal changes mid-period in a timing diagram.
  • Leaving boxes empty in a classification question: each one is worth marks.

Check it with Python

The idea of the program, before you see it: memory is a dictionary that maps an address to its contents, and the registers are variables (pc, mar, mbr, ir, ac). A while loop repeats the fetch (the first line of code in the loop: the four transfers plus counting the access) and the execution (one if per operation code) until it reaches HALT. To decode, ir >> 12 keeps the 4 most significant bits, the code, and ir & 0xFFF the 12 least significant bits, the address: the same thing you did by hand when you covered the first digit. And the accesses variable adds 1 every time the program reads from or writes to mem.

I ran problem 1 through the toy machine from the theory, changing only the program and the data. Run once:

# A toy Von Neumann machine: 16-bit words = operation code (4 bits) + address (12 bits)
OPS = {0x1: "LOAD", 0x2: "STORE", 0x5: "ADD", 0x6: "SUB", 0x8: "JUMP", 0xF: "HALT"}

# Practice problem 1: update the gallery photo counter
mem = {0x040: 0x10E0,   # LOAD  0E0 -> AC = photos there were
       0x041: 0x50E1,   # ADD   0E1 -> + new photos
       0x042: 0x60E2,   # SUB   0E2 -> - deleted photos
       0x043: 0x20E0,   # STORE 0E0 -> the counter is overwritten
       0x044: 0xF000,   # HALT
       0x0E0: 0x00C7,   # photos in the gallery (199)
       0x0E1: 0x0003,   # new photos (3)
       0x0E2: 0x0001}   # deleted photos (1)

pc, ac, accesses, h = 0x040, 0, 0, lambda v, n=4: f"{v:0{n}X}"
while True:
    # Fetch cycle: the address comes from PC, the instruction arrives through MBR and ends up in IR
    mar = pc; mbr = mem[mar]; ir = mbr; pc += 1; accesses += 1
    op, addr = ir >> 12, ir & 0xFFF
    print(f"fetch      PC={h(pc,3)}  MAR={h(mar,3)}  MBR={h(mbr)}  IR={h(ir)}  -> {OPS[op]} {h(addr,3)}")
    # Execute cycle: depends on the operation code
    if op == 0xF:
        print("execute    HALT: the CPU stops"); break
    elif op == 0x8:
        pc = addr                                    # control: breaks the sequence
    elif op == 0x2:
        mar = addr; mbr = ac; mem[mar] = mbr; accesses += 1   # processor -> memory
    else:
        mar = addr; mbr = mem[mar]; accesses += 1    # memory -> processor
        ac = mbr if op == 0x1 else (ac + mbr if op == 0x5 else ac - mbr)
    print(f"execute    MAR={h(mar,3)}  MBR={h(mbr)}  AC={h(ac)}  PC={h(pc,3)}")

print(f"\nCounter at 0E0: {h(mem[0x0E0])} = {mem[0x0E0]}")
print("Memory accesses:", accesses, "(one per fetch and one per LOAD, ADD, SUB or STORE)")

Output:

fetch      PC=041  MAR=040  MBR=10E0  IR=10E0  -> LOAD 0E0
execute    MAR=0E0  MBR=00C7  AC=00C7  PC=041
fetch      PC=042  MAR=041  MBR=50E1  IR=50E1  -> ADD 0E1
execute    MAR=0E1  MBR=0003  AC=00CA  PC=042
fetch      PC=043  MAR=042  MBR=60E2  IR=60E2  -> SUB 0E2
execute    MAR=0E2  MBR=0001  AC=00C9  PC=043
fetch      PC=044  MAR=043  MBR=20E0  IR=20E0  -> STORE 0E0
execute    MAR=0E0  MBR=00C9  AC=00C9  PC=044
fetch      PC=045  MAR=044  MBR=F000  IR=F000  -> HALT 000
execute    HALT: the CPU stops

Counter at 0E0: 00C9 = 201
Memory accesses: 9 (one per fetch and one per LOAD, ADD, SUB or STORE)

What to watch:

  1. Each pair of lines (fetch + execute) is a pair of rows in our table: compare them.
  2. In the fetch of SUB, AC is still 00CA: the diagram of the problem freezes exactly that moment.
  3. The execution of STORE writes to 0E0, which is also where LOAD read from: the counter is overwritten.
  4. The 9 accesses come from counting them in the code: 5 fetches + 4 data accesses.

Summary

  • A trace is a table with one row per phase and one column per register; what does not change is copied.
  • Fetch is always MAR ← PC, MBR ← M[MAR], IR ← MBR, PC ← PC + 1.
  • In execute, MAR takes the operand address from IR; MBR carries the data in whichever direction applies.
  • Frequency and period are inverses: f=1/T f = 1/T ; 250 ns ↔ 4 MHz and 2.4 GHz ↔ 0.417 ns.
  • The sending time is bits · bit period.
  • In classification questions, the criterion matters more than the name: ADD 0E1 is a combination.

Checklist: have you practised it?

  • Can you do the fetch from memory, without looking?
  • Do you tell, in every row of a trace, whether a value is an address or data?
  • Do you go from MHz to ns and from GHz to ns without doubting the prefix?
  • Have you drawn the timing diagram of A and B yourself without looking at the one in the article?
  • Have you reviewed the three solutions and checked the arithmetic?
  • Have you tried the «Try it yourself» ideas without looking at the theory?

If you answered yes to almost everything, you are ready for the introduction to computers exercises, where I no longer give you the solution ready-made. See you there!

Next step: exercisesIntroduction to computers — solved exercises with timing diagrams, a trace with a jump, a row of the photo in 2 bits and a practice quiz (and the 2.5 GHz I turned into 2.5 ns)

Did this article help you? Here is how you can support SergioLearns →