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:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/v5/modules/vci_mem_cache

  • branches/v5/modules/vci_mem_cache/caba/metadata/vci_mem_cache.sd

    r351 r440  
    99
    1010        tmpl_parameters = [
    11                         parameter.Module('vci_param'  , default = 'caba:vci_param')
    12                 ],
     11            parameter.Module('vci_param_int', default = 'caba:vci_param',
     12                cell_size = parameter.Reference('memc_cell_size_int')
     13            ),
     14            parameter.Module('vci_param_ext', default = 'caba:vci_param',
     15                cell_size = parameter.Reference('memc_cell_size_ext')
     16            ),
     17            parameter.Int('dspin_in_width'),
     18            parameter.Int('dspin_out_width'),
     19        ],
    1320
    1421        header_files = [
     
    1926        ],
    2027
    21         implementation_files = [ '../source/src/vci_mem_cache.cpp' ],
     28        interface_files = [
     29            '../../include/soclib/mem_cache.h',
     30        ],
     31
     32        implementation_files = [
     33            '../source/src/vci_mem_cache.cpp'
     34        ],
    2235
    2336        uses = [
     
    2740            Uses('caba:generic_fifo'),
    2841            Uses('caba:generic_llsc_global_table'),
    29                         Uses('caba:dspin_dhccp_param')
     42            Uses('caba:dspin_dhccp_param')
    3043        ],
    3144
    3245        ports = [
    33             Port( 'caba:vci_target'   , 'p_vci_tgt' ),
    34             Port(
    35                                 'caba:dspin_input',
    36                                 'p_dspin_in',
    37                                 dspin_data_size = 33,
    38                         ),
    39                         Port(
    40                                 'caba:dspin_output',
    41                                 'p_dspin_out',
    42                                 dspin_data_size = 40,
    43                         ),
    44             Port( 'caba:vci_initiator', 'p_vci_ixr' ),
    45             Port( 'caba:bit_in'       , 'p_resetn'  , auto = 'resetn' ),
    46             Port( 'caba:clock_in'     , 'p_clk'     , auto = 'clock'  ),
     46            Port('caba:clock_in'     , 'p_clk'      , auto = 'clock' ),
     47            Port('caba:bit_in'       , 'p_resetn'   , auto = 'resetn'),
     48            Port('caba:vci_target'   , 'p_vci_tgt'),
     49            Port('caba:vci_initiator', 'p_vci_ixr'),
     50            Port('caba:dspin_input',
     51                'p_dspin_in',
     52                dspin_data_size = parameter.Reference('dspin_in_width')
     53            ),
     54            Port('caba:dspin_output',
     55                'p_dspin_out',
     56                dspin_data_size = parameter.Reference('dspin_out_width')
     57            ),
    4758        ],
    4859
    4960        instance_parameters = [
    50             parameter.Module( 'mtp', 'common:mapping_table' ),
    51             parameter.Module( 'mtc', 'common:mapping_table' ),
    52             parameter.Module( 'mtx', 'common:mapping_table' ),
    53             parameter.IntTab( 'vci_ixr_index' ),
    54             parameter.IntTab( 'vci_ini_index' ),
    55             parameter.IntTab( 'vci_tgt_index' ),
    56             parameter.IntTab( 'vci_tgt_index_cleanup '),
    57             parameter.Int   ( 'nways' ),
    58             parameter.Int   ( 'nsets' ),
    59             parameter.Int   ( 'nwords' ),
    60             parameter.Int   ( 'heap_size' ),
    61         ],
    62 
    63         extensions = [
    64             'dsx:get_ident='
    65             'vci_ini_index:p_vci_ini:mtc,'
    66             'vci_tgt_index_cleanup:p_vci_tgt_cleanup:mtc,'
    67             'vci_tgt_index:p_vci_tgt:mtp,'
    68             'vci_ixr_index:p_vci_ixr:mtx',
    69             'dsx:addressable=vci_tgt_index,vci_tgt_index_cleanup',
     61            parameter.Module('mtp', 'common:mapping_table'),
     62            parameter.Module('mtc', 'common:mapping_table'),
     63            parameter.Module('mtx', 'common:mapping_table'),
     64            parameter.IntTab('vci_ixr_index'),
     65            parameter.IntTab('vci_ini_index'),
     66            parameter.IntTab('vci_tgt_index'),
     67            parameter.IntTab('vci_tgt_index_cleanup'),
     68            parameter.Int   ('nways'),
     69            parameter.Int   ('nsets'),
     70            parameter.Int   ('nwords'),
     71            parameter.Int   ('heap_size'),
    7072        ],
    7173)
  • branches/v5/modules/vci_mem_cache/caba/source/include/mem_cache_directory.h

    r307 r440  
    4040  ////////////////////////////////////////////////////////////////////////
    4141  class Owner{
    42     typedef uint32_t size_t;
    4342   
    4443    public:
     
    9291
    9392    typedef uint32_t tag_t;
    94     typedef uint32_t size_t;
    9593
    9694    public:
     
    165163    void print()
    166164    {
    167       std::cout << "Valid = " << valid << " ; IS COUNT = " << is_cnt << " ; Dirty = " << dirty << " ; Lock = "
    168                 << lock
     165      std::cout << "Valid = " << valid
     166                << " ; IS COUNT = " << is_cnt
     167                << " ; Dirty = " << dirty
     168                << " ; Lock = " << lock
    169169                << " ; Tag = " << std::hex << tag << std::dec
    170170                << " ; Count = " << count
     
    187187    typedef uint32_t data_t;
    188188    typedef uint32_t tag_t;
    189     typedef uint32_t size_t;
    190189
    191190    private:
     
    275274
    276275    /////////////////////////////////////////////////////////////////////
     276    // The inval function invalidate an entry defined by the set and
     277    // way arguments.
     278    /////////////////////////////////////////////////////////////////////
     279    void inval( const size_t &set, const size_t &way )
     280    {
     281        m_dir_tab[set][way].init();
     282    }
     283
     284    /////////////////////////////////////////////////////////////////////
    277285    // The read_neutral() function reads a directory entry, without
    278286    // changing the LRU
     
    321329      // update LRU bits
    322330      bool all_recent = true;
    323       for ( size_t i=0 ; i<m_ways ; i++ ) {
    324         if ( i != way ) all_recent = m_lru_tab[set][i].recent && all_recent;
    325       }
    326       if ( all_recent ) {
    327         for( size_t i=0 ; i<m_ways ; i++ ) m_lru_tab[set][i].recent = false;
    328       } else {
    329         m_lru_tab[set][way].recent = true;
     331      for ( size_t i=0 ; i<m_ways ; i++ )
     332      {
     333          if ( i != way ) all_recent = m_lru_tab[set][i].recent && all_recent;
     334      }
     335      if ( all_recent )
     336      {
     337          for( size_t i=0 ; i<m_ways ; i++ ) m_lru_tab[set][i].recent = false;
     338      }
     339      else
     340      {
     341          m_lru_tab[set][way].recent = true;
    330342      }
    331343    } // end write()
     
    408420  ///////////////////////////////////////////////////////////////////////
    409421  class HeapEntry{
    410     typedef uint32_t size_t;
    411422
    412423    public:
     
    472483  ////////////////////////////////////////////////////////////////////////
    473484  class HeapDirectory{
    474     typedef uint32_t size_t;
    475485   
    476486    private:
  • 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;
  • branches/v5/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h

    r362 r440  
    5252#include "dspin_dhccp_param.h"
    5353
    54 #define TRANSACTION_TAB_LINES 4 // Number of lines in the transaction tab
    55 #define UPDATE_TAB_LINES      4 // Number of lines in the update tab
     54#define TRT_ENTRIES      4      // Number of entries in TRT
     55#define UPT_ENTRIES      4      // Number of entries in UPT
     56#define HEAP_ENTRIES     1024   // Number of entries in HEAP
    5657
    5758namespace soclib {  namespace caba {
     59
    5860  using namespace sc_core;
    5961
    60   template<typename vci_param>
     62  template<typename vci_param_int,
     63           typename vci_param_ext,
     64           size_t   dspin_in_width,
     65           size_t   dspin_out_width>
    6166    class VciMemCache
    6267    : public soclib::caba::BaseModule
    6368    {
    64       typedef sc_dt::sc_uint<40> addr_t;
    65       typedef typename vci_param::fast_addr_t vci_addr_t;
     69      typedef typename vci_param_int::fast_addr_t  addr_t;
     70
     71      typedef typename sc_dt::sc_uint<64>          wide_data_t;
     72
    6673      typedef uint32_t data_t;
    6774      typedef uint32_t tag_t;
    68       typedef uint32_t size_t;
    6975      typedef uint32_t be_t;
    7076      typedef uint32_t copy_t;
    7177
    7278      /* States of the TGT_CMD fsm */
    73       enum tgt_cmd_fsm_state_e{
     79      enum tgt_cmd_fsm_state_e
     80      {
    7481        TGT_CMD_IDLE,
     82        TGT_CMD_ERROR,
    7583        TGT_CMD_READ,
    7684        TGT_CMD_WRITE,
    77         TGT_CMD_CAS
     85        TGT_CMD_CAS,
     86        TGT_CMD_CONFIG
    7887      };
    7988
    8089      /* States of the TGT_RSP fsm */
    81       enum tgt_rsp_fsm_state_e{
     90      enum tgt_rsp_fsm_state_e
     91      {
     92        TGT_RSP_CONFIG_IDLE,
     93        TGT_RSP_TGT_CMD_IDLE,
    8294        TGT_RSP_READ_IDLE,
    8395        TGT_RSP_WRITE_IDLE,
    8496        TGT_RSP_CAS_IDLE,
    8597        TGT_RSP_XRAM_IDLE,
    86         TGT_RSP_INIT_IDLE,
     98        TGT_RSP_MULTI_ACK_IDLE,
    8799        TGT_RSP_CLEANUP_IDLE,
     100        TGT_RSP_CONFIG,
     101        TGT_RSP_TGT_CMD,
    88102        TGT_RSP_READ,
    89103        TGT_RSP_WRITE,
    90104        TGT_RSP_CAS,
    91105        TGT_RSP_XRAM,
    92         TGT_RSP_INIT,
     106        TGT_RSP_MULTI_ACK,
    93107        TGT_RSP_CLEANUP
    94108      };
    95109
    96110      /* States of the DSPIN_TGT fsm */
    97       enum cc_receive_fsm_state_e{
     111      enum cc_receive_fsm_state_e
     112      {
    98113        CC_RECEIVE_IDLE,
    99114        CC_RECEIVE_CLEANUP,
     115        CC_RECEIVE_CLEANUP_EOP,
    100116        CC_RECEIVE_MULTI_ACK
    101117      };
    102118
    103119      /* States of the CC_SEND fsm */
    104       enum cc_send_fsm_state_e{
     120      enum cc_send_fsm_state_e
     121      {
     122        CC_SEND_CONFIG_IDLE,
    105123        CC_SEND_XRAM_RSP_IDLE,
    106124        CC_SEND_WRITE_IDLE,
    107125        CC_SEND_CAS_IDLE,
    108126        CC_SEND_CLEANUP_IDLE,
     127        CC_SEND_CONFIG_INVAL_HEADER,
     128        CC_SEND_CONFIG_INVAL_NLINE,
     129        CC_SEND_CONFIG_BRDCAST_HEADER,
     130        CC_SEND_CONFIG_BRDCAST_NLINE,
    109131        CC_SEND_CLEANUP_ACK,
    110132        CC_SEND_XRAM_RSP_BRDCAST_HEADER,
     
    126148
    127149      /* States of the MULTI_ACK fsm */
    128       enum multi_ack_fsm_state_e{
     150      enum multi_ack_fsm_state_e
     151      {
    129152        MULTI_ACK_IDLE,
    130153        MULTI_ACK_UPT_LOCK,
    131154        MULTI_ACK_UPT_CLEAR,
    132         MULTI_ACK_WRITE_RSP
     155        MULTI_ACK_WRITE_RSP,
     156        MULTI_ACK_CONFIG_ACK
     157      };
     158
     159      /* States of the CONFIG fsm */
     160      enum config_fsm_state_e
     161      {
     162        CONFIG_IDLE,
     163        CONFIG_LOOP,
     164        CONFIG_RSP,
     165        CONFIG_DIR_REQ,
     166        CONFIG_DIR_ACCESS,
     167        CONFIG_DIR_UPT_LOCK,
     168        CONFIG_BC_SEND,
     169        CONFIG_BC_WAIT,
     170        CONFIG_INV_SEND,
     171        CONFIG_HEAP_REQ,
     172        CONFIG_HEAP_SCAN,
     173        CONFIG_HEAP_LAST,
     174        CONFIG_INV_WAIT
    133175      };
    134176
    135177      /* States of the READ fsm */
    136       enum read_fsm_state_e{
     178      enum read_fsm_state_e
     179      {
    137180        READ_IDLE,
    138181        READ_DIR_REQ,
     
    151194
    152195      /* States of the WRITE fsm */
    153       enum write_fsm_state_e{
     196      enum write_fsm_state_e
     197      {
    154198        WRITE_IDLE,
    155199        WRITE_NEXT,
     
    177221
    178222      /* States of the IXR_RSP fsm */
    179       enum ixr_rsp_fsm_state_e{
     223      enum ixr_rsp_fsm_state_e
     224      {
    180225        IXR_RSP_IDLE,
    181226        IXR_RSP_ACK,
     
    185230
    186231      /* States of the XRAM_RSP fsm */
    187       enum xram_rsp_fsm_state_e{
     232      enum xram_rsp_fsm_state_e
     233      {
    188234        XRAM_RSP_IDLE,
    189235        XRAM_RSP_TRT_COPY,
     
    204250
    205251      /* States of the IXR_CMD fsm */
    206       enum ixr_cmd_fsm_state_e{
     252      enum ixr_cmd_fsm_state_e
     253      {
    207254        IXR_CMD_READ_IDLE,
    208255        IXR_CMD_WRITE_IDLE,
    209256        IXR_CMD_CAS_IDLE,
    210257        IXR_CMD_XRAM_IDLE,
    211         IXR_CMD_READ_NLINE,
    212         IXR_CMD_WRITE_NLINE,
    213         IXR_CMD_CAS_NLINE,
    214         IXR_CMD_XRAM_DATA
     258        IXR_CMD_READ,
     259        IXR_CMD_WRITE,
     260        IXR_CMD_CAS,
     261        IXR_CMD_XRAM
    215262      };
    216263
    217264      /* States of the CAS fsm */
    218       enum cas_fsm_state_e{
     265      enum cas_fsm_state_e
     266      {
    219267        CAS_IDLE,
    220268        CAS_DIR_REQ,
     
    241289
    242290      /* States of the CLEANUP fsm */
    243       enum cleanup_fsm_state_e{
     291      enum cleanup_fsm_state_e
     292      {
    244293        CLEANUP_IDLE,
    245294        CLEANUP_GET_NLINE,
     
    256305        CLEANUP_UPT_CLEAR,
    257306        CLEANUP_WRITE_RSP,
    258         CLEANUP_SEND_ACK
     307        CLEANUP_CONFIG_ACK,
     308        CLEANUP_SEND_CLACK
    259309      };
    260310
    261311      /* States of the ALLOC_DIR fsm */
    262       enum alloc_dir_fsm_state_e{
     312      enum alloc_dir_fsm_state_e
     313      {
    263314        ALLOC_DIR_RESET,
     315        ALLOC_DIR_CONFIG,
    264316        ALLOC_DIR_READ,
    265317        ALLOC_DIR_WRITE,
     
    270322
    271323      /* States of the ALLOC_TRT fsm */
    272       enum alloc_trt_fsm_state_e{
     324      enum alloc_trt_fsm_state_e
     325      {
    273326        ALLOC_TRT_READ,
    274327        ALLOC_TRT_WRITE,
     
    279332
    280333      /* States of the ALLOC_UPT fsm */
    281       enum alloc_upt_fsm_state_e{
     334      enum alloc_upt_fsm_state_e
     335      {
     336        ALLOC_UPT_CONFIG,
    282337        ALLOC_UPT_WRITE,
    283338        ALLOC_UPT_XRAM_RSP,
     
    288343
    289344      /* States of the ALLOC_HEAP fsm */
    290       enum alloc_heap_fsm_state_e{
     345      enum alloc_heap_fsm_state_e
     346      {
    291347        ALLOC_HEAP_RESET,
    292348        ALLOC_HEAP_READ,
     
    294350        ALLOC_HEAP_CAS,
    295351        ALLOC_HEAP_CLEANUP,
    296         ALLOC_HEAP_XRAM_RSP
     352        ALLOC_HEAP_XRAM_RSP,
     353        ALLOC_HEAP_CONFIG
    297354      };
    298355
     
    325382      };
    326383
     384      /* Configuration commands */
     385      enum cmd_config_type_e
     386      {
     387          CMD_CONFIG_INVAL = 0,
     388          CMD_CONFIG_SYNC  = 1
     389      };
     390
    327391      // debug variables (for each FSM)
    328       bool         m_debug_global;
    329       bool         m_debug_tgt_cmd_fsm;
    330       bool         m_debug_tgt_rsp_fsm;
    331       bool         m_debug_cc_send_fsm;
    332       bool         m_debug_cc_receive_fsm;
    333       bool         m_debug_multi_ack_fsm;
    334       bool         m_debug_read_fsm;
    335       bool         m_debug_write_fsm;
    336       bool         m_debug_cas_fsm;
    337       bool         m_debug_cleanup_fsm;
    338       bool         m_debug_ixr_cmd_fsm;
    339       bool         m_debug_ixr_rsp_fsm;
    340       bool         m_debug_xram_rsp_fsm;
     392      bool         m_debug;
    341393      bool         m_debug_previous_hit;
    342394      size_t       m_debug_previous_count;
    343395
    344396      bool         m_monitor_ok;
    345       vci_addr_t   m_monitor_base;
    346       vci_addr_t   m_monitor_length;
     397      addr_t       m_monitor_base;
     398      addr_t       m_monitor_length;
    347399
    348400      // instrumentation counters
    349401      uint32_t     m_cpt_cycles;        // Counter of cycles
     402
    350403      uint32_t     m_cpt_read;          // Number of READ transactions
     404      uint32_t     m_cpt_read_remote;   // number of remote READ transactions
     405      uint32_t     m_cpt_read_flits;    // number of flits for READs
     406      uint32_t     m_cpt_read_cost;     // Number of (flits * distance) for READs
     407
    351408      uint32_t     m_cpt_read_miss;     // Number of MISS READ
     409
    352410      uint32_t     m_cpt_write;         // Number of WRITE transactions
     411      uint32_t     m_cpt_write_remote;  // number of remote WRITE transactions
     412      uint32_t     m_cpt_write_flits;   // number of flits for WRITEs
     413      uint32_t     m_cpt_write_cost;    // Number of (flits * distance) for WRITEs
     414
    353415      uint32_t     m_cpt_write_miss;    // Number of MISS WRITE
    354416      uint32_t     m_cpt_write_cells;   // Cumulated length for WRITE transactions
     
    366428      uint32_t     m_cpt_cas;           // Number of CAS transactions
    367429
     430      uint32_t     m_cpt_cleanup_cost;  // Number of (flits * distance) for CLEANUPs
     431
     432      uint32_t     m_cpt_update_flits;  // Number of flits for UPDATEs
     433      uint32_t     m_cpt_update_cost;   // Number of (flits * distance) for UPDATEs
     434
     435      uint32_t     m_cpt_inval_cost;    // Number of (flits * distance) for INVALs
     436
     437      uint32_t     m_cpt_get;
     438
     439      uint32_t     m_cpt_put;
     440
    368441      size_t       m_prev_count;
    369442
     
    373446
    374447      public:
    375       sc_in<bool>                           p_clk;
    376       sc_in<bool>                           p_resetn;
    377       soclib::caba::VciTarget<vci_param>    p_vci_tgt;
    378       soclib::caba::VciInitiator<vci_param> p_vci_ixr;
    379       soclib::caba::DspinInput<33>          p_dspin_in;
    380       soclib::caba::DspinOutput<40>         p_dspin_out;
     448      sc_in<bool>                                 p_clk;
     449      sc_in<bool>                                 p_resetn;
     450      soclib::caba::VciTarget<vci_param_int>      p_vci_tgt;
     451      soclib::caba::VciInitiator<vci_param_ext>  p_vci_ixr;
     452      soclib::caba::DspinInput<dspin_in_width>    p_dspin_in;
     453      soclib::caba::DspinOutput<dspin_out_width>  p_dspin_out;
    381454
    382455      VciMemCache(
    383456          sc_module_name name,                                // Instance Name
    384           const soclib::common::MappingTable &mtp,            // Mapping table for direct network
    385           const soclib::common::MappingTable &mtx,            // Mapping table for external network
    386           const soclib::common::IntTab       &srcid_x,        // global index on external network
    387           const soclib::common::IntTab       &tgtid_d,        // global index on direct network
    388           const size_t                       cc_global_id,    // global index on cc network
     457          const soclib::common::MappingTable &mtp,            // Mapping table INT network
     458          const soclib::common::MappingTable &mtx,            // Mapping table RAM network
     459          const soclib::common::IntTab       &srcid_x,        // global index RAM network
     460          const soclib::common::IntTab       &tgtid_d,        // global index INT network
     461          const size_t                       cc_global_id,    // global index CC network
    389462          const size_t                       nways,           // Number of ways per set
    390463          const size_t                       nsets,           // Number of sets
    391464          const size_t                       nwords,          // Number of words per line
    392           const size_t                       max_copies,      // max number of copies in heap
    393           const size_t                       heap_size=1024,  // number of heap entries
    394           const size_t                       trt_lines=TRANSACTION_TAB_LINES,
    395           const size_t                       upt_lines=UPDATE_TAB_LINES,       
     465          const size_t                       max_copies,      // max number of copies
     466          const size_t                       heap_size=HEAP_ENTRIES,
     467          const size_t                       trt_lines=TRT_ENTRIES,
     468          const size_t                       upt_lines=UPT_ENTRIES,     
    396469          const size_t                       debug_start_cycle=0,
    397470          const bool                         debug_ok=false );
     
    401474      void print_stats();
    402475      void print_trace();
    403       void copies_monitor(vci_addr_t addr);
    404       void start_monitor(vci_addr_t addr, vci_addr_t length);
     476      void copies_monitor(addr_t addr);
     477      void start_monitor(addr_t addr, addr_t length);
    405478      void stop_monitor();
    406479
     
    409482      void transition();
    410483      void genMoore();
    411       void check_monitor( const char *buf, vci_addr_t addr, data_t data);
    412       void check_monitor_read( const char *buf, vci_addr_t addr);
     484      void check_monitor( const char *buf, addr_t addr, data_t data, bool read);
    413485
    414486      // Component attributes
    415       std::list<soclib::common::Segment> m_seglist;          // segments allocated to memcache
     487      std::list<soclib::common::Segment> m_seglist;          // segments allocated
    416488      size_t                             m_nseg;             // number of segments
    417489      soclib::common::Segment            **m_seg;            // array of segments pointers
    418       const size_t                       m_srcid_x;          // global index on external network
     490      size_t                             m_seg_config;       // config segment index
     491      const size_t                       m_srcid_x;          // global index on RAM network
    419492      const size_t                       m_initiators;       // Number of initiators
    420493      const size_t                       m_heap_size;        // Size of the heap
     
    434507      size_t                             m_max_copies;       // max number of copies in heap
    435508      GenericLLSCGlobalTable
    436       < 32  ,                              // number of slots
    437         4096,                              // number of processors in the system
    438         8000,                              // registratioçn life span (in # of LL operations)
    439         typename vci_param::fast_addr_t >  // address type
    440                                          m_llsc_table;       // ll/sc global registration table
     509      < 32  ,    // number of slots
     510        4096,    // number of processors in the system
     511        8000,    // registration life (# of LL operations)
     512        addr_t >                         m_llsc_table;       // ll/sc registration table
    441513
    442514      // adress masks
    443       const soclib::common::AddressMaskingTable<vci_addr_t>   m_x;
    444       const soclib::common::AddressMaskingTable<vci_addr_t>   m_y;
    445       const soclib::common::AddressMaskingTable<vci_addr_t>   m_z;
    446       const soclib::common::AddressMaskingTable<vci_addr_t>   m_nline;
     515      const soclib::common::AddressMaskingTable<addr_t>   m_x;
     516      const soclib::common::AddressMaskingTable<addr_t>   m_y;
     517      const soclib::common::AddressMaskingTable<addr_t>   m_z;
     518      const soclib::common::AddressMaskingTable<addr_t>   m_nline;
    447519
    448520      // broadcast address
    449       uint32_t                                                m_broadcast_address;
     521      uint32_t                           m_broadcast_boundaries;
    450522
    451523      //////////////////////////////////////////////////
     
    453525      //////////////////////////////////////////////////
    454526
     527      sc_signal<int>         r_tgt_cmd_fsm;
     528
    455529      // Fifo between TGT_CMD fsm and READ fsm
    456       GenericFifo<uint64_t>  m_cmd_read_addr_fifo;
     530      GenericFifo<addr_t>    m_cmd_read_addr_fifo;
    457531      GenericFifo<size_t>    m_cmd_read_length_fifo;
    458532      GenericFifo<size_t>    m_cmd_read_srcid_fifo;
     
    461535
    462536      // Fifo between TGT_CMD fsm and WRITE fsm
    463       GenericFifo<uint64_t>  m_cmd_write_addr_fifo;
     537      GenericFifo<addr_t>    m_cmd_write_addr_fifo;
    464538      GenericFifo<bool>      m_cmd_write_eop_fifo;
    465539      GenericFifo<size_t>    m_cmd_write_srcid_fifo;
     
    470544
    471545      // Fifo between TGT_CMD fsm and CAS fsm
    472       GenericFifo<uint64_t>  m_cmd_cas_addr_fifo;
     546      GenericFifo<addr_t>    m_cmd_cas_addr_fifo;
    473547      GenericFifo<bool>      m_cmd_cas_eop_fifo;
    474548      GenericFifo<size_t>    m_cmd_cas_srcid_fifo;
     
    477551      GenericFifo<data_t>    m_cmd_cas_wdata_fifo;
    478552
    479       // Fifo between INIT_RSP fsm and CLEANUP fsm
     553      // Fifo between CC_RECEIVE fsm and CLEANUP fsm
    480554      GenericFifo<uint64_t>  m_cc_receive_to_cleanup_fifo;
    481555     
    482       // Fifo between INIT_RSP fsm and MULTI_ACK fsm
     556      // Fifo between CC_RECEIVE fsm and MULTI_ACK fsm
    483557      GenericFifo<uint64_t>  m_cc_receive_to_multi_ack_fifo;
    484558
    485       sc_signal<int>         r_tgt_cmd_fsm;
     559      // Buffer between TGT_CMD fsm and TGT_RSP fsm
     560      // (segmentation violation response request)
     561      sc_signal<bool>     r_tgt_cmd_to_tgt_rsp_req;
     562
     563      sc_signal<uint32_t> r_tgt_cmd_to_tgt_rsp_rdata;
     564      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_error;
     565      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_srcid;
     566      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_trdid;
     567      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_pktid;
     568
     569      sc_signal<addr_t>   r_tgt_cmd_config_addr;
     570      sc_signal<size_t>   r_tgt_cmd_config_cmd;
     571
     572      ///////////////////////////////////////////////////////
     573      // Registers controlled by the CONFIG fsm
     574      ///////////////////////////////////////////////////////
     575
     576      sc_signal<int>      r_config_fsm;            // FSM state
     577      sc_signal<bool>     r_config_lock;           // lock protecting exclusive access
     578      sc_signal<int>      r_config_cmd;            // config request status
     579      sc_signal<addr_t>   r_config_address;        // target buffer physical address
     580      sc_signal<size_t>   r_config_srcid;          // config request srcid
     581      sc_signal<size_t>   r_config_trdid;          // config request trdid
     582      sc_signal<size_t>   r_config_pktid;          // config request pktid
     583      sc_signal<size_t>   r_config_nlines;         // number of lines covering the buffer
     584      sc_signal<size_t>   r_config_dir_way;        // DIR: selected way
     585      sc_signal<size_t>   r_config_dir_count;      // DIR: number of copies
     586      sc_signal<bool>     r_config_dir_is_cnt;     // DIR: counter mode (broadcast required)
     587      sc_signal<size_t>   r_config_dir_copy_srcid; // DIR: first copy SRCID
     588      sc_signal<bool>     r_config_dir_copy_inst;  // DIR: first copy L1 type
     589      sc_signal<size_t>   r_config_dir_next_ptr;   // DIR: index of next copy in HEAP
     590      sc_signal<size_t>   r_config_heap_next;      // current pointer to scan HEAP
     591
     592      sc_signal<size_t>   r_config_upt_index;  // UPT index
     593
     594      // Buffer between CONFIG fsm and TGT_RSP fsm (send a done response to L1 cache)
     595      sc_signal<bool>     r_config_to_tgt_rsp_req;    // valid request
     596      sc_signal<bool>     r_config_to_tgt_rsp_error;  // error response
     597      sc_signal<size_t>   r_config_to_tgt_rsp_srcid;  // Transaction srcid
     598      sc_signal<size_t>   r_config_to_tgt_rsp_trdid;  // Transaction trdid
     599      sc_signal<size_t>   r_config_to_tgt_rsp_pktid;  // Transaction pktid
     600
     601      // Buffer between CONFIG fsm and CC_SEND fsm (multi-inval / broadcast-inval)
     602      sc_signal<bool>     r_config_to_cc_send_multi_req;    // multi-inval request
     603      sc_signal<bool>     r_config_to_cc_send_brdcast_req;  // broadcast-inval request
     604      sc_signal<addr_t>   r_config_to_cc_send_nline;        // line index
     605      sc_signal<size_t>   r_config_to_cc_send_trdid;        // UPT index
     606      GenericFifo<bool>   m_config_to_cc_send_inst_fifo;    // fifo for the L1 type
     607      GenericFifo<size_t> m_config_to_cc_send_srcid_fifo;   // fifo for owners srcid
     608
     609#if L1_MULTI_CACHE
     610      GenericFifo<size_t> m_config_to_cc_send_cache_id_fifo; // fifo for cache_id
     611#endif
    486612
    487613      ///////////////////////////////////////////////////////
     
    489615      ///////////////////////////////////////////////////////
    490616
    491       sc_signal<int>      r_read_fsm;        // FSM state
    492       sc_signal<size_t>   r_read_copy;       // Srcid of the first copy
    493       sc_signal<size_t>   r_read_copy_cache; // Srcid of the first copy
    494       sc_signal<bool>     r_read_copy_inst;  // Type of the first copy
    495       sc_signal<tag_t>    r_read_tag;        // cache line tag (in directory)
    496       sc_signal<bool>     r_read_is_cnt;     // is_cnt bit (in directory)
    497       sc_signal<bool>     r_read_lock;       // lock bit (in directory)
    498       sc_signal<bool>     r_read_dirty;      // dirty bit (in directory)
    499       sc_signal<size_t>   r_read_count;      // number of copies
    500       sc_signal<size_t>   r_read_ptr;        // pointer to the heap
    501       sc_signal<data_t> * r_read_data;       // data (one cache line)
    502       sc_signal<size_t>   r_read_way;        // associative way (in cache)
    503       sc_signal<size_t>   r_read_trt_index;  // Transaction Table index
    504       sc_signal<size_t>   r_read_next_ptr;   // Next entry to point to
    505       sc_signal<bool>     r_read_last_free;  // Last free entry
    506       sc_signal<typename vci_param::fast_addr_t>
    507                           r_read_ll_key;     // LL key returned by the llsc_global_table
     617      sc_signal<int>      r_read_fsm;          // FSM state
     618      sc_signal<size_t>   r_read_copy;         // Srcid of the first copy
     619      sc_signal<size_t>   r_read_copy_cache;   // Srcid of the first copy
     620      sc_signal<bool>     r_read_copy_inst;    // Type of the first copy
     621      sc_signal<tag_t>    r_read_tag;          // cache line tag (in directory)
     622      sc_signal<bool>     r_read_is_cnt;       // is_cnt bit (in directory)
     623      sc_signal<bool>     r_read_lock;         // lock bit (in directory)
     624      sc_signal<bool>     r_read_dirty;        // dirty bit (in directory)
     625      sc_signal<size_t>   r_read_count;        // number of copies
     626      sc_signal<size_t>   r_read_ptr;          // pointer to the heap
     627      sc_signal<data_t> * r_read_data;         // data (one cache line)
     628      sc_signal<size_t>   r_read_way;          // associative way (in cache)
     629      sc_signal<size_t>   r_read_trt_index;    // Transaction Table index
     630      sc_signal<size_t>   r_read_next_ptr;     // Next entry to point to
     631      sc_signal<bool>     r_read_last_free;    // Last free entry
     632      sc_signal<addr_t>   r_read_ll_key;       // LL key from the llsc_global_table
    508633
    509634      // Buffer between READ fsm and IXR_CMD fsm (ask a missing cache line to XRAM)
     
    520645      sc_signal<size_t>   r_read_to_tgt_rsp_word;   // first word of the response
    521646      sc_signal<size_t>   r_read_to_tgt_rsp_length; // length of the response
    522       sc_signal<typename vci_param::fast_addr_t>
    523                           r_read_to_tgt_rsp_ll_key; // LL key returned by the llsc_global_table
     647      sc_signal<addr_t>   r_read_to_tgt_rsp_ll_key; // LL key from the llsc_global_table
    524648
    525649      ///////////////////////////////////////////////////////////////
     
    578702      GenericFifo<bool>   m_write_to_cc_send_inst_fifo;     // fifo for the L1 type
    579703      GenericFifo<size_t> m_write_to_cc_send_srcid_fifo;    // fifo for srcids
     704
    580705#if L1_MULTI_CACHE
    581706      GenericFifo<size_t> m_write_to_cc_send_cache_id_fifo; // fifo for srcids
     
    596721      sc_signal<size_t>   r_multi_ack_pktid;     // pending write pktid
    597722      sc_signal<addr_t>   r_multi_ack_nline;     // pending write nline
     723
     724      // signaling completion of multi-inval to CONFIG fsm
     725      sc_signal<bool>     r_multi_ack_to_config_ack;
    598726
    599727      // Buffer between MULTI_ACK fsm and TGT_RSP fsm (complete write/update transaction)
     
    633761      sc_signal<size_t>   r_cleanup_way;           // associative way (in cache)
    634762
    635       sc_signal<size_t>   r_cleanup_write_srcid;   // srcid of write response
     763      sc_signal<size_t>   r_cleanup_write_srcid;   // srcid of write rsp
    636764      sc_signal<size_t>   r_cleanup_write_trdid;   // trdid of write rsp
    637765      sc_signal<size_t>   r_cleanup_write_pktid;   // pktid of write rsp
    638       sc_signal<bool>     r_cleanup_write_need_rsp;// needs a write rsp
     766
     767      sc_signal<bool>     r_cleanup_need_rsp;      // write response required
     768      sc_signal<bool>     r_cleanup_need_ack;      // config acknowledge required
    639769
    640770      sc_signal<size_t>   r_cleanup_index;         // index of the INVAL line (in the UPT)
    641771
     772      // signaling completion of broadcast-inval to CONFIG fsm
     773      sc_signal<bool>     r_cleanup_to_config_ack; 
     774       
    642775      // Buffer between CLEANUP fsm and TGT_RSP fsm (acknowledge a write command from L1)
    643776      sc_signal<bool>     r_cleanup_to_tgt_rsp_req;   // valid request
     
    703836      GenericFifo<bool>   m_cas_to_cc_send_inst_fifo;     // fifo for the L1 type
    704837      GenericFifo<size_t> m_cas_to_cc_send_srcid_fifo;    // fifo for srcids
     838
    705839#if L1_MULTI_CACHE
    706840      GenericFifo<size_t> m_cas_to_cc_send_cache_id_fifo; // fifo for srcids
     
    749883      sc_signal<size_t>   r_xram_rsp_to_tgt_rsp_length; // length of the response
    750884      sc_signal<bool>     r_xram_rsp_to_tgt_rsp_rerror; // send error to requester
    751       sc_signal<typename vci_param::fast_addr_t>
    752                           r_xram_rsp_to_tgt_rsp_ll_key; // LL key returned by the llsc_global_table
     885      sc_signal<addr_t>   r_xram_rsp_to_tgt_rsp_ll_key; // LL key from llsc_global_table
    753886
    754887      // Buffer between XRAM_RSP fsm and CC_SEND fsm (Inval L1 Caches)
     
    759892      GenericFifo<bool>   m_xram_rsp_to_cc_send_inst_fifo;     // fifo for the L1 type
    760893      GenericFifo<size_t> m_xram_rsp_to_cc_send_srcid_fifo;    // fifo for srcids
     894
    761895#if L1_MULTI_CACHE
    762896      GenericFifo<size_t> m_xram_rsp_to_cc_send_cache_id_fifo; // fifo for srcids
  • branches/v5/modules/vci_mem_cache/caba/source/include/xram_transaction.h

    r362 r440  
    1313////////////////////////////////////////////////////////////////////////
    1414
    15 class TransactionTabEntry {
    16     typedef uint32_t              size_t;
     15class TransactionTabEntry
     16{
     17    typedef sc_dt::sc_uint<64>    wide_data_t;
     18    typedef sc_dt::sc_uint<40>    addr_t;
    1719    typedef uint32_t              data_t;
    18     typedef sc_dt::sc_uint<40>    addr_t;
    1920    typedef uint32_t              be_t;
    2021
     
    8485    // The print() function prints the entry
    8586    ////////////////////////////////////////////////////////////////////
    86     void print(){
     87    void print()
     88    {
    8789        std::cout << "valid       = " << valid        << std::endl;
    8890        std::cout << "xram_read   = " << xram_read    << std::endl;
     
    137139//                  The transaction tab                             
    138140////////////////////////////////////////////////////////////////////////
    139 class TransactionTab{
    140     typedef uint32_t size_t;
    141     typedef uint32_t data_t;
    142     typedef sc_dt::sc_uint<40> addr_t;
    143     typedef uint32_t be_t;
     141class TransactionTab
     142{
     143    typedef sc_dt::sc_uint<64>    wide_data_t;
     144    typedef sc_dt::sc_uint<40>    addr_t;
     145    typedef uint32_t              data_t;
     146    typedef uint32_t              be_t;
    144147
    145148    private:
    146     size_t size_tab;                // The size of the tab
     149    const std::string tab_name;                // the name for logs
     150    size_t            size_tab;                // the size of the tab
    147151
    148152    data_t be_to_mask(be_t be)
     
    176180    }
    177181
    178     TransactionTab(size_t n_entries, size_t n_words)
    179     {
    180         size_tab = n_entries;
     182    TransactionTab(const std::string &name,
     183                   size_t            n_entries,
     184                   size_t            n_words )
     185    : tab_name( name ),
     186      size_tab( n_entries )
     187    {
    181188        tab = new TransactionTabEntry[size_tab];
    182         for ( size_t i=0; i<size_tab; i++) {
     189        for ( size_t i=0; i<size_tab; i++)
     190        {
    183191            tab[i].alloc(n_words);
    184192        }
     
    368376
    369377    /////////////////////////////////////////////////////////////////////
    370     // The write_rsp() function writes a word of the response to an
    371     // XRAM read transaction.
     378    // The write_rsp() function writes two 32 bits words of the response
     379    // to a XRAM read transaction.
    372380    // The BE field in TRT is taken into account.
    373381    // Arguments :
    374382    // - index : the index of the transaction in the transaction tab
    375383    // - word_index : the index of the data in the line
    376     // - data : the data to write
     384    // - data : a 64 bits value
    377385    // - error : invalid data
    378386    /////////////////////////////////////////////////////////////////////
    379     void write_rsp(const size_t index,
    380             const size_t word,
    381             const data_t data,
    382             const bool   rerror)
    383     {
    384         assert( (index < size_tab)
    385                 && "Selected entry  out of range in write_rsp() Transaction Tab");
    386         assert( (word <= tab[index].wdata_be.size())
    387                 && "Bad word_index in write_rsp() in TransactionTab");
    388         assert( tab[index].valid
    389                 && "Transaction Tab Entry invalid in write_rsp()");
    390         assert( tab[index].xram_read
    391                 && "Selected entry is not an XRAM read transaction in write_rsp()");
    392 
    393         data_t mask = be_to_mask(tab[index].wdata_be[word]);
    394         tab[index].wdata[word] = (tab[index].wdata[word] & mask) | (data & ~mask);
     387    void write_rsp(const size_t      index,
     388                   const size_t      word,
     389                   const wide_data_t data,
     390                   const bool        rerror)
     391    {
     392        data_t  value;
     393        data_t  mask;
     394
     395        if ( index >= size_tab )
     396        {
     397            std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
     398                      <<  " TRT entry  out of range in write_rsp()" << std::endl;
     399            exit(0);
     400        }
     401        if ( word > tab[index].wdata_be.size() )
     402        {
     403            std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
     404                      <<  " Bad word_index in write_rsp() in TRT" << std::endl;
     405            exit(0);
     406        }
     407        if ( not tab[index].valid )
     408        {
     409            std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
     410                      <<  " TRT Entry invalid in write_rsp()" << std::endl;
     411            exit(0);
     412        }
     413        if ( not tab[index].xram_read )
     414        {
     415            std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
     416                      <<  " TRT entry is not an XRAM GET in write_rsp()" << std::endl;
     417            exit(0);
     418        }
     419
     420        // first 32 bits word
     421        value = (data_t)data;
     422        mask  = be_to_mask(tab[index].wdata_be[word]);
     423        tab[index].wdata[word] = (tab[index].wdata[word] & mask) | (value & ~mask);
     424
     425        // second 32 bits word
     426        value = (data_t)(data>>32);
     427        mask  = be_to_mask(tab[index].wdata_be[word+1]);
     428        tab[index].wdata[word+1] = (tab[index].wdata[word+1] & mask) | (value & ~mask);
     429
     430        // error update
    395431        tab[index].rerror |= rerror;
    396432    }
  • branches/v5/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r367 r440  
    2626* SOCLIB_LGPL_HEADER_END
    2727*
    28 * Maintainers: alain eric.guthmuller@polytechnique.edu
     28* Maintainers: alain.greiner@lip6.fr
     29*              eric.guthmuller@polytechnique.edu
    2930*              cesar.fuguet-tortolero@lip6.fr
    3031*              alexandre.joannou@lip6.fr
     
    3334#include "../include/vci_mem_cache.h"
    3435
    35 //////   debug services   ///////////////////////////////////////////////////////
     36//////   debug services   /////////////////////////////////////////////////////////////
    3637// All debug messages are conditionned by two variables:
    3738// - compile time   : DEBUG_MEMC_*** : defined below
    38 // - execution time : m_debug_***    : defined by constructor arguments
    39 //    m_debug_* = (m_debug_ok) and (m_cpt_cycle > m_debug_start_cycle)
    40 /////////////////////////////////////////////////////////////////////////////////
    41 
    42 #define DEBUG_MEMC_GLOBAL   0 // synthetic trace of all FSMs
    43 #define DEBUG_MEMC_READ     1 // detailed trace of READ FSM
    44 #define DEBUG_MEMC_WRITE    1 // detailed trace of WRITE FSM
    45 #define DEBUG_MEMC_CAS      1 // detailed trace of CAS FSM
    46 #define DEBUG_MEMC_IXR_CMD  1 // detailed trace of IXR_RSP FSM
    47 #define DEBUG_MEMC_IXR_RSP  1 // detailed trace of IXR_RSP FSM
    48 #define DEBUG_MEMC_XRAM_RSP 1 // detailed trace of XRAM_RSP FSM
    49 #define DEBUG_MEMC_CC_SEND 1 // detailed trace of CC_SEND FSM
     39// - execution time : m_debug  = (m_debug_ok) and (m_cpt_cycle > m_debug_start_cycle)
     40///////////////////////////////////////////////////////////////////////////////////////
     41
     42#define DEBUG_MEMC_GLOBAL    0 // synthetic trace of all FSMs
     43#define DEBUG_MEMC_CONFIG    1 // detailed trace of CONFIG FSM
     44#define DEBUG_MEMC_READ      1 // detailed trace of READ FSM
     45#define DEBUG_MEMC_WRITE     1 // detailed trace of WRITE FSM
     46#define DEBUG_MEMC_CAS       1 // detailed trace of CAS FSM
     47#define DEBUG_MEMC_IXR_CMD   1 // detailed trace of IXR_RSP FSM
     48#define DEBUG_MEMC_IXR_RSP   1 // detailed trace of IXR_RSP FSM
     49#define DEBUG_MEMC_XRAM_RSP  1 // detailed trace of XRAM_RSP FSM
     50#define DEBUG_MEMC_CC_SEND   1 // detailed trace of CC_SEND FSM
    5051#define DEBUG_MEMC_MULTI_ACK 1 // detailed trace of MULTI_ACK FSM
    51 #define DEBUG_MEMC_TGT_CMD  1 // detailed trace of TGT_CMD FSM
    52 #define DEBUG_MEMC_TGT_RSP  1 // detailed trace of TGT_RSP FSM
    53 #define DEBUG_MEMC_CLEANUP  1 // detailed trace of CLEANUP FSM
    54 
    55 #define RANDOMIZE_CAS       1
    56 
    57 namespace soclib
    58 {
    59 namespace caba
    60 {
     52#define DEBUG_MEMC_TGT_CMD   1 // detailed trace of TGT_CMD FSM
     53#define DEBUG_MEMC_TGT_RSP   1 // detailed trace of TGT_RSP FSM
     54#define DEBUG_MEMC_CLEANUP   1 // detailed trace of CLEANUP FSM
     55
     56#define RANDOMIZE_CAS        1
     57
     58namespace soclib { namespace caba {
    6159
    6260const char *tgt_cmd_fsm_str[] =
    6361{
    6462  "TGT_CMD_IDLE",
     63  "TGT_CMD_ERROR",
    6564  "TGT_CMD_READ",
    6665  "TGT_CMD_WRITE",
    67   "TGT_CMD_CAS"
     66  "TGT_CMD_CAS",
     67  "TGT_CMD_CONFIG"
    6868};
    6969const char *tgt_rsp_fsm_str[] =
    7070{
     71  "TGT_RSP_CONFIG_IDLE",
     72  "TGT_RSP_TGT_CMD_IDLE",
    7173  "TGT_RSP_READ_IDLE",
    7274  "TGT_RSP_WRITE_IDLE",
    7375  "TGT_RSP_CAS_IDLE",
    7476  "TGT_RSP_XRAM_IDLE",
    75   "TGT_RSP_INIT_IDLE",
     77  "TGT_RSP_MULTI_ACK_IDLE",
    7678  "TGT_RSP_CLEANUP_IDLE",
     79  "TGT_RSP_CONFIG",
     80  "TGT_RSP_TGT_CMD",
    7781  "TGT_RSP_READ",
    7882  "TGT_RSP_WRITE",
    7983  "TGT_RSP_CAS",
    8084  "TGT_RSP_XRAM",
    81   "TGT_RSP_INIT",
     85  "TGT_RSP_MULTI_ACK",
    8286  "TGT_RSP_CLEANUP"
    8387};
     
    8690  "CC_RECEIVE_IDLE",
    8791  "CC_RECEIVE_CLEANUP",
     92  "CC_RECEIVE_CLEANUP_EOP",
    8893  "CC_RECEIVE_MULTI_ACK"
    8994};
    9095const char *cc_send_fsm_str[] =
    9196{
     97  "CC_SEND_CONFIG_IDLE",
    9298  "CC_SEND_XRAM_RSP_IDLE",
    9399  "CC_SEND_WRITE_IDLE",
    94100  "CC_SEND_CAS_IDLE",
    95101  "CC_SEND_CLEANUP_IDLE",
     102  "CC_SEND_CONFIG_INVAL_HEADER",
     103  "CC_SEND_CONFIG_INVAL_NLINE",
     104  "CC_SEND_CONFIG_BRDCAST_HEADER",
     105  "CC_SEND_CONFIG_BRDCAST_NLINE",
    96106  "CC_SEND_CLEANUP_ACK",
    97107  "CC_SEND_XRAM_RSP_BRDCAST_HEADER",
     
    116126  "MULTI_ACK_UPT_LOCK",
    117127  "MULTI_ACK_UPT_CLEAR",
    118   "MULTI_ACK_WRITE_RSP"
     128  "MULTI_ACK_WRITE_RSP",
     129  "MULTI_ACK_CONFIG_ACK"
     130};
     131const char *config_fsm_str[] =
     132{
     133  "CONFIG_IDLE",
     134  "CONFIG_LOOP",
     135  "CONFIG_RSP",
     136  "CONFIG_DIR_REQ",
     137  "CONFIG_DIR_ACCESS",
     138  "CONFIG_DIR_UPT_LOCK",
     139  "CONFIG_BC_SEND",
     140  "CONFIG_BC_WAIT",
     141  "CONFIG_INV_SEND",
     142  "CONFIG_HEAP_REQ",
     143  "CONFIG_HEAP_SCAN",
     144  "CONFIG_HEAP_LAST",
     145  "CONFIG_INV_WAIT"
    119146};
    120147const char *read_fsm_str[] =
     
    190217  "IXR_CMD_CAS_IDLE",
    191218  "IXR_CMD_XRAM_IDLE",
    192   "IXR_CMD_READ_NLINE",
    193   "IXR_CMD_WRITE_NLINE",
    194   "IXR_CMD_CAS_NLINE",
    195   "IXR_CMD_XRAM_DATA"
     219  "IXR_CMD_READ",
     220  "IXR_CMD_WRITE",
     221  "IXR_CMD_CAS",
     222  "IXR_CMD_XRAM"
    196223};
    197224const char *cas_fsm_str[] =
     
    235262  "CLEANUP_UPT_CLEAR",
    236263  "CLEANUP_WRITE_RSP",
    237   "CLEANUP_SEND_ACK"
     264  "CLEANUP_CONFIG_ACK",
     265  "CLEANUP_SEND_CLACK"
    238266};
    239267const char *alloc_dir_fsm_str[] =
     
    269297  "ALLOC_HEAP_CAS",
    270298  "ALLOC_HEAP_CLEANUP",
    271   "ALLOC_HEAP_XRAM_RSP"
     299  "ALLOC_HEAP_XRAM_RSP",
     300  "ALLOC_HEAP_CONFIG"
    272301};
    273302
    274303#define tmpl(x) \
    275   template<typename vci_param> x \
    276   VciMemCache<vci_param>
     304  template<typename vci_param_int, \
     305           typename vci_param_ext, \
     306           size_t dspin_in_width,  \
     307           size_t dspin_out_width> x \
     308  VciMemCache<vci_param_int, vci_param_ext, dspin_in_width, dspin_out_width>
    277309
    278310using namespace soclib::common;
     
    288320  const IntTab        &srcid_x,          // global index on external network
    289321  const IntTab        &tgtid_d,          // global index on direct network
    290   const size_t        cc_global_id,      // global index on cc network 
     322  const size_t        cc_global_id,      // global index on cc network
    291323  const size_t        nways,             // number of ways per set
    292   const size_t        nsets,             // number of associative sets 
     324  const size_t        nsets,             // number of associative sets
    293325  const size_t        nwords,            // number of words in cache line
    294326  const size_t        max_copies,        // max number of copies in heap
     
    311343    m_nseg( 0 ),
    312344    m_srcid_x( mtx.indexForId(srcid_x) ),
    313     m_initiators( 1 << vci_param::S ),
     345    m_initiators( 1 << vci_param_int::S ),
    314346    m_heap_size( heap_size ),
    315347    m_ways( nways ),
     
    320352    m_debug_ok( debug_ok ),
    321353    m_trt_lines(trt_lines),
    322     m_trt(trt_lines, nwords),
     354    m_trt(this->name(), trt_lines, nwords),
    323355    m_upt_lines(upt_lines),
    324356    m_upt(upt_lines),
    325     m_cache_directory(nways, nsets, nwords, vci_param::N),
     357    m_cache_directory(nways, nsets, nwords, vci_param_int::N),
    326358    m_cache_data(nways, nsets, nwords),
    327359    m_heap(m_heap_size),
     
    332364    m_x(L2(m_words), 2),
    333365    m_y(L2(m_sets), L2(m_words) + 2),
    334     m_z(vci_param::N - L2(m_sets) - L2(m_words) - 2, L2(m_sets) + L2(m_words) + 2),
    335     m_nline(vci_param::N - L2(m_words) - 2, L2(m_words) + 2),
     366    m_z(vci_param_int::N - L2(m_sets) - L2(m_words) - 2, L2(m_sets) + L2(m_words) + 2),
     367    m_nline(vci_param_int::N - L2(m_words) - 2, L2(m_words) + 2),
    336368#undef L2
    337369
    338370    // XMIN(5 bits) / XMAX(5 bits) / YMIN(5 bits) / YMAX(5 bits)
    339371    //   0b00000    /   0b11111    /   0b00000    /   0b11111
    340     m_broadcast_address(0x7C1F),
     372    m_broadcast_boundaries(0x7C1F),
     373
     374    r_tgt_cmd_fsm("r_tgt_cmd_fsm"),
    341375
    342376    //  FIFOs
     
    365399    m_cc_receive_to_multi_ack_fifo("m_cc_receive_to_multi_ack_fifo", 4),
    366400
    367     r_tgt_cmd_fsm("r_tgt_cmd_fsm"),
    368 
    369     r_read_fsm("r_read_fsm"),
    370 
    371     r_write_fsm("r_write_fsm"),
     401    r_config_fsm( "r_config_fsm" ),
     402
     403    m_config_to_cc_send_inst_fifo( "m_config_to_cc_send_inst_fifo", 8 ),
     404    m_config_to_cc_send_srcid_fifo( "m_config_to_cc_send_srcid_fifo", 8 ),
     405
     406    r_read_fsm( "r_read_fsm" ),
     407
     408    r_write_fsm( "r_write_fsm" ),
    372409
    373410    m_write_to_cc_send_inst_fifo("m_write_to_cc_send_inst_fifo",8),
     
    412449    r_alloc_heap_reset_cpt("r_alloc_heap_reset_cpt")
    413450{
     451    std::cout << "  - Building VciMemCache : " << name << std::endl;
     452
    414453    assert(IS_POW_OF_2(nsets));
    415454    assert(IS_POW_OF_2(nwords));
     
    420459
    421460    // check Transaction table size
    422     assert((uint32_log2(trt_lines) <= vci_param::T) and
    423          "Need more bits for VCI TRDID field");
     461    assert((uint32_log2(trt_lines) <= vci_param_ext::T) and
     462    "MEMC ERROR : Need more bits for VCI TRDID field");
     463
     464    // check internal and external data width
     465    assert( (vci_param_int::B == 4 ) and
     466    "MEMC ERROR : VCI internal data width must be 32 bits");
     467
     468    assert( (vci_param_ext::B == 8) and
     469    "MEMC ERROR : VCI external data width must be 64 bits");
     470
     471    // Check coherence between internal & external addresses
     472    assert( (vci_param_int::N == vci_param_ext::N) and
     473    "MEMC ERROR : VCI internal & external addresses must have the same width");
    424474
    425475    // Get the segments associated to the MemCache
     
    429479    for(seg = m_seglist.begin(); seg != m_seglist.end() ; seg++)
    430480    {
     481        std::cout << "    => segment " << seg->name()
     482                  << " / base = " << std::hex << seg->baseAddress()
     483                  << " / size = " << seg->size() << std::endl;
    431484        m_nseg++;
    432485    }
     
    436489    for(seg = m_seglist.begin() ; seg != m_seglist.end() ; seg++)
    437490    {
     491        if ( seg->special() ) m_seg_config = i;
    438492        m_seg[i] = & (*seg);
    439493        i++;
     
    475529
    476530///////////////////////////////////////////////////////////////////////
    477 tmpl(void) ::start_monitor(vci_addr_t addr, vci_addr_t length)
     531tmpl(void) ::start_monitor(addr_t addr, addr_t length)
    478532///////////////////////////////////////////////////////////////////////
    479533{
     
    490544}
    491545
    492 ///////////////////////////////////////////////////////////////////////
    493 tmpl(void) ::check_monitor(const char *buf, vci_addr_t addr, data_t data)
    494 ///////////////////////////////////////////////////////////////////////
     546////////////////////////////////////////////////
     547tmpl(void) ::check_monitor( const char  *buf,
     548                            addr_t      addr,
     549                            data_t      data,
     550                            bool        read )
     551////////////////////////////////////////////////
    495552{
    496553  if((addr >= m_monitor_base) and
    497554      (addr < m_monitor_base + m_monitor_length))
    498555  {
    499     std::cout << " MEMC Write Monitor : " << buf << " Address = " << std::hex << addr
    500               << " / Data = " << data << " at cycle " << std::dec << m_cpt_cycles << std::endl;
     556    if ( read ) std::cout << " Monitor MEMC Read  ";
     557    else        std::cout << " Monitor MEMC Write ";
     558    std::cout << buf
     559              << " / Address = " << std::hex << addr
     560              << " / Data = " << data
     561              << " at cycle " << std::dec << m_cpt_cycles << std::endl;
    501562  }
    502563}
    503564
    504 ///////////////////////////////////////////////////////////////////////
    505 tmpl(void) ::check_monitor_read(const char *buf, vci_addr_t addr)
    506 ///////////////////////////////////////////////////////////////////////
    507 {
    508   if((addr >= m_monitor_base) and
    509       (addr < m_monitor_base + m_monitor_length))
    510   {
    511     std::cout << " MEMC Read Monitor : " << buf << " Address = " << std::hex << addr
    512               << std::endl;
    513   }
    514 }
    515 
    516565/////////////////////////////////////////////////////
    517 tmpl(void) ::copies_monitor(vci_addr_t addr)
     566tmpl(void) ::copies_monitor(addr_t addr)
    518567/////////////////////////////////////////////////////
    519568{
    520569  DirectoryEntry entry = m_cache_directory.read_neutral(addr);
     570
    521571  if((entry.count != m_debug_previous_count) or
    522572      (entry.valid != m_debug_previous_hit))
    523573  {
    524     std::cout << " MEMC " << name()
    525               << " cache change at cycle " << std::dec << m_cpt_cycles
     574    std::cout << "Monitor MEMC " << name()
     575              << " at cycle " << std::dec << m_cpt_cycles
    526576              << " for address " << std::hex << addr
    527577              << " / HIT = " << entry.valid
     
    537587{
    538588  std::cout << "MEMC " << name() << std::endl;
    539   std::cout << "  "  << tgt_cmd_fsm_str[r_tgt_cmd_fsm]
    540             << " | " << tgt_rsp_fsm_str[r_tgt_rsp_fsm]
    541             << " | " << read_fsm_str[r_read_fsm]
    542             << " | " << write_fsm_str[r_write_fsm]
    543             << " | " << cas_fsm_str[r_cas_fsm]
    544             << " | " << cleanup_fsm_str[r_cleanup_fsm] << std::endl;
    545   std::cout << "  "  << cc_send_fsm_str[r_cc_send_fsm]
    546             << " | " << cc_receive_fsm_str[r_cc_receive_fsm]
    547             << " | " << multi_ack_fsm_str[r_multi_ack_fsm]
    548             << " | " << ixr_cmd_fsm_str[r_ixr_cmd_fsm]
    549             << " | " << ixr_rsp_fsm_str[r_ixr_rsp_fsm]
     589  std::cout << "  "  << tgt_cmd_fsm_str[r_tgt_cmd_fsm.read()]
     590            << " | " << tgt_rsp_fsm_str[r_tgt_rsp_fsm.read()]
     591            << " | " << read_fsm_str[r_read_fsm.read()]
     592            << " | " << write_fsm_str[r_write_fsm.read()]
     593            << " | " << cas_fsm_str[r_cas_fsm.read()]
     594            << " | " << config_fsm_str[r_config_fsm.read()]
     595            << " | " << cleanup_fsm_str[r_cleanup_fsm.read()] << std::endl;
     596  std::cout << "  "  << cc_send_fsm_str[r_cc_send_fsm.read()]
     597            << " | " << cc_receive_fsm_str[r_cc_receive_fsm.read()]
     598            << " | " << multi_ack_fsm_str[r_multi_ack_fsm.read()]
     599            << " | " << ixr_cmd_fsm_str[r_ixr_cmd_fsm.read()]
     600            << " | " << ixr_rsp_fsm_str[r_ixr_rsp_fsm.read()]
    550601            << " | " << xram_rsp_fsm_str[r_xram_rsp_fsm] << std::endl;
    551 
    552   //m_llsc_table.print_trace();
    553 
     602  std::cout << "  "  << alloc_dir_fsm_str[r_alloc_dir_fsm.read()]
     603            << " | " << alloc_trt_fsm_str[r_alloc_trt_fsm.read()]
     604            << " | " << alloc_upt_fsm_str[r_alloc_upt_fsm.read()]
     605            << " | " << alloc_heap_fsm_str[r_alloc_heap_fsm.read()] << std::endl;
    554606}
    555607
     
    613665    // Initializing FSMs
    614666    r_tgt_cmd_fsm    = TGT_CMD_IDLE;
    615     r_tgt_rsp_fsm    = TGT_RSP_READ_IDLE;
     667    r_config_fsm     = CONFIG_IDLE;
     668    r_tgt_rsp_fsm    = TGT_RSP_TGT_CMD_IDLE;
    616669    r_cc_send_fsm    = CC_SEND_XRAM_RSP_IDLE;
    617670    r_cc_receive_fsm = CC_RECEIVE_IDLE;
     
    629682    r_ixr_cmd_fsm    = IXR_CMD_READ_IDLE;
    630683
    631     m_debug_global         = false;
    632     m_debug_tgt_cmd_fsm    = false;
    633     m_debug_tgt_rsp_fsm    = false;
    634     m_debug_cc_send_fsm  = false;
    635     m_debug_cc_receive_fsm  = false;
    636     m_debug_multi_ack_fsm  = false;
    637     m_debug_read_fsm       = false;
    638     m_debug_write_fsm      = false;
    639     m_debug_cas_fsm        = false;
    640     m_debug_cleanup_fsm    = false;
    641     m_debug_ixr_cmd_fsm    = false;
    642     m_debug_ixr_rsp_fsm    = false;
    643     m_debug_xram_rsp_fsm   = false;
     684    m_debug                = false;
    644685    m_debug_previous_hit   = false;
    645686    m_debug_previous_count = 0;
     
    672713    m_cmd_cas_eop_fifo.init()   ;
    673714
     715    r_config_cmd  = MEMC_CMD_NOP;
     716    r_config_lock = false;
     717
     718    m_config_to_cc_send_inst_fifo.init();
     719    m_config_to_cc_send_srcid_fifo.init();
     720#if L1_MULTI_CACHE
     721    m_config_to_cc_send_cache_id_fifo.init();
     722#endif
     723
     724    r_tgt_cmd_to_tgt_rsp_req = false;
     725
    674726    r_read_to_tgt_rsp_req = false;
    675727    r_read_to_ixr_cmd_req = false;
     
    677729    r_write_to_tgt_rsp_req          = false;
    678730    r_write_to_ixr_cmd_req          = false;
    679     r_write_to_cc_send_multi_req   = false;
    680     r_write_to_cc_send_brdcast_req = false;
     731    r_write_to_cc_send_multi_req    = false;
     732    r_write_to_cc_send_brdcast_req  = false;
    681733    r_write_to_multi_ack_req        = false;
    682734
     
    765817  bool    cc_receive_to_cleanup_fifo_get = false;
    766818  bool    cc_receive_to_cleanup_fifo_put = false;
    767    
     819
    768820  bool    cc_receive_to_multi_ack_fifo_get = false;
    769821  bool    cc_receive_to_multi_ack_fifo_put = false;
     
    787839#endif
    788840
     841  bool    config_to_cc_send_fifo_put   = false;
     842  bool    config_to_cc_send_fifo_get   = false;
     843  bool    config_to_cc_send_fifo_inst  = false;
     844  size_t  config_to_cc_send_fifo_srcid = 0;
     845
    789846  bool    cas_to_cc_send_fifo_put   = false;
    790847  bool    cas_to_cc_send_fifo_get   = false;
     
    796853#endif
    797854
    798   m_debug_global         = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    799   m_debug_tgt_cmd_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    800   m_debug_tgt_rsp_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    801   m_debug_cc_send_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    802   m_debug_cc_receive_fsm = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    803   m_debug_multi_ack_fsm  = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    804   m_debug_read_fsm       = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    805   m_debug_write_fsm      = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    806   m_debug_cas_fsm        = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    807   m_debug_cleanup_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    808   m_debug_ixr_cmd_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    809   m_debug_ixr_rsp_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    810   m_debug_xram_rsp_fsm   = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
     855  m_debug = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    811856
    812857#if DEBUG_MEMC_GLOBAL
    813   if(m_debug_global)
    814   {
     858if(m_debug)
     859{
    815860    std::cout
    816861        << "---------------------------------------------"           << std::dec << std::endl
    817         << "MEM_CACHE "            << name() 
     862        << "MEM_CACHE "            << name()
    818863        << " ; Time = "            << m_cpt_cycles                                << std::endl
    819864        << " - TGT_CMD FSM    = "  << tgt_cmd_fsm_str[r_tgt_cmd_fsm.read()]       << std::endl
     
    833878        << " - ALLOC_UPT FSM  = "  << alloc_upt_fsm_str[r_alloc_upt_fsm.read()]   << std::endl
    834879        << " - ALLOC_HEAP FSM = "  << alloc_heap_fsm_str[r_alloc_heap_fsm.read()] << std::endl;
    835   }
     880}
    836881#endif
    837882
     
    839884  //    TGT_CMD FSM
    840885  ////////////////////////////////////////////////////////////////////////////////////
    841   // The TGT_CMD_FSM controls the incoming VCI command pakets from the processors
     886  // The TGT_CMD_FSM controls the incoming VCI command pakets from the processors,
     887  // and dispatch these commands to the proper FSM through dedicated FIFOs.
    842888  //
    843   // There are 5 types of accepted commands :
    844   // - READ   : A READ request has a length of 1 VCI cell. It can be a single word
    845   //            or an entire cache line, depending on the PLEN value.
    846   // - WRITE  : A WRITE request has a maximum length of 16 cells, and can only
    847   //            concern words in a same line.
    848   // - CAS    : A CAS request has a length of 2 cells or 4 cells.
    849   // - LL     : An LL request has a length of 1 cell.
    850   // - SC     : An SC request has a length of 2 cells. First cell contains the
    851   //            acces key, second cell the data to write in case of success.
     889  // There are 5 types of commands accepted in the XRAM segment:
     890  // - READ   : A READ request has a length of 1 VCI flit. It can be a single word
     891  //            or an entire cache line, depending on the PLEN value => READ FSM
     892  // - WRITE  : A WRITE request has a maximum length of 16 flits, and can only
     893  //            concern words in a same line => WRITE FSM
     894  // - CAS    : A CAS request has a length of 2 flits or 4 flits => CAS FSM
     895  // - LL     : An LL request has a length of 1 flit => READ FSM
     896  // - SC     : An SC request has a length of 2 flits. First flit contains the
     897  //            acces key, second flit the data to write => WRITE FSM.
     898  //
     899  // The READ/WRITE commands accepted in the configuration segment are targeting
     900  // configuration or status registers. They must contain one single flit.
     901  // - For almost all addressable registers, the response is returned immediately.
     902  // - For MEMC_CMD_TYPE, the response is delayed until the operation is completed.
    852903  ////////////////////////////////////////////////////////////////////////////////////
    853904
    854905  switch(r_tgt_cmd_fsm.read())
    855906  {
    856       //////////////////
    857     case TGT_CMD_IDLE:
    858       if(p_vci_tgt.cmdval)
    859       {
     907    //////////////////
     908    case TGT_CMD_IDLE:     // waiting a VCI command (RAM or CONFIG)
     909    if(p_vci_tgt.cmdval)
     910    {
    860911
    861912#if DEBUG_MEMC_TGT_CMD
    862         if(m_debug_tgt_cmd_fsm)
    863         {
    864           std::cout
    865               << "  <MEMC " << name()
    866               << ".TGT_CMD_IDLE> Receive command from srcid "
    867               << std::dec << p_vci_tgt.srcid.read()
    868               << " / for address "
    869               << std::hex << p_vci_tgt.address.read()
    870               << std::endl;
    871         }
     913if(m_debug)
     914std::cout << "  <MEMC " << name()
     915          << " TGT_CMD_IDLE> Receive command from srcid "
     916          << std::hex << p_vci_tgt.srcid.read()
     917          << " / address " << std::hex << p_vci_tgt.address.read() << std::endl;
    872918#endif
    873919        // checking segmentation violation
    874         vci_addr_t  address = p_vci_tgt.address.read();
    875         uint32_t    plen    = p_vci_tgt.plen.read();
    876         bool found = false;
    877         for(size_t seg_id = 0 ; seg_id < m_nseg ; seg_id++)
    878         {
    879           if(m_seg[seg_id]->contains(address) &&
    880               m_seg[seg_id]->contains(address + plen - vci_param::B))
    881           {
    882             found = true;
    883           }
    884         }
    885         if(not found)
    886         {
    887           std::cout << "VCI_MEM_CACHE ERROR " << name() << std::endl;
    888           std::cout
    889               << "Out of segment VCI address in TGT_CMD_IDLE state (address = "
    890               << std::hex << address << ", srcid = " << p_vci_tgt.srcid.read()
    891               << std::dec << ", cycle = " << m_cpt_cycles << ")" << std::endl;
    892           exit(0);
    893         }
    894 
    895         if(p_vci_tgt.cmd.read() == vci_param::CMD_READ)
    896         {
    897           // check that the pktid is either :
    898           // TYPE_READ_DATA_UNC
    899           // TYPE_READ_DATA_MISS
    900           // TYPE_READ_INS_UNC
    901           // TYPE_READ_INS_MISS
    902           // ==> bit2 must be zero with the TSAR encoding
    903           // ==> mask = 0b0100 = 0x4
    904           assert(((p_vci_tgt.pktid.read() & 0x4) == 0x0) &&
    905                  "The type specified in the pktid field is incompatible with the READ CMD");
    906           r_tgt_cmd_fsm = TGT_CMD_READ;
    907         }
    908         else if(p_vci_tgt.cmd.read() == vci_param::CMD_WRITE)
    909         {
    910           // check that the pktid is TYPE_WRITE
    911           // ==> TYPE_WRITE = X100 with the TSAR encoding
    912           // ==> mask = 0b0111 = 0x7
    913           assert(((p_vci_tgt.pktid.read() & 0x7) == 0x4) &&
    914                  "The type specified in the pktid field is incompatible with the WRITE CMD");
    915           r_tgt_cmd_fsm = TGT_CMD_WRITE;
    916         }
    917         else if(p_vci_tgt.cmd.read() == vci_param::CMD_LOCKED_READ)
    918         {
    919           // check that the pktid is TYPE_LL
    920           // ==> TYPE_LL = X110 with the TSAR encoding
    921           // ==> mask = 0b0111 = 0x7
    922           assert(((p_vci_tgt.pktid.read() & 0x7) == 0x6) &&
    923                  "The type specified in the pktid field is incompatible with the LL CMD");
    924           r_tgt_cmd_fsm = TGT_CMD_READ;
    925         }
    926         else if(p_vci_tgt.cmd.read() == vci_param::CMD_NOP)
    927         {
    928           // check that the pktid is either :
    929           // TYPE_CAS
    930           // TYPE_SC
    931           // ==> TYPE_CAS = X101 with the TSAR encoding
    932           // ==> TYPE_SC  = X111 with the TSAR encoding
    933           // ==> mask = 0b0101 = 0x5
    934           assert(((p_vci_tgt.pktid.read() & 0x5) == 0x5) &&
    935                  "The type specified in the pktid field is incompatible with the NOP CMD");
    936 
    937           if((p_vci_tgt.pktid.read() & 0x7) == TYPE_CAS)
    938             r_tgt_cmd_fsm = TGT_CMD_CAS;
    939           else // TYPE_SC
    940             r_tgt_cmd_fsm = TGT_CMD_WRITE;
     920        addr_t      address  = p_vci_tgt.address.read();
     921        uint32_t    plen     = p_vci_tgt.plen.read();
     922        bool        found    = false;
     923        bool        config   = false;
     924
     925        // register arguments for response (segmentation violation or config)
     926        r_tgt_cmd_to_tgt_rsp_srcid = p_vci_tgt.srcid.read();
     927        r_tgt_cmd_to_tgt_rsp_trdid = p_vci_tgt.trdid.read();
     928        r_tgt_cmd_to_tgt_rsp_pktid = p_vci_tgt.pktid.read();
     929
     930        for(size_t seg_id = 0 ; (seg_id < m_nseg) and not found ; seg_id++)
     931        {
     932            if( m_seg[seg_id]->contains(address) and
     933                m_seg[seg_id]->contains(address + plen - vci_param_int::B) )
     934            {
     935                found = true;
     936                if ( m_seg[seg_id]->special() ) config = true;
     937            }
     938        }
     939
     940        if ( not found )                /////////// out of segment error
     941        {
     942            r_tgt_cmd_fsm   = TGT_CMD_ERROR;
     943        }
     944        else if ( config )              /////////// configuration command
     945        {
     946            if ( not p_vci_tgt.eop.read() ) r_tgt_cmd_fsm = TGT_CMD_ERROR;
     947            else                            r_tgt_cmd_fsm = TGT_CMD_CONFIG;
     948        }
     949        else                            //////////// memory access
     950        {
     951            if ( p_vci_tgt.cmd.read() == vci_param_int::CMD_READ )
     952            {
     953                // check that the pktid is either :
     954                // TYPE_READ_DATA_UNC
     955                // TYPE_READ_DATA_MISS
     956                // TYPE_READ_INS_UNC
     957                // TYPE_READ_INS_MISS
     958                // ==> bit2 must be zero with the TSAR encoding
     959                // ==> mask = 0b0100 = 0x4
     960                assert( ((p_vci_tgt.pktid.read() & 0x4) == 0x0) and
     961                "The type specified in the pktid field is incompatible with the READ CMD");
     962                r_tgt_cmd_fsm = TGT_CMD_READ;
     963            }
     964            else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)
     965            {
     966                // check that the pktid is TYPE_WRITE
     967                // ==> TYPE_WRITE = X100 with the TSAR encoding
     968                // ==> mask = 0b0111 = 0x7
     969                assert(((p_vci_tgt.pktid.read() & 0x7) == 0x4) and
     970                "The type specified in the pktid field is incompatible with the WRITE CMD");
     971                r_tgt_cmd_fsm = TGT_CMD_WRITE;
     972            }
     973            else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ)
     974            {
     975                // check that the pktid is TYPE_LL
     976                // ==> TYPE_LL = X110 with the TSAR encoding
     977                // ==> mask = 0b0111 = 0x7
     978                assert(((p_vci_tgt.pktid.read() & 0x7) == 0x6) and
     979                "The type specified in the pktid field is incompatible with the LL CMD");
     980                r_tgt_cmd_fsm = TGT_CMD_READ;
     981            }
     982            else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_NOP)
     983            {
     984                // check that the pktid is either :
     985                // TYPE_CAS
     986                // TYPE_SC
     987                // ==> TYPE_CAS = X101 with the TSAR encoding
     988                // ==> TYPE_SC  = X111 with the TSAR encoding
     989                // ==> mask = 0b0101 = 0x5
     990                assert(((p_vci_tgt.pktid.read() & 0x5) == 0x5) and
     991                "The type specified in the pktid field is incompatible with the NOP CMD");
     992
     993                if((p_vci_tgt.pktid.read() & 0x7) == TYPE_CAS) r_tgt_cmd_fsm = TGT_CMD_CAS;
     994                else                                           r_tgt_cmd_fsm = TGT_CMD_WRITE;
     995            }
     996            else
     997            {
     998                r_tgt_cmd_fsm = TGT_CMD_ERROR;
     999            }
     1000        }
     1001    }
     1002    break;
     1003
     1004    ///////////////////
     1005    case TGT_CMD_ERROR:  // response error must be sent
     1006
     1007    // wait if pending TGT_CMD request to TGT_RSP FSM
     1008    if(r_tgt_cmd_to_tgt_rsp_req.read()) break;
     1009
     1010    // consume all the command packet flits before sending response error
     1011    if ( p_vci_tgt.cmdval and p_vci_tgt.eop )
     1012    {
     1013        r_tgt_cmd_to_tgt_rsp_req   = true;
     1014        r_tgt_cmd_to_tgt_rsp_error = 1;
     1015        r_tgt_cmd_fsm              = TGT_CMD_IDLE;
     1016
     1017#if DEBUG_MEMC_TGT_CMD
     1018if(m_debug)
     1019  std::cout << "  <MEMC " << name()
     1020    << " TGT_CMD_ERROR> Segmentation violation:"
     1021    << " address = " << std::hex << p_vci_tgt.address.read()
     1022    << " / srcid = " << p_vci_tgt.srcid.read()
     1023    << " / trdid = " << p_vci_tgt.trdid.read()
     1024    << " / pktid = " << p_vci_tgt.pktid.read()
     1025    << " / plen = " << std::dec << p_vci_tgt.plen.read() << std::endl;
     1026#endif
     1027
     1028    }
     1029    break;
     1030
     1031    ////////////////////
     1032    case TGT_CMD_CONFIG:    // execute config request and return response
     1033    {
     1034        addr_t   seg_base = m_seg[m_seg_config]->baseAddress();
     1035        addr_t   address  = p_vci_tgt.address.read();
     1036        size_t   cell     = (address - seg_base)/vci_param_int::B;
     1037     
     1038        bool     need_rsp;
     1039        size_t   error; 
     1040        uint32_t rdata = 0;         // default value
     1041
     1042        if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_READ)         // get lock
     1043             and (cell == MEMC_LOCK) )
     1044        {
     1045            rdata            = (uint32_t)r_config_lock.read();
     1046            need_rsp         = true;
     1047            error            = 0;
     1048            r_config_lock    = true;
     1049        }
     1050        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)  // release lock
     1051                   and (cell == MEMC_LOCK) )
     1052        {
     1053            need_rsp         = true;
     1054            error            = 0;
     1055            r_config_lock    = false;
     1056        }
     1057        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_lo
     1058                   and (cell == MEMC_ADDR_LO) )
     1059        {
     1060            need_rsp         = true;
     1061            error            = 0;
     1062            r_config_address = (r_config_address.read() & 0xFFFFFFFF00000000LL) |
     1063                               (addr_t)p_vci_tgt.wdata.read();
     1064        }
     1065        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_hi
     1066                   and (cell == MEMC_ADDR_HI) )
     1067        {
     1068            need_rsp         = true;
     1069            error            = 0;
     1070            r_config_address = (r_config_address.read() & 0x00000000FFFFFFFFLL) |
     1071                               ((addr_t)p_vci_tgt.wdata.read())<<32;
     1072        }
     1073        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set buf_lines
     1074                   and (cell == MEMC_BUF_LENGTH) )
     1075        {
     1076            need_rsp         = true;
     1077            error            = 0;
     1078            size_t lines = (size_t)(p_vci_tgt.wdata.read()/(m_words<<2));
     1079            if ( r_config_address.read()/(m_words*vci_param_int::B) ) lines++;
     1080            r_config_nlines  = lines;
     1081        }
     1082        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set cmd type
     1083                   and (cell == MEMC_CMD_TYPE) )
     1084        {
     1085            need_rsp         = false;
     1086            error            = 0;
     1087            r_config_cmd     = p_vci_tgt.wdata.read();
     1088            r_config_srcid   = p_vci_tgt.srcid.read();
     1089            r_config_trdid   = p_vci_tgt.trdid.read();
     1090            r_config_pktid   = p_vci_tgt.pktid.read();
    9411091        }
    9421092        else
    9431093        {
    944           std::cout << "VCI_MEM_CACHE ERROR " << name()
    945                     << " TGT_CMD_IDLE state" << std::endl;
    946           std::cout << " illegal VCI command type" << std::endl;
    947           exit(0);
    948         }
    949       }
    950       break;
    951 
    952       //////////////////
    953     case TGT_CMD_READ:
    954       // This test checks that the read does not cross a cache line limit.
    955       // It must not be taken into account when dealing with an LL CMD.
    956       if(((m_x[(vci_addr_t) p_vci_tgt.address.read()]+ (p_vci_tgt.plen.read() >>2)) > 16) && (p_vci_tgt.cmd.read() != vci_param::CMD_LOCKED_READ))
    957       {
    958         std::cout
    959             << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
    960             << std::endl;
    961         std::cout
    962             << " illegal address/plen combination for VCI read command" << std::endl;
     1094            need_rsp         = true;
     1095            error            = 1;
     1096        }
     1097
     1098        if ( need_rsp )
     1099        {
     1100            // blocked if previous pending request to TGT_RSP FSM
     1101            if ( r_tgt_cmd_to_tgt_rsp_req.read() ) break;
     1102
     1103            r_tgt_cmd_to_tgt_rsp_req   = true;
     1104            r_tgt_cmd_to_tgt_rsp_error = error;
     1105            r_tgt_cmd_to_tgt_rsp_rdata = rdata;
     1106            r_tgt_cmd_fsm              = TGT_CMD_IDLE;
     1107        }
     1108        else
     1109        {
     1110            r_tgt_cmd_fsm              = TGT_CMD_IDLE;
     1111        }
     1112
     1113#if DEBUG_MEMC_TGT_CMD
     1114if(m_debug)
     1115std::cout << "  <MEMC " << name() << " TGT_CMD_CONFIG> Configuration request:"
     1116          << " address = " << std::hex << p_vci_tgt.address.read()
     1117          << " / wdata = " << p_vci_tgt.wdata.read()
     1118          << " / error = " << error << std::endl;
     1119#endif
     1120        break;
     1121    }
     1122    //////////////////
     1123    case TGT_CMD_READ:    // Push a read request into read fifo
     1124
     1125    // check that the read does not cross a cache line limit.
     1126    if ( ((m_x[(addr_t) p_vci_tgt.address.read()]+ (p_vci_tgt.plen.read() >>2)) > 16) and
     1127          (p_vci_tgt.cmd.read() != vci_param_int::CMD_LOCKED_READ))
     1128    {
     1129        std::cout << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
     1130                  << " illegal address/plen for VCI read command" << std::endl;
    9631131        exit(0);
    964       }
    965       if(!p_vci_tgt.eop.read())
    966       {
    967         std::cout
    968             << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
    969             << std::endl;
    970         std::cout
    971             << " read or ll command packets must contain one single flit"
    972             << std::endl;
     1132    }
     1133    // check single flit
     1134    if(!p_vci_tgt.eop.read())
     1135    {
     1136        std::cout << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
     1137                  << " read command packet must contain one single flit" << std::endl;
    9731138        exit(0);
    974       }
    975       if((p_vci_tgt.cmd.read() == vci_param::CMD_LOCKED_READ) && (p_vci_tgt.plen.read() != 8))
    976       {
    977         std::cout
    978             << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
    979             << std::endl;
    980         std::cout
    981             << " ll command packets must have a plen of 8"
    982             << std::endl;
     1139    }
     1140    // check plen for LL
     1141    if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ) and
     1142         (p_vci_tgt.plen.read() != 8) )
     1143    {
     1144        std::cout << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
     1145                  << " ll command packets must have a plen of 8" << std::endl;
    9831146        exit(0);
    984       }
    985 
    986       if(p_vci_tgt.cmdval && m_cmd_read_addr_fifo.wok())
    987       {
     1147    }
     1148
     1149    if ( p_vci_tgt.cmdval and m_cmd_read_addr_fifo.wok() )
     1150    {
    9881151
    9891152#if DEBUG_MEMC_TGT_CMD
    990         if(m_debug_tgt_cmd_fsm)
    991         {
    992           std::cout << "  <MEMC " << name() << ".TGT_CMD_READ> Push into read_fifo:"
    993                     << " address = " << std::hex << p_vci_tgt.address.read()
    994                     << " srcid = " << std::dec << p_vci_tgt.srcid.read()
    995                     << " trdid = " << p_vci_tgt.trdid.read()
    996                     << " pktid = " << p_vci_tgt.pktid.read()
    997                     << " plen = " << std::dec << p_vci_tgt.plen.read() << std::endl;
    998         }
     1153if(m_debug)
     1154std::cout << "  <MEMC " << name() << " TGT_CMD_READ> Push into read_fifo:"
     1155          << " address = " << std::hex << p_vci_tgt.address.read()
     1156          << " / srcid = " << p_vci_tgt.srcid.read()
     1157          << " / trdid = " << p_vci_tgt.trdid.read()
     1158          << " / pktid = " << p_vci_tgt.pktid.read()
     1159          << " / plen = " << std::dec << p_vci_tgt.plen.read() << std::endl;
    9991160#endif
    10001161        cmd_read_fifo_put = true;
    1001         if(p_vci_tgt.cmd.read() == vci_param::CMD_LOCKED_READ)
    1002           m_cpt_ll++;
    1003         else
    1004           m_cpt_read++;
     1162        if(p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ) m_cpt_ll++;
     1163        else                                                       m_cpt_read++;
    10051164        r_tgt_cmd_fsm = TGT_CMD_IDLE;
    1006       }
    1007       break;
    1008 
    1009       ///////////////////
     1165    }
     1166    break;
     1167
     1168    ///////////////////
    10101169    case TGT_CMD_WRITE:
    1011       if(p_vci_tgt.cmdval && m_cmd_write_addr_fifo.wok())
    1012       {
     1170    if(p_vci_tgt.cmdval and m_cmd_write_addr_fifo.wok())
     1171    {
    10131172
    10141173#if DEBUG_MEMC_TGT_CMD
    1015         if(m_debug_tgt_cmd_fsm)
    1016         {
    1017           std::cout << "  <MEMC " << name() << ".TGT_CMD_WRITE> Push into write_fifo:"
    1018                     << " address = " << std::hex << p_vci_tgt.address.read()
    1019                     << " srcid = " << std::dec << p_vci_tgt.srcid.read()
    1020                     << " trdid = " << p_vci_tgt.trdid.read()
    1021                     << " pktid = " << p_vci_tgt.pktid.read()
    1022                     << " wdata = " << std::hex << p_vci_tgt.wdata.read()
    1023                     << " be = " << p_vci_tgt.be.read()
    1024                     << " plen = " << std::dec << p_vci_tgt.plen.read() << std::endl;
    1025         }
     1174if(m_debug)
     1175std::cout << "  <MEMC " << name() << " TGT_CMD_WRITE> Push into write_fifo:"
     1176          << " address = " << std::hex << p_vci_tgt.address.read()
     1177          << " / srcid = " << p_vci_tgt.srcid.read()
     1178          << " / trdid = " << p_vci_tgt.trdid.read()
     1179          << " / pktid = " << p_vci_tgt.pktid.read()
     1180          << " / wdata = " << p_vci_tgt.wdata.read()
     1181          << " / be = " << p_vci_tgt.be.read()
     1182          << " / plen = " << std::dec << p_vci_tgt.plen.read() << std::endl;
    10261183#endif
    10271184        cmd_write_fifo_put = true;
    10281185        if(p_vci_tgt.eop)  r_tgt_cmd_fsm = TGT_CMD_IDLE;
    1029       }
    1030       break;
    1031 
    1032       ////////////////////
     1186    }
     1187    break;
     1188
     1189    /////////////////
    10331190    case TGT_CMD_CAS:
    1034       if((p_vci_tgt.plen.read() != 8) && (p_vci_tgt.plen.read() != 16))
    1035       {
    1036         std::cout
    1037             << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_CAS state"
    1038             << std::endl
    1039             << "illegal format for CAS command " << std::endl;
    1040 
     1191    if((p_vci_tgt.plen.read() != 8) and (p_vci_tgt.plen.read() != 16))
     1192    {
     1193        std::cout << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_CAS state"
     1194                  << "illegal format for CAS command " << std::endl;
    10411195        exit(0);
    1042       }
    1043 
    1044       if(p_vci_tgt.cmdval && m_cmd_cas_addr_fifo.wok())
    1045       {
     1196    }
     1197
     1198    if(p_vci_tgt.cmdval and m_cmd_cas_addr_fifo.wok())
     1199    {
    10461200
    10471201#if DEBUG_MEMC_TGT_CMD
    1048         if(m_debug_tgt_cmd_fsm)
    1049         {
    1050           std::cout << "  <MEMC " << name() << ".TGT_CMD_CAS> Pushing command into cmd_cas_fifo:"
    1051                     << " address = " << std::hex << p_vci_tgt.address.read()
    1052                     << " srcid = " << std::dec << p_vci_tgt.srcid.read()
    1053                     << " trdid = " << p_vci_tgt.trdid.read()
    1054                     << " pktid = " << p_vci_tgt.pktid.read()
    1055                     << " wdata = " << std::hex << p_vci_tgt.wdata.read()
    1056                     << " be = " << p_vci_tgt.be.read()
    1057                     << " plen = " << std::dec << p_vci_tgt.plen.read() << std::endl;
    1058         }
     1202if(m_debug)
     1203std::cout << "  <MEMC " << name() << " TGT_CMD_CAS> Pushing command into cmd_cas_fifo:"
     1204          << " address = " << std::hex << p_vci_tgt.address.read()
     1205          << " srcid = " << p_vci_tgt.srcid.read()
     1206          << " trdid = " << p_vci_tgt.trdid.read()
     1207          << " pktid = " << p_vci_tgt.pktid.read()
     1208          << " wdata = " << p_vci_tgt.wdata.read()
     1209          << " be = " << p_vci_tgt.be.read()
     1210          << " plen = " << std::dec << p_vci_tgt.plen.read() << std::endl;
    10591211#endif
    10601212        cmd_cas_fifo_put = true;
    10611213        if(p_vci_tgt.eop) r_tgt_cmd_fsm = TGT_CMD_IDLE;
    1062       }
    1063       break;
     1214    }
     1215    break;
    10641216  } // end switch tgt_cmd_fsm
    10651217
     
    10711223  // update the UPT.
    10721224  //
    1073   // It can be update or inval requests initiated by the WRITE or CAS FSM,
    1074   // or inval requests initiated by the XRAM_RSP FSM.
    1075   // It can also be a direct request from the WRITE FSM.
     1225  // - The FSM decrements the proper entry in UPT,
     1226  //   and clear the UPT entry when all responses have been received.
     1227  // - If required, it sends a request to the TGT_RSP FSM to complete
     1228  //   a pending  write transaction.
     1229  // - If required, it sends an acknowledge to the CONFIG FSM to signal
     1230  //   completion of a line inval.
    10761231  //
    1077   // The FSM decrements the proper entry in UPT.
    1078   // It sends a request to the TGT_RSP FSM to complete the pending
    1079   // write transaction (acknowledge response to the writer processor),
    1080   // and clear the UPT entry when all responses have been received.
    1081   //
    1082   // All those response packets are one flit packet.
    1083   // The index in the Table is defined in the UPDT_TABLE INDEX field, and
    1084   // the transaction type is defined in the UPT entry.
     1232  // All those multi-ack packets are one flit packet.
     1233  // The index in the UPT is defined in the UPDTID field.
    10851234  ////////////////////////////////////////////////////////////////////////
    10861235
    10871236  switch(r_multi_ack_fsm.read())
    10881237  {
     1238    ////////////////////
    10891239    case MULTI_ACK_IDLE:
    1090       {
     1240    {
    10911241        bool multi_ack_fifo_rok = m_cc_receive_to_multi_ack_fifo.rok();
    10921242
    1093         // None Multicast Acknowledgement received and
    1094         // none WRITE FSM UPT decrement request
    1095         if( not multi_ack_fifo_rok and
    1096             not r_write_to_multi_ack_req.read())
    1097         {
     1243        // No CC_RECEIVE FSM request and no WRITE FSM request
     1244        if( not multi_ack_fifo_rok and not r_write_to_multi_ack_req.read())
    10981245          break;
    1099         }
    1100 
    1101         // WRITE FSM request to decrement update table response counter
    1102         // Priority to Multicast Acknowledgement priority
     1246
     1247        uint8_t updt_index;
     1248
     1249        // handling WRITE FSM request to decrement update table response
     1250        // counter if no CC_RECEIVE FSM request
    11031251        if(not multi_ack_fifo_rok)
    11041252        {
     1253          updt_index               = r_write_to_multi_ack_upt_index.read();
    11051254          r_write_to_multi_ack_req = false;
    1106           r_multi_ack_upt_index    = r_write_to_multi_ack_upt_index.read();
    1107           r_multi_ack_fsm          = MULTI_ACK_UPT_LOCK;
    1108 
    1109           break;
    1110         }
    1111 
    1112         // Multicast Acknowledgement received
    1113         uint64_t flit = m_cc_receive_to_multi_ack_fifo.read();
    1114 
    1115         uint8_t updt_index =
    1116           DspinDhccpParam::dspin_get(flit, DspinDhccpParam::MULTI_ACK_UPDT_INDEX);
    1117 
    1118         bool eop =
    1119           (DspinDhccpParam::dspin_get(flit, DspinDhccpParam::FROM_L1_EOP) == 0x1);
    1120 
    1121         if(updt_index >= m_upt.size())
    1122         {
    1123           std::cout
    1124             << "VCI_MEM_CACHE ERROR " << name()
    1125             << " MULTI_ACK_IDLE state" << std::endl
    1126             << "index too large for UPT: "
    1127             << std::dec
    1128             << " / UPT index = " << updt_index
    1129             << " / UPT size = "  << m_upt.size()
    1130             << std::endl;
    1131 
    1132           exit(0);
    1133         }
    1134 
    1135         if(not eop)
    1136         {
    1137           std::cout
    1138             << "VCI_MEM_CACHE ERROR " << name()
    1139             << " MULTI_ACK_IDLE state" << std::endl
    1140             << "A Multicast Acknowledgement must be an one flit packet"
    1141             << std::endl;
    1142 
    1143           exit(0);
    1144         }
    1145 
    1146         cc_receive_to_multi_ack_fifo_get = true;
    1147         r_multi_ack_upt_index           = updt_index;
    1148         r_multi_ack_fsm                 = MULTI_ACK_UPT_LOCK;
     1255        }
     1256        // Handling CC_RECEIVE FSM request
     1257        else
     1258        {
     1259          uint64_t flit = m_cc_receive_to_multi_ack_fifo.read();
     1260          updt_index    = DspinDhccpParam::dspin_get(flit,
     1261                            DspinDhccpParam::MULTI_ACK_UPDT_INDEX);
     1262
     1263          cc_receive_to_multi_ack_fifo_get = true;
     1264        }
     1265
     1266        assert((updt_index < m_upt.size()) and
     1267               "VCI_MEM_CACHE ERROR in MULTI_ACK_IDLE : "
     1268               "index too large for UPT");
     1269
     1270        r_multi_ack_upt_index = updt_index;
     1271        r_multi_ack_fsm       = MULTI_ACK_UPT_LOCK;
    11491272
    11501273#if DEBUG_MEMC_MULTI_ACK
    1151         if(m_debug_multi_ack_fsm)
    1152         {
    1153           std::cout
    1154             <<  "  <MEMC " << name()
    1155             << ".MULTI_ACK_IDLE> Response for UPT entry "
    1156             << updt_index
    1157             << std::endl;
    1158         }
     1274if(m_debug)
     1275{
     1276    if (multi_ack_fifo_rok)
     1277    {
     1278        std::cout << "  <MEMC " << name()
     1279                  << " MULTI_ACK_IDLE> Response for UPT entry "
     1280                  << (size_t)updt_index << std::endl;
     1281    }
     1282    else
     1283    {
     1284        std::cout << "  <MEMC " << name()
     1285                  << " MULTI_ACK_IDLE> Write FSM request to decrement UPT entry "
     1286                  << updt_index << std::endl;
     1287    }
     1288}
    11591289#endif
    11601290        break;
    11611291      }
    11621292
     1293    ////////////////////////
    11631294    case MULTI_ACK_UPT_LOCK:
    1164       {
     1295    {
    11651296        // get lock to the UPDATE table
    11661297        if(r_alloc_upt_fsm.read() != ALLOC_UPT_MULTI_ACK) break;
     
    11721303        if(not valid)
    11731304        {
    1174           std::cout
    1175             << "VCI_MEM_CACHE ERROR " << name()
    1176             << " MULTI_ACK_UPT_LOCK state" << std::endl
    1177             << "unsuccessful access to decrement the UPT"
    1178             << std::endl;
    1179 
    1180           exit(0);
     1305            std::cout << "VCI_MEM_CACHE ERROR " << name()
     1306                      << " MULTI_ACK_UPT_LOCK state" << std::endl
     1307                      << "unsuccessful access to decrement the UPT" << std::endl;
     1308            exit(0);
    11811309        }
    11821310
     
    11911319
    11921320#if DEBUG_MEMC_MULTI_ACK
    1193         if(m_debug_multi_ack_fsm)
    1194         {
    1195           std::cout
    1196             << "  <MEMC " << name()
    1197             << ".MULTI_ACK_UPT_LOCK> Decrement the responses counter for UPT:"
    1198             << " entry = "       << r_multi_ack_upt_index.read()
    1199             << " / rsp_count = " << std::dec << count
    1200             << std::endl;
    1201         }
     1321if(m_debug)
     1322std::cout << "  <MEMC " << name()
     1323          << " MULTI_ACK_UPT_LOCK> Decrement the responses counter for UPT:"
     1324          << " entry = "       << r_multi_ack_upt_index.read()
     1325          << " / rsp_count = " << std::dec << count << std::endl;
    12021326#endif
    12031327        break;
    1204       }
    1205 
    1206     case MULTI_ACK_UPT_CLEAR:
    1207       {
     1328    }
     1329
     1330    /////////////////////////
     1331    case MULTI_ACK_UPT_CLEAR:   // Clear UPT entry / Test if rsp or ack required
     1332    {
    12081333        if(r_alloc_upt_fsm.read() != ALLOC_UPT_MULTI_ACK)
    12091334        {
    1210           std::cout
    1211             << "VCI_MEM_CACHE ERROR " << name()
    1212             << " MULTI_ACK_UPT_CLEAR state"
    1213             << " bad UPT allocation"
    1214             << std::endl;
    1215 
    1216           exit(0);
     1335            std::cout << "VCI_MEM_CACHE ERROR " << name()
     1336                      << " MULTI_ACK_UPT_CLEAR state"
     1337                      << " bad UPT allocation" << std::endl;
     1338            exit(0);
    12171339        }
    12181340
     
    12221344        r_multi_ack_nline = m_upt.nline(r_multi_ack_upt_index.read());
    12231345        bool need_rsp     = m_upt.need_rsp(r_multi_ack_upt_index.read());
     1346        bool need_ack     = m_upt.need_ack(r_multi_ack_upt_index.read());
    12241347
    12251348        // clear the UPT entry
    12261349        m_upt.clear(r_multi_ack_upt_index.read());
    12271350
    1228         if(need_rsp)
    1229         {
    1230           r_multi_ack_fsm = MULTI_ACK_WRITE_RSP;
    1231         }
    1232         else
    1233         {
    1234           r_multi_ack_fsm = MULTI_ACK_IDLE;
    1235         }
     1351        if      ( need_rsp ) r_multi_ack_fsm = MULTI_ACK_WRITE_RSP;
     1352        else if ( need_ack ) r_multi_ack_fsm = MULTI_ACK_CONFIG_ACK;
     1353        else                 r_multi_ack_fsm = MULTI_ACK_IDLE;
    12361354
    12371355#if DEBUG_MEMC_MULTI_ACK
    1238         if(m_debug_multi_ack_fsm)
    1239         {
    1240           std::cout
    1241             <<  "  <MEMC " << name()
    1242             << ".MULTI_ACK_UPT_CLEAR> Clear UPT entry "
    1243             << r_multi_ack_upt_index.read()
    1244             << std::endl;
    1245         }
     1356if(m_debug)
     1357std::cout <<  "  <MEMC " << name()
     1358          << " MULTI_ACK_UPT_CLEAR> Clear UPT entry "
     1359          << std::dec << r_multi_ack_upt_index.read() << std::endl;
    12461360#endif
    12471361        break;
    1248       }
    1249 
    1250     case MULTI_ACK_WRITE_RSP:
    1251       {
    1252         // Post a request to TGT_RSP FSM
    1253         // Wait if pending request to the TGT_RSP FSM
    1254         if(r_multi_ack_to_tgt_rsp_req.read()) break;
     1362    }
     1363    /////////////////////////
     1364    case MULTI_ACK_WRITE_RSP:     // Post a response request to TGT_RSP FSM
     1365                                  // Wait if pending request
     1366    {
     1367        if ( r_multi_ack_to_tgt_rsp_req.read() ) break;
    12551368
    12561369        r_multi_ack_to_tgt_rsp_req   = true;
     
    12611374
    12621375#if DEBUG_MEMC_MULTI_ACK
    1263         if(m_debug_multi_ack_fsm)
    1264         {
    1265           std::cout
    1266             << "  <MEMC " << name()
    1267             << ".MULTI_ACK_WRITE_RSP> Request TGT_RSP FSM to send a response to srcid "
    1268             << r_multi_ack_srcid.read()
    1269             << std::endl;
    1270         }
     1376if(m_debug)
     1377std::cout << "  <MEMC " << name() << " MULTI_ACK_WRITE_RSP>"
     1378          << " Request TGT_RSP FSM to send a response to srcid "
     1379          << std::hex << r_multi_ack_srcid.read() << std::endl;
    12711380#endif
    12721381        break;
    1273       }
     1382    }
     1383    //////////////////////////
     1384    case MULTI_ACK_CONFIG_ACK:    // Signals multi-inval completion to CONFIG FSM
     1385                                  // Wait if pending request
     1386    {
     1387        if ( r_multi_ack_to_config_ack.read() ) break;
     1388
     1389        r_multi_ack_to_config_ack   = true;
     1390        r_multi_ack_fsm              = MULTI_ACK_IDLE;
     1391
     1392#if DEBUG_MEMC_MULTI_ACK
     1393if(m_debug)
     1394std::cout << "  <MEMC " << name() << " MULTI_ACK_CONFIG_ACK>"
     1395          << " Signals inval completion to CONFIG FSM" << std::endl;
     1396#endif
     1397        break;
     1398    }
    12741399  } // end switch r_multi_ack_fsm
     1400
     1401  ////////////////////////////////////////////////////////////////////////////////////
     1402  //    CONFIG FSM
     1403  ////////////////////////////////////////////////////////////////////////////////////
     1404  // The CONFIG FSM handles the VCI configuration requests (INVAL & SYNC).
     1405  // The target buffer can have any size, and there is one single command for
     1406  // all cache lines covered by the target buffer.
     1407  // An INVAL or SYNC configuration request is defined by the followinf registers:
     1408  // - bool      r_config_cmd        : INVAL / SYNC / NOP)
     1409  // - uint64_t  r_config_address    : buffer base address
     1410  // - uint32_t  r_config_nlines     : number of lines covering buffer
     1411  //
     1412  // For both INVAL and SYNC commands, the CONFIG FSM contains the loop handling
     1413  // all cache lines covered by the target buffer.
     1414  //
     1415  // - INVAL request:
     1416  //   For each line, it access to the DIR array.
     1417  //   In case of miss, it does nothing, and a response is requested to TGT_RSP FSM.
     1418  //   In case of hit, with no copies in L1 caches, the line is invalidated and
     1419  //   a response is requested to TGT_RSP FSM.
     1420  //   If there is copies, a multi-inval, or a broadcast-inval coherence transaction
     1421  //   is launched and registered in UPT. The multi-inval transaction is signaled
     1422  //   by the r_multi_ack_to config_ack or r_cleanup_to_config_ack flip-flops.
     1423  //   The config inval response is sent only when the last line has been invalidated.
     1424  //
     1425  // - SYNC request:
     1426  //
     1427  //  ...  Not implemented yet ...
     1428  //
     1429  // From the software point of view, a configuration request is a sequence
     1430  // of 6 atomic accesses:
     1431  // - Read  MEMC_LOCK       : Get the lock
     1432  // - Write MEMC_ADDR_LO    : Set the buffer address LSB
     1433  // - Write MEMC_ADDR_HI    : Set the buffer address MSB
     1434  // - Write MEMC_BUF_LENGTH : set buffer length (bytes)
     1435  // - Write MEMC_CMD_TYPE   : launch the actual operation
     1436  // - WRITE MEMC_LOCK       : release the lock
     1437  ////////////////////////////////////////////////////////////////////////////////////
     1438
     1439  switch( r_config_fsm.read() )
     1440  {
     1441      /////////////////
     1442      case CONFIG_IDLE:  // waiting a config request
     1443      {
     1444          if ( r_config_cmd.read() != MEMC_CMD_NOP ) 
     1445          {
     1446              r_config_fsm    = CONFIG_LOOP;
     1447
     1448#if DEBUG_MEMC_CONFIG
     1449if(m_debug)
     1450std::cout << "  <MEMC " << name() << " CONFIG_IDLE> Config Request received"
     1451          << " address = " << std::hex << r_config_address.read()
     1452          << " / nlines = " << std::dec << r_config_nlines.read()
     1453          << " / type = " << r_config_cmd.read() << std::endl;
     1454#endif
     1455          }
     1456          break;
     1457      }
     1458      /////////////////
     1459      case CONFIG_LOOP:   // test last line
     1460      {
     1461          if ( r_config_nlines.read() == 0 )
     1462          {
     1463              r_config_cmd = MEMC_CMD_NOP;
     1464              r_config_fsm = CONFIG_RSP;
     1465          }
     1466          else
     1467          {
     1468              r_config_fsm = CONFIG_DIR_REQ;
     1469          }
     1470
     1471#if DEBUG_MEMC_CONFIG
     1472if(m_debug)
     1473std::cout << "  <MEMC " << name() << " CONFIG_LOOP>"
     1474          << " address = " << std::hex << r_config_address.read()   
     1475          << " / nlines = " << std::dec << r_config_nlines.read()
     1476          << " / command = " << r_config_cmd.read() << std::endl;
     1477#endif
     1478          break;
     1479      }
     1480      ////////////////////
     1481      case CONFIG_DIR_REQ:  // Request directory lock
     1482      {
     1483          if ( r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG )
     1484          {
     1485              r_config_fsm = CONFIG_DIR_ACCESS;
     1486          }
     1487
     1488#if DEBUG_MEMC_CONFIG
     1489if(m_debug)
     1490std::cout << "  <MEMC " << name() << " CONFIG_DIR_REQ>"
     1491          << " Request DIR access" << std::endl;
     1492#endif
     1493          break;
     1494      }
     1495      ///////////////////////
     1496      case CONFIG_DIR_ACCESS:   // Access directory and decode config command
     1497      {
     1498          size_t way = 0;
     1499          DirectoryEntry entry = m_cache_directory.read(r_config_address.read(), way);
     1500
     1501          if ( entry.valid and                            // hit & inval command
     1502               (r_config_cmd.read() == MEMC_CMD_INVAL) )
     1503          {
     1504              r_config_dir_way        = way;
     1505              r_config_dir_copy_inst  = entry.owner.inst;
     1506              r_config_dir_copy_srcid = entry.owner.srcid;
     1507              r_config_dir_is_cnt     = entry.is_cnt;
     1508              r_config_dir_count      = entry.count;
     1509              r_config_dir_next_ptr   = entry.ptr;
     1510
     1511              r_config_fsm    = CONFIG_DIR_UPT_LOCK;
     1512          }
     1513          else if ( entry.valid and                       // hit & sync command
     1514                    entry.dirty and
     1515                    (r_config_cmd.read() == MEMC_CMD_SYNC) )
     1516          {
     1517              std::cout << "VCI_MEM_CACHE ERROR: "
     1518                        << "SYNC config request not implemented yet" << std::endl;
     1519              exit(0);
     1520          }
     1521          else                                            // return to LOOP
     1522          {
     1523              r_config_nlines  = r_config_nlines.read() - 1;
     1524              r_config_address = r_config_address.read() + (m_words<<2);
     1525              r_config_fsm     = CONFIG_LOOP;
     1526          }
     1527
     1528#if DEBUG_MEMC_CONFIG
     1529if(m_debug)
     1530std::cout << "  <MEMC " << name() << " CONFIG_DIR_ACCESS> Accessing directory: "
     1531          << " address = " << std::hex << r_config_address.read()
     1532          << " / hit = " << std::dec << entry.valid
     1533          << " / dirty = " << entry.dirty
     1534          << " / count = " << entry.count
     1535          << " / is_cnt = " << entry.is_cnt << std::endl;
     1536#endif
     1537          break;
     1538      }
     1539      /////////////////////////
     1540      case CONFIG_DIR_UPT_LOCK:  // enter this state in case of INVAL command
     1541                                 // Try to get both DIR & UPT locks, and return
     1542                                 // to LOOP state if UPT full.
     1543                                 // Register inval in UPT, and invalidate the
     1544                                 // directory if UPT not full.
     1545      {
     1546          if ( r_alloc_upt_fsm.read() == ALLOC_UPT_CONFIG )
     1547          {
     1548              size_t set        = m_y[(addr_t)(r_config_address.read())];
     1549              size_t way        = r_config_dir_way.read();
     1550
     1551              if ( r_config_dir_count.read() == 0 )     // inval DIR and return to LOOP
     1552              {
     1553                  m_cache_directory.inval( way, set );
     1554                  r_config_nlines  = r_config_nlines.read() - 1;
     1555                  r_config_address = r_config_address.read() + (m_words<<2);
     1556                  r_config_fsm     = CONFIG_LOOP;
     1557
     1558#if DEBUG_MEMC_CONFIG
     1559if(m_debug)
     1560std::cout << "  <MEMC " << name() << " CONFIG_DIR_UPT_LOCK>"
     1561          << " No copies in L1 : inval DIR entry"  << std::endl;
     1562#endif
     1563              }
     1564              else    // try to register inval in UPT
     1565              {
     1566                  bool        wok       = false;
     1567                  size_t      index     = 0;
     1568                  bool        broadcast = r_config_dir_is_cnt.read();
     1569                  size_t      srcid     = r_config_srcid.read();
     1570                  size_t      trdid     = r_config_trdid.read();
     1571                  size_t      pktid     = r_config_pktid.read();
     1572                  addr_t      nline     = m_nline[(addr_t)(r_config_address.read())];
     1573                  size_t      nb_copies = r_config_dir_count.read();
     1574
     1575                  wok = m_upt.set(false,       // it's an inval transaction
     1576                                  broadcast,   
     1577                                  false,       // no response required
     1578                                  true,        // acknowledge required
     1579                                  srcid,
     1580                                  trdid,
     1581                                  pktid,
     1582                                  nline,
     1583                                  nb_copies,
     1584                                  index);
     1585                  if ( wok )  // UPT success => inval DIR slot
     1586                  {
     1587                      m_cache_directory.inval( way, set );
     1588                      r_config_upt_index = index;
     1589                      if ( broadcast )  r_config_fsm = CONFIG_BC_SEND;
     1590                      else              r_config_fsm = CONFIG_INV_SEND;
     1591
     1592#if DEBUG_MEMC_CONFIG
     1593if(m_debug)
     1594std::cout << "  <MEMC " << name() << " CONFIG_DIR_UPT_LOCK>"
     1595          << " Inval DIR entry and register inval in UPT"
     1596          << " : index = " << std::dec << index
     1597          << " / broadcast = " << broadcast << std::endl;
     1598#endif
     1599                  }
     1600                  else       // UPT full => release both DIR and UPT locks
     1601                  {
     1602                      r_config_fsm = CONFIG_LOOP;
     1603
     1604#if DEBUG_MEMC_CONFIG
     1605if(m_debug)
     1606std::cout << "  <MEMC " << name() << " CONFIG_DIR_UPT_LOCK>"
     1607          << " UPT full : release DIR & UPT locks and retry" << std::endl;
     1608#endif
     1609                  }
     1610              }
     1611          }
     1612          break;
     1613      }
     1614      ////////////////////
     1615      case CONFIG_BC_SEND:    // Post a broadcast inval request to CC_SEND FSM
     1616      {
     1617          if( not r_config_to_cc_send_multi_req.read() and
     1618              not r_config_to_cc_send_brdcast_req.read() )
     1619          {
     1620              r_config_to_cc_send_multi_req   = false;
     1621              r_config_to_cc_send_brdcast_req = true;
     1622              r_config_to_cc_send_trdid       = r_config_upt_index.read();
     1623              r_config_to_cc_send_nline       = m_nline[(addr_t)(r_config_address.read())];
     1624              r_cleanup_to_config_ack         = false;
     1625              r_config_fsm                    = CONFIG_BC_WAIT;
     1626
     1627#if DEBUG_MEMC_CONFIG
     1628if(m_debug)
     1629std::cout << "  <MEMC " << name() << " CONFIG_BC_SEND>"
     1630          << " Post a broadcast inval request to CC_SEND FSM"
     1631          << " / address = " << r_config_address.read() <<std::endl;
     1632#endif
     1633          }
     1634          break;
     1635      }
     1636      ////////////////////
     1637      case CONFIG_BC_WAIT:      // wait broadcast completion to return to LOOP
     1638      {
     1639          if ( r_cleanup_to_config_ack.read() )
     1640          {
     1641              r_config_fsm     = CONFIG_LOOP;
     1642              r_config_nlines  = r_config_nlines.read() - 1;
     1643              r_config_address = r_config_address.read() + (m_words<<2);
     1644          }
     1645
     1646#if DEBUG_MEMC_CONFIG
     1647if(m_debug)
     1648std::cout << "  <MEMC " << name() << " CONFIG_BC_WAIT> Waiting BC completion "
     1649          << " done = " << r_cleanup_to_config_ack.read()
     1650          << std::endl;
     1651#endif
     1652          break;
     1653      }
     1654      /////////////////////
     1655      case CONFIG_INV_SEND:    // Post a multi inval request to CC_SEND FSM
     1656      {
     1657          if( not r_config_to_cc_send_multi_req.read() and
     1658              not r_config_to_cc_send_brdcast_req.read() )
     1659          {
     1660              r_config_to_cc_send_multi_req   = true;
     1661              r_config_to_cc_send_brdcast_req = false;
     1662              r_config_to_cc_send_trdid       = r_config_upt_index.read();
     1663              r_config_to_cc_send_nline       = m_nline[(addr_t)(r_config_address.read())];
     1664              r_multi_ack_to_config_ack       = false;
     1665
     1666              config_to_cc_send_fifo_srcid    = r_config_dir_copy_srcid.read();
     1667              config_to_cc_send_fifo_inst     = r_config_dir_copy_inst.read();
     1668              config_to_cc_send_fifo_put      = true;
     1669
     1670              if ( r_config_dir_count.read() == 1 )  r_config_fsm = CONFIG_INV_WAIT;
     1671              else                                   r_config_fsm = CONFIG_HEAP_REQ;
     1672
     1673#if DEBUG_MEMC_CONFIG
     1674if(m_debug)
     1675std::cout << "  <MEMC " << name() << " CONFIG_INV_SEND>"
     1676          << " Post multi inval request to CC_SEND FSM"
     1677          << " / address = " << std::hex << r_config_address.read()
     1678          << " / copy = " << r_config_dir_copy_srcid.read()
     1679          << " / inst = " << std::dec << r_config_dir_copy_inst.read() << std::endl;
     1680#endif
     1681          }
     1682          break;
     1683      }
     1684      /////////////////////
     1685      case CONFIG_HEAP_REQ:  // Try to get access to Heap
     1686      {
     1687          if ( r_alloc_heap_fsm.read() == ALLOC_HEAP_CONFIG )
     1688          {
     1689              r_config_fsm       = CONFIG_HEAP_SCAN;
     1690              r_config_heap_next = r_config_dir_next_ptr.read();
     1691          }
     1692
     1693#if DEBUG_MEMC_CONFIG
     1694if(m_debug)
     1695std::cout << "  <MEMC " << name() << " CONFIG_HEAP_REQ>"
     1696          << " Requesting HEAP lock" << std::endl;
     1697#endif
     1698          break;
     1699      }
     1700      //////////////////////
     1701      case CONFIG_HEAP_SCAN:      // scan HEAP and send inval to CC_SEND FSM
     1702      {
     1703          HeapEntry entry = m_heap.read( r_config_heap_next.read() );
     1704          bool last_copy  = (entry.next == r_config_heap_next.read());
     1705
     1706          config_to_cc_send_fifo_srcid = entry.owner.srcid;
     1707          config_to_cc_send_fifo_inst  = entry.owner.inst;
     1708          // config_to_cc_send_fifo_last  = last_copy;
     1709          config_to_cc_send_fifo_put   = true;
     1710
     1711          if ( m_config_to_cc_send_inst_fifo.wok() ) // inval request accepted
     1712          {
     1713              r_config_heap_next = entry.next;
     1714              if ( last_copy ) r_config_fsm = CONFIG_HEAP_LAST;
     1715          }
     1716         
     1717#if DEBUG_MEMC_CONFIG
     1718if(m_debug)
     1719std::cout << "  <MEMC " << name() << " CONFIG_HEAP_SCAN>"
     1720          << " Post multi inval request to CC_SEND FSM"
     1721          << " / address = " << std::hex << r_config_address.read()
     1722          << " / copy = " << entry.owner.srcid
     1723          << " / inst = " << std::dec << entry.owner.inst << std::endl;
     1724#endif
     1725          break;
     1726      }
     1727      //////////////////////
     1728      case CONFIG_HEAP_LAST:      // HEAP housekeeping
     1729      {
     1730          size_t free_pointer = m_heap.next_free_ptr();
     1731          HeapEntry last_entry;
     1732          last_entry.owner.srcid = 0;
     1733          last_entry.owner.inst  = false;
     1734
     1735          if ( m_heap.is_full() )
     1736          {
     1737              last_entry.next = r_config_dir_next_ptr.read();
     1738              m_heap.unset_full();
     1739          }
     1740          else
     1741          {
     1742              last_entry.next = free_pointer;
     1743          }
     1744
     1745          m_heap.write_free_ptr( r_config_dir_next_ptr.read() );
     1746          m_heap.write( r_config_heap_next.read(), last_entry );
     1747          r_config_fsm = CONFIG_INV_WAIT;
     1748
     1749#if DEBUG_MEMC_CONFIG
     1750if(m_debug)
     1751std::cout << "  <MEMC " << name() << " CONFIG_HEAP_LAST>"
     1752          << " Heap housekeeping" << std::endl;
     1753#endif
     1754          break;
     1755      }
     1756      /////////////////////
     1757      case CONFIG_INV_WAIT:      // wait inval completion to return to LOOP
     1758      {
     1759          if ( r_multi_ack_to_config_ack.read() )
     1760          {
     1761              r_config_fsm     = CONFIG_LOOP;
     1762              r_config_nlines  = r_config_nlines.read() - 1;
     1763              r_config_address = r_config_address.read() + (m_words<<2);
     1764          }
     1765
     1766#if DEBUG_MEMC_CONFIG
     1767if(m_debug)
     1768std::cout << "  <MEMC " << name() << " CONFIG_INV_WAIT> Waiting inval completion "
     1769          << " done = " << r_multi_ack_to_config_ack.read()
     1770          << std::endl;
     1771#endif
     1772          break;
     1773      }
     1774
     1775      ////////////////
     1776      case CONFIG_RSP:  // request TGT_RSP FSM to return response
     1777      {
     1778          if ( not r_config_to_tgt_rsp_req.read() )
     1779          {
     1780              r_config_to_tgt_rsp_srcid  = r_config_srcid.read();
     1781              r_config_to_tgt_rsp_trdid  = r_config_trdid.read();
     1782              r_config_to_tgt_rsp_pktid  = r_config_pktid.read();
     1783              r_config_to_tgt_rsp_error  = false;
     1784              r_config_to_tgt_rsp_req    = true;
     1785              r_config_fsm               = CONFIG_IDLE;
     1786
     1787#if DEBUG_MEMC_CONFIG
     1788if(m_debug)
     1789std::cout << "  <MEMC " << name() << " CONFIG_RSP> Request TGT_RSP FSM to return response:"
     1790          << " error = " << r_config_to_tgt_rsp_error.read()
     1791          << " / rsrcid = " << std::hex << r_config_srcid.read() << std::endl;
     1792#endif
     1793          }
     1794          break;
     1795
     1796      }
     1797  }  // end switch r_config_fsm
    12751798
    12761799  ////////////////////////////////////////////////////////////////////////////////////
     
    13001823  {
    13011824      ///////////////
    1302     case READ_IDLE:
    1303       // waiting a read request
    1304     {
     1825      case READ_IDLE:  // waiting a read request
     1826      {
    13051827      if(m_cmd_read_addr_fifo.rok())
    13061828      {
    13071829
    13081830#if DEBUG_MEMC_READ
    1309         if(m_debug_read_fsm)
    1310         {
    1311           std::cout << "  <MEMC " << name() << ".READ_IDLE> Read request:"
    1312                     << " srcid = " << std::dec << m_cmd_read_srcid_fifo.read()
    1313                     << " / address = " << std::hex << m_cmd_read_addr_fifo.read()
    1314                     << " / pktid = " << std::hex << m_cmd_read_pktid_fifo.read()
    1315                     << " / nwords = " << std::dec << m_cmd_read_length_fifo.read() << std::endl;
    1316         }
     1831if(m_debug)
     1832std::cout << "  <MEMC " << name() << " READ_IDLE> Read request"
     1833          << " : address = " << std::hex << m_cmd_read_addr_fifo.read()
     1834          << " / srcid = " << m_cmd_read_srcid_fifo.read()
     1835          << " / trdid = " << m_cmd_read_trdid_fifo.read()
     1836          << " / pktid = " << m_cmd_read_pktid_fifo.read()
     1837          << " / nwords = " << std::dec << m_cmd_read_length_fifo.read() << std::endl;
    13171838#endif
    13181839        r_read_fsm = READ_DIR_REQ;
     
    13211842    }
    13221843
     1844    //////////////////
     1845    case READ_DIR_REQ:  // Get the lock to the directory
     1846    {
     1847      if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
     1848      {
     1849        r_read_fsm = READ_DIR_LOCK;
     1850      }
     1851
     1852#if DEBUG_MEMC_READ
     1853if(m_debug)
     1854std::cout << "  <MEMC " << name() << " READ_DIR_REQ> Requesting DIR lock " << std::endl;
     1855#endif
     1856      break;
     1857    }
     1858
    13231859    ///////////////////
    1324     case READ_DIR_REQ:
    1325       // Get the lock to the directory
    1326     {
    1327       if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
    1328       {
    1329         r_read_fsm = READ_DIR_LOCK;
    1330       }
    1331 
    1332 #if DEBUG_MEMC_READ
    1333       if(m_debug_read_fsm)
    1334       {
    1335         std::cout
    1336             << "  <MEMC " << name() << ".READ_DIR_REQ> Requesting DIR lock "
    1337             << std::endl;
    1338       }
    1339 #endif
    1340       break;
    1341     }
    1342 
    1343     ///////////////////
    1344     case READ_DIR_LOCK:
    1345       // check directory for hit / miss
     1860    case READ_DIR_LOCK:  // check directory for hit / miss
    13461861    {
    13471862      if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
     
    13751890        {
    13761891          // test if we need to register a new copy in the heap
    1377           if(entry.is_cnt || (entry.count == 0) || !cached_read)
     1892          if(entry.is_cnt or (entry.count == 0) or !cached_read)
    13781893          {
    13791894            r_read_fsm = READ_DIR_HIT;
     
    13901905
    13911906#if DEBUG_MEMC_READ
    1392         if(m_debug_read_fsm)
    1393         {
    1394           std::cout
    1395               << "  <MEMC " << name() << ".READ_DIR_LOCK> Accessing directory: "
    1396               << " address = " << std::hex << m_cmd_read_addr_fifo.read()
    1397               << " / hit = " << std::dec << entry.valid
    1398               << " / count = " <<std::dec << entry.count
    1399               << " / is_cnt = " << entry.is_cnt << std::endl;
    1400           if((m_cmd_read_pktid_fifo.read() & 0x7) == TYPE_LL)
    1401           {
    1402             std::cout
    1403                 << "  <MEMC " << name() << ".READ_DIR_LOCK> global_llsc_table LL access" << std::endl;
    1404           }
    1405         }
     1907if(m_debug)
     1908{
     1909std::cout << "  <MEMC " << name() << " READ_DIR_LOCK> Accessing directory: "
     1910          << " address = " << std::hex << m_cmd_read_addr_fifo.read()
     1911          << " / hit = " << std::dec << entry.valid
     1912          << " / count = " <<std::dec << entry.count
     1913          << " / is_cnt = " << entry.is_cnt;
     1914if((m_cmd_read_pktid_fifo.read() & 0x7) == TYPE_LL) std::cout << " / LL access" << std::endl;
     1915else                                                std::cout << std::endl;
     1916}
    14061917#endif
    14071918      }
    14081919      else
    14091920      {
    1410         std::cout
    1411             << "VCI_MEM_CACHE ERROR " << name()
    1412             << " READ_DIR_LOCK state" << std::endl
    1413             << "Bad DIR allocation"   << std::endl;
    1414 
     1921        std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_DIR_LOCK state"
     1922                  << "Bad DIR allocation"   << std::endl;
    14151923        exit(0);
    14161924      }
     
    14291937      if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
    14301938      {
    1431         // signals generation
    14321939        // check if this is an instruction read, this means pktid is either
    14331940        // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
     
    14411948
    14421949        // read data in the cache
    1443         size_t set        = m_y[(vci_addr_t)(m_cmd_read_addr_fifo.read())];
     1950        size_t set        = m_y[(addr_t)(m_cmd_read_addr_fifo.read())];
    14441951        size_t way        = r_read_way.read();
    14451952
     
    14511958        entry.is_cnt  = is_cnt;
    14521959        entry.dirty   = r_read_dirty.read();
    1453         entry.tag   = r_read_tag.read();
     1960        entry.tag     = r_read_tag.read();
    14541961        entry.lock    = r_read_lock.read();
    14551962        entry.ptr     = r_read_ptr.read();
     
    14861993
    14871994#if DEBUG_MEMC_READ
    1488         if(m_debug_read_fsm)
    1489         {
    1490           std::cout
    1491               << "  <MEMC " << name() << ".READ_DIR_HIT> Update directory entry:"
    1492               << " addr = " << std::hex << m_cmd_read_addr_fifo.read()
    1493               << " / set = " << std::dec << set
    1494               << " / way = " << way
    1495               << " / owner_id = " << entry.owner.srcid
    1496               << " / owner_ins = " << entry.owner.inst
    1497               << " / count = " << entry.count
    1498               << " / is_cnt = " << entry.is_cnt << std::endl;
    1499         }
    1500 #endif
    1501 /**/
     1995if(m_debug)
     1996std::cout << "  <MEMC " << name() << " READ_DIR_HIT> Update directory entry:"
     1997          << " addr = " << std::hex << m_cmd_read_addr_fifo.read()
     1998          << " / set = " << std::dec << set
     1999          << " / way = " << way
     2000          << " / owner_id = " << std::hex << entry.owner.srcid
     2001          << " / owner_ins = " << std::dec << entry.owner.inst
     2002          << " / count = " << entry.count
     2003          << " / is_cnt = " << entry.is_cnt << std::endl;
     2004#endif
     2005
    15022006          if(m_monitor_ok)
    15032007          {
    15042008            char buf[80];
    1505             snprintf(buf, 80, "READ_DIR_HIT srcid %d, ins %d", m_cmd_read_srcid_fifo.read(), ((m_cmd_read_pktid_fifo.read()&0x2)!=0));
    1506             check_monitor_read(buf, m_cmd_read_addr_fifo.read());
     2009            snprintf(buf, 80, "READ_DIR_HIT srcid %d, ins %d",
     2010                     (int)m_cmd_read_srcid_fifo.read(),
     2011                     (int)((m_cmd_read_pktid_fifo.read()&0x2)!=0));
     2012            check_monitor(buf, m_cmd_read_addr_fifo.read(), r_read_data[0], true);
    15072013          }
    1508 /**/
     2014
    15092015
    15102016        m_cache_directory.write(set, way, entry);
     
    15142020    }
    15152021
     2022    ///////////////////
     2023    case READ_HEAP_REQ:    // Get the lock to the HEAP directory
     2024    {
     2025      if(r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
     2026      {
     2027        r_read_fsm = READ_HEAP_LOCK;
     2028      }
     2029
     2030#if DEBUG_MEMC_READ
     2031if(m_debug)
     2032std::cout << "  <MEMC " << name() << " READ_HEAP_REQ>"
     2033          << " Requesting HEAP lock " << std::endl;
     2034#endif
     2035      break;
     2036    }
     2037
    15162038    ////////////////////
    1517     case READ_HEAP_REQ:
    1518       // Get the lock to the HEAP directory
    1519     {
    1520 /**/
    1521           if(m_monitor_ok)
    1522           {
    1523             char buf[80];
    1524             snprintf(buf, 80, "READ_HEAP_REQ srcid %d, ins %d", m_cmd_read_srcid_fifo.read(), ((m_cmd_read_pktid_fifo.read()&0x2)!=0));
    1525             check_monitor_read(buf, m_cmd_read_addr_fifo.read());
    1526           }
    1527 /**/
     2039    case READ_HEAP_LOCK:   // read data in cache, update the directory
     2040                           // and prepare the HEAP update
     2041    {
    15282042      if(r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
    15292043      {
    1530         r_read_fsm = READ_HEAP_LOCK;
    1531       }
    1532 
    1533 #if DEBUG_MEMC_READ
    1534       if(m_debug_read_fsm)
    1535       {
    1536         std::cout
    1537             << "  <MEMC " << name() << ".READ_HEAP_REQ> Requesting HEAP lock "
    1538             << std::endl;
    1539       }
    1540 #endif
    1541       break;
    1542     }
    1543 
    1544     ////////////////////
    1545     case READ_HEAP_LOCK:
    1546       // read data in cache, update the directory
    1547       // and prepare the HEAP update
    1548     {
    1549       if(r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
    1550       {
    15512044        // enter counter mode when we reach the limit of copies or the heap is full
    1552         bool go_cnt = (r_read_count.read() >= m_max_copies) || m_heap.is_full();
     2045        bool go_cnt = (r_read_count.read() >= m_max_copies) or m_heap.is_full();
    15532046
    15542047        // read data in the cache
    1555         size_t set = m_y[(vci_addr_t)(m_cmd_read_addr_fifo.read())];
     2048        size_t set = m_y[(addr_t)(m_cmd_read_addr_fifo.read())];
    15562049        size_t way = r_read_way.read();
    15572050
     
    16232116
    16242117#if DEBUG_MEMC_READ
    1625         if(m_debug_read_fsm)
    1626         {
    1627           std::cout << "  <MEMC " << name() << ".READ_HEAP_LOCK> Update directory:"
    1628                     << " tag = " << std::hex << entry.tag
    1629                     << " set = " << std::dec << set
    1630                     << " way = " << way
    1631                     << " count = " << entry.count
    1632                     << " is_cnt = " << entry.is_cnt << std::endl;
    1633         }
     2118if(m_debug)
     2119std::cout << "  <MEMC " << name() << " READ_HEAP_LOCK> Update directory:"
     2120          << " tag = " << std::hex << entry.tag
     2121          << " set = " << std::dec << set
     2122          << " way = " << way
     2123          << " count = " << entry.count
     2124          << " is_cnt = " << entry.is_cnt << std::endl;
    16342125#endif
    16352126      }
    16362127      else
    16372128      {
    1638         std::cout
    1639             << "VCI_MEM_CACHE ERROR " << name()
    1640             << " READ_HEAP_LOCK state" << std::endl
    1641             << "Bad HEAP allocation"   << std::endl;
    1642 
     2129        std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_HEAP_LOCK"
     2130                  << "Bad HEAP allocation"   << std::endl;
    16432131        exit(0);
    16442132      }
    1645 
    1646       break;
    1647     }
    1648 
     2133      break;
     2134    }
    16492135    /////////////////////
    1650     case READ_HEAP_WRITE:       // add a entry in the heap
     2136    case READ_HEAP_WRITE:       // add an entry in the heap
    16512137    {
    16522138      if(r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
     
    16742160
    16752161#if DEBUG_MEMC_READ
    1676         if(m_debug_read_fsm)
    1677         {
    1678           std::cout
    1679               << "  <MEMC " << name() << ".READ_HEAP_WRITE> Add an entry in the heap:"
    1680               << " owner_id = " << heap_entry.owner.srcid
    1681               << " owner_ins = " << heap_entry.owner.inst << std::endl;
    1682         }
     2162if(m_debug)
     2163std::cout << "  <MEMC " << name() << " READ_HEAP_WRITE> Add an entry in the heap:"
     2164          << " owner_id = " << std::hex << heap_entry.owner.srcid
     2165          << " owner_ins = " << std::dec << heap_entry.owner.inst << std::endl;
    16832166#endif
    16842167      }
    16852168      else
    16862169      {
    1687         std::cout
    1688             << "VCI_MEM_CACHE ERROR " << name()
    1689             << " READ_HEAP_WRITE state" << std::endl
    1690             << "Bad HEAP allocation" << std::endl;
    1691 
     2170        std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_HEAP_WRITE"
     2171                  << "Bad HEAP allocation" << std::endl;
    16922172        exit(0);
    16932173      }
    16942174      break;
    16952175    }
    1696 
    16972176    /////////////////////
    16982177    case READ_HEAP_ERASE:
     
    17132192      else
    17142193      {
    1715         std::cout
    1716             << "VCI_MEM_CACHE ERROR " << name()
    1717             << " READ_HEAP_ERASE state" << std::endl
    1718             << "Bad HEAP allocation" << std::endl;
    1719 
     2194        std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_HEAP_ERASE"
     2195                  << "Bad HEAP allocation" << std::endl;
    17202196        exit(0);
    17212197      }
     
    17492225      else
    17502226      {
    1751         std::cout << "VCI_MEM_CACHE ERROR " << name()
    1752                   << " READ_HEAP_LAST state" << std::endl;
    1753         std::cout << "Bad HEAP allocation" << std::endl;
     2227        std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_HEAP_LAST"
     2228                  << "Bad HEAP allocation" << std::endl;
    17542229        exit(0);
    17552230      }
    17562231      break;
    17572232    }
    1758 
    17592233    //////////////
    17602234    case READ_RSP:    //  request the TGT_RSP FSM to return data
     
    17632237      {
    17642238        for(size_t i=0 ; i<m_words ; i++)  r_read_to_tgt_rsp_data[i] = r_read_data[i];
    1765         r_read_to_tgt_rsp_word   = m_x[(vci_addr_t) m_cmd_read_addr_fifo.read()];
     2239        r_read_to_tgt_rsp_word   = m_x[(addr_t) m_cmd_read_addr_fifo.read()];
    17662240        r_read_to_tgt_rsp_length = m_cmd_read_length_fifo.read();
    17672241        r_read_to_tgt_rsp_srcid  = m_cmd_read_srcid_fifo.read();
     
    17742248
    17752249#if DEBUG_MEMC_READ
    1776         if(m_debug_read_fsm)
    1777         {
    1778           std::cout << "  <MEMC " << name() << ".READ_RSP> Request the TGT_RSP FSM to return data:"
    1779                     << " rsrcid = " << std::dec << m_cmd_read_srcid_fifo.read()
    1780                     << " / address = " << std::hex << m_cmd_read_addr_fifo.read()
    1781                     << " / nwords = " << std::dec << m_cmd_read_length_fifo.read() << std::endl;
    1782         }
    1783 #endif
    1784       }
    1785       break;
    1786     }
    1787 
     2250if(m_debug)
     2251std::cout << "  <MEMC " << name() << " READ_RSP> Request TGT_RSP FSM to return data:"
     2252          << " rsrcid = " << std::hex << m_cmd_read_srcid_fifo.read()
     2253          << " / address = " << std::hex << m_cmd_read_addr_fifo.read()
     2254          << " / nwords = " << std::dec << m_cmd_read_length_fifo.read() << std::endl;
     2255#endif
     2256      }
     2257      break;
     2258    }
    17882259    ///////////////////
    17892260    case READ_TRT_LOCK: // read miss : check the Transaction Table
     
    17922263      {
    17932264        size_t      index     = 0;
    1794         vci_addr_t  addr      = (vci_addr_t) m_cmd_read_addr_fifo.read();
     2265        addr_t      addr      = (addr_t) m_cmd_read_addr_fifo.read();
    17952266        bool        hit_read  = m_trt.hit_read(m_nline[addr], index);
    17962267        bool        hit_write = m_trt.hit_write(m_nline[addr]);
    17972268        bool        wok       = !m_trt.full(index);
    17982269
    1799         if(hit_read || !wok || hit_write)    // missing line already requested or no space
     2270        if(hit_read or !wok or hit_write)    // missing line already requested or no space
    18002271        {
    18012272          if(!wok)      m_cpt_trt_full++;
    1802           if(hit_read || hit_write)   m_cpt_trt_rb++;
     2273          if(hit_read or hit_write)   m_cpt_trt_rb++;
    18032274          r_read_fsm = READ_IDLE;
    18042275        }
     
    18112282
    18122283#if DEBUG_MEMC_READ
    1813         if(m_debug_read_fsm)
    1814         {
    1815           std::cout << "  <MEMC " << name() << ".READ_TRT_LOCK> Check TRT:"
    1816                     << " hit_read = " << hit_read
    1817                     << " / hit_write = " << hit_write
    1818                     << " / full = " << !wok << std::endl;
    1819         }
     2284if(m_debug)
     2285std::cout << "  <MEMC " << name() << " READ_TRT_LOCK> Check TRT:"
     2286          << " hit_read = " << hit_read
     2287          << " / hit_write = " << hit_write
     2288          << " / full = " << !wok << std::endl;
    18202289#endif
    18212290      }
     
    18302299        m_trt.set(r_read_trt_index.read(),
    18312300                              true,
    1832                               m_nline[(vci_addr_t)(m_cmd_read_addr_fifo.read())],
     2301                              m_nline[(addr_t)(m_cmd_read_addr_fifo.read())],
    18332302                              m_cmd_read_srcid_fifo.read(),
    18342303                              m_cmd_read_trdid_fifo.read(),
     
    18362305                              true,
    18372306                              m_cmd_read_length_fifo.read(),
    1838                               m_x[(vci_addr_t)(m_cmd_read_addr_fifo.read())],
     2307                              m_x[(addr_t)(m_cmd_read_addr_fifo.read())],
    18392308                              std::vector<be_t> (m_words,0),
    18402309                              std::vector<data_t> (m_words,0),
    18412310                              r_read_ll_key.read());
    18422311#if DEBUG_MEMC_READ
    1843         if(m_debug_read_fsm)
    1844         {
    1845           std::cout << "  <MEMC " << name() << ".READ_TRT_SET> Write in Transaction Table: " << std::hex
    1846                     << " address = " << std::hex << m_cmd_read_addr_fifo.read()
    1847                     << " / srcid = " << std::dec << m_cmd_read_srcid_fifo.read()
    1848                     << std::endl;
    1849         }
     2312if(m_debug)
     2313std::cout << "  <MEMC " << name() << " READ_TRT_SET> Write in Transaction Table:"
     2314          << " address = " << std::hex << m_cmd_read_addr_fifo.read()
     2315          << " / srcid = " << std::hex << m_cmd_read_srcid_fifo.read() << std::endl;
    18502316#endif
    18512317        r_read_fsm = READ_TRT_REQ;
     
    18552321
    18562322    //////////////////
    1857     case READ_TRT_REQ:
    1858     {
    1859       // consume the read request in the FIFO,
    1860       // and send it to the ixr_cmd_fsm
    1861 
     2323    case READ_TRT_REQ:   // consume the read request in FIFO and send it to IXR_CMD_FSM
     2324    {
    18622325      if(not r_read_to_ixr_cmd_req)
    18632326      {
    18642327        cmd_read_fifo_get       = true;
    18652328        r_read_to_ixr_cmd_req   = true;
    1866         r_read_to_ixr_cmd_nline = m_nline[(vci_addr_t)(m_cmd_read_addr_fifo.read())];
     2329        r_read_to_ixr_cmd_nline = m_nline[(addr_t)(m_cmd_read_addr_fifo.read())];
    18672330        r_read_to_ixr_cmd_trdid = r_read_trt_index.read();
    18682331        r_read_fsm              = READ_IDLE;
    18692332
    18702333#if DEBUG_MEMC_READ
    1871         if(m_debug_read_fsm)
    1872         {
    1873           std::cout
    1874               << "  <MEMC " << name() << ".READ_TRT_REQ> Request GET transaction for address "
    1875               << std::hex << m_cmd_read_addr_fifo.read() << std::endl;
    1876         }
     2334if(m_debug)
     2335std::cout << "  <MEMC " << name() << " READ_TRT_REQ> Request GET transaction for address "
     2336          << std::hex << m_cmd_read_addr_fifo.read() << std::endl;
    18772337#endif
    18782338      }
     
    19142374  switch(r_write_fsm.read())
    19152375  {
    1916       ////////////////
     2376    ////////////////
    19172377    case WRITE_IDLE:  // copy first word of a write burst in local buffer
    19182378    {
     
    19292389        // consume a word in the FIFO & write it in the local buffer
    19302390        cmd_write_fifo_get  = true;
    1931         size_t index        = m_x[(vci_addr_t)(m_cmd_write_addr_fifo.read())];
     2391        size_t index        = m_x[(addr_t)(m_cmd_write_addr_fifo.read())];
    19322392
    19332393        r_write_address     = (addr_t)(m_cmd_write_addr_fifo.read());
     
    19472407        }
    19482408
    1949         if (m_cmd_write_eop_fifo.read() || ((m_cmd_write_pktid_fifo.read() & 0x7) == TYPE_SC))
     2409        if (m_cmd_write_eop_fifo.read() or ((m_cmd_write_pktid_fifo.read() & 0x7) == TYPE_SC))
    19502410        {
    19512411          r_write_fsm = WRITE_DIR_REQ;
     
    19572417
    19582418#if DEBUG_MEMC_WRITE
    1959         if(m_debug_write_fsm)
    1960         {
    1961           std::cout << "  <MEMC " << name() << ".WRITE_IDLE> Write request "
     2419        if(m_debug)
     2420        {
     2421          std::cout << "  <MEMC " << name() << " WRITE_IDLE> Write request "
    19622422                    << " srcid = " << std::dec << m_cmd_write_srcid_fifo.read()
    19632423                    << " / address = " << std::hex << m_cmd_write_addr_fifo.read()
     
    19762436
    19772437#if DEBUG_MEMC_WRITE
    1978         if(m_debug_write_fsm)
     2438        if(m_debug)
    19792439        {
    19802440          std::cout << "  <MEMC " << name()
    1981                     << ".WRITE_NEXT> Write another word in local buffer"
     2441                    << " WRITE_NEXT> Write another word in local buffer"
    19822442                    << std::endl;
    19832443        }
     
    19862446
    19872447        // check that the next word is in the same cache line
    1988         if((m_nline[(vci_addr_t)(r_write_address.read())]       !=
    1989             m_nline[(vci_addr_t)(m_cmd_write_addr_fifo.read())]))
     2448        if((m_nline[(addr_t)(r_write_address.read())]       !=
     2449            m_nline[(addr_t)(m_cmd_write_addr_fifo.read())]))
    19902450        {
    19912451          std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_NEXT state" << std::endl
     
    20292489          if(not m_cmd_write_addr_fifo.rok()) break;
    20302490
    2031           assert(m_cmd_write_eop_fifo.read() &&
     2491          assert(m_cmd_write_eop_fifo.read() and
    20322492                 "Error in VCI_MEM_CACHE : "
    20332493                 "invalid packet format for SC command");
     
    20602520
    20612521#if DEBUG_MEMC_WRITE
    2062       if(m_debug_write_fsm)
     2522      if(m_debug)
    20632523      {
    20642524        std::cout
    2065             << "  <MEMC " << name() << ".WRITE_DIR_REQ> Requesting DIR lock "
     2525            << "  <MEMC " << name() << " WRITE_DIR_REQ> Requesting DIR lock "
    20662526            << std::endl;
    20672527      }
     
    20952555          r_write_way        = way;
    20962556
    2097           if(entry.is_cnt && entry.count)
     2557          if(entry.is_cnt and entry.count)
    20982558          {
    20992559            r_write_fsm = WRITE_DIR_READ;
     
    21102570
    21112571#if DEBUG_MEMC_WRITE
    2112         if(m_debug_write_fsm)
    2113         {
    2114           std::cout << "  <MEMC " << name() << ".WRITE_DIR_LOCK> Check the directory: "
     2572        if(m_debug)
     2573        {
     2574          std::cout << "  <MEMC " << name() << " WRITE_DIR_LOCK> Check the directory: "
    21152575                    << " address = " << std::hex << r_write_address.read()
    21162576                    << " hit = " << std::dec << entry.valid
     
    21182578                    << " is_cnt = " << entry.is_cnt << std::endl;
    21192579          if((r_write_pktid.read() & 0x7) == TYPE_SC)
    2120             std::cout << "  <MEMC " << name() << ".WRITE_DIR_LOCK> global_llsc_table SC access" << std::endl;
     2580            std::cout << "  <MEMC " << name() << " WRITE_DIR_LOCK> global_llsc_table SC access" << std::endl;
    21212581          else
    2122             std::cout << "  <MEMC " << name() << ".WRITE_DIR_LOCK> global_llsc_table SW access" << std::endl;
     2582            std::cout << "  <MEMC " << name() << " WRITE_DIR_LOCK> global_llsc_table SW access" << std::endl;
    21232583        }
    21242584#endif
     
    21402600    {
    21412601      // update local buffer
    2142       size_t set  = m_y[(vci_addr_t)(r_write_address.read())];
     2602      size_t set  = m_y[(addr_t)(r_write_address.read())];
    21432603      size_t way  = r_write_way.read();
    21442604      for(size_t word=0 ; word<m_words ; word++)
     
    21602620
    21612621#if DEBUG_MEMC_WRITE
    2162       if(m_debug_write_fsm)
    2163       {
    2164         std::cout << "  <MEMC " << name() << ".WRITE_DIR_READ> Read the cache to complete local buffer" << std::endl;
     2622      if(m_debug)
     2623      {
     2624        std::cout << "  <MEMC " << name() << " WRITE_DIR_READ> Read the cache to complete local buffer" << std::endl;
    21652625      }
    21662626#endif
     
    21872647      entry.ptr            = r_write_ptr.read();
    21882648
    2189       size_t set           = m_y[(vci_addr_t)(r_write_address.read())];
     2649      size_t set           = m_y[(addr_t)(r_write_address.read())];
    21902650      size_t way           = r_write_way.read();
    21912651
     
    22022662      // no_update is true when there is no need for coherence transaction
    22032663      // (tests for sc requests)
    2204       bool no_update = ((r_write_count.read() ==0) || (owner && (r_write_count.read() ==1) && (r_write_pktid.read() != TYPE_SC)));
     2664      bool no_update = ( (r_write_count.read() == 0) or
     2665                         (owner and (r_write_count.read() ==1) and (r_write_pktid.read() != TYPE_SC)));
    22052666
    22062667      // write data in the cache if no coherence transaction
     
    22132674          if(m_monitor_ok)
    22142675          {
    2215             vci_addr_t address = (r_write_address.read() & ~(vci_addr_t) 0x3F) | word<<2;
     2676            addr_t address = (r_write_address.read() & ~(addr_t) 0x3F) | word<<2;
    22162677            char buf[80];
    2217             snprintf(buf, 80, "WRITE_DIR_HIT srcid %d", r_write_srcid.read());
    2218             check_monitor(buf, address, r_write_data[word].read());
     2678            snprintf(buf, 80, "WRITE_DIR_HIT srcid %d",
     2679                     (int)r_write_srcid.read());
     2680            check_monitor(buf, address, r_write_data[word].read(), false);
    22192681          }
    22202682        }
     
    22342696      // coherence update required
    22352697      {
    2236         if(!r_write_to_cc_send_multi_req.read()   &&
    2237             !r_write_to_cc_send_brdcast_req.read())
     2698        if(!r_write_to_cc_send_multi_req.read() and
     2699           !r_write_to_cc_send_brdcast_req.read())
    22382700        {
    22392701          r_write_fsm = WRITE_UPT_LOCK;
     
    22462708
    22472709#if DEBUG_MEMC_WRITE
    2248       if(m_debug_write_fsm)
    2249       {
    2250         if(no_update)
    2251         {
    2252           std::cout << "  <MEMC " << name() << ".WRITE_DIR_HIT> Write into cache / No coherence transaction"
    2253                     << std::endl;
    2254         }
    2255         else
    2256         {
    2257           std::cout << "  <MEMC " << name() << ".WRITE_DIR_HIT> Coherence update required:"
    2258                     << " is_cnt = " << r_write_is_cnt.read()
    2259                     << " nb_copies = " << std::dec << r_write_count.read() << std::endl;
    2260           if(owner)
    2261             std::cout << "       ... but the first copy is the writer" << std::endl;
    2262         }
    2263       }
     2710if(m_debug)
     2711{
     2712    if(no_update)
     2713    {
     2714        std::cout << "  <MEMC " << name()
     2715                  << " WRITE_DIR_HIT> Write into cache / No coherence transaction"
     2716                  << std::endl;
     2717    }
     2718    else
     2719    {
     2720        std::cout << "  <MEMC " << name() << " WRITE_DIR_HIT> Coherence update required:"
     2721                  << " is_cnt = " << r_write_is_cnt.read()
     2722                  << " nb_copies = " << std::dec << r_write_count.read() << std::endl;
     2723        if(owner) std::cout << "       ... but the first copy is the writer" << std::endl;
     2724    }
     2725}
    22642726#endif
    22652727      break;
     
    22762738        size_t      trdid      = r_write_trdid.read();
    22772739        size_t      pktid      = r_write_pktid.read();
    2278         addr_t      nline      = m_nline[(vci_addr_t)(r_write_address.read())];
     2740        addr_t      nline      = m_nline[(addr_t)(r_write_address.read())];
    22792741        size_t      nb_copies  = r_write_count.read();
    2280         size_t      set        = m_y[(vci_addr_t)(r_write_address.read())];
     2742        size_t      set        = m_y[(addr_t)(r_write_address.read())];
    22812743        size_t      way        = r_write_way.read();
    22822744
    22832745        wok = m_upt.set(true,  // it's an update transaction
    2284                                false,    // it's not a broadcast
    2285                                true,     // it needs a response
    2286                                srcid,
    2287                                trdid,
    2288                                pktid,
    2289                                nline,
    2290                                nb_copies,
    2291                                index);
     2746                        false,    // it's not a broadcast
     2747                        true,     // response required
     2748                        false,    // no acknowledge required
     2749                        srcid,   
     2750                        trdid,
     2751                        pktid,
     2752                        nline,
     2753                        nb_copies,
     2754                        index);
    22922755        if(wok)       // write data in cache
    22932756        {
    22942757          for(size_t word=0 ; word<m_words ; word++)
    22952758          {
    2296             m_cache_data.write(way, set, word, r_write_data[word].read(), r_write_be[word].read());
     2759            m_cache_data.write(way,
     2760                               set,
     2761                               word,
     2762                               r_write_data[word].read(),
     2763                               r_write_be[word].read());
    22972764
    22982765            if(m_monitor_ok)
    22992766            {
    2300               vci_addr_t address = (r_write_address.read() & ~(vci_addr_t) 0x3F) | word<<2;
     2767              addr_t address = (r_write_address.read() & ~(addr_t) 0x3F) | word<<2;
    23012768              char buf[80];
    2302               snprintf(buf, 80, "WRITE_UPT_LOCK srcid %d", srcid);
    2303               check_monitor(buf, address, r_write_data[word].read());
     2769              snprintf(buf, 80, "WRITE_UPT_LOCK srcid %d", (int)srcid);
     2770              check_monitor(buf, address, r_write_data[word].read(), false);
    23042771            }
    23052772          }
     
    23072774
    23082775#if DEBUG_MEMC_WRITE
    2309         if(m_debug_write_fsm)
    2310         {
    2311           if(wok)
    2312           {
    2313             std::cout << "  <MEMC " << name() << ".WRITE_UPT_LOCK> Register the multicast update in UPT / "
    2314                       << " nb_copies = " << r_write_count.read() << std::endl;
    2315           }
    2316         }
     2776if(m_debug)
     2777{
     2778    if(wok)
     2779    {
     2780        std::cout << "  <MEMC " << name()
     2781                  << " WRITE_UPT_LOCK> Register the multicast update in UPT / "
     2782                  << " nb_copies = " << r_write_count.read() << std::endl;
     2783    }
     2784}
    23172785#endif
    23182786        r_write_upt_index = index;
     
    23312799
    23322800#if DEBUG_MEMC_WRITE
    2333         if(m_debug_write_fsm)
    2334         {
    2335           std::cout << "  <MEMC " << name() << ".WRITE_UPT_HEAP_LOCK> Get acces to the HEAP" << std::endl;
    2336         }
     2801if(m_debug)
     2802std::cout << "  <MEMC " << name()
     2803          << " WRITE_UPT_HEAP_LOCK> Get acces to the HEAP" << std::endl;
    23372804#endif
    23382805        r_write_fsm = WRITE_UPT_REQ;
     
    23422809
    23432810    //////////////////
    2344     case WRITE_UPT_REQ:
    2345     {
    2346       // prepare the coherence transaction for the CC_SEND FSM
    2347       // and write the first copy in the FIFO
    2348       // send the request if only one copy
    2349 
    2350       if(!r_write_to_cc_send_multi_req.read() &&
    2351           !r_write_to_cc_send_brdcast_req.read())    // no pending coherence request
    2352       {
    2353         r_write_to_cc_send_brdcast_req  = false;
    2354         r_write_to_cc_send_trdid        = r_write_upt_index.read();
    2355         r_write_to_cc_send_nline        = m_nline[(vci_addr_t)(r_write_address.read())];
    2356         r_write_to_cc_send_index        = r_write_word_index.read();
    2357         r_write_to_cc_send_count        = r_write_word_count.read();
    2358 
    2359         for(size_t i=0; i<m_words ; i++) r_write_to_cc_send_be[i]=r_write_be[i].read();
    2360 
    2361         size_t min = r_write_word_index.read();
    2362         size_t max = r_write_word_index.read() + r_write_word_count.read();
    2363         for(size_t i=min ; i<max ; i++) r_write_to_cc_send_data[i] = r_write_data[i];
    2364 
    2365         if((r_write_copy.read() != r_write_srcid.read()) or(r_write_pktid.read() == TYPE_SC) or
     2811    case WRITE_UPT_REQ:    // prepare the coherence transaction for the CC_SEND FSM
     2812                           // and write the first copy in the FIFO
     2813                           // send the request if only one copy
     2814    {
     2815      assert(not r_write_to_cc_send_multi_req.read()   and
     2816             not r_write_to_cc_send_brdcast_req.read() and
     2817             "Error in VCI_MEM_CACHE : pending multicast or broadcast\n"
     2818             "transaction in WRITE_UPT_REQ state"
     2819            );
     2820
     2821      r_write_to_cc_send_brdcast_req  = false;
     2822      r_write_to_cc_send_trdid        = r_write_upt_index.read();
     2823      r_write_to_cc_send_nline        = m_nline[(addr_t)(r_write_address.read())];
     2824      r_write_to_cc_send_index        = r_write_word_index.read();
     2825      r_write_to_cc_send_count        = r_write_word_count.read();
     2826
     2827      for(size_t i=0; i<m_words ; i++) r_write_to_cc_send_be[i]=r_write_be[i].read();
     2828
     2829      size_t min = r_write_word_index.read();
     2830      size_t max = r_write_word_index.read() + r_write_word_count.read();
     2831      for(size_t i=min ; i<max ; i++) r_write_to_cc_send_data[i] = r_write_data[i];
     2832
     2833      if((r_write_copy.read() != r_write_srcid.read()) or(r_write_pktid.read() == TYPE_SC) or
    23662834#if L1_MULTI_CACHE
    2367             (r_write_copy_cache.read() != r_write_pktid.read()) or
    2368 #endif
    2369             r_write_copy_inst.read())
    2370         {
    2371           // put the first srcid in the fifo
    2372           write_to_cc_send_fifo_put     = true;
    2373           write_to_cc_send_fifo_inst    = r_write_copy_inst.read();
    2374           write_to_cc_send_fifo_srcid   = r_write_copy.read();
     2835          (r_write_copy_cache.read() != r_write_pktid.read()) or
     2836#endif
     2837          r_write_copy_inst.read())
     2838      {
     2839        // put the first srcid in the fifo
     2840        write_to_cc_send_fifo_put     = true;
     2841        write_to_cc_send_fifo_inst    = r_write_copy_inst.read();
     2842        write_to_cc_send_fifo_srcid   = r_write_copy.read();
    23752843#if L1_MULTI_CACHE
    2376           write_to_cc_send_fifo_cache_id= r_write_copy_cache.read();
    2377 #endif
    2378           if(r_write_count.read() == 1)
    2379           {
    2380             r_write_fsm = WRITE_IDLE;
    2381             r_write_to_cc_send_multi_req = true;
    2382           }
    2383           else
    2384           {
    2385             r_write_fsm = WRITE_UPT_NEXT;
    2386             r_write_to_dec = false;
    2387 
    2388           }
     2844        write_to_cc_send_fifo_cache_id= r_write_copy_cache.read();
     2845#endif
     2846        if(r_write_count.read() == 1)
     2847        {
     2848          r_write_fsm = WRITE_IDLE;
     2849          r_write_to_cc_send_multi_req = true;
    23892850        }
    23902851        else
     
    23922853          r_write_fsm = WRITE_UPT_NEXT;
    23932854          r_write_to_dec = false;
    2394         }
     2855
     2856        }
     2857      }
     2858      else
     2859      {
     2860        r_write_fsm = WRITE_UPT_NEXT;
     2861        r_write_to_dec = false;
     2862      }
    23952863
    23962864#if DEBUG_MEMC_WRITE
    2397         if(m_debug_write_fsm)
    2398         {
    2399           std::cout << "  <MEMC " << name() << ".WRITE_UPT_REQ> Post first request to CC_SEND FSM"
    2400                     << " / srcid = " << std::dec << r_write_copy.read()
    2401                     << " / inst = "  << std::dec << r_write_copy_inst.read() << std::endl;
    2402           if(r_write_count.read() == 1)
    2403             std::cout << "         ... and this is the last" << std::endl;
    2404         }
    2405 #endif
    2406       }
     2865      if(m_debug)
     2866      {
     2867        std::cout
     2868          << "  <MEMC "    << name()
     2869          << " WRITE_UPT_REQ> Post first request to CC_SEND FSM"
     2870          << " / srcid = " << std::dec << r_write_copy.read()
     2871          << " / inst = "  << std::dec << r_write_copy_inst.read() << std::endl;
     2872
     2873        if(r_write_count.read() == 1)
     2874          std::cout << "         ... and this is the last" << std::endl;
     2875      }
     2876#endif
    24072877      break;
    24082878    }
     
    24242894      bool dec_upt_counter;
    24252895
    2426       if(((entry.owner.srcid != r_write_srcid.read()) || (r_write_pktid.read() == TYPE_SC)) or
     2896      if(((entry.owner.srcid != r_write_srcid.read()) or (r_write_pktid.read() == TYPE_SC)) or
    24272897#if L1_MULTI_CACHE
    24282898          (entry.owner.cache_id != r_write_pktid.read()) or
     
    24392909
    24402910#if DEBUG_MEMC_WRITE
    2441         if(m_debug_write_fsm)
    2442         {
    2443           std::cout << "  <MEMC " << name() << ".WRITE_UPT_NEXT> Post another request to CC_SEND FSM"
     2911        if(m_debug)
     2912        {
     2913          std::cout << "  <MEMC " << name() << " WRITE_UPT_NEXT> Post another request to CC_SEND FSM"
    24442914                    << " / heap_index = " << std::dec << r_write_ptr.read()
    24452915                    << " / srcid = " << std::dec << r_write_copy.read()
     
    24552925
    24562926#if DEBUG_MEMC_WRITE
    2457         if(m_debug_write_fsm)
    2458         {
    2459           std::cout << "  <MEMC " << name() << ".WRITE_UPT_NEXT> Skip one entry in heap matching the writer"
     2927        if(m_debug)
     2928        {
     2929          std::cout << "  <MEMC " << name() << " WRITE_UPT_NEXT> Skip one entry in heap matching the writer"
    24602930                    << " / heap_index = " << std::dec << r_write_ptr.read()
    24612931                    << " / srcid = " << std::dec << r_write_copy.read()
     
    25353005          // consume a word in the FIFO & write it in the local buffer
    25363006          cmd_write_fifo_get  = true;
    2537           size_t index        = m_x[(vci_addr_t)(m_cmd_write_addr_fifo.read())];
     3007          size_t index        = m_x[(addr_t)(m_cmd_write_addr_fifo.read())];
    25383008
    25393009          r_write_address     = (addr_t)(m_cmd_write_addr_fifo.read());
     
    25533023          }
    25543024
    2555           if(m_cmd_write_eop_fifo.read() || ((m_cmd_write_pktid_fifo.read() & 0x7)  == TYPE_SC))
     3025          if(m_cmd_write_eop_fifo.read() or ((m_cmd_write_pktid_fifo.read() & 0x7)  == TYPE_SC))
    25563026          {
    25573027            r_write_fsm = WRITE_DIR_REQ;
     
    25683038
    25693039#if DEBUG_MEMC_WRITE
    2570         if(m_debug_write_fsm)
    2571         {
    2572           std::cout << "  <MEMC " << name() << ".WRITE_RSP> Post a request to TGT_RSP FSM: rsrcid = "
    2573                     << std::dec << r_write_srcid.read() << std::endl;
    2574           if(m_cmd_write_addr_fifo.rok())
    2575           {
    2576             std::cout << "                    New Write request: "
    2577                       << " srcid = " << std::dec << m_cmd_write_srcid_fifo.read()
    2578                       << " / address = " << std::hex << m_cmd_write_addr_fifo.read()
    2579                       << " / data = " << m_cmd_write_data_fifo.read() << std::endl;
    2580           }
    2581         }
     3040if(m_debug)
     3041{
     3042    std::cout << "  <MEMC " << name() << " WRITE_RSP> Post a request to TGT_RSP FSM"
     3043              << " : rsrcid = " << std::hex << r_write_srcid.read() << std::endl;
     3044    if(m_cmd_write_addr_fifo.rok())
     3045    {
     3046        std::cout << "                    New Write request: "
     3047                  << " srcid = " << std::hex << m_cmd_write_srcid_fifo.read()
     3048                  << " / address = " << m_cmd_write_addr_fifo.read()
     3049                  << " / data = " << m_cmd_write_data_fifo.read() << std::endl;
     3050    }
     3051}
    25823052#endif
    25833053      }
     
    25923062
    25933063#if DEBUG_MEMC_WRITE
    2594         if(m_debug_write_fsm)
    2595         {
    2596           std::cout << "  <MEMC " << name() << ".WRITE_MISS_TRT_LOCK> Check the TRT" << std::endl;
    2597         }
     3064if(m_debug)
     3065std::cout << "  <MEMC " << name() << " WRITE_MISS_TRT_LOCK> Check the TRT" << std::endl;
    25983066#endif
    25993067        size_t  hit_index = 0;
    26003068        size_t  wok_index = 0;
    2601         vci_addr_t  addr  = (vci_addr_t) r_write_address.read();
     3069        addr_t  addr  = (addr_t) r_write_address.read();
    26023070        bool    hit_read  = m_trt.hit_read(m_nline[addr], hit_index);
    26033071        bool    hit_write = m_trt.hit_write(m_nline[addr]);
     
    26103078          m_cpt_write_miss++;
    26113079        }
    2612         else if(wok && !hit_write)      // set a new entry in TRT
     3080        else if(wok and !hit_write)      // set a new entry in TRT
    26133081        {
    26143082          r_write_trt_index = wok_index;
     
    26283096    case WRITE_WAIT:  // release the locks protecting the shared ressources
    26293097    {
     3098
    26303099#if DEBUG_MEMC_WRITE
    2631       if(m_debug_write_fsm)
    2632       {
    2633         std::cout << "  <MEMC " << name() << ".WRITE_WAIT> Releases the locks before retry" << std::endl;
    2634       }
     3100if(m_debug)
     3101std::cout << "  <MEMC " << name() << " WRITE_WAIT> Releases the locks before retry" << std::endl;
    26353102#endif
    26363103      r_write_fsm = WRITE_DIR_REQ;
     
    26543121        m_trt.set(r_write_trt_index.read(),
    26553122                              true,     // read request to XRAM
    2656                               m_nline[(vci_addr_t)(r_write_address.read())],
     3123                              m_nline[(addr_t)(r_write_address.read())],
    26573124                              r_write_srcid.read(),
    26583125                              r_write_trdid.read(),
     
    26663133
    26673134#if DEBUG_MEMC_WRITE
    2668         if(m_debug_write_fsm)
    2669         {
    2670           std::cout << "  <MEMC " << name() << ".WRITE_MISS_TRT_SET> Set a new entry in TRT" << std::endl;
    2671         }
     3135if(m_debug)
     3136std::cout << "  <MEMC " << name() << " WRITE_MISS_TRT_SET> Set a new entry in TRT" << std::endl;
    26723137#endif
    26733138      }
     
    26953160
    26963161#if DEBUG_MEMC_WRITE
    2697         if(m_debug_write_fsm)
    2698         {
    2699           std::cout << "  <MEMC " << name() << ".WRITE_MISS_TRT_DATA> Modify an existing entry in TRT" << std::endl;
    2700           m_trt.print(r_write_trt_index.read());
    2701         }
     3162if(m_debug)
     3163std::cout << "  <MEMC " << name() << " WRITE_MISS_TRT_DATA> Modify an existing entry in TRT" << std::endl;
    27023164#endif
    27033165      }
     
    27123174        r_write_to_ixr_cmd_req   = true;
    27133175        r_write_to_ixr_cmd_write = false;
    2714         r_write_to_ixr_cmd_nline = m_nline[(vci_addr_t)(r_write_address.read())];
     3176        r_write_to_ixr_cmd_nline = m_nline[(addr_t)(r_write_address.read())];
    27153177        r_write_to_ixr_cmd_trdid = r_write_trt_index.read();
    27163178        r_write_fsm              = WRITE_RSP;
    27173179
    27183180#if DEBUG_MEMC_WRITE
    2719         if(m_debug_write_fsm)
    2720         {
    2721           std::cout << "  <MEMC " << name() << ".WRITE_MISS_XRAM_REQ> Post a GET request to the IXR_CMD FSM" << std::endl;
    2722         }
     3181if(m_debug)
     3182std::cout << "  <MEMC " << name() << " WRITE_MISS_XRAM_REQ> Post a GET request to the IXR_CMD FSM" << std::endl;
    27233183#endif
    27243184      }
     
    27443204
    27453205#if DEBUG_MEMC_WRITE
    2746         if(m_debug_write_fsm)
    2747         {
    2748           std::cout << "  <MEMC " << name() << ".WRITE_BC_TRT_LOCK> Check TRT : wok = "
    2749                     << wok << " / index = " << wok_index << std::endl;
    2750         }
     3206if(m_debug)
     3207std::cout << "  <MEMC " << name() << " WRITE_BC_TRT_LOCK> Check TRT"
     3208          << " : wok = " << wok << " / index = " << wok_index << std::endl;
    27513209#endif
    27523210      }
     
    27643222        size_t      trdid     = r_write_trdid.read();
    27653223        size_t      pktid     = r_write_pktid.read();
    2766         addr_t      nline     = m_nline[(vci_addr_t)(r_write_address.read())];
     3224        addr_t      nline     = m_nline[(addr_t)(r_write_address.read())];
    27673225        size_t      nb_copies = r_write_count.read();
    27683226
    2769         wok =m_upt.set(false,  // it's an inval transaction
    2770                               true,     // it's a broadcast
    2771                               true,     // it needs a response
    2772                               srcid,
    2773                               trdid,
    2774                               pktid,
    2775                               nline,
    2776                               nb_copies,
    2777                               index);
     3227        wok = m_upt.set(false,  // it's an inval transaction
     3228                        true,     // it's a broadcast
     3229                        true,     // response required
     3230                        false,    // no acknowledge required
     3231                        srcid,
     3232                        trdid,
     3233                        pktid,
     3234                        nline,
     3235                        nb_copies,
     3236                        index);
    27783237
    27793238#if DEBUG_MEMC_WRITE
    2780         if(m_debug_write_fsm)
    2781         {
    2782           if(wok)
    2783           {
    2784             std::cout << "  <MEMC " << name() << ".WRITE_BC_UPT_LOCK> Register the broadcast inval in UPT / "
    2785                       << " nb_copies = " << r_write_count.read() << std::endl;
    2786           }
    2787         }
     3239if( m_debug and wok )
     3240std::cout << "  <MEMC " << name() << " WRITE_BC_UPT_LOCK> Register broadcast inval in UPT"
     3241          << " / nb_copies = " << r_write_count.read() << std::endl;
    27883242#endif
    27893243        r_write_upt_index = index;
     
    28003254      // Register a put transaction to XRAM in TRT
    28013255      // and invalidate the line in directory
    2802       if((r_alloc_trt_fsm.read() != ALLOC_TRT_WRITE) ||
    2803           (r_alloc_upt_fsm.read() != ALLOC_UPT_WRITE) ||
     3256      if((r_alloc_trt_fsm.read() != ALLOC_TRT_WRITE) or
     3257          (r_alloc_upt_fsm.read() != ALLOC_UPT_WRITE) or
    28043258          (r_alloc_dir_fsm.read() != ALLOC_DIR_WRITE))
    28053259      {
     
    28123266      m_trt.set(r_write_trt_index.read(),
    28133267                            false,    // write request to XRAM
    2814                             m_nline[(vci_addr_t)(r_write_address.read())],
     3268                            m_nline[(addr_t)(r_write_address.read())],
    28153269                            0,
    28163270                            0,
     
    28363290      entry.ptr           = 0;
    28373291      entry.count         = 0;
    2838       size_t set          = m_y[(vci_addr_t)(r_write_address.read())];
     3292      size_t set          = m_y[(addr_t)(r_write_address.read())];
    28393293      size_t way          = r_write_way.read();
    28403294
     
    28423296
    28433297#if DEBUG_MEMC_WRITE
    2844       if(m_debug_write_fsm)
    2845       {
    2846         std::cout << "  <MEMC " << name() << ".WRITE_BC_DIR_INVAL> Invalidate the directory entry: @ = "
    2847                   << r_write_address.read() << " / register the put transaction in TRT:" << std::endl;
    2848       }
     3298if(m_debug)
     3299std::cout << "  <MEMC " << name() << " WRITE_BC_DIR_INVAL> Invalidate the directory entry: @ = "
     3300          << r_write_address.read() << " / register the put transaction in TRT:" << std::endl;
    28493301#endif
    28503302      r_write_fsm = WRITE_BC_CC_SEND;
     
    28553307    case WRITE_BC_CC_SEND:    // Post a coherence broadcast request to CC_SEND FSM
    28563308    {
    2857       if(!r_write_to_cc_send_multi_req.read() && !r_write_to_cc_send_brdcast_req.read())
     3309      if(!r_write_to_cc_send_multi_req.read() and !r_write_to_cc_send_brdcast_req.read())
    28583310      {
    28593311        r_write_to_cc_send_multi_req   = false;
    28603312        r_write_to_cc_send_brdcast_req = true;
    28613313        r_write_to_cc_send_trdid       = r_write_upt_index.read();
    2862         r_write_to_cc_send_nline       = m_nline[(vci_addr_t)(r_write_address.read())];
     3314        r_write_to_cc_send_nline       = m_nline[(addr_t)(r_write_address.read())];
    28633315        r_write_to_cc_send_index       = 0;
    28643316        r_write_to_cc_send_count       = 0;
     
    28723324
    28733325#if DEBUG_MEMC_WRITE
    2874         if(m_debug_write_fsm)
    2875         {
    2876           std::cout << "  <MEMC " << name() << ".WRITE_BC_CC_SEND> Post a broadcast request to CC_SEND FSM" << std::endl;
    2877         }
     3326if(m_debug)
     3327std::cout << "  <MEMC " << name()
     3328          << " WRITE_BC_CC_SEND> Post a broadcast request to CC_SEND FSM" << std::endl;
    28783329#endif
    28793330      }
     
    28883339        r_write_to_ixr_cmd_req     = true;
    28893340        r_write_to_ixr_cmd_write   = true;
    2890         r_write_to_ixr_cmd_nline   = m_nline[(vci_addr_t)(r_write_address.read())];
     3341        r_write_to_ixr_cmd_nline   = m_nline[(addr_t)(r_write_address.read())];
    28913342        r_write_to_ixr_cmd_trdid   = r_write_trt_index.read();
    28923343
     
    28963347
    28973348#if DEBUG_MEMC_WRITE
    2898         if(m_debug_write_fsm)
    2899         {
    2900           std::cout << "  <MEMC " << name() << ".WRITE_BC_XRAM_REQ> Post a put request to IXR_CMD FSM" << std::endl;
    2901         }
     3349if(m_debug)
     3350std::cout << "  <MEMC " << name()
     3351          << " WRITE_BC_XRAM_REQ> Post a put request to IXR_CMD FSM" << std::endl;
    29023352#endif
    29033353      }
     
    29103360  ///////////////////////////////////////////////////////////////////////
    29113361  // The IXR_CMD fsm controls the command packets to the XRAM :
    2912   // - It sends a single cell VCI read request to the XRAM in case of MISS
     3362  // It handles requests from the READ, WRITE, CAS, XRAM_RSP FSMs
     3363  // with a round-robin priority.
     3364  //
     3365  // - It sends a single flit VCI read request to the XRAM in case of MISS
    29133366  // posted by the READ, WRITE or CAS FSMs : the TRDID field contains
    29143367  // the Transaction Tab index.
    2915   // The VCI response is a multi-cell packet : the N cells contain
     3368  // The VCI response is a multi-flit packet : the N cells contain
    29163369  // the N data words.
    2917   // - It sends a multi-cell VCI write when the XRAM_RSP FSM, WRITE FSM
     3370  //
     3371  // - It sends a multi-flit VCI write when the XRAM_RSP FSM, WRITE FSM
    29183372  // or CAS FSM request to save a dirty line to the XRAM.
    2919   // The VCI response is a single cell packet.
    2920   // This FSM handles requests from the READ, WRITE, CAS & XRAM_RSP FSMs
    2921   // with a round-robin priority.
     3373  // The VCI response is a single flit packet.
    29223374  ////////////////////////////////////////////////////////////////////////
    29233375
    29243376  switch(r_ixr_cmd_fsm.read())
    29253377  {
    2926       ////////////////////////
     3378    ////////////////////////
    29273379    case IXR_CMD_READ_IDLE:
    2928       if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE_NLINE;
    2929       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS_NLINE;
    2930       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM_DATA;
    2931       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ_NLINE;
    2932       break;
    2933       ////////////////////////
     3380    {
     3381      if     (r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
     3382      else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
     3383      else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3384      else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
     3385      break;
     3386    }
     3387    ////////////////////////
    29343388    case IXR_CMD_WRITE_IDLE:
    2935       if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS_NLINE;
    2936       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM_DATA;
    2937       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ_NLINE;
    2938       else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE_NLINE;
    2939       break;
    2940       ////////////////////////
     3389    {
     3390      if     (r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
     3391      else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3392      else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
     3393      else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
     3394      break;
     3395    }
     3396    ////////////////////////
    29413397    case IXR_CMD_CAS_IDLE:
    2942       if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM_DATA;
    2943       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ_NLINE;
    2944       else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE_NLINE;
    2945       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS_NLINE;
    2946       break;
    2947       ////////////////////////
     3398    {
     3399      if     (r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3400      else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
     3401      else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
     3402      else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
     3403      break;
     3404    }
     3405    ////////////////////////
    29483406    case IXR_CMD_XRAM_IDLE:
    2949       if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ_NLINE;
    2950       else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE_NLINE;
    2951       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS_NLINE;
    2952       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM_DATA;
    2953       break;
    2954       /////////////////////////       // send a get request to XRAM
    2955     case IXR_CMD_READ_NLINE:
     3407    {
     3408      if     (r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
     3409      else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
     3410      else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
     3411      else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3412      break;
     3413    }
     3414    //////////////////       // send a get from READ FSM
     3415    case IXR_CMD_READ:
     3416    {
    29563417      if(p_vci_ixr.cmdack)
    29573418      {
     
    29603421
    29613422#if DEBUG_MEMC_IXR_CMD
    2962         if(m_debug_ixr_cmd_fsm)
    2963         {
    2964           std::cout << "  <MEMC " << name() << ".IXR_CMD_READ_NLINE> Send a get request to xram" << std::endl;
    2965         }
    2966 #endif
    2967       }
    2968       break;
    2969       //////////////////////////
    2970     case IXR_CMD_WRITE_NLINE:     // send a put or get command to XRAM
     3423if(m_debug)
     3424std::cout << "  <MEMC " << name() << " IXR_CMD_READ>"
     3425          << " Send a get request to xram / address = " << std::hex
     3426          << (addr_t)(r_read_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
     3427#endif
     3428      }
     3429      break;
     3430    }
     3431    ///////////////////
     3432    case IXR_CMD_WRITE:     // send a put or get from WRITE FSM
     3433    {
    29713434      if(p_vci_ixr.cmdack)
    29723435      {
    2973         if(r_write_to_ixr_cmd_write.read())
    2974         {
    2975           if(r_ixr_cmd_cpt.read() == (m_words - 1))
     3436        if(r_write_to_ixr_cmd_write.read())   // PUT
     3437        {
     3438          if(r_ixr_cmd_cpt.read() == (m_words - 2))
    29763439          {
    29773440            r_ixr_cmd_cpt = 0;
     
    29813444          else
    29823445          {
    2983             r_ixr_cmd_cpt = r_ixr_cmd_cpt + 1;
     3446            r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    29843447          }
    29853448
    29863449#if DEBUG_MEMC_IXR_CMD
    2987           if(m_debug_ixr_cmd_fsm)
    2988           {
    2989             std::cout << "  <MEMC " << name() << ".IXR_CMD_WRITE_NLINE> Send a put request to xram" << std::endl;
    2990           }
    2991 #endif
    2992         }
    2993         else
     3450if(m_debug)
     3451std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE>"
     3452          << " Send a put request to xram / address = " << std::hex
     3453          << (addr_t)((r_write_to_ixr_cmd_nline.read() * m_words +
     3454                      r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
     3455#endif
     3456        }
     3457        else                                  // GET
    29943458        {
    29953459          r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE;
     
    29973461
    29983462#if DEBUG_MEMC_IXR_CMD
    2999           if(m_debug_ixr_cmd_fsm)
    3000           {
    3001             std::cout << "  <MEMC " << name() << ".IXR_CMD_WRITE_NLINE> Send a get request to xram" << std::endl;
    3002           }
    3003 #endif
    3004         }
    3005       }
    3006       break;
    3007       //////////////////////
    3008     case IXR_CMD_CAS_NLINE:      // send a put or get command to XRAM
     3463if(m_debug)
     3464std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE>"
     3465          << " Send a get request to xram / address = " << std::hex
     3466          << (addr_t)(r_write_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
     3467#endif
     3468        }
     3469      }
     3470      break;
     3471    }
     3472    /////////////////
     3473    case IXR_CMD_CAS:      // send a put or get command from CAS FSM
     3474    {
    30093475      if(p_vci_ixr.cmdack)
    30103476      {
    3011         if(r_cas_to_ixr_cmd_write.read())
    3012         {
    3013           if(r_ixr_cmd_cpt.read() == (m_words - 1))
     3477        if(r_cas_to_ixr_cmd_write.read()) // PUT
     3478        {
     3479          if(r_ixr_cmd_cpt.read() == (m_words - 2))
    30143480          {
    30153481            r_ixr_cmd_cpt = 0;
     
    30193485          else
    30203486          {
    3021             r_ixr_cmd_cpt = r_ixr_cmd_cpt + 1;
     3487            r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    30223488          }
    30233489
    30243490#if DEBUG_MEMC_IXR_CMD
    3025           if(m_debug_ixr_cmd_fsm)
    3026           {
    3027             std::cout << "  <MEMC " << name() << ".IXR_CMD_CAS_NLINE> Send a put request to xram" << std::endl;
    3028           }
    3029 #endif
    3030         }
    3031         else
     3491if(m_debug)
     3492std::cout << "  <MEMC " << name() << " IXR_CMD_CAS>"
     3493          << " Send a put request to xram / address = " << std::hex
     3494          << (addr_t)( (r_cas_to_ixr_cmd_nline.read() * m_words +
     3495                      r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
     3496#endif
     3497        }
     3498        else                            // GET
    30323499        {
    30333500          r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE;
     
    30353502
    30363503#if DEBUG_MEMC_IXR_CMD
    3037           if(m_debug_ixr_cmd_fsm)
    3038           {
    3039             std::cout << "  <MEMC " << name() << ".IXR_CMD_CAS_NLINE> Send a get request to xram" << std::endl;
    3040           }
    3041 #endif
    3042         }
    3043       }
    3044       break;
    3045       ////////////////////////
    3046     case IXR_CMD_XRAM_DATA:     // send a put command to XRAM
     3504if(m_debug)
     3505std::cout << "  <MEMC " << name() << " IXR_CMD_CAS>"
     3506          << " Send a get request to xram / address = " << std::hex
     3507          << (addr_t)(r_cas_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
     3508#endif
     3509        }
     3510      }
     3511      break;
     3512    }
     3513    //////////////////
     3514    case IXR_CMD_XRAM:     // send a put from XRAM_RSP FSM
     3515    {
    30473516      if(p_vci_ixr.cmdack)
    30483517      {
    3049         if(r_ixr_cmd_cpt.read() == (m_words - 1))
     3518        if(r_ixr_cmd_cpt.read() == (m_words - 2))
    30503519        {
    30513520          r_ixr_cmd_cpt = 0;
     
    30553524        else
    30563525        {
    3057           r_ixr_cmd_cpt = r_ixr_cmd_cpt + 1;
     3526          r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    30583527        }
    30593528
    30603529#if DEBUG_MEMC_IXR_CMD
    3061         if(m_debug_ixr_cmd_fsm)
    3062         {
    3063           std::cout << "  <MEMC " << name() << ".IXR_CMD_XRAM_DATA> Send a put request to xram" << std::endl;
    3064         }
    3065 #endif
    3066       }
    3067       break;
     3530if(m_debug)
     3531std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM>"
     3532          << " Send a put request to xram / address = " << std::hex
     3533          << (addr_t)( (r_xram_rsp_to_ixr_cmd_nline.read() * m_words +
     3534                       r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
     3535#endif
     3536      }
     3537      break;
     3538    }
    30683539
    30693540  } // end switch r_ixr_cmd_fsm
     
    30903561  switch(r_ixr_rsp_fsm.read())
    30913562  {
    3092       //////////////////
    3093     case IXR_RSP_IDLE:  // test if it's a get or a put transaction
     3563    //////////////////
     3564    case IXR_RSP_IDLE:  // test transaction type: PUT/GET
    30943565    {
    30953566      if(p_vci_ixr.rspval.read())
     
    30973568        r_ixr_rsp_cpt   = 0;
    30983569        r_ixr_rsp_trt_index = p_vci_ixr.rtrdid.read();
    3099         if(p_vci_ixr.reop.read() && !(p_vci_ixr.rerror.read() &0x1))   // put transaction
     3570        if(p_vci_ixr.reop.read() and !(p_vci_ixr.rerror.read() &0x1))   // PUT transaction
    31003571        {
    31013572          r_ixr_rsp_fsm = IXR_RSP_ACK;
    31023573
    31033574#if DEBUG_MEMC_IXR_RSP
    3104           if(m_debug_ixr_rsp_fsm)
    3105           {
    3106             std::cout << "  <MEMC " << name() << ".IXR_RSP_IDLE> Response from XRAM to a put transaction" << std::endl;
    3107           }
    3108 #endif
    3109         }
    3110         else                     // get transaction
     3575if(m_debug)
     3576std::cout << "  <MEMC " << name()
     3577          << " IXR_RSP_IDLE> Response from XRAM to a put transaction" << std::endl;
     3578#endif
     3579        }
     3580        else                                                         // GET transaction
    31113581        {
    31123582          r_ixr_rsp_fsm = IXR_RSP_TRT_READ;
    31133583
    31143584#if DEBUG_MEMC_IXR_RSP
    3115           if(m_debug_ixr_rsp_fsm)
    3116           {
    3117             std::cout << "  <MEMC " << name() << ".IXR_RSP_IDLE> Response from XRAM to a get transaction" << std::endl;
    3118           }
    3119 #endif
    3120         }
    3121       }
    3122       break;
    3123     }
    3124     ////////////////////////
    3125     case IXR_RSP_ACK:        // Aknowledge the VCI response
     3585if(m_debug)
     3586std::cout << "  <MEMC " << name()
     3587          << " IXR_RSP_IDLE> Response from XRAM to a get transaction" << std::endl;
     3588#endif
     3589        }
     3590      }
     3591      break;
     3592    }
     3593    /////////////////
     3594    case IXR_RSP_ACK:        // Aknowledge the VCI response for a PUT
    31263595    {
    31273596      if(p_vci_ixr.rspval.read()) r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE;
    31283597
    31293598#if DEBUG_MEMC_IXR_RSP
    3130       if(m_debug_ixr_rsp_fsm)
    3131       {
    3132         std::cout << "  <MEMC " << name() << ".IXR_RSP_ACK>" << std::endl;
    3133       }
     3599if(m_debug)
     3600std::cout << "  <MEMC " << name() << " IXR_RSP_ACK>" << std::endl;
    31343601#endif
    31353602      break;
     
    31443611
    31453612#if DEBUG_MEMC_IXR_RSP
    3146         if(m_debug_ixr_rsp_fsm)
    3147         {
    3148           std::cout << "  <MEMC " << name() << ".IXR_RSP_TRT_ERASE> Erase TRT entry "
    3149                     << r_ixr_rsp_trt_index.read() << std::endl;
    3150         }
    3151 #endif
    3152       }
    3153       break;
    3154     }
    3155     ///////////////////////
    3156     case IXR_RSP_TRT_READ:    // write data in the TRT
    3157     {
    3158       if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) &&  p_vci_ixr.rspval)
    3159       {
    3160         size_t index    = r_ixr_rsp_trt_index.read();
    3161         bool   eop    = p_vci_ixr.reop.read();
    3162         data_t data   = p_vci_ixr.rdata.read();
    3163         bool   error    = ((p_vci_ixr.rerror.read() & 0x1) == 1);
    3164         assert(((eop == (r_ixr_rsp_cpt.read() == (m_words-1))) || p_vci_ixr.rerror.read())
     3613if(m_debug)
     3614std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_ERASE> Erase TRT entry "
     3615          << r_ixr_rsp_trt_index.read() << std::endl;
     3616#endif
     3617      }
     3618      break;
     3619    }
     3620    //////////////////////
     3621    case IXR_RSP_TRT_READ:    // write a 64 bits data in the TRT
     3622    {
     3623      if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and  p_vci_ixr.rspval)
     3624      {
     3625        size_t      index    = r_ixr_rsp_trt_index.read();
     3626        bool        eop      = p_vci_ixr.reop.read();
     3627        wide_data_t data     = p_vci_ixr.rdata.read();
     3628        bool        error    = ((p_vci_ixr.rerror.read() & 0x1) == 1);
     3629
     3630        assert(((eop == (r_ixr_rsp_cpt.read() == (m_words-2))) or p_vci_ixr.rerror.read())
    31653631               and "Error in VCI_MEM_CACHE : invalid length for a response from XRAM");
    3166         m_trt.write_rsp(index,
    3167                                     r_ixr_rsp_cpt.read(),
    3168                                     data,
    3169                                     error);
    3170         r_ixr_rsp_cpt = r_ixr_rsp_cpt.read() + 1;
     3632
     3633        m_trt.write_rsp( index,
     3634                         r_ixr_rsp_cpt.read(),
     3635                         data,
     3636                         error);
     3637
     3638        r_ixr_rsp_cpt = r_ixr_rsp_cpt.read() + 2;
     3639
    31713640        if(eop)
    31723641        {
     
    31763645
    31773646#if DEBUG_MEMC_IXR_RSP
    3178         if(m_debug_ixr_rsp_fsm)
    3179         {
    3180           std::cout << "  <MEMC " << name() << ".IXR_RSP_TRT_READ> Writing a word in TRT : "
    3181                     << " index = " << std::dec << index
    3182                     << " / word = " << r_ixr_rsp_cpt.read()
    3183                     << " / data = " << std::hex << data << std::endl;
    3184         }
     3647if(m_debug)
     3648std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_READ> Writing a word in TRT : "
     3649          << " index = " << std::dec << index
     3650          << " / word = " << r_ixr_rsp_cpt.read()
     3651          << " / data = " << std::hex << data << std::endl;
    31853652#endif
    31863653      }
     
    32003667  //
    32013668  // When a response is available, the corresponding TRT entry
    3202   // must be copied in a local buffer to be written in the cache.
     3669  // is copied in a local buffer to be written in the cache.
    32033670  // The FSM takes the lock protecting the TRT, and the lock protecting the DIR.
    32043671  // It selects a cache slot and writes the line in the cache.
     
    32143681  switch(r_xram_rsp_fsm.read())
    32153682  {
    3216       ///////////////////
    3217     case XRAM_RSP_IDLE: // scan the XRAM responses to get the TRT index (round robin)
     3683    ///////////////////
     3684    case XRAM_RSP_IDLE: // scan the XRAM responses / select a TRT index (round robin)
    32183685    {
    32193686      size_t ptr   = r_xram_rsp_trt_index.read();
     
    32213688      for(size_t i=0 ; i<lines ; i++)
    32223689      {
    3223         size_t index= (i+ptr+1) %lines;
     3690        size_t index = (i+ptr+1) %lines;
    32243691        if(r_ixr_rsp_to_xram_rsp_rok[index])
    32253692        {
     
    32293696
    32303697#if DEBUG_MEMC_XRAM_RSP
    3231           if(m_debug_xram_rsp_fsm)
    3232           {
    3233             std::cout << "  <MEMC " << name() << ".XRAM_RSP_IDLE> Available cache line in TRT:"
    3234                       << " index = " << std::dec << index << std::endl;
    3235           }
     3698if(m_debug)
     3699std::cout << "  <MEMC " << name() << " XRAM_RSP_IDLE>"
     3700          << " Available cache line in TRT:"
     3701          << " index = " << std::dec << index << std::endl;
    32363702#endif
    32373703          break;
     
    32413707    }
    32423708    ///////////////////////
    3243     case XRAM_RSP_DIR_LOCK:
    3244       // Takes the lock on the directory
    3245       // Takes the lock on TRT
    3246       // Copy the TRT entry in a local buffer
    3247     {
    3248       if((r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) &&
     3709    case XRAM_RSP_DIR_LOCK: // Takes the DIR lock and the TRT lock
     3710                            // Copy the TRT entry in a local buffer
     3711    {
     3712      if((r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
    32493713          (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP))
    32503714      {
    32513715        // copy the TRT entry in the r_xram_rsp_trt_buf local buffer
    32523716        size_t  index = r_xram_rsp_trt_index.read();
    3253 
    3254         TransactionTabEntry trt_entry(m_trt.read(index));
    3255         r_xram_rsp_trt_buf.copy(trt_entry);  // TRT entry local buffer
     3717        r_xram_rsp_trt_buf.copy( m_trt.read(index) );
    32563718
    32573719        r_xram_rsp_fsm = XRAM_RSP_TRT_COPY;
    32583720
    32593721#if DEBUG_MEMC_XRAM_RSP
    3260         if(m_debug_xram_rsp_fsm)
    3261         {
    3262           std::cout << "  <MEMC " << name() << ".XRAM_RSP_DIR_LOCK> Get access to directory" << std::endl;
    3263         }
     3722if(m_debug)
     3723std::cout << "  <MEMC " << name() << " XRAM_RSP_DIR_LOCK>"
     3724          << " Get access to DIR and TRT" << std::endl;
    32643725#endif
    32653726      }
     
    32673728    }
    32683729    ///////////////////////
    3269     case XRAM_RSP_TRT_COPY:
    3270       // Select a victim cache line
    3271     {
    3272       if((r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP))
     3730    case XRAM_RSP_TRT_COPY: // Select a victim cache line
     3731                            // and copy it in a local buffer
     3732    {
     3733      if ( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
     3734           (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) )
    32733735      {
    32743736        // selects & extracts a victim line from cache
    32753737        size_t way = 0;
    3276         size_t set = m_y[(vci_addr_t)(r_xram_rsp_trt_buf.nline * m_words * 4)];
     3738        size_t set = m_y[(addr_t)(r_xram_rsp_trt_buf.nline * m_words * 4)];
    32773739
    32783740        DirectoryEntry victim(m_cache_directory.select(set, way));
    32793741
    3280         bool inval = (victim.count && victim.valid) ;
     3742        bool inval = (victim.count and victim.valid) ;
    32813743
    32823744        // copy the victim line in a local buffer
     
    32843746
    32853747        r_xram_rsp_victim_copy      = victim.owner.srcid;
     3748
    32863749#if L1_MULTI_CACHE
    32873750        r_xram_rsp_victim_copy_cache= victim.owner.cache_id;
     
    33073770
    33083771#if DEBUG_MEMC_XRAM_RSP
    3309         if(m_debug_xram_rsp_fsm)
    3310         {
    3311           std::cout << "  <MEMC " << name() << ".XRAM_RSP_TRT_COPY> Select a slot: "
    3312                     << " way = " << std::dec << way
    3313                     << " / set = " << set
    3314                     << " / inval_required = " << inval << std::endl;
    3315         }
     3772if(m_debug)
     3773std::cout << "  <MEMC " << name() << " XRAM_RSP_TRT_COPY>"
     3774          << " Select a slot: "
     3775          << " way = " << std::dec << way
     3776          << " / set = " << set
     3777          << " / inval_required = " << inval << std::endl;
    33163778#endif
    33173779      }
    33183780      else
    33193781      {
    3320         std::cout << "VCI_MEM_CACHE ERROR "     << name()
    3321                   << " XRAM_RSP_TRT_COPY state" << std::endl
    3322                   << "bad TRT allocation"       << std::endl;
    3323 
     3782        std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_TRT_COPY"
     3783                  << " bad TRT or DIR allocation" << std::endl;
    33243784        exit(0);
    33253785      }
     
    33273787    }
    33283788    /////////////////////////
    3329     case XRAM_RSP_INVAL_LOCK: // check a possible pending inval
     3789    case XRAM_RSP_INVAL_LOCK: // Take the UPT lock to check a possible pending inval
    33303790    {
    33313791      if(r_alloc_upt_fsm == ALLOC_UPT_XRAM_RSP)
    33323792      {
    3333         size_t index;
    3334         if(m_upt.search_inval(r_xram_rsp_trt_buf.nline, index))
     3793        size_t index = 0;
     3794        if(m_upt.search_inval(r_xram_rsp_trt_buf.nline, index))  // pending inval
    33353795        {
    33363796          r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    33373797
    33383798#if DEBUG_MEMC_XRAM_RSP
    3339           if(m_debug_xram_rsp_fsm)
    3340           {
    3341             std::cout << "  <MEMC " << name() << ".XRAM_RSP_INVAL_LOCK> Get acces to UPT,"
    3342                       << " but an invalidation is already registered at this address" << std::endl;
    3343             m_upt.print();
    3344           }
    3345 #endif
    3346 
    3347         }
    3348         else if(m_upt.is_full() && r_xram_rsp_victim_inval.read())
     3799if(m_debug)
     3800std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
     3801          << " Get acces to UPT, but line invalidation registered"
     3802          << " / nline = " << std::hex << r_xram_rsp_trt_buf.nline
     3803          << " / index = " << std::dec << index << std::endl;
     3804#endif
     3805
     3806        }
     3807        else if(m_upt.is_full() and r_xram_rsp_victim_inval.read()) // UPT full
    33493808        {
    33503809          r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    33513810
    33523811#if DEBUG_MEMC_XRAM_RSP
    3353           if(m_debug_xram_rsp_fsm)
    3354           {
    3355             std::cout << "  <MEMC " << name() << ".XRAM_RSP_INVAL_LOCK> Get acces to UPT,"
    3356                       << " but the table is full" << std::endl;
    3357             m_upt.print();
    3358           }
     3812if(m_debug)
     3813std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
     3814          << " Get acces to UPT, but inval required and UPT full" << std::endl;
    33593815#endif
    33603816        }
     
    33643820
    33653821#if DEBUG_MEMC_XRAM_RSP
    3366           if(m_debug_xram_rsp_fsm)
    3367           {
    3368             std::cout << "  <MEMC " << name() << ".XRAM_RSP_INVAL_LOCK> Get acces to UPT" << std::endl;
    3369           }
     3822if(m_debug)
     3823std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
     3824          << " Get acces to UPT" << std::endl;
    33703825#endif
    33713826        }
     
    33743829    }
    33753830    /////////////////////////
    3376     case XRAM_RSP_INVAL_WAIT: // returns to DIR_LOCK to retry
    3377     {
     3831    case XRAM_RSP_INVAL_WAIT: // release all locks and returns to DIR_LOCK to retry
     3832    {
     3833
     3834#if DEBUG_MEMC_XRAM_RSP
     3835if(m_debug)
     3836std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_WAIT>"
     3837          << " Release all locks and retry" << std::endl;
     3838#endif
    33783839      r_xram_rsp_fsm = XRAM_RSP_DIR_LOCK;
    33793840      break;
     
    33813842    ///////////////////////
    33823843    case XRAM_RSP_DIR_UPDT:   // updates the cache (both data & directory)
    3383       // and possibly set an inval request in UPT
    3384     {
    3385       // signals generation
     3844                              // and possibly set an inval request in UPT
     3845    {
    33863846      // check if this is an instruction read, this means pktid is either
    33873847      // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
    33883848      // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
    3389       bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) && r_xram_rsp_trt_buf.proc_read;
     3849      bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) and r_xram_rsp_trt_buf.proc_read;
     3850
    33903851      // check if this is a cached read, this means pktid is either
    33913852      // TYPE_READ_DATA_MISS 0bX001 with TSAR encoding
    33923853      // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
    3393       bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) && r_xram_rsp_trt_buf.proc_read;
    3394 
    3395       // update data
     3854      bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) and r_xram_rsp_trt_buf.proc_read;
     3855
     3856      bool dirty = false;
     3857
     3858      // update cache data
    33963859      size_t set   = r_xram_rsp_victim_set.read();
    33973860      size_t way   = r_xram_rsp_victim_way.read();
     
    34003863        m_cache_data.write(way, set, word, r_xram_rsp_trt_buf.wdata[word]);
    34013864
     3865        dirty = dirty or (r_xram_rsp_trt_buf.wdata_be[word] != 0);
     3866
    34023867        if(m_monitor_ok)
    34033868        {
    3404           vci_addr_t address = r_xram_rsp_trt_buf.nline<<6 | word<<2;
    3405           check_monitor("XRAM_RSP_DIR_UPDT", address, r_xram_rsp_trt_buf.wdata[word]);
    3406         }
    3407       }
    3408       // compute dirty
    3409       bool dirty = false;
    3410       for(size_t i=0; i<m_words; i++) dirty = dirty || (r_xram_rsp_trt_buf.wdata_be[i] != 0);
    3411       // update directory
     3869          addr_t address = r_xram_rsp_trt_buf.nline<<6 | word<<2;
     3870          check_monitor("XRAM_RSP_DIR_UPDT", address, r_xram_rsp_trt_buf.wdata[word], false);
     3871        }
     3872      }
     3873
     3874      // update cache directory
    34123875      DirectoryEntry entry;
    34133876      entry.valid   = true;
     
    34373900      m_cache_directory.write(set, way, entry);
    34383901
     3902      // request an invalidattion request in UPT for victim line
    34393903      if(r_xram_rsp_victim_inval.read())
    34403904      {
    3441         bool   brdcast    = r_xram_rsp_victim_is_cnt.read();
    3442         size_t index    = 0;
    3443         size_t count_copies   = r_xram_rsp_victim_count.read();
     3905        bool   broadcast    = r_xram_rsp_victim_is_cnt.read();
     3906        size_t index        = 0;
     3907        size_t count_copies = r_xram_rsp_victim_count.read();
    34443908
    34453909        bool   wok = m_upt.set(false,      // it's an inval transaction
    3446                                       brdcast,  // set brdcast bit
    3447                                       false,    // it does not need a response
    3448                                       0,    // srcid
    3449                                       0,    // trdid
    3450                                       0,    // pktid
    3451                                       r_xram_rsp_victim_nline.read(),
    3452                                       count_copies,
    3453                                       index);
     3910                               broadcast,  // set broadcast bit
     3911                               false,      // no response required
     3912                               false,      // no acknowledge required
     3913                               0,          // srcid
     3914                               0,          // trdid
     3915                               0,          // pktid
     3916                               r_xram_rsp_victim_nline.read(),
     3917                               count_copies,
     3918                               index);
     3919
    34543920        r_xram_rsp_upt_index = index;
    34553921
    34563922        if(!wok)
    34573923        {
    3458           std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_HEAP_LAST state" << std::endl;
    3459           std::cout << "an update_tab entry was free but write is unsuccessful" << std::endl;
     3924          std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_DIR_UPDT"
     3925                    << " update_tab entry free but write unsuccessful" << std::endl;
    34603926          exit(0);
    34613927        }
     
    34633929
    34643930#if DEBUG_MEMC_XRAM_RSP
    3465       if(m_debug_xram_rsp_fsm)
    3466       {
    3467         std::cout << "  <MEMC " << name() << ".XRAM_RSP_DIR_UPDT> Directory update: "
    3468                   << " way = " << std::dec << way
    3469                   << " / set = " << set
    3470                   << " / owner_id = " << entry.owner.srcid
    3471                   << " / owner_ins = " << entry.owner.inst
    3472                   << " / count = " << entry.count
    3473                   << " / is_cnt = " << entry.is_cnt << std::endl;
    3474         if(r_xram_rsp_victim_inval.read())
    3475           std::cout << "                           Invalidation request for victim line "
    3476                     << std::hex << r_xram_rsp_victim_nline.read()
    3477                     << " / broadcast = " << r_xram_rsp_victim_is_cnt.read() << std::endl;
    3478       }
    3479 #endif
    3480 
    3481       // If the victim is not dirty, we don't need another XRAM  put transaction,
    3482       // and we canwe erase the TRT entry
     3931if(m_debug)
     3932{
     3933std::cout << "  <MEMC " << name() << " XRAM_RSP_DIR_UPDT>"
     3934          << " Cache update: "
     3935          << " way = " << std::dec << way
     3936          << " / set = " << set
     3937          << " / owner_id = " << std::hex << entry.owner.srcid
     3938          << " / owner_ins = " << std::dec << entry.owner.inst
     3939          << " / count = " << entry.count
     3940          << " / is_cnt = " << entry.is_cnt << std::endl;
     3941if(r_xram_rsp_victim_inval.read())
     3942std::cout << "                           Invalidation request for victim line "
     3943          << std::hex << r_xram_rsp_victim_nline.read()
     3944          << " / broadcast = " << r_xram_rsp_victim_is_cnt.read() << std::endl;
     3945}
     3946#endif
     3947
     3948      // If the victim is not dirty, we don't need another XRAM put transaction,
     3949      // and we can erase the TRT entry
    34833950      if(!r_xram_rsp_victim_dirty.read())  m_trt.erase(r_xram_rsp_trt_index.read());
    34843951
    34853952      // Next state
    34863953      if(r_xram_rsp_victim_dirty.read())       r_xram_rsp_fsm = XRAM_RSP_TRT_DIRTY;
    3487       else if(r_xram_rsp_trt_buf.proc_read)       r_xram_rsp_fsm = XRAM_RSP_DIR_RSP;
    3488       else if(r_xram_rsp_victim_inval.read())       r_xram_rsp_fsm = XRAM_RSP_INVAL;
    3489       else                                            r_xram_rsp_fsm = XRAM_RSP_IDLE;
     3954      else if(r_xram_rsp_trt_buf.proc_read)    r_xram_rsp_fsm = XRAM_RSP_DIR_RSP;
     3955      else if(r_xram_rsp_victim_inval.read())  r_xram_rsp_fsm = XRAM_RSP_INVAL;
     3956      else                                     r_xram_rsp_fsm = XRAM_RSP_IDLE;
    34903957      break;
    34913958    }
    34923959    ////////////////////////
    3493     case XRAM_RSP_TRT_DIRTY:  // set the TRT entry (write to XRAM) if the victim is dirty
     3960    case XRAM_RSP_TRT_DIRTY:  // set the TRT entry (PUT to XRAM) if the victim is dirty
    34943961    {
    34953962      if(r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP)
     
    35083975
    35093976#if DEBUG_MEMC_XRAM_RSP
    3510         if(m_debug_xram_rsp_fsm)
    3511         {
    3512           std::cout << "  <MEMC " << name() << ".XRAM_RSP_TRT_DIRTY> Set TRT entry for the put transaction:"
    3513                     << " dirty victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
    3514         }
    3515 #endif
    3516         if(r_xram_rsp_trt_buf.proc_read)       r_xram_rsp_fsm = XRAM_RSP_DIR_RSP;
    3517         else if(r_xram_rsp_victim_inval.read())       r_xram_rsp_fsm = XRAM_RSP_INVAL;
    3518         else                                            r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
     3977if(m_debug)
     3978std::cout << "  <MEMC " << name() << " XRAM_RSP_TRT_DIRTY>"
     3979          << " Set TRT entry for the put transaction"
     3980          << " / dirty victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
     3981#endif
     3982        if(r_xram_rsp_trt_buf.proc_read)         r_xram_rsp_fsm = XRAM_RSP_DIR_RSP;
     3983        else if(r_xram_rsp_victim_inval.read())  r_xram_rsp_fsm = XRAM_RSP_INVAL;
     3984        else                                     r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
    35193985      }
    35203986      break;
     
    35283994        r_xram_rsp_to_tgt_rsp_trdid = r_xram_rsp_trt_buf.trdid;
    35293995        r_xram_rsp_to_tgt_rsp_pktid = r_xram_rsp_trt_buf.pktid;
    3530         for(size_t i=0; i < m_words; i++) r_xram_rsp_to_tgt_rsp_data[i] = r_xram_rsp_trt_buf.wdata[i];
     3996        for(size_t i=0; i < m_words; i++)
     3997        {
     3998            r_xram_rsp_to_tgt_rsp_data[i] = r_xram_rsp_trt_buf.wdata[i];
     3999        }
    35314000        r_xram_rsp_to_tgt_rsp_word   = r_xram_rsp_trt_buf.word_index;
    35324001        r_xram_rsp_to_tgt_rsp_length = r_xram_rsp_trt_buf.read_length;
     
    35354004        r_xram_rsp_to_tgt_rsp_req    = true;
    35364005
    3537         if(r_xram_rsp_victim_inval) r_xram_rsp_fsm = XRAM_RSP_INVAL;
     4006        if(r_xram_rsp_victim_inval)      r_xram_rsp_fsm = XRAM_RSP_INVAL;
    35384007        else if(r_xram_rsp_victim_dirty) r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
    3539         else                                r_xram_rsp_fsm = XRAM_RSP_IDLE;
    3540 
     4008        else                             r_xram_rsp_fsm = XRAM_RSP_IDLE;
    35414009
    35424010#if DEBUG_MEMC_XRAM_RSP
    3543         if(m_debug_xram_rsp_fsm)
    3544         {
    3545           std::cout << "  <MEMC " << name() << ".XRAM_RSP_DIR_RSP> Request the TGT_RSP FSM to return data:"
    3546                     << " rsrcid = " << std::dec << r_xram_rsp_trt_buf.srcid
    3547                     << " / address = " << std::hex << r_xram_rsp_trt_buf.nline*m_words*4
    3548                     << " / nwords = " << std::dec << r_xram_rsp_trt_buf.read_length << std::endl;
    3549         }
     4011if(m_debug)
     4012std::cout << "  <MEMC " << name() << " XRAM_RSP_DIR_RSP>"
     4013          << " Request the TGT_RSP FSM to return data:"
     4014          << " rsrcid = " << std::hex << r_xram_rsp_trt_buf.srcid
     4015          << " / address = " << std::hex << r_xram_rsp_trt_buf.nline*m_words*4
     4016          << " / nwords = " << std::dec << r_xram_rsp_trt_buf.read_length << std::endl;
    35504017#endif
    35514018      }
     
    35554022    case XRAM_RSP_INVAL:  // send invalidate request to CC_SEND FSM
    35564023    {
    3557       if(!r_xram_rsp_to_cc_send_multi_req.read() &&
     4024      if(!r_xram_rsp_to_cc_send_multi_req.read() and
    35584025          !r_xram_rsp_to_cc_send_brdcast_req.read())
    35594026      {
    35604027        bool multi_req = !r_xram_rsp_victim_is_cnt.read();
    3561         bool last_multi_req  = multi_req && (r_xram_rsp_victim_count.read() == 1);
    3562         bool not_last_multi_req = multi_req && (r_xram_rsp_victim_count.read() != 1);
     4028        bool last_multi_req  = multi_req and (r_xram_rsp_victim_count.read() == 1);
     4029        bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1);
    35634030
    35644031        r_xram_rsp_to_cc_send_multi_req    = last_multi_req;
     
    35754042
    35764043        if(r_xram_rsp_victim_dirty)  r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
    3577         else if(not_last_multi_req)    r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ;
    3578         else                            r_xram_rsp_fsm = XRAM_RSP_IDLE;
     4044        else if(not_last_multi_req)  r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ;
     4045        else                         r_xram_rsp_fsm = XRAM_RSP_IDLE;
    35794046
    35804047#if DEBUG_MEMC_XRAM_RSP
    3581         if(m_debug_xram_rsp_fsm)
    3582         {
    3583           std::cout << "  <MEMC " << name() << ".XRAM_RSP_INVAL> Send an inval request to CC_SEND FSM:"
    3584                     << " victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
    3585         }
     4048if(m_debug)
     4049std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL>"
     4050          << " Send an inval request to CC_SEND FSM"
     4051          << " / victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
    35864052#endif
    35874053      }
     
    35964062        r_xram_rsp_to_ixr_cmd_nline = r_xram_rsp_victim_nline.read();
    35974063        r_xram_rsp_to_ixr_cmd_trdid = r_xram_rsp_trt_index.read();
    3598         for(size_t i=0; i<m_words ; i++) r_xram_rsp_to_ixr_cmd_data[i] = r_xram_rsp_victim_data[i];
     4064        for(size_t i=0; i<m_words ; i++)
     4065        {
     4066            r_xram_rsp_to_ixr_cmd_data[i] = r_xram_rsp_victim_data[i];
     4067        }
    35994068        m_cpt_write_dirty++;
    36004069
    3601         bool multi_req = !r_xram_rsp_victim_is_cnt.read() && r_xram_rsp_victim_inval.read();
    3602         bool not_last_multi_req = multi_req && (r_xram_rsp_victim_count.read() != 1);
     4070        bool multi_req = !r_xram_rsp_victim_is_cnt.read() and r_xram_rsp_victim_inval.read();
     4071        bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1);
     4072
    36034073        if(not_last_multi_req)   r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ;
    3604         else                        r_xram_rsp_fsm = XRAM_RSP_IDLE;
     4074        else                     r_xram_rsp_fsm = XRAM_RSP_IDLE;
    36054075
    36064076#if DEBUG_MEMC_XRAM_RSP
    3607         if(m_debug_xram_rsp_fsm)
    3608         {
    3609           std::cout << "  <MEMC " << name() << ".XRAM_RSP_WRITE_DIRTY> Send the put request to IXR_CMD FSM:"
    3610                     << " victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
    3611         }
    3612 #endif
    3613       }
    3614       break;
    3615     }
    3616 
     4077if(m_debug)
     4078std::cout << "  <MEMC " << name() << " XRAM_RSP_WRITE_DIRTY>"
     4079          << " Send the put request to IXR_CMD FSM"
     4080          << " / victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
     4081#endif
     4082      }
     4083      break;
     4084    }
    36174085    /////////////////////////
    3618     case XRAM_RSP_HEAP_REQ:
    3619       // Get the lock to the HEAP directory
     4086    case XRAM_RSP_HEAP_REQ:    // Get the lock to the HEAP
    36204087    {
    36214088      if(r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP)
     
    36254092
    36264093#if DEBUG_MEMC_XRAM_RSP
    3627       if(m_debug_xram_rsp_fsm)
    3628       {
    3629         std::cout
    3630             << "  <MEMC " << name() << ".XRAM_RSP_HEAP_REQ> Requesting HEAP lock "
    3631             << std::endl;
    3632       }
    3633 #endif
    3634       break;
    3635     }
    3636 
     4094if(m_debug)
     4095std::cout << "  <MEMC " << name() << " XRAM_RSP_HEAP_REQ>"
     4096          << " Requesting HEAP lock" << std::endl;
     4097#endif
     4098      break;
     4099    }
    36374100    /////////////////////////
    3638     case XRAM_RSP_HEAP_ERASE: // erase the list of copies and sent invalidations
     4101    case XRAM_RSP_HEAP_ERASE: // erase the copies and send invalidations
    36394102    {
    36404103      if(r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP)
     
    36674130
    36684131#if DEBUG_MEMC_XRAM_RSP
    3669         if(m_debug_xram_rsp_fsm)
    3670         {
    3671           std::cout << "  <MEMC " << name() << ".XRAM_RSP_HEAP_ERASE> Erase the list of copies:"
    3672                     << " srcid = " << std::dec << entry.owner.srcid
    3673                     << " / inst = " << std::dec << entry.owner.inst << std::endl;
    3674         }
     4132if(m_debug)
     4133std::cout << "  <MEMC " << name() << " XRAM_RSP_HEAP_ERASE>"
     4134          << " Erase copy:"
     4135          << " srcid = " << std::hex << entry.owner.srcid
     4136          << " / inst = " << std::dec << entry.owner.inst << std::endl;
    36754137#endif
    36764138      }
     
    36784140    }
    36794141    /////////////////////////
    3680     case XRAM_RSP_HEAP_LAST:  // last member of the list
     4142    case XRAM_RSP_HEAP_LAST:  // last copy
    36814143    {
    36824144      if(r_alloc_heap_fsm.read() != ALLOC_HEAP_XRAM_RSP)
    36834145      {
    3684         std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_HEAP_LAST state" << std::endl;
    3685         std::cout << "bad HEAP allocation" << std::endl;
     4146        std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_HEAP_LAST"
     4147                   << " bad HEAP allocation" << std::endl;
    36864148        exit(0);
    36874149      }
     
    37104172
    37114173#if DEBUG_MEMC_XRAM_RSP
    3712       if(m_debug_xram_rsp_fsm)
    3713       {
    3714         std::cout << "  <MEMC " << name() << ".XRAM_RSP_HEAP_LAST> Heap housekeeping" << std::endl;
    3715       }
     4174if(m_debug)
     4175std::cout << "  <MEMC " << name() << " XRAM_RSP_HEAP_LAST>"
     4176          << " Heap housekeeping" << std::endl;
    37164177#endif
    37174178      break;
     
    37244185      // Next state
    37254186      if(r_xram_rsp_trt_buf.proc_read) r_xram_rsp_fsm = XRAM_RSP_ERROR_RSP;
    3726       else                                 r_xram_rsp_fsm = XRAM_RSP_IDLE;
     4187      else                             r_xram_rsp_fsm = XRAM_RSP_IDLE;
    37274188
    37284189#if DEBUG_MEMC_XRAM_RSP
    3729       if(m_debug_xram_rsp_fsm)
    3730       {
    3731         std::cout << "  <MEMC " << name() << ".XRAM_RSP_ERROR_ERASE> Error reported by XRAM / erase the TRT entry" << std::endl;
    3732       }
     4190if(m_debug)
     4191std::cout << "  <MEMC " << name() << " XRAM_RSP_ERROR_ERASE>"
     4192          << " Error reported by XRAM / erase the TRT entry" << std::endl;
    37334193#endif
    37344194      break;
     
    37424202        r_xram_rsp_to_tgt_rsp_trdid  = r_xram_rsp_trt_buf.trdid;
    37434203        r_xram_rsp_to_tgt_rsp_pktid  = r_xram_rsp_trt_buf.pktid;
    3744         for(size_t i=0; i < m_words; i++) r_xram_rsp_to_tgt_rsp_data[i] = r_xram_rsp_trt_buf.wdata[i];
     4204        for(size_t i=0; i < m_words; i++)
     4205        {
     4206            r_xram_rsp_to_tgt_rsp_data[i] = r_xram_rsp_trt_buf.wdata[i];
     4207        }
    37454208        r_xram_rsp_to_tgt_rsp_word   = r_xram_rsp_trt_buf.word_index;
    37464209        r_xram_rsp_to_tgt_rsp_length = r_xram_rsp_trt_buf.read_length;
     
    37514214
    37524215#if DEBUG_MEMC_XRAM_RSP
    3753         if(m_debug_xram_rsp_fsm)
    3754         {
    3755           std::cout << "  <MEMC " << name() << ".XRAM_RSP_ERROR_RSP> Request a response error to TGT_RSP FSM:"
    3756                     << " srcid = " << std::dec << r_xram_rsp_trt_buf.srcid << std::endl;
    3757         }
     4216if(m_debug)
     4217std::cout << "  <MEMC " << name()
     4218          << " XRAM_RSP_ERROR_RSP> Request a response error to TGT_RSP FSM:"
     4219          << " srcid = " << std::dec << r_xram_rsp_trt_buf.srcid << std::endl;
    37584220#endif
    37594221      }
     
    37714233  switch(r_cleanup_fsm.read())
    37724234  {
    3773     case CLEANUP_IDLE:
    3774     {
    3775       // Get first DSPIN flit of the CLEANUP command
     4235    //////////////////
     4236    case CLEANUP_IDLE:     // Get first DSPIN flit of the CLEANUP command
     4237    {
    37764238      if(not m_cc_receive_to_cleanup_fifo.rok()) break;
    37774239
     
    37964258        DspinDhccpParam::dspin_get(
    37974259            flit,
    3798             DspinDhccpParam::CLEANUP_NLINE_MSB)
    3799         << 32;
     4260            DspinDhccpParam::CLEANUP_NLINE_MSB) << 32;
    38004261
    38014262      r_cleanup_inst  = (type == DspinDhccpParam::TYPE_CLEANUP_INST);
     
    38144275      m_cpt_cleanup++;
    38154276      cc_receive_to_cleanup_fifo_get = true;
    3816       r_cleanup_fsm                 = CLEANUP_GET_NLINE;
     4277      r_cleanup_fsm                  = CLEANUP_GET_NLINE;
    38174278
    38184279#if DEBUG_MEMC_CLEANUP
    3819       if(m_debug_cleanup_fsm)
    3820       {
    3821         std::cout
    3822             << "  <MEMC "         << name()
    3823             << ".CLEANUP_IDLE> Cleanup request:" << std::hex
    3824             << " / owner_id = "   << srcid
    3825             << " / owner_ins = "  << (type == DspinDhccpParam::TYPE_CLEANUP_INST)
    3826             << std::endl;
    3827       }
    3828 #endif
    3829       break;
    3830     }
    3831 
    3832     case CLEANUP_GET_NLINE:
    3833     {
    3834       // Get second flit of cleanup command
     4280if(m_debug)
     4281std::cout << "  <MEMC "         << name()
     4282          << " CLEANUP_IDLE> Cleanup request:" << std::hex
     4283          << " / owner_id = "   << srcid
     4284          << " / owner_ins = "  << (type == DspinDhccpParam::TYPE_CLEANUP_INST) << std::endl;
     4285#endif
     4286      break;
     4287    }
     4288
     4289    ///////////////////////
     4290    case CLEANUP_GET_NLINE:  // GET second DSPIN flit of the cleanup command
     4291    {
    38354292      if(not m_cc_receive_to_cleanup_fifo.rok()) break;
    38364293
    38374294      uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
    38384295
    3839       addr_t nline =
    3840         r_cleanup_nline.read() |
     4296      addr_t nline = r_cleanup_nline.read() |
    38414297        DspinDhccpParam::dspin_get(flit, DspinDhccpParam::CLEANUP_NLINE_LSB);
    38424298
    3843       bool eop =
    3844         DspinDhccpParam::dspin_get(flit, DspinDhccpParam::FROM_L1_EOP) == 0x1;
    3845 
    3846       assert(
    3847           eop &&
    3848           "VCI_MEM_CACHE ERROR: "
    3849           "CLEANUP command must have exactly two flits");
    3850 
    38514299      cc_receive_to_cleanup_fifo_get = true;
    3852       r_cleanup_nline               = nline;
    3853       r_cleanup_fsm                 = CLEANUP_DIR_REQ;
     4300      r_cleanup_nline                = nline;
     4301      r_cleanup_fsm                  = CLEANUP_DIR_REQ;
    38544302
    38554303#if DEBUG_MEMC_CLEANUP
    3856       if(m_debug_cleanup_fsm)
    3857       {
    3858         std::cout
    3859             << "  <MEMC "         << name()
    3860             << ".CLEANUP_GET_NLINE> Cleanup request:"
    3861             << std::hex
    3862             << " / address = "    << nline * m_words * 4
    3863             << std::endl;
    3864       }
    3865 #endif
    3866       break;
    3867     }
    3868 
    3869     case CLEANUP_DIR_REQ:
    3870     {
    3871       // Get the lock to the directory
     4304if(m_debug)
     4305std::cout << "  <MEMC "         << name()
     4306          << " CLEANUP_GET_NLINE> Cleanup request:"
     4307          << " / address = " << std::hex << nline * m_words * 4 << std::endl;
     4308#endif
     4309      break;
     4310    }
     4311
     4312    /////////////////////
     4313    case CLEANUP_DIR_REQ:   // Get the lock to the directory
     4314    {
    38724315      if(r_alloc_dir_fsm.read() != ALLOC_DIR_CLEANUP) break;
    38734316
     
    38754318
    38764319#if DEBUG_MEMC_CLEANUP
    3877       if(m_debug_cleanup_fsm)
    3878       {
    3879         std::cout
    3880             << "  <MEMC " << name() << ".CLEANUP_DIR_REQ> Requesting DIR lock "
    3881             << std::endl;
    3882       }
    3883 #endif
    3884       break;
    3885     }
    3886 
     4320if(m_debug)
     4321std::cout << "  <MEMC " << name() << " CLEANUP_DIR_REQ> Requesting DIR lock" << std::endl;
     4322#endif
     4323      break;
     4324    }
     4325
     4326    //////////////////////
    38874327    case CLEANUP_DIR_LOCK:
    38884328    {
     
    39164356#endif
    39174357
    3918       // hit :
    3919       // the copy must be cleared
    3920       if(entry.valid)
     4358      if(entry.valid)      // hit : the copy must be cleared
    39214359      {
    39224360        assert(
    3923             (entry.count > 0) &&
     4361            (entry.count > 0) and
    39244362            "VCI MEM CACHE ERROR: "
    39254363            "In CLEANUP_DIR_LOCK, CLEANUP command on a valid entry "
     
    39274365
    39284366        // no access to the heap
    3929         if((entry.count == 1) || (entry.is_cnt))
     4367        if((entry.count == 1) or (entry.is_cnt))
    39304368        {
    39314369          r_cleanup_fsm = CLEANUP_DIR_WRITE;
     
    39374375        }
    39384376      }
    3939       // miss :
    3940       // we must check the update table for a pending
    3941       // invalidation transaction
    3942       else
     4377      else                // miss : check UPT for a pending invalidation transaction
    39434378      {
    39444379        r_cleanup_fsm = CLEANUP_UPT_LOCK;
     
    39464381
    39474382#if DEBUG_MEMC_CLEANUP
    3948       if(m_debug_cleanup_fsm)
     4383      if(m_debug)
    39494384      {
    39504385        std::cout
    39514386            << "  <MEMC " << name()
    3952             << ".CLEANUP_DIR_LOCK> Test directory status: "
     4387            << " CLEANUP_DIR_LOCK> Test directory status: "
    39534388            << std::hex
    39544389            << " line = "         << cleanup_address
     
    39664401    }
    39674402
     4403    ///////////////////////
    39684404    case CLEANUP_DIR_WRITE:
    39694405    {
     
    39804416
    39814417      size_t way         = r_cleanup_way.read();
    3982       size_t set         = m_y[(vci_addr_t)(r_cleanup_nline.read()*m_words*4)];
     4418      size_t set         = m_y[(addr_t)(r_cleanup_nline.read()*m_words*4)];
    39834419      bool   match_srcid = (r_cleanup_copy.read() == r_cleanup_srcid.read());
    39844420
     
    39884424
    39894425      bool   match_inst  = (r_cleanup_copy_inst.read() == r_cleanup_inst.read());
    3990       bool   match       = match_srcid && match_inst;
     4426      bool   match       = match_srcid and match_inst;
    39914427
    39924428      if(not r_cleanup_is_cnt.read() and not match)
     
    40194455      m_cache_directory.write(set, way, entry);
    40204456
    4021       r_cleanup_fsm = CLEANUP_SEND_ACK;
     4457      r_cleanup_fsm = CLEANUP_SEND_CLACK;
    40224458
    40234459#if DEBUG_MEMC_CLEANUP
    4024       if(m_debug_cleanup_fsm)
     4460      if(m_debug)
    40254461      {
    40264462        std::cout
    40274463            << "  <MEMC " << name()
    4028             << ".CLEANUP_DIR_WRITE> Update directory:"
     4464            << " CLEANUP_DIR_WRITE> Update directory:"
    40294465            << std::hex
    40304466            << " address = "   << r_cleanup_nline.read() * m_words * 4
     
    40404476    }
    40414477
     4478    //////////////////////
    40424479    case CLEANUP_HEAP_REQ:
    40434480    {
     
    40484485
    40494486#if DEBUG_MEMC_CLEANUP
    4050       if(m_debug_cleanup_fsm)
     4487      if(m_debug)
    40514488      {
    40524489        std::cout
    40534490            << "  <MEMC " << name()
    4054             << ".CLEANUP_HEAP_REQ> HEAP lock acquired "
     4491            << " CLEANUP_HEAP_REQ> HEAP lock acquired "
    40554492            << std::endl;
    40564493      }
     
    40594496    }
    40604497
     4498    //////////////////////
    40614499    case CLEANUP_HEAP_LOCK:
    40624500    {
     
    40754513
    40764514      size_t way            = r_cleanup_way.read();
    4077       size_t set            = m_y[(vci_addr_t)(r_cleanup_nline.read() *m_words*4)];
     4515      size_t set            = m_y[(addr_t)(r_cleanup_nline.read() *m_words*4)];
    40784516
    40794517      HeapEntry heap_entry  = m_heap.read(r_cleanup_ptr.read());
     
    42004638
    42014639#if DEBUG_MEMC_CLEANUP
    4202       if(m_debug_cleanup_fsm)
     4640      if(m_debug)
    42034641      {
    42044642        std::cout
    42054643            << "  <MEMC " << name()
    4206             << ".CLEANUP_HEAP_LOCK> Checks matching:"
     4644            << " CLEANUP_HEAP_LOCK> Checks matching:"
    42074645            << " address = "      << r_cleanup_nline.read() * m_words * 4
    42084646            << " / dir_id = "     << r_cleanup_copy.read()
     
    42184656    }
    42194657
     4658    ////////////////////////
    42204659    case CLEANUP_HEAP_SEARCH:
    42214660    {
     
    42374676      bool match_heap_srcid = (heap_entry.owner.srcid == r_cleanup_srcid.read());
    42384677      bool match_heap_inst  = (heap_entry.owner.inst  == r_cleanup_inst.read());
    4239       bool match_heap       = match_heap_srcid && match_heap_inst;
     4678      bool match_heap       = match_heap_srcid and match_heap_inst;
    42404679
    42414680#if L1_MULTI_CACHE
     
    42774716
    42784717#if DEBUG_MEMC_CLEANUP
    4279       if(m_debug_cleanup_fsm)
     4718      if(m_debug)
    42804719      {
    42814720        if(not match_heap)
     
    42834722          std::cout
    42844723              << "  <MEMC " << name()
    4285               << ".CLEANUP_HEAP_SEARCH> Matching copy not found, search next:"
     4724              << " CLEANUP_HEAP_SEARCH> Matching copy not found, search next:"
    42864725              << std::endl;
    42874726        }
     
    42904729          std::cout
    42914730              << "  <MEMC " << name()
    4292               << ".CLEANUP_HEAP_SEARCH> Matching copy found:"
     4731              << " CLEANUP_HEAP_SEARCH> Matching copy found:"
    42934732              << std::endl;
    42944733        }
     
    43064745      break;
    43074746    }
    4308 
    4309     case CLEANUP_HEAP_CLEAN:
    4310     {
    4311       // remove a copy in the linked list
     4747    ////////////////////////
     4748    case CLEANUP_HEAP_CLEAN:    // remove a copy in the linked list
     4749    {
    43124750      if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    43134751      {
     
    43464784
    43474785#if DEBUG_MEMC_CLEANUP
    4348       if(m_debug_cleanup_fsm)
    4349       {
    4350         std::cout
    4351             << "  <MEMC " << name()
    4352             << ".CLEANUP_HEAP_SEARCH> Remove the copy in the linked list"
    4353             << std::endl;
    4354       }
    4355 #endif
    4356       break;
    4357     }
    4358 
    4359     case CLEANUP_HEAP_FREE:
    4360     {
    4361       // The heap entry pointed by r_cleanup_next_ptr is freed
    4362       // and becomes the head of the list of free entries
     4786if(m_debug)
     4787std::cout << "  <MEMC " << name() << " CLEANUP_HEAP_SEARCH>"
     4788          << " Remove the copy in the linked list" << std::endl;
     4789#endif
     4790      break;
     4791    }
     4792    ///////////////////////
     4793    case CLEANUP_HEAP_FREE:   // The heap entry pointed by r_cleanup_next_ptr is freed
     4794                              // and becomes the head of the list of free entries
     4795    {
    43634796      if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    43644797      {
     
    43924825      m_heap.unset_full();
    43934826
    4394       r_cleanup_fsm = CLEANUP_SEND_ACK;
     4827      r_cleanup_fsm = CLEANUP_SEND_CLACK;
    43954828
    43964829#if DEBUG_MEMC_CLEANUP
    4397       if(m_debug_cleanup_fsm)
    4398       {
    4399         std::cout
    4400             << "  <MEMC " << name()
    4401             << ".CLEANUP_HEAP_SEARCH> Update the list of free entries"
    4402             << std::endl;
    4403       }
    4404 #endif
    4405       break;
    4406     }
    4407 
    4408     case CLEANUP_UPT_LOCK:
    4409     {
    4410       // search pending invalidate transaction matching the Cleanup NLINE in the UPDATE TABLE
    4411       // get the lock in the UPDATE_TABLE
     4830if(m_debug)
     4831std::cout << "  <MEMC " << name() << " CLEANUP_HEAP_FREE>"
     4832          << " Update the list of free entries" << std::endl;
     4833#endif
     4834      break;
     4835    }
     4836    //////////////////////
     4837    case CLEANUP_UPT_LOCK:   // get the lock protecting the UPT to search a pending
     4838                             // invalidate transaction matching the cleanup
     4839    {
    44124840      if(r_alloc_upt_fsm.read() != ALLOC_UPT_CLEANUP) break;
    44134841
     
    44174845      match_inval = m_upt.search_inval(r_cleanup_nline.read(), index);
    44184846
    4419       // no pending inval
    4420       if(not match_inval)
    4421       {
    4422         r_cleanup_fsm = CLEANUP_SEND_ACK;
     4847      if ( not match_inval )     // no pending inval
     4848      {
     4849          r_cleanup_fsm = CLEANUP_SEND_CLACK;
    44234850
    44244851#if DEBUG_MEMC_CLEANUP
    4425         if(m_debug_cleanup_fsm)
    4426         {
    4427           std::cout
    4428               << "  <MEMC " << name()
    4429               << ".CLEANUP_UPT_LOCK> Unexpected cleanup"
    4430               << " with no corresponding UPT entry:"
    4431               << " address = " << std::hex
    4432               << (r_cleanup_nline.read() *4*m_words)
    4433               << std::endl;
    4434         }
    4435 #endif
    4436         break;
     4852if(m_debug)
     4853std::cout << "  <MEMC " << name()
     4854          << " CLEANUP_UPT_LOCK> Unexpected cleanup"
     4855          << " with no corresponding UPT entry:"
     4856          << " address = " << std::hex
     4857          << (r_cleanup_nline.read() *4*m_words)
     4858          << std::endl;
     4859#endif
     4860          break;
    44374861      }
    44384862
    44394863      // pending inval
    4440       r_cleanup_write_srcid    = m_upt.srcid(index);
    4441       r_cleanup_write_trdid    = m_upt.trdid(index);
    4442       r_cleanup_write_pktid    = m_upt.pktid(index);
    4443       r_cleanup_write_need_rsp = m_upt.need_rsp(index);
    4444       r_cleanup_index          = index;
     4864      r_cleanup_write_srcid = m_upt.srcid(index);
     4865      r_cleanup_write_trdid = m_upt.trdid(index);
     4866      r_cleanup_write_pktid = m_upt.pktid(index);
     4867      r_cleanup_need_rsp    = m_upt.need_rsp(index);
     4868      r_cleanup_need_ack    = m_upt.need_ack(index);
     4869      r_cleanup_index       = index;
    44454870
    44464871      r_cleanup_fsm         = CLEANUP_UPT_DECREMENT;
    44474872
    44484873#if DEBUG_MEMC_CLEANUP
    4449       if(m_debug_cleanup_fsm)
    4450       {
    4451         std::cout
    4452             << "  <MEMC " << name()
    4453             << ".CLEANUP_UPT_LOCK> Cleanup matching pending"
    4454             << " invalidate transaction on UPT:"
    4455             << std::hex
    4456             << " address = "   << r_cleanup_nline.read() * m_words * 4
    4457             << " upt_entry = " << index
    4458             << std::endl;
    4459       }
    4460 #endif
    4461       break;
    4462     }
    4463 
    4464     case CLEANUP_UPT_DECREMENT:
    4465     {
    4466       // decrement response counter in UPT matching entry
     4874if(m_debug)
     4875std::cout << "  <MEMC " << name()
     4876          << " CLEANUP_UPT_LOCK> Cleanup matching pending"
     4877          << " invalidate transaction on UPT:"
     4878          << " address = " << std::hex << r_cleanup_nline.read() * m_words * 4
     4879          << " / upt_entry = " << index << std::endl;
     4880#endif
     4881      break;
     4882    }
     4883    ///////////////////////////
     4884    case CLEANUP_UPT_DECREMENT:   // decrement response counter in UPT matching entry
     4885    {
    44674886      if(r_alloc_upt_fsm.read() != ALLOC_UPT_CLEANUP)
    44684887      {
     
    44794898      m_upt.decrement(r_cleanup_index.read(), count);
    44804899
    4481       // invalidation transaction finished
    4482       // (all acknowledgements received)
    4483       if(count == 0)
     4900      if(count == 0)   // multi inval transaction completed
    44844901      {
    44854902        r_cleanup_fsm = CLEANUP_UPT_CLEAR;
    44864903      }
    4487       // invalidation transaction not finished
    4488       else
    4489       {
    4490         r_cleanup_fsm = CLEANUP_SEND_ACK ;
     4904      else             // multi inval transaction not completed
     4905      {
     4906        r_cleanup_fsm = CLEANUP_SEND_CLACK ;
    44914907      }
    44924908
    44934909#if DEBUG_MEMC_CLEANUP
    4494       if(m_debug_cleanup_fsm)
    4495       {
    4496         std::cout
    4497             << "  <MEMC "      << name()
    4498             << ".CLEANUP_UPT_DECREMENT> Decrement response counter in UPT:"
     4910if(m_debug)
     4911std::cout << "  <MEMC " << name() << " CLEANUP_UPT_DECREMENT>"
     4912          << " Decrement response counter in UPT:"
    44994913            << " UPT_index = " << r_cleanup_index.read()
    4500             << " rsp_count = " << count
    4501             << std::endl;
    4502       }
    4503 #endif
    4504       break;
    4505     }
    4506 
    4507     case CLEANUP_UPT_CLEAR:
    4508     {
    4509       // Clear UPT entry of finished invalidation transaction
     4914            << " / rsp_count = " << count << std::endl;
     4915#endif
     4916      break;
     4917    }
     4918    ///////////////////////
     4919    case CLEANUP_UPT_CLEAR:    // Clear UPT entry
     4920    {
    45104921      if(r_alloc_upt_fsm.read() != ALLOC_UPT_CLEANUP)
    45114922      {
     
    45214932      m_upt.clear(r_cleanup_index.read());
    45224933
    4523       if(r_cleanup_write_need_rsp.read())
    4524       {
    4525         r_cleanup_fsm = CLEANUP_WRITE_RSP;
    4526       }
    4527       else
    4528       {
    4529         r_cleanup_fsm = CLEANUP_SEND_ACK;
    4530       }
     4934      if      ( r_cleanup_need_rsp.read() ) r_cleanup_fsm = CLEANUP_WRITE_RSP;
     4935      else if ( r_cleanup_need_ack.read() ) r_cleanup_fsm = CLEANUP_CONFIG_ACK;
     4936      else                                  r_cleanup_fsm = CLEANUP_SEND_CLACK;
    45314937
    45324938#if DEBUG_MEMC_CLEANUP
    4533       if(m_debug_cleanup_fsm)
    4534       {
    4535         std::cout
    4536             << "  <MEMC "      << name()
    4537             << ".CLEANUP_UPT_CLEAR> Clear entry in UPT:"
    4538             << " UPT_index = " << r_cleanup_index.read()
    4539             << std::endl;
    4540       }
    4541 #endif
    4542       break;
    4543     }
    4544 
    4545     case CLEANUP_WRITE_RSP:
    4546     {
    4547       // response to a previous write on the direct network
    4548       // wait if pending request to the TGT_RSP FSM
     4939if(m_debug)
     4940std::cout << "  <MEMC "      << name()
     4941          << " CLEANUP_UPT_CLEAR> Clear entry in UPT:"
     4942          << " UPT_index = " << r_cleanup_index.read() << std::endl;
     4943#endif
     4944      break;
     4945    }
     4946    ///////////////////////
     4947    case CLEANUP_WRITE_RSP:    // response to a previous write on the direct network
     4948                               // wait if pending request to the TGT_RSP FSM
     4949    {
    45494950      if(r_cleanup_to_tgt_rsp_req.read()) break;
    45504951
     
    45554956      r_cleanup_to_tgt_rsp_pktid   = r_cleanup_write_pktid.read();
    45564957
    4557       r_cleanup_fsm                = CLEANUP_SEND_ACK;
     4958      r_cleanup_fsm                = CLEANUP_SEND_CLACK;
    45584959
    45594960#if DEBUG_MEMC_CLEANUP
    4560       if(m_debug_cleanup_fsm)
    4561       {
    4562         std::cout
    4563             << "  <MEMC " << name()
    4564             << ".CLEANUP_WRITE_RSP> Send a response to a previous"
    4565             << " write request waiting for coherence transaction completion: "
    4566             << " rsrcid = "   << std::dec << r_cleanup_write_srcid.read()
    4567             << " / rtrdid = " << std::dec << r_cleanup_write_trdid.read()
    4568             << std::endl;
    4569       }
    4570 #endif
    4571       break;
    4572     }
    4573 
    4574     case CLEANUP_SEND_ACK:
    4575     {
    4576       // acknowledgement to a cleanup command
    4577       // on the coherence network (request to the CC_SEND FSM).
    4578       // wait if pending request to the CC_SEND FSM
     4961if(m_debug)
     4962std::cout << "  <MEMC " << name() << " CLEANUP_WRITE_RSP>"
     4963          << " Send a response to a previous write request: "
     4964          << " rsrcid = "   << std::hex << r_cleanup_write_srcid.read()
     4965          << " / rtrdid = " << r_cleanup_write_trdid.read()
     4966          << " / rpktid = " << r_cleanup_write_pktid.read() << std::endl;
     4967#endif
     4968      break;
     4969    }
     4970    ////////////////////////
     4971    case CLEANUP_CONFIG_ACK:   // signals inval completion to CONFIG FSM
     4972                               // wait if pending request
     4973    {
     4974      if ( r_cleanup_to_config_ack.read() ) break;
     4975
     4976      r_cleanup_to_config_ack      = true;
     4977      r_cleanup_fsm                = CLEANUP_SEND_CLACK;
     4978
     4979#if DEBUG_MEMC_CLEANUP
     4980if(m_debug)
     4981std::cout << "  <MEMC " << name() << " CLEANUP_CONFIG_ACK>"
     4982          << " Acknowledge broacast inval completion" << std::endl;
     4983#endif
     4984      break;
     4985    }
     4986    ////////////////////////
     4987    case CLEANUP_SEND_CLACK:    // acknowledgement to a cleanup command
     4988                              // on the coherence network (request to the CC_SEND FSM).
     4989                              // wait if pending request to the CC_SEND FSM
     4990    {
    45794991      if(r_cleanup_to_cc_send_req.read()) break;
    45804992
     
    45885000
    45895001#if DEBUG_MEMC_CLEANUP
    4590       if(m_debug_cleanup_fsm)
    4591       {
    4592         std::cout
    4593             << "  <MEMC " << name()
    4594             << ".CLEANUP_SEND_ACK> Send the response to a cleanup request:"
    4595             << " srcid = " << std::dec << r_cleanup_srcid.read()
    4596             << std::endl;
    4597       }
     5002if(m_debug)
     5003std::cout << "  <MEMC " << name()
     5004          << " CLEANUP_SEND_CLACK> Send the response to a cleanup request:"
     5005          << " srcid = " << std::dec << r_cleanup_srcid.read() << std::endl;
    45985006#endif
    45995007      break;
     
    46355043
    46365044#if DEBUG_MEMC_CAS
    4637         if(m_debug_cas_fsm)
    4638         {
    4639           std::cout << "  <MEMC " << name() << ".CAS_IDLE> CAS command: " << std::hex
     5045        if(m_debug)
     5046        {
     5047          std::cout << "  <MEMC " << name() << " CAS_IDLE> CAS command: " << std::hex
    46405048                    << " srcid = " <<  std::dec << m_cmd_cas_srcid_fifo.read()
    46415049                    << " addr = " << std::hex << m_cmd_cas_addr_fifo.read()
     
    46585066          r_cas_rdata[r_cas_cpt.read()] = m_cmd_cas_wdata_fifo.read();
    46595067
    4660         if((r_cas_cpt.read() == 1) && m_cmd_cas_eop_fifo.read())
     5068        if((r_cas_cpt.read() == 1) and m_cmd_cas_eop_fifo.read())
    46615069          r_cas_wdata = m_cmd_cas_wdata_fifo.read();
    46625070
     
    46855093
    46865094#if DEBUG_MEMC_CAS
    4687       if(m_debug_cas_fsm)
     5095      if(m_debug)
    46885096      {
    46895097        std::cout
    4690             << "  <MEMC " << name() << ".CAS_DIR_REQ> Requesting DIR lock "
     5098            << "  <MEMC " << name() << " CAS_DIR_REQ> Requesting DIR lock "
    46915099            << std::endl;
    46925100      }
     
    47195127
    47205128#if DEBUG_MEMC_CAS
    4721         if(m_debug_cas_fsm)
    4722         {
    4723           std::cout << "  <MEMC " << name() << ".CAS_DIR_LOCK> Directory acces"
     5129        if(m_debug)
     5130        {
     5131          std::cout << "  <MEMC " << name() << " CAS_DIR_LOCK> Directory acces"
    47245132                    << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
    47255133                    << " / hit = " << std::dec << entry.valid
     
    47465154    {
    47475155      size_t way  = r_cas_way.read();
    4748       size_t set  = m_y[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5156      size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
    47495157
    47505158      // update directory (lock & dirty bits)
     
    47715179
    47725180#if DEBUG_MEMC_CAS
    4773       if(m_debug_cas_fsm)
    4774       {
    4775         std::cout
    4776           << "  <MEMC " << name() << ".CAS_DIR_HIT_READ> Read data from "
    4777           << " cache and store it in buffer"
    4778           << std::endl;
    4779       }
     5181if(m_debug)
     5182std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_READ> Read data from "
     5183          << " cache and store it in buffer" << std::endl;
    47805184#endif
    47815185      break;
     
    47845188    case CAS_DIR_HIT_COMPARE:
    47855189    {
    4786       size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5190      size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    47875191
    47885192      // Read data in buffer & check data change
     
    47935197
    47945198      // to avoid livelock, force the atomic access to fail pseudo-randomly
    4795       bool forced_fail = ((r_cas_lfsr % (64) == 0) && RANDOMIZE_CAS);
     5199      bool forced_fail = ((r_cas_lfsr % (64) == 0) and RANDOMIZE_CAS);
    47965200      r_cas_lfsr = (r_cas_lfsr >> 1) ^ ((- (r_cas_lfsr & 1)) & 0xd0000001);
    47975201
     
    48085212
    48095213#if DEBUG_MEMC_CAS
    4810       if(m_debug_cas_fsm)
    4811       {
    4812         std::cout << "  <MEMC " << name() << ".CAS_DIR_HIT_COMPARE> Compare the old"
    4813                   << " and the new data"
    4814                   << " / expected value = " << r_cas_rdata[0].read()
    4815                   << " / actual value = "   << r_cas_data[word].read()
    4816                   << " / forced_fail = "    << forced_fail << std::endl;
    4817       }
     5214if(m_debug)
     5215std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_COMPARE> Compare the old"
     5216          << " and the new data"
     5217          << " / expected value = " << r_cas_rdata[0].read()
     5218          << " / actual value = "   << r_cas_data[word].read()
     5219          << " / forced_fail = "    << forced_fail << std::endl;
    48185220#endif
    48195221      break;
     
    48335235          r_cas_fsm = CAS_BC_TRT_LOCK;    // broadcast invalidate required
    48345236        }
    4835         else if(!r_cas_to_cc_send_multi_req.read() &&
     5237        else if(!r_cas_to_cc_send_multi_req.read() and
    48365238                !r_cas_to_cc_send_brdcast_req.read())
    48375239        {
     
    48465248      {
    48475249        size_t way  = r_cas_way.read();
    4848         size_t set  = m_y[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
    4849         size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5250        size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5251        size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    48505252
    48515253        // cache update
     
    48595261        if(m_monitor_ok)
    48605262        {
    4861           vci_addr_t address = m_cmd_cas_addr_fifo.read();
     5263          addr_t address = m_cmd_cas_addr_fifo.read();
    48625264          char buf[80];
    4863           snprintf(buf, 80, "CAS_DIR_HIT_WRITE srcid %d", m_cmd_cas_srcid_fifo.read());
    4864           check_monitor(buf, address, r_cas_wdata.read());
     5265          snprintf(buf, 80, "CAS_DIR_HIT_WRITE srcid %d",
     5266                   (int)m_cmd_cas_srcid_fifo.read());
     5267          check_monitor(buf, address, r_cas_wdata.read(), false);
    48655268
    48665269          if(r_cas_cpt.read() == 4)
    4867             check_monitor(buf, address+4, m_cmd_cas_wdata_fifo.read());
     5270            check_monitor(buf, address+4, m_cmd_cas_wdata_fifo.read(), false);
    48685271        }
    48695272
    48705273#if DEBUG_MEMC_CAS
    4871         if(m_debug_cas_fsm)
    4872         {
    4873           std::cout << "  <MEMC " << name() << ".CAS_DIR_HIT_WRITE> Update cache:"
    4874                     << " way = " << std::dec << way
    4875                     << " / set = " << set
    4876                     << " / word = " << word
    4877                     << " / value = " << r_cas_wdata.read()
    4878                     << " / count = " << r_cas_count.read() << std::endl;
    4879           std::cout << "  <MEMC "
    4880                     << name() << ".CAS_DIR_HIT_WRITE> global_llsc_table SW access" << std::endl;
    4881         }
     5274if(m_debug)
     5275std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE> Update cache:"
     5276          << " way = " << std::dec << way
     5277          << " / set = " << set
     5278          << " / word = " << word
     5279          << " / value = " << r_cas_wdata.read()
     5280          << " / count = " << r_cas_count.read()
     5281          << " / global_llsc_table access" << std::endl;
    48825282#endif
    48835283      }
     
    48965296        size_t      trdid      = m_cmd_cas_trdid_fifo.read();
    48975297        size_t      pktid      = m_cmd_cas_pktid_fifo.read();
    4898         addr_t      nline      = m_nline[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5298        addr_t      nline      = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    48995299        size_t      nb_copies  = r_cas_count.read();
    49005300
    4901         wok = m_upt.set(true,  // it's an update transaction
    4902                                false,   // it's not a broadcast
    4903                                true,    // it needs a response
    4904                                srcid,
    4905                                trdid,
    4906                                pktid,
    4907                                nline,
    4908                                nb_copies,
    4909                                index);
     5301        wok = m_upt.set(true,    // it's an update transaction
     5302                        false,   // it's not a broadcast
     5303                        true,    // response required 
     5304                        false,   // no acknowledge required
     5305                        srcid,
     5306                        trdid,
     5307                        pktid,
     5308                        nline,
     5309                        nb_copies,
     5310                        index);
    49105311        if(wok)   // coherence transaction registered in UPT
    49115312        {
    49125313          // cache update
    49135314          size_t way  = r_cas_way.read();
    4914           size_t set  = m_y[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
    4915           size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5315          size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5316          size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    49165317
    49175318          m_cache_data.write(way, set, word, r_cas_wdata.read());
     
    49255326          if(m_monitor_ok)
    49265327          {
    4927             vci_addr_t address = m_cmd_cas_addr_fifo.read();
     5328            addr_t address = m_cmd_cas_addr_fifo.read();
    49285329            char buf[80];
    4929             snprintf(buf, 80, "CAS_DIR_HIT_WRITE srcid %d", m_cmd_cas_srcid_fifo.read());
    4930             check_monitor(buf, address, r_cas_wdata.read());
     5330            snprintf(buf, 80, "CAS_DIR_HIT_WRITE srcid %d",
     5331                     (int)m_cmd_cas_srcid_fifo.read());
     5332            check_monitor(buf, address, r_cas_wdata.read(), false);
    49315333
    49325334            if(r_cas_cpt.read() ==4)
    4933               check_monitor(buf, address+4, m_cmd_cas_wdata_fifo.read());
     5335              check_monitor(buf, address+4, m_cmd_cas_wdata_fifo.read(), false);
    49345336          }
    49355337        }
     
    49405342
    49415343#if DEBUG_MEMC_CAS
    4942         if(m_debug_cas_fsm)
    4943         {
    4944           std::cout << "  <MEMC " << name()
    4945                     << ".CAS_UPT_LOCK> Register multi-update transaction in UPT"
    4946                     << " / wok = " << wok
    4947                     << " / nline  = " << std::hex << nline
    4948                     << " / count = " << nb_copies << std::endl;
    4949         }
     5344if(m_debug)
     5345std::cout << "  <MEMC " << name()
     5346          << " CAS_UPT_LOCK> Register multi-update transaction in UPT"
     5347          << " / wok = " << wok
     5348          << " / nline  = " << std::hex << nline
     5349          << " / count = " << nb_copies << std::endl;
    49505350#endif
    49515351      }
     
    49575357
    49585358#if DEBUG_MEMC_CAS
    4959       if(m_debug_cas_fsm)
     5359      if(m_debug)
    49605360      {
    49615361        std::cout << "  <MEMC " << name()
    4962                   << ".CAS_WAIT> Release all locks" << std::endl;
     5362                  << " CAS_WAIT> Release all locks" << std::endl;
    49635363      }
    49645364#endif
     
    49735373
    49745374#if DEBUG_MEMC_CAS
    4975         if(m_debug_cas_fsm)
     5375        if(m_debug)
    49765376        {
    49775377          std::cout << "  <MEMC " << name()
    4978                     << ".CAS_UPT_HEAP_LOCK> Get access to the heap" << std::endl;
     5378                    << " CAS_UPT_HEAP_LOCK> Get access to the heap" << std::endl;
    49795379        }
    49805380#endif
     
    49895389             "VCI_MEM_CACHE ERROR : bad HEAP allocation");
    49905390
    4991       if(!r_cas_to_cc_send_multi_req.read() && !r_cas_to_cc_send_brdcast_req.read())
     5391      if(!r_cas_to_cc_send_multi_req.read() and !r_cas_to_cc_send_brdcast_req.read())
    49925392      {
    49935393        r_cas_to_cc_send_brdcast_req  = false;
    49945394        r_cas_to_cc_send_trdid        = r_cas_upt_index.read();
    4995         r_cas_to_cc_send_nline        = m_nline[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
    4996         r_cas_to_cc_send_index        = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5395        r_cas_to_cc_send_nline        = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5396        r_cas_to_cc_send_index        = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    49975397        r_cas_to_cc_send_wdata        = r_cas_wdata.read();
    49985398
     
    50295429
    50305430#if DEBUG_MEMC_CAS
    5031         if(m_debug_cas_fsm)
    5032         {
    5033           std::cout << "  <MEMC " << name() << ".CAS_UPT_REQ> Send the first update request to CC_SEND FSM "
     5431        if(m_debug)
     5432        {
     5433          std::cout << "  <MEMC " << name() << " CAS_UPT_REQ> Send the first update request to CC_SEND FSM "
    50345434                    << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
    50355435                    << " / wdata = " << std::hex << r_cas_wdata.read()
     
    50695469
    50705470#if DEBUG_MEMC_CAS
    5071       if(m_debug_cas_fsm)
    5072       {
    5073         std::cout << "  <MEMC " << name() << ".CAS_UPT_NEXT> Send the next update request to CC_SEND FSM "
     5471      if(m_debug)
     5472      {
     5473        std::cout << "  <MEMC " << name() << " CAS_UPT_NEXT> Send the next update request to CC_SEND FSM "
    50745474                  << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
    50755475                  << " / wdata = " << std::hex << r_cas_wdata.read()
     
    50885488        {
    50895489          // fill the data buffer
    5090           size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5490          size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    50915491          for(size_t i = 0; i<m_words; i++)
    50925492          {
     
    50955495              r_cas_to_ixr_cmd_data[i] = r_cas_wdata.read();
    50965496            }
    5097             else if((i == word+1) && (r_cas_cpt.read() == 4))   // 64 bit CAS
     5497            else if((i == word+1) and (r_cas_cpt.read() == 4))   // 64 bit CAS
    50985498            {
    50995499              r_cas_to_ixr_cmd_data[i] = m_cmd_cas_wdata_fifo.read();
     
    51235523      break;
    51245524    }
    5125     ///////////////////
     5525    /////////////////////
    51265526    case CAS_BC_UPT_LOCK:  // register a broadcast inval transaction in UPT
    5127       // write data in cache in case of successful registration
     5527                           // write data in cache in case of successful registration
    51285528    {
    51295529      if(r_alloc_upt_fsm.read() == ALLOC_UPT_CAS)
     
    51345534        size_t      trdid     = m_cmd_cas_trdid_fifo.read();
    51355535        size_t      pktid     = m_cmd_cas_pktid_fifo.read();
    5136         addr_t      nline     = m_nline[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5536        addr_t      nline     = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    51375537        size_t      nb_copies = r_cas_count.read();
    51385538
    51395539        // register a broadcast inval transaction in UPT
    51405540        wok = m_upt.set(false,  // it's an inval transaction
    5141                                true,    // it's a broadcast
    5142                                true,    // it needs a response
    5143                                srcid,
    5144                                trdid,
    5145                                pktid,
    5146                                nline,
    5147                                nb_copies,
    5148                                index);
     5541                        true,    // it's a broadcast
     5542                        true,    // response required
     5543                        false,   // no acknowledge required
     5544                        srcid,
     5545                        trdid,
     5546                        pktid,
     5547                        nline,
     5548                        nb_copies,
     5549                        index);
    51495550
    51505551        if(wok)     // UPT not full
     
    51525553          // cache update
    51535554          size_t way  = r_cas_way.read();
    5154           size_t set  = m_y[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
    5155           size_t word = m_x[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5555          size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5556          size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    51565557
    51575558          m_cache_data.write(way, set, word, r_cas_wdata.read());
     
    51625563          if(m_monitor_ok)
    51635564          {
    5164             vci_addr_t address = m_cmd_cas_addr_fifo.read();
     5565            addr_t address = m_cmd_cas_addr_fifo.read();
    51655566            char buf[80];
    5166             snprintf(buf, 80, "CAS_DIR_HIT_WRITE srcid %d", m_cmd_cas_srcid_fifo.read());
    5167             check_monitor(buf, address, r_cas_wdata.read());
     5567            snprintf(buf, 80, "CAS_DIR_HIT_WRITE srcid %d",
     5568                     (int)m_cmd_cas_srcid_fifo.read());
     5569            check_monitor(buf, address, r_cas_wdata.read(), false);
    51685570            if(r_cas_cpt.read() ==4)
    5169               check_monitor(buf, address+4, m_cmd_cas_wdata_fifo.read());
     5571              check_monitor(buf, address+4, m_cmd_cas_wdata_fifo.read(), false);
    51705572          }
    51715573          r_cas_upt_index = index;
    51725574          r_cas_fsm = CAS_BC_DIR_INVAL;
     5575
    51735576#if DEBUG_MEMC_CAS
    5174           if(m_debug_cas_fsm)
    5175           {
    5176             std::cout << "  <MEMC " << name() << ".CAS_BC_UPT_LOCK> Register a broadcast inval transaction in UPT"
    5177                       << " / nline = " << nline
    5178                       << " / count = " << nb_copies
    5179                       << " / upt_index = " << index << std::endl;
    5180           }
     5577if(m_debug)
     5578std::cout << "  <MEMC " << name()
     5579          << " CAS_BC_UPT_LOCK> Register a broadcast inval transaction in UPT"
     5580          << " / nline = " << std::hex << nline
     5581          << " / count = " << std::dec << nb_copies
     5582          << " / upt_index = " << index << std::endl;
    51815583#endif
    51825584        }
     
    51885590      break;
    51895591    }
    5190     //////////////////
     5592    //////////////////////
    51915593    case CAS_BC_DIR_INVAL:  // Register the PUT transaction in TRT, and inval the DIR entry
    51925594    {
    5193       if((r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) &&
    5194           (r_alloc_upt_fsm.read() == ALLOC_UPT_CAS) &&
     5595      if((r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
     5596          (r_alloc_upt_fsm.read() == ALLOC_UPT_CAS) and
    51955597          (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS))
    51965598      {
     
    51985600        m_trt.set(r_cas_trt_index.read(),
    51995601                              false,    // PUT request to XRAM
    5200                               m_nline[(vci_addr_t)(m_cmd_cas_addr_fifo.read())],
     5602                              m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())],
    52015603                              0,
    52025604                              0,
     
    52225624        entry.owner.inst    = false;
    52235625        entry.ptr           = 0;
    5224         size_t set          = m_y[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5626        size_t set          = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
    52255627        size_t way          = r_cas_way.read();
    52265628        m_cache_directory.write(set, way, entry);
     
    52295631
    52305632#if DEBUG_MEMC_CAS
    5231         if(m_debug_cas_fsm)
    5232         {
    5233           std::cout << "  <MEMC " << name() << ".CAS_BC_DIR_INVAL> Register the PUT in TRT and invalidate DIR entry"
    5234                     << " / nline = " << std::hex << m_nline[(vci_addr_t)(m_cmd_cas_addr_fifo.read())]
    5235                     << " / set = " << std::dec << set << " / way = " << way << std::endl;
    5236         }
     5633if(m_debug)
     5634std::cout << "  <MEMC " << name()
     5635          << " CAS_BC_DIR_INVAL> Register the PUT in TRT and invalidate DIR entry"
     5636          << " / nline = " << std::hex << m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())]
     5637          << " / set = " << std::dec << set << " / way = " << way << std::endl;
    52375638#endif
    52385639      }
     
    52465647    case CAS_BC_CC_SEND:  // Request the broadcast inval to CC_SEND FSM
    52475648    {
    5248       if(!r_cas_to_cc_send_multi_req.read() &&
     5649      if(!r_cas_to_cc_send_multi_req.read() and
    52495650          !r_cas_to_cc_send_brdcast_req.read())
    52505651      {
     
    52525653        r_cas_to_cc_send_brdcast_req  = true;
    52535654        r_cas_to_cc_send_trdid        = r_cas_upt_index.read();
    5254         r_cas_to_cc_send_nline        = m_nline[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5655        r_cas_to_cc_send_nline        = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    52555656        r_cas_to_cc_send_index        = 0;
    52565657        r_cas_to_cc_send_wdata        = 0;
     
    52675668        r_cas_to_ixr_cmd_req     = true;
    52685669        r_cas_to_ixr_cmd_write   = true;
    5269         r_cas_to_ixr_cmd_nline   = m_nline[(vci_addr_t)(m_cmd_cas_addr_fifo.read())];
     5670        r_cas_to_ixr_cmd_nline   = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    52705671        r_cas_to_ixr_cmd_trdid   = r_cas_trt_index.read();
    52715672        r_cas_fsm                = CAS_IDLE;
     
    52745675
    52755676#if DEBUG_MEMC_CAS
    5276         if(m_debug_cas_fsm)
    5277         {
    5278           std::cout << "  <MEMC " << name() << ".CAS_BC_XRAM_REQ> Request a PUT transaction to IXR_CMD FSM" << std::hex
    5279                     << " / nline = " << m_nline[(vci_addr_t) m_cmd_cas_addr_fifo.read()]
    5280                     << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    5281         }
     5677if(m_debug)
     5678std::cout << "  <MEMC " << name()
     5679          << " CAS_BC_XRAM_REQ> Request a PUT transaction to IXR_CMD FSM" << std::hex
     5680          << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
     5681          << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    52825682#endif
    52835683      }
    52845684      else
    52855685      {
    5286         std::cout << "MEM_CACHE, CAS_BC_XRAM_REQ state : request should not have been previously set"
    5287                   << std::endl;
     5686        std::cout << "ERROR in MEM_CACHE / CAS_BC_XRAM_REQ state"
     5687                  << " : request should not have been previously set" << std::endl;
    52885688      }
    52895689      break;
     
    53045704
    53055705#if DEBUG_MEMC_CAS
    5306         if(m_debug_cas_fsm)
    5307         {
    5308           std::cout << "  <MEMC " << name() << ".CAS_RSP_FAIL> Request TGT_RSP to send a failure response" << std::endl;
    5309         }
     5706if(m_debug)
     5707std::cout << "  <MEMC " << name()
     5708          << " CAS_RSP_FAIL> Request TGT_RSP to send a failure response" << std::endl;
    53105709#endif
    53115710      }
     
    53275726
    53285727#if DEBUG_MEMC_CAS
    5329         if(m_debug_cas_fsm)
    5330         {
    5331           std::cout << "  <MEMC " << name() << ".CAS_RSP_SUCCESS> Request TGT_RSP to send a success response" << std::endl;
    5332         }
     5728if(m_debug)
     5729std::cout << "  <MEMC " << name()
     5730          << " CAS_RSP_SUCCESS> Request TGT_RSP to send a success response" << std::endl;
    53335731#endif
    53345732      }
     
    53425740        size_t   index = 0;
    53435741        bool hit_read = m_trt.hit_read(
    5344                           m_nline[(vci_addr_t) m_cmd_cas_addr_fifo.read()],index);
     5742                          m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],index);
    53455743        bool hit_write = m_trt.hit_write(
    5346                            m_nline[(vci_addr_t) m_cmd_cas_addr_fifo.read()]);
     5744                           m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]);
    53475745        bool wok = !m_trt.full(index);
    53485746
    53495747#if DEBUG_MEMC_CAS
    5350         if(m_debug_cas_fsm)
    5351         {
    5352           std::cout << "  <MEMC " << name() << ".CAS_MISS_TRT_LOCK> Check TRT state"
     5748        if(m_debug)
     5749        {
     5750          std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_LOCK> Check TRT state"
    53535751                    << " / hit_read = "  << hit_read
    53545752                    << " / hit_write = " << hit_write
     
    53585756#endif
    53595757
    5360         if(hit_read || !wok || hit_write)    // missing line already requested or no space in TRT
     5758        if(hit_read or !wok or hit_write)    // missing line already requested or no space in TRT
    53615759        {
    53625760          r_cas_fsm = CAS_WAIT;
     
    53875785        m_trt.set(r_cas_trt_index.read(),
    53885786                              true,   // read request
    5389                               m_nline[(vci_addr_t) m_cmd_cas_addr_fifo.read()],
     5787                              m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],
    53905788                              m_cmd_cas_srcid_fifo.read(),
    53915789                              m_cmd_cas_trdid_fifo.read(),
     
    53995797
    54005798#if DEBUG_MEMC_CAS
    5401         if(m_debug_cas_fsm)
    5402         {
    5403           std::cout << "  <MEMC " << name() << ".CAS_MISS_TRT_SET> Register a GET transaction in TRT" << std::hex
    5404                     << " / nline = " << m_nline[(vci_addr_t) m_cmd_cas_addr_fifo.read()]
     5799        if(m_debug)
     5800        {
     5801          std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_SET> Register a GET transaction in TRT" << std::hex
     5802                    << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
    54055803                    << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    54065804        }
     
    54175815        r_cas_to_ixr_cmd_write      = false;
    54185816        r_cas_to_ixr_cmd_trdid      = r_cas_trt_index.read();
    5419         r_cas_to_ixr_cmd_nline      = m_nline[(vci_addr_t) m_cmd_cas_addr_fifo.read()];
     5817        r_cas_to_ixr_cmd_nline      = m_nline[(addr_t) m_cmd_cas_addr_fifo.read()];
    54205818        r_cas_fsm                   = CAS_WAIT;
    54215819
    54225820#if DEBUG_MEMC_CAS
    5423         if(m_debug_cas_fsm)
    5424         {
    5425           std::cout << "  <MEMC " << name() << ".CAS_MISS_XRAM_REQ> Request a GET transaction to IXR_CMD FSM" << std::hex
    5426                     << " / nline = " << m_nline[(vci_addr_t) m_cmd_cas_addr_fifo.read()]
     5821        if(m_debug)
     5822        {
     5823          std::cout << "  <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction to IXR_CMD FSM" << std::hex
     5824                    << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
    54275825                    << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    54285826        }
     
    54435841  // the CLEANUP fsm.
    54445842  //
    5445   // It implements a round-robin priority between the four possible client FSMs
    5446   // XRAM_RSP, WRITE, CAS and CLEANUP. Each FSM can request the next services:
     5843  // It implements a round-robin priority between the five possible client FSMs
     5844  //     XRAM_RSP > CAS > CLEANUP > WRITE > CONFIG
     5845  //
     5846  // Each FSM can request the next services:
    54475847  // - r_xram_rsp_to_cc_send_multi_req : multi-inval
    54485848  //   r_xram_rsp_to_cc_send_brdcast_req : broadcast-inval
     
    54515851  // - r_cas_to_cc_send_multi_req : multi-update
    54525852  //   r_cas_to_cc_send_brdcast_req : broadcast-inval
     5853  // - r_config_to_cc_send_multi_req : multi-inval
     5854  //   r_config_to_cc_send_brdcast_req : broadcast-inval
     5855  //   
    54535856  // - r_cleanup_to_cc_send_req : cleanup acknowledgement
    54545857  //
     
    54645867  switch(r_cc_send_fsm.read())
    54655868  {
    5466     case CC_SEND_WRITE_IDLE:
    5467       {
    5468         // XRAM_RSP FSM has highest priority
    5469         if(m_xram_rsp_to_cc_send_inst_fifo.rok() ||
     5869      /////////////////////////
     5870      case CC_SEND_CONFIG_IDLE:    // XRAM_RSP FSM has highest priority
     5871      {
     5872        // XRAM_RSP
     5873        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
    54705874            r_xram_rsp_to_cc_send_multi_req.read())
    54715875        {
     
    54745878          break;
    54755879        }
    5476 
    54775880        if(r_xram_rsp_to_cc_send_brdcast_req.read())
    54785881        {
     
    54815884          break;
    54825885        }
    5483 
    5484         if(m_cas_to_cc_send_inst_fifo.rok() ||
     5886        // CAS
     5887        if(m_cas_to_cc_send_inst_fifo.rok() or
    54855888            r_cas_to_cc_send_multi_req.read())
    54865889        {
     
    54895892          break;
    54905893        }
    5491 
    54925894        if(r_cas_to_cc_send_brdcast_req.read())
    54935895        {
     
    54965898          break;
    54975899        }
    5498 
     5900        // CLEANUP
    54995901        if (r_cleanup_to_cc_send_req.read())
    55005902        {
     
    55025904          break;
    55035905        }
    5504 
    5505         if(m_write_to_cc_send_inst_fifo.rok() ||
     5906        // WRITE
     5907        if(m_write_to_cc_send_inst_fifo.rok() or
    55065908            r_write_to_cc_send_multi_req.read())
    55075909        {
     
    55105912          break;
    55115913        }
    5512 
    55135914        if(r_write_to_cc_send_brdcast_req.read())
    55145915        {
    55155916          r_cc_send_fsm = CC_SEND_WRITE_BRDCAST_HEADER;
    55165917          m_cpt_inval++;
     5918          break;
     5919        }
     5920        // CONFIG
     5921        if(r_config_to_cc_send_multi_req.read())
     5922        {
     5923          r_cc_send_fsm = CC_SEND_CONFIG_INVAL_HEADER;
     5924          m_cpt_inval++;
     5925          break;
     5926        }
     5927        if(r_config_to_cc_send_brdcast_req.read())
     5928        {
     5929          r_cc_send_fsm = CC_SEND_CONFIG_BRDCAST_HEADER;
     5930          m_cpt_inval++;
     5931          break;
    55175932        }
    55185933        break;
    55195934      }
    5520 
    5521     case CC_SEND_XRAM_RSP_IDLE:
    5522       {
    5523         // CAS FSM has highest priority
    5524         if(m_cas_to_cc_send_inst_fifo.rok() ||
     5935      ////////////////////////
     5936      case CC_SEND_WRITE_IDLE:     // CONFIG FSM has highest priority
     5937      {
     5938        // CONFIG
     5939        if(r_config_to_cc_send_multi_req.read())
     5940        {
     5941          r_cc_send_fsm = CC_SEND_CONFIG_INVAL_HEADER;
     5942          m_cpt_inval++;
     5943          break;
     5944        }
     5945        if(r_config_to_cc_send_brdcast_req.read())
     5946        {
     5947          r_cc_send_fsm = CC_SEND_CONFIG_BRDCAST_HEADER;
     5948          m_cpt_inval++;
     5949          break;
     5950        }
     5951        // XRAM_RSP
     5952        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
     5953            r_xram_rsp_to_cc_send_multi_req.read())
     5954        {
     5955          r_cc_send_fsm = CC_SEND_XRAM_RSP_INVAL_HEADER;
     5956          m_cpt_inval++;
     5957          break;
     5958        }
     5959        if(r_xram_rsp_to_cc_send_brdcast_req.read())
     5960        {
     5961          r_cc_send_fsm = CC_SEND_XRAM_RSP_BRDCAST_HEADER;
     5962          m_cpt_inval++;
     5963          break;
     5964        }
     5965        // CAS
     5966        if(m_cas_to_cc_send_inst_fifo.rok() or
    55255967            r_cas_to_cc_send_multi_req.read())
    55265968        {
     
    55295971          break;
    55305972        }
    5531 
    55325973        if(r_cas_to_cc_send_brdcast_req.read())
    55335974        {
     
    55365977          break;
    55375978        }
    5538 
    5539         if(r_cleanup_to_cc_send_req.read())
     5979        // CLEANUP
     5980        if (r_cleanup_to_cc_send_req.read())
    55405981        {
    55415982          r_cc_send_fsm = CC_SEND_CLEANUP_ACK;
    55425983          break;
    55435984        }
    5544 
    5545         if(m_write_to_cc_send_inst_fifo.rok() ||
     5985        // WRITE
     5986        if(m_write_to_cc_send_inst_fifo.rok() or
    55465987            r_write_to_cc_send_multi_req.read())
    55475988        {
     
    55505991          break;
    55515992        }
    5552 
    55535993        if(r_write_to_cc_send_brdcast_req.read())
    55545994        {
     
    55575997          break;
    55585998        }
    5559 
    5560         if(m_xram_rsp_to_cc_send_inst_fifo.rok() ||
     5999        break;
     6000      }
     6001      ///////////////////////////
     6002      case CC_SEND_XRAM_RSP_IDLE:   // CAS FSM has highest priority
     6003      {
     6004        // CAS
     6005        if(m_cas_to_cc_send_inst_fifo.rok() or
     6006            r_cas_to_cc_send_multi_req.read())
     6007        {
     6008          r_cc_send_fsm = CC_SEND_CAS_UPDT_HEADER;
     6009          m_cpt_update++;
     6010          break;
     6011        }
     6012        if(r_cas_to_cc_send_brdcast_req.read())
     6013        {
     6014          r_cc_send_fsm = CC_SEND_CAS_BRDCAST_HEADER;
     6015          m_cpt_inval++;
     6016          break;
     6017        }
     6018        // CLEANUP
     6019        if(r_cleanup_to_cc_send_req.read())
     6020        {
     6021          r_cc_send_fsm = CC_SEND_CLEANUP_ACK;
     6022          break;
     6023        }
     6024        // WRITE
     6025        if(m_write_to_cc_send_inst_fifo.rok() or
     6026            r_write_to_cc_send_multi_req.read())
     6027        {
     6028          r_cc_send_fsm = CC_SEND_WRITE_UPDT_HEADER;
     6029          m_cpt_update++;
     6030          break;
     6031        }
     6032
     6033        if(r_write_to_cc_send_brdcast_req.read())
     6034        {
     6035          r_cc_send_fsm = CC_SEND_WRITE_BRDCAST_HEADER;
     6036          m_cpt_inval++;
     6037          break;
     6038        }
     6039        // CONFIG
     6040        if(r_config_to_cc_send_multi_req.read())
     6041        {
     6042          r_cc_send_fsm = CC_SEND_CONFIG_INVAL_HEADER;
     6043          m_cpt_inval++;
     6044          break;
     6045        }
     6046        if(r_config_to_cc_send_brdcast_req.read())
     6047        {
     6048          r_cc_send_fsm = CC_SEND_CONFIG_BRDCAST_HEADER;
     6049          m_cpt_inval++;
     6050          break;
     6051        }
     6052        // XRAM_RSP
     6053        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
    55616054            r_xram_rsp_to_cc_send_multi_req.read())
    55626055        {
     
    55656058          break;
    55666059        }
    5567 
    55686060        if(r_xram_rsp_to_cc_send_brdcast_req.read())
    55696061        {
    55706062          r_cc_send_fsm = CC_SEND_XRAM_RSP_BRDCAST_HEADER;
    55716063          m_cpt_inval++;
    5572         }
    5573 
     6064          break;
     6065        }
    55746066        break;
    55756067      }
    5576 
    5577     case CC_SEND_CAS_IDLE:
    5578       {
    5579         // CLEANUP FSM has highest priority
     6068      //////////////////////
     6069      case CC_SEND_CAS_IDLE:   // CLEANUP FSM has highest priority
     6070      {
    55806071        if(r_cleanup_to_cc_send_req.read())
    55816072        {
     
    55836074          break;
    55846075        }
    5585 
    5586         if(m_write_to_cc_send_inst_fifo.rok() ||
     6076        if(m_write_to_cc_send_inst_fifo.rok() or
    55876077            r_write_to_cc_send_multi_req.read())
    55886078        {
     
    55916081          break;
    55926082        }
    5593 
    55946083        if(r_write_to_cc_send_brdcast_req.read())
    55956084        {
     
    55986087          break;
    55996088        }
    5600 
    5601         if(m_xram_rsp_to_cc_send_inst_fifo.rok() ||
     6089        // CONFIG
     6090        if(r_config_to_cc_send_multi_req.read())
     6091        {
     6092          r_cc_send_fsm = CC_SEND_CONFIG_INVAL_HEADER;
     6093          m_cpt_inval++;
     6094          break;
     6095        }
     6096        if(r_config_to_cc_send_brdcast_req.read())
     6097        {
     6098          r_cc_send_fsm = CC_SEND_CONFIG_BRDCAST_HEADER;
     6099          m_cpt_inval++;
     6100          break;
     6101        }
     6102        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
    56026103            r_xram_rsp_to_cc_send_multi_req.read())
    56036104        {
     
    56066107          break;
    56076108        }
    5608 
    56096109        if(r_xram_rsp_to_cc_send_brdcast_req.read())
    56106110        {
     
    56136113          break;
    56146114        }
    5615 
    5616         if(m_cas_to_cc_send_inst_fifo.rok() ||
     6115        if(m_cas_to_cc_send_inst_fifo.rok() or
    56176116            r_cas_to_cc_send_multi_req.read())
    56186117        {
     
    56216120          break;
    56226121        }
    5623 
    56246122        if(r_cas_to_cc_send_brdcast_req.read())
    56256123        {
    56266124          r_cc_send_fsm = CC_SEND_CAS_BRDCAST_HEADER;
    56276125          m_cpt_inval++;
     6126          break;
    56286127        }
    56296128        break;
    56306129      }
    5631 
    5632     case CC_SEND_CLEANUP_IDLE:
    5633       {
    5634         // WRITE FSM has highest priority
    5635         if(m_write_to_cc_send_inst_fifo.rok() ||
     6130      //////////////////////////
     6131      case CC_SEND_CLEANUP_IDLE:   // WRITE FSM has highest priority
     6132      {
     6133        // WRITE
     6134        if(m_write_to_cc_send_inst_fifo.rok() or
    56366135            r_write_to_cc_send_multi_req.read())
    56376136        {
     
    56406139          break;
    56416140        }
    5642 
    56436141        if(r_write_to_cc_send_brdcast_req.read())
    56446142        {
     
    56476145          break;
    56486146        }
    5649 
    5650         if(m_xram_rsp_to_cc_send_inst_fifo.rok() ||
     6147        // CONFIG
     6148        if(r_config_to_cc_send_multi_req.read())
     6149        {
     6150          r_cc_send_fsm = CC_SEND_CONFIG_INVAL_HEADER;
     6151          m_cpt_inval++;
     6152          break;
     6153        }
     6154        if(r_config_to_cc_send_brdcast_req.read())
     6155        {
     6156          r_cc_send_fsm = CC_SEND_CONFIG_BRDCAST_HEADER;
     6157          m_cpt_inval++;
     6158          break;
     6159        }
     6160        // XRAM_RSP
     6161        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
    56516162            r_xram_rsp_to_cc_send_multi_req.read())
    56526163        {
     
    56556166          break;
    56566167        }
    5657 
    56586168        if(r_xram_rsp_to_cc_send_brdcast_req.read())
    56596169        {
     
    56626172          break;
    56636173        }
    5664 
    5665         if(m_cas_to_cc_send_inst_fifo.rok() ||
     6174        // CAS
     6175        if(m_cas_to_cc_send_inst_fifo.rok() or
    56666176            r_cas_to_cc_send_multi_req.read())
    56676177        {
     
    56706180          break;
    56716181        }
    5672 
    56736182        if(r_cas_to_cc_send_brdcast_req.read())
    56746183        {
     
    56776186          break;
    56786187        }
    5679 
     6188        // CLEANUP
    56806189        if(r_cleanup_to_cc_send_req.read())
    56816190        {
    56826191          r_cc_send_fsm = CC_SEND_CLEANUP_ACK;
    5683         }
    5684 
     6192          break;
     6193        }
    56856194        break;
    56866195      }
    5687 
    5688     case CC_SEND_CLEANUP_ACK:
    5689       {
    5690         // send only flit for a cleanup acknowledgement (from CLEANUP FSM)
     6196      /////////////////////////////////
     6197      case CC_SEND_CONFIG_INVAL_HEADER:   // send first flit multi-inval (from CONFIG FSM)
     6198      {
     6199        if(m_config_to_cc_send_inst_fifo.rok())
     6200        {
     6201          if(not p_dspin_out.read) break;
     6202          r_cc_send_fsm = CC_SEND_CONFIG_INVAL_NLINE;
     6203          break;
     6204        }
     6205        if(r_config_to_cc_send_multi_req.read()) r_config_to_cc_send_multi_req = false;
     6206        r_cc_send_fsm = CC_SEND_CONFIG_IDLE;
     6207        break;
     6208      }
     6209      ////////////////////////////////
     6210      case CC_SEND_CONFIG_INVAL_NLINE:    // send second flit multi-inval (from CONFIG FSM)
     6211      {
     6212        if(not p_dspin_out.read) break;
     6213        m_cpt_inval_mult++;
     6214        config_to_cc_send_fifo_get = true;
     6215        r_cc_send_fsm = CC_SEND_CONFIG_INVAL_HEADER;
     6216
     6217#if DEBUG_MEMC_CC_SEND
     6218if(m_debug)
     6219std::cout << "  <MEMC " << name()
     6220          << " CC_SEND_CONFIG_INVAL_NLINE> multi-inval for line "
     6221          << std::hex << r_config_to_cc_send_nline.read() << std::endl;
     6222#endif
     6223        break;
     6224      }
     6225      ///////////////////////////////////
     6226      case CC_SEND_CONFIG_BRDCAST_HEADER:   // send first flit BC-inval (from CONFIG FSM)
     6227      {
     6228        if(not p_dspin_out.read) break;
     6229        r_cc_send_fsm = CC_SEND_CONFIG_BRDCAST_NLINE;
     6230        break;
     6231      }
     6232      //////////////////////////////////
     6233      case CC_SEND_CONFIG_BRDCAST_NLINE:    // send second flit BC-inval (from CONFIG FSM)
     6234      {
     6235        if(not p_dspin_out.read) break;
     6236        m_cpt_inval_brdcast++;
     6237        r_config_to_cc_send_brdcast_req = false;
     6238        r_cc_send_fsm = CC_SEND_CONFIG_IDLE;
     6239
     6240#if DEBUG_MEMC_CC_SEND
     6241if(m_debug)
     6242std::cout << "  <MEMC " << name()
     6243          << " CC_SEND_CONFIG_BRDCAST_NLINE> BC-Inval for line "
     6244          << std::hex << r_config_to_cc_send_nline.read() << std::endl;
     6245#endif
     6246        break;
     6247      }
     6248      /////////////////////////
     6249      case CC_SEND_CLEANUP_ACK:   // send one flit for a cleanup acknowledgement
     6250      {
    56916251        if(not p_dspin_out.read) break;
    56926252
     
    56956255
    56966256#if DEBUG_MEMC_CC_SEND
    5697         if(m_debug_cc_send_fsm)
    5698         {
    5699           std::cout
    5700             << "  <MEMC " << name()
    5701             << ".CC_SEND_CLEANUP_ACK> Cleanup Acknowledgement for srcid "
    5702             << r_cleanup_to_cc_send_srcid.read()
    5703             << std::endl;
    5704         }
     6257if(m_debug)
     6258std::cout << "  <MEMC " << name()
     6259          << " CC_SEND_CLEANUP_ACK> Cleanup Ack for srcid "
     6260          << std::hex << r_cleanup_to_cc_send_srcid.read() << std::endl;
    57056261#endif
    57066262        break;
    57076263      }
    5708 
    5709     case CC_SEND_XRAM_RSP_INVAL_HEADER:
    5710       {
    5711         // send first flit multi-inval (from XRAM_RSP FSM)
     6264      ///////////////////////////////////
     6265      case CC_SEND_XRAM_RSP_INVAL_HEADER:   // send first flit multi-inval (from XRAM_RSP FSM)
     6266      {
    57126267        if(m_xram_rsp_to_cc_send_inst_fifo.rok())
    57136268        {
    57146269          if(not p_dspin_out.read) break;
    5715 
    57166270          r_cc_send_fsm = CC_SEND_XRAM_RSP_INVAL_NLINE;
    57176271          break;
    57186272        }
    5719 
    5720         if(r_xram_rsp_to_cc_send_multi_req.read())
    5721         {
    5722           r_xram_rsp_to_cc_send_multi_req = false;
    5723         }
    5724 
     6273        if(r_xram_rsp_to_cc_send_multi_req.read()) r_xram_rsp_to_cc_send_multi_req = false;
    57256274        r_cc_send_fsm = CC_SEND_XRAM_RSP_IDLE;
    57266275        break;
    57276276      }
    5728 
    5729     case CC_SEND_XRAM_RSP_INVAL_NLINE:
    5730       {
    5731         // send second flit multi-inval (from XRAM_RSP FSM)
     6277      //////////////////////////////////
     6278      case CC_SEND_XRAM_RSP_INVAL_NLINE:   // send second flit multi-inval (from XRAM_RSP FSM)
     6279      {
    57326280        if(not p_dspin_out.read) break;
    5733 
    57346281        m_cpt_inval_mult++;
    5735 
    57366282        xram_rsp_to_cc_send_fifo_get = true;
    5737         r_cc_send_fsm                = CC_SEND_XRAM_RSP_INVAL_HEADER;
     6283        r_cc_send_fsm = CC_SEND_XRAM_RSP_INVAL_HEADER;
    57386284
    57396285#if DEBUG_MEMC_CC_SEND
    5740         if(m_debug_cc_send_fsm)
    5741         {
    5742           std::cout
    5743             << "  <MEMC " << name()
    5744             << ".CC_SEND_XRAM_RSP_INVAL_NLINE> Broadcast-Inval for line "
    5745             << r_xram_rsp_to_cc_send_nline.read()
    5746             << std::endl;
    5747         }
     6286if(m_debug)
     6287std::cout << "  <MEMC " << name()
     6288          << " CC_SEND_XRAM_RSP_INVAL_NLINE> BC-Inval for line "
     6289          << std::hex << r_xram_rsp_to_cc_send_nline.read() << std::endl;
    57486290#endif
    57496291        break;
    57506292      }
    5751 
    5752     case CC_SEND_XRAM_RSP_BRDCAST_HEADER:
    5753       {
    5754         // send first flit broadcast-inval (from XRAM_RSP FSM)
     6293      /////////////////////////////////////
     6294      case CC_SEND_XRAM_RSP_BRDCAST_HEADER:  // send first flit broadcast-inval (from XRAM_RSP FSM)
     6295      {
    57556296        if(not p_dspin_out.read) break;
    5756 
    57576297        r_cc_send_fsm = CC_SEND_XRAM_RSP_BRDCAST_NLINE;
    57586298        break;
    57596299      }
    5760 
    5761     case CC_SEND_XRAM_RSP_BRDCAST_NLINE:
    5762       {
    5763         // send second flit broadcast-inval (from XRAM_RSP FSM)
     6300      ////////////////////////////////////
     6301      case CC_SEND_XRAM_RSP_BRDCAST_NLINE:   // send second flit broadcast-inval (from XRAM_RSP FSM)
     6302      {
    57646303        if(not p_dspin_out.read) break;
    5765 
    57666304        m_cpt_inval_brdcast++;
    5767 
    57686305        r_xram_rsp_to_cc_send_brdcast_req = false;
    57696306        r_cc_send_fsm = CC_SEND_XRAM_RSP_IDLE;
    57706307
    57716308#if DEBUG_MEMC_CC_SEND
    5772         if(m_debug_cc_send_fsm)
    5773         {
    5774           std::cout
    5775             << "  <MEMC " << name()
    5776             << ".CC_SEND_XRAM_RSP_BRDCAST_NLINE> Broadcast-Inval for line "
    5777             << r_xram_rsp_to_cc_send_nline.read()
    5778             << std::endl;
    5779         }
     6309if(m_debug)
     6310std::cout << "  <MEMC " << name()
     6311          << " CC_SEND_XRAM_RSP_BRDCAST_NLINE> BC-Inval for line "
     6312          << std::hex << r_xram_rsp_to_cc_send_nline.read() << std::endl;
    57806313#endif
    57816314        break;
    57826315      }
    5783 
    5784     case CC_SEND_WRITE_BRDCAST_HEADER:
    5785       {
    5786         // send first flit broadcast-inval (from WRITE FSM)
     6316      //////////////////////////////////
     6317      case CC_SEND_WRITE_BRDCAST_HEADER:   // send first flit broadcast-inval (from WRITE FSM)
     6318      {
    57876319        if(not p_dspin_out.read) break;
    5788 
    57896320        r_cc_send_fsm = CC_SEND_WRITE_BRDCAST_NLINE;
    57906321        break;
    57916322      }
    5792 
    5793     case CC_SEND_WRITE_BRDCAST_NLINE:
    5794       {
    5795         // send second flit broadcast-inval (from WRITE FSM)
     6323      /////////////////////////////////
     6324      case CC_SEND_WRITE_BRDCAST_NLINE:   // send second flit broadcast-inval (from WRITE FSM)
     6325      {
    57966326        if(not p_dspin_out.read) break;
    57976327
     
    58026332
    58036333#if DEBUG_MEMC_CC_SEND
    5804         if(m_debug_cc_send_fsm)
    5805         {
    5806           std::cout
    5807             << "  <MEMC " << name()
    5808             << ".CC_SEND_WRITE_BRDCAST_NLINE> Broadcast-Inval for line "
    5809             << r_write_to_cc_send_nline.read()
    5810             << std::endl;
    5811         }
     6334if(m_debug)
     6335std::cout << "  <MEMC " << name()
     6336          << " CC_SEND_WRITE_BRDCAST_NLINE> BC-Inval for line "
     6337          << std::hex << r_write_to_cc_send_nline.read() << std::endl;
    58126338#endif
    58136339        break;
    58146340      }
    5815 
    5816     case CC_SEND_WRITE_UPDT_HEADER:
    5817       {
    5818         // send first flit for a multi-update (from WRITE FSM)
     6341      ///////////////////////////////
     6342      case CC_SEND_WRITE_UPDT_HEADER:   // send first flit for a multi-update (from WRITE FSM)
     6343      {
    58196344        if(m_write_to_cc_send_inst_fifo.rok())
    58206345        {
     
    58336358        break;
    58346359      }
    5835 
    5836     case CC_SEND_WRITE_UPDT_NLINE:
    5837       {
    5838         // send second flit for a multi-update (from WRITE FSM)
     6360      //////////////////////////////
     6361      case CC_SEND_WRITE_UPDT_NLINE:   // send second flit for a multi-update (from WRITE FSM)
     6362      {
    58396363        if(not p_dspin_out.read) break;
    5840 
    58416364        m_cpt_update_mult++;
    58426365
     
    58456368
    58466369#if DEBUG_MEMC_CC_SEND
    5847         if(m_debug_cc_send_fsm)
    5848         {
    5849           std::cout
    5850             << "  <MEMC " << name()
    5851             << ".CC_SEND_WRITE_UPDT_NLINE> Multicast-Update for line "
    5852             << r_write_to_cc_send_nline.read()
    5853             << std::endl;
    5854         }
     6370if(m_debug)
     6371std::cout << "  <MEMC " << name()
     6372          << " CC_SEND_WRITE_UPDT_NLINE> Multicast-Update for line "
     6373          << r_write_to_cc_send_nline.read() << std::endl;
    58556374#endif
    58566375        break;
    58576376      }
    5858 
    5859     case CC_SEND_WRITE_UPDT_DATA:
    5860       {
    5861         // send N data flits for a multi-update (from WRITE FSM)
     6377      /////////////////////////////
     6378      case CC_SEND_WRITE_UPDT_DATA:   // send N data flits for a multi-update (from WRITE FSM)
     6379      {
    58626380        if(not p_dspin_out.read) break;
    5863 
    58646381        if(r_cc_send_cpt.read() == (r_write_to_cc_send_count.read()-1))
    58656382        {
     
    58726389        break;
    58736390      }
    5874 
    5875     case CC_SEND_CAS_BRDCAST_HEADER:
    5876       {
    5877         // send first flit for a broadcast-inval (from CAS FSM)
     6391      ////////////////////////////////
     6392      case CC_SEND_CAS_BRDCAST_HEADER:   // send first flit  broadcast-inval (from CAS FSM)
     6393      {
    58786394        if(not p_dspin_out.read) break;
    5879 
    58806395        r_cc_send_fsm = CC_SEND_CAS_BRDCAST_NLINE;
    58816396        break;
    58826397      }
    5883 
    5884     case CC_SEND_CAS_BRDCAST_NLINE:
    5885       {
    5886         // send second flit broadcast-inval (from CAS FSM)
     6398      ///////////////////////////////
     6399      case CC_SEND_CAS_BRDCAST_NLINE:   // send second flit broadcast-inval (from CAS FSM)
     6400      {
    58876401        if(not p_dspin_out.read) break;
    5888 
    58896402        m_cpt_inval_brdcast++;
    58906403
     
    58936406
    58946407#if DEBUG_MEMC_CC_SEND
    5895         if(m_debug_cc_send_fsm)
    5896         {
    5897           std::cout
    5898             << "  <MEMC " << name()
    5899             << ".CC_SEND_CAS_BRDCAST_NLINE> Broadcast-Inval for line "
    5900             << r_cas_to_cc_send_nline.read()
    5901             << std::endl;
    5902         }
     6408if(m_debug)
     6409std::cout << "  <MEMC " << name()
     6410          << " CC_SEND_CAS_BRDCAST_NLINE> Broadcast-Inval for line "
     6411          << r_cas_to_cc_send_nline.read() << std::endl;
    59036412#endif
    59046413        break;
    59056414      }
    5906 
    5907     case CC_SEND_CAS_UPDT_HEADER:
    5908       {
    5909         // send first flit for a multi-update (from CAS FSM)
     6415      /////////////////////////////
     6416      case CC_SEND_CAS_UPDT_HEADER:   // send first flit for a multi-update (from CAS FSM)
     6417      {
    59106418        if(m_cas_to_cc_send_inst_fifo.rok())
    59116419        {
     
    59256433        break;
    59266434      }
    5927 
    5928     case CC_SEND_CAS_UPDT_NLINE:
    5929       {
    5930         // send second flit for a multi-update (from CAS FSM)
     6435      ////////////////////////////
     6436      case CC_SEND_CAS_UPDT_NLINE:   // send second flit for a multi-update (from CAS FSM)
     6437      {
    59316438        if(not p_dspin_out.read) break;
    59326439
     
    59376444
    59386445#if DEBUG_MEMC_CC_SEND
    5939         if(m_debug_cc_send_fsm)
    5940         {
    5941           std::cout
    5942             << "  <MEMC " << name()
    5943             << ".CC_SEND_CAS_UPDT_NLINE> Multicast-Update for line "
    5944             << r_cas_to_cc_send_nline.read()
    5945             << std::endl;
    5946         }
     6446if(m_debug)
     6447std::cout << "  <MEMC " << name()
     6448          << " CC_SEND_CAS_UPDT_NLINE> Multicast-Update for line "
     6449          << r_cas_to_cc_send_nline.read() << std::endl;
    59476450#endif
    59486451        break;
    59496452      }
    5950 
    5951     case CC_SEND_CAS_UPDT_DATA:
    5952       {
    5953         // send first data for a multi-update (from CAS FSM)
     6453      ///////////////////////////
     6454      case CC_SEND_CAS_UPDT_DATA:   // send first data for a multi-update (from CAS FSM)
     6455      {
    59546456        if(not p_dspin_out.read) break;
    59556457
     
    59646466        break;
    59656467      }
    5966 
    5967     case CC_SEND_CAS_UPDT_DATA_HIGH:
    5968       {
    5969         // send second data for a multi-update (from CAS FSM)
     6468      ////////////////////////////////
     6469      case CC_SEND_CAS_UPDT_DATA_HIGH:   // send second data for a multi-update (from CAS FSM)
     6470      {
    59706471        if(not p_dspin_out.read) break;
    5971 
    59726472        cas_to_cc_send_fifo_get = true;
    59736473        r_cc_send_fsm = CC_SEND_CAS_UPDT_HEADER;
     
    59826482  // The CC_RECEIVE fsm controls the DSPIN target port on the coherence
    59836483  // network.
    5984   ///////////////////////////////////////////////////////////////////////////////
     6484  //////////////////////////////////////////////////////////////////////////////
    59856485
    59866486  switch(r_cc_receive_fsm.read())
    59876487  {
     6488    /////////////////////
    59886489    case CC_RECEIVE_IDLE:
    59896490      {
     
    59956496              DspinDhccpParam::FROM_L1_TYPE);
    59966497
    5997         if((type == DspinDhccpParam::TYPE_CLEANUP_DATA) ||
    5998            (type == DspinDhccpParam::TYPE_CLEANUP_INST) )
    5999         { 
     6498        if((type == DspinDhccpParam::TYPE_CLEANUP_DATA) or
     6499           (type == DspinDhccpParam::TYPE_CLEANUP_INST))
     6500        {
    60006501          r_cc_receive_fsm = CC_RECEIVE_CLEANUP;
    60016502          break;
    60026503        }
    6003        
     6504
    60046505        if(type == DspinDhccpParam::TYPE_MULTI_ACK)
    60056506        {
     
    60086509        }
    60096510
    6010         assert(
    6011             false &&
    6012             "VCI_MEM_CACHE ERROR: Incorrect type in coherence request from "
    6013             "L1 Cache");
    6014        
     6511        assert(false and
     6512            "VCI_MEM_CACHE ERROR in CC_RECEIVE : "
     6513            "Illegal type in coherence request");
     6514
    60156515        break;
    60166516      }
     6517    ////////////////////////
    60176518    case CC_RECEIVE_CLEANUP:
    60186519      {
    6019         // wait for a valid cleanup flit
    6020         // wait for a WOK in the CC_RECEIVE to CLEANUP fifo
    6021         if(not p_dspin_in.write or not m_cc_receive_to_cleanup_fifo.wok()) break;
    6022 
    6023         bool eop = (
    6024             DspinDhccpParam::dspin_get(
    6025               p_dspin_in.data.read(),
    6026               DspinDhccpParam::FROM_L1_EOP)
    6027             == 0x1);
     6520        // write first CLEANUP flit in CC_RECEIVE to CLEANUP fifo
     6521
     6522        if(not p_dspin_in.write or not m_cc_receive_to_cleanup_fifo.wok())
     6523          break;
     6524
     6525        assert(not p_dspin_in.eop.read() and
     6526            "VCI_MEM_CACHE ERROR in CC_RECEIVE : "
     6527            "CLEANUP command must have two flits");
    60286528
    60296529        cc_receive_to_cleanup_fifo_put = true;
    6030         if(eop)
    6031         {
    6032           r_cc_receive_fsm = CC_RECEIVE_IDLE;
    6033         }
     6530        r_cc_receive_fsm               = CC_RECEIVE_CLEANUP_EOP;
    60346531
    60356532        break;
    60366533      }
     6534    ////////////////////////////
     6535    case CC_RECEIVE_CLEANUP_EOP:
     6536      {
     6537        // write second CLEANUP flit in CC_RECEIVE to CLEANUP fifo
     6538
     6539        if(not p_dspin_in.write or not m_cc_receive_to_cleanup_fifo.wok())
     6540          break;
     6541
     6542        assert(p_dspin_in.eop.read() and
     6543            "VCI_MEM_CACHE ERROR in CC_RECEIVE : "
     6544            "CLEANUP command must have two flits");
     6545
     6546        cc_receive_to_cleanup_fifo_put = true;
     6547        r_cc_receive_fsm               = CC_RECEIVE_IDLE;
     6548
     6549        break;
     6550      }
     6551
     6552    //////////////////////////
    60376553    case CC_RECEIVE_MULTI_ACK:
    60386554      {
    6039         // wait for a valid multicast acknowledgement flit
     6555        // write MULTI_ACK flit in CC_RECEIVE to MULTI_ACK fifo
     6556
    60406557        // wait for a WOK in the CC_RECEIVE to MULTI_ACK fifo
    6041         if(not p_dspin_in.write or not m_cc_receive_to_multi_ack_fifo.wok()) break;
    6042 
    6043         bool eop = (
    6044             DspinDhccpParam::dspin_get(
    6045               p_dspin_in.data.read(),
    6046               DspinDhccpParam::FROM_L1_EOP)
    6047             == 0x1);
    6048 
    6049         cc_receive_to_multi_ack_fifo_put  = true;
    6050         if(eop)
    6051         {
    6052           r_cc_receive_fsm = CC_RECEIVE_IDLE;
    6053         }
    6054 
     6558        if(not p_dspin_in.write or not m_cc_receive_to_multi_ack_fifo.wok())
     6559          break;
     6560
     6561        assert(p_dspin_in.eop.read() and
     6562            "VCI_MEM_CACHE ERROR in CC_RECEIVE : "
     6563            "MULTI_ACK command must have one flit");
     6564
     6565        cc_receive_to_multi_ack_fifo_put = true;
     6566        r_cc_receive_fsm                 = CC_RECEIVE_IDLE;
    60556567        break;
    60566568      }
    6057     default:
    6058       {
    6059         assert(
    6060             false &&
    6061             "VCI_MEM_CACHE ERROR: Invalid state in CC_RECEIVE FSM");
    6062       }
    60636569  }
    6064   /////////////////////////////////////////////////////////////////////
     6570  //////////////////////////////////////////////////////////////////////////
    60656571  //    TGT_RSP FSM
    6066   /////////////////////////////////////////////////////////////////////
     6572  //////////////////////////////////////////////////////////////////////////
    60676573  // The TGT_RSP fsm sends the responses on the VCI target port
    6068   // with a round robin priority between six requests :
     6574  // with a round robin priority between eigth requests :
     6575  // - r_config_to_tgt_rsp_req
     6576  // - r_tgt_cmd_to_tgt_rsp_req
    60696577  // - r_read_to_tgt_rsp_req
    60706578  // - r_write_to_tgt_rsp_req
     
    60736581  // - r_xram_rsp_to_tgt_rsp_req
    60746582  // - r_multi_ack_to_tgt_rsp_req
    6075   // The  ordering is :  read > write > cas > xram > init > cleanup
    6076   /////////////////////////////////////////////////////////////////////
     6583  //
     6584  // The ordering is :
     6585  //   config >tgt_cmd > read > write > cas > xram > multi_ack > cleanup
     6586  //////////////////////////////////////////////////////////////////////////
    60776587
    60786588  switch(r_tgt_rsp_fsm.read())
    60796589  {
    6080     case TGT_RSP_READ_IDLE:
    6081     {
    6082       // write requests have the highest priority
    6083       if(r_write_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_WRITE;
    6084       else if(r_cas_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CAS  ;
     6590    /////////////////////////
     6591    case TGT_RSP_CONFIG_IDLE:  // tgt_cmd requests have the highest priority
     6592    {
     6593      if(r_tgt_cmd_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
     6594      else if(r_read_to_tgt_rsp_req)
     6595      {
     6596        r_tgt_rsp_fsm = TGT_RSP_READ;
     6597        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
     6598      }
     6599      else if(r_write_to_tgt_rsp_req)     r_tgt_rsp_fsm = TGT_RSP_WRITE;
     6600      else if(r_cas_to_tgt_rsp_req)       r_tgt_rsp_fsm = TGT_RSP_CAS;
    60856601      else if(r_xram_rsp_to_tgt_rsp_req)
    60866602      {
     
    60886604        r_tgt_rsp_cpt = r_xram_rsp_to_tgt_rsp_word.read();
    60896605      }
    6090       else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_INIT   ;
    6091       else if(r_cleanup_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
    6092       else if(r_read_to_tgt_rsp_req)
     6606      else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK;
     6607      else if(r_cleanup_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6608      else if(r_config_to_tgt_rsp_req)    r_tgt_rsp_fsm = TGT_RSP_CONFIG;
     6609      break;
     6610    }
     6611    //////////////////////////
     6612    case TGT_RSP_TGT_CMD_IDLE: // read requests have the highest priority
     6613    {
     6614      if(r_read_to_tgt_rsp_req)
    60936615      {
    60946616        r_tgt_rsp_fsm = TGT_RSP_READ;
    60956617        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
    60966618      }
    6097       break;
    6098     }
    6099     ////////////////////////
    6100     case TGT_RSP_WRITE_IDLE:  // cas requests have the highest priority
    6101     {
    6102       if(r_cas_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CAS;
     6619      else if(r_write_to_tgt_rsp_req)     r_tgt_rsp_fsm = TGT_RSP_WRITE;
     6620      else if(r_cas_to_tgt_rsp_req)       r_tgt_rsp_fsm = TGT_RSP_CAS;
    61036621      else if(r_xram_rsp_to_tgt_rsp_req)
    61046622      {
     
    61066624        r_tgt_rsp_cpt = r_xram_rsp_to_tgt_rsp_word.read();
    61076625      }
    6108       else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_INIT   ;
    6109       else if(r_cleanup_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6626      else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK;
     6627      else if(r_cleanup_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6628      else if(r_config_to_tgt_rsp_req)    r_tgt_rsp_fsm = TGT_RSP_CONFIG;
     6629      else if(r_tgt_cmd_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
     6630      break;
     6631    }
     6632    ///////////////////////
     6633    case TGT_RSP_READ_IDLE: // write requests have the highest priority
     6634    {
     6635      if(r_write_to_tgt_rsp_req)          r_tgt_rsp_fsm = TGT_RSP_WRITE;
     6636      else if(r_cas_to_tgt_rsp_req)       r_tgt_rsp_fsm = TGT_RSP_CAS;
     6637      else if(r_xram_rsp_to_tgt_rsp_req)
     6638      {
     6639        r_tgt_rsp_fsm = TGT_RSP_XRAM;
     6640        r_tgt_rsp_cpt = r_xram_rsp_to_tgt_rsp_word.read();
     6641      }
     6642      else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK;
     6643      else if(r_cleanup_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6644      else if(r_config_to_tgt_rsp_req)    r_tgt_rsp_fsm = TGT_RSP_CONFIG;
     6645      else if(r_tgt_cmd_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
    61106646      else if(r_read_to_tgt_rsp_req)
    61116647      {
     
    61136649        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
    61146650      }
    6115 
    6116       else if(r_write_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_WRITE;
    6117       break;
    6118     }
    6119     ///////////////////////
    6120     case TGT_RSP_CAS_IDLE:   // xram_rsp requests have the highest priority
    6121     {
    6122       if(r_xram_rsp_to_tgt_rsp_req)
     6651      break;
     6652    }
     6653    ////////////////////////
     6654    case TGT_RSP_WRITE_IDLE: // cas requests have the highest priority
     6655    {
     6656      if(r_cas_to_tgt_rsp_req)            r_tgt_rsp_fsm = TGT_RSP_CAS;
     6657      else if(r_xram_rsp_to_tgt_rsp_req)
    61236658      {
    61246659        r_tgt_rsp_fsm = TGT_RSP_XRAM;
    61256660        r_tgt_rsp_cpt = r_xram_rsp_to_tgt_rsp_word.read();
    61266661      }
    6127       else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_INIT   ;
    6128       else if(r_cleanup_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6662      else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK;
     6663      else if(r_cleanup_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6664      else if(r_config_to_tgt_rsp_req)    r_tgt_rsp_fsm = TGT_RSP_CONFIG;
     6665      else if(r_tgt_cmd_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
    61296666      else if(r_read_to_tgt_rsp_req)
    61306667      {
     
    61326669        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
    61336670      }
    6134       else if(r_write_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_WRITE;
    6135       else if(r_cas_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CAS  ;
     6671      else if(r_write_to_tgt_rsp_req)     r_tgt_rsp_fsm = TGT_RSP_WRITE;
    61366672      break;
    61376673    }
    61386674    ///////////////////////
    6139     case TGT_RSP_XRAM_IDLE:   // init requests have the highest priority
    6140     {
    6141 
    6142       if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_INIT   ;
    6143       else if(r_cleanup_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6675    case TGT_RSP_CAS_IDLE: // xram_rsp requests have the highest priority
     6676    {
     6677      if(r_xram_rsp_to_tgt_rsp_req)
     6678      {
     6679        r_tgt_rsp_fsm = TGT_RSP_XRAM;
     6680        r_tgt_rsp_cpt = r_xram_rsp_to_tgt_rsp_word.read();
     6681      }
     6682      else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK   ;
     6683      else if(r_cleanup_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6684      else if(r_config_to_tgt_rsp_req)    r_tgt_rsp_fsm = TGT_RSP_CONFIG;
     6685      else if(r_tgt_cmd_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
    61446686      else if(r_read_to_tgt_rsp_req)
    61456687      {
     
    61476689        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
    61486690      }
    6149       else if(r_write_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_WRITE;
    6150       else if(r_cas_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CAS  ;
     6691      else if(r_write_to_tgt_rsp_req)     r_tgt_rsp_fsm = TGT_RSP_WRITE;
     6692      else if(r_cas_to_tgt_rsp_req)       r_tgt_rsp_fsm = TGT_RSP_CAS  ;
     6693      break;
     6694    }
     6695    ///////////////////////
     6696    case TGT_RSP_XRAM_IDLE: // multi ack requests have the highest priority
     6697    {
     6698
     6699      if(r_multi_ack_to_tgt_rsp_req)      r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK   ;
     6700      else if(r_cleanup_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6701      else if(r_config_to_tgt_rsp_req)    r_tgt_rsp_fsm = TGT_RSP_CONFIG;
     6702      else if(r_tgt_cmd_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
     6703      else if(r_read_to_tgt_rsp_req)
     6704      {
     6705        r_tgt_rsp_fsm = TGT_RSP_READ;
     6706        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
     6707      }
     6708      else if(r_write_to_tgt_rsp_req)     r_tgt_rsp_fsm = TGT_RSP_WRITE;
     6709      else if(r_cas_to_tgt_rsp_req)       r_tgt_rsp_fsm = TGT_RSP_CAS  ;
    61516710      else if(r_xram_rsp_to_tgt_rsp_req)
    61526711      {
     
    61566715      break;
    61576716    }
    6158     ///////////////////////
    6159     case TGT_RSP_INIT_IDLE:   // cleanup requests have the highest priority
    6160     {
    6161       if(r_cleanup_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6717    ////////////////////////////
     6718    case TGT_RSP_MULTI_ACK_IDLE: // cleanup requests have the highest priority
     6719    {
     6720      if(r_cleanup_to_tgt_rsp_req)        r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6721      else if(r_config_to_tgt_rsp_req)    r_tgt_rsp_fsm = TGT_RSP_CONFIG;
     6722      else if(r_tgt_cmd_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
    61626723      else if(r_read_to_tgt_rsp_req)
    61636724      {
     
    61656726        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
    61666727      }
    6167       else if(r_write_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_WRITE;
    6168       else if(r_cas_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CAS  ;
     6728      else if(r_write_to_tgt_rsp_req)     r_tgt_rsp_fsm = TGT_RSP_WRITE;
     6729      else if(r_cas_to_tgt_rsp_req)       r_tgt_rsp_fsm = TGT_RSP_CAS  ;
    61696730      else if(r_xram_rsp_to_tgt_rsp_req)
    61706731      {
     
    61726733        r_tgt_rsp_cpt = r_xram_rsp_to_tgt_rsp_word.read();
    61736734      }
    6174       else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_INIT;
    6175       break;
    6176     }
    6177     ///////////////////////
    6178     case TGT_RSP_CLEANUP_IDLE:    // read requests have the highest priority
    6179     {
    6180       if(r_read_to_tgt_rsp_req)
     6735      else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK;
     6736      break;
     6737    }
     6738    //////////////////////////
     6739    case TGT_RSP_CLEANUP_IDLE: // tgt cmd requests have the highest priority
     6740    {
     6741      if(r_config_to_tgt_rsp_req)         r_tgt_rsp_fsm = TGT_RSP_CONFIG;
     6742      else if(r_tgt_cmd_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
     6743      else if(r_read_to_tgt_rsp_req)
    61816744      {
    61826745        r_tgt_rsp_fsm = TGT_RSP_READ;
    61836746        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
    61846747      }
    6185       else if(r_write_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_WRITE;
    6186       else if(r_cas_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CAS  ;
     6748      else if(r_write_to_tgt_rsp_req)     r_tgt_rsp_fsm = TGT_RSP_WRITE;
     6749      else if(r_cas_to_tgt_rsp_req)       r_tgt_rsp_fsm = TGT_RSP_CAS  ;
    61876750      else if(r_xram_rsp_to_tgt_rsp_req)
    61886751      {
     
    61906753        r_tgt_rsp_cpt = r_xram_rsp_to_tgt_rsp_word.read();
    61916754      }
    6192       else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_INIT   ;
    6193       else if(r_cleanup_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6755      else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK   ;
     6756      else if(r_cleanup_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6757      break;
     6758    }
     6759    ////////////////////
     6760    case TGT_RSP_CONFIG:  // send the response for a config transaction
     6761    {
     6762      if ( p_vci_tgt.rspack )
     6763      {
     6764        r_config_to_tgt_rsp_req = false;
     6765        r_tgt_rsp_fsm           = TGT_RSP_CONFIG_IDLE;
     6766
     6767#if DEBUG_MEMC_TGT_RSP
     6768if( m_debug )
     6769{
     6770  std::cout
     6771    << "  <MEMC " << name()
     6772    << " TGT_RSP_CONFIG>  Config transaction completed response"
     6773    << " / rsrcid = " << std::hex << r_config_to_tgt_rsp_srcid.read()
     6774    << " / rtrdid = " << r_config_to_tgt_rsp_trdid.read()
     6775    << " / rpktid = " << r_config_to_tgt_rsp_pktid.read()
     6776    << std::endl;
     6777}
     6778#endif
     6779      }
     6780      break;
     6781    }
     6782    /////////////////////
     6783    case TGT_RSP_TGT_CMD: // send the response for a segmentation violation
     6784    {
     6785      if ( p_vci_tgt.rspack )
     6786      {
     6787        r_tgt_cmd_to_tgt_rsp_req = false;
     6788        r_tgt_rsp_fsm            = TGT_RSP_TGT_CMD_IDLE;
     6789
     6790#if DEBUG_MEMC_TGT_RSP
     6791if( m_debug )
     6792{
     6793  std::cout
     6794    << "  <MEMC " << name()
     6795    << " TGT_RSP_TGT_CMD> Segmentation violation response"
     6796    << " / rsrcid = " << std::hex << r_tgt_cmd_to_tgt_rsp_srcid.read()
     6797    << " / rtrdid = " << r_tgt_cmd_to_tgt_rsp_trdid.read()
     6798    << " / rpktid = " << r_tgt_cmd_to_tgt_rsp_pktid.read()
     6799    << std::endl;
     6800}
     6801#endif
     6802      }
    61946803      break;
    61956804    }
     
    62016810
    62026811#if DEBUG_MEMC_TGT_RSP
    6203 if( m_debug_tgt_rsp_fsm )
     6812if( m_debug )
    62046813{
    62056814  std::cout
    6206     << "  <MEMC " << name() << ".TGT_RSP_READ> Read response"
    6207     << " / rsrcid = " << std::dec << r_read_to_tgt_rsp_srcid.read()
     6815    << "  <MEMC " << name() << " TGT_RSP_READ> Read response"
     6816    << " / rsrcid = " << std::hex << r_read_to_tgt_rsp_srcid.read()
    62086817    << " / rtrdid = " << r_read_to_tgt_rsp_trdid.read()
    62096818    << " / rpktid = " << r_read_to_tgt_rsp_pktid.read()
    6210     << " / rdata = " << std::hex << r_read_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read()
     6819    << " / rdata = " << r_read_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read()
    62116820    << " / cpt = " << std::dec << r_tgt_rsp_cpt.read() << std::endl;
    62126821}
    62136822#endif
    6214  
    6215         uint32_t last_word_idx = r_read_to_tgt_rsp_word.read() + r_read_to_tgt_rsp_length.read() - 1;
     6823
     6824        uint32_t last_word_idx = r_read_to_tgt_rsp_word.read() +
     6825                                 r_read_to_tgt_rsp_length.read() - 1;
    62166826        bool     is_last_word  = (r_tgt_rsp_cpt.read() == last_word_idx);
    62176827        bool     is_ll         = ((r_read_to_tgt_rsp_pktid.read() & 0x7) == TYPE_LL);
    62186828
    6219         if ( (is_last_word and not is_ll) or (r_tgt_rsp_key_sent.read() and is_ll))
     6829        if ((is_last_word              and not is_ll) or
     6830            (r_tgt_rsp_key_sent.read() and is_ll))
    62206831        {
    62216832          // Last word in case of READ or second flit in case if LL
     
    62456856
    62466857#if DEBUG_MEMC_TGT_RSP
    6247         if(m_debug_tgt_rsp_fsm)
    6248         {
    6249           std::cout << "  <MEMC " << name() << ".TGT_RSP_WRITE> Write response"
    6250                     << " / rsrcid = " << std::dec << r_write_to_tgt_rsp_srcid.read()
    6251                     << " / rtrdid = " << r_write_to_tgt_rsp_trdid.read()
    6252                     << " / rpktid = " << r_write_to_tgt_rsp_pktid.read() << std::endl;
    6253         }
     6858if(m_debug)
     6859std::cout << "  <MEMC " << name() << " TGT_RSP_WRITE> Write response"
     6860          << " / rsrcid = " << std::hex << r_write_to_tgt_rsp_srcid.read()
     6861          << " / rtrdid = " << r_write_to_tgt_rsp_trdid.read()
     6862          << " / rpktid = " << r_write_to_tgt_rsp_pktid.read() << std::endl;
    62546863#endif
    62556864        r_tgt_rsp_fsm = TGT_RSP_WRITE_IDLE;
     
    62586867      break;
    62596868    }
    6260     ///////////////////
     6869    /////////////////////
    62616870    case TGT_RSP_CLEANUP:   // pas clair pour moi (AG)
    62626871    {
     
    62656874
    62666875#if DEBUG_MEMC_TGT_RSP
    6267         if(m_debug_tgt_rsp_fsm)
    6268         {
    6269           std::cout << "  <MEMC " << name() << ".TGT_RSP_CLEANUP> Cleanup response"
    6270                     << " / rsrcid = " << std::dec << r_cleanup_to_tgt_rsp_srcid.read()
    6271                     << " / rtrdid = " << r_cleanup_to_tgt_rsp_trdid.read()
    6272                     << " / rpktid = " << r_cleanup_to_tgt_rsp_pktid.read() << std::endl;
    6273         }
     6876if(m_debug)
     6877std::cout << "  <MEMC " << name() << " TGT_RSP_CLEANUP> Cleanup response"
     6878          << " / rsrcid = " << std::hex << r_cleanup_to_tgt_rsp_srcid.read()
     6879          << " / rtrdid = " << r_cleanup_to_tgt_rsp_trdid.read()
     6880          << " / rpktid = " << r_cleanup_to_tgt_rsp_pktid.read() << std::endl;
    62746881#endif
    62756882        r_tgt_rsp_fsm = TGT_RSP_CLEANUP_IDLE;
     
    62786885      break;
    62796886    }
    6280     //////////////////
     6887    /////////////////
    62816888    case TGT_RSP_CAS:    // send one atomic word response
    62826889    {
     
    62856892
    62866893#if DEBUG_MEMC_TGT_RSP
    6287         if(m_debug_tgt_rsp_fsm)
    6288         {
    6289           std::cout << "  <MEMC " << name() << ".TGT_RSP_CAS> CAS response"
    6290                     << " / rsrcid = " << std::dec << r_cas_to_tgt_rsp_srcid.read()
    6291                     << " / rtrdid = " << r_cas_to_tgt_rsp_trdid.read()
    6292                     << " / rpktid = " << r_cas_to_tgt_rsp_pktid.read() << std::endl;
    6293         }
     6894if(m_debug)
     6895std::cout << "  <MEMC " << name() << " TGT_RSP_CAS> CAS response"
     6896          << " / rsrcid = " << std::hex << r_cas_to_tgt_rsp_srcid.read()
     6897          << " / rtrdid = " << r_cas_to_tgt_rsp_trdid.read()
     6898          << " / rpktid = " << r_cas_to_tgt_rsp_pktid.read() << std::endl;
    62946899#endif
    62956900        r_tgt_rsp_fsm = TGT_RSP_CAS_IDLE;
     
    62986903      break;
    62996904    }
    6300 
    6301     ///////////////////////
     6905    //////////////////
    63026906    case TGT_RSP_XRAM:    // send the response after XRAM access
    63036907    {
     
    63066910
    63076911#if DEBUG_MEMC_TGT_RSP
    6308 if( m_debug_tgt_rsp_fsm )
    6309 {
    6310   std::cout
    6311     << "  <MEMC " << name() << ".TGT_RSP_XRAM> Response following XRAM access"
    6312     << " / rsrcid = " << std::dec << r_xram_rsp_to_tgt_rsp_srcid.read()
    6313     << " / rtrdid = " << r_xram_rsp_to_tgt_rsp_trdid.read()
    6314     << " / rpktid = " << r_xram_rsp_to_tgt_rsp_pktid.read()
    6315     << " / rdata = " << std::hex << r_xram_rsp_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read()
    6316     << " / cpt = " << std::dec << r_tgt_rsp_cpt.read() << std::endl;
    6317 }
    6318 #endif
    6319         uint32_t last_word_idx = r_xram_rsp_to_tgt_rsp_word.read() + r_xram_rsp_to_tgt_rsp_length.read() - 1;
     6912if( m_debug )
     6913std::cout << "  <MEMC " << name() << " TGT_RSP_XRAM> Response following XRAM access"
     6914          << " / rsrcid = " << std::hex << r_xram_rsp_to_tgt_rsp_srcid.read()
     6915          << " / rtrdid = " << r_xram_rsp_to_tgt_rsp_trdid.read()
     6916          << " / rpktid = " << r_xram_rsp_to_tgt_rsp_pktid.read()
     6917          << " / rdata = " << r_xram_rsp_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read()
     6918          << " / cpt = " << std::dec << r_tgt_rsp_cpt.read() << std::endl;
     6919#endif
     6920        uint32_t last_word_idx = r_xram_rsp_to_tgt_rsp_word.read() +
     6921                                 r_xram_rsp_to_tgt_rsp_length.read() - 1;
    63206922        bool     is_last_word  = (r_tgt_rsp_cpt.read() == last_word_idx);
    63216923        bool     is_ll         = ((r_xram_rsp_to_tgt_rsp_pktid.read() & 0x7) == TYPE_LL);
     
    63356937          {
    63366938            r_tgt_rsp_key_sent = true;                     // Send second flit of ll
    6337           }                                                                           
     6939          }
    63386940          else
    63396941          {
     
    63446946      break;
    63456947    }
    6346     //////////////////
    6347     case TGT_RSP_INIT:    // send the write response after coherence transaction
     6948    ///////////////////////
     6949    case TGT_RSP_MULTI_ACK:    // send the write response after coherence transaction
    63486950    {
    63496951      if(p_vci_tgt.rspack)
     
    63516953
    63526954#if DEBUG_MEMC_TGT_RSP
    6353         if(m_debug_tgt_rsp_fsm)
    6354         {
    6355           std::cout << "  <MEMC " << name() << ".TGT_RSP_INIT> Write response after coherence transaction"
    6356                     << " / rsrcid = " << std::dec << r_multi_ack_to_tgt_rsp_srcid.read()
    6357                     << " / rtrdid = " << r_multi_ack_to_tgt_rsp_trdid.read()
    6358                     << " / rpktid = " << r_multi_ack_to_tgt_rsp_pktid.read() << std::endl;
    6359         }
    6360 #endif
    6361         r_tgt_rsp_fsm = TGT_RSP_INIT_IDLE;
     6955if(m_debug)
     6956std::cout << "  <MEMC " << name() << " TGT_RSP_MULTI_ACK> Write response after coherence transaction"
     6957          << " / rsrcid = " << std::hex << r_multi_ack_to_tgt_rsp_srcid.read()
     6958          << " / rtrdid = " << r_multi_ack_to_tgt_rsp_trdid.read()
     6959          << " / rpktid = " << r_multi_ack_to_tgt_rsp_pktid.read() << std::endl;
     6960#endif
     6961        r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK_IDLE;
    63626962        r_multi_ack_to_tgt_rsp_req = false;
    63636963      }
     
    63696969  //    ALLOC_UPT FSM
    63706970  ////////////////////////////////////////////////////////////////////////////////////
    6371   // The ALLOC_UPT FSM allocates the access to the Update/Inval Table (UPT).
    6372   // with a round robin priority between three FSMs : MULTI_ACK > WRITE > XRAM_RSP > CLEANUP
    6373   // - The WRITE FSM initiates update transactions and sets  new entry in UPT.
    6374   // - The XRAM_RSP FSM initiates inval transactions and sets new entry in UPT.
     6971  // The ALLOC_UPT FSM allocates the access to the Update/Inval Table (UPT),
     6972  // with a round robin priority between six FSMs, with the following order:
     6973  //  CONFIG > MULTI_ACK > WRITE > XRAM_RSP > CLEANUP > CAS
     6974  // - The CONFIG FSM initiates an inval transaction and sets a new entry in UPT.
    63756975  // - The MULTI_ACK FSM complete those trasactions and erase the UPT entry.
     6976  // - The WRITE FSM initiates update transaction and sets a new entry in UPT.
     6977  // - The XRAM_RSP FSM initiates an inval transactions and sets a new entry in UPT.
    63766978  // - The CLEANUP  FSM decrement an entry in UPT.
     6979  // - The CAS FSM does the same thing as the WRITE FSM.
    63776980  // The resource is always allocated.
    63786981  /////////////////////////////////////////////////////////////////////////////////////
     
    63806983  switch(r_alloc_upt_fsm.read())
    63816984  {
    6382 
    6383       ////////////////////////
    6384     case ALLOC_UPT_MULTI_ACK:
    6385       if((r_multi_ack_fsm.read() != MULTI_ACK_UPT_LOCK) &&
     6985      //////////////////////
     6986      case ALLOC_UPT_CONFIG:   // allocated to CONFIG FSM
     6987      if (r_config_fsm.read() != CONFIG_DIR_UPT_LOCK)
     6988      {
     6989        if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
     6990          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
     6991               
     6992        else if((r_write_fsm.read() == WRITE_UPT_LOCK) or
     6993                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
     6994          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     6995
     6996        else if(r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     6997          r_alloc_upt_fsm = ALLOC_UPT_XRAM_RSP;
     6998
     6999        else if(r_cleanup_fsm.read() == CLEANUP_UPT_LOCK)
     7000          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
     7001
     7002        else if((r_cas_fsm.read() == CAS_UPT_LOCK) or
     7003                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
     7004          r_alloc_upt_fsm = ALLOC_UPT_CAS;
     7005      }
     7006      break;
     7007
     7008      /////////////////////////
     7009      case ALLOC_UPT_MULTI_ACK:   // allocated to MULTI_ACK FSM
     7010      if( (r_multi_ack_fsm.read() != MULTI_ACK_UPT_LOCK) and
    63867011          (r_multi_ack_fsm.read() != MULTI_ACK_UPT_CLEAR))
    63877012      {
    6388         if((r_write_fsm.read() == WRITE_UPT_LOCK) ||
     7013        if((r_write_fsm.read() == WRITE_UPT_LOCK) or
    63897014            (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    63907015          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     
    63967021          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
    63977022
    6398         else if((r_cas_fsm.read() == CAS_UPT_LOCK) ||
     7023        else if((r_cas_fsm.read() == CAS_UPT_LOCK) or
    63997024                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    64007025          r_alloc_upt_fsm = ALLOC_UPT_CAS;
     7026
     7027        else if(r_config_fsm.read() == CONFIG_DIR_UPT_LOCK)
     7028          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
    64017029      }
    64027030      break;
    64037031
    64047032      /////////////////////
    6405     case ALLOC_UPT_WRITE:
    6406       if((r_write_fsm.read() != WRITE_UPT_LOCK) &&
     7033      case ALLOC_UPT_WRITE:   // allocated to WRITE FSM
     7034      if((r_write_fsm.read() != WRITE_UPT_LOCK) and
    64077035          (r_write_fsm.read() != WRITE_BC_UPT_LOCK))
    64087036      {
     
    64137041          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
    64147042
    6415         else if((r_cas_fsm.read() == CAS_UPT_LOCK) ||
     7043        else if((r_cas_fsm.read() == CAS_UPT_LOCK) or
    64167044                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    64177045          r_alloc_upt_fsm = ALLOC_UPT_CAS;
    64187046
     7047        else if(r_config_fsm.read() == CONFIG_DIR_UPT_LOCK)
     7048          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
     7049
    64197050        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    64207051          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
     
    64237054
    64247055      ////////////////////////
    6425     case ALLOC_UPT_XRAM_RSP:
     7056      case ALLOC_UPT_XRAM_RSP:
    64267057      if(r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK)
    64277058      {
     
    64297060          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
    64307061
    6431         else if((r_cas_fsm.read() == CAS_UPT_LOCK) ||
     7062        else if((r_cas_fsm.read() == CAS_UPT_LOCK) or
    64327063                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    64337064          r_alloc_upt_fsm = ALLOC_UPT_CAS;
    64347065
     7066        else if(r_config_fsm.read() == CONFIG_DIR_UPT_LOCK)
     7067          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
     7068
    64357069        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    64367070          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
    64377071
    6438         else if((r_write_fsm.read() == WRITE_UPT_LOCK)   ||
     7072        else if((r_write_fsm.read() == WRITE_UPT_LOCK)   or
    64397073                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    64407074          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     
    64437077
    64447078      //////////////////////////
    6445     case ALLOC_UPT_CLEANUP:
    6446       if((r_cleanup_fsm.read() != CLEANUP_UPT_LOCK     ) &&
     7079      case ALLOC_UPT_CLEANUP:
     7080      if((r_cleanup_fsm.read() != CLEANUP_UPT_LOCK     ) and
    64477081         (r_cleanup_fsm.read() != CLEANUP_UPT_DECREMENT))
    64487082      {
    6449         if((r_cas_fsm.read() == CAS_UPT_LOCK) ||
     7083        if((r_cas_fsm.read() == CAS_UPT_LOCK) or
    64507084            (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    64517085          r_alloc_upt_fsm = ALLOC_UPT_CAS;
    64527086
     7087        else if(r_config_fsm.read() == CONFIG_DIR_UPT_LOCK)
     7088          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
     7089
    64537090        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    64547091          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
    64557092
    6456         else if((r_write_fsm.read() == WRITE_UPT_LOCK) ||
     7093        else if((r_write_fsm.read() == WRITE_UPT_LOCK) or
    64577094                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    64587095          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     
    64647101
    64657102      //////////////////////////
    6466     case ALLOC_UPT_CAS:
    6467       if((r_cas_fsm.read() != CAS_UPT_LOCK) &&
     7103      case ALLOC_UPT_CAS:
     7104      if((r_cas_fsm.read() != CAS_UPT_LOCK) and
    64687105          (r_cas_fsm.read() != CAS_BC_UPT_LOCK))
    64697106      {
    6470         if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
     7107        if(r_config_fsm.read() == CONFIG_DIR_UPT_LOCK)
     7108          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
     7109
     7110        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    64717111          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
    64727112
    6473         else if((r_write_fsm.read() == WRITE_UPT_LOCK) ||
     7113        else if((r_write_fsm.read() == WRITE_UPT_LOCK) or
    64747114                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    64757115          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     
    64897129  ////////////////////////////////////////////////////////////////////////////////////
    64907130  // The ALLOC_DIR FSM allocates the access to the directory and
    6491   // the data cache with a round robin priority between 5 user FSMs :
    6492   // The cyclic ordering is READ > WRITE > CAS > CLEANUP > XRAM_RSP
     7131  // the data cache with a round robin priority between 6 user FSMs :
     7132  // The cyclic ordering is CONFIG > READ > WRITE > CAS > CLEANUP > XRAM_RSP
    64937133  // The ressource is always allocated.
    64947134  /////////////////////////////////////////////////////////////////////////////////////
     
    64967136  switch(r_alloc_dir_fsm.read())
    64977137  {
    6498     case ALLOC_DIR_RESET:
    6499       // Initializes the directory one SET each cycle. All the WAYS of a SET are
    6500       // initialize in parallel
     7138    /////////////////////
     7139    case ALLOC_DIR_RESET: // Initializes the directory one SET per cycle.
     7140                          // All the WAYS of a SET initialized in parallel
    65017141
    65027142      r_alloc_dir_reset_cpt.write(r_alloc_dir_reset_cpt.read() + 1);
     
    65057145      {
    65067146        m_cache_directory.init();
    6507 
    65087147        r_alloc_dir_fsm = ALLOC_DIR_READ;
    65097148      }
    65107149      break;
    65117150
    6512       ////////////////////
    6513     case ALLOC_DIR_READ:
    6514       if(((r_read_fsm.read()        != READ_DIR_REQ)   &&
    6515           (r_read_fsm.read()        != READ_DIR_LOCK)   &&
    6516           (r_read_fsm.read()        != READ_TRT_LOCK)   &&
    6517           (r_read_fsm.read()        != READ_HEAP_REQ))
    6518           ||
    6519           ((r_read_fsm.read()       == READ_TRT_LOCK)   &&
    6520            (r_alloc_trt_fsm.read()  == ALLOC_TRT_READ)))
    6521       {
     7151    //////////////////////
     7152    case ALLOC_DIR_CONFIG:    // allocated to CONFIG FSM
     7153    if ( (r_config_fsm.read()    != CONFIG_DIR_REQ) and
     7154         (r_config_fsm.read()    != CONFIG_DIR_ACCESS) and
     7155         (r_config_fsm.read()    != CONFIG_DIR_UPT_LOCK) )
     7156    {
     7157        if(r_read_fsm.read() == READ_DIR_REQ)
     7158          r_alloc_dir_fsm = ALLOC_DIR_READ;
     7159
     7160        else if(r_write_fsm.read() == WRITE_DIR_REQ)
     7161          r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     7162
     7163        else if(r_cas_fsm.read() == CAS_DIR_REQ)
     7164          r_alloc_dir_fsm = ALLOC_DIR_CAS;
     7165
     7166        else if(r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
     7167          r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     7168
     7169        else if(r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
     7170          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
     7171    }
     7172    break;
     7173
     7174    ////////////////////
     7175    case ALLOC_DIR_READ:    // allocated to READ FSM
     7176    if( ((r_read_fsm.read()      != READ_DIR_REQ)   and
     7177         (r_read_fsm.read()      != READ_DIR_LOCK)   and
     7178         (r_read_fsm.read()      != READ_TRT_LOCK)   and
     7179         (r_read_fsm.read()      != READ_HEAP_REQ))
     7180         or
     7181         ((r_read_fsm.read()       == READ_TRT_LOCK)   and
     7182          (r_alloc_trt_fsm.read()  == ALLOC_TRT_READ)) )
     7183    {
    65227184        if(r_write_fsm.read() == WRITE_DIR_REQ)
    65237185          r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     
    65317193        else if(r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    65327194          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    6533       }
    6534       break;
    6535 
    6536       /////////////////////
    6537     case ALLOC_DIR_WRITE:
    6538       if(((r_write_fsm.read()       != WRITE_DIR_REQ)  &&
    6539           (r_write_fsm.read()       != WRITE_DIR_LOCK)  &&
    6540           (r_write_fsm.read()       != WRITE_DIR_READ)  &&
    6541           (r_write_fsm.read()       != WRITE_DIR_HIT)  &&
    6542           (r_write_fsm.read()       != WRITE_BC_TRT_LOCK)  &&
    6543           (r_write_fsm.read()       != WRITE_BC_UPT_LOCK)  &&
    6544           (r_write_fsm.read()       != WRITE_MISS_TRT_LOCK)  &&
    6545           (r_write_fsm.read()       != WRITE_UPT_LOCK)  &&
    6546           (r_write_fsm.read()       != WRITE_UPT_HEAP_LOCK))
    6547           ||
    6548           ((r_write_fsm.read()      == WRITE_UPT_HEAP_LOCK)  &&
    6549            (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE))
    6550           ||
    6551           ((r_write_fsm.read()      == WRITE_MISS_TRT_LOCK)  &&
    6552            (r_alloc_trt_fsm.read()  == ALLOC_TRT_WRITE)))
    6553       {
     7195
     7196        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
     7197          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     7198    }
     7199    break;
     7200
     7201    /////////////////////
     7202    case ALLOC_DIR_WRITE:    // allocated to WRITE FSM
     7203    if(((r_write_fsm.read()       != WRITE_DIR_REQ)  and
     7204        (r_write_fsm.read()       != WRITE_DIR_LOCK)  and
     7205        (r_write_fsm.read()       != WRITE_DIR_READ)  and
     7206        (r_write_fsm.read()       != WRITE_DIR_HIT)  and
     7207        (r_write_fsm.read()       != WRITE_BC_TRT_LOCK)  and
     7208        (r_write_fsm.read()       != WRITE_BC_UPT_LOCK)  and
     7209        (r_write_fsm.read()       != WRITE_MISS_TRT_LOCK)  and
     7210        (r_write_fsm.read()       != WRITE_UPT_LOCK)  and
     7211        (r_write_fsm.read()       != WRITE_UPT_HEAP_LOCK))
     7212        or
     7213        ((r_write_fsm.read()      == WRITE_UPT_HEAP_LOCK)  and
     7214         (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE))
     7215        or
     7216        ((r_write_fsm.read()      == WRITE_MISS_TRT_LOCK)  and
     7217         (r_alloc_trt_fsm.read()  == ALLOC_TRT_WRITE)))
     7218    {
    65547219        if(r_cas_fsm.read() == CAS_DIR_REQ)
    65557220          r_alloc_dir_fsm = ALLOC_DIR_CAS;
     
    65617226          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    65627227
     7228        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
     7229          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     7230
    65637231        else if(r_read_fsm.read() == READ_DIR_REQ)
    65647232          r_alloc_dir_fsm = ALLOC_DIR_READ;
    6565       }
    6566       break;
    6567 
    6568       ////////////////////
    6569     case ALLOC_DIR_CAS:
    6570       if(((r_cas_fsm.read()         != CAS_DIR_REQ)  &&
    6571           (r_cas_fsm.read()         != CAS_DIR_LOCK)  &&
    6572           (r_cas_fsm.read()         != CAS_DIR_HIT_READ)  &&
    6573           (r_cas_fsm.read()         != CAS_DIR_HIT_COMPARE)  &&
    6574           (r_cas_fsm.read()         != CAS_DIR_HIT_WRITE)  &&
    6575           (r_cas_fsm.read()         != CAS_BC_TRT_LOCK)  &&
    6576           (r_cas_fsm.read()         != CAS_BC_UPT_LOCK)  &&
    6577           (r_cas_fsm.read()         != CAS_MISS_TRT_LOCK)  &&
    6578           (r_cas_fsm.read()         != CAS_UPT_LOCK)  &&
    6579           (r_cas_fsm.read()         != CAS_UPT_HEAP_LOCK))
    6580           ||
    6581           ((r_cas_fsm.read()        == CAS_UPT_HEAP_LOCK)  &&
    6582            (r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS))
    6583           ||
    6584           ((r_cas_fsm.read()        == CAS_MISS_TRT_LOCK)  &&
    6585            (r_alloc_trt_fsm.read()  == ALLOC_TRT_CAS)))
    6586       {
     7233    }
     7234    break;
     7235
     7236    ///////////////////
     7237    case ALLOC_DIR_CAS:    // allocated to CAS FSM
     7238    if(((r_cas_fsm.read()         != CAS_DIR_REQ)  and
     7239        (r_cas_fsm.read()         != CAS_DIR_LOCK)  and
     7240        (r_cas_fsm.read()         != CAS_DIR_HIT_READ)  and
     7241        (r_cas_fsm.read()         != CAS_DIR_HIT_COMPARE)  and
     7242        (r_cas_fsm.read()         != CAS_DIR_HIT_WRITE)  and
     7243        (r_cas_fsm.read()         != CAS_BC_TRT_LOCK)  and
     7244        (r_cas_fsm.read()         != CAS_BC_UPT_LOCK)  and
     7245        (r_cas_fsm.read()         != CAS_MISS_TRT_LOCK)  and
     7246        (r_cas_fsm.read()         != CAS_UPT_LOCK)  and
     7247        (r_cas_fsm.read()         != CAS_UPT_HEAP_LOCK))
     7248        or
     7249        ((r_cas_fsm.read()        == CAS_UPT_HEAP_LOCK)  and
     7250         (r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS))
     7251        or
     7252        ((r_cas_fsm.read()        == CAS_MISS_TRT_LOCK)  and
     7253         (r_alloc_trt_fsm.read()  == ALLOC_TRT_CAS)))
     7254    {
    65877255        if(r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    65887256          r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     
    65917259          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    65927260
     7261        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
     7262          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     7263
    65937264        else if(r_read_fsm.read() == READ_DIR_REQ)
    65947265          r_alloc_dir_fsm = ALLOC_DIR_READ;
     
    65967267        else if(r_write_fsm.read() == WRITE_DIR_REQ)
    65977268          r_alloc_dir_fsm = ALLOC_DIR_WRITE;
    6598       }
    6599       break;
    6600 
    6601       ///////////////////////
    6602     case ALLOC_DIR_CLEANUP:
    6603       if((r_cleanup_fsm.read() != CLEANUP_DIR_REQ) &&
    6604           (r_cleanup_fsm.read() != CLEANUP_DIR_LOCK) &&
    6605           (r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) &&
    6606           (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK))
    6607       {
     7269    }
     7270      break;
     7271
     7272    ///////////////////////
     7273    case ALLOC_DIR_CLEANUP:    // allocated to CLEANUP FSM
     7274    if((r_cleanup_fsm.read() != CLEANUP_DIR_REQ) and
     7275        (r_cleanup_fsm.read() != CLEANUP_DIR_LOCK) and
     7276        (r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) and
     7277        (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK))
     7278    {
    66087279        if(r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    66097280          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    66107281
     7282        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
     7283          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     7284
    66117285        else if(r_read_fsm.read() == READ_DIR_REQ)
    66127286          r_alloc_dir_fsm = ALLOC_DIR_READ;
     
    66177291        else if(r_cas_fsm.read() == CAS_DIR_REQ)
    66187292          r_alloc_dir_fsm = ALLOC_DIR_CAS;
    6619       }
    6620       break;
    6621 
    6622       ////////////////////////
    6623     case ALLOC_DIR_XRAM_RSP:
    6624       if((r_xram_rsp_fsm.read() != XRAM_RSP_DIR_LOCK) &&
    6625           (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) &&
    6626           (r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK))
    6627       {
    6628         if(r_read_fsm.read() == READ_DIR_REQ)
     7293    }
     7294    break;
     7295
     7296    ////////////////////////
     7297    case ALLOC_DIR_XRAM_RSP:    // allocated to XRAM_RSP FSM
     7298    if( (r_xram_rsp_fsm.read() != XRAM_RSP_DIR_LOCK) and
     7299        (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) and
     7300        (r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK))
     7301    {
     7302        if(r_config_fsm.read() == CONFIG_DIR_REQ)
     7303          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     7304
     7305        else if(r_read_fsm.read() == READ_DIR_REQ)
    66297306          r_alloc_dir_fsm = ALLOC_DIR_READ;
    66307307
     
    66377314        else if(r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    66387315          r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
    6639       }
    6640       break;
     7316    }
     7317    break;
    66417318
    66427319  } // end switch alloc_dir_fsm
     
    66537330  switch(r_alloc_trt_fsm.read())
    66547331  {
    6655       ////////////////////
     7332    ////////////////////
    66567333    case ALLOC_TRT_READ:
    66577334      if(r_read_fsm.read() != READ_TRT_LOCK)
    66587335      {
    6659         if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     7336        if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    66607337            (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    66617338          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    66627339
    6663         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     7340        else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    66647341                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    66657342          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    66667343
    6667         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     7344        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    66687345                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    66697346          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    66707347
    6671         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     7348        else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    66727349                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    66737350          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     
    66757352      break;
    66767353
    6677       /////////////////////
     7354    /////////////////////
    66787355    case ALLOC_TRT_WRITE:
    6679       if((r_write_fsm.read() != WRITE_MISS_TRT_LOCK) &&
    6680           (r_write_fsm.read() != WRITE_BC_TRT_LOCK) &&
     7356      if((r_write_fsm.read() != WRITE_MISS_TRT_LOCK) and
     7357          (r_write_fsm.read() != WRITE_BC_TRT_LOCK) and
    66817358          (r_write_fsm.read() != WRITE_BC_UPT_LOCK))
    66827359      {
    6683         if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     7360        if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    66847361            (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    66857362          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    66867363
    6687         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     7364        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    66887365                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    66897366          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    66907367
    6691         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     7368        else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    66927369                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    66937370          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     
    66987375      break;
    66997376
    6700       ////////////////////
     7377    ////////////////////
    67017378    case ALLOC_TRT_CAS:
    6702       if((r_cas_fsm.read() != CAS_MISS_TRT_LOCK) &&
    6703           (r_cas_fsm.read() != CAS_BC_TRT_LOCK) &&
     7379      if((r_cas_fsm.read() != CAS_MISS_TRT_LOCK) and
     7380          (r_cas_fsm.read() != CAS_BC_TRT_LOCK) and
    67047381          (r_cas_fsm.read() != CAS_BC_UPT_LOCK))
    67057382      {
    6706         if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     7383        if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    67077384            (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    67087385          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    67097386
    6710         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     7387        else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    67117388                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    67127389          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     
    67157392          r_alloc_trt_fsm = ALLOC_TRT_READ;
    67167393
    6717         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     7394        else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    67187395                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    67197396          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     
    67217398      break;
    67227399
    6723       ////////////////////////
     7400    ////////////////////////
    67247401    case ALLOC_TRT_XRAM_RSP:
    6725       if(((r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_LOCK)  ||
    6726           (r_alloc_dir_fsm.read() != ALLOC_DIR_XRAM_RSP)) &&
    6727           (r_xram_rsp_fsm.read()  != XRAM_RSP_TRT_COPY)  &&
    6728           (r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_UPDT)  &&
     7402      if(((r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_LOCK)  or
     7403          (r_alloc_dir_fsm.read() != ALLOC_DIR_XRAM_RSP)) and
     7404          (r_xram_rsp_fsm.read()  != XRAM_RSP_TRT_COPY)  and
     7405          (r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_UPDT)  and
    67297406          (r_xram_rsp_fsm.read()  != XRAM_RSP_INVAL_LOCK))
    67307407      {
    6731         if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     7408        if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    67327409            (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    67337410          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     
    67367413          r_alloc_trt_fsm = ALLOC_TRT_READ;
    67377414
    6738         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     7415        else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    67397416                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    67407417          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    67417418
    6742         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     7419        else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    67437420                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    67447421          r_alloc_trt_fsm = ALLOC_TRT_CAS;
     
    67467423      break;
    67477424
    6748       ////////////////////////
     7425    ////////////////////////
    67497426    case ALLOC_TRT_IXR_RSP:
    6750       if((r_ixr_rsp_fsm.read() != IXR_RSP_TRT_ERASE) &&
     7427      if((r_ixr_rsp_fsm.read() != IXR_RSP_TRT_ERASE) and
    67517428          (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ))
    67527429      {
     
    67547431          r_alloc_trt_fsm = ALLOC_TRT_READ;
    67557432
    6756         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     7433        else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    67577434                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    67587435          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    67597436
    6760         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     7437        else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    67617438                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    67627439          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    67637440
    6764         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     7441        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    67657442                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    67667443          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     
    67747451  ////////////////////////////////////////////////////////////////////////////////////
    67757452  // The ALLOC_HEAP FSM allocates the access to the heap
    6776   // with a round robin priority between 5 user FSMs :
    6777   // The cyclic ordering is READ > WRITE > CAS > CLEANUP > XRAM_RSP
     7453  // with a round robin priority between 6 user FSMs :
     7454  // The cyclic ordering is READ > WRITE > CAS > CLEANUP > XRAM_RSP > CONFIG
    67787455  // The ressource is always allocated.
    67797456  /////////////////////////////////////////////////////////////////////////////////////
     
    67827459  {
    67837460      ////////////////////
    6784     case ALLOC_HEAP_RESET:
     7461      case ALLOC_HEAP_RESET:
    67857462      // Initializes the heap one ENTRY each cycle.
    67867463
     
    67967473
    67977474      ////////////////////
    6798     case ALLOC_HEAP_READ:
    6799       if((r_read_fsm.read() != READ_HEAP_REQ) &&
    6800           (r_read_fsm.read() != READ_HEAP_LOCK) &&
     7475      case ALLOC_HEAP_READ:
     7476      if((r_read_fsm.read() != READ_HEAP_REQ) and
     7477          (r_read_fsm.read() != READ_HEAP_LOCK) and
    68017478          (r_read_fsm.read() != READ_HEAP_ERASE))
    68027479      {
     
    68127489        else if(r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ)
    68137490          r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
     7491
     7492        else if(r_config_fsm.read() == CONFIG_HEAP_REQ)
     7493          r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
    68147494      }
    68157495      break;
    68167496
    68177497      /////////////////////
    6818     case ALLOC_HEAP_WRITE:
    6819       if((r_write_fsm.read() != WRITE_UPT_HEAP_LOCK) &&
    6820           (r_write_fsm.read() != WRITE_UPT_REQ) &&
     7498      case ALLOC_HEAP_WRITE:
     7499      if((r_write_fsm.read() != WRITE_UPT_HEAP_LOCK) and
     7500          (r_write_fsm.read() != WRITE_UPT_REQ) and
    68217501          (r_write_fsm.read() != WRITE_UPT_NEXT))
    68227502      {
     
    68307510          r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    68317511
     7512        else if(r_config_fsm.read() == CONFIG_HEAP_REQ)
     7513          r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     7514
    68327515        else if(r_read_fsm.read() == READ_HEAP_REQ)
    68337516          r_alloc_heap_fsm = ALLOC_HEAP_READ;
     
    68367519
    68377520      ////////////////////
    6838     case ALLOC_HEAP_CAS:
    6839       if((r_cas_fsm.read() != CAS_UPT_HEAP_LOCK) &&
    6840           (r_cas_fsm.read() != CAS_UPT_REQ) &&
     7521      case ALLOC_HEAP_CAS:
     7522      if((r_cas_fsm.read() != CAS_UPT_HEAP_LOCK) and
     7523          (r_cas_fsm.read() != CAS_UPT_REQ) and
    68417524          (r_cas_fsm.read() != CAS_UPT_NEXT))
    68427525      {
     
    68477530          r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    68487531
     7532        else if(r_config_fsm.read() == CONFIG_HEAP_REQ)
     7533          r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     7534
    68497535        else if(r_read_fsm.read() == READ_HEAP_REQ)
    68507536          r_alloc_heap_fsm = ALLOC_HEAP_READ;
     
    68567542
    68577543      ///////////////////////
    6858     case ALLOC_HEAP_CLEANUP:
    6859       if((r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) &&
    6860           (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK) &&
    6861           (r_cleanup_fsm.read() != CLEANUP_HEAP_SEARCH) &&
     7544      case ALLOC_HEAP_CLEANUP:
     7545      if((r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) and
     7546          (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK) and
     7547          (r_cleanup_fsm.read() != CLEANUP_HEAP_SEARCH) and
    68627548          (r_cleanup_fsm.read() != CLEANUP_HEAP_CLEAN))
    68637549      {
     
    68657551          r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    68667552
     7553        else if(r_config_fsm.read() == CONFIG_HEAP_REQ)
     7554          r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     7555
    68677556        else if(r_read_fsm.read() == READ_HEAP_REQ)
    68687557          r_alloc_heap_fsm = ALLOC_HEAP_READ;
     
    68777566
    68787567      ////////////////////////
    6879     case ALLOC_HEAP_XRAM_RSP:
    6880       if((r_xram_rsp_fsm.read() != XRAM_RSP_HEAP_REQ) &&
     7568      case ALLOC_HEAP_XRAM_RSP:
     7569      if((r_xram_rsp_fsm.read() != XRAM_RSP_HEAP_REQ) and
    68817570          (r_xram_rsp_fsm.read() != XRAM_RSP_HEAP_ERASE))
     7571      {
     7572        if(r_config_fsm.read() == CONFIG_HEAP_REQ)
     7573          r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     7574
     7575        else if(r_read_fsm.read() == READ_HEAP_REQ)
     7576          r_alloc_heap_fsm = ALLOC_HEAP_READ;
     7577
     7578        else if(r_write_fsm.read() == WRITE_UPT_HEAP_LOCK)
     7579          r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
     7580
     7581        else if(r_cas_fsm.read() == CAS_UPT_HEAP_LOCK)
     7582          r_alloc_heap_fsm = ALLOC_HEAP_CAS;
     7583
     7584        else if(r_cleanup_fsm.read() == CLEANUP_HEAP_REQ)
     7585          r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
     7586
     7587      }
     7588      break;
     7589
     7590      ///////////////////////
     7591      case ALLOC_HEAP_CONFIG:
     7592      if((r_config_fsm.read() != CONFIG_HEAP_REQ) and
     7593          (r_config_fsm.read() != CONFIG_HEAP_SCAN))
    68827594      {
    68837595        if(r_read_fsm.read() == READ_HEAP_REQ)
     
    68937605          r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
    68947606
     7607        if(r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ)
     7608          r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    68957609      }
    68967610      break;
     
    68987612  } // end switch alloc_heap_fsm
    68997613
    6900 
    6901   ////////////////////////////////////////////////////////////////////////////////////
     7614  /////////////////////////////////////////////////////////////////////
    69027615  //    TGT_CMD to READ FIFO
    6903   ////////////////////////////////////////////////////////////////////////////////////
    6904 
    6905   if(cmd_read_fifo_put)
    6906   {
    6907     if(cmd_read_fifo_get)
    6908     {
    6909       m_cmd_read_addr_fifo.put_and_get((addr_t)(p_vci_tgt.address.read()));
    6910       m_cmd_read_length_fifo.put_and_get(p_vci_tgt.plen.read() >>2);
    6911       m_cmd_read_srcid_fifo.put_and_get(p_vci_tgt.srcid.read());
    6912       m_cmd_read_trdid_fifo.put_and_get(p_vci_tgt.trdid.read());
    6913       m_cmd_read_pktid_fifo.put_and_get(p_vci_tgt.pktid.read());
    6914     }
    6915     else
    6916     {
    6917       m_cmd_read_addr_fifo.simple_put((addr_t)(p_vci_tgt.address.read()));
    6918       m_cmd_read_length_fifo.simple_put(p_vci_tgt.plen.read() >>2);
    6919       m_cmd_read_srcid_fifo.simple_put(p_vci_tgt.srcid.read());
    6920       m_cmd_read_trdid_fifo.simple_put(p_vci_tgt.trdid.read());
    6921       m_cmd_read_pktid_fifo.simple_put(p_vci_tgt.pktid.read());
    6922     }
    6923   }
    6924   else
    6925   {
    6926     if(cmd_read_fifo_get)
    6927     {
    6928       m_cmd_read_addr_fifo.simple_get();
    6929       m_cmd_read_length_fifo.simple_get();
    6930       m_cmd_read_srcid_fifo.simple_get();
    6931       m_cmd_read_trdid_fifo.simple_get();
    6932       m_cmd_read_pktid_fifo.simple_get();
    6933     }
    6934   }
     7616  /////////////////////////////////////////////////////////////////////
     7617
     7618  m_cmd_read_addr_fifo.update(   cmd_read_fifo_get, cmd_read_fifo_put,
     7619                                 p_vci_tgt.address.read() );
     7620  m_cmd_read_length_fifo.update( cmd_read_fifo_get, cmd_read_fifo_put,
     7621                                 p_vci_tgt.plen.read()>>2 );
     7622  m_cmd_read_srcid_fifo.update(  cmd_read_fifo_get, cmd_read_fifo_put,
     7623                                 p_vci_tgt.srcid.read() );
     7624  m_cmd_read_trdid_fifo.update(  cmd_read_fifo_get, cmd_read_fifo_put,
     7625                                 p_vci_tgt.trdid.read() );
     7626  m_cmd_read_pktid_fifo.update(  cmd_read_fifo_get, cmd_read_fifo_put,
     7627                                 p_vci_tgt.pktid.read() );
     7628
    69357629  /////////////////////////////////////////////////////////////////////
    69367630  //    TGT_CMD to WRITE FIFO
    69377631  /////////////////////////////////////////////////////////////////////
    69387632
    6939   if(cmd_write_fifo_put)
    6940   {
    6941     if(cmd_write_fifo_get)
    6942     {
    6943       m_cmd_write_addr_fifo.put_and_get((addr_t)(p_vci_tgt.address.read()));
    6944       m_cmd_write_eop_fifo.put_and_get(p_vci_tgt.eop.read());
    6945       m_cmd_write_srcid_fifo.put_and_get(p_vci_tgt.srcid.read());
    6946       m_cmd_write_trdid_fifo.put_and_get(p_vci_tgt.trdid.read());
    6947       m_cmd_write_pktid_fifo.put_and_get(p_vci_tgt.pktid.read());
    6948       m_cmd_write_data_fifo.put_and_get(p_vci_tgt.wdata.read());
    6949       m_cmd_write_be_fifo.put_and_get(p_vci_tgt.be.read());
    6950     }
    6951     else
    6952     {
    6953       m_cmd_write_addr_fifo.simple_put((addr_t)(p_vci_tgt.address.read()));
    6954       m_cmd_write_eop_fifo.simple_put(p_vci_tgt.eop.read());
    6955       m_cmd_write_srcid_fifo.simple_put(p_vci_tgt.srcid.read());
    6956       m_cmd_write_trdid_fifo.simple_put(p_vci_tgt.trdid.read());
    6957       m_cmd_write_pktid_fifo.simple_put(p_vci_tgt.pktid.read());
    6958       m_cmd_write_data_fifo.simple_put(p_vci_tgt.wdata.read());
    6959       m_cmd_write_be_fifo.simple_put(p_vci_tgt.be.read());
    6960     }
    6961   }
    6962   else
    6963   {
    6964     if(cmd_write_fifo_get)
    6965     {
    6966       m_cmd_write_addr_fifo.simple_get();
    6967       m_cmd_write_eop_fifo.simple_get();
    6968       m_cmd_write_srcid_fifo.simple_get();
    6969       m_cmd_write_trdid_fifo.simple_get();
    6970       m_cmd_write_pktid_fifo.simple_get();
    6971       m_cmd_write_data_fifo.simple_get();
    6972       m_cmd_write_be_fifo.simple_get();
    6973     }
    6974   }
     7633  m_cmd_write_addr_fifo.update(  cmd_write_fifo_get, cmd_write_fifo_put,
     7634                                 (addr_t)p_vci_tgt.address.read() );
     7635  m_cmd_write_eop_fifo.update(   cmd_write_fifo_get, cmd_write_fifo_put,
     7636                                 p_vci_tgt.eop.read() );
     7637  m_cmd_write_srcid_fifo.update( cmd_write_fifo_get, cmd_write_fifo_put,
     7638                                 p_vci_tgt.srcid.read() );
     7639  m_cmd_write_trdid_fifo.update( cmd_write_fifo_get, cmd_write_fifo_put,
     7640                                 p_vci_tgt.trdid.read() );
     7641  m_cmd_write_pktid_fifo.update( cmd_write_fifo_get, cmd_write_fifo_put,
     7642                                 p_vci_tgt.pktid.read() );
     7643  m_cmd_write_data_fifo.update(  cmd_write_fifo_get, cmd_write_fifo_put,
     7644                                 p_vci_tgt.wdata.read() );
     7645  m_cmd_write_be_fifo.update(    cmd_write_fifo_get, cmd_write_fifo_put,
     7646                                 p_vci_tgt.be.read() );
     7647
    69757648  ////////////////////////////////////////////////////////////////////////////////////
    69767649  //    TGT_CMD to CAS FIFO
    69777650  ////////////////////////////////////////////////////////////////////////////////////
    69787651
    6979   if(cmd_cas_fifo_put)
    6980   {
    6981     if(cmd_cas_fifo_get)
    6982     {
    6983       m_cmd_cas_addr_fifo.put_and_get((addr_t)(p_vci_tgt.address.read()));
    6984       m_cmd_cas_eop_fifo.put_and_get(p_vci_tgt.eop.read());
    6985       m_cmd_cas_srcid_fifo.put_and_get(p_vci_tgt.srcid.read());
    6986       m_cmd_cas_trdid_fifo.put_and_get(p_vci_tgt.trdid.read());
    6987       m_cmd_cas_pktid_fifo.put_and_get(p_vci_tgt.pktid.read());
    6988       m_cmd_cas_wdata_fifo.put_and_get(p_vci_tgt.wdata.read());
    6989     }
    6990     else
    6991     {
    6992       m_cmd_cas_addr_fifo.simple_put((addr_t)(p_vci_tgt.address.read()));
    6993       m_cmd_cas_eop_fifo.simple_put(p_vci_tgt.eop.read());
    6994       m_cmd_cas_srcid_fifo.simple_put(p_vci_tgt.srcid.read());
    6995       m_cmd_cas_trdid_fifo.simple_put(p_vci_tgt.trdid.read());
    6996       m_cmd_cas_pktid_fifo.simple_put(p_vci_tgt.pktid.read());
    6997       m_cmd_cas_wdata_fifo.simple_put(p_vci_tgt.wdata.read());
    6998     }
    6999   }
    7000   else
    7001   {
    7002     if(cmd_cas_fifo_get)
    7003     {
    7004       m_cmd_cas_addr_fifo.simple_get();
    7005       m_cmd_cas_eop_fifo.simple_get();
    7006       m_cmd_cas_srcid_fifo.simple_get();
    7007       m_cmd_cas_trdid_fifo.simple_get();
    7008       m_cmd_cas_pktid_fifo.simple_get();
    7009       m_cmd_cas_wdata_fifo.simple_get();
    7010     }
    7011   }
     7652  m_cmd_cas_addr_fifo.update(  cmd_cas_fifo_get, cmd_cas_fifo_put,
     7653                               (addr_t)p_vci_tgt.address.read() );
     7654  m_cmd_cas_eop_fifo.update(   cmd_cas_fifo_get, cmd_cas_fifo_put,
     7655                               p_vci_tgt.eop.read() );
     7656  m_cmd_cas_srcid_fifo.update( cmd_cas_fifo_get, cmd_cas_fifo_put,
     7657                               p_vci_tgt.srcid.read() );
     7658  m_cmd_cas_trdid_fifo.update( cmd_cas_fifo_get, cmd_cas_fifo_put,
     7659                               p_vci_tgt.trdid.read() );
     7660  m_cmd_cas_pktid_fifo.update( cmd_cas_fifo_get, cmd_cas_fifo_put,
     7661                               p_vci_tgt.pktid.read() );
     7662  m_cmd_cas_wdata_fifo.update( cmd_cas_fifo_get, cmd_cas_fifo_put,
     7663                               p_vci_tgt.wdata.read() );
     7664
    70127665  ////////////////////////////////////////////////////////////////////////////////////
    70137666  //    CC_RECEIVE to CLEANUP FIFO
    70147667  ////////////////////////////////////////////////////////////////////////////////////
    70157668
    7016   if(cc_receive_to_cleanup_fifo_put)
    7017   {
    7018     if(cc_receive_to_cleanup_fifo_get)
    7019     {
    7020       m_cc_receive_to_cleanup_fifo.put_and_get(p_dspin_in.data.read());
    7021     }
    7022     else
    7023     {
    7024       m_cc_receive_to_cleanup_fifo.simple_put(p_dspin_in.data.read());
    7025     }
    7026   }
    7027   else
    7028   {
    7029     if(cc_receive_to_cleanup_fifo_get)
    7030     {
    7031       m_cc_receive_to_cleanup_fifo.simple_get();
    7032     }
    7033   }
     7669  m_cc_receive_to_cleanup_fifo.update( cc_receive_to_cleanup_fifo_get,
     7670                                       cc_receive_to_cleanup_fifo_put,
     7671                                       p_dspin_in.data.read() );
    70347672
    70357673  ////////////////////////////////////////////////////////////////////////////////////
     
    70377675  ////////////////////////////////////////////////////////////////////////////////////
    70387676
    7039   if(cc_receive_to_multi_ack_fifo_put)
    7040   {
    7041     if(cc_receive_to_multi_ack_fifo_get)
    7042     {
    7043       m_cc_receive_to_multi_ack_fifo.put_and_get(p_dspin_in.data.read());
    7044     }
    7045     else
    7046     {
    7047       m_cc_receive_to_multi_ack_fifo.simple_put(p_dspin_in.data.read());
    7048     }
    7049   }
    7050   else
    7051   {
    7052     if(cc_receive_to_multi_ack_fifo_get)
    7053     {
    7054       m_cc_receive_to_multi_ack_fifo.simple_get();
    7055     }
    7056   }
     7677  m_cc_receive_to_multi_ack_fifo.update( cc_receive_to_multi_ack_fifo_get,
     7678                                         cc_receive_to_multi_ack_fifo_put,
     7679                                         p_dspin_in.data.read() );
    70577680
    70587681  ////////////////////////////////////////////////////////////////////////////////////
     
    70607683  ////////////////////////////////////////////////////////////////////////////////////
    70617684
    7062   if(write_to_cc_send_fifo_put)
    7063   {
    7064     if(write_to_cc_send_fifo_get)
    7065     {
    7066       m_write_to_cc_send_inst_fifo.put_and_get(write_to_cc_send_fifo_inst);
    7067       m_write_to_cc_send_srcid_fifo.put_and_get(write_to_cc_send_fifo_srcid);
     7685  m_write_to_cc_send_inst_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,
     7686                                       write_to_cc_send_fifo_inst );
     7687  m_write_to_cc_send_srcid_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,
     7688                                        write_to_cc_send_fifo_srcid );
    70687689#if L1_MULTI_CACHE
    7069       m_write_to_cc_send_cache_id_fifo.put_and_get(write_to_cc_send_fifo_cache_id);
    7070 #endif
    7071     }
    7072     else
    7073     {
    7074       m_write_to_cc_send_inst_fifo.simple_put(write_to_cc_send_fifo_inst);
    7075       m_write_to_cc_send_srcid_fifo.simple_put(write_to_cc_send_fifo_srcid);
     7690  m_write_to_cc_send_cache_id_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,
     7691                                           write_to_cc_send_fifo_cache_id );
     7692#endif
     7693
     7694  ////////////////////////////////////////////////////////////////////////////////////
     7695  //    CONFIG to CC_SEND FIFO
     7696  ////////////////////////////////////////////////////////////////////////////////////
     7697
     7698  m_config_to_cc_send_inst_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,
     7699                                        config_to_cc_send_fifo_inst );
     7700  m_config_to_cc_send_srcid_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,
     7701                                         config_to_cc_send_fifo_srcid );
    70767702#if L1_MULTI_CACHE
    7077       m_write_to_cc_send_cache_id_fifo.simple_put(write_to_cc_send_fifo_cache_id);
    7078 #endif
    7079     }
    7080   }
    7081   else
    7082   {
    7083     if(write_to_cc_send_fifo_get)
    7084     {
    7085       m_write_to_cc_send_inst_fifo.simple_get();
    7086       m_write_to_cc_send_srcid_fifo.simple_get();
    7087 #if L1_MULTI_CACHE
    7088       m_write_to_cc_send_cache_id_fifo.simple_get();
    7089 #endif
    7090     }
    7091   }
     7703  m_config_to_cc_send_cache_id_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,
     7704                                            config_to_cc_send_fifo_cache_id );
     7705#endif
     7706
    70927707  ////////////////////////////////////////////////////////////////////////////////////
    70937708  //    XRAM_RSP to CC_SEND FIFO
    70947709  ////////////////////////////////////////////////////////////////////////////////////
    70957710
    7096   if(xram_rsp_to_cc_send_fifo_put)
    7097   {
    7098     if(xram_rsp_to_cc_send_fifo_get)
    7099     {
    7100       m_xram_rsp_to_cc_send_inst_fifo.put_and_get(xram_rsp_to_cc_send_fifo_inst);
    7101       m_xram_rsp_to_cc_send_srcid_fifo.put_and_get(xram_rsp_to_cc_send_fifo_srcid);
     7711  m_xram_rsp_to_cc_send_inst_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,
     7712                                          xram_rsp_to_cc_send_fifo_inst );
     7713  m_xram_rsp_to_cc_send_srcid_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,
     7714                                           xram_rsp_to_cc_send_fifo_srcid );
    71027715#if L1_MULTI_CACHE
    7103       m_xram_rsp_to_cc_send_cache_id_fifo.put_and_get(xram_rsp_to_cc_send_fifo_cache_id);
    7104 #endif
    7105     }
    7106     else
    7107     {
    7108       m_xram_rsp_to_cc_send_inst_fifo.simple_put(xram_rsp_to_cc_send_fifo_inst);
    7109       m_xram_rsp_to_cc_send_srcid_fifo.simple_put(xram_rsp_to_cc_send_fifo_srcid);
    7110 #if L1_MULTI_CACHE
    7111       m_xram_rsp_to_cc_send_cache_id_fifo.simple_put(xram_rsp_to_cc_send_fifo_cache_id);
    7112 #endif
    7113     }
    7114   }
    7115   else
    7116   {
    7117     if(xram_rsp_to_cc_send_fifo_get)
    7118     {
    7119       m_xram_rsp_to_cc_send_inst_fifo.simple_get();
    7120       m_xram_rsp_to_cc_send_srcid_fifo.simple_get();
    7121 #if L1_MULTI_CACHE
    7122       m_xram_rsp_to_cc_send_cache_id_fifo.simple_get();
    7123 #endif
    7124     }
    7125   }
     7716  m_xram_rsp_to_cc_send_cache_id_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,
     7717                                              xram_rsp_to_cc_send_fifo_cache_id );
     7718#endif
     7719
    71267720  ////////////////////////////////////////////////////////////////////////////////////
    71277721  //    CAS to CC_SEND FIFO
    71287722  ////////////////////////////////////////////////////////////////////////////////////
    71297723
    7130   if(cas_to_cc_send_fifo_put)
    7131   {
    7132     if(cas_to_cc_send_fifo_get)
    7133     {
    7134       m_cas_to_cc_send_inst_fifo.put_and_get(cas_to_cc_send_fifo_inst);
    7135       m_cas_to_cc_send_srcid_fifo.put_and_get(cas_to_cc_send_fifo_srcid);
     7724  m_cas_to_cc_send_inst_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,
     7725                                     cas_to_cc_send_fifo_inst );
     7726  m_cas_to_cc_send_srcid_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,
     7727                                      cas_to_cc_send_fifo_srcid );
    71367728#if L1_MULTI_CACHE
    7137       m_cas_to_cc_send_cache_id_fifo.put_and_get(cas_to_cc_send_fifo_cache_id);
    7138 #endif
    7139     }
    7140     else
    7141     {
    7142       m_cas_to_cc_send_inst_fifo.simple_put(cas_to_cc_send_fifo_inst);
    7143       m_cas_to_cc_send_srcid_fifo.simple_put(cas_to_cc_send_fifo_srcid);
    7144 #if L1_MULTI_CACHE
    7145       m_cas_to_cc_send_cache_id_fifo.simple_put(cas_to_cc_send_fifo_cache_id);
    7146 #endif
    7147     }
    7148   }
    7149   else
    7150   {
    7151     if(cas_to_cc_send_fifo_get)
    7152     {
    7153       m_cas_to_cc_send_inst_fifo.simple_get();
    7154       m_cas_to_cc_send_srcid_fifo.simple_get();
    7155 #if L1_MULTI_CACHE
    7156       m_cas_to_cc_send_cache_id_fifo.simple_get();
    7157 #endif
    7158     }
    7159   }
     7729  m_cas_to_cc_send_cache_id_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,
     7730                                         cas_to_cc_send_fifo_cache_id );
     7731#endif
    71607732
    71617733  m_cpt_cycles++;
     
    71717743  ////////////////////////////////////////////////////////////
    71727744
    7173   p_vci_ixr.be      = 0xF;
     7745  p_vci_ixr.be      = 0xFF;   // nor transmited to external ram
    71747746  p_vci_ixr.pktid   = 0;
    71757747  p_vci_ixr.srcid   = m_srcid_x;
     
    71797751  p_vci_ixr.clen    = 0;
    71807752  p_vci_ixr.cfixed  = false;
    7181 
    7182   if(r_ixr_cmd_fsm.read() == IXR_CMD_READ_NLINE)
     7753  p_vci_ixr.plen    = 64;
     7754
     7755  if(r_ixr_cmd_fsm.read() == IXR_CMD_READ)
    71837756  {
    7184     p_vci_ixr.cmd     = vci_param::CMD_READ;
    7185     p_vci_ixr.cmdval  = true;
    7186     p_vci_ixr.address = (addr_t)(r_read_to_ixr_cmd_nline.read() *m_words*4);
    7187     p_vci_ixr.plen    = m_words*4;
    7188     p_vci_ixr.wdata   = 0x00000000;
    7189     p_vci_ixr.trdid   = r_read_to_ixr_cmd_trdid.read();
    7190     p_vci_ixr.eop     = true;
     7757    p_vci_ixr.cmd       = vci_param_ext::CMD_READ;
     7758    p_vci_ixr.cmdval    = true;
     7759    p_vci_ixr.address   = (addr_t)(r_read_to_ixr_cmd_nline.read() * m_words * 4);
     7760    p_vci_ixr.wdata     = 0;
     7761    p_vci_ixr.trdid     = r_read_to_ixr_cmd_trdid.read();
     7762    p_vci_ixr.eop       = true;
    71917763  }
    7192   else if(r_ixr_cmd_fsm.read() == IXR_CMD_CAS_NLINE)
     7764  else if(r_ixr_cmd_fsm.read() == IXR_CMD_CAS)
    71937765  {
    71947766    if(r_cas_to_ixr_cmd_write.read())
    71957767    {
    7196       p_vci_ixr.cmd     = vci_param::CMD_WRITE;
     7768      size_t word       = r_ixr_cmd_cpt.read();
     7769      p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
    71977770      p_vci_ixr.cmdval  = true;
    7198       p_vci_ixr.address = (addr_t)((r_cas_to_ixr_cmd_nline.read() *m_words+r_ixr_cmd_cpt.read()) *4);
    7199       p_vci_ixr.plen    = m_words*4;
    7200       p_vci_ixr.wdata   = r_cas_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read();
     7771      p_vci_ixr.address = (addr_t)( (r_cas_to_ixr_cmd_nline.read() * m_words + word) * 4 );
     7772      p_vci_ixr.wdata   = ((wide_data_t)(r_cas_to_ixr_cmd_data[word].read()))  |
     7773                          ((wide_data_t)(r_cas_to_ixr_cmd_data[word+1].read()) << 32);
    72017774      p_vci_ixr.trdid   = r_cas_to_ixr_cmd_trdid.read();
    7202       p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-1));
     7775      p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-2));
    72037776    }
    72047777    else
    72057778    {
    7206       p_vci_ixr.cmd     = vci_param::CMD_READ;
     7779      p_vci_ixr.cmd     = vci_param_ext::CMD_READ;
    72077780      p_vci_ixr.cmdval  = true;
    72087781      p_vci_ixr.address = (addr_t)(r_cas_to_ixr_cmd_nline.read() *m_words*4);
    7209       p_vci_ixr.plen    = m_words*4;
    7210       p_vci_ixr.wdata   = 0x00000000;
     7782      p_vci_ixr.wdata   = 0;
    72117783      p_vci_ixr.trdid   = r_cas_to_ixr_cmd_trdid.read();
    72127784      p_vci_ixr.eop     = true;
    72137785    }
    72147786  }
    7215   else if(r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_NLINE)
     7787  else if(r_ixr_cmd_fsm.read() == IXR_CMD_WRITE)
    72167788  {
    72177789    if(r_write_to_ixr_cmd_write.read())
    72187790    {
    7219       p_vci_ixr.cmd     = vci_param::CMD_WRITE;
     7791      p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
    72207792      p_vci_ixr.cmdval  = true;
    7221       p_vci_ixr.address = (addr_t)((r_write_to_ixr_cmd_nline.read() *m_words+r_ixr_cmd_cpt.read()) *4);
    7222       p_vci_ixr.plen    = m_words*4;
    7223       p_vci_ixr.wdata   = r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read();
     7793      p_vci_ixr.address = (addr_t)( (r_write_to_ixr_cmd_nline.read() * m_words +
     7794                                     r_ixr_cmd_cpt.read()) * 4 );
     7795      p_vci_ixr.wdata   = ((wide_data_t)(r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
     7796                          ((wide_data_t)(r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32));
    72247797      p_vci_ixr.trdid   = r_write_to_ixr_cmd_trdid.read();
    7225       p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-1));
     7798      p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-2));
    72267799    }
    72277800    else
    72287801    {
    7229       p_vci_ixr.cmd     = vci_param::CMD_READ;
     7802      p_vci_ixr.cmd     = vci_param_ext::CMD_READ;
    72307803      p_vci_ixr.cmdval  = true;
    72317804      p_vci_ixr.address = (addr_t)(r_write_to_ixr_cmd_nline.read() *m_words*4);
    7232       p_vci_ixr.plen    = m_words*4;
    7233       p_vci_ixr.wdata   = 0x00000000;
     7805      p_vci_ixr.wdata   = 0;
    72347806      p_vci_ixr.trdid   = r_write_to_ixr_cmd_trdid.read();
    72357807      p_vci_ixr.eop     = true;
    72367808    }
    72377809  }
    7238   else if(r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_DATA)
     7810  else if(r_ixr_cmd_fsm.read() == IXR_CMD_XRAM)
    72397811  {
    7240     p_vci_ixr.cmd     = vci_param::CMD_WRITE;
    7241     p_vci_ixr.cmdval  = true;
    7242     p_vci_ixr.address = (addr_t)((r_xram_rsp_to_ixr_cmd_nline.read() *m_words+r_ixr_cmd_cpt.read()) *4);
    7243     p_vci_ixr.plen    = m_words*4;
    7244     p_vci_ixr.wdata   = r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read();
    7245     p_vci_ixr.trdid   = r_xram_rsp_to_ixr_cmd_trdid.read();
    7246     p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-1));
     7812    p_vci_ixr.cmd       = vci_param_ext::CMD_WRITE;
     7813    p_vci_ixr.cmdval    = true;
     7814    p_vci_ixr.address   = (addr_t)( (r_xram_rsp_to_ixr_cmd_nline.read() * m_words +
     7815                                   r_ixr_cmd_cpt.read()) * 4 );
     7816    p_vci_ixr.wdata     = ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
     7817                          ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32));
     7818    p_vci_ixr.trdid     = r_xram_rsp_to_ixr_cmd_trdid.read();
     7819    p_vci_ixr.eop       = (r_ixr_cmd_cpt == (m_words-2));
    72477820  }
    72487821  else
    72497822  {
    7250     p_vci_ixr.cmdval  = false;
    7251     p_vci_ixr.address = 0;
    7252     p_vci_ixr.plen    = 0;
    7253     p_vci_ixr.wdata   = 0;
    7254     p_vci_ixr.trdid   = 0;
    7255     p_vci_ixr.eop = false;
     7823    p_vci_ixr.cmdval    = false;
     7824    p_vci_ixr.cmd       = vci_param_ext::CMD_READ;
     7825    p_vci_ixr.address   = 0;
     7826    p_vci_ixr.wdata     = 0;
     7827    p_vci_ixr.trdid     = 0;
     7828    p_vci_ixr.eop       = false;
    72567829  }
    72577830
     
    72607833  ////////////////////////////////////////////////////
    72617834
    7262   if(((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) &&
    7263       (r_ixr_rsp_fsm.read()   == IXR_RSP_TRT_READ)) ||
     7835  if(((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and
     7836      (r_ixr_rsp_fsm.read()   == IXR_RSP_TRT_READ)) or
    72647837      (r_ixr_rsp_fsm.read()   == IXR_RSP_ACK))
    7265    
     7838
    72667839    p_vci_ixr.rspack = true;
    72677840
     
    72767849  {
    72777850    case TGT_CMD_IDLE:
    7278       p_vci_tgt.cmdack  = false;
     7851      p_vci_tgt.cmdack = false;
     7852      break;
     7853
     7854    case TGT_CMD_CONFIG:
     7855    case TGT_CMD_ERROR:
     7856      p_vci_tgt.cmdack = not r_tgt_cmd_to_tgt_rsp_req.read();
    72797857      break;
    72807858
    72817859    case TGT_CMD_READ:
    7282       p_vci_tgt.cmdack  = m_cmd_read_addr_fifo.wok();
     7860      p_vci_tgt.cmdack = m_cmd_read_addr_fifo.wok();
    72837861      break;
    72847862
    72857863    case TGT_CMD_WRITE:
    7286       p_vci_tgt.cmdack  = m_cmd_write_addr_fifo.wok();
     7864      p_vci_tgt.cmdack = m_cmd_write_addr_fifo.wok();
    72877865      break;
    72887866
    72897867    case TGT_CMD_CAS:
    7290       p_vci_tgt.cmdack  = m_cmd_cas_addr_fifo.wok();
    7291       break;
    7292 
    7293     default:
    7294       p_vci_tgt.cmdack  = false;
     7868      p_vci_tgt.cmdack = m_cmd_cas_addr_fifo.wok();
    72957869      break;
    72967870  }
     
    73027876  switch(r_tgt_rsp_fsm.read())
    73037877  {
     7878    case TGT_RSP_CONFIG_IDLE:
     7879    case TGT_RSP_TGT_CMD_IDLE:
    73047880    case TGT_RSP_READ_IDLE:
    73057881    case TGT_RSP_WRITE_IDLE:
    73067882    case TGT_RSP_CAS_IDLE:
    73077883    case TGT_RSP_XRAM_IDLE:
    7308     case TGT_RSP_INIT_IDLE:
     7884    case TGT_RSP_MULTI_ACK_IDLE:
    73097885    case TGT_RSP_CLEANUP_IDLE:
     7886    {
    73107887      p_vci_tgt.rspval  = false;
    73117888      p_vci_tgt.rsrcid  = 0;
     
    73167893      p_vci_tgt.reop    = false;
    73177894      break;
     7895    }
     7896    case TGT_RSP_CONFIG:
     7897    {
     7898      p_vci_tgt.rspval  = true;
     7899      p_vci_tgt.rdata   = 0;
     7900      p_vci_tgt.rsrcid  = r_config_to_tgt_rsp_srcid.read();
     7901      p_vci_tgt.rtrdid  = r_config_to_tgt_rsp_trdid.read();
     7902      p_vci_tgt.rpktid  = r_config_to_tgt_rsp_pktid.read();
     7903      p_vci_tgt.rerror  = r_config_to_tgt_rsp_error.read();
     7904      p_vci_tgt.reop    = true;
     7905
     7906      break;
     7907    }
     7908
     7909    case TGT_RSP_TGT_CMD:
     7910    {
     7911      p_vci_tgt.rspval  = true;
     7912      p_vci_tgt.rdata   = 0;
     7913      p_vci_tgt.rsrcid  = r_tgt_cmd_to_tgt_rsp_srcid.read();
     7914      p_vci_tgt.rtrdid  = r_tgt_cmd_to_tgt_rsp_trdid.read();
     7915      p_vci_tgt.rpktid  = r_tgt_cmd_to_tgt_rsp_pktid.read();
     7916      p_vci_tgt.rerror  = r_tgt_cmd_to_tgt_rsp_error.read();
     7917      p_vci_tgt.reop    = true;
     7918
     7919      break;
     7920    }
    73187921
    73197922    case TGT_RSP_READ:
     
    73467949    case TGT_RSP_WRITE:
    73477950      p_vci_tgt.rspval   = true;
    7348       if(((r_write_to_tgt_rsp_pktid.read() & 0x7) == TYPE_SC) && r_write_to_tgt_rsp_sc_fail.read())
     7951      if(((r_write_to_tgt_rsp_pktid.read() & 0x7) == TYPE_SC) and r_write_to_tgt_rsp_sc_fail.read())
    73497952        p_vci_tgt.rdata  = 1;
    73507953      else
     
    74048007    }
    74058008
    7406     case TGT_RSP_INIT:
     8009    case TGT_RSP_MULTI_ACK:
    74078010      p_vci_tgt.rspval   = true;
    74088011      p_vci_tgt.rdata    = 0; // Can be a CAS or SC rsp
     
    74168019
    74178020  ////////////////////////////////////////////////////////////////////
    7418   // Initiator command signals on the p_dspin_out port (CC_SEND FSM)
     8021  // p_dspin_out port (CC_SEND FSM)
    74198022  ////////////////////////////////////////////////////////////////////
    74208023
    74218024  p_dspin_out.write = false;
     8025  p_dspin_out.eop   = false;
    74228026  p_dspin_out.data  = 0;
    74238027
    74248028  switch(r_cc_send_fsm.read())
    74258029  {
    7426  
     8030    ///////////////////////////
     8031    case CC_SEND_CONFIG_IDLE:
    74278032    case CC_SEND_XRAM_RSP_IDLE:
    74288033    case CC_SEND_WRITE_IDLE:
    74298034    case CC_SEND_CAS_IDLE:
    74308035    case CC_SEND_CLEANUP_IDLE:
     8036    {
    74318037        break;
    7432 
     8038    }
     8039    ////////////////////////////////
     8040    case CC_SEND_CONFIG_INVAL_HEADER:
     8041    {
     8042        uint8_t multi_inval_type;
     8043        if(m_config_to_cc_send_inst_fifo.read())
     8044        {
     8045          multi_inval_type = DspinDhccpParam::TYPE_MULTI_INVAL_INST;
     8046        }
     8047        else
     8048        {
     8049          multi_inval_type = DspinDhccpParam::TYPE_MULTI_INVAL_DATA;
     8050        }
     8051
     8052        uint64_t flit = 0;
     8053        uint64_t dest = m_config_to_cc_send_srcid_fifo.read() <<
     8054                        (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
     8055
     8056        DspinDhccpParam::dspin_set( flit,
     8057                                    dest,
     8058                                    DspinDhccpParam::MULTI_INVAL_DEST);
     8059
     8060        DspinDhccpParam::dspin_set( flit,
     8061                                    m_cc_global_id,
     8062                                    DspinDhccpParam::MULTI_INVAL_SRCID);
     8063
     8064        DspinDhccpParam::dspin_set( flit,
     8065                                    r_config_to_cc_send_trdid.read(),
     8066                                    DspinDhccpParam::MULTI_INVAL_UPDT_INDEX);
     8067
     8068        DspinDhccpParam::dspin_set( flit,
     8069                                    multi_inval_type,
     8070                                    DspinDhccpParam::FROM_MC_TYPE);
     8071        p_dspin_out.write = true;
     8072        p_dspin_out.data  = flit;
     8073        break;
     8074    }
     8075    ////////////////////////////////
     8076    case CC_SEND_CONFIG_INVAL_NLINE:
     8077    {
     8078        uint64_t flit = 0;
     8079        DspinDhccpParam::dspin_set( flit,
     8080                                    r_config_to_cc_send_nline.read(),
     8081                                    DspinDhccpParam::MULTI_INVAL_NLINE);
     8082        p_dspin_out.eop   = true;
     8083        p_dspin_out.write = true;
     8084        p_dspin_out.data  = flit;
     8085        break;
     8086    }
     8087    ////////////////////////
    74338088    case CC_SEND_CLEANUP_ACK:
    74348089      {
     
    74388093          cleanup_ack_type = DspinDhccpParam::TYPE_CLEANUP_ACK_INST;
    74398094        }
    7440         else 
     8095        else
    74418096        {
    74428097          cleanup_ack_type = DspinDhccpParam::TYPE_CLEANUP_ACK_DATA;
     
    74458100        uint64_t flit = 0;
    74468101        uint64_t dest =
    7447           r_cleanup_to_cc_send_srcid.read() <<
    7448           (DspinDhccpParam::SRCID_WIDTH - vci_param::S);
    7449 
    7450         DspinDhccpParam::dspin_set(
    7451             flit,
    7452             1ULL,
    7453             DspinDhccpParam::FROM_MC_EOP);
     8102          r_cleanup_to_cc_send_srcid.read() <<
     8103          (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
    74548104
    74558105        DspinDhccpParam::dspin_set(
     
    74738123            DspinDhccpParam::FROM_MC_TYPE);
    74748124
     8125        p_dspin_out.eop   = true;
    74758126        p_dspin_out.write = true;
    74768127        p_dspin_out.data  = flit;
    74778128
    74788129        break;
    7479       }
    7480 
     8130    }
     8131
     8132    ///////////////////////////////////
    74818133    case CC_SEND_XRAM_RSP_INVAL_HEADER:
    7482       {
     8134    {
    74838135        if(not m_xram_rsp_to_cc_send_inst_fifo.rok()) break;
    74848136
     
    74888140          multi_inval_type = DspinDhccpParam::TYPE_MULTI_INVAL_INST;
    74898141        }
    7490         else 
     8142        else
    74918143        {
    74928144          multi_inval_type = DspinDhccpParam::TYPE_MULTI_INVAL_DATA;
     
    74948146
    74958147        uint64_t flit = 0;
    7496         uint64_t dest =
    7497           m_xram_rsp_to_cc_send_srcid_fifo.read() <<
    7498           (DspinDhccpParam::SRCID_WIDTH - vci_param::S);
    7499 
    7500         DspinDhccpParam::dspin_set(
    7501             flit,
    7502             dest,
    7503             DspinDhccpParam::MULTI_INVAL_DEST);
    7504 
    7505         DspinDhccpParam::dspin_set(
    7506             flit,
    7507             m_cc_global_id,
    7508             DspinDhccpParam::MULTI_INVAL_SRCID);
    7509 
    7510         DspinDhccpParam::dspin_set(
    7511             flit,
    7512             r_xram_rsp_to_cc_send_trdid.read(),
    7513             DspinDhccpParam::MULTI_INVAL_UPDT_INDEX);
    7514 
    7515         DspinDhccpParam::dspin_set(
    7516             flit,
    7517             multi_inval_type,
    7518             DspinDhccpParam::FROM_MC_TYPE);
    7519 
    7520         p_dspin_out.write = true;
    7521         p_dspin_out.data  = flit;
    7522 
    7523         break;
    7524       }
    7525 
    7526     case CC_SEND_XRAM_RSP_INVAL_NLINE:
    7527       {
    7528         uint64_t flit = 0;
    7529 
    7530         DspinDhccpParam::dspin_set(
    7531             flit,
    7532             1ULL,
    7533             DspinDhccpParam::FROM_MC_EOP);
    7534 
    7535         DspinDhccpParam::dspin_set(
    7536             flit,
    7537             r_xram_rsp_to_cc_send_nline.read(),
    7538             DspinDhccpParam::MULTI_INVAL_NLINE);
    7539        
    7540 
     8148        uint64_t dest = m_xram_rsp_to_cc_send_srcid_fifo.read() <<
     8149                        (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
     8150
     8151        DspinDhccpParam::dspin_set( flit,
     8152                                    dest,
     8153                                    DspinDhccpParam::MULTI_INVAL_DEST);
     8154
     8155        DspinDhccpParam::dspin_set( flit,
     8156                                    m_cc_global_id,
     8157                                    DspinDhccpParam::MULTI_INVAL_SRCID);
     8158
     8159        DspinDhccpParam::dspin_set( flit,
     8160                                    r_xram_rsp_to_cc_send_trdid.read(),
     8161                                    DspinDhccpParam::MULTI_INVAL_UPDT_INDEX);
     8162
     8163        DspinDhccpParam::dspin_set( flit,
     8164                                    multi_inval_type,
     8165                                    DspinDhccpParam::FROM_MC_TYPE);
    75418166        p_dspin_out.write = true;
    75428167        p_dspin_out.data  = flit;
    7543 
    75448168        break;
    7545       }
    7546 
     8169    }
     8170
     8171    //////////////////////////////////
     8172    case CC_SEND_XRAM_RSP_INVAL_NLINE:
     8173    {
     8174        uint64_t flit = 0;
     8175
     8176        DspinDhccpParam::dspin_set( flit,
     8177                                    r_xram_rsp_to_cc_send_nline.read(),
     8178                                    DspinDhccpParam::MULTI_INVAL_NLINE);
     8179        p_dspin_out.eop   = true;
     8180        p_dspin_out.write = true;
     8181        p_dspin_out.data  = flit;
     8182        break;
     8183    }
     8184
     8185    /////////////////////////////////////
     8186    case CC_SEND_CONFIG_BRDCAST_HEADER:
    75478187    case CC_SEND_XRAM_RSP_BRDCAST_HEADER:
    75488188    case CC_SEND_WRITE_BRDCAST_HEADER:
    75498189    case CC_SEND_CAS_BRDCAST_HEADER:
    7550       {
     8190    {
    75518191        uint64_t flit = 0;
    75528192
    7553         DspinDhccpParam::dspin_set(
    7554             flit,
    7555             m_broadcast_address,
    7556             DspinDhccpParam::BROADCAST_BOX);
    7557 
    7558         DspinDhccpParam::dspin_set(
    7559             flit,
    7560             m_cc_global_id,
    7561             DspinDhccpParam::BROADCAST_SRCID);
    7562 
    7563         DspinDhccpParam::dspin_set(
    7564             flit,
    7565             1ULL,
    7566             DspinDhccpParam::FROM_MC_BC);
    7567 
     8193        DspinDhccpParam::dspin_set( flit,
     8194                                    m_broadcast_boundaries,
     8195                                    DspinDhccpParam::BROADCAST_BOX);
     8196
     8197        DspinDhccpParam::dspin_set( flit,
     8198                                    m_cc_global_id,
     8199                                    DspinDhccpParam::BROADCAST_SRCID);
     8200
     8201        DspinDhccpParam::dspin_set( flit,
     8202                                    1ULL,
     8203                                    DspinDhccpParam::FROM_MC_BC);
    75688204        p_dspin_out.write = true;
    75698205        p_dspin_out.data  = flit;
    7570 
    75718206        break;
    7572       }
    7573 
     8207    }
     8208    ////////////////////////////////////
    75748209    case CC_SEND_XRAM_RSP_BRDCAST_NLINE:
    7575       {
     8210    {
    75768211        uint64_t flit = 0;
    7577 
    7578         DspinDhccpParam::dspin_set(
    7579             flit,
    7580             1ULL,
    7581             DspinDhccpParam::FROM_MC_EOP);
    7582 
    7583         DspinDhccpParam::dspin_set(
    7584             flit,
    7585             r_xram_rsp_to_cc_send_nline.read(),
    7586             DspinDhccpParam::BROADCAST_NLINE);
    7587 
     8212        DspinDhccpParam::dspin_set( flit,
     8213                                    r_xram_rsp_to_cc_send_nline.read(),
     8214                                    DspinDhccpParam::BROADCAST_NLINE);
    75888215        p_dspin_out.write = true;
     8216        p_dspin_out.eop   = true;
    75898217        p_dspin_out.data  = flit;
    7590 
    75918218        break;
    7592       }
    7593 
     8219    }
     8220    //////////////////////////////////
     8221    case CC_SEND_CONFIG_BRDCAST_NLINE:
     8222    {
     8223        uint64_t flit = 0;
     8224        DspinDhccpParam::dspin_set( flit,
     8225                                    r_config_to_cc_send_nline.read(),
     8226                                    DspinDhccpParam::BROADCAST_NLINE);
     8227        p_dspin_out.write = true;
     8228        p_dspin_out.eop   = true;
     8229        p_dspin_out.data  = flit;
     8230        break;
     8231    }
     8232    /////////////////////////////////
    75948233    case CC_SEND_WRITE_BRDCAST_NLINE:
    7595       {
     8234    {
    75968235        uint64_t flit = 0;
    7597 
    7598         DspinDhccpParam::dspin_set(
    7599             flit,
    7600             1ULL,
    7601             DspinDhccpParam::FROM_MC_EOP);
    7602 
    7603         DspinDhccpParam::dspin_set(
    7604             flit,
    7605             r_write_to_cc_send_nline.read(),
    7606             DspinDhccpParam::BROADCAST_NLINE);
    7607 
     8236        DspinDhccpParam::dspin_set( flit,
     8237                                    r_write_to_cc_send_nline.read(),
     8238                                    DspinDhccpParam::BROADCAST_NLINE);
    76088239        p_dspin_out.write = true;
     8240        p_dspin_out.eop   = true;
    76098241        p_dspin_out.data  = flit;
    7610 
    76118242        break;
    7612       }
    7613 
     8243    }
     8244    ///////////////////////////////
    76148245    case CC_SEND_CAS_BRDCAST_NLINE:
    7615       {
     8246    {
    76168247        uint64_t flit = 0;
    7617 
    7618         DspinDhccpParam::dspin_set(
    7619             flit,
    7620             1ULL,
    7621             DspinDhccpParam::FROM_MC_EOP);
    7622 
    7623         DspinDhccpParam::dspin_set(
    7624             flit,
    7625             r_cas_to_cc_send_nline.read(),
    7626             DspinDhccpParam::BROADCAST_NLINE);
    7627 
     8248        DspinDhccpParam::dspin_set( flit,
     8249                                    r_cas_to_cc_send_nline.read(),
     8250                                    DspinDhccpParam::BROADCAST_NLINE);
    76288251        p_dspin_out.write = true;
     8252        p_dspin_out.eop   = true;
    76298253        p_dspin_out.data  = flit;
    7630 
    76318254        break;
    7632       }
    7633 
     8255    }
     8256    ///////////////////////////////
    76348257    case CC_SEND_WRITE_UPDT_HEADER:
    7635       {
     8258    {
    76368259        if(not m_write_to_cc_send_inst_fifo.rok()) break;
    76378260
     
    76418264          multi_updt_type = DspinDhccpParam::TYPE_MULTI_UPDT_INST;
    76428265        }
    7643         else 
     8266        else
    76448267        {
    76458268          multi_updt_type = DspinDhccpParam::TYPE_MULTI_UPDT_DATA;
     
    76488271        uint64_t flit = 0;
    76498272        uint64_t dest =
    7650           m_write_to_cc_send_srcid_fifo.read() << 
    7651           (DspinDhccpParam::SRCID_WIDTH - vci_param::S);
     8273          m_write_to_cc_send_srcid_fifo.read() <<
     8274          (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
    76528275
    76538276        DspinDhccpParam::dspin_set(
     
    76758298
    76768299        break;
    7677       }
    7678 
     8300    }
     8301    //////////////////////////////
    76798302    case CC_SEND_WRITE_UPDT_NLINE:
    7680       {
     8303    {
    76818304        uint64_t flit = 0;
    76828305
     
    76958318
    76968319        break;
    7697       }
    7698 
     8320    }
     8321    /////////////////////////////
    76998322    case CC_SEND_WRITE_UPDT_DATA:
    7700       {
    7701         uint8_t multi_updt_eop;
    7702         if(  r_cc_send_cpt.read() ==
    7703             (r_write_to_cc_send_count.read()-1))
    7704         {
    7705           multi_updt_eop = 1;
    7706         }
    7707         else
    7708         {
    7709           multi_updt_eop = 0;
    7710         }
    7711 
    7712         uint8_t multi_updt_cpt  =
     8323    {
     8324
     8325        uint8_t multi_updt_cpt  =
    77138326          r_cc_send_cpt.read() + r_write_to_cc_send_index.read();
    77148327
     
    77178330
    77188331        uint64_t flit = 0;
    7719 
    7720         DspinDhccpParam::dspin_set(
    7721             flit,
    7722             (uint64_t)multi_updt_eop,
    7723             DspinDhccpParam::FROM_MC_EOP);
    77248332
    77258333        DspinDhccpParam::dspin_set(
     
    77348342
    77358343        p_dspin_out.write = true;
     8344        p_dspin_out.eop   = (r_cc_send_cpt.read() == (r_write_to_cc_send_count.read()-1));
    77368345        p_dspin_out.data  = flit;
    77378346
    77388347        break;
    7739       }
    7740 
     8348    }
     8349    ////////////////////////////
    77418350    case CC_SEND_CAS_UPDT_HEADER:
    7742       {
     8351    {
    77438352        if (not m_cas_to_cc_send_inst_fifo.rok()) break;
    77448353
     
    77488357          multi_updt_type = DspinDhccpParam::TYPE_MULTI_UPDT_INST;
    77498358        }
    7750         else 
     8359        else
    77518360        {
    77528361          multi_updt_type = DspinDhccpParam::TYPE_MULTI_UPDT_DATA;
     
    77558364        uint64_t flit = 0;
    77568365        uint64_t dest =
    7757           m_cas_to_cc_send_srcid_fifo.read() << 
    7758           (DspinDhccpParam::SRCID_WIDTH - vci_param::S);
     8366          m_cas_to_cc_send_srcid_fifo.read() <<
     8367          (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
    77598368
    77608369        DspinDhccpParam::dspin_set(
     
    77828391
    77838392        break;
    7784       }
    7785 
     8393    }
     8394    ////////////////////////////
    77868395    case CC_SEND_CAS_UPDT_NLINE:
    7787       {
     8396    {
    77888397        uint64_t flit = 0;
    77898398
     
    78028411
    78038412        break;
    7804       }
    7805 
     8413    }
     8414    ///////////////////////////
    78068415    case CC_SEND_CAS_UPDT_DATA:
    7807       {
    7808         uint8_t multi_updt_eop;
    7809         if(not r_cas_to_cc_send_is_long.read())
    7810         {
    7811           multi_updt_eop = 1;
    7812         }
    7813         else
    7814         {
    7815           multi_updt_eop = 0;
    7816         }
    7817 
     8416    {
    78188417        uint64_t flit = 0;
    7819 
    7820         DspinDhccpParam::dspin_set(
    7821             flit,
    7822             (uint64_t)multi_updt_eop,
    7823             DspinDhccpParam::FROM_MC_EOP);
    78248418
    78258419        DspinDhccpParam::dspin_set(
     
    78348428
    78358429        p_dspin_out.write = true;
     8430        p_dspin_out.eop   = not r_cas_to_cc_send_is_long.read();
    78368431        p_dspin_out.data  = flit;
    78378432
    78388433        break;
    7839       }
    7840 
     8434    }
     8435    ////////////////////////////////
    78418436    case CC_SEND_CAS_UPDT_DATA_HIGH:
    7842       {
     8437    {
    78438438        uint64_t flit = 0;
    7844 
    7845         DspinDhccpParam::dspin_set(
    7846             flit,
    7847             1ULL,
    7848             DspinDhccpParam::FROM_MC_EOP);
    78498439
    78508440        DspinDhccpParam::dspin_set(
     
    78598449
    78608450        p_dspin_out.write = true;
     8451        p_dspin_out.eop   = true;
    78618452        p_dspin_out.data  = flit;
    78628453
    78638454        break;
    7864       }
     8455    }
    78658456  }
    78668457
    78678458  ///////////////////////////////////////////////////////////////////
    7868   // Target command signals from the p_dspin_in port (CC_RECEIVE FSM)
     8459  // p_dspin_in port (CC_RECEIVE FSM)
    78698460  ///////////////////////////////////////////////////////////////////
    78708461  p_dspin_in.read = false;
     
    78768467      }
    78778468    case CC_RECEIVE_CLEANUP:
     8469    case CC_RECEIVE_CLEANUP_EOP:
    78788470      {
    78798471        p_dspin_in.read = m_cc_receive_to_cleanup_fifo.wok();
Note: See TracChangeset for help on using the changeset viewer.