Professional Documents
Culture Documents
sg/~cs1104
SchoolofComputing NationalUniversityofSingapore
CS1104-P2-6
CS1104-P2-6
Datapath
CS1104-P2-6
Recap: Organisation
Bus
Processor
Control
Memory
Devices
Input
Cache Datapath
Output Registers
CS1104-P2-6
Fundamental Concepts
CS1104-P2-6
Instruction execution
cycle: fetch, decode, execute. Fetch: fetch next
Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction
instruction (using PC) from memory into IR. Decode: decode the instruction. Execute: execute instruction.
CS1104-P2-6
is stored in a word, and that the memory is byte addressable. PC (Program Counter) contains address of next instruction. IR [[PC]] PC [PC] + 4
CS1104-P2-6
Single-bus Organization
Internal processor bus PC Address line Memory bus Data line MAR MDR Y Control signals ...
Instruction decoder and control logic
IR
RO MUX
A B
: : R(n1)
Carry-in
:
XOR
ALU
TEMP Z
CS1104-P2-6
Instruction Execution
another or to the ALU (Arithmetic Logic Unit). Perform an arithmetic or a logic operation and store the result in a register. Fetch the contents of a given memory location and load them into a register. Store a word of data from a register into a given memory location.
CS1104-P2-6
10
Register Transfer
CS1104-P2-6
11
Ri in X Ri X Ri out
Arithmetic/Logic Operation
ALU: Performs
arithmetic and logic operations on its A and B inputs. To perform Select R3 [R1] + [R2]:
1. R1out , Yin 2. R2out , SelectY, Add, Zin 3. Zout , R3in
Y in X Constant 4 MUX
A B
ALU Z in X Z X Z out
CS1104-P2-6
13
:
XOR
ALU
Carry-in
CS1104-P2-6
14
/* R2 [[R1]]
MAR [R1] Start a Read operation on the memory bus Wait for the MFC response from the memory Load MDR from the memory bus R2 [MDR]
Memory-bus data lines MDR inE X MDR X MDR outE Processor: Datapath and Control X MDR out 15 Internal processor bus MDR in X
CS1104-P2-6
CS1104-P2-6
17
Multiple-Bus Organization
Single-bus structure: Control sequences are long as
only one data item can be transferred over the bus in a clock cycle. Figure on next slide shows a three-bus structure. All registers are combined into a single block called register file with three ports: 2 outputs allowing 2 registers to be accessed simultaneously and have their contents put on buses A and B, and 1 input allowing data on bus C to be loaded into a third register. Buses A and B are used to transfer source operands to the A and B inputs of ALU, and result transferred to destination over bus C.
Processor: Datapath and Control 19
CS1104-P2-6
Bus C
Bus A Bus B
Bus C
PC
IR
MDR
A
MUX
ALU
R
MAR
CS1104-P2-6
Address line Memory bus data lines Processor: Datapath and Control
20
CS1104-P2-6
21
Control
Hardwired control or microprogrammed control. Hardwired control:
Clock
CLK Control step counter
... :
IR External inputs
: :
Decoder/ encoder
: ...
Control signals CS1104-P2-6 Processor: Datapath and Control Memory bus data lines
Condition codes
22
Control (2)
Microprogrammed control:
Control signals generated by a program. Control word (CW) is a microinstruction that contains
individual bits that represent the various control signals. Vertical organization: highly encoded schemes that use compact codes to specify only a small number of control functions in each microinstruction. Horizontal organization: minimally encoded scheme in which many resources can be controlled with a single microinstructions. Popular in Complex Instruction Set Architectures (CISC) because complex instruction sets require complex controllers that can more easily be implemented as microprograms.
CS1104-P2-6
23
Control (3)
Example of a horizontal
organization scheme:
1. 2. 3. 4. 5. 6. 7.
tu o n i
PCout , MARin , Read, Select4, Add, Zin Zout , PCin , Yin , WMFC MDRout , IRin R3out , MARin , Read R1out , Yin , WMFC MDRout , SelectY, Add, Zin Zout , R1in , End
Zt uo 1 R tuo
Yn i
Zn i
t ce e S l
-oc M ri not c u t s n i r i
1 2 3 4 5 6 7
0 1 0 0 0 0 0
1 0 0 0 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
0 0 1 0 0 1 0
0 0 1 0 0 0 0
0 1 0 0 1 0 0
1 0 0 0 0 0 0
1 0 0 0 0 1 0
1 0 0 0 0 1 0
0 1 0 0 0 0 1
0 0 0 0 1 0 0
0 0 0 0 0 0 1
0 0 0 1 0 0 0
CF M W dn E
0 1 0 0 1 0 0 0 0 0 0 0 0 1
RA M dae R
RD M R I
dd A
1R 3R
CP
CP
..
..
tu o
n i
tu o
n j
n i
CS1104-P2-6
CS1104-P2-6
25
Stages of a Datapath
executes an instruction (performs all necessary operations beginning with fetching the instruction) would be too bulky and inefficient. an instruction into stages, and then connect the stages to create the whole datapath. Smaller stages are easier to design. Easy to optimize (change) one stage without
touching the others.
Processor: Datapath and Control 26
CS1104-P2-6
Stages
1. 2. 3. 4. 5. Instruction Fetch Instruction Decode ALU Memory Access Register Write
CS1104-P2-6
27
CS1104-P2-6
28
CS1104-P2-6
CS1104-P2-6
30
CS1104-P2-6
31
CS1104-P2-6
32
instruction memory
registers
PC
ALU
+4
1. Instruction Fetch
CS1104-P2-6
Data memory
33
CS1104-P2-6
34
instruction memory
2 imm
reg[2]
+4
CS1104-P2-6
Data memory
35
3 1
registers
PC
reg[1]+reg[2]
slti $r3,$r1,17
Stage 1: Fetch this instruction, increment PC. Stage 2: Decode to find it is an slti, then read
register $r1. Stage 3: Compare value retrieved in stage 2 with the integer 17. Stage 4: Go idle. Stage 5: Write the result of stage 3 in register $r3.
CS1104-P2-6
36
instruction memory
3 imm
+4
17
CS1104-P2-6
Data memory
37
x 1
registers
PC
reg[1]-17
Datapath Walkthroughs: sw
sw $r3, 20($r1)
Stage 1: Fetch this instruction, increment PC. Stage 2: Decode to find it is an sw, then read
CS1104-P2-6
registers $r1 and $r3. Stage 3: Add 20 to value in register $r1 (retrieved in stage 2). Stage 4: Write value in register $r3 (retrieved in stage 2) into memory address computed in stage 3. Stage 5: Go idle (nothing to write into a register).
38
instruction memory
3 imm
reg[3]
+4
20
CS1104-P2-6
sw r3, 20(r1)
x 1
registers
PC
reg[1]+20
CS1104-P2-6
40
Datapath Walkthroughs: lw
lw $r3, 40($r1)
Stage 1: Fetch this instruction, increment PC. Stage 2: Decode to find it is a lw, then read
register $r1. Stage 3: Add 40 to value in register $r1 (retrieved in stage 2). Stage 4: Read value from memory address compute in stage 3. Stage 5: Write value found in stage 4 into register $r3.
CS1104-P2-6
41
instruction memory
+4
imm
40
CS1104-P2-6
lw r3, 40(r1)
42
r3<-MEM[r1+40]
Data memory
x 1
registers
PC
reg[1]+40
CS1104-P2-6
43
Datapath: Summary
Construct datapath based on register transfers
required to perform instructions. Control part causes the right transfers to happen.
instruction memory
ALU
+4
CS1104-P2-6
Data memory
44
rd rs rt
registers
PC
ALU
ALU Control
45
R-type instructions
Branch instruction
Jump instruction
High-level view of finite state machine control. Sequential logic design can be used to assert the
correct control signals at the correct times.
Processor: Datapath and Control CS1104-P2-6 46
Summary
memory) computational ability (ALU) helper hardware (local registers and PC)
CS1104-P2-6
47
Summary (2)
CS1104-P2-6
End of file
CS1104-P2-6
49