Professional Documents
Culture Documents
RISC Instruction Set:: I) Data Manipulation Instructions
RISC Instruction Set:: I) Data Manipulation Instructions
RISC Instruction Set:: I) Data Manipulation Instructions
look at existing ideas" and as a result of examination of how the instructions are actually used in
the real programs. RISC architecture starts with a small set of most frequently used instructions
which determines the pipeline structure of the machine enabling fast execution of those
instructions in one cycle. One cycle per instruction is achieved by exploitation of parallelism
through the use of pipelining. Basically we can characterize RISC as a performance oriented
architecture based on exploitation of parallelism through pipelining.
It includes:
SPARC (used by Sun Microsystems workstations, an outgrow of Berkeley RISC),
MIPS (an outgrow of Stanford MIPS project, used by Silicon Graphics), and a super-
scalar implementation of RISC architecture,
IBM RS/6000 (also known as PowerPC architecture)
Each instruction of the RISC machine is simple and straight forward. Thus, the time required to
execute each instruction can be shortened and the number of cycles reduced. Typically the
instruction execution time is divided in five stages, machine cycles, and as soon as processing of
one stage is finished, the machine proceeds with executing the second stage. However, when the
stage becomes free it is used to execute the same operation that belongs to the next instruction.
The operation of the instructions is performed in a pipeline fashion, similar to the assembly line
in the factory process. Typically those five pipeline stages are:
IF – Instruction Fetch
ID – Instruction Decode
EX – Execute
MA – Memory Access
WB – Write Back
The call instruction differs from other instructions of this group in one respect. It pushes the
address of the instruction that has been executed in delay slot into specified register. It will be
used as a return address. Thus to get the correct return address the address pushed by “call”
instruction should be incremented by 04h. This can be done in the control transfer instruction
used to return from procedure or function call.
v) Miscellaneous Instructions
In this group two types of instructions are included. Instructions “reti”, “getlpc” and “putpsw”
are privileged instructions andcan be executed only if P flag is 0. The non-priviliged group
comprises “getpsw” and “nop” instructions.
The “reti’ instruction is used for return from interrupt handling routine. It restores the previous
system operation mode(P flag) and loads the PC with the content of specified register. The
control transfer is delayed by one cycle.
The getlpc must be the first instruction of any interrupt handling routine. It moves the content of
LSTPC (the address of interrupted instruction) to register specified, which will be used to restart
the interrupted instruction.
The putpsw instruction is used to change the content of flags. Changing the flags C, S, Z, and V
is meaningless because these flags change dynamically and no one can predict the content
without actually analyzing the program. The result, of instruction will be effected only after the
end of execution cycle.
The getpsw pushes the content of flags into the register specified. The nop instruction does
nothing and generally used to fill the delay slot, if compiler is unable to fill it with some
meaningful instruction. Sometimes it used to introduce calculated amount of delay in program.
No instruction of this group except putpsw changes the flags, putpsw changes flags.
RISC processor is designed with load/store architecture, meaning that all operations are performed on
operands held in the processor registers and the main memory can only be accessed through the load and
store instructions.
RISC instructions are executed by using the technique called pipelining. There are four stages in pipeline
technique:
1) Instructions fetch cycle (IF):Send the program counter (PC) to memory and fetch the
current instruction from memory. Update the PC to the next sequential PC by adding one to the PC.
2) Instructions decode/register fetch cycle (ID):Decode the instruction and read the registers
corresponding to register source specifiers from the register file.
3) Execution (EX): The ALU operates on the operands prepared in the prior cycle, performing one
of three functions depending on the instruction type.
4) Store result (ST):Write the result into the register file, whether it comes from the memory system
(for a load) or from the ALU (for an ALU instruction).
Main modules
Let us consider modules of RISC processor. The main parts of processor is shown in Figure and are
explained bellow :
Registers:
Holds values of internal operation, such as the address of the instruction being executed and the data
being processed i.e. Program Counter Register, Status Register.
Barrel Shifter:
A barrel shifter is a digital circuit that can shift a data word by a specified number of bits in one clock
cycle. It can be implemented as a sequence of multiplexers and in such an implementation the output of
one Mux is connected to the input of the next Mux in a way that depends on the shift distance. For
example, take a four-bit barrel shifter, with inputs A, B, C and D. The shifter can cycle the order of the
bits ABCD as DABC, CDAB, or BCDA; in this case, no bits are lost. That is, it can shift all of the outputs
up to three positions to the right. The barrel shifter has a variety of applications, including being a useful
component in microprocessors (alongside the ALU. A barrel shifter is a combinational logic circuit with
n data inputs, n data outputs, and a set of control inputs that specify how to shift the data between input
and output. A barrel shifter that is part of a microprocessor CPU can typically specify the direction of
shift, the type of shift and the amount of shift.
Booth’s Multiplier:
Booth's multiplication algorithm is a multiplication algorithm that multiplies two signed binary numbers
in two's complement notation. Booth used desk calculators that were faster at shifting than adding and
created the algorithm to increase their speed. The area and speed of the multiplier is an important issue,
increment in speed results in large area consumption and vice versa. Multipliers play vital role in most of
the high performance systems. Performance of a system depends to a great extent on the performance of
multiplier thus multipliers should be fast and consume less area and hardware. For this one multiplier is
used with Booth’s Algorithm. The two main advantages of this algorithm are speed and the ability to do
signed multiplication (using two’s complement) without any extra conversions.
Pipelining
The basic concept of pipelining is to break up instruction execution activities into stages that can
operate independently. Every instruction passes through the same stages much like an assembly
line.
For example, we could set up the following stages for a MIPS pipeline.
With these pipeline stages, a sequence of instructions can be executed as shown below. Time
progresses from left to right. Each horizontal division represents one clock period.
Advantages of Pipelining
Disadvantages of Pipelining
Structural hazards:
Example 1:
o For cost-saving reasons, a CPU may be designed with a single interface to
memory.
o When a Load or Store gets to the MEM stage, the instruction in the IF stage must
be stalled.
Data Hazards
o All of the instructions after ADD use the result of the ADD instruction.
o Since the standard DLX pipeline waits until WB to write the value back, the SUB,
AND and OR instructions read the wrong value.
o Also, the error may not be deterministic if an interrupt occurs between the ADD
and the AND, which would allow the ADD to write its result.
For example, consider:
This inserts a bubble into the pipeline just as the structural hazard did.
o Just as with structural hazards, no instructions are started during the cycle in
which the bubble is inserted.
o This increases the number of cycles required and thus the CPI.