0
$\begingroup$

My question relates to a video I watched on YouTube.

The pipeline is a 5-stage pipeline which include fetch, decode, ALU, Mem (data), and Write.

It mentions that nothing is fetched until we're sure what to fetch. How can that be though? Won't you need to fetch and decode an instruction first to know what to fetch?

He mentions that the ADDI instruction gets fetched, but then goes in a bubble since it's not a branch. I really do not understand what is happening here and why the CPI for each instruction are ADDI=2, ADD=2, and BNEZ=3.

Can any explain to me what's going on here? Maybe a table with cycle iteration would be helpful.

Here's the video link: Branch Prediction question

enter image description here

$\endgroup$
2
$\begingroup$

I figured out what he means: fetch the instruction and decode it, but do not fetch the next instruction until you've determined whether it's a branch or non-branch instruction.

For the non-branch instructions, it will fetch next instruction after the decode stage. But for the branch instruction, it will require an extra cycle to determine it should stay in the loop or not.

The CPI does add up if I do follow through with what I've mentioned. I've added a picture to give you a better picture of what's happening at each cycle.enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.