Ignore:
Timestamp:
Jul 17, 2013, 9:24:48 AM (11 years ago)
Author:
cfuguet
Message:

Merging branch/v5/vci_mem_cache with trunk modifications to
start the development of new coherence protocol modifications
in this component

Location:
branches/v5/modules/vci_mem_cache
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/v5/modules/vci_mem_cache

  • branches/v5/modules/vci_mem_cache/caba/source/include/update_tab.h

    r307 r440  
    1111////////////////////////////////////////////////////////////////////////
    1212class UpdateTabEntry {
     13
    1314  typedef uint32_t size_t;
    1415  typedef sc_dt::sc_uint<40> addr_t;
    1516
    1617  public:
     18
    1719  bool      valid;      // It is a valid pending transaction
    1820  bool      update;     // It is an update transaction
    1921  bool      brdcast;    // It is a broadcast invalidate
    20   bool      rsp;        // It needs a response to the initiator
     22  bool      rsp;        // Response to the initiator required
     23  bool      ack;        // Acknowledge to the CONFIG FSM required
    2124  size_t        srcid;      // The srcid of the initiator which wrote the data
    2225  size_t        trdid;      // The trdid of the initiator which wrote the data
     
    2528  size_t        count;      // The number of acknowledge responses to receive
    2629
    27   UpdateTabEntry(){
     30  UpdateTabEntry()
     31  {
    2832    valid       = false;
    2933    update  = false;
    3034    brdcast = false;
    3135    rsp     = false;
     36    ack     = false;
    3237    srcid       = 0;
    3338    trdid       = 0;
     
    3843
    3944  UpdateTabEntry(bool   i_valid,
    40       bool   i_update,
    41       bool   i_brdcast,
    42       bool   i_rsp,
    43       size_t i_srcid,
    44       size_t i_trdid,
    45       size_t i_pktid,
    46       addr_t i_nline,
    47       size_t i_count)
     45                 bool   i_update,
     46                 bool   i_brdcast,
     47                 bool   i_rsp,
     48                 bool   i_ack,
     49                 size_t i_srcid,
     50                 size_t i_trdid,
     51                 size_t i_pktid,
     52                 addr_t i_nline,
     53                 size_t i_count)
    4854  {
    4955    valid       = i_valid;
     
    5157    brdcast = i_brdcast;
    5258    rsp     = i_rsp;
     59    ack     = i_ack;
    5360    srcid       = i_srcid;
    5461    trdid       = i_trdid;
     
    6471    brdcast = source.brdcast;
    6572    rsp     = source.rsp;
     73    ack     = source.ack;
    6674    srcid   = source.srcid;
    6775    trdid   = source.trdid;
     
    8088    brdcast= false;
    8189    rsp    = false;
     90    ack    = false;
    8291    srcid  = 0;
    8392    trdid  = 0;
     
    98107    brdcast= source.brdcast;
    99108    rsp    = source.rsp;
     109    ack    = source.ack  ;
    100110    srcid  = source.srcid;
    101111    trdid  = source.trdid;
     
    108118  // The print() function prints the entry 
    109119  ////////////////////////////////////////////////////////////////////
    110   void print(){
    111     std::cout << std::dec << "valid  = " << valid  << std::endl;
    112     std::cout << "update = " << update << std::endl;
    113     std::cout << "brdcast= " << brdcast<< std::endl;
    114     std::cout << "rsp    = " << rsp    << std::endl;
    115     std::cout << "srcid  = " << srcid  << std::endl;
    116     std::cout << "trdid  = " << trdid  << std::endl;
    117     std::cout << "pktid  = " << pktid  << std::endl;
    118     std::cout << std::hex << "nline  = " << nline  << std::endl;
    119     std::cout << std::dec << "count  = " << count  << std::endl;
     120  void print()
     121  {
     122    std::cout << " val = " << std::dec << valid
     123              << " / updt = " << update
     124              << " / bc = " << brdcast
     125              << " / rsp = " << rsp
     126              << " / ack = " << ack   
     127              << " / count = " << count
     128              << " / srcid = " << std::hex << srcid
     129              << " / trdid = " << trdid   
     130              << " / pktid = " << pktid
     131              << " / nline = " << nline  << std::endl;
    120132  }
    121133};
     
    126138class UpdateTab{
    127139
    128   typedef uint32_t size_t;
    129   typedef sc_dt::sc_uint<40> addr_t;
     140  typedef uint64_t addr_t;
    130141
    131142  private:
    132   size_t size_tab;
     143  size_t                      size_tab;
    133144  std::vector<UpdateTabEntry> tab;
    134145
     
    150161  // The size() function returns the size of the tab 
    151162  ////////////////////////////////////////////////////////////////////
    152   const size_t size(){
     163  const size_t size()
     164  {
    153165    return size_tab;
    154166  }
    155167
    156 
    157168  ////////////////////////////////////////////////////////////////////
    158169  // The print() function diplays the tab content
    159170  ////////////////////////////////////////////////////////////////////
    160   void print(){
    161     for(size_t i=0; i<size_tab; i++) {
    162       std::cout << "UPDATE TAB ENTRY " << std::dec << i << "--------" << std::endl;
     171  void print()
     172  {
     173    std::cout << "UPDATE TABLE Content" << std::endl;
     174    for(size_t i=0; i<size_tab; i++)
     175    {
     176      std::cout << "[" << std::dec << i << "] ";
    163177      tab[i].print();
    164178    }
     
    166180  }
    167181
    168 
    169182  /////////////////////////////////////////////////////////////////////
    170183  // The init() function initializes the tab
    171184  /////////////////////////////////////////////////////////////////////
    172   void init(){
    173     for ( size_t i=0; i<size_tab; i++) {
    174       tab[i].init();
    175     }
    176   }
    177 
     185  void init()
     186  {
     187    for ( size_t i=0; i<size_tab; i++) tab[i].init();
     188  }
    178189
    179190  /////////////////////////////////////////////////////////////////////
     
    201212  ///////////////////////////////////////////////////////////////////////////
    202213  bool set(const bool   update,
    203       const bool   brdcast,
    204       const bool   rsp,
    205       const size_t srcid,
    206       const size_t trdid,
    207       const size_t pktid,
    208       const addr_t nline,
    209       const size_t count,
    210       size_t &index)
    211   {
    212     for ( size_t i=0 ; i<size_tab ; i++ ) {
    213       if( !tab[i].valid ) {
     214           const bool   brdcast,
     215           const bool   rsp,
     216           const bool   ack,
     217           const size_t srcid,
     218           const size_t trdid,
     219           const size_t pktid,
     220           const addr_t nline,
     221           const size_t count,
     222           size_t       &index)
     223  {
     224    for ( size_t i=0 ; i<size_tab ; i++ )
     225    {
     226      if( !tab[i].valid )
     227      {
    214228        tab[i].valid            = true;
    215229        tab[i].update           = update;
    216230        tab[i].brdcast      = brdcast;
    217231        tab[i].rsp          = rsp;
     232        tab[i].ack          = ack;
    218233        tab[i].srcid            = (size_t) srcid;
    219234        tab[i].trdid            = (size_t) trdid;
     
    236251  /////////////////////////////////////////////////////////////////////
    237252  bool decrement( const size_t index,
    238       size_t &counter )
     253                  size_t &counter )
    239254  {
    240255    assert((index<size_tab) && "Bad Update Tab Entry");
    241     if ( tab[index].valid ) {
     256    if ( tab[index].valid )
     257    {
    242258      tab[index].count--;
    243259      counter = tab[index].count;
    244260      return true;
    245     } else {
     261    }
     262    else
     263    {
    246264      return false;
    247265    }
     
    253271  bool is_full()
    254272  {
    255     for(size_t i = 0 ; i < size_tab ; i++){
    256       if(!tab[i].valid){
    257         return false;
    258       }
     273    for(size_t i = 0 ; i < size_tab ; i++)
     274    {
     275      if(!tab[i].valid) return false;
    259276    }
    260277    return true;
     
    266283  bool is_not_empty()
    267284  {
    268     for(size_t i = 0 ; i < size_tab ; i++){
    269       if(tab[i].valid){
     285    for(size_t i = 0 ; i < size_tab ; i++)
     286    {
     287      if(tab[i].valid) return true;
     288    }
     289    return false;
     290  }
     291
     292  /////////////////////////////////////////////////////////////////////
     293  // The need_rsp() function returns the need of a response
     294  // Arguments :
     295  // - index : the index of the entry
     296  /////////////////////////////////////////////////////////////////////
     297  bool need_rsp(const size_t index)
     298  {
     299    assert(index<size_tab && "Bad Update Tab Entry");
     300    return tab[index].rsp;     
     301  }
     302
     303  /////////////////////////////////////////////////////////////////////
     304  // The need_ack() function returns the need of an acknowledge
     305  // Arguments :
     306  // - index : the index of the entry
     307  /////////////////////////////////////////////////////////////////////
     308  bool need_ack(const size_t index)
     309  {
     310    assert(index<size_tab && "Bad Update Tab Entry");
     311    return tab[index].ack;     
     312  }
     313
     314  /////////////////////////////////////////////////////////////////////
     315  // The is_brdcast() function returns the transaction type
     316  // Arguments :
     317  // - index : the index of the entry
     318  /////////////////////////////////////////////////////////////////////
     319  bool is_brdcast(const size_t index)
     320  {
     321    assert(index<size_tab && "Bad Update Tab Entry");
     322    return tab[index].brdcast; 
     323  }
     324
     325  /////////////////////////////////////////////////////////////////////
     326  // The is_update() function returns the transaction type
     327  // Arguments :
     328  // - index : the index of the entry
     329  /////////////////////////////////////////////////////////////////////
     330  bool is_update(const size_t index)
     331  {
     332    assert(index<size_tab && "Bad Update Tab Entry");
     333    return tab[index].update;   
     334  }
     335
     336  /////////////////////////////////////////////////////////////////////
     337  // The srcid() function returns the srcid value
     338  // Arguments :
     339  // - index : the index of the entry
     340  /////////////////////////////////////////////////////////////////////
     341  size_t srcid(const size_t index)
     342  {
     343    assert(index<size_tab && "Bad Update Tab Entry");
     344    return tab[index].srcid;   
     345  }
     346
     347  /////////////////////////////////////////////////////////////////////
     348  // The trdid() function returns the trdid value
     349  // Arguments :
     350  // - index : the index of the entry
     351  /////////////////////////////////////////////////////////////////////
     352  size_t trdid(const size_t index)
     353  {
     354    assert(index<size_tab && "Bad Update Tab Entry");
     355    return tab[index].trdid;   
     356  }
     357
     358  /////////////////////////////////////////////////////////////////////
     359  // The pktid() function returns the pktid value
     360  // Arguments :
     361  // - index : the index of the entry
     362  /////////////////////////////////////////////////////////////////////
     363  size_t pktid(const size_t index)
     364  {
     365    assert(index<size_tab && "Bad Update Tab Entry");
     366    return tab[index].pktid;   
     367  }
     368
     369  /////////////////////////////////////////////////////////////////////
     370  // The nline() function returns the nline value
     371  // Arguments :
     372  // - index : the index of the entry
     373  /////////////////////////////////////////////////////////////////////
     374  addr_t nline(const size_t index)
     375  {
     376    assert(index<size_tab && "Bad Update Tab Entry");
     377    return tab[index].nline;
     378  }
     379
     380  /////////////////////////////////////////////////////////////////////
     381  // The search_inval() function returns the index of the entry in UPT
     382  // Arguments :
     383  // - nline : the line number of the entry in the directory
     384  /////////////////////////////////////////////////////////////////////
     385  bool search_inval(const addr_t nline,size_t &index)
     386  {
     387    size_t i ;
     388
     389    for (i = 0 ; i < size_tab ; i++)
     390    {
     391      if ( (tab[i].nline == nline) and tab[i].valid and not tab[i].update )
     392      {
     393        index = i ;
    270394        return true;
    271395      }
     
    275399
    276400  /////////////////////////////////////////////////////////////////////
    277   // The need_rsp() function returns the need of a response
    278   // Arguments :
    279   // - index : the index of the entry
    280   /////////////////////////////////////////////////////////////////////
    281   bool need_rsp(const size_t index)
    282   {
    283     assert(index<size_tab && "Bad Update Tab Entry");
    284     return tab[index].rsp;     
    285   }
    286 
    287   /////////////////////////////////////////////////////////////////////
    288   // The is_update() function returns the transaction type
    289   // Arguments :
    290   // - index : the index of the entry
    291   /////////////////////////////////////////////////////////////////////
    292   bool is_brdcast(const size_t index)
    293   {
    294     assert(index<size_tab && "Bad Update Tab Entry");
    295     return tab[index].brdcast; 
    296   }
    297 
    298   /////////////////////////////////////////////////////////////////////
    299   // The is_update() function returns the transaction type
    300   // Arguments :
    301   // - index : the index of the entry
    302   /////////////////////////////////////////////////////////////////////
    303   bool is_update(const size_t index)
    304   {
    305     assert(index<size_tab && "Bad Update Tab Entry");
    306     return tab[index].update;   
    307   }
    308 
    309   /////////////////////////////////////////////////////////////////////
    310   // The srcid() function returns the srcid value
    311   // Arguments :
    312   // - index : the index of the entry
    313   /////////////////////////////////////////////////////////////////////
    314   size_t srcid(const size_t index)
    315   {
    316     assert(index<size_tab && "Bad Update Tab Entry");
    317     return tab[index].srcid;   
    318   }
    319 
    320   /////////////////////////////////////////////////////////////////////
    321   // The trdid() function returns the trdid value
    322   // Arguments :
    323   // - index : the index of the entry
    324   /////////////////////////////////////////////////////////////////////
    325   size_t trdid(const size_t index)
    326   {
    327     assert(index<size_tab && "Bad Update Tab Entry");
    328     return tab[index].trdid;   
    329   }
    330 
    331   /////////////////////////////////////////////////////////////////////
    332   // The pktid() function returns the pktid value
    333   // Arguments :
    334   // - index : the index of the entry
    335   /////////////////////////////////////////////////////////////////////
    336   size_t pktid(const size_t index)
    337   {
    338     assert(index<size_tab && "Bad Update Tab Entry");
    339     return tab[index].pktid;   
    340   }
    341 
    342   /////////////////////////////////////////////////////////////////////
    343   // The nline() function returns the nline value
    344   // Arguments :
    345   // - index : the index of the entry
    346   /////////////////////////////////////////////////////////////////////
    347   addr_t nline(const size_t index)
    348   {
    349     assert(index<size_tab && "Bad Update Tab Entry");
    350     return tab[index].nline;
    351   }
    352 
    353   /////////////////////////////////////////////////////////////////////
    354   // The search_inval() function returns the index of the entry in UPT
     401  // The read_nline() function returns the index of the entry in UPT
    355402  // Arguments :
    356403  // - nline : the line number of the entry in the directory
    357404  /////////////////////////////////////////////////////////////////////
    358   bool search_inval(const addr_t nline,size_t &index)
     405  bool read_nline(const addr_t nline,size_t &index)
    359406  {
    360407    size_t i ;
    361408
    362     for (i = 0 ; i < size_tab ; i++){
    363       if((tab[i].nline == nline) && tab[i].valid){
    364         if(!tab[i].update){
    365           index = i ;
    366           return true;
    367         }
    368       }
    369     }
    370     return false;
    371   }
    372 
    373   /////////////////////////////////////////////////////////////////////
    374   // The read_nline() function returns the index of the entry in UPT
    375   // Arguments :
    376   // - nline : the line number of the entry in the directory
    377   /////////////////////////////////////////////////////////////////////
    378   bool read_nline(const addr_t nline,size_t &index)
    379   {
    380     size_t i ;
    381 
    382     for (i = 0 ; i < size_tab ; i++){
    383       if((tab[i].nline == nline) && tab[i].valid){
     409    for (i = 0 ; i < size_tab ; i++)
     410    {
     411      if ( (tab[i].nline == nline) and tab[i].valid )
     412      {
    384413        index = i ;
    385414        return true;
Note: See TracChangeset for help on using the changeset viewer.