The control unit
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
The datapath can add, store and jump, but something has to tell each part what to do every cycle. That is the control unit. Watch TINY-8's control unit read an opcode and set seven control wires, see its whole control table go by row by row, then step through four real instructions (LDI, SUB, ST and JNZ) as the wires light and steer the data. Finish with the two ways to build it: hard-wired logic and microcode.
5 أسئلة سريعة
اختر إجابة لتعرف السبب. تُحفَظ نتيجتك مع تقدّمك.
01What goes into TINY-8's control unit, and what comes out?
The control unit only looks at what kind of instruction it is (the opcode) and, for JZ and JNZ, the Z flag. It answers with one control signal per job in the datapath.
02For ST r2, [32], which control signals are 1?
A store writes memory and must not change any register, so MemWrite is 1 and RegWrite is 0. Nothing else matters for ST.
03LDI r3, 1 needs the ALU's second input to be the immediate byte, not a register. Which signal chooses that?
ALUSrc is the select line of the mux in front of the ALU: 0 picks register rs, 1 picks the immediate byte. LDI then uses ALUOp PASS to send that byte to r3.
04The Z flag is 1 when the control unit decodes JNZ 4. What happens?
JNZ jumps only if Z is 0. With Z = 1 the last result was zero, so PCSrc stays 0 and the PC simply moves on to the next instruction.
05What is the main difference between a hard-wired and a microcoded control unit?
Both produce the same signals. Gates are fast but fixed once built; a control store holding microcode (addressed by the opcode and, for JZ and JNZ, the Z flag) is easier to design and to change. Wilkes proposed microprogramming in 1951, and the IBM System/360 family made it common in 1964.
المسرد
- Control unit
- The part of a processor that reads each instruction's opcode and sets the control signals that tell the datapath what to do.
- Datapath
- The parts that hold and change data: registers, the ALU, memory and the multiplexers between them.
- Immediate
- A number written right inside the instruction itself. In TINY-8 it is the second byte, such as the 1 in LDI r3, 1 or the address 32 in ST r2, [32].
- Multiplexer (mux)
- A switch for data: it has two or more inputs and one output, and a select signal decides which input goes through.
- Flag (Z)
- A 1-bit note the ALU leaves after an operation. The Z (zero) flag is 1 when the last result was 0; JZ and JNZ read it to decide whether to jump.
- Opcode
- The bits of an instruction that say which instruction it is. In TINY-8 it is the top 4 bits of the first byte, so there are 16 instructions.
- Control signal
- A wire from the control unit to one part of the datapath, such as RegWrite (may a register change?) or ALUOp (which operation should the ALU do?).
- Microcode
- Control words kept in a small memory, the control store, looked up by the opcode (and flags such as Z); each machine instruction runs as one or more of these words, stepped by a micro-PC.
الملاحظات والمصادر
- For a single-cycle processor the control signals depend only on the opcode, plus a flag for conditional jumps, so the control unit is a truth table with one row per instruction (Harris and Harris, Digital Design and Computer Architecture, section 7.3.2).
- Every encoding, register value and PC in the figure comes from TINY-8, the course's teaching CPU, and its reference simulator. The figure draws seven of the control signals; the full table also has FlagWrite, OutWrite (for OUT), Halt and the input port as a third write-back choice (for IN).
- A dash in the table means don't care: the signal has no effect for that instruction, so the designer may let the circuit output either value. The figure shows those as 0.
- Maurice Wilkes proposed microprogramming in 1951 (Wilkes and Stringer, 1953). IBM brought it to the mainstream with the System/360 family in 1964. Hard-wired control was faster; a ROM of microcode was easier to get right and to change (Patterson and Hennessy, Computer Organization and Design, 3rd ed., section 5.12).
- Harris and Harris, Digital Design and Computer Architecture (section 7.3: single-cycle processor control)
- Patterson and Hennessy, Computer Organization and Design, 3rd ed., section 5.12: historical perspective (hard-wired and microprogrammed control)
- Nisan and Schocken, The Elements of Computing Systems (Nand2Tetris), project 5: the CPU
- MIT OpenCourseWare 6.004 Computation Structures
اختبار يتاح بعد الخطوة الأخيرة.