The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+1 vote

Can anyone explain the concept of branch folding, I didn't get it after reading from hamacher.Further it was explained using this diagram,I have a doubt here : Is it possible to have two decode operations in the same cycle (Cycle 6 D3 and D5) will it not be a structural hazard as both the instructions are using the same device?Hamacher Page 469 Diagram 

asked in CO & Architecture by Junior (605 points) | 99 views

1 Answer

0 votes

Any instructions that lie between the branch instruction and it's target are basically discarded : branch folding.

Now coming to your diagram doubt, Here it's clearly mentioned that I5 is the branch instruction and Ik is it's target, so need not to worry about any type of hazard because I6 and all other instructions between I5 and Ik are anyways discarded(As per my definition).
So the target instruction Ik will fetch the instruction only after the branch instruction I5 is over.
Hope it's clear enough!  :)

answered by Active (1.5k points)
edited by
Understood the branch folding part.

The hazard which I am talking about is that how D3 and D5 of I3 and I5 are being executed in the same clock cycle in spite of the fact that there is only one decode unit.Further the instruction queue should be of length 2 at cycle 4,why is it still 1? As because it has already F3 and F4 and none of them have been dispatched till that cycle.

May be these questions seem to be silly but I am getting a feeling that I am missing a very basic concept,so can you please explain this part.

If you see at clk 4 the Instruction queue length is 1. Now think when can it be 1? Only when at clk4 the already present instruction of queue i.e. I3 is now at dispatched/decode stage and in same clk4  I4 is being fetched into queue, though diagram it is shown at clk 6(which is correct according to convention) it could even be placed at clk 5, thus at clk 6 only I5 is being dispatched and decode.

I hope this explanation goes with Carl, but this is what logically possible otherwise no two instruction can perform in the same stage in the same cycle.

Let me know if I am going wrong somewhere. Peace.

What is the convention that you have mentioned?
When an instruction is having dependency than decode just before execute is what I have mostly seen because why to fetch wrong operands, But that convention is nothing to be noticed your concept won't change with or without it.

Related questions

+3 votes
1 answer
+2 votes
0 answers
asked Dec 19, 2017 in CO & Architecture by Tesla! Veteran (15.2k points) | 70 views
+3 votes
2 answers
asked Jun 8, 2017 in CO & Architecture by reena_kandari Boss (8.3k points) | 276 views

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

34,268 questions
40,982 answers
39,895 users