169 views

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?

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!  :)

edited
0
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.
0

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.

0
What is the convention that you have mentioned?
0
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.