Computer Organization, Executing an Instruction

Download Report

Transcript Computer Organization, Executing an Instruction

Computer Organization, Executing an
Instruction
Computer Organization, Executing an Instruction
• Fundamental Concepts
• Processor fetches one instruction at a time and
perform the operation specified.
• Instructions are fetched from successive
memory locations until a branch or a jump
instruction is encountered.
• Processor keeps track of the address of the
memory location containing the next
instruction to be fetched using Program
Counter (PC).
Computer Organization, Executing an Instruction
• Executing an Instruction
• Fetch the contents of the memory location
pointed to by the PC.
• The contents of this location are loaded into the IR
(fetch phase).
•
IR ← [[PC]]
• Assuming that the memory is byte addressable,
increment the contents of the PC by 4 (fetch
phase).
•
PC ← [PC] + 4
• Carry out the actions specified by the instruction
in the IR (execution phase).
Computer Organization, Executing an Instruction
control
lines
ALU
Carry -in
XOR
TEMP
Z
Figure 7.1. Single-bus organization of the datapath inside a processor.
Computer Organization, Executing an Instruction
• Executing an Instruction
• Type of instructions
• Transfer a word of data from one processor
register to another or to the ALU.
• Perform an arithmetic or a logic operation and
store the result in a processor register.
• Fetch the contents of a given memory location and
load them into a processor register.
• Store a word of data from a processor register into
a given memory location.
• All operations and data transfers are controlled by
the processor clock.
Computer Organization, Executing an Instruction
• Register Transfers
Computer Organization, Executing an Instruction
• Performing an Arithmetic or Logic Operation
• The ALU is a combinational circuit that has no
internal storage.
• ALU gets the two operands from MUX and bus.
• The result is temporarily stored in register Z.
• What is the sequence of operations to add the
contents of register R1 to those of R2 and store
the result in R3?
– R1out, Yin
– R2out, SelectY, Add, Zin
– Zout, R3in
Computer Organization, Executing an Instruction
• Fetching a Word from Memory
• The response time of each memory access varies (cache
miss, memory-mapped I/O,…).
• To accommodate this, the processor waits until it
receives the requested operation has been completed
(Memory-Function-Completed, MFC).
• Move (R1), R2
• 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]
Computer Organization, Executing an Instruction
•
•
•
•
Execution of a Complete Instruction
Add (R3), R1
Fetch the instruction
Fetch the first operand (the contents of the
memory location pointed to by R3)
• Perform the addition
• Load the result into R1
Computer Organization, Executing an Instruction
Internal processor
bus
Control signals
PC
Instruction
Address
lines
decoder and
MAR
control logic
Memory
bus
MDR
Data
lines
IR
Y
R0
Constant 4
Select
MUX
Add
ALU
control
lines
Sub
A
B
R n - 1
ALU
Carry -in
XOR
TEMP
Z
• Execution of a Complete Instruction
• Add (R3), R1
Fi gure 7.1. Si ngl e-bus organi zati on of the datapath i nsi de a processor.
Computer Organization, Executing an Instruction
control
lines
ALU
Carry -in
XOR
TEMP
Z
Fi gure 7.1. Si ngl e-bus organi zati on of the datapath i nsi de a processor.
Computer Organization, Executing an Instruction
• Layered view of a computer system
•
• The layered hierarchical view of the computer
system illustrates how the operating system
interacts with the users of the computer
system:
Computer Organization, Executing an Instruction
Computer Organization, Executing an Instruction
• A computer system can be divided into four
components
•  Hardware
•  Operating System
•  Application programs
•  Users
Computer Organization, Executing an Instruction
Computer Organization, Executing an Instruction
•  Hardware:the CPU, the memory and the I/O devices
•
Provides the basic computing resources for the system
•  Application programs:- like word processors, spreadsheets,
compilers, web browsers
•
Provides the way in which these resources are used to
solve user’s problems
•  OS:controls and coordinates the use of the h/w
among the various application programs for the various user
• Users
•
The ultimate use of the computer is to provide one or
set of applications
•
The user of these applications is called end users
•
Is not concerned with the computer architecture
•
User views a computer in terms of an application
Computer Organization, Executing an Instruction
• That applications can be expressed in a programming
language and is developed by an application progm
• An application is a set of machine instructions that is
completely responsible for controlling the h/w
• Some of these prog are called utility prog such as
•
Management of files
•
Control of i/o
• The most important system prog is called OS
• Os masks the details of the h/w from the programmer
and provide an interface with system
• OS acts as a mediator making it easier for the
programmer and for the application programs to access
and use those facilities and services.