Execution of Complete Instruction
Execution of Complete Instruction
Registers
Input
Arithmetic and
Memory
Logic Unit
Output
Control
Register file: a
memory unit for the Control circuitry:
Control
processor’s general- Register Interpret or decode the
purpose registers circuitry fetched instruction
file
(GPRs)
Processor–memory interface
Select MUX R2
R3
Add
ALU A B
…
Sub
ALU
…
lines Rn-1
Carry
XOR in
Z TEMP
Processor Internal: External Bus (1/2)
• External Memory Bus: Internal processor
bus Control
– Processor-memory signals
…
PC
interface: External Instruction
Address
memory bus are lines
decoder
&
MAR
controlled through External output input control logic
memory
MAR and MDR. bus
MDR
Data IR
– MAR: Specify the lines
…
Sub
internal processor bus. control ALU
…
…
Sub
• Outputs: Data stored in control ALU
…
– Program Counter Y R0
Constant 4
• Keep track of the address R1
of the next instruction to Select MUX R2
be fetched and executed. R3
Add
ALU A B
– Instruction Register
…
Sub
control ALU
…
lines Rn-1
• Hold the instruction until XOR
Carry
in
the current execution is
Z TEMP
completed.
Processor Internal: Register (2/2)
• Special Registers: Internal processor
bus Control
Y, Z, & TEMP signals
…
PC
– Transparent to the Address
Instruction
decoder
programmer. lines
MAR &
External control logic
– Used by the processor memory
bus
for temporary storage Data
MDR
IR
during execution of lines
some instructions. Y R0
Constant 4 R1
– Never used for storing R2
Select MUX
data generated by one R3
Add
instruction for later use ALU A B
…
Sub
control
by another instruction. ALU
…
Select MUX R2
– The input A of ALU: R3
Select (ctrl line) either ALU
Add
A B
…
Sub
• The output of register Y orcontrol ALU
…
…
Sub
control ALU
…
• Multiple-Bus Organization
Instruction Execution (1/3)
1) Fetch Phase Internal processor
bus Control
– IR [[PC]] signals
…
PC
• Fetch the contents of the Instruction
Address
memory location pointed lines
decoder
&
to by PC, and load into IR External MAR
control logic
memory
– PC [PC]+4 bus
MDR
• Increment the contents of Data IR
lines
PC by 4.
Y R0
– Why 4? Instruction is 32 Constant 4 R1
bits (4B) and memory is
byte addressable. Select MUX R2
R3
2) Execute Phase ALU
Add
A B
…
Sub
control ALU
– Decode instruction in IR
…
lines Rn-1
Carry
XOR in
– Perform the operation(s)
Z TEMP
Instruction Execution (2/3)
1) Fetch Phase Internal processor
bus Control
– IR [[PC]] signals
…
PC
• Fetch the contents of the Instruction
Address
memory location pointed lines
decoder
&
to by PC, and load into IR External MAR
control logic
memory
– PC [PC]+4 bus
MDR
• Increment the contents of Data IR
lines
PC by 4.
Y R0
– Why 4? Instruction is 32 Constant 4 R1
bits (4B) and memory is
byte addressable. Select MUX R2
R3
2) Execute Phase ALU
Add
A B
…
Sub
control ALU
– Decode instruction in IR
…
lines Rn-1
Carry
XOR in
– Perform the operation(s)
Z TEMP
Instruction Execution (3/3)
1) Fetch Phase Internal processor
bus Control
– IR [[PC]] signals
…
PC
• Fetch the contents of the Instruction
Address
memory location pointed lines
decoder
&
to by PC, and load into IR External MAR
control logic
memory
– PC [PC]+4 bus
MDR
• Increment the contents of Data IR
lines
PC by 4.
Y R0
– Why 4? Instruction is 32 Constant 4 R1
bits (4B) and memory is
byte addressable. Select MUX R2
R3
2) Execute Phase ALU
Add
A B
…
Sub
control ALU
– Decode instruction in IR
…
lines Rn-1
Carry
XOR in
– Perform the operation(s)
Z TEMP
Instruction Execution: Execute Phase
• An instruction can be executed by performing one
or more of the following operation(s):
1) Transfer data from a register to another
register or to the ALU
1) Perform arithmetic (or logic) operations
and store the result into the special register Z
2) Load content of a memory location to a register
3) Store content of a register to a memory location
1) Register Transfer
• Input and output of Internal processor
bus Control
register Ri are controlled signals
…
PC
by switches ( ): Address
Instruction
decoder
– Ri-in: Allow data to be lines
MAR &
External control logic
transferred into Ri memory
bus
MDR
Data IR
Ri-in lines
Y R0
Ri Constant 4 R1
Select MUX R2
Ri-out R3
Add
ALU A B
…
Sub
– Ri-out: Allow data to be control ALU
…
lines Rn-1
Carry
transferred out from Ri XOR in
Z TEMP
1) Register Transfer (Cont’d)
Internal processor
bus Control
signals
• Ex: R3 R1 PC
…
Instruction
Address
decoder
lines &
MAR
External control logic
memory
Sequence of Steps: bus
Data
MDR
IR
lines
Y R0
R1-out, R3-in Constant 4 R1
Select MUX R2
R3
Add
ALU A B
…
Sub
control ALU
…
lines Rn-1
Carry
XOR in
Z TEMP
2) Arithmetic or Logic Operation
• ALU: A circuit without Internal processor
bus Control
storage to manipulate data. signals
…
PC
– Two inputs: from A & B Address
Instruction
decoder
• A: #4 or register Y lines
MAR &
External control logic
• B: Any other register memory
– ALU: Perform operation bus
Data
MDR
IR
– One output: to register Z lines
Y R0
• Ex: R3 R1 + R2 Constant 4 R1
…
Sub
control ALU
…
Rn-1
Select-Y, R2-out, lines
XOR
Carry
in
Z-out,
Lec09:
CSCI2510 R3-in Unit
Basic Processing
2) Arithmetic or Logic Operation (Cont’d)
• Ex: R3 R1 + R2
Control lines
( R /W, MFC, etc.)
*MFC (Memory Function Completed): Indicating the
requested operation has been completed.
3) Fetching a Word from Memory (Cont’d)
MAR-in, MDR
Data IR
Read (start to load a lines
…
Sub
loading is completed) control ALU
…
lines Rn-1
Carry
3. MDR-out, XOR in
Z TEMP
R2-in
3) Fetching a Word from Memory (Cont’d)
MAR-in, MAR in
2. MDR-inE, Read
(MR)
completed)
MFC
3. MDR-out,
R2-in (not shown) MDR out
4) Storing Word to Memory
• This operation is similar Internal processor
bus Control
to the previous one. PC signals
…
• Ex: Mov (R1), R2 R/W
MFC
(Control lines) Instruction
decoder
External
Sequence of Steps: memory Addr
MAR &
control logic
bus lines
R1-out, MDR
Data
MAR-in lines
IR
Y R0
…
Sub
control ALU
…
Rn-1
MDR-outE, lines
XOR
Carry
in
storing is completed)
Revisit: Fetch Phase
• Fetch Phase: The first phase of Internal processor
bus Control
machine instruction execution signals
…
PC
– IR [[PC]] Address
Instruction
decoder
• Fetch the instruction lines
MAR &
from the memory External control logic
memory
location pointed to by PC, bus
MDR
and load it into IR Data IR
lines
– PC [PC]+4 Y R0
• Increment the contents Constant 4 R1
of PC by 4 Select MUX R2
…
Sub
of steps for the fetch control ALU
…
lines Rn-1
Carry
phase with the highest XOR in
parallelism? Z TEMP
Fetch Phase (Step - 1)
•Ex: Fetch Phase Internal processor
bus Control
Sequence of Steps: PC signals
…
R/W
PC-out, MAR-in, Read MFC
(Control lines) Instruction
decoder
External
Select-4, Add, Zin memory Addr
MAR &
control logic
bus lines
Fetch the instruction MDR
IR
– Increment PC in parallel
Y R0
MDR-inE, WaitMFC Constant 4 R1
…
Sub
(discuss later). control ALU
…
lines Rn-1
Carry
XOR in
– Increment PC in parallel. Y R0
Constant 4 R1
MDR-inE, WaitMFC Select MUX R2
Z-out, PC-in, Y-in Add
R3
ALU A B
– Y-in is for branch
…
Sub
control ALU
…
Rn-1
(discuss later). lines
XOR
Carry
in
– Increment PC in parallel. Y R0
Constant 4 R1
MDR-inE, WaitMFC Select MUX R2
Z-out, PC-in, Y-in Add
R3
ALU A B
– Y-in is for branch
…
Sub
control ALU
…
Rn-1
(discuss later). lines
XOR
Carry
in
• Multiple-Bus Organization
Example 1) ADD R1, (R3)
• Execution of a Complete Instruction:
Sequence of Steps:
1) Fetch the instruction Fetch:
1. PC-out, MAR-in, Read
2) Decode the instruction
Select-4, B-in, Z-in, Add
3) Load the operand [R3]
2. MDR-inE, WaitMFC Z-out,
from memory
PC-in, Y-in
4) Perform the addition
5) Store the result to R1 3. MDR-out, IR-in
Decode:
Execution:
4. R3-out, MAR-in, Read
5. R1-out, Y-in, MDR-inE, WaitMFC
6. MDR-out, SelectY, Add, Z-in,
7. Z-out, R1-in, End
Example 1) ADD R1, (R3) (2/3)
Sequence of Steps: Internal processor
bus Control
1. PC-out, MAR-in, Read PC signals
…
Select-4, B-in, Z-in, Add R/W
(Control lines) Instruction
MFC decoder
2. MDR-inE, WaitMFC External
MAR &
memory Addr control logic
Z-out, PC-in, Y-in bus lines
3. MDR-out, IR-in MDR
IR
4. R3-out, MAR-in, Read
Y R0
5. R1-out, Y-in, MDR-inE, Constant 4 R1
WaitMFC Select MUX R2
…
Sub
control ALU
…
lines Rn-1
7. Z-out, R1-in XOR
Carry
in
Z TEMP
Example 1) ADD R1, (R3) (3/3)
• Detailed Explanation for Sequence of Steps:
PC loaded into MAR, read request to memory,
MUX selects 4, added to PC (B-in) in ALU, store sum in Z
Z moved to PC (and Y) while waiting for memory
Word fetched from memory and loaded into IR
Instruction Decoding: Figure out what the instruction
should do and set control circuitry for steps 4 – 7
R3 transferred to MAR, read request to memory
Content of R1 moved to Y while waiting for memory
Read operation completed, the loaded word is already in
MDR and copied to B-in of ALU, SelectY as second input
of ALU, add performed
Result is transferred to R1