Documente Academic
Documente Profesional
Documente Cultură
Shantanu Dutt
Department of Electrical $ Computer Engineering University of Illinois, Chicago Phone: (312) 355-1314 e-mail: dutt@ece.uic.edu URL: http://www.ece.uic.edu/~dutt
Shantanu Dutt
UIC
CPU IR1
opcode ir0_sel dr_enb
ri
Clk
ir1_sel result_sel[0..1]
rj rk ri
opcode
r0write r7write
Fetch & Load IR (> 1cc) Decode & Incr PC (1cc) Read, Exe. (in ALU) & Write (>= 1cc) (b) A Simple Instruction Flow
Mux
control signals
Register File
Clk
control signals
Clk
alu_sel[0..2]
ALU
Write Bus
1. Myth8 has 8-bit wide datapaths, including memory bus width, vs. 32 bits for the Edu32 2. Word sizes are similarly di erent 3. There is no explicit PC in the Myth8. The PC resides in r7 in the register le|this makes loading the instruction address to the memory address bus more complex 4. Instruction size is 16 bits for the Myth8 its is 32 bits for the Edu32. So two memory fetches are required to get a single instruction in the Myth8 vs. only one for the Edu32 (the instruction size and the data bus widths are equal in the Edu32). 5. The Myth8 does not have any ALU input and output registers. This could potentially cause a (multiple cc) race condition for multiple cc ALU operations as the ALU o/p can write to the destination register before the operation is complete (if the CU is not properly designed). If the dest. reg. is the same as any source reg. the i/p to the ALU changes before the operation is completed potentially causing an incorrect result.
SIMPLE CONTROL UNIT FSM FOR MYTH8 -- Instr. Fetch & Arithmetic Instruction Execution
Reset result_sel=00 (select write bus) alusel=ADD, cin=0 ri_sel=1rj_sel=1rk_sel=1 (READ & EXECUTE & WRITE) [ri <- rj+rk]
r7=initial value
asel=7, bsel=7 alusel=OR mar_sel=1 r6_write=1 (FETCH0) [r6 <- r7, MAR <- r7]
[r7 <- r6+1, ir0 <- mem[mar]] asel=6 alusel=ADDA r7_write=1 ir0_sel=1; read=1 (FETCH1) wait=0 asel=7, bsel=7 alusel=OR mar_sel=1 r6_write=1 (FETCH2) [r6 <- r7, MAR <- r7] [r7 <- r6+1, ir1 <- mem[mar]] asel=6 alusel=ADDA wait=0 r7_write=1 ir1_sel=1; read=1 (FETCH3)
opcode=ADD
(DECODE)
opcode=MUL
cntr0=0
wait=1
rj_sel=1 rk_sel=1 c_sel =1, count=m-2 (READ & EXECUTE) rj_sel=1 rk_sel=1
wait=1
NOTE: There is actually no multiplier and no counter in the myth8; we assume the existence of these units to illustrate multiple cc arithmetic operations.
alusel=MUL (Cont. EXECUTE) cntr0=1 result_sel=00 (MUL DONE) [rj -> ReadBusA (select write bus) rk -> ReadBusB] ri_sel=1 (EXECUTE & WRITE) [ri <- rj x rk]
CPU IR1
opcode ir0_sel dr_enb
ri
Clk
MDR
dr_sel[0..1] Clk
ir1_sel result_sel[0..1]
rj rk ri
opcode
Control Unit (CU)
r0write r7write
ri_sel rj_sel rk_sel
Fetch & Load IR (> 1cc) Decode & Incr PC (1cc) Read, Exe. (in ALU) & Write (>= 1cc) (b) A Simple Instruction Flow
Mux
control signals
Register File
Clk
control signals
Clk
alu_sel[0..2]
ALU
Write Bus
Programming language-type representation of above Moore FSM. Note that mythsim microcode language syntax is slightly di erent.
1. // r7 =initial value (set by a reset signal) 2. // Load r7 into MAR and r6 Fetch0: a sel = 7 b sel = 7 mar sel = 1 r 6 write = 1 3. // Fetch higher-order byte of 16-bit instruction note that the memory is byte addressable Fetch1: ir 0 sel = 1 read = 1, a sel = 6 alu sel = ADDA r 7 write = 1 // control signals not speci ed are 0 r6 + 1]
4. // Load r7 into MAR and r6 Fetch2: a sel = 7 b sel = 7 mar sel = 1 r 6 write = 1 5. // Fetch lower-order byte of 16-bit instruction Fetch3: ir 1 sel = 1 read = 1, a sel = 6 alu sel = ADDA r 7 write = 1 // control signals not speci ed are 0
r7
if wait then goto Fetch3 endif 6. Decode: if (opcode==ADD) then goto Add else if (opcode==MUL) then goto Mul endif // ADD and MUL are prede ned constants corresponding to the opcode values for these instructions
7.
Add:
rj sel = 1 rk sel = 1 alu sel = ADD c in = 0 result sel = ALU ri sel = 1, // 1 cc Add operation, select register speci ed in ri eld of IR for writing
8. Mul: rj sel = 1 rk sel = 1 c sel = 1 count = m ; 2, // Multiplication takes m cc's. After this cc, 1 cc will have elapsed since register reads and m ; 2 will be loaded into the counter. Note that the myth8 does not have either a multiplier in its ALU nor a counter. These are being assumed here to illustrate the CU design for multiple cc ALU execution phase. 9. Mul Wait: rj sel=1, rk sel=1, if (cntr0 == 0) then goto Mul Wait endif 10. alu sel = MUL result sel = ALU ri sel = 1,
goto Fetch0
CPU IR1
opcode ir0_sel dr_enb
ri Clk
dr_sel[0..1]
MDR
Clk
ir1_sel result_sel[0..1]
rj rk ri
opcode
Control Unit (CU)
r0write r7write
ri_sel rj_sel rk_sel
Mux
control signals
Register File
Clk
control signals
Clk
alu_sel[0..2]
ALU
Write Bus
CPU IR1
opcode ir0_sel dr_enb
ri Clk
dr_sel[0..1]
MDR
Clk
ir1_sel result_sel[0..1]
rj rk ri
opcode
Control Unit (CU)
r0write r7write
ri_sel rj_sel rk_sel
Mux
control signals
Register File
Clk
control signals
Clk
alu_sel[0..2]
ALU
Write Bus
[operation] Subpath 1
[operation] Subpath 2
[operation]
[operation] Subpath n
8 dr_enb O1 O2 ir1_sel
result_sel[0..1]
MAR 1
O1 O2 mar_sel
IR0
IR1
dr_sel[0..1] O1 MDR O2
CPU
opcode 3
Mux
Register File 1 r6 r7 2
O1 O2
Write Bus
1. Connections to the input of the ALU (or any combinational logic) need to be maintained for the entire period of the required operation. For e.g., if there is a multiplier in the ALU, and multiplication takes 10cc to nish, the read control signals ( a sel b sel] or rj sel rk sel]) in the Myth8) have to be maintained for the entire 10 cc's so that the operand registers remain connected to the multiplier's inputs for the entire 10 cc's. 2. In multiple-cc operations, the write control signal for writing to the destination register should only be valid in the last cc of the operation to avoid mutiple-cc race conditions. So if M U L r1 r2 r3] is the multiplication instruction (r1 r2 r3) and takes 10 cc, a sel = 2 b sel = 3 (or rj sel = 1 rk sel = 1) should be maintained for the entire 10 cc's, while r 1 write = 1 (or ri sel = 1) should only be active in the 10'th cc. 3. Be careful not to keep on loading data into a register over multiple cc's while its content is supposed to be changing over those cc's (e.g., loading the initial count value in the counter in the hypotehtical Myth8).
8 dr_enb O1 O2 ir1_sel
result_sel[0..1]
MAR 1
O1 O2 mar_sel
IR0
IR1
dr_sel[0..1] O1 MDR O2
CPU
opcode 3
Mux
Register File 1 r6 r7 2
O1 O2
Write Bus
8 dr_enb O1 O2 ir1_sel
result_sel[0..1]
MAR 1
O1 O2 mar_sel
IR0
IR1
dr_sel[0..1] O1 MDR O2
CPU
opcode 3
Mux
Register File 1 r6 r7 2
O1 O2
Write Bus
8 dr_enb O1 O2 ir0_sel
result_sel[0..1]
MAR
O1 O2 mar_sel
IR1
ir1_sel r0write r0write
ri_sel rj_sel rk_sel
IR0
dr_sel[0..1] O1 MDR O2
CPU
Fetch Stage
Fetch CU
opcode
Mux
Register File
O1 O2 8 8 Read Bus B
Read CU
a_sel[0..2] b_sel[0..2]
Read Bus A
Opcode register
ALU CU
cout, m7, v
cin
alu_sel[0..2]
Write CU