Hello, I have some questions regarding BTB management in gem5.

I can see the functions for btb table defined in src/cpu/pred/btb.cc. There is 
a lookup and update function for DefaultBTB class aswell. I could see the use 
of these 2 functions are in branch predictor code.

In predict function of src/cpu/pred/bpred_unit.cc file, I see that at first, 
branch predictor is called (uncondBranch or Branch predictor lookup funciton). 
If prediction is taken and instruction is not return and indirect type then 
BTB.lookup function is called to see if target address is in BTB or not 
(BTBHits).

Whereas, BTB.update is called in squash function only when the branch is 
actually taken but was mispredicted to be not taken


My questions are :

1) When BTB doesn't have a valid entry (when BTB.valid is false in 
bpred_unit.cc), I see that btbUpdate function is called. But this btbUpdate 
function is defined in branch predictor code like bi-mode, tournament etc. How 
does this btbUpdate function of branch predictor updates btb table in btb.cc 
(using DefaultBTB class)? Because I only see use of BTB.update during squash 
function only in bpred_unit.cc. btbUpdate function of branch predictor seems to 
update bp history within the branch predictor.


2) In btb.cc there is no function to make the btb entry valid (struct BTBEntry) 
to false. During squash, if the branch is actually not taken and was 
mispredicted to be taken, the btb entry still remains valid. Is this right? I 
understand that branch predictor is first checked for branch taken or not and 
then BTB.lookup is called if the prediction is taken. However, I am willing to 
change the order. I would like to check first if it's a BTB hit or not and then 
check if the branch predictor output is prediction taken or not.


3) I am trying to implement BTB with multiple branch targets (as per recent ARM 
CPUs). Any insights on how to approach this implementation in gem5 would be 
helpful

Thanks




_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org

Reply via email to