Datapath and control
แนะนำใหม่ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| datapath/ˈdeɪtəpæθ/ | เส้นทางข้อมูล |
| ALU/ˌeɪ el ˈjuː/ | หน่วยคำนวณทางคณิตศาสตร์และตรรกะ (ALU) |
| Control/kənˈtrəʊl/ | The set of switch settings for each instruction: RegWrite, MemRead, MemWrite, MemToReg, ALUSrc and Branch. |
| don't-care/dəʊnt keə/ | An input combination whose output does not matter, so it can be set to 0 or 1 to simplify the logic. |
| CPI/ˌsiː piː ˈaɪ/ | cycles per instruction: the average number of clock cycles each instruction takes |
One clock, one instruction
- The datapath 数据通路 is the plumbing. The PC feeds instruction memory, the register file reads two sources, the ALU 算术逻辑单元 computes, data memory reads or writes, the result is written back, and the PC takes PC + 4 or a branch target.
- Control 控制 is the set of switch settings for each instruction: RegWrite, MemRead, MemWrite, MemToReg, ALUSrc and Branch. It is pure combinational logic on the opcode and funct fields.

The single-cycle clock must wait for —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
All work fits in one clock, so lw (IM+RF+ALU+DM+wiring = 900 ps) sets the cycle.
The slowest instruction sets the clock
- All the work fits in one clock cycle, so the clock must wait for the longest instruction: the path of
lw. With our numbers (IM 200, RF 100, ALU 200, DM 250, wiring 150 ps): $200 + 100 + 200 + 250 + 150 = 900$ ps per cycle. - 100 instructions take $90\,000$ ps. Making
addfaster would not help: the machine runs at the speed of its slowest instruction.
With IM 200, RF 100, ALU 200, DM 250, wiring 150 ps, the lw cycle is —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
200+100+200+250+150 = 900 ps: the slowest instruction sets the clock.
In the single-cycle machine, making add faster would shorten the clock period.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The clock must fit the slowest instruction, lw at $900$ ps. A faster add finishes earlier inside the same cycle and then waits.
Six bits per instruction
lw R4, 8(R1): RegWrite 1, MemRead 1, MemToReg 1, ALUSrc 1 (the immediate goes to the ALU), Branch 0, MemWrite 0.sw R5, 12(R1): RegWrite 0, MemWrite 1, MemRead 0, MemToReg = x. The x is a don't-care 无关项: nothing is written back, so the bit changes nothing you can observe. Don't-cares give the designer freedom.
For lw, the ALUSrc control bit selects —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The ALU must add base + immediate, so ALUSrc = 1 routes the immediate.
The multi-cycle alternative
- Split each instruction into steps and clock at the slowest unit, $250$ ps. Now
lwtakes $5$ cycles, R-type andswtake $4$, andbeqtakes $3$. For a mix of $25\%$ loads, $10\%$ stores, $50\%$ R-type and $15\%$ branches: CPI $= 1.25 + 0.4 + 2.0 + 0.45 = 4.1$. - The time per instruction is $4.1 \times 250 = 1025$ ps, slower than the single cycle's $900$ ps. Multi-cycle helps only when the units are very unequal.
- The real gain comes from overlapping the steps of different instructions: pipelining. Note that
beqsets ALUSrc to $0$, because it compares two registers.
A multi-cycle machine runs 40% loads (5 cycles) and 60% R-type (4 cycles). What is the CPI?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
0.4 x 5 + 0.6 x 4 = 2.0 + 2.4 = 4.4.
สนับสนุน beq R1, R2, loop, the ALUSrc control bit is —
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The branch subtracts R2 from R1 to test equality, so the second ALU input is a register.
The iron law of performance
- Time = instructions × CPI 每指令周期数 × cycle time. Everything an architect does changes one of the three, and usually makes another worse.
- For 100 instructions: single-cycle $100 \times 1 \times 900 = 90\,000$ ps; multi-cycle $100 \times 4.1 \times 250 = 102\,500$ ps; a 5-stage pipeline at CPI 1.129 and 250 ps gives $\mathbf{28\,225}$ ps. Pipelining wins because it keeps CPI near 1 with the short clock.
100 instructions at CPI 1.129 with a 250 ps clock: total time (ps)?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
$100 \times 1.129 \times 250 = 28\,225$.
A lower CPI always means a faster program.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Time also depends on the cycle time: the single-cycle design has CPI 1 at 900 ps and takes 90,000 ps, while the pipeline has CPI 1.129 at 250 ps and takes 28,225.
Worked example: control bits for beq and addi
beq R1, R2, L: RegWrite 0, MemRead 0, MemWrite 0, ALUSrc 0 (two registers), Branch 1, MemToReg x. The ALU subtracts; its Zero output AND Branch chooses the target.addi R4, R1, 127: RegWrite 1, ALUSrc 1 (the immediate), MemToReg 0 (the ALU result is written back), Branch 0, and no memory access. Seven instructions give seven rows of one truth table.
สนับสนุน addi, which control setting is right?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The immediate feeds the ALU and the ALU result is written back.
Marks that slip away
- Speeding up the common instruction. The single-cycle clock is set by
lw, so a fasteraddchanges nothing. - Fixing don't-cares out of habit. A don't-care is free only when nothing can observe it, as with MemToReg on
sw; fixing it costs logic and gains nothing. - Assuming multi-cycle is faster. For the course mix it averages $1025$ ps against $900$ ps. It wins only when the units are very unequal.
Recap
- Datapath: PC, instruction memory, register file, ALU, data memory, write-back.
- Single-cycle clock = slowest instruction: $900$ ps for
lwhere. For 100 instructions of the course mix:
| Design | Clock (ps) | CPI | Time (ns) |
|---|---|---|---|
| Single-cycle | 900 | 1 | 90.0 |
| Multi-cycle | 250 | 4.1 | 102.5 |
| Pipeline | 250 | 1.129 | 28.2 |
-
CPI is cycles per instruction; the pipeline has 5 stages.
-
Control is combinational: six bits per instruction, with don't-cares where nothing can be observed.
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้