(Latest update: 2016/11/30) (But Aaron Fox is updating this on 10/20/2020)
This is a branch predictor simulator for Bimodal, Gshare, Hybrid, and YehPatt branch predictors.
To compile the program,
make
To run the program,
-
Bimodal predictor:
sim_bp bimodal < i_B > < i_BTB > < assoc_BTB > < tracefile >
< i_B > is the number of PC bits used to index the bimodal table, the rest are obvious.
< i_BTB > is the number of PC bits used to index the BTB.
< assoc_BTB > is the BTB associativity.
Setting either < i_BTB > or < assoc_BTB > to 0 implies that there is no BTB.
-
Gshare predictor:
sim_bp gshare < i_G > < h > < i_BTB > < assoc_BTB > < tracefile >
< i_G > and < h > are the number of PC and GHR bits used to index the gshare table, respectively.
The other parameters are identical to the bimodal case.
-
Hydbrid predictor:
sim_bp hybrid < i_C > < i_G > < h > < i_B > < i_BTB > < assoc_BTB > < tracefile >
< i_C > is the number of PC bits used to index the chooser table. The other parameters are same as in the bimodal and gshare cases.
-
YehPatt predictor:
sim_bp yehpatt < h > < p > < i_BTB > < assoc_BTB > < tracefile >
< h > and < p > are the number of PC and local history register bits used to index the history table and pattern table, respectively. The other parameters are identical to the bimodal case.
The output of this program includes
-
The commandline content
-
The branch target buffer
-
The predictor content (such as prediction table, chooser table, global history register, history table)
-
The statistics
a. Number of branches
b. Number of predictions from the branch predictor
c. Number of mispredictions from the branch predictor
d. Number of mispredictions from the BTB
e. Branch misprediction rate ((item d + item c) / item a)
The simulator reads a trace file in the following format:
< branch PC in hex > t|n
< branch PC in hex > t|n
...
The first field is the address of the branch instruction in memory. This field is used to index into predictors. The second field indicates whether the branch is actually taken or not. Here is a sample trace.
00a3b5fc t
00a3b604 t
00a3b60c n
Example trace files can be found at: https://www.cis.upenn.edu/~milom/cis501-Fall08/homework/hw3/hw3.html