├── README.md └── TAGE ├── Branch_Benchmark.zip ├── Different_TAG_Lengths └── Index_Tag_Generator_Model_3.v └── Source ├── Bimodal_Table.v ├── BranchAddress.v ├── Comparator.v ├── Incrementer.v ├── Index_Tag_Generator.v ├── Statistics.v ├── TAGE_Controller.v ├── TAGE_Table.v ├── TopLevel.v ├── TopLevel_testbench.v ├── prediction.v ├── update_history.v └── update_predictor.v /README.md: -------------------------------------------------------------------------------- 1 | # TAGE based Predictor Verilog Code 2 | Verilog Implementation of TAGE based predictor by Andre Seznec and Pierre Michaud 3 | The implementation is based on this paper http://www.irisa.fr/caps/people/seznec/JILP-COTTAGE.pdf 4 | 5 | I have done some modification with respect to the tag length, this was to limit the hardware bugdet by varying the tag- length and number of indexes 6 | 7 | The TAGE predictor has 1 Bimodal Table and 4 TAGGED predictor Component with different geometric lengths respectively 7, 14, 44, 130 8 | 9 | Table 1 . Tag-length of Different tag component in different models 10 | 11 | | Model No | T1 | T2 | T3 | T4 | No of Entries | Total hardware budget in Bits | 12 | |-----------|----|----|----|----|---------------|--------------------------------| 13 | | 2 | 8 | 8 | 9 | 9 | 512 | 29174 | 14 | | 3 | 5 | 5 | 5 | 5 | 1024 | 44032 | 15 | 16 | The source directory has model 2(only the index_Tag.Generator.v file is changed for different models). The Model 3 is there in directory Different_TAG_Lengths. 17 | 18 | 19 | I have provided a sample test benchmark. The trace was obtained from the 2011 championship branh predictor tournament.They are in Zip file Branch_Benchmark.zip 20 | 21 | The implementation is basic, you can optimize the verilog code as per your requirement based on the many TAGE papers published. 22 | -------------------------------------------------------------------------------- /TAGE/Branch_Benchmark.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RoyanTuscano/-TAGE-based-Predictor-Verilog-Code/eed1c7e3b0e16164a2535cf962eb747bef903918/TAGE/Branch_Benchmark.zip -------------------------------------------------------------------------------- /TAGE/Different_TAG_Lengths/Index_Tag_Generator_Model_3.v: -------------------------------------------------------------------------------- 1 | `timescale 1ns / 1ps 2 | //Model 3 with all tag lenths as 5 and no of entries 1024 i.e index bit size of 10 3 | 4 | module Index_Tag_Generator(CLK,reset,ghist,pc_addr, Index_bank1,Index_bank2, 5 | Index_bank3, Index_bank4, 6 | Comp_tag_bank1, Comp_tag_bank2, Comp_tag_bank3 7 | ,Comp_tag_bank4, index_tag_enable); 8 | 9 | //parameter HistLen_Bank1=8; 10 | //parameter HistLen_Bank2=15; 11 | //parameter HistLen_Bank3=44; 12 | //parameter HistLen_Bank4=130; 13 | 14 | parameter GlobLen=131; //This is the global history length 15 | 16 | //parameter OutLen1=0 ; //this is the length that will be thrown out at the end and wont be used...HistLen%OutLen 17 | //parameter OutLen2=7 ; 18 | //parameter OutLen3=4 ; 19 | //parameter OutLen4=2; 20 | parameter ADDRESS_SIZE=32; //length of the program counter 21 | 22 | 23 | 24 | input CLK,reset; 25 | input [GlobLen-1:0] ghist; 26 | input [ADDRESS_SIZE - 1:0] pc_addr; 27 | input index_tag_enable; 28 | 29 | output reg [tag_len-1 : 0] Comp_tag_bank1, Comp_tag_bank2; 30 | output reg [tag_len : 0] Comp_tag_bank3, Comp_tag_bank4; 31 | output reg [IL-1 : 0] Index_bank1, Index_bank2, Index_bank3, Index_bank4; 32 | 33 | always @(posedge CLK) begin 34 | if(reset==1'b0)begin 35 | Comp_tag_bank1<={tag_len{1'b0}}; 36 | Comp_tag_bank2<={tag_len{1'b0}}; 37 | Comp_tag_bank3<={9{1'b0}}; 38 | Comp_tag_bank4<={9{1'b0}}; 39 | Index_bank1<={IL{1'b0}}; 40 | Index_bank2<={IL{1'b0}}; 41 | Index_bank3<={IL{1'b0}}; 42 | Index_bank4<={IL{1'b0}}; 43 | 44 | end 45 | else if(index_tag_enable==1'b1) begin 46 | //compute index 47 | 48 | Index_bank1<=(pc_addr[9:0])^(pc_addr[19:10])^(pc_addr[29:20])^({2'b00,{ghist[7:0]}}); 49 | Index_bank2<=(pc_addr[9:0])^(pc_addr[19:10])^(pc_addr[29:20])^(ghist[9:0])^({5'b0000,{ghist[14:10]}}); 50 | Index_bank3<=(pc_addr[9:0])^(pc_addr[19:10])^(pc_addr[29:20])^(ghist[9:0])^(ghist[19:10])^(ghist[29:20])^(ghist[39:30])^({6'b000000,{ghist[43:40]}}); 51 | Index_bank4<=(pc_addr[9:0])^(pc_addr[19:10])^(pc_addr[29:20])^(ghist[9:0])^(ghist[19:10])^(ghist[29:20])^(ghist[39:30]) 52 | ^(ghist[49:40])^(ghist[59:50])^(ghist[69:60])^(ghist[79:70])^(ghist[89:80])^(ghist[99:90])^(ghist[109:100]) 53 | ^(ghist[119:110])^(ghist[129:120]); 54 | //Compute Tag 55 | Comp_tag_bank1<=(pc_addr[4:0])^(ghist[4:0]) ^({ghist[3:0],1'b0}); 56 | Comp_tag_bank2<=(pc_addr[4:0])^(ghist[4:0])^(ghist[9:5])^(ghist[14:10])^({ghist[3:0],1'b0})^({ghist[7:4],1'b0})^({ghist[11:8],1'b0})^({1'b0,ghist[14:12],1'b0}); 57 | Comp_tag_bank3<=(pc_addr[4:0])^(ghist[4:0])^(ghist[9:5])^(ghist[14:10])^(ghist[19:15])^(ghist[24:20])^ 58 | (ghist[29:25])^(ghist[34:30])^(ghist[39:35])^(ghist[44:40]) 59 | ^({ghist[3:0],1'b0})^({ghist[7:4],1'b0})^({ghist[11:8],1'b0})^({ghist[15:12],1'b0})^({ghist[19:16],1'b0}) 60 | ^({ghist[23:20],1'b0})^({ghist[27:24],1'b0})^({ghist[31:28],1'b0})^({ghist[35:32],1'b0}) 61 | ^({ghist[39:36],1'b0})^({ghist[43:40],1'b0}); 62 | Comp_tag_bank4<=(pc_addr[4:0])^(ghist[4:0])^(ghist[9:5])^(ghist[14:10])^(ghist[19:15])^(ghist[24:20])^ 63 | (ghist[29:25])^(ghist[34:30])^(ghist[39:35])^(ghist[44:40]) 64 | ^(ghist[49:45])^(ghist[54:50])^(ghist[59:55])^(ghist[64:60])^(ghist[69:65]) 65 | ^(ghist[74:70])^(ghist[79:75])^(ghist[84:80])^(ghist[89:85])^(ghist[94:90]) 66 | ^(ghist[99:95])^(ghist[104:100])^(ghist[109:105])^(ghist[114:110])^(ghist[119:115]) 67 | ^(ghist[124:120])^(ghist[129:125])^({ghist[3:0],1'b0})^({ghist[7:4],1'b0})^({ghist[11:8],1'b0})^({ghist[15:12],1'b0})^({ghist[19:16],1'b0}) 68 | ^({ghist[23:20],1'b0})^({ghist[27:24],1'b0})^({ghist[31:28],1'b0})^({ghist[35:32],1'b0}) 69 | ^({ghist[39:36],1'b0})^({ghist[43:40],1'b0})^({ghist[47:44],1'b0})^({ghist[51:48],1'b0})^ 70 | ({ghist[55:52],1'b0})^({ghist[59:56],1'b0})^({ghist[63:60],1'b0})^({ghist[67:64],1'b0})^ 71 | ({ghist[71:68],1'b0})^({ghist[75:72],1'b0})^({ghist[79:76],1'b0})^({ghist[83:80],1'b0})^({ghist[87:84],1'b0})^ 72 | ({ghist[91:88],1'b0})^({ghist[95:92],1'b0})^({ghist[99:96],1'b0})^({ghist[103:100],1'b0})^ 73 | ({ghist[107:104],1'b0})^({ghist[111:108],1'b0})^({ghist[115:112],1'b0})^({ghist[119:116],1'b0}) 74 | ^({ghist[123:120],1'b0})^({ghist[127:124],1'b0})^({2'b00,ghist[129:128],1'b0}) ; 75 | 76 | end 77 | else begin 78 | Index_bank2<=Index_bank1; 79 | Index_bank2<=Index_bank2; 80 | Index_bank3<=Index_bank3; 81 | Index_bank4<=Index_bank4; 82 | Comp_tag_bank1<=Comp_tag_bank1; 83 | Comp_tag_bank2<=Comp_tag_bank2; 84 | Comp_tag_bank3<=Comp_tag_bank3; 85 | Comp_tag_bank4<=Comp_tag_bank4; 86 | end 87 | 88 | 89 | end 90 | 91 | endmodule 92 | -------------------------------------------------------------------------------- /TAGE/Source/Bimodal_Table.v: -------------------------------------------------------------------------------- 1 | `timescale 1ns / 1ps 2 | 3 | module Bimodal_Table(Clk, wr, rd, index/*pc*/, rdata_c_bits, correct_prediction, inc_counter, dec_counter,update_enable); 4 | 5 | parameter IL=13; //Index size ie number of addresses 6 | parameter CL=3; //Counter length 7 | 8 | reg [ CL-1 : 0 ] c_bits[(1 << IL) - 1 : 0]; //Counter table 9 | 10 | output [ CL-1 : 0 ] rdata_c_bits; 11 | reg [ CL-1 : 0 ] rdata_c_bits_reg; 12 | input [IL - 1 : 0]index; 13 | input Clk,rd,wr; 14 | input correct_prediction; 15 | input inc_counter; 16 | input dec_counter; 17 | input update_enable; 18 | 19 | integer i, j; 20 | 21 | initial 22 | begin 23 | for (i = 0; i < (1<