Module 5
Module 5
UNIT
Module 5
Overview
⚫ Instruction Set Processor (ISP) – executes
machine instructions and coordinates the
activities of other cells.
⚫ Also called Central Processing Unit (CPU)
⚫ A typical computing task consists of a series
of steps specified by a sequence of machine
instructions that constitute a program.
⚫ An instruction is executed by carrying out a
sequence of more rudimentary operations.
Some Fundamental
Concepts
Fundamental Concepts
⚫ Processor fetches one instruction at a time and
performs 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).
⚫ After fetching an instruction, the contents of the PC
are updated to point to the next instruction in the
sequence.
⚫ A branch instruction may load a different value into the PC.
Steps in Executing an
Instruction
⚫ Fetch the contents of the memory location pointed
to by the PC. The contents of this location are
loaded into the instruction register 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).
Processor Organization Internal processor
bus
Control signals
PC
Instruction
Address
decoder and
lines
MAR control logic
MDR HAS
Memory
TWO INPUTS bus
AND TWO
MDR
OUTPUTS Data
lines IR
Datapath
Y
Constant 4 R0
Select MUX
Add
A B
ALU Sub R ( n - 1)
control ALU
lines
Carry-in
XOR TEMP
Z
Textbook Page 413
Processor Organization..
⚫ Figure 7.1 shows an organization in which the
ALU and all the registers are interconnected via
a single common bus.
⚫ This bus is internal to the processor.
⚫ The data and address lines of the external
memory bus are connected to the internal
processor bus via the memory data register,
MDR, and the memory address register, MAR,
respectively.
⚫ Register MDR has two inputs and two outputs.
Processor Organization..
⚫ Data may be loaded into MDR either from the
memory bus or from the internal processor bus.
⚫ The data stored in MDR may be placed on either
bus.
⚫ The input of MAR is connected to the internal bus,
and its output is connected to the external bus.
⚫ The control lines of the memory bus are connected
to the instruction decoder and control logic block.
⚫ This unit is responsible for issuing the signals that control
the operation of all the units inside the processor and for
interacting with the memory bus.
Processor Organization..
⚫ The number and use of the processor registers R0
through R(n - 1) vary considerably from one
processor to another.
⚫ Registers may be provided for general-purpose use
by the programmer.
⚫ Some may be dedicated as special-purpose registers, such
as index registers or stack pointers.
⚫ The registers, Y, Z, and TEMP are used by the
processor for temporary storage during execution of
some instructions.
⚫ These registers are never used for storing data generated
by one instruction for later use by another instruction.
Processor Organization..
⚫ The multiplexer MUX selects either the output of
register Y or a constant value 4 to be provided as
input A of the ALU.
⚫ The constant 4 is used to increment the contents of the
program counter.
⚫ We will refer to the two possible values of the MUX
control input Select as Select4 and SelectY for
selecting the constant 4 or register Y, respectively.
Processor Organization..
⚫ As instruction execution progresses, data are
transferred from one register to another, often
passing through the ALU to perform some arithmetic
or logic operation.
⚫ The instruction decoder and control logic unit is
responsible for implementing the actions specified
by the instruction loaded in the IR register.
⚫ The decoder generates the control signals needed
to select the registers involved and direct the
transfer of data.
⚫ The registers, the ALU, and the interconnecting bus
are collectively referred to as the datapath.
Sequence of Steps in
Executing an Instruction
⚫ 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.
Register Transfers
⚫ Instruction execution involves a sequence of
steps in which data are transferred from one
register to another.
⚫ For each register, two control signals are used to
place the contents of that register on the bus or
to load the data on the bus into the register.
⚫ This is represented symbolically in Figure 7.2.
⚫ The input and output of register Ri are
connected to the bus via switches controlled by
the signals Riin and Riout respectively.
Register Transfers..
⚫ When Riin is set to 1, the data on the bus are
loaded into Ri.
⚫ Similarly, when Riout is set to 1, the contents of
register Ri are placed on the bus.
⚫ While Riout is equal to 0, the bus can be used for
transferring data from other registers.
Register Transfers.. Riin
Internal processor
bus
Ri
Riout
Y in
Constant 4
Select MUX
A B
ALU
Z in
Z out
Figure 7.2. Input and output gating for the registers in Figure 7.1.
Register Transfers..
⚫ Suppose that we wish to transfer the contents of
register R1 to register R4.
⚫ This can be accomplished as follows:
⚫ Enable the output of register R1 by setting R1out to 1.
This places the contents of R1 on the processor bus.
⚫ Enable the input of register R4 by setting R4in to 1.
This loads data from the processor bus into register
R4.
⚫ All operations and data transfers within the
processor take place within time periods defined
by the processor clock.
Register Transfers..
⚫ An implementation for one bit of register Ri is
shown in Figure 7.3 as an example.
⚫ A two-input multiplexer is used to select the data
applied to the input of an edge-triggered D flip-
flop.
⚫ When the control input Riin is equal to 1, the
multiplexer selects the data on the bus.
⚫ This data will be loaded into the flip-flop at the rising
edge of the clock.
⚫ When Riin is equal to 0, the multiplexer feeds
back the value currently stored in the flip-flop.
Register Transfers..
⚫ The Q output of the flip-flop is connected to the
bus via a tri-state gate.
⚫ When Riout is equal to 0, the gate's output is in
the high-impedance (electrically disconnected)
state.
⚫ This corresponds to the open-circuit state of a switch.
⚫ When Riout = 1, the gate drives the bus to 0 or 1,
depending on the value of Q.
Register Transfers..
Bus
D Q
1
Q
Riiout
Riin
Clock
Figure 7.3. Input and output gating for one register bit.
Performing an Arithmetic or
Logic Operation
⚫ The ALU is a combinational circuit that has no
internal storage.
⚫ It performs arithmetic and logic operations on the two
operands applied to its A and B inputs.
⚫ ALU gets the two operands from MUX and bus.
The result is temporarily stored in register Z.
⚫ The sequence of operations to add the contents of
register R1 to those of R2 and store the result in
R3.
1. R1out, Yin
2. R2out, SelectY, Add, Zin
3. Zout, R3in
Performing an Arithmetic or
Logic Operation..
⚫ The signals whose names are given in any step
are activated for the duration of the clock cycle
corresponding to that step.
⚫ All other signals are inactive.
⚫ In step 1, the output of register R1 and the input
of register Y are enabled, causing the contents
of RI to be transferred over the bus to Y.
Performing an Arithmetic or
Logic Operation..
⚫ In step 2, the multiplexer's Select signal is set to
SelectY, causing the multiplexer to gate the
contents of register Y to input A of the ALU.
⚫ At the same time, the contents of register R2 are gated
onto the bus and, hence, to input B.
⚫ The Add line is set to 1, causing the output of the ALU to
be the sum of the two numbers at inputs A and B.
⚫ This sum is loaded into register Z because its input
control signal is activated.
⚫ In step 3, the contents of register Z are transferred
to the destination register, R3.
Fetching a Word from
Memory
⚫ To fetch a word of information from memory, the
processor has to specify the address of the
memory location where this information is
stored and request a Read operation.
⚫ The information to be fetched may be an
instruction in a program or an operand specified
by an instruction.
⚫ The processor transfers the required address to
the MAR, whose output is connected to the
address lines of the memory bus.
Fetching a Word from
Memory..
⚫ At the same time, the processor uses the
control lines of the memory bus to indicate that
a Read operation is needed.
⚫ When the requested data are received from the
memory they are stored in register MDR,
⚫ From MDR, they can be transferred to other
registers in the processor.
Fetching a Word from
Memory..
MDR
MDRinE MDRin
Timing Clock
MR
MDR inE
Data