Notes Co Unit3
Notes Co Unit3
To execute a program, the processor fetches one instruction at a time and performs the operations
specified. Instructions are fetched from successive memory locations until a branch or a jump
instruction is encountered. The processor keeps track of the address of the memory location
containing the next instruction to be fetched using the 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.
Another key register in the processor is the instruction register, IR. Suppose that each instruction
comprises 4 bytes, and that it is stored in one memory word. To execute an instruction, the
processor has to perform the following three steps:
1. Fetch the contents of the memory location pointed to by the PC. The contents of this location are
interpreted as an instruction to be executed. Hence, they are loaded into the IR. Symbolically,
this canbewritten as
IR ⟵ [[PC]]
2. Assuming that the memory is byte addressable, increment the contents of the PC by 4, that is,
PC ⟵ [PC]+4
3. Carry out the actions specified by the instruction in the IR.
In cases where an instruction occupies more than one word, steps 1 and 2 must be repeated as many
times as necessary to fetch the complete instruction. These two steps are usually referred to as the
fetch phase; step 3 constitutes the execution phase.
Figure shows the processor organization in which the arithmetic and logic unit (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. 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.
The number and use of the processor registers R0 through
R(n - I) 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. Three
registers, Y, Z, and TEMP in Figure are transparent to the
programmer, that is, the programmer need not be concerned
with them because they are never referenced explicitly by
any instruction. They 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.
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.
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
HARDWIRED CONTROL
The techniques to generate the control signals
needed to execute instructions in theproper
sequence fall into one of two categories: hardwired
control and microprogrammed control.
In the sequence of control signals, each step is
completed in one clock period. A counter may be
used to keep track of the control steps, as shown in
Figure. Each state, or count, of this counter
corresponds to one control step. The required
control signals are determined by the following
information:
• Contents of the control step counter
• Contents of the instruction register
• Contents of the condition code flags
• External input signals, such as MFC and
interrupt requests
The decoder/encoder block in Figure is a combinational circuit that generates the required control
outputs, depending on the state of all its inputs. The step decoder provides a separate signal line for
each step, or time slot, in the control sequence. The output of the instruction decoder consists of a
separate line for each machine instruction, For any instruction loaded in the IR, one of the output
lines INS1 through INSm is set to 1, and all other lines are set to 0. The input signals to the encoder
block in Figure are combined to generate the individual control signals Yin, PCout, Add, End, and
so on. An example of how the encoder generates the Zin control signal is given in Figure. This
circuit implements the logic function
Zin = T1 + T6 . ADD + T4 . BR + ....
This signal is asserted during time slot TI for all instructions,
during T6 for an Add instruction, during T4 for an unconditional
branch instruction, and so on. The sequence of operations carried
out by the machine is determined by the wiring of the logic
elements, hence the name "hardwired". A controller that uses this
approach can operate at high speed. It has little flexibility, and the
complexity of the instruction set it can implement is limited.
INSTRUCTION PIPELINING
An instruction has a number of stages. Consider
subdividing instruction processing into two stages: fetch
instruction and execute instruction. There are times during
the execution of an instruction when main memory is not
being accessed. This time could be used to fetch the next
instruction in parallel with the execution of the current
one. Figure(a) depicts this approach. The pipeline has two
independent stages. The first stage fetches an instruction
and buffers it. When the second stage is free, the first