Ece4750 T01 Proc Scycle
Ece4750 T01 Proc Scycle
Ece4750 T01 Proc Scycle
10
1 Instruction Set Architecture 1.3. PARC Instruction Set Architecture
PARCv1 instruction assembly, semantics, and encoding
addu rd, rs, rt 6 5 5 5 5 6
R[rd] R[rs] + R[rt] 000000 rs rt rd 00000 100001
PC PC+4 31 26 25 21 20 16 15 11 10 6 5 0
addiu rt, rs, imm 6 5 5 16
R[rt] R[rs] + sext(imm) 001001 rs rt imm
PC PC+4 31 26 25 21 20 16 15 0
mul rd, rs, rt 6 5 5 5 5 6
R[rd] R[rs] * R[rt] 011100 rs rt rd 00000 000010
PC PC+4 31 26 25 21 20 16 15 11 10 6 5 0
lw rt, imm(rs) 6 5 5 16
R[rt] M[ R[rs] + sext(imm) ] 100011 rs rt imm
PC PC+4 31 26 25 21 20 16 15 0
sw rt, imm(rs) 6 5 5 16
M[ R[rs] + sext(imm) ] R[rt] 101011 rs rt imm
PC PC+4 31 26 25 21 20 16 15 0
j target 6 26
PC jtarg( PC, target ) 000010 target
31 26 25 0
jal target 6 26
R[31] PC + 4 000011 target
PC jtarg( PC, target ) 31 26 25 0
jr rs 6 5 5 5 5 6
PC R[rs] 000000 rs 00000 00000 00000 001000
31 26 25 21 20 16 15 11 10 6 5 0
bne rs, rt, imm 6 5 5 16
if ( R[rs] != R[rt] ) 000101 rs 0 imm
PC PC+4 + imm*4 31 26 25 21 20 16 15 0
11
1 Instruction Set Architecture 1.3. PARC Instruction Set Architecture
PARCv1 vector-vector add assembly and C program
C code for doing element-wise vector addition.
Equivalent PARCv1 assembly code. Recall that arguments are passed in
registers r4r7, return value is stored to r2, and the return address is
stored in r31.
12
1 Instruction Set Architecture 1.3. PARC Instruction Set Architecture
PARCv1 mystery assembly and C program
What is the C code corresponding to the PARCv1 assembly shown
below? Assume assembly implements a function.
addiu r12, r0, 0
loop:
lw r13, 0(r4)
bne r13, r6, foo
addiu r2, r12, 0
jr r31
foo:
addiu r4, r4, 4
addiu r12, r12, 1
bne r12, r5, loop
addiu r2, r0, -1
jr r31
13
2 Single-Cycle Processors
2. Single-Cycle Processors
Control Signals Status Signals
Control Unit
Datapath
Inst
Val
Inst
Req
Inst
Resp
Data
Val
Data
Req
Data
Resp
<1 cycle
combinatiional
Memory
14
2 Single-Cycle Processors 2.1. Single-Cycle Processor Datapath
2.1. Single-Cycle Processor Datapath
Implementing ADDU Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
Implementing ADDIU Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
15
2 Single-Cycle Processors 2.1. Single-Cycle Processor Datapath
Implementing ADDU and ADDIU Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
Adding the MUL Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
16
2 Single-Cycle Processors 2.1. Single-Cycle Processor Datapath
Adding the LW Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
Data Mem
Interface
Adding the SW Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
Data Mem
Interface
17
2 Single-Cycle Processors 2.1. Single-Cycle Processor Datapath
Adding the J Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
Data Mem
Interface
ir[25:0]
j_tgen
j_targ
pc_sel
Adding the JAL Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
Data Mem
Interface
ir[25:0]
j_tgen
j_targ
pc_sel
alu_func
18
2 Single-Cycle Processors 2.1. Single-Cycle Processor Datapath
Adding the JR Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
Data Mem
Interface
ir[25:0]
j_tgen
j_targ
pc_sel
alu_func
jr
Adding the BNE Instruction
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
Data Mem
Interface
ir[25:0]
j_tgen
j_targ
pc_sel
alu_func
jr
ir[15:0]
br_tgen
eq
br_targ
19
2 Single-Cycle Processors 2.1. Single-Cycle Processor Datapath
Adding a New Auto-Incrementing Load Instruction
Draw on the datapath diagram what paths we need to use as well as
any new paths we will need to add in order to implement the following
auto-incrementing load instruction.
lw.ai rt, imm(rs)
R[rt] M[ R[rs] + sext(imm) ]; R[rs] R[rs] + 4
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
Data Mem
Interface
ir[25:0]
j_tgen
j_targ
pc_sel
alu_func
jr
ir[15:0]
br_tgen
eq
br_targ
20
2 Single-Cycle Processors 2.2. Single-Cycle Processor Control Unit
2.2. Single-Cycle Processor Control Unit
inst pc_sel op1_sel alu_func wb_sel waddr wen
addu
addiu
mul
lw
sw
j
jal
jr
bne
lw.ai
21
3 Analyzing Processor Performance
3. Analyzing Processor Performance
Time
Program
=
Instructions
Program
Cycles
Instruction
Time
Cycles
Instructions / program depends on source code, compiler, ISA
Cycles / instruction (CPI) depends on ISA, microarchitecture
Time / cycle depends upon microarchitecture and implementation
Microarchitecture CPI Cycle Time
this topic Single-Cycle Processor 1 long
Topic 02 FSM Processor >1 short
Topic 03 Pipelined Processor 1 short
Students often confuse Cycle Time with the execution time
of a sequence of transactions measured in cycles.
Cycle Time is the clock period or the inverse of the clock frequency.
22
3 Analyzing Processor Performance
Estimating cycle time
There are many paths through the design that start at a state element
and end at a state element. The critical path is the longest path across
all of these paths. We can usually use a simple rst-order static timing
estimate to estimate the cycle time (i.e., the clock period and thus also
the clock frequency).
pc
regfile
(read) regfile
(write)
regfile
_wen
regfile
_waddr
alu
ir[20:16]
ir[25:21]
+4
Instruction Mem
Interface
To control unit
pc_plus4
op1
_sel
sext
ir[15:0]
mul
wb_sel
Data Mem
Interface
ir[25:0]
j_tgen
j_targ
pc_sel
alu_func
jr
ir[15:0]
br_tgen
eq
br_targ
23
3 Analyzing Processor Performance
Estimating execution time
Using our rst-order equation for processor performance, how long in
nanoseconds will it take to execute the vector-vector add example
assuming n is 64?
loop:
lw r12, 0(r4)
lw r13, 0(r5)
addu r14, r12, r13
sw r14, 0(r6)
addiu r4, r4, 4
addiu r5, r5, 4
addiu r6, r6, 4
addiu r7, r7, -1
bne r7, r0, loop
jr r31
Using our rst-order equation for processor performance, how long in
nanoseconds will it take to execute the mystery program assuming n is
64 and that we nd a match on the 10th element.
addiu r12, r0, 0
loop:
lw r13, 0(r4)
bne r13, r6, foo
addiu r2, r12, 0
jr r31
foo:
addiu r4, r4, 4
addiu r12, r12, 1
bne r12, r5, loop
addiu r2, r0, -1
jr r31
24