About

Homework: Exercise L6b

Theory: How to Approach These

Jump to: Q1 · Q2 · Q3


Worked Examples

Exercise Q1

Explain why, in MARIE, the MAR is only 12 bits wide while the AC is 16 bits wide.

PartDetail
AsksExplain the two widths from what each register holds.
NeedsMARIE: 4K words of memory, 16-bit words, instruction = 4-bit opcode + 12-bit address.
Look atMAR holds an address; AC holds data.
If it changesBigger memory widens MAR and PC (16K words → 14 bits); bigger words widen AC, MBR, IR.
Show solution ↓
Solution

How to solve

  1. Say what the MAR holds (an address) and count the memory locations: 4096=2124096 = 2^{12}.
  2. Say what the AC holds (a data word) and give the word size, 16 bits.
  3. Summarise as a rule.

Sample answer

The MAR holds a memory address. MARIE has 4K =4096=212= 4096 = 2^{12} words, so 12 bits name every location (00016\text{000}_{16} to FFF16\text{FFF}_{16}). This matches the 12-bit address field of an instruction.

The AC holds a data word. MARIE’s words and ALU are 16 bits (two’s complement, −32768-32768 to +32767+32767), so the AC must be 16 bits.

MAR width = log⁡2(memory words)=12\log_2(\text{memory words}) = 12; AC width = word size = 16. The PC is also 12 bits; the MBR and IR are 16 bits.

Watch out: do not say the registers differ “because of the opcode”; the reason is address versus data.

Exercise Q2

Explain the steps of the fetch-decode-execute cycle. Your explanation should include what is happening in the various registers.

PartDetail
AsksDescribe each stage and which register changes to what.
NeedsRTN of fetch, decode, get operand, execute (6.3).
Look at“Include what is happening in the registers”: use a trace table with real numbers.
If it changesOnly the execute step differs per instruction; fetch and decode are the same.
Show solution ↓
Solution

How to solve

  1. Fetch: put the PC in the MAR, read the instruction into the IR, increment the PC.
  2. Decode: copy the address field to the MAR and decode the opcode.
  3. Get operand: read memory into the MBR if the instruction needs data.
  4. Execute: do the instruction’s own transfers, then return to fetch (unless Halt).
  5. Show a worked trace with numbers.

Sample answer

  • Fetch: MAR ← PC; IR ← M[MAR]; PC ← PC + 1.
  • Decode: MAR ← IR[11–0]; the control unit decodes the opcode IR[15–12].
  • Get operand: MBR ← M[MAR] (Load, Add, Subt, …).
  • Execute: e.g. AC ← MBR (Load), AC ← AC + MBR (Add). Then back to fetch.

Example: Load 104 at address 100, M[104] = 0023.

StepRTNPCIRMARMBRAC
start100----------------
FetchMAR ← PC100----100--------
IR ← M[MAR]1001104100--------
PC ← PC + 11011104100--------
DecodeMAR ← IR[11–0]1011104104--------
OperandMBR ← M[MAR]10111041040023----
ExecuteAC ← MBR101110410400230023

Roles: PC next instruction; MAR address being accessed; IR current instruction; MBR data to or from memory; AC working value and result.

Watch out: the PC is incremented during fetch, so it already points past the current instruction when it executes.

Exercise Q3

Draw the timing diagram for MARIE’s Load instruction using the format of Figure 4.16.

PartDetail
AsksDraw each control signal high/low over the clock cycles of Load’s execution.
NeedsLoad: MAR ← X; MBR ← M[MAR]; AC ← MBR. Source → P2P1P0P_2P_1P_0, destination → P5P4P3P_5P_4P_3, MRM_R to read memory, CrC_r on the last step.
Look atFigure 4.16 is Add; Load’s last step uses the bus only (no ALU, no A0A_0, no LALTL_{ALT}).
If it changesAny instruction: write its RTL, list signals per TT, draw one row per signal.
Show solution ↓
Solution

How to solve

  1. Write the RTL; fetch and decode use T0T_0–T2T_2, so execution starts at T3T_3.
  2. For each step, source number → P2P1P0P_2P_1P_0 and destination number → P5P4P3P_5P_4P_3 (memory 0, MAR 1, PC 2, MBR 3, AC 4, IR 7).
  3. Add MRM_R for a memory read and CrC_r on the last step.
  4. Draw each signal high in exactly the cycles that list it.
CycleRTLSource → P2P1P0P_2P_1P_0Dest → P5P4P3P_5P_4P_3ExtraSignals = 1
T3T_3
T4T_4
T5T_5

Sample answer

CycleRTLReadWriteExtraSignals
T3T_3MAR ← XIR = 111 → P2P1P0P_2P_1P_0MAR = 001 → P3P_3P3 P2 P1 P0 T3P_3\ P_2\ P_1\ P_0\ T_3
T4T_4MBR ← M[MAR]memory = 000MBR = 011 → P4P3P_4P_3MRM_RP4 P3 T4 MRP_4\ P_3\ T_4\ M_R
T5T_5AC ← MBRMBR = 011 → P1P0P_1P_0AC = 100 → P5P_5CrC_rP5 P1 P0 T5 CrP_5\ P_1\ P_0\ T_5\ C_r
Waveform diagramC3C4C5T3T4T5P0P1P2P3P4P5CrMR

A0A_0, A1A_1, MWM_W and LALTL_{ALT} stay low throughout.

Watch out: the MBR → AC move is over the bus (P1P0P_1P_0), not through the ALU, so there is no A0A_0 or LALTL_{ALT}.