DPCO 4th Unit Notes
DPCO 4th Unit Notes
INSTRUCTION EXECUTION
The execution of an instruction in a processor can be split up into a number of stages.
How many stages there are, and the purpose of each stage is different for each
processor design.
Examples: 2 stages (Instruction Fetch / Instruction Execute) and 3 stages (Instruction
Fetch, Instruction Decode, Instruction Execute).
The MIPS processor has 5 stages of Instruction Execution
1. IF:The Instruction Fetch stage fetches the next instruction from memory using the
address in the PC (Program Counter) register and stores this instruction in the IR
(Instruction Register)
2. ID:The Instruction Decode stage decodes the instruction in the IR, calculates the
next PC, and reads any operands required from the register file.
3. EX:The Execute stage "executes" the instruction. In fact, all ALU operations are done
in this stage. (The ALU is the Arithmetic and Logic Unit and performs operations
such as addition, subtraction, shifts left and right, etc.)
4. MA:The Memory Access stage performs any memory access required by the current
instruction, So, for loads, it would load an operand from memory. For stores, it
would store an operand into memory. For all other instructions, it would do nothing.
5. WB:Write Back For instructions that have a result (a destination register), the Write
Back writes this result back to the register file. Note that this includes nearly all
instructions, except nops (a nop, no-op or no-operation instruction simply does
nothing) and s (stores).
2. Read one or two registers, using fields of the instruction to select the registers to
read. For the load word instruction, we need to read only one register, but most
other instructions require reading two registers.
For example, all instruction classes, except jump, use the arithmetic-logical
unit(ALU) after reading the registers.
The memory-reference instructions use the ALU for an address calculation, the
arithmetic-logical instructions for the operation execution, and branches for
comparison.
A memory-reference instruction will need to access the memory either to read
data for a load or write data for a store.
An arithmetic-logical or load instruction must write the data from the ALU or
memory back into a register.
Lastly, for a branch instruction, we may need to change the next instruction
address based on the comparison; otherwise, the PC should be incremented by 4
to get the address of the next instruction.
Figure 4.1 An abstract view of the implementation of the MIPS
The following figure shows the high-level view of a MIPS implementation, focusing on
the various functional units and their interconnection.
A logic element need to be added that chooses from among the multiple
sources and steers one of those sources to its destination.
This selection is commonly done with a device called a multiplexor, also called a
data selector.
The multiplexor selects from among several inputs based on the setting of its
control lines. The control lines are set based primarily on information taken from
the instruction being executed.
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
The top multiplexor controls the value of PC(PC+4 or the branch destination
address.
The middle multiplexor is used to steer the output of the ALU for writing in to the
register file.
The bottom most multiplexor is used to determine whether the second ALU input
is from the registers
2.BUILDING A DATAPATH
Types of data path
Single-cycle Datapath: Each instruction executes in a single cycle
Multi-cycle Datapath: Each instruction is broken up into a series of shorter steps
Pipelined Datapath: Each instruction is broken up into a series of steps; Multiple
instructions execute at once
This simplest data path will attempt to execute all instructions in one clock cycle.
No data path resource can be used more than once per instruction, so any element
needed more than once must be duplicated need a memory for instructions separately
Many of the elements can be shared by different instruction flows.
To share a data path element between two different instruction classes, multiple
connections to the input of an element, using a multiplexor and control signal to select
among the multiple inputs.
A reasonable way to start a data path design is to examine the major components
required to execute each class of MIPS instructions.
To share a data path element between two different instruction classes, need to allow
multiple connections to the input of an element.
If two instructions have two different formats to store result so need to support two
different sources for the data stored into the register file.
For that need two multiplexers, one multiplexor is placed at the ALU input and another
at the data input to the register file.
Instruction memory:
The instruction memory need only provide read access because the data path
does not write instructions.
The instruction memory is called as combinational element because it will
perform only read access.
The output at any time reflects the contents of the location specified by the
address input,
No read control signal is needed.
Program Counter:
The program counter is a 32-bit register that is written at the end of every
clock cycle
Does not need a write control signal.
The register containing the address of the instruction in the program being
executed.
Adder:
The adder is an ALU wired to always add its two 32-bit inputs and place the sum
on its output.
Fetching Phase:
To execute any instruction, must start by fetching the instruction from memory.
To prepare for executing the next instruction, must also increment the
program counter
So that it points at the next instruction, 4 bytes (PC+4).
There are two elements need to implement the R-format ALU operations such as
1. Register file
2. ALU
1.Register file:
The register file contains all the registers and has two read ports and one write
port.
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
The register file always outputs the contents of the registers corresponding to
the Read register inputs on the outputs
No other control inputs are needed.
Register write must be explicitly indicated by asserting the write control signal.
The register number to the register file is all 5 bits wide to specify one of 32 bits
wide.
2.ALU:
ALU takes two 32 bit inputs and produces a 32 bit result as well as 1 bit signal if
the result is 0.
The operation to be performed by the ALU is controlled with the ALU operation
signal, which will be 4 bits wide.
The Zero detection output used to implement branches.
2.4 Data path for Memory reference instructions
Consider the MIPS load word and store word instructions, which have the general form.
lw $t1,offset_value($t2)
2.sw $t1,offset_value ($t2).
These instructions compute a memory address by adding the base register, which is
$t2, to the 16-bit signed off set field contained in the instruction.
Memory address= base register+16-bit signed off set field
If the instruction is a store, the value to be stored must also be read from the register
file where it resides in $t1.
If the instruction is a load, the value read from memory must be written into the
register file in the specified register, which is $t1.
Units needed to implement loads and stores
To implement MIPS load and store instructions - four units required
1.Register file
2.ALU
3.Data Memory
4.Sign extension unit
1.
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
Register file:
The register file contains all the registers and has two read ports and one write
port.
The register file always outputs the contents of the registers corresponding to
the Read register inputs on the outputs
No other control inputs are needed.
Register write must be explicitly indicated by asserting the write control signal.
The register number to the register file is all 5 bits wide to specify one of 32 bits
wide.
2.ALU:
ALU takes two 32 bit inputs and produces a 32 bit result as well as 1 bit signal if
the result is 0.
The operation to be performed by the ALU is controlled with the ALU operation
signal, which will be 4 bits wide.
The Zero detection output used to implement branches.
3.Data Memory unit:
The memory unit is a state element with inputs for the address and the write
data.
It produces a single output for the read result.
Data Memory unit has separate read and write control lines for read and write
operation.
Register file does not require read signal but memory unit needs a read signal
Because the register file, reading the value of an invalid address can cause
problems.
4.Sign Extension unit:
The sign extension unit has a 16-bit data input and that sign-extended into a 32-
bit result.
2.5 Data Path for Branch Instructions
There are two kinds of branch instructions are available beq-branch equal,bnq-branch
unequal
The beq instruction has three operands, in that
1.Two operands are registers that are compared for equality
2.One operand is a 16-bit off set used to compute the branch target address
relative to the branch instruction address.
Ex: beq $t1,$t2,offset,
To implement this instruction, must compute the branch target address
Branch target address:
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
When the ALUOP value is 10, then the function code is used to set the ALU control
input.
Multiple levels of decoding functions:
1. The main control unit generates the ALUOP bits.
2. ALUOP bit is used as a input to the ALU control.
3. That ALU control generates the actual signals to control the ALU unit.
Mapping 2‑bit ALU Op field and 6‑bit funct field
2‑bit ALUOp field and the 6‑bit funct field mapped 4-bit ALU control bits.
There are 64 possible values are available for function field .
The function field is used only when the ALUOP bits equal to 10.
A small piece of logic that recognizes the subset of possible values and causes
the correct setting of the ALU control bits.
Don’t-care term: An element of a logical function in which the output does not depend
on the values of all the inputs. Don’t-care terms may be specified in different ways.
R-Format:
The first row of the table corresponds to the R-format instructions (add, sub, AND,
OR, and slt).
For all these instructions, the source register fields are rs and rt, and the
destination register field is rd; this defines how the signals ALUSrc and RegDst
are set.
R-type instruction writes a register (Reg-Write = 1), but neither reads nor writes
data memory.
The ALUOp field for R-type instructions is set to 10 to indicate that the ALU
control should be generated from the funct field.
Load Word and store word:
The second and third rows of this table give the control signal settings for lw and
sw.
These ALUSrc and ALUOp fi elds are set to perform the address calculation.
The MemRead and MemWrite are set to perform the memory access.
RegDst and RegWrite are set for a load to cause the result to be stored into the
rt register.
Branch instruction:
The branch instruction is similar to an R-format operation, since it sends the rs
and rt registers to the ALU.
The ALUOp field for branch is set for a subtract (ALU control = 01), which is
used to test for equality. Notice that the MemtoReg field is irrelevant when the
RegWrite signal is 0: since the register is not being written, the value of the
data on the register data write port is not used.
Thus, the entry MemtoReg in the last two rows of the table is replaced with X
for don’t care. Don’t cares can also be added to RegDst when RegWrite is 0.
5 SIMPLE IMPLIMENTATION:
Single cycle implementation also called single clock cycle implementation.
Single cycle implementation is an instruction which is executed in one clock cycle.
The jump instruction looks somewhat like a branch instruction but computes the
target PC differently and is not conditional.
Like a branch, the low-order 2 bits of a jump address are always 00two.
The next lower 26 bits of this 32-bit address come from the 26-bit immediate field in
the instruction.
The upper 4 bits of the address that should replace the PC come from the PC of the
jump instruction plus 4.
Thus, we can implement a jump by storing into the PC the concatenation of
The upper 4 bits of the current PC + 4
The 26-bit immediate field of the jump instruction
The bits 00two
An additional multiplexor (at the upper right) is used to choose between the jump
target and either the branch target or the sequential instruction following this one.
This multiplexor is controlled by the jump control signal.
The jump target address is obtained by shifting the lower 26 bits of the jump
instruction left 2 bits, effectively adding 00 as the low-order bits, and then
concatenating the upper4 bits of PC + 4 as the high-order bits, thus yielding a 32-bit
address.
Why single cycle implementation is not used today?
Single cycle implementation is not used mostly because of the following reasons:
1. It is inefficient.
2. Clock cycle have same length for every instruction.
3. Overall performance is very poor because it has too long clock cycle.
6 CONTROL DESIGN TYPES
A control unit based on the received inputs generates control signals, which are then sent to
the central processor. The computer’s processor then tells the attached hardware what
operations to perform.
It coordinates the sequence of data movements into, out of, and between a
processor’s many sub-units and data flow inside the processor.
It interprets instructions.
It receives external instructions or commands to which it converts to sequence of
control signals.
It controls many execution units (i.e. ALU, data buffers and registers) contained
within a CPU.
Types of Control Unit
There are two types of control units:
1. Hardwired control unit
2. Micro programmable control unit.
6.1 Hardwired Control Unit
In the Hardwired control unit, the control signals are generated by specially designed
hardware logical circuits, the signal generation method cannot be modified without physical
change of the circuit structure.
The circuit that generates specific sequences of control signals in response to the
supplied instruction
The opcode of an instruction contains the basic data for control signal generation.
In the instruction decoder, the operation code is decoded.
The instruction decoder constitutes a set of many decoders that decode different
fields of the instruction opcode.
As a result, few output lines going out from the instruction decoder obtains active
signal values.
These output lines are connected to the inputs of the matrix that generates control
signals for executive units of the computer.
This matrix implements logical combinations of the decoded signals from the
instruction opcode with the outputs from the matrix that generates signals
representing consecutive control unit states and with signals coming from the
outside of the processor, e.g. interrupt signals.
The matrices are built in a similar way as a programmable logic arrays
Control signals for an instruction execution are generated till the end of the
instruction execution cycle.
A number of signals generated by the control signal generator matrix are sent back
to inputs of the next control state generator matrix.
This matrix combines these signals with the timing signals
When a new instruction arrives at the control unit, the control units is in the initial
state of new instruction fetching.
Instruction decoding allows the control unit enters the first state relating to
execution of the new instruction
A change of any of the earlier mentioned signals stimulates the change of the
control unit state.
When an external signal appears, (e.g. an interrupt) the control unit takes entry into
a next control state that is the state concerned with the reaction to this external
signal (e.g. interrupt processing).
The values of flags and state variables of the computer are used to select suitable
states for the instruction execution cycle.
The last states in the cycle are control states that commence fetching the next
instruction of the program: sending the program counter content to the main
memory address buffer register and next, reading the instruction word to the
instruction register of computer.
When the ongoing instruction is the stop instruction that ends program execution,
the control unit enters an operating system state, in which it waits for a next user
directive.
It is designed with usual goals of minimizing the number of components used and
maximizing the speed of operation.
The control unit is implemented using hardware (gates, flip-flops, and counters).
This circuit uses the bits from the Opcode field in our instructions, bits from the flag
(or status) register, signals from the bus, and signals from the clock. as inputs
Advantages:
1. Hardwired Control Unit is fast.
2. Optimized design with low number of components and fast mode of operation.
3. Faster than micro- programmed control unit.
4. It does not require control memory.
Disadvantage
o Modifications or addition in the design is very difficult, complex and expensive.
7.PIPELINING
Pipelining is an implementation technique in which multiple instructions are executed
simultaneously by overlapping them in execution. Ie Multiple instructions are executed
simultaneously to save time
A technique used in advanced microprocessors where the microprocessor begins
executing a second instruction before the first has been completed. –
A Pipeline is a series of stages, where some work is done at each stage and the work
is not finished until it has passed through all stages
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
With pipelining, the computer architecture allows the next instructions to be fetched
while the processor is executing an instruction
How Pipelines Works :
The pipeline is divided into segments and each segment can execute its operation
concurrently with the other segments.
Once a segment completes an operation, it passes the result to the next segment
in the pipeline and fetches the next operations from the preceding segment.
The pipelined approach takes much less time since all steps—called stages in
pipelining are executed concurrently.
If all the stages take about the same amount of time then the speed-up due to
pipelining is equal to the number of stages in the pipeline,
In this way, the number of operations performed per second is increased even
though the elapsed time needed to perform anyone operation is not changed.
Pipelining is a particularly effective way of organizing concurrent activity in a
computer system.
Pipelining improves performance by increasing instruction throughput
Thus the overall performance of the processor is improved both in terms of resource
utilization and throughput
7.1Stages in MIPS Pipelining
1. Instruction Fetch(IF): Fetch instruction from memory.
2. Instruction Decode(ID):Read registers while decoding the instruction. The
regular format of MIPS instructions allows reading and decoding to occur
simultaneously.
3. Excute(Ex):Execute the operation or calculate an address
4. Memory Access(MEM):Access an operand in data memory.
5. Write Back(WB)Write the result into a register
7.3Pipelined Datapath
The division of an instruction into five stages means a five-stage pipeline in which up
to five instructions will be in execution during any single clock cycle.
Thus, the single cycle datapath is separated to five pieces, with each piece named
corresponding to a stage of instruction execution:
1. IF: Instruction fetch
2. ID: Instruction decode and register fi le read
3. EX: Execution or address calculation
4. MEM: Data memory access
5. WB: Write back
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
The five components correspond roughly to the way the datapath is drawn;
instructions and data move generally from left to right through the five stages as they
complete execution.
There are, however, two exceptions to this left -to-right flow of instructions:
The write-back stage, which places the result back into the register fi le in the
middle of the datapath
The selection of the next value of the PC, choosing between the incremented
PC and the branch address from the MEM stage
Data flowing from right to left does not aff ect the current instruction; these reverse
data movements influence only later instructions in the pipeline. Note that the fi rst
right-toleft flow of data can lead to data hazards and the second leads to control
hazards. ❖
One way to show what happens in pipelined execution is to pretend that each
instruction has its own datapath, and then to place these datapaths on a timeline to
show their relationship.
Figure: Instructions being executed using the single-cycle datapath assuming pipelined
execution.
shows, the instruction memory is used during only one of the five stages of an
instruction, allowing it to be shared by following instructions during the other four
stages.
To retain the value of an individual instruction for its other four stages, the value read
from instruction memory must be saved in a register.
Below figure shows the pipelined datapath with the pipeline registers highlighted. All
instructions advance during each clock cycle from one pipeline register to the next.
The registers are named for the two stages separated by that register.
For example, the pipeline register between the IF and ID stages is called IF/ID. Notice
that there is no pipeline register at the end of the write-back stage.
All instructions must update some state in the processor—the register file, memory,
or the PC.
FIGURE IF and ID: First and second pipe stages of an instruction with the active portions of
the datapath highlighted
FIGURE EX: The third pipe stage of a load instruction, highlighting the portions of the
datapath
4. Memory access: The top portion of Figure shows the load instruction reading the data
memory using the address from the EX/MEM pipeline register and loading the data into the
MEM/WB pipeline register.
5. Write-back: The bottom portion of Figure shows the final step: reading the data from the
MEM/WB pipeline register and writing it into the register file in the middle of the figure.
This walk-through of the load instruction shows that any information needed in a later pipe
stage must be passed to that stage via a pipeline register
FIGURE MEM and WB: The fourth and fifth pipe stages of a load instruction, highlighting
the portions of the datapath
8. HAZARDS
Hazards are situations that prevent the next instruction in the instruction cycle from being
executed during its designated clock cycle. Hazards reduce the performance of the Pipelining
3 Types of hazard
1.Structural hazard.
2.Data hazard
3.Control hazard
8.1 Structural Hazard
Structural Hazard occurs when a planned instruction cannot be executed in the proper
clock cycle because the hardware does not support the combination of instructions
that are set to execute.
MIPS instruction set was designed to be pipelined, making it fairly easy for designers to
avoid structural hazards when designing a pipeline.
However, If the pipeline in below Figure had a fourth instruction in the same clock cycle
the first instruction is accessing data from memory while the fourth instruction is
fetching an instruction from that same memory. Without two memories, this pipeline
could have a structural hazard.
Here the sub instruction uses the result of add instruction($s0). The add instruction
cannot write its result until the fifth stage. This result is wasting 3 clock cycle
Since the stall occurs due to the non-availability of data, this is termed as data hazard.
a data hazard could severely stall the pipeline.
Figure below shows the connection to forward the value in $s0 after the execution
stage of the add instruction as input to the execution stage of the sub instruction.
Even with forwarding, we would have to stall one stage for a load-use data hazard,
Stalling A pipeline stall (also called bubble) is a delay in execution of an instruction in
order to resolve a hazard
Problem :Reordering Code to Avoid Pipeline Stalls
Consider the following code segment in C:
a = b + e;
c = b + f;
MIPS code for this segment, assuming all variables are in memory and are
addressable as off sets from $t0:
lw $t1, 0($t0)
lw $t2, 4($t0)
add $t3, $t1,$t2
sw $t3, 12($t0)
lw $t4, 8($t0)
add $t5, $t1,$t4
sw $t5, 16($t0)
Find the hazards in the above code segment and reorder the instructions to
avoid any pipeline stall
Both add instructions have a hazard because of their respective dependence on
the immediately preceding lw instruction. Notice that bypassing eliminates
several other potential hazards, including the dependence of the first add on the
first lw and any hazards for store instructions. Moving up the third lw instruction
to become the third instruction eliminates both hazards:
lw $t1, 0($t0)
lw $t2, 4($t0)
lw $t4, 8($t0)
add $t3, $t1, $t2
sw $t3 12($t0)
add $t5, $t1,$t4
sw $t5, 16($t0)
.
8.3 Control Hazards
Ths is also called as branch hazard, when the proper instruction cannot execute in the
proper pipeline clock cycle because the instruction that was fetched is not the one that
is needed, ie the flow of instruction addresses is not what the pipeline expected.
A control hazard, arising from the need to make a decision based on the results of one
instruction while others are executing.
If a branch instruction comes, the pipeline fetches it but cannot possibly know what the
next instruction should be, since it only just received the branch instruction from
memory.
Control hazard occurs less than data hazard, nothing is effective as forwarding to data
hazard.
Solution for Control Hazard
1. Pipeline Stall cycles
2. Branch delay slots
3. Branch predictors
8.3.1Stalling:
One possible solution is to stall immediately after a branch is fetched, waiting until the
pipeline determines the outcome of the branch and knows what instruction address to
fetch from. Stalling the instruction until the branch is complete is too slow
That an extra hardware can test registers, calculate the branch address, and update the
PC during the second stage of the pipeline
.
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
Even with this extra hardware, It cannot resolve the branch in the second stage as it is
often the case for longer pipelines and it is too high cost for more computers
So need to focus on another method to resolve the control hazard that is called branch
prediction
8.3.2Delayed Branched
MIPS processors use a branch delay slot to eliminate single-cycle stalls after branches.
The instruction after a conditional branch is always executed , whether the branch is
taken or not!
The effect is to execute one or more instructions following the conditional branch
before the branch is taken.
the assembler automatically arrange the instruction to get the branch
The branch performance is to reduce the cost of the taken branch
Efficient for small pipelines, inefficient for long pipeline
Moving the branch decision up requires two actions to occur earlier
1. Computing the Branch Target Address
2. Evaluating the branch decision
8.3.3Branch Prediction
A method of resolving a branch hazard that assumes a given outcome for the branch
and proceeds from that assumption rather than waiting to ascertain the actual
outcome
One improvement over branch stalling is to predict that the branch will not be taken
and thus continue the execution of instructions
Figure shows the Pipeline when the branch is Taken/not Taken
If branches are untaken,half the time and if it costs little to discard the instructions,
this optimization halves the cost of control hazard
If the branch is taken, the instructions that are being fetched and decoded must be
discarded, execution continues at branch target
2 Types: static and dynamic
Static Branch Prediction:A more sophisticated version of branch prediction
would have some branches predicted as taken and some as untaken. In the
case of programming, at the bottom of loops are branches that jump back to
the top of the loop. Always predict taken for branches that jump to an earlier
address.
Dynamic Branch Prediction
Prediction of branches at runtime using runtime information is called
dynamic branch prediction
One approach is to look up the address of the instruction to see if a branch
was taken the last time this instruction was executed, and, if so, to begin
fetching new instructions from the same place as the last time. This
technique is called dynamic branch prediction.
A branch prediction buffer is a small memory indexed by the lower portion
of the address of the branch instruction The memory contains a bit that says
whether the branch was recently taken or not
Dynamic hardware predictors make their guesses depending on the
behavior of each branch and may change predictions for a branch over the
life of a program.
adjusting the next prediction depending on the success of recent guesses.
One popular approach to dynamic prediction of branches is keeping a
history for each branch as taken or untaken, and then using the recent past
behavior to predict the future.
2 Types
1. One-bit prediction scheme
2 States : Taken or Not Taken
9.Exceptions in MIPS
Exceptions and interrupts are unexpected events that disrupt the normal flow of
instruction execution.
An exception is an unexpected event from within the processor. An interrupt is an
unexpected event from outside the processor.
Exception and interrupt handling is implemented multicycle CPU design.
Events that trigger exceptions and interrupt
Arithmetic overflow occurs during the execution of an add, addi, or sub
instruction. If the result of the computation is too large or too small to hold in
the result register, the Overflow output of the ALU will become high during the
execute state. This event triggers an exception.
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
PART -A
1.Define Instruction execution
The execution of an instruction in a processor can be split up into a number of stages. How
many stages there are, and the purpose of each stage is different for each processor design.
8. EX:The Execute stage "executes" the instruction. In fact, all ALU operations are done
in this stage. (The ALU is the Arithmetic and Logic Unit and performs operations
such as addition, subtraction, shifts left and right, etc.)
9. MA:The Memory Access stage performs any memory access required by the current
instruction, So, for loads, it would load an operand from memory. For stores, it
would store an operand into memory. For all other instructions, it would do nothing.
10.WB:Write Back For instructions that have a result (a destination register), the Write
Back writes this result back to the register file. Note that this includes nearly all
instructions, except nops (a nop, no-op or no-operation instruction simply does
nothing) and s (stores).
lw $t1,offset_value($t2)
2.sw $t1,offset_value ($t2).
12.What is Data Memory unit?
The memory unit is a state element with inputs for the address and the write
data.
It produces a single output for the read result.
Data Memory unit has separate read and write control lines for read and write
operation.
Register file does not require read signal but memory unit needs a read signal
Because the register file, reading the value of an invalid address can cause
problems.
13.Define Sign Extension unit
The sign extension unit has a 16-bit data input and that sign-extended into a 32-
bit result.
14.What is Branch target address?
It is an address specified in a branch, which becomes the new program counter
(PC) if the branch is taken.
If the operands are equal, the branch target address becomes the new PC, and it
is called as branch is taken.
If the operands are not equal, the incremented PC should replace the current PC
and it is called as branch is not taken.
20.Define Pipelining
Pipelining is an implementation technique in which multiple instructions are executed
simultaneously by overlapping them in execution. Ie Multiple instructions are executed
simultaneously to save time
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
A Pipeline is a series of stages, where some work is done at each stage and the work is not
finished until it has passed through all stages
Types: Instruction Pipeline and Arithmetic Pipeline
.
21.What is a Hazard
Hazards are situations that prevent the next instruction in the instruction cycle from being
executed during its designated clock cycle. Hazards reduce the performance of the Pipelining
3 Types of hazard
4.Structural hazard.
5.Data hazard
6.Control hazard
22.Define Structural Hazard
Structural Hazard occurs when a planned instruction cannot be executed in the proper
clock cycle because the hardware does not support the combination of instructions
that are set to execute.
23 Define Data Hazards
It is called a pipeline data hazard, When a planned instruction cannot execute in the
proper clock cycle because data that is needed to execute the instruction is not yet
available.
Data hazards occur when the pipeline must be stalled because one step must wait for
another to complete.
In a computer pipeline, data hazards arise from the dependence of one instruction on
an earlier one that is still in the pipeline.
Example: suppose we have an add instruction followed immediately by a subtract
instruction that uses the sum ($s0):
add $s0, $t0, $t1
sub $t2, $s0, $t3
24. Write solutions to data hazard
1) forwarding or bypassing.
2) Stalling
3) Reordering Code to Avoid Pipeline Stalls
25 What is Control Hazards
Ths is also called as branch hazard, when the proper instruction cannot execute in the
proper pipeline clock cycle because the instruction that was fetched is not the one that
is needed, ie the flow of instruction addresses is not what the pipeline expected.
A control hazard, arising from the need to make a decision based on the results of one
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
32 What is meant by branch folding and what is the condition to implement it?
The instruction fetch unit has executed the branch instruction concurrently with in the
Downloaded by jini A (jini.cse1988@gmail.com)
lOMoARcPSD|56743091
PART B
1.Explain the building data path in detail with data path segment for 3 instruction classes
2.Explain the control design unit in detail
3. Write in detail about i)Hardwired control ii)Microprogrammed control
4.what is Pipelining? Explain in detail
5.Write about pipelined datapath and control in detail
6.Define Hazards.What are the types of Hazards?Explain in detail