About

Homework: Exercise L7 (Control Unit)

Theory: How to Approach These

Jump to: Q1 · Q2 · Q3 · Q4 · Q5


Worked Examples

Exercise Q1

Suppose we add the following instruction to MARIE’s ISA:

JumpOffset X

This instruction will jump to the address calculated by adding the given address, X, to the contents of the accumulator. Show how this instruction would be executed using RTN.

PartDetail
AsksWrite the register transfers that make PC = X + AC.
NeedsALU adds only AC + MBR; X is IR[11–0]; the PC loads from the bus.
Look atX is a value here, not a data address, so no memory read.
If it changesNew instruction: decide what ends where, move operands to MBR/AC, copy the result to its destination.
Show solution ↓
Solution

How to solve

  1. Put X into the MBR so the ALU can use it.
  2. Add: AC ← AC + MBR.
  3. Copy the sum to the PC.

Sample answer

MBR <- X            / X = IR[11-0]
AC  <- AC + MBR     / AC = AC + X
PC  <- AC           / jump to the computed address

These run after the normal fetch and decode. Example: AC = 0005, JumpOffset 100: MBR = 0100, AC = 0105, PC = 105, so the next instruction is fetched from 105.

Watch out: the AC is overwritten with the target address, and only its low 12 bits go into the PC. Do not read memory at X.

Exercise Q2

Using the coding given in Table 4.9, translate into binary the mnemonic microcode instructions given in Figure 4.23 for the fetch-decode cycle (the first nine lines of the table).

AddressMicroOp 1MicroOp 2JumpDest.
0000000MAR ← PCNOP00000000
0000001IR ← M[MAR]NOP00000000
0000010PC ← PC + 1NOP00000000
0000011MAR ← IR[11-0]NOP00000000
0000100If IR[15-12] = MicroOP2[4-1]0000010100000
0000101If IR[15-12] = MicroOP2[4-1]0001010100111
0000110If IR[15-12] = MicroOP2[4-1]0010010101010
0000111If IR[15-12] = MicroOP2[4-1]0011010101100
0001000If IR[15-12] = MicroOP2[4-1]0100010101111
AddressMicroOp 1MicroOp 2JumpDest.
000000000000000
000000100000000
000001000000000
000001100000000
000010010100000
000010110100111
000011010101010
000011110101100
000100010101111
PartDetail
AsksReplace each mnemonic with its 5-bit code; the other columns are already binary.
NeedsNOP 00000, IR ← M[MAR] 00110, MAR ← IR[11–0] 01000, MAR ← PC 01010, PC ← PC + 1 10001, If IR[15–12] = MicroOp2[4–1] 11000.
Look atOnly MicroOp1 (and NOP) need translating; lines 4–8 already hold binary MicroOp2.
If it changesOther lines: look up codes in Table 4.9; the 5 + 5 + 1 + 7 layout stays.
Show solution ↓
Solution

How to solve

  1. Look up each MicroOp1 code in Table 4.9 (NOP = 00000 in MicroOp2).
  2. Copy Jump and Dest unchanged.
  3. Concatenate into the 18-bit word: 5 + 5 + 1 + 7.

Sample answer

AddressMicroOp 1MicroOp 2JumpDest.18-bit word
0000000010100000000000000010100000000000000
0000001001100000000000000001100000000000000
0000010100010000000000000100010000000000000
0000011010000000000000000010000000000000000
0000100110000000010100000110000000010100000
0000101110000001010100111110000001010100111
0000110110000010010101010110000010010101010
0000111110000011010101100110000011010101100
0001000110000100010101111110000100010101111

Lines 4–8 are the jump table: MicroOp2 bits 4–1 hold the opcode tested (0000 JnS → 32, 0001 Load → 39, 0010 Store → 42, 0011 Add → 44, 0100 Subt → 47). Each word is 5+5+1+7=185+5+1+7 = 18 bits ✓.

Watch out: keep the field order MicroOp1 | MicroOp2 | Jump | Dest and every leading zero.

Exercise Q3

You and a colleague are designing a brand new microprocessor architecture. Your colleague wants the processor to support 509 different instructions. You do not agree, and would like to have many fewer instructions. Outline the argument for a position paper to present to the management team that will make the final decision. Try to anticipate the argument that could be made to support the opposing viewpoint.

PartDetail
AsksAn essay outline: your position (fewer instructions), reasons, the other side’s reasons, your replies.
NeedsHardwired vs microprogrammed control, RISC vs CISC, opcode bits =⌈log⁡2n⌉= \lceil \log_2 n \rceil.
Look at“Anticipate the opposing argument”: include it and rebut it.
If it changesDefending 509 instead: swap sides, keep the same structure.
Show solution ↓
Solution

How to solve

  1. State a clear thesis.
  2. Give technical arguments with numbers where possible.
  3. List the strongest opposing points with a rebuttal each.
  4. End with a recommendation.

Sample answer

1. Thesis. A small, regular instruction set (tens, not hundreds) is faster, cheaper and quicker to build than one with 509 instructions.

2. Arguments for fewer instructions

PointArgument
Simpler controlControl can be hardwired, faster than microprogrammed.
Faster clockSimpler logic has shorter paths, so a higher clock.
PipeliningUniform, simple instructions pipeline well (near one per cycle).
Opcode size509 instructions need ⌈log⁡2509⌉=9\lceil \log_2 509 \rceil = 9 bits; 32–64 need 5–6, leaving room for registers and addresses.
CompilersUse a small subset most of the time; rare instructions still cost chip area.
Area and powerSaved area goes to registers and cache.
CostFewer instructions to design and test: lower cost, fewer bugs, faster to market.

