The book says that a total time required for a pipeline with k stages to execute n instructions is as follows.
$T _{k,n} =[pqnk+(1-pq)(k+n-1)] \tau$
p is the probability of encountering a branch instruction.
q is the probability that execution of a branch instruction I causes a jump to a nonconsecutive address.
(Each jump requires the pipeline to be cleared)
However, I can not understand why this makes sense. The formula indicates that
"If there is a branch instruction and is taken, the number of stages is nk. And in the remaining cases, it is (1-pq)(k+n-1)
I can understand the second case, but why is the number of stages nk in the first case? I think that the result of nk stages never occurs unless every instruction is a branch instruction so that the pipeline is cleared every time each instruction is executed. Instructions after a branch instruction which is taken can be executed in the pipeline, so it must be less than nk. What do I miss?