Ignore:
Timestamp:
Jul 12, 2013, 12:16:30 PM (11 years ago)
Author:
alain
Message:

Introducing a preliminary configuration interface in vci_mem_cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/vci_mem_cache/caba/source/include/update_tab.h

    r385 r434  
    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 sc_dt::sc_uint<40> addr_t;
     140  typedef uint64_t addr_t;
    129141
    130142  private:
    131   size_t size_tab;
     143  size_t                      size_tab;
    132144  std::vector<UpdateTabEntry> tab;
    133145
     
    149161  // The size() function returns the size of the tab 
    150162  ////////////////////////////////////////////////////////////////////
    151   const size_t size(){
     163  const size_t size()
     164  {
    152165    return size_tab;
    153166  }
    154167
    155 
    156168  ////////////////////////////////////////////////////////////////////
    157169  // The print() function diplays the tab content
    158170  ////////////////////////////////////////////////////////////////////
    159   void print(){
    160     for(size_t i=0; i<size_tab; i++) {
    161       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 << "] ";
    162177      tab[i].print();
    163178    }
     
    165180  }
    166181
    167 
    168182  /////////////////////////////////////////////////////////////////////
    169183  // The init() function initializes the tab
    170184  /////////////////////////////////////////////////////////////////////
    171   void init(){
    172     for ( size_t i=0; i<size_tab; i++) {
    173       tab[i].init();
    174     }
    175   }
    176 
     185  void init()
     186  {
     187    for ( size_t i=0; i<size_tab; i++) tab[i].init();
     188  }
    177189
    178190  /////////////////////////////////////////////////////////////////////
     
    200212  ///////////////////////////////////////////////////////////////////////////
    201213  bool set(const bool   update,
    202       const bool   brdcast,
    203       const bool   rsp,
    204       const size_t srcid,
    205       const size_t trdid,
    206       const size_t pktid,
    207       const addr_t nline,
    208       const size_t count,
    209       size_t &index)
    210   {
    211     for ( size_t i=0 ; i<size_tab ; i++ ) {
    212       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      {
    213228        tab[i].valid            = true;
    214229        tab[i].update           = update;
    215230        tab[i].brdcast      = brdcast;
    216231        tab[i].rsp          = rsp;
     232        tab[i].ack          = ack;
    217233        tab[i].srcid            = (size_t) srcid;
    218234        tab[i].trdid            = (size_t) trdid;
     
    235251  /////////////////////////////////////////////////////////////////////
    236252  bool decrement( const size_t index,
    237       size_t &counter )
     253                  size_t &counter )
    238254  {
    239255    assert((index<size_tab) && "Bad Update Tab Entry");
    240     if ( tab[index].valid ) {
     256    if ( tab[index].valid )
     257    {
    241258      tab[index].count--;
    242259      counter = tab[index].count;
    243260      return true;
    244     } else {
     261    }
     262    else
     263    {
    245264      return false;
    246265    }
     
    252271  bool is_full()
    253272  {
    254     for(size_t i = 0 ; i < size_tab ; i++){
    255       if(!tab[i].valid){
    256         return false;
    257       }
     273    for(size_t i = 0 ; i < size_tab ; i++)
     274    {
     275      if(!tab[i].valid) return false;
    258276    }
    259277    return true;
     
    265283  bool is_not_empty()
    266284  {
    267     for(size_t i = 0 ; i < size_tab ; i++){
    268       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 ;
    269394        return true;
    270395      }
     
    274399
    275400  /////////////////////////////////////////////////////////////////////
    276   // The need_rsp() function returns the need of a response
    277   // Arguments :
    278   // - index : the index of the entry
    279   /////////////////////////////////////////////////////////////////////
    280   bool need_rsp(const size_t index)
    281   {
    282     assert(index<size_tab && "Bad Update Tab Entry");
    283     return tab[index].rsp;     
    284   }
    285 
    286   /////////////////////////////////////////////////////////////////////
    287   // The is_update() function returns the transaction type
    288   // Arguments :
    289   // - index : the index of the entry
    290   /////////////////////////////////////////////////////////////////////
    291   bool is_brdcast(const size_t index)
    292   {
    293     assert(index<size_tab && "Bad Update Tab Entry");
    294     return tab[index].brdcast; 
    295   }
    296 
    297   /////////////////////////////////////////////////////////////////////
    298   // The is_update() function returns the transaction type
    299   // Arguments :
    300   // - index : the index of the entry
    301   /////////////////////////////////////////////////////////////////////
    302   bool is_update(const size_t index)
    303   {
    304     assert(index<size_tab && "Bad Update Tab Entry");
    305     return tab[index].update;   
    306   }
    307 
    308   /////////////////////////////////////////////////////////////////////
    309   // The srcid() function returns the srcid value
    310   // Arguments :
    311   // - index : the index of the entry
    312   /////////////////////////////////////////////////////////////////////
    313   size_t srcid(const size_t index)
    314   {
    315     assert(index<size_tab && "Bad Update Tab Entry");
    316     return tab[index].srcid;   
    317   }
    318 
    319   /////////////////////////////////////////////////////////////////////
    320   // The trdid() function returns the trdid value
    321   // Arguments :
    322   // - index : the index of the entry
    323   /////////////////////////////////////////////////////////////////////
    324   size_t trdid(const size_t index)
    325   {
    326     assert(index<size_tab && "Bad Update Tab Entry");
    327     return tab[index].trdid;   
    328   }
    329 
    330   /////////////////////////////////////////////////////////////////////
    331   // The pktid() function returns the pktid value
    332   // Arguments :
    333   // - index : the index of the entry
    334   /////////////////////////////////////////////////////////////////////
    335   size_t pktid(const size_t index)
    336   {
    337     assert(index<size_tab && "Bad Update Tab Entry");
    338     return tab[index].pktid;   
    339   }
    340 
    341   /////////////////////////////////////////////////////////////////////
    342   // The nline() function returns the nline value
    343   // Arguments :
    344   // - index : the index of the entry
    345   /////////////////////////////////////////////////////////////////////
    346   addr_t nline(const size_t index)
    347   {
    348     assert(index<size_tab && "Bad Update Tab Entry");
    349     return tab[index].nline;
    350   }
    351 
    352   /////////////////////////////////////////////////////////////////////
    353   // 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
    354402  // Arguments :
    355403  // - nline : the line number of the entry in the directory
    356404  /////////////////////////////////////////////////////////////////////
    357   bool search_inval(const addr_t nline,size_t &index)
     405  bool read_nline(const addr_t nline,size_t &index)
    358406  {
    359407    size_t i ;
    360408
    361     for (i = 0 ; i < size_tab ; i++){
    362       if((tab[i].nline == nline) && tab[i].valid){
    363         if(!tab[i].update){
    364           index = i ;
    365           return true;
    366         }
    367       }
    368     }
    369     return false;
    370   }
    371 
    372   /////////////////////////////////////////////////////////////////////
    373   // The read_nline() function returns the index of the entry in UPT
    374   // Arguments :
    375   // - nline : the line number of the entry in the directory
    376   /////////////////////////////////////////////////////////////////////
    377   bool read_nline(const addr_t nline,size_t &index)
    378   {
    379     size_t i ;
    380 
    381     for (i = 0 ; i < size_tab ; i++){
    382       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      {
    383413        index = i ;
    384414        return true;
Note: See TracChangeset for help on using the changeset viewer.