3. Opposing arguments and rebuttals

Opposing argumentRebuttal
Programs are shorter and use less memory.Memory is cheap; caches hide the cost.
Fewer instruction fetches.A pipelined design with caches runs several simple instructions in the time of one complex one.
Complex operations in hardware are faster.Add only the few that measurements show are really used.
Easier for assembly programmers and compilers.Compilers generate the code; few people write assembly.
Backward compatibility.A brand-new architecture has no legacy code.
Microcode makes adding instructions easy.It slows every instruction.

4. Recommendation. A small, regular instruction set with hardwired, pipelined control; spend the saved area on registers and cache; add specific complex instructions only if benchmarks show a need.

Watch out: an essay with no opposing view and no rebuttal misses the question; “fewer is simpler” alone is not an argument.

Exercise Q4

Using Figure 4.23 as a guide, write the binary microcode for MARIE’s Load instruction. Assume that the microcode begins at instruction line number 011000020110000_2.

Hint: For Load:

  • MAR ← IR[11-0] or MAR ← X
  • MBR ← M[MAR]
  • AC ← MBR
AddressMicroOp 1MicroOp 2JumpDest.
0110000
0110001
0110010
PartDetail
AsksOne binary line per microoperation of Load, at 0110000, 0110001, 0110010.
NeedsMAR ← IR[11–0] 01000, MBR ← M[MAR] 01101, AC ← MBR 00010, NOP 00000. Fall through with Jump 0; last line Jump 1, Dest 0000000.
Look atOnly the last line jumps back to fetch.
If it changesOther instruction: write its RTL, one line per step, last line Jump = 1, Dest = 0000000.
Show solution ↓
Solution

How to solve

  1. Write Load’s three microoperations in order.
  2. Put each code in MicroOp1 with NOP in MicroOp2.
  3. Set Jump = 0 on the first two lines; on the last set Jump = 1, Dest = 0000000 to return to fetch.

Sample answer

AddressMicroOp 1MicroOp 2JumpDest.
011000001000 (MAR ← IR[11-0])0000000000000
011000101101 (MBR ← M[MAR])0000000000000
011001000010 (AC ← MBR)0000010000000

As 18-bit words:

0110000:  01000 00000 0 0000000
0110001:  01101 00000 0 0000000
0110010:  00010 00000 1 0000000

To reach this routine the jump table needs the line 11000 | 00010 | 1 | 0110000 (if opcode = 0001, Load, jump to 0110000).

Watch out: forgetting Jump = 1 on the last line leaves the machine running into the next routine.

Exercise Q5

Which control signals should contain a 1 for each step in executing the JUMPI instruction?

OpcodeInstructionRTN
1100JumpI XMAR ← X
MBR ← M[MAR]
PC ← MBR
StepRTNTimeP5P_5P4P_4P3P_3P2P_2P1P_1P0P_0CrC_rIncrPCMRM_RMWM_WLALTL_{ALT}
FetchMAR ← PCT0T_0
IR ← M[MAR]T1T_1
Decode IR[15-12]PC ← PC + 1T2T_2
Get operandMAR ← IR[11-0]T3T_3
ExecuteMBR ← M[MAR]T4T_4
PC ← MBRT5T_5
PartDetail
AsksFor T0T_0 to T5T_5, mark every control signal that is 1.
NeedsMemory 000, MAR 001, PC 010, MBR 011, AC 100, IR 111. Source → P2P1P0P_2P_1P_0, destination → P5P4P3P_5P_4P_3; MRM_R to read memory; CrC_r on the last step.
Look atThe last step’s destination is the PC (010 → P4P_4), not the AC.
If it changesAnother instruction: write its RTL, then fill the same table.
Show solution ↓
Solution

How to solve

  1. Per step, convert the source register to bits on P2P1P0P_2P_1P_0 and the destination register to bits on P5P4P3P_5P_4P_3.
  2. Add MRM_R for a memory read and IncrPC for PC ← PC + 1.
  3. Add CrC_r on the last step to reset the cycle counter.

Sample answer

StepRTNTimeP5P_5P4P_4P3P_3P2P_2P1P_1P0P_0CrC_rIncrPCMRM_RMWM_WLALTL_{ALT}
FetchMAR ← PCT0T_000101000000
IR ← M[MAR]T1T_111100000100
Decode IR[15-12]PC ← PC + 1T2T_200000001000
Get operandMAR ← IR[11-0]T3T_300111100000
ExecuteMBR ← M[MAR]T4T_401100000100
PC ← MBRT5T_501001110000

How each row is found:

  • T0T_0: read PC (010 → P1P_1), write MAR (001 → P3P_3).
  • T1T_1: read memory (000, so MRM_R), write IR (111 → P5P4P3P_5P_4P_3).
  • T2T_2: no bus transfer; IncrPC adds 1 to the PC while IR[15-12] is decoded.
  • T3T_3: read IR (111 → P2P1P0P_2P_1P_0), write MAR (001 → P3P_3).
  • T4T_4: read memory (000, so MRM_R), write MBR (011 → P4P3P_4P_3).
  • T5T_5: read MBR (011 → P1P0P_1P_0), write PC (010 → P4P_4), and CrC_r ends the instruction.
Waveform diagramC0C1C2C3C4C5P0P1P2P3P4P5CrIncrPCMR

MWM_W and LALTL_{ALT} stay 0 throughout: JumpI does not write memory or use the ALU.

Watch out: list only signals that are 1 (MBR = 011 is P4P3P_4P_3, not P5P_5); CrC_r only on the last step.