Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

btb.h

Go to the documentation of this file.
00001 /*
00002         Copyright (C) 1997 CFU Corporation
00003 
00004         File: btb.h
00005         Description: branch target buffer
00006         Author: Chao-yinig Fu
00007         Date: Oct. 27, 2000
00008 
00009         ^..^
00010         (00)
00011 
00012          $__$
00013         <~00~>
00014          (oo)
00015           ||
00016 
00017         ```````
00018         C ^|^ D
00019          \ O /
00020 */
00021 
00022 #ifndef INCLUDED_BTB_H
00023 #define INCLUDED_BTB_H
00024 
00025 #include <stdio.h>
00026 #include <assert.h>
00027 
00028 class BTB
00029 {
00030 public:
00031         BTB():_tag(NULL) {}
00032 
00033         // b => block size
00034         // e => number of entry
00035         // s => set associtivity
00036         BTB(int b, int e,int s):_b(b),_e(e),_s(s)
00037         {
00038                 _num_of_entry=1<<_e;
00039                 _num_of_entry_per_set=1<<_s;
00040                 _index_mask=(1<<(_e-_s))-1;
00041 
00042                 _tag=new int[_num_of_entry];
00043                 _time=new int[_num_of_entry];
00044                 _slot=new int[_num_of_entry];
00045                 _target=new int[_num_of_entry];
00046 
00047                 for(int i=0;i<_num_of_entry;i++)
00048                 {
00049                         _tag[i]=-1;
00050                         _slot[i]=0;
00051                         _target[i]=0;
00052                         _time[i]=0;
00053                 }
00054 
00055                 //show(stderr);
00056                 //exit(0);
00057         }
00058 
00059         void show(FILE *f)
00060         {
00061                 fprintf(f,"=== BTB ===");
00062                 fprintf(f,"_b=%d\n",_b);
00063                 fprintf(f,"_e=%d\n",_e);
00064                 fprintf(f,"_s=%d\n",_s);
00065                 fprintf(f,"_num_of_entry=%d\n",_num_of_entry);
00066                 fprintf(f,"_num_of_entry_per_set=%d\n",_num_of_entry_per_set);
00067                 fprintf(f,"_index_mask=%d\n",_index_mask);
00068         }
00069 
00070         ~BTB() 
00071         {
00072                 delete []_tag;
00073                 delete []_slot;
00074                 delete []_target;
00075                 delete []_time;
00076         }
00077 
00078         void predict(int ip,int slot,bool &find_btb,int &target);
00079         void update(int ip,int slot,int target,int global_cycle);
00080         
00081 
00082 private:
00083         int _b;         // operation size are the 2^_b bytes
00084         int _e;         // 2^_c => number of entry
00085         int _s;         // 2^_s => set associativity
00086         int _num_of_entry;      // number of entry
00087         int _num_of_entry_per_set;      // number of entry per set
00088         int _index_mask;        // mask for finding index
00089 
00090         int *_tag;      // store the tag of this op
00091         int *_slot;     // store the slot information of this op
00092         int *_target;   // store the value for prediction
00093         int *_time;     // store the time array
00094 };
00095 
00096 #endif // INCLUDED_BRANCH_H

Generated on Mon Jul 21 20:24:03 2003 for TINKER LEGO DOC by doxygen 1.3.2