Ignore:
Timestamp:
Aug 22, 2013, 6:45:38 PM (11 years ago)
Author:
haoliu
Message:

This version for RWT has merged with the lastest version of classic tsar.
It pass the test with giet_vm.

Location:
branches/RWT/modules/vci_mem_cache/caba/source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/RWT/modules/vci_mem_cache/caba/source/include

  • branches/RWT/modules/vci_mem_cache/caba/source/include/mem_cache_directory.h

    r477 r495  
    66#include <cassert>
    77#include "arithmetics.h"
    8 
    9 // !!!
    10 // The L1_MULTI_CACHE mechanism does no longer work with the new pktid encoding
    11 // of TSAR. Turning the define below to a non null value will cause the memcache
    12 // to behave in an unpredicted way.
    13 // TODO Either remove the mechanism from the mem cache or update its behaviour.
    14 
    15 #define L1_MULTI_CACHE 0
    168
    179//#define RANDOM_EVICTION
     
    4638      bool      inst;       // Is the owner an ICache ?
    4739      size_t    srcid;      // The SRCID of the owner
    48 #if L1_MULTI_CACHE
    49       size_t    cache_id;   // In multi_cache configuration
    50 #endif
    5140
    5241    ////////////////////////
    5342    // Constructors
    5443    ////////////////////////
    55       Owner(bool   i_inst
    56             ,size_t i_srcid
    57 #if L1_MULTI_CACHE
    58             ,size_t i_cache_id
    59 #endif
    60             ){
     44      Owner(bool   i_inst,
     45            size_t i_srcid)
     46      {
    6147        inst    = i_inst;
    6248        srcid   = i_srcid;
    63 #if L1_MULTI_CACHE
    64         cache_id= i_cache_id;
    65 #endif
    66       }
    67 
    68       Owner(const Owner &a){
     49      }
     50
     51      Owner(const Owner &a)
     52      {
    6953        inst    = a.inst;
    7054        srcid   = a.srcid;
    71 #if L1_MULTI_CACHE
    72         cache_id= a.cache_id;
    73 #endif
    74       }
    75 
    76       Owner(){
     55      }
     56
     57      Owner()
     58      {
    7759        inst    = false;
    7860        srcid   = 0;
    79 #if L1_MULTI_CACHE
    80         cache_id= 0;
    81 #endif
    8261      }
    8362      // end constructors
     
    11695      owner.inst    = 0;
    11796      owner.srcid   = 0;
    118 #if L1_MULTI_CACHE
    119       owner.cache_id= 0;
    120 #endif
    12197      ptr           = 0;
    12298    }
     
    177153                << " ; Count = " << count
    178154                << " ; Owner = " << owner.srcid
    179 #if L1_MULTI_CACHE
    180                 << "." << owner.cache_id
    181 #endif
    182155                << " " << owner.inst
    183156                << " ; Pointer = " << ptr << std::endl;
     
    328301    // - entry : the entry value
    329302    /////////////////////////////////////////////////////////////////////
    330     void write(const size_t &set, const size_t &way, const DirectoryEntry &entry)
     303    void write( const size_t         &set,
     304                const size_t         &way,
     305                const DirectoryEntry &entry)
    331306    {
    332307      assert( (set<m_sets)
     
    374349    DirectoryEntry select(const size_t &set, size_t &way)
    375350    {
    376       assert( (set < m_sets)
     351        assert( (set < m_sets)
    377352          && "Cache Directory : (select) The set index is invalid");
    378353
    379       for(size_t i=0; i<m_ways; i++){
    380         if(!m_dir_tab[set][i].valid){
    381           way=i;
    382           return DirectoryEntry(m_dir_tab[set][way]);
     354        // looking for an empty slot
     355        for(size_t i=0; i<m_ways; i++)
     356        {
     357            if( not m_dir_tab[set][i].valid )
     358            {
     359                way=i;
     360                return DirectoryEntry(m_dir_tab[set][way]);
     361            }
    383362        }
    384       }
    385363
    386364#ifdef RANDOM_EVICTION
    387       lfsr = (lfsr >> 1) ^ ((-(lfsr & 1)) & 0xd0000001);
    388       way = lfsr % m_ways;
    389       return DirectoryEntry(m_dir_tab[set][way]);
     365        lfsr = (lfsr >> 1) ^ ((-(lfsr & 1)) & 0xd0000001);
     366        way = lfsr % m_ways;
     367        return DirectoryEntry(m_dir_tab[set][way]);
    390368#endif
    391369
    392       for(size_t i=0; i<m_ways; i++){
    393         if(!(m_lru_tab[set][i].recent) && !(m_dir_tab[set][i].lock)){
    394           way=i;
    395           return DirectoryEntry(m_dir_tab[set][way]);
     370        // looking for a not locked and not recently used entry
     371        for(size_t i=0; i<m_ways; i++)
     372        {
     373            if((not m_lru_tab[set][i].recent) && (not m_dir_tab[set][i].lock) )
     374            {
     375                way=i;
     376                return DirectoryEntry(m_dir_tab[set][way]);
     377            }
    396378        }
    397       }
    398       for(size_t i=0; i<m_ways; i++){
    399         if( !(m_lru_tab[set][i].recent) && (m_dir_tab[set][i].lock)){
    400           way=i;
    401           return DirectoryEntry(m_dir_tab[set][way]);
     379
     380        // looking for a locked not recently used entry
     381        for(size_t i=0; i<m_ways; i++)
     382        {
     383            if( (not m_lru_tab[set][i].recent) && (m_dir_tab[set][i].lock))
     384            {
     385                way=i;
     386                return DirectoryEntry(m_dir_tab[set][way]);
     387            }
    402388        }
    403       }
    404       for(size_t i=0; i<m_ways; i++){
    405         if( (m_lru_tab[set][i].recent) && !(m_dir_tab[set][i].lock)){
    406           way=i;
    407           return DirectoryEntry(m_dir_tab[set][way]);
     389
     390        // looking for a recently used entry not locked
     391        for(size_t i=0; i<m_ways; i++)
     392        {
     393            if( (m_lru_tab[set][i].recent) && (not m_dir_tab[set][i].lock))
     394            {
     395                way=i;
     396                return DirectoryEntry(m_dir_tab[set][way]);
     397            }
    408398        }
    409       }
    410       way = 0;
    411       return DirectoryEntry(m_dir_tab[set][0]);
     399
     400        // select way 0 (even if entry is locked and recently used)
     401        way = 0;
     402        return DirectoryEntry(m_dir_tab[set][0]);
    412403    } // end select()
    413404
     
    443434    ////////////////////////
    444435      HeapEntry()
    445       :owner(false,0
    446 #if L1_MULTI_CACHE
    447              ,0
    448 #endif
    449              )
     436      :owner(false,0)
    450437      {
    451438        next = 0;
     
    455442    // Constructor
    456443    ////////////////////////
    457       HeapEntry(const HeapEntry &entry){
     444      HeapEntry(const HeapEntry &entry)
     445      {
    458446        owner.inst  = entry.owner.inst;
    459447        owner.srcid = entry.owner.srcid;
    460 #if L1_MULTI_CACHE
    461         owner.cache_id = entry.owner.cache_id;
    462 #endif       
    463448        next           = entry.next;
    464449      } // end constructor
     
    467452    // The copy() function copies an existing source entry to a target
    468453    /////////////////////////////////////////////////////////////////////
    469       void copy(const HeapEntry &entry){
     454      void copy(const HeapEntry &entry)
     455      {
    470456        owner.inst     = entry.owner.inst;
    471457        owner.srcid    = entry.owner.srcid;
    472 #if L1_MULTI_CACHE
    473         owner.cache_id = entry.owner.cache_id;
    474 #endif
    475458        next           = entry.next;
    476459      } // end copy()
     
    483466        << " -- owner.inst     : " << std::dec << owner.inst << std::endl
    484467        << " -- owner.srcid    : " << std::dec << owner.srcid << std::endl
    485 #if L1_MULTI_CACHE
    486         << " -- owner.cache_id : " << std::dec << owner.cache_id << std::endl
    487 #endif
    488468        << " -- next           : " << std::dec << next << std::endl;
    489469
     
    646626  //                        Cache Data
    647627  ////////////////////////////////////////////////////////////////////////
    648   class CacheData {
     628  class CacheData
     629  {
    649630    private:
    650631      const uint32_t m_sets;
     
    656637    public:
    657638
     639      ///////////////////////////////////////////////////////
    658640      CacheData(uint32_t ways, uint32_t sets, uint32_t words)
    659         : m_sets(sets), m_ways(ways), m_words(words) {
    660 
     641        : m_sets(sets), m_ways(ways), m_words(words)
     642      {
    661643          m_cache_data = new uint32_t ** [ways];
    662           for ( size_t i=0 ; i < ways ; i++ ) {
    663             m_cache_data[i] = new uint32_t * [sets];
     644          for ( size_t i=0 ; i < ways ; i++ )
     645          {
     646              m_cache_data[i] = new uint32_t * [sets];
    664647          }
    665           for ( size_t i=0; i<ways; i++ ) {
    666             for ( size_t j=0; j<sets; j++ ) {
    667               m_cache_data[i][j] = new uint32_t [words];
    668             }
     648          for ( size_t i=0; i<ways; i++ )
     649          {
     650              for ( size_t j=0; j<sets; j++ )
     651              {
     652                  m_cache_data[i][j] = new uint32_t [words];
     653              }
    669654          }
    670         }
    671 
    672       ~CacheData() {
    673           for(size_t i=0; i<m_ways ; i++){
    674               for(size_t j=0; j<m_sets ; j++){
     655      }
     656      ////////////
     657      ~CacheData()
     658      {
     659          for(size_t i=0; i<m_ways ; i++)
     660          {
     661              for(size_t j=0; j<m_sets ; j++)
     662              {
    675663                  delete [] m_cache_data[i][j];
    676664              }
    677665          }
    678           for(size_t i=0; i<m_ways ; i++){
     666          for(size_t i=0; i<m_ways ; i++)
     667          {
    679668              delete [] m_cache_data[i];
    680669          }
    681670          delete [] m_cache_data;
    682671      }
    683 
    684       uint32_t read (
    685           const uint32_t &way,
    686           const uint32_t &set,
    687           const uint32_t &word) const {
    688 
    689         assert((set  < m_sets ) && "Cache data error: Trying to read a wrong set" );
    690         assert((way  < m_ways ) && "Cache data error: Trying to read a wrong way" );
    691         assert((word < m_words) && "Cache data error: Trying to read a wrong word");
    692 
    693         return m_cache_data[way][set][word];
    694       }
    695 
    696       void read_line(
    697           const uint32_t &way,
    698           const uint32_t &set,
    699           sc_core::sc_signal<uint32_t> * cache_line)
    700       {
    701         assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" );
    702         assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" );
    703 
    704         for (uint32_t word=0; word<m_words; word++)
    705           cache_line[word].write(m_cache_data[way][set][word]);
    706       }
    707 
    708       void write (
    709           const uint32_t &way,
    710           const uint32_t &set,
    711           const uint32_t &word,
    712           const uint32_t &data,
    713           const uint32_t &be = 0xF) {
    714 
    715         assert((set  < m_sets ) && "Cache data error: Trying to write a wrong set" );
    716         assert((way  < m_ways ) && "Cache data error: Trying to write a wrong way" );
    717         assert((word < m_words) && "Cache data error: Trying to write a wrong word");
    718         assert((be  <= 0xF    ) && "Cache data error: Trying to write a wrong word cell");
    719 
    720         if (be == 0x0) return;
    721 
    722         if (be == 0xF) {
    723             m_cache_data[way][set][word] = data;
    724             return;
    725         }
    726 
    727         uint32_t mask = 0;
    728         if  (be & 0x1) mask = mask | 0x000000FF;
    729         if  (be & 0x2) mask = mask | 0x0000FF00;
    730         if  (be & 0x4) mask = mask | 0x00FF0000;
    731         if  (be & 0x8) mask = mask | 0xFF000000;
    732 
    733         m_cache_data[way][set][word] =
    734           (data & mask) | (m_cache_data[way][set][word] & ~mask);
     672      //////////////////////////////////////////
     673      uint32_t read ( const uint32_t &way,
     674                      const uint32_t &set,
     675                      const uint32_t &word) const
     676      {
     677          assert((set  < m_sets ) && "Cache data error: Trying to read a wrong set" );
     678          assert((way  < m_ways ) && "Cache data error: Trying to read a wrong way" );
     679          assert((word < m_words) && "Cache data error: Trying to read a wrong word");
     680
     681          return m_cache_data[way][set][word];
     682      }
     683      //////////////////////////////////////////
     684      void read_line( const uint32_t &way,
     685                      const uint32_t &set,
     686                      sc_core::sc_signal<uint32_t> * cache_line)
     687      {
     688          assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" );
     689          assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" );
     690
     691          for (uint32_t word=0; word<m_words; word++)
     692              cache_line[word].write(m_cache_data[way][set][word]);
     693      }
     694      /////////////////////////////////////////
     695      void write ( const uint32_t &way,
     696                   const uint32_t &set,
     697                   const uint32_t &word,
     698                   const uint32_t &data,
     699                   const uint32_t &be = 0xF)
     700      {
     701
     702          assert((set  < m_sets ) && "Cache data error: Trying to write a wrong set" );
     703          assert((way  < m_ways ) && "Cache data error: Trying to write a wrong way" );
     704          assert((word < m_words) && "Cache data error: Trying to write a wrong word");
     705          assert((be  <= 0xF    ) && "Cache data error: Trying to write a wrong be");
     706
     707          if (be == 0x0) return;
     708
     709          if (be == 0xF)
     710          {
     711              m_cache_data[way][set][word] = data;
     712              return;
     713          }
     714
     715          uint32_t mask = 0;
     716          if  (be & 0x1) mask = mask | 0x000000FF;
     717          if  (be & 0x2) mask = mask | 0x0000FF00;
     718          if  (be & 0x4) mask = mask | 0x00FF0000;
     719          if  (be & 0x8) mask = mask | 0xFF000000;
     720
     721          m_cache_data[way][set][word] =
     722              (data & mask) | (m_cache_data[way][set][word] & ~mask);
    735723      }
    736724  }; // end class CacheData
  • branches/RWT/modules/vci_mem_cache/caba/source/include/update_tab.h

  • branches/RWT/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h

    r477 r495  
    2525 * SOCLIB_LGPL_HEADER_END
    2626 *
    27  * Maintainers: alain eric.guthmuller@polytechnique.edu
     27 * Maintainers: alain.greiner@lip6.fr
     28 *              eric.guthmuller@polytechnique.edu
    2829 *              cesar.fuguet-tortolero@lip6.fr
    2930 *              alexandre.joannou@lip6.fr
     
    154155        MULTI_ACK_UPT_LOCK,
    155156        MULTI_ACK_UPT_CLEAR,
    156         MULTI_ACK_WRITE_RSP,
    157         MULTI_ACK_CONFIG_ACK
     157        MULTI_ACK_WRITE_RSP
    158158      };
    159159
     
    163163        CONFIG_IDLE,
    164164        CONFIG_LOOP,
     165        CONFIG_WAIT,
    165166        CONFIG_RSP,
    166167        CONFIG_DIR_REQ,
    167168        CONFIG_DIR_ACCESS,
    168         CONFIG_DIR_IVT_LOCK,
     169        CONFIG_IVT_LOCK,
    169170        CONFIG_BC_SEND,
    170         CONFIG_BC_WAIT,
    171         CONFIG_INV_SEND,
     171        CONFIG_INVAL_SEND,
    172172        CONFIG_HEAP_REQ,
    173173        CONFIG_HEAP_SCAN,
    174174        CONFIG_HEAP_LAST,
    175         CONFIG_INV_WAIT
     175        CONFIG_TRT_LOCK,
     176        CONFIG_TRT_SET,
     177        CONFIG_PUT_REQ
    176178      };
    177179
     
    204206        WRITE_DIR_LOCK,
    205207        WRITE_IVT_LOCK_HIT_WB,
    206         WRITE_DIR_READ,
    207208        WRITE_DIR_HIT,
    208209        WRITE_UPT_LOCK,
     
    217218        WRITE_MISS_TRT_SET,
    218219        WRITE_MISS_XRAM_REQ,
     220        WRITE_BC_DIR_READ,
    219221        WRITE_BC_TRT_LOCK,
    220222        WRITE_BC_IVT_LOCK,
     
    243245        XRAM_RSP_DIR_UPDT,
    244246        XRAM_RSP_DIR_RSP,
    245         XRAM_RSP_INVAL_LOCK,
     247        XRAM_RSP_IVT_LOCK,
    246248        XRAM_RSP_INVAL_WAIT,
    247249        XRAM_RSP_INVAL,
     
    262264        IXR_CMD_XRAM_IDLE,
    263265        IXR_CMD_CLEANUP_IDLE,
    264         IXR_CMD_READ,
    265         IXR_CMD_WRITE,
    266         IXR_CMD_CAS,
    267         IXR_CMD_XRAM,
    268         IXR_CMD_CLEANUP_DATA
     266        IXR_CMD_CONFIG_IDLE,
     267        IXR_CMD_READ_TRT,
     268        IXR_CMD_WRITE_TRT,
     269        IXR_CMD_CAS_TRT,
     270        IXR_CMD_XRAM_TRT,
     271        IXR_CMD_CLEANUP_TRT,
     272        IXR_CMD_CONFIG_TRT,
     273        IXR_CMD_READ_SEND,
     274        IXR_CMD_WRITE_SEND,
     275        IXR_CMD_CAS_SEND,
     276        IXR_CMD_XRAM_SEND,
     277        IXR_CMD_CLEANUP_DATA_SEND,
     278        IXR_CMD_CONFIG_SEND
    269279      };
    270280
     
    318328        CLEANUP_IXR_REQ,
    319329        CLEANUP_WAIT,
    320         CLEANUP_CONFIG_ACK,
    321330        CLEANUP_SEND_CLACK
    322331      };
     
    342351        ALLOC_TRT_XRAM_RSP,
    343352        ALLOC_TRT_IXR_RSP,
    344         ALLOC_TRT_CLEANUP
     353        ALLOC_TRT_CLEANUP,
     354        ALLOC_TRT_IXR_CMD,
     355        ALLOC_TRT_CONFIG
    345356      };
    346357
     
    404415      };
    405416
    406       /* Configuration commands */
    407       enum cmd_config_type_e
    408       {
    409           CMD_CONFIG_INVAL = 0,
    410           CMD_CONFIG_SYNC  = 1
    411       };
    412 
    413       // debug variables (for each FSM)
     417      // debug variables
    414418      bool                 m_debug;
    415419      bool                 m_debug_previous_valid;
    416420      size_t               m_debug_previous_count;
    417421      bool                 m_debug_previous_dirty;
    418       sc_signal<data_t>*   m_debug_previous_data;
    419       sc_signal<data_t>*   m_debug_data;
    420 
    421       bool         m_monitor_ok;
    422       addr_t       m_monitor_base;
    423       addr_t       m_monitor_length;
     422      data_t *             m_debug_previous_data;
     423      data_t *             m_debug_data;
    424424
    425425      // instrumentation counters
     
    644644      uint32_t                           m_broadcast_boundaries;
    645645
    646       //////////////////////////////////////////////////
    647       // Registers controlled by the TGT_CMD fsm
    648       //////////////////////////////////////////////////
    649 
    650       sc_signal<int>         r_tgt_cmd_fsm;
    651 
    652646      // Fifo between TGT_CMD fsm and READ fsm
    653647      GenericFifo<addr_t>    m_cmd_read_addr_fifo;
     
    693687      sc_signal<size_t>   r_tgt_cmd_config_cmd;
    694688
     689      //////////////////////////////////////////////////
     690      // Registers controlled by the TGT_CMD fsm
     691      //////////////////////////////////////////////////
     692
     693      sc_signal<int>         r_tgt_cmd_fsm;
     694      sc_signal<size_t>      r_tgt_cmd_srcid;           // srcid for response to config
     695      sc_signal<size_t>      r_tgt_cmd_trdid;           // trdid for response to config
     696      sc_signal<size_t>      r_tgt_cmd_pktid;           // pktid for response to config
     697
    695698      ///////////////////////////////////////////////////////
    696699      // Registers controlled by the CONFIG fsm
    697700      ///////////////////////////////////////////////////////
    698701
    699       sc_signal<int>      r_config_fsm;            // FSM state
    700       sc_signal<bool>     r_config_lock;           // lock protecting exclusive access
    701       sc_signal<int>      r_config_cmd;            // config request status
    702       sc_signal<addr_t>   r_config_address;        // target buffer physical address
    703       sc_signal<size_t>   r_config_srcid;          // config request srcid
    704       sc_signal<size_t>   r_config_trdid;          // config request trdid
    705       sc_signal<size_t>   r_config_pktid;          // config request pktid
    706       sc_signal<size_t>   r_config_nlines;         // number of lines covering the buffer
    707       sc_signal<size_t>   r_config_dir_way;        // DIR: selected way
    708       sc_signal<size_t>   r_config_dir_count;      // DIR: number of copies
    709       sc_signal<bool>     r_config_dir_is_cnt;     // DIR: counter mode (broadcast required)
    710       sc_signal<size_t>   r_config_dir_copy_srcid; // DIR: first copy SRCID
    711       sc_signal<bool>     r_config_dir_copy_inst;  // DIR: first copy L1 type
    712       sc_signal<size_t>   r_config_dir_next_ptr;   // DIR: index of next copy in HEAP
    713       sc_signal<size_t>   r_config_heap_next;      // current pointer to scan HEAP
    714 
    715       sc_signal<size_t>   r_config_ivt_index;      // IVT index
     702      sc_signal<int>      r_config_fsm;               // FSM state
     703      sc_signal<bool>     r_config_lock;              // lock protecting exclusive access
     704      sc_signal<int>      r_config_cmd;               // config request type 
     705      sc_signal<addr_t>   r_config_address;           // target buffer physical address
     706      sc_signal<size_t>   r_config_srcid;             // config request srcid
     707      sc_signal<size_t>   r_config_trdid;             // config request trdid
     708      sc_signal<size_t>   r_config_pktid;             // config request pktid
     709      sc_signal<size_t>   r_config_cmd_lines;         // number of lines to be handled
     710      sc_signal<size_t>   r_config_rsp_lines;         // number of lines not completed
     711      sc_signal<size_t>   r_config_dir_way;           // DIR: selected way
     712      sc_signal<bool>     r_config_dir_lock;          // DIR: locked entry
     713      sc_signal<size_t>   r_config_dir_count;         // DIR: number of copies
     714      sc_signal<bool>     r_config_dir_is_cnt;        // DIR: counter mode (broadcast)
     715      sc_signal<size_t>   r_config_dir_copy_srcid;    // DIR: first copy SRCID
     716      sc_signal<bool>     r_config_dir_copy_inst;     // DIR: first copy L1 type
     717      sc_signal<size_t>   r_config_dir_ptr;           // DIR: index of next copy in HEAP
     718      sc_signal<size_t>   r_config_heap_next;         // current pointer to scan HEAP
     719      sc_signal<size_t>   r_config_trt_index;         // selected entry in TRT
     720      sc_signal<size_t>   r_config_ivt_index;         // selected entry in IVT
     721
     722      // Buffer between CONFIG fsm and IXR_CMD fsm
     723      sc_signal<bool>     r_config_to_ixr_cmd_req;    // valid request
     724      sc_signal<size_t>   r_config_to_ixr_cmd_index;  // TRT index
     725
    716726
    717727      // Buffer between CONFIG fsm and TGT_RSP fsm (send a done response to L1 cache)
     
    730740      GenericFifo<size_t> m_config_to_cc_send_srcid_fifo;   // fifo for owners srcid
    731741
    732 #if L1_MULTI_CACHE
    733       GenericFifo<size_t> m_config_to_cc_send_cache_id_fifo; // fifo for cache_id
    734 #endif
    735 
    736742      ///////////////////////////////////////////////////////
    737743      // Registers controlled by the READ fsm
    738744      ///////////////////////////////////////////////////////
    739745
    740       sc_signal<int>      r_read_fsm;          // FSM state
    741       sc_signal<size_t>   r_read_copy;         // Srcid of the first copy
    742       sc_signal<size_t>   r_read_copy_cache;   // Srcid of the first copy
    743       sc_signal<bool>     r_read_copy_inst;    // Type of the first copy
    744       sc_signal<tag_t>    r_read_tag;          // cache line tag (in directory)
    745       sc_signal<bool>     r_read_is_cnt;       // is_cnt bit (in directory)
    746       sc_signal<bool>     r_read_lock;         // lock bit (in directory)
    747       sc_signal<bool>     r_read_dirty;        // dirty bit (in directory)
    748       sc_signal<size_t>   r_read_count;        // number of copies
    749       sc_signal<size_t>   r_read_ptr;          // pointer to the heap
    750       sc_signal<data_t> * r_read_data;         // data (one cache line)
    751       sc_signal<size_t>   r_read_way;          // associative way (in cache)
    752       sc_signal<size_t>   r_read_trt_index;    // Transaction Table index
    753       sc_signal<size_t>   r_read_next_ptr;     // Next entry to point to
    754       sc_signal<bool>     r_read_last_free;    // Last free entry
    755       sc_signal<addr_t>   r_read_ll_key;       // LL key from the llsc_global_table
    756 
    757       // Buffer between READ fsm and IXR_CMD fsm (ask a missing cache line to XRAM)
    758       sc_signal<bool>     r_read_to_ixr_cmd_req;    // valid request
    759       sc_signal<addr_t>   r_read_to_ixr_cmd_nline;  // cache line index
    760       sc_signal<size_t>   r_read_to_ixr_cmd_trdid;  // index in Transaction Table
     746      sc_signal<int>      r_read_fsm;                 // FSM state
     747      sc_signal<size_t>   r_read_copy;                // Srcid of the first copy
     748      sc_signal<size_t>   r_read_copy_cache;          // Srcid of the first copy
     749      sc_signal<bool>     r_read_copy_inst;           // Type of the first copy
     750      sc_signal<tag_t>    r_read_tag;                 // cache line tag (in directory)
     751      sc_signal<bool>     r_read_is_cnt;              // is_cnt bit (in directory)
     752      sc_signal<bool>     r_read_lock;                // lock bit (in directory)
     753      sc_signal<bool>     r_read_dirty;               // dirty bit (in directory)
     754      sc_signal<size_t>   r_read_count;               // number of copies
     755      sc_signal<size_t>   r_read_ptr;                 // pointer to the heap
     756      sc_signal<data_t> * r_read_data;                // data (one cache line)
     757      sc_signal<size_t>   r_read_way;                 // associative way (in cache)
     758      sc_signal<size_t>   r_read_trt_index;           // Transaction Table index
     759      sc_signal<size_t>   r_read_next_ptr;            // Next entry to point to
     760      sc_signal<bool>     r_read_last_free;           // Last free entry
     761      sc_signal<addr_t>   r_read_ll_key;              // LL key from llsc_global_table
     762
     763      // Buffer between READ fsm and IXR_CMD fsm
     764      sc_signal<bool>     r_read_to_ixr_cmd_req;      // valid request
     765      sc_signal<size_t>   r_read_to_ixr_cmd_index;    // TRT index
    761766
    762767      // Buffer between READ fsm and TGT_RSP fsm (send a hit read response to L1 cache)
    763       sc_signal<bool>     r_read_to_tgt_rsp_req;    // valid request
    764       sc_signal<size_t>   r_read_to_tgt_rsp_srcid;  // Transaction srcid
    765       sc_signal<size_t>   r_read_to_tgt_rsp_trdid;  // Transaction trdid
    766       sc_signal<size_t>   r_read_to_tgt_rsp_pktid;  // Transaction pktid
    767       sc_signal<data_t> * r_read_to_tgt_rsp_data;   // data (one cache line)
    768       sc_signal<size_t>   r_read_to_tgt_rsp_word;   // first word of the response
    769       sc_signal<size_t>   r_read_to_tgt_rsp_length; // length of the response
    770       sc_signal<addr_t>   r_read_to_tgt_rsp_ll_key; // LL key from the llsc_global_table
     768      sc_signal<bool>     r_read_to_tgt_rsp_req;      // valid request
     769      sc_signal<size_t>   r_read_to_tgt_rsp_srcid;    // Transaction srcid
     770      sc_signal<size_t>   r_read_to_tgt_rsp_trdid;    // Transaction trdid
     771      sc_signal<size_t>   r_read_to_tgt_rsp_pktid;    // Transaction pktid
     772      sc_signal<data_t> * r_read_to_tgt_rsp_data;     // data (one cache line)
     773      sc_signal<size_t>   r_read_to_tgt_rsp_word;     // first word of the response
     774      sc_signal<size_t>   r_read_to_tgt_rsp_length;   // length of the response
     775      sc_signal<addr_t>   r_read_to_tgt_rsp_ll_key;   // LL key from llsc_global_table
    771776
    772777      //RWT: Buffer between READ fsm and CC_SEND fsm (send inval)
     
    795800      ///////////////////////////////////////////////////////////////
    796801
    797       sc_signal<int>      r_write_fsm;        // FSM state
    798       sc_signal<addr_t>   r_write_address;    // first word address
    799       sc_signal<size_t>   r_write_word_index; // first word index in line
    800       sc_signal<size_t>   r_write_word_count; // number of words in line
    801       sc_signal<size_t>   r_write_srcid;      // transaction srcid
    802       sc_signal<size_t>   r_write_trdid;      // transaction trdid
    803       sc_signal<size_t>   r_write_pktid;      // transaction pktid
    804       sc_signal<data_t> * r_write_data;       // data (one cache line)
    805       sc_signal<be_t>   * r_write_be;         // one byte enable per word
    806       sc_signal<bool>     r_write_byte;       // (BE != 0X0) and (BE != 0xF)
    807       sc_signal<bool>     r_write_is_cnt;     // is_cnt bit (in directory)
    808       sc_signal<bool>     r_write_lock;       // lock bit (in directory)
    809       sc_signal<tag_t>    r_write_tag;        // cache line tag (in directory)
    810       sc_signal<size_t>   r_write_copy;       // first owner of the line
    811       sc_signal<size_t>   r_write_copy_cache; // first owner of the line
    812       sc_signal<bool>     r_write_copy_inst;  // is this owner a ICache ?
    813       sc_signal<size_t>   r_write_count;      // number of copies
    814       sc_signal<size_t>   r_write_ptr;        // pointer to the heap
    815       sc_signal<size_t>   r_write_next_ptr;   // next pointer to the heap
    816       sc_signal<bool>     r_write_to_dec;     // need to decrement update counter
    817       sc_signal<size_t>   r_write_way;        // way of the line
    818       sc_signal<size_t>   r_write_trt_index;  // index in Transaction Table
    819       sc_signal<size_t>   r_write_upt_index;  // index in Update Table
    820       sc_signal<bool>     r_write_sc_fail;    // sc command failed
    821       sc_signal<bool>     r_write_pending_sc; // sc command pending
     802      sc_signal<int>      r_write_fsm;                // FSM state
     803      sc_signal<addr_t>   r_write_address;            // first word address
     804      sc_signal<size_t>   r_write_word_index;         // first word index in line
     805      sc_signal<size_t>   r_write_word_count;         // number of words in line
     806      sc_signal<size_t>   r_write_srcid;              // transaction srcid
     807      sc_signal<size_t>   r_write_trdid;              // transaction trdid
     808      sc_signal<size_t>   r_write_pktid;              // transaction pktid
     809      sc_signal<data_t> * r_write_data;               // data (one cache line)
     810      sc_signal<be_t>   * r_write_be;                 // one byte enable per word
     811      sc_signal<bool>     r_write_byte;               // (BE != 0X0) and (BE != 0xF)
     812      sc_signal<bool>     r_write_is_cnt;             // is_cnt bit (in directory)
     813      sc_signal<bool>     r_write_lock;               // lock bit (in directory)
     814      sc_signal<tag_t>    r_write_tag;                // cache line tag (in directory)
     815      sc_signal<size_t>   r_write_copy;               // first owner of the line
     816      sc_signal<size_t>   r_write_copy_cache;         // first owner of the line
     817      sc_signal<bool>     r_write_copy_inst;          // is this owner a ICache ?
     818      sc_signal<size_t>   r_write_count;              // number of copies
     819      sc_signal<size_t>   r_write_ptr;                // pointer to the heap
     820      sc_signal<size_t>   r_write_next_ptr;           // next pointer to the heap
     821      sc_signal<bool>     r_write_to_dec;             // need to decrement update counter
     822      sc_signal<size_t>   r_write_way;                // way of the line
     823      sc_signal<size_t>   r_write_trt_index;          // index in Transaction Table
     824      sc_signal<size_t>   r_write_upt_index;          // index in Update Table
     825      sc_signal<bool>     r_write_sc_fail;            // sc command failed
     826      sc_signal<bool>     r_write_pending_sc;         // sc command pending
    822827
    823828      // Buffer between WRITE fsm and TGT_RSP fsm (acknowledge a write command from L1)
     
    828833      sc_signal<bool>     r_write_to_tgt_rsp_sc_fail; // sc command failed
    829834
    830       // Buffer between WRITE fsm and IXR_CMD fsm (ask a missing cache line to XRAM)
    831       sc_signal<bool>     r_write_to_ixr_cmd_req;   // valid request
    832       sc_signal<bool>     r_write_to_ixr_cmd_write; // write request
    833       sc_signal<addr_t>   r_write_to_ixr_cmd_nline; // cache line index
    834       sc_signal<data_t> * r_write_to_ixr_cmd_data;  // cache line data
    835       sc_signal<size_t>   r_write_to_ixr_cmd_trdid; // index in Transaction Table
     835      // Buffer between WRITE fsm and IXR_CMD fsm
     836      sc_signal<bool>     r_write_to_ixr_cmd_req;     // valid request
     837      sc_signal<bool>     r_write_to_ixr_cmd_put;     // request type (GET/PUT)
     838      sc_signal<size_t>   r_write_to_ixr_cmd_index;   // TRT index
    836839
    837840      // Buffer between WRITE fsm and CC_SEND fsm (Update/Invalidate L1 caches)
     
    847850      GenericFifo<size_t> m_write_to_cc_send_srcid_fifo;    // fifo for srcids
    848851
    849 #if L1_MULTI_CACHE
    850       GenericFifo<size_t> m_write_to_cc_send_cache_id_fifo; // fifo for srcids
    851 #endif
    852 
    853852      // Buffer between WRITE fsm and MULTI_ACK fsm (Decrement UPT entry)
    854853      sc_signal<bool>     r_write_to_multi_ack_req;       // valid request
     
    878877      sc_signal<addr_t>   r_multi_ack_nline;     // pending write nline
    879878
    880       // signaling completion of multi-inval to CONFIG fsm
    881       sc_signal<bool>     r_multi_ack_to_config_ack;
    882 
    883879      // Buffer between MULTI_ACK fsm and TGT_RSP fsm (complete write/update transaction)
    884880      sc_signal<bool>     r_multi_ack_to_tgt_rsp_req;   // valid request
     
    897893      sc_signal<addr_t>   r_cleanup_nline;         // cache line index
    898894
    899 #if L1_MULTI_CACHE
    900       sc_signal<size_t>   r_cleanup_pktid;         // transaction pktid
    901 #endif
    902895
    903896      sc_signal<copy_t>   r_cleanup_copy;          // first copy
     
    926919      sc_signal<size_t>   r_cleanup_index;         // index of the INVAL line (in the UPT)
    927920
    928       // signaling completion of broadcast-inval to CONFIG fsm
    929       sc_signal<bool>     r_cleanup_to_config_ack; 
    930        
    931921      // Buffer between CLEANUP fsm and TGT_RSP fsm (acknowledge a write command from L1)
    932922      sc_signal<bool>     r_cleanup_to_tgt_rsp_req;   // valid request
     
    950940      ///////////////////////////////////////////////////////
    951941
    952       sc_signal<int>      r_cas_fsm;        // FSM state
    953       sc_signal<data_t>   r_cas_wdata;      // write data word
    954       sc_signal<data_t> * r_cas_rdata;      // read data word
    955       sc_signal<uint32_t> r_cas_lfsr;       // lfsr for random introducing
    956       sc_signal<size_t>   r_cas_cpt;        // size of command
    957       sc_signal<copy_t>   r_cas_copy;       // Srcid of the first copy
    958       sc_signal<copy_t>   r_cas_copy_cache; // Srcid of the first copy
    959       sc_signal<bool>     r_cas_copy_inst;  // Type of the first copy
    960       sc_signal<size_t>   r_cas_count;      // number of copies
    961       sc_signal<size_t>   r_cas_ptr;        // pointer to the heap
    962       sc_signal<size_t>   r_cas_next_ptr;   // next pointer to the heap
    963       sc_signal<bool>     r_cas_is_cnt;     // is_cnt bit (in directory)
    964       sc_signal<bool>     r_cas_dirty;      // dirty bit (in directory)
    965       sc_signal<size_t>   r_cas_way;        // way in directory
    966       sc_signal<size_t>   r_cas_set;        // set in directory
    967       sc_signal<data_t>   r_cas_tag;        // cache line tag (in directory)
    968       sc_signal<size_t>   r_cas_trt_index;  // Transaction Table index
    969       sc_signal<size_t>   r_cas_upt_index;  // Update Table index
    970       sc_signal<data_t> * r_cas_data;       // cache line data
     942      sc_signal<int>      r_cas_fsm;              // FSM state
     943      sc_signal<data_t>   r_cas_wdata;            // write data word
     944      sc_signal<data_t> * r_cas_rdata;            // read data word
     945      sc_signal<uint32_t> r_cas_lfsr;             // lfsr for random introducing
     946      sc_signal<size_t>   r_cas_cpt;              // size of command
     947      sc_signal<copy_t>   r_cas_copy;             // Srcid of the first copy
     948      sc_signal<copy_t>   r_cas_copy_cache;       // Srcid of the first copy
     949      sc_signal<bool>     r_cas_copy_inst;        // Type of the first copy
     950      sc_signal<size_t>   r_cas_count;            // number of copies
     951      sc_signal<size_t>   r_cas_ptr;              // pointer to the heap
     952      sc_signal<size_t>   r_cas_next_ptr;         // next pointer to the heap
     953      sc_signal<bool>     r_cas_is_cnt;           // is_cnt bit (in directory)
     954      sc_signal<bool>     r_cas_dirty;            // dirty bit (in directory)
     955      sc_signal<size_t>   r_cas_way;              // way in directory
     956      sc_signal<size_t>   r_cas_set;              // set in directory
     957      sc_signal<data_t>   r_cas_tag;              // cache line tag (in directory)
     958      sc_signal<size_t>   r_cas_trt_index;        // Transaction Table index
     959      sc_signal<size_t>   r_cas_upt_index;        // Update Table index
     960      sc_signal<data_t> * r_cas_data;             // cache line data
    971961
    972962      sc_signal<bool>     r_cas_coherent;
     
    974964      // Buffer between CAS fsm and IXR_CMD fsm (XRAM write)
    975965      sc_signal<bool>     r_cas_to_ixr_cmd_req;   // valid request
    976       sc_signal<addr_t>   r_cas_to_ixr_cmd_nline; // cache line index
    977       sc_signal<size_t>   r_cas_to_ixr_cmd_trdid; // index in Transaction Table
    978       sc_signal<bool>     r_cas_to_ixr_cmd_write; // write request
    979       sc_signal<data_t> * r_cas_to_ixr_cmd_data;  // cache line data
    980 
     966      sc_signal<bool>     r_cas_to_ixr_cmd_put;   // request type (GET/PUT)
     967      sc_signal<size_t>   r_cas_to_ixr_cmd_index; // TRT index
    981968
    982969      // Buffer between CAS fsm and TGT_RSP fsm
     
    999986      GenericFifo<size_t> m_cas_to_cc_send_srcid_fifo;    // fifo for srcids
    1000987
    1001 #if L1_MULTI_CACHE
    1002       GenericFifo<size_t> m_cas_to_cc_send_cache_id_fifo; // fifo for srcids
    1003 #endif
    1004 
    1005988      ////////////////////////////////////////////////////
    1006989      // Registers controlled by the IXR_RSP fsm
    1007990      ////////////////////////////////////////////////////
    1008991
    1009       sc_signal<int>      r_ixr_rsp_fsm;       // FSM state
    1010       sc_signal<size_t>   r_ixr_rsp_trt_index; // TRT entry index
    1011       sc_signal<size_t>   r_ixr_rsp_cpt;       // word counter
     992      sc_signal<int>      r_ixr_rsp_fsm;                // FSM state
     993      sc_signal<size_t>   r_ixr_rsp_trt_index;          // TRT entry index
     994      sc_signal<size_t>   r_ixr_rsp_cpt;                // word counter
     995
     996      // Buffer between IXR_RSP fsm and CONFIG fsm  (response from the XRAM)
     997      sc_signal<bool>     r_ixr_rsp_to_config_ack;      // one single bit   
    1012998
    1013999      // Buffer between IXR_RSP fsm and XRAM_RSP fsm  (response from the XRAM)
    1014       sc_signal<bool>   * r_ixr_rsp_to_xram_rsp_rok; // A xram response is ready
     1000      sc_signal<bool>   * r_ixr_rsp_to_xram_rsp_rok;    // one bit per TRT entry
    10151001
    10161002      ////////////////////////////////////////////////////
     
    10551041      GenericFifo<size_t> m_xram_rsp_to_cc_send_srcid_fifo;    // fifo for srcids
    10561042
    1057 #if L1_MULTI_CACHE
    1058       GenericFifo<size_t> m_xram_rsp_to_cc_send_cache_id_fifo; // fifo for srcids
    1059 #endif
    1060 
    1061       // Buffer between XRAM_RSP fsm and IXR_CMD fsm (XRAM write)
     1043      // Buffer between XRAM_RSP fsm and IXR_CMD fsm
    10621044      sc_signal<bool>     r_xram_rsp_to_ixr_cmd_req;   // Valid request
    1063       sc_signal<addr_t>   r_xram_rsp_to_ixr_cmd_nline; // cache line index
    1064       sc_signal<data_t> * r_xram_rsp_to_ixr_cmd_data;  // cache line data
    1065       sc_signal<size_t>   r_xram_rsp_to_ixr_cmd_trdid; // index in transaction table
     1045      sc_signal<size_t>   r_xram_rsp_to_ixr_cmd_index; // TRT index
    10661046
    10671047      //RWT
     
    10731053
    10741054      sc_signal<int>      r_ixr_cmd_fsm;
    1075       sc_signal<size_t>   r_ixr_cmd_cpt;
     1055      sc_signal<size_t>   r_ixr_cmd_word;              // word index for a put
     1056      sc_signal<size_t>   r_ixr_cmd_trdid;             // TRT index value     
     1057      sc_signal<addr_t>   r_ixr_cmd_address;           // address to XRAM
     1058      sc_signal<data_t> * r_ixr_cmd_wdata;             // cache line buffer
     1059      sc_signal<bool>     r_ixr_cmd_get;               // transaction type (PUT/GET)
    10761060
    10771061      ////////////////////////////////////////////////////
     
    11491133      sc_signal<data_t>    *r_cleanup_to_ixr_cmd_data;
    11501134      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_srcid;
    1151       sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_trdid;
     1135      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_index;
    11521136      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_pktid;
    11531137      sc_signal<addr_t>    r_cleanup_to_ixr_cmd_nline;
  • branches/RWT/modules/vci_mem_cache/caba/source/include/xram_transaction.h

    r477 r495  
    3434    bool                rerror;         // error returned by xram
    3535    data_t              ll_key;         // LL key returned by the llsc_global_table
     36    bool                config;         // transaction required by CONFIG FSM
    3637
    3738    /////////////////////////////////////////////////////////////////////
     
    4243        valid           = false;
    4344        rerror      = false;
     45        config      = false;
    4446    }
    4547
     
    8082        rerror      = source.rerror;
    8183        ll_key      = source.ll_key;
     84        config      = source.config;
    8285    }
    8386
     
    8790    void print()
    8891    {
     92        std::cout << "------- TRT entry -------" << std::endl;
    8993        std::cout << "valid       = " << valid        << std::endl;
    9094        std::cout << "xram_read   = " << xram_read    << std::endl;
     
    96100        std::cout << "read_length = " << read_length  << std::endl;
    97101        std::cout << "word_index  = " << word_index   << std::endl;
    98         for(size_t i=0; i<wdata_be.size() ; i++){
    99             std::cout << "wdata_be [" << i <<"] = " << wdata_be[i] << std::endl;
    100         }
    101         for(size_t i=0; i<wdata.size() ; i++){
    102             std::cout << "wdata [" << i <<"] = " << wdata[i] << std::endl;
    103         }
     102        for(size_t i=0; i<wdata_be.size() ; i++)
     103        {
     104            std::cout << "wdata_be[" << std::dec << i << "] = "
     105                      << std::hex << wdata_be[i] << std::endl;
     106        }
     107        for(size_t i=0; i<wdata.size() ; i++)
     108        {
     109            std::cout << "wdata[" << std::dec << i << "] = "
     110                      << std::hex << wdata[i] << std::endl;
     111        }
     112        std::cout << "rerror      = " << rerror       << std::endl;
     113        std::cout << "ll_key      = " << ll_key       << std::endl;
     114        std::cout << "config      = " << config       << std::endl;
    104115        std::cout << std::endl;
    105         std::cout << "rerror      = " << rerror       << std::endl;
    106116    }
    107117
     
    114124        wdata_be.clear();
    115125        wdata.clear();
    116         valid=false;
    117         rerror=false;
    118     }
    119 
    120     TransactionTabEntry(const TransactionTabEntry &source){
     126        valid  = false;
     127        rerror = false;
     128        config = false;
     129    }
     130
     131    TransactionTabEntry(const TransactionTabEntry &source)
     132    {
    121133        valid       = source.valid;
    122134        xram_read       = source.xram_read;
     
    132144        rerror      = source.rerror;
    133145        ll_key      = source.ll_key;
     146        config      = source.config;
    134147    }
    135148
     
    197210        delete [] tab;
    198211    }
    199 
    200212    /////////////////////////////////////////////////////////////////////
    201213    // The size() function returns the size of the tab
     
    205217        return size_tab;
    206218    }
    207 
    208219    /////////////////////////////////////////////////////////////////////
    209220    // The init() function initializes the transaction tab entries
     
    211222    void init()
    212223    {
    213         for ( size_t i=0; i<size_tab; i++) {
     224        for ( size_t i=0; i<size_tab; i++)
     225        {
    214226            tab[i].init();
    215227        }
    216228    }
    217 
    218229    /////////////////////////////////////////////////////////////////////
    219230    // The print() function prints a transaction tab entry
     
    223234    void print(const size_t index)
    224235    {
    225         assert( (index < size_tab)
    226                 && "Invalid Transaction Tab Entry");
     236        assert( (index < size_tab) and
     237        "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()");
     238
    227239        tab[index].print();
    228240        return;
    229241    }
    230 
    231242    /////////////////////////////////////////////////////////////////////
    232243    // The read() function returns a transaction tab entry.
     
    236247    TransactionTabEntry read(const size_t index)
    237248    {
    238         assert( (index < size_tab)
    239                 && "Invalid Transaction Tab Entry");
     249        assert( (index < size_tab) and
     250        "MEMC ERROR: Invalid Transaction Tab Entry");
     251
    240252        return tab[index];
    241253    }
    242 
    243254    /////////////////////////////////////////////////////////////////////
    244255    // The full() function returns the state of the transaction tab
     
    249260    bool full(size_t &index)
    250261    {
    251         for(size_t i=0; i<size_tab; i++){
    252             if(!tab[i].valid){
     262        for(size_t i=0; i<size_tab; i++)
     263        {
     264            if(!tab[i].valid)
     265            {
    253266                index=i;
    254267                return false;   
     
    257270        return true;
    258271    }
    259 
    260272    /////////////////////////////////////////////////////////////////////
    261273    // The hit_read() function checks if an XRAM read transaction exists
     
    268280    bool hit_read(const addr_t nline,size_t &index)
    269281    {
    270         for(size_t i=0; i<size_tab; i++){
    271             if((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read)) {
     282        for(size_t i=0; i<size_tab; i++)
     283        {
     284            if((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read))
     285            {
    272286                index=i;
    273287                return true;   
     
    276290        return false;
    277291    }
    278 
    279292    ///////////////////////////////////////////////////////////////////////
    280293    // The hit_write() function looks if an XRAM write transaction exists
     
    286299    bool hit_write(const addr_t nline)
    287300    {
    288         for(size_t i=0; i<size_tab; i++){
    289             if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read)) {
     301        for(size_t i=0; i<size_tab; i++)
     302        {
     303            if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read))
     304            {
    290305                return true;   
    291306            }
     
    325340            const std::vector<data_t> &data)
    326341    {
    327         assert( (index < size_tab)
    328                 && "Invalid Transaction Tab Entry");
    329         assert(be.size()==tab[index].wdata_be.size()
    330                 && "Bad data mask in write_data_mask in TransactionTab");
    331         assert(data.size()==tab[index].wdata.size()
    332                 && "Bad data in write_data_mask in TransactionTab");
    333 
    334         for(size_t i=0; i<tab[index].wdata_be.size() ; i++) {
     342        assert( (index < size_tab) and
     343        "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()");
     344
     345        assert( (be.size()==tab[index].wdata_be.size()) and
     346        "MEMC ERROR: Bad be size in TRT write_data_mask()");
     347
     348        assert( (data.size()==tab[index].wdata.size()) and
     349        "MEMC ERROR: Bad data size in TRT write_data_mask()");
     350
     351        for(size_t i=0; i<tab[index].wdata_be.size() ; i++)
     352        {
    335353            tab[index].wdata_be[i] = tab[index].wdata_be[i] | be[i];
    336354            data_t mask = be_to_mask(be[i]);
     
    338356        }
    339357    }
    340 
    341358    /////////////////////////////////////////////////////////////////////
    342359    // The set() function registers a transaction (read or write)
     
    355372    // - data_be : the mask of the data to write (in case of write)
    356373    // - ll_key  : the ll key (if any) returned by the llsc_global_table
     374    // - config  : transaction required by config FSM
    357375    /////////////////////////////////////////////////////////////////////
    358376    void set(const size_t index,
     
    367385            const std::vector<be_t> &data_be,
    368386            const std::vector<data_t> &data,
    369             const data_t ll_key = 0)
    370     {
    371         assert( (index < size_tab)
    372                 && "The selected entry is out of range in set() Transaction Tab");
    373         assert(data_be.size()==tab[index].wdata_be.size()
    374                 && "Bad data_be argument in set() TransactionTab");
    375         assert(data.size()==tab[index].wdata.size()
    376                 && "Bad data argument in set() TransactionTab");
     387            const data_t ll_key = 0,
     388            const bool config = false)
     389    {
     390        assert( (index < size_tab) and
     391        "MEMC ERROR: The selected entry is out of range in TRT set()");
     392
     393        assert( (data_be.size()==tab[index].wdata_be.size()) and
     394        "MEMC ERROR: Bad data_be argument in TRT set()");
     395
     396        assert( (data.size()==tab[index].wdata.size()) and
     397        "MEMC ERROR: Bad data argument in TRT set()");
    377398
    378399        tab[index].valid                = true;
     
    386407        tab[index].word_index       = word_index;
    387408        tab[index].ll_key           = ll_key;
     409        tab[index].config           = config;
    388410        for(size_t i=0; i<tab[index].wdata.size(); i++)
    389411        {
     
    398420    // The BE field in TRT is taken into account.
    399421    // Arguments :
    400     // - index : the index of the transaction in the transaction tab
    401     // - word_index : the index of the data in the line
    402     // - data : a 64 bits value
    403     // - error : invalid data
     422    // - index : index of the entry in TRT
     423    // - word  : index of the 32 bits word in the line
     424    // - data  : 64 bits value (first data right)
    404425    /////////////////////////////////////////////////////////////////////
    405426    void write_rsp(const size_t      index,
    406427                   const size_t      word,
    407                    const wide_data_t data,
    408                    const bool        rerror)
     428                   const wide_data_t data)
    409429    {
    410430        data_t  value;
    411431        data_t  mask;
    412432
    413         if ( index >= size_tab )
    414         {
    415             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    416                       <<  " TRT entry  out of range in write_rsp()" << std::endl;
    417             exit(0);
    418         }
    419         if ( word > tab[index].wdata_be.size() )
    420         {
    421             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    422                       <<  " Bad word_index in write_rsp() in TRT" << std::endl;
    423             exit(0);
    424         }
    425         if ( not tab[index].valid )
    426         {
    427             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    428                       <<  " TRT Entry invalid in write_rsp()" << std::endl;
    429             exit(0);
    430         }
    431         if ( not tab[index].xram_read )
    432         {
    433             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    434                       <<  " TRT entry is not an XRAM GET in write_rsp()" << std::endl;
    435             exit(0);
    436         }
     433        assert( (index < size_tab) and
     434        "MEMC ERROR: The selected entry is out of range in TRT write_rsp()");
     435
     436        assert( (word < tab[index].wdata_be.size()) and
     437        "MEMC ERROR: Bad word index in TRT write_rsp()");
     438
     439        assert( (tab[index].valid) and
     440        "MEMC ERROR: TRT entry not valid in TRT write_rsp()");
     441
     442        assert( (tab[index].xram_read ) and
     443        "MEMC ERROR: TRT entry is not a GET in TRT write_rsp()");
    437444
    438445        // first 32 bits word
     
    445452        mask  = be_to_mask(tab[index].wdata_be[word+1]);
    446453        tab[index].wdata[word+1] = (tab[index].wdata[word+1] & mask) | (value & ~mask);
    447 
    448         // error update
    449         tab[index].rerror |= rerror;
    450     }
    451 
     454    }
    452455    /////////////////////////////////////////////////////////////////////
    453456    // The erase() function erases an entry in the transaction tab.
     
    457460    void erase(const size_t index)
    458461    {
    459         assert( (index < size_tab)
    460                 && "The selected entry is out of range in erase() Transaction Tab");
     462        assert( (index < size_tab) and
     463        "MEMC ERROR: The selected entry is out of range in TRT erase()");
     464
    461465        tab[index].valid        = false;
    462466        tab[index].rerror   = false;
     467    }
     468    /////////////////////////////////////////////////////////////////////
     469    // The is_config() function returns the config flag value.
     470    // Arguments :
     471    // - index : the index of the entry in the transaction tab
     472    /////////////////////////////////////////////////////////////////////
     473    bool is_config(const size_t index)
     474    {
     475        assert( (index < size_tab) and
     476        "MEMC ERROR: The selected entry is out of range in TRT is_config()");
     477
     478        return tab[index].config;
    463479    }
    464480}; // end class TransactionTab
  • branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r477 r495  
    4545#define DEBUG_MEMC_WRITE     1 // detailed trace of WRITE FSM
    4646#define DEBUG_MEMC_CAS       1 // detailed trace of CAS FSM
    47 #define DEBUG_MEMC_IXR_CMD   1 // detailed trace of IXR_RSP FSM
     47#define DEBUG_MEMC_IXR_CMD   1 // detailed trace of IXR_CMD FSM
    4848#define DEBUG_MEMC_IXR_RSP   1 // detailed trace of IXR_RSP FSM
    4949#define DEBUG_MEMC_XRAM_RSP  1 // detailed trace of XRAM_RSP FSM
     
    129129  "MULTI_ACK_UPT_CLEAR",
    130130  "MULTI_ACK_WRITE_RSP",
    131   "MULTI_ACK_CONFIG_ACK"
    132131};
    133132const char *config_fsm_str[] =
     
    135134  "CONFIG_IDLE",
    136135  "CONFIG_LOOP",
     136  "CONFIG_WAIT"
    137137  "CONFIG_RSP",
    138138  "CONFIG_DIR_REQ",
    139139  "CONFIG_DIR_ACCESS",
    140   "CONFIG_DIR_IVT_LOCK",
     140  "CONFIG_IVT_LOCK",
    141141  "CONFIG_BC_SEND",
    142   "CONFIG_BC_WAIT",
    143   "CONFIG_INV_SEND",
     142  "CONFIG_INVAL_SEND"
    144143  "CONFIG_HEAP_REQ",
    145144  "CONFIG_HEAP_SCAN",
    146145  "CONFIG_HEAP_LAST",
    147   "CONFIG_INV_WAIT"
     146  "CONFIG_TRT_LOCK",
     147  "CONFIG_TRT_SET",
     148  "CONFIG_PUT_REQ"
    148149};
    149150const char *read_fsm_str[] =
     
    172173  "WRITE_DIR_LOCK",
    173174  "WRITE_IVT_LOCK_HIT_WB",
    174   "WRITE_DIR_READ",
    175175  "WRITE_DIR_HIT",
    176176  "WRITE_UPT_LOCK",
     
    185185  "WRITE_MISS_TRT_SET",
    186186  "WRITE_MISS_XRAM_REQ",
     187  "WRITE_BC_DIR_READ",
    187188  "WRITE_BC_TRT_LOCK",
    188189  "WRITE_BC_IVT_LOCK",
     
    207208  "XRAM_RSP_DIR_UPDT",
    208209  "XRAM_RSP_DIR_RSP",
    209   "XRAM_RSP_INVAL_LOCK",
     210  "XRAM_RSP_IVT_LOCK",
    210211  "XRAM_RSP_INVAL_WAIT",
    211212  "XRAM_RSP_INVAL",
     
    224225  "IXR_CMD_XRAM_IDLE",
    225226  "IXR_CMD_CLEANUP_IDLE",
    226   "IXR_CMD_READ",
    227   "IXR_CMD_WRITE",
    228   "IXR_CMD_CAS",
    229   "IXR_CMD_XRAM",
    230   "IXR_CMD_CLEANUP_DATA"
     227  "IXR_CMD_CONFIG_IDLE",
     228  "IXR_CMD_READ_TRT",
     229  "IXR_CMD_WRITE_TRT",
     230  "IXR_CMD_CAS_TRT",
     231  "IXR_CMD_XRAM_TRT",
     232  "IXR_CMD_CLEANUP_TRT",
     233  "IXR_CMD_CONFIG_TRT",
     234  "IXR_CMD_READ_SEND",
     235  "IXR_CMD_WRITE_SEND",
     236  "IXR_CMD_CAS_SEND",
     237  "IXR_CMD_XRAM_SEND",
     238  "IXR_CMD_CLEANUP_DATA_SEND",
     239  "IXR_CMD_CONFIG_SEND"
    231240};
    232241const char *cas_fsm_str[] =
     
    276285  "CLEANUP_IXR_REQ",
    277286  "CLEANUP_WAIT",
    278   "CLEANUP_CONFIG_ACK",
    279287  "CLEANUP_SEND_CLACK"
    280288};
     
    297305  "ALLOC_TRT_IXR_RSP",
    298306  "ALLOC_TRT_CLEANUP"
     307  "ALLOC_TRT_IXR_CMD",
     308  "ALLOC_TRT_CONFIG"
    299309};
    300310const char *alloc_upt_fsm_str[] =
     
    357367  : soclib::caba::BaseModule(name),
    358368
    359     m_monitor_ok(false),
    360369    p_clk( "p_clk" ),
    361370    p_resetn( "p_resetn" ),
     
    437446    m_write_to_cc_send_inst_fifo("m_write_to_cc_send_inst_fifo",8),
    438447    m_write_to_cc_send_srcid_fifo("m_write_to_cc_send_srcid_fifo",8),
    439 #if L1_MULTI_CACHE
    440     m_write_to_cc_send_cache_id_fifo("m_write_to_cc_send_cache_id_fifo",8),
    441 #endif
    442448
    443449    r_multi_ack_fsm("r_multi_ack_fsm"),
     
    449455    m_cas_to_cc_send_inst_fifo("m_cas_to_cc_send_inst_fifo",8),
    450456    m_cas_to_cc_send_srcid_fifo("m_cas_to_cc_send_srcid_fifo",8),
    451 #if L1_MULTI_CACHE
    452     m_cas_to_cc_send_cache_id_fifo("m_cas_to_cc_send_cache_id_fifo",8),
    453 #endif
    454457
    455458    r_ixr_rsp_fsm("r_ixr_rsp_fsm"),
     
    458461    m_xram_rsp_to_cc_send_inst_fifo("m_xram_rsp_to_cc_send_inst_fifo",8),
    459462    m_xram_rsp_to_cc_send_srcid_fifo("m_xram_rsp_to_cc_send_srcid_fifo",8),
    460 #if L1_MULTI_CACHE
    461     m_xram_rsp_to_cc_send_cache_id_fifo("m_xram_rsp_to_cc_send_cache_id_fifo",8),
    462 #endif
    463463
    464464    r_ixr_cmd_fsm("r_ixr_cmd_fsm"),
     
    528528    r_xram_rsp_victim_data     = new sc_signal<data_t>[nwords];
    529529    r_xram_rsp_to_tgt_rsp_data = new sc_signal<data_t>[nwords];
    530     r_xram_rsp_to_ixr_cmd_data = new sc_signal<data_t>[nwords];
     530    //r_xram_rsp_to_ixr_cmd_data = new sc_signal<data_t>[nwords];
    531531
    532532    // Allocation for READ FSM
     
    539539    r_write_to_cc_send_data    = new sc_signal<data_t>[nwords];
    540540    r_write_to_cc_send_be      = new sc_signal<be_t>[nwords];
    541     r_write_to_ixr_cmd_data    = new sc_signal<data_t>[nwords];
     541    //r_write_to_ixr_cmd_data    = new sc_signal<data_t>[nwords];
    542542
    543543    // Allocation for CAS FSM
    544     r_cas_to_ixr_cmd_data      = new sc_signal<data_t>[nwords];
     544    //r_cas_to_ixr_cmd_data      = new sc_signal<data_t>[nwords];
    545545    r_cas_data                 = new sc_signal<data_t>[nwords];
    546546    r_cas_rdata                = new sc_signal<data_t>[2];
     547
     548    // Allocation for IXR_CMD FSM
     549    r_ixr_cmd_wdata            = new sc_signal<data_t>[nwords];
    547550
    548551    // Allocation for ODCCP
     
    553556
    554557    // Allocation for debug
    555     m_debug_previous_data      = new sc_signal<data_t>[nwords];
    556     m_debug_data               = new sc_signal<data_t>[nwords];
     558    m_debug_previous_data      = new data_t[nwords];
     559    m_debug_data               = new data_t[nwords];
    557560
    558561    SC_METHOD(transition);
     
    564567    sensitive << p_clk.neg();
    565568} // end constructor
    566 
    567 ///////////////////////////////////////////////////////////////////////
    568 tmpl(void) ::start_monitor(addr_t addr, addr_t length)
    569 ///////////////////////////////////////////////////////////////////////
    570 {
    571   m_monitor_ok        = true;
    572   m_monitor_base      = addr;
    573   m_monitor_length    = length;
    574 }
    575 
    576 ///////////////////////////////////////////////////////////////////////
    577 tmpl(void) ::stop_monitor()
    578 ///////////////////////////////////////////////////////////////////////
    579 {
    580   m_monitor_ok        = false;
    581 }
    582 
    583 ////////////////////////////////////////////////
    584 tmpl(void) ::check_monitor( addr_t      addr,
    585                             data_t      data,
    586                             bool        read )
    587 ////////////////////////////////////////////////
    588 {
    589   if((addr >= m_monitor_base) and
    590       (addr < m_monitor_base + m_monitor_length))
    591   {
    592     if ( read ) std::cout << " Monitor MEMC Read ";
    593     else        std::cout << " Monitor MEMC Write";
    594     std::cout << " / Address = " << std::hex << addr
    595               << " / Data = " << data
    596               << " at cycle " << std::dec << m_cpt_cycles << std::endl;
    597   }
    598 }
    599569
    600570/////////////////////////////////////////////////////
     
    609579
    610580    if ( entry.valid )
    611     {
    612         m_cache_data.read_line( way, set, m_debug_data );
    613 
    614         for ( size_t i = 0 ; i<m_words ; i++ )
    615         {
    616             if ( m_debug_previous_valid and
    617                  (m_debug_data[i].read() != m_debug_previous_data[i].read()) )
    618                  data_change = true;
    619             m_debug_previous_data[i] = m_debug_data[i].read();
    620         }
    621     }
    622    
     581     {
     582        for ( size_t word = 0 ; word<m_words ; word++ )
     583        {
     584            m_debug_data[word] = m_cache_data.read(way, set, word);
     585            if ( m_debug_previous_valid and
     586                 (m_debug_data[word] != m_debug_previous_data[word]) )
     587            {
     588                data_change = true;
     589            }
     590         }
     591     }
     592   
     593    // print values if any change
    623594    if ( (entry.valid != m_debug_previous_valid) or
    624595         (entry.valid and (entry.count != m_debug_previous_count)) or
    625596         (entry.valid and (entry.dirty != m_debug_previous_dirty)) or data_change )
    626597    {
    627         std::cout << "Monitor MEMC " << name()
    628                   << " at cycle " << std::dec << m_cpt_cycles
    629                   << " for address " << std::hex << addr
    630                   << " / HIT = " << std::dec << entry.valid
    631                   << " / WAY = " << way
    632                   << " / COUNT = " << entry.count
    633                   << " / DIRTY = " << entry.dirty
    634                   << " / DATA_CHANGE = " << entry.count
    635                   << std::endl;
     598         std::cout << "Monitor MEMC " << name()
     599                   << " at cycle " << std::dec << m_cpt_cycles
     600                   << " for address " << std::hex << addr
     601                   << " / VAL = " << std::dec << entry.valid
     602                   << " / WAY = " << way
     603                   << " / COUNT = " << entry.count
     604                   << " / DIRTY = " << entry.dirty
     605                   << " / DATA_CHANGE = " << data_change
     606                   << std::endl;
     607         std::cout << std::hex << "     /0:" << m_debug_data[0]
     608                   << "/1:" << m_debug_data[1]
     609                   << "/2:" << m_debug_data[2]
     610                   << "/3:" << m_debug_data[3]
     611                   << "/4:" << m_debug_data[4]
     612                   << "/5:" << m_debug_data[5]
     613                   << "/6:" << m_debug_data[6]
     614                   << "/7:" << m_debug_data[7]
     615                   << "/8:" << m_debug_data[8]
     616                   << "/9:" << m_debug_data[9]
     617                   << "/A:" << m_debug_data[10]
     618                   << "/B:" << m_debug_data[11]
     619                   << "/C:" << m_debug_data[12]
     620                   << "/D:" << m_debug_data[13]
     621                   << "/E:" << m_debug_data[14]
     622                   << "/F:" << m_debug_data[15]
     623                   << std::endl;
    636624    }
    637625    m_debug_previous_count = entry.count;
    638626    m_debug_previous_valid = entry.valid;
    639627    m_debug_previous_dirty = entry.dirty;
     628    for( size_t word=0 ; word<m_words ; word++ )
     629        m_debug_previous_data[word] = m_debug_data[word];
    640630}
    641631
     
    836826  delete [] r_xram_rsp_victim_data;
    837827  delete [] r_xram_rsp_to_tgt_rsp_data;
    838   delete [] r_xram_rsp_to_ixr_cmd_data;
    839828
    840829  delete [] r_read_data;
     
    919908    m_config_to_cc_send_inst_fifo.init();
    920909    m_config_to_cc_send_srcid_fifo.init();
    921 #if L1_MULTI_CACHE
    922     m_config_to_cc_send_cache_id_fifo.init();
    923 #endif
    924910
    925911    r_tgt_cmd_to_tgt_rsp_req = false;
     
    938924    m_write_to_cc_send_inst_fifo.init();
    939925    m_write_to_cc_send_srcid_fifo.init();
    940 #if L1_MULTI_CACHE
    941     m_write_to_cc_send_cache_id_fifo.init();
    942 #endif
    943926
    944927    r_cleanup_to_tgt_rsp_req      = false;
     
    954937    r_cas_lfsr                    = -1   ;
    955938    r_cas_to_ixr_cmd_req          = false;
    956     r_cas_to_cc_send_multi_req   = false;
    957     r_cas_to_cc_send_brdcast_req = false;
     939    r_cas_to_cc_send_multi_req    = false;
     940    r_cas_to_cc_send_brdcast_req  = false;
    958941
    959942    m_cas_to_cc_send_inst_fifo.init();
     
    969952
    970953    r_xram_rsp_to_tgt_rsp_req          = false;
    971     r_xram_rsp_to_cc_send_multi_req   = false;
    972     r_xram_rsp_to_cc_send_brdcast_req = false;
     954    r_xram_rsp_to_cc_send_multi_req    = false;
     955    r_xram_rsp_to_cc_send_brdcast_req  = false;
    973956    r_xram_rsp_to_ixr_cmd_req          = false;
    974957    r_xram_rsp_trt_index               = 0;
     
    976959    m_xram_rsp_to_cc_send_inst_fifo.init();
    977960    m_xram_rsp_to_cc_send_srcid_fifo.init();
    978 #if L1_MULTI_CACHE
    979     m_xram_rsp_to_cc_send_cache_id_fifo.init();
    980 #endif
    981 
    982     r_ixr_cmd_cpt          = 0;
     961
    983962    r_alloc_dir_reset_cpt  = 0;
    984963    r_alloc_heap_reset_cpt = 0;
     
    996975    r_cleanup_to_ixr_cmd_req   = false;
    997976    r_cleanup_to_ixr_cmd_srcid = 0;
    998     r_cleanup_to_ixr_cmd_trdid = 0;
    999977    r_cleanup_to_ixr_cmd_pktid = 0;
    1000978    r_cleanup_to_ixr_cmd_nline = 0;
     
    10951073  size_t  write_to_cc_send_fifo_srcid = 0;
    10961074
    1097 #if L1_MULTI_CACHE
    1098   size_t  write_to_cc_send_fifo_cache_id = 0;
    1099 #endif
    1100 
    11011075  bool    xram_rsp_to_cc_send_fifo_put   = false;
    11021076  bool    xram_rsp_to_cc_send_fifo_get   = false;
     
    11041078  size_t  xram_rsp_to_cc_send_fifo_srcid = 0;
    11051079
    1106 #if L1_MULTI_CACHE
    1107   size_t  xram_rsp_to_cc_send_fifo_cache_id = 0;
    1108 #endif
    1109 
    11101080  bool    config_to_cc_send_fifo_put   = false;
    11111081  bool    config_to_cc_send_fifo_get   = false;
     
    11171087  bool    cas_to_cc_send_fifo_inst  = false;
    11181088  size_t  cas_to_cc_send_fifo_srcid = 0;
    1119 
    1120 #if L1_MULTI_CACHE
    1121   size_t  cas_to_cc_send_fifo_cache_id = 0;
    1122 #endif
    11231089
    11241090  m_debug = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
     
    12751241    case TGT_CMD_ERROR:  // response error must be sent
    12761242
    1277     // wait if pending TGT_CMD request to TGT_RSP FSM
     1243    // wait if pending request
    12781244    if(r_tgt_cmd_to_tgt_rsp_req.read()) break;
    12791245
     
    13091275        size_t   error; 
    13101276        uint32_t rdata = 0;         // default value
     1277        uint32_t wdata = p_vci_tgt.wdata.read();     
    13111278
    13121279        if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_READ)         // get lock
     
    13171284            error            = 0;
    13181285            r_config_lock    = true;
     1286            if ( rdata == 0 )
     1287            {
     1288                r_tgt_cmd_srcid = p_vci_tgt.srcid.read();
     1289                r_tgt_cmd_trdid = p_vci_tgt.trdid.read();
     1290                r_tgt_cmd_pktid = p_vci_tgt.pktid.read();
     1291            }
     1292
    13191293        }
    13201294        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)  // release lock
    1321                    and (cell == MEMC_LOCK) )
     1295                   and (cell == MEMC_LOCK)
     1296                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
    13221297        {
    13231298            need_rsp         = true;
     
    13261301        }
    13271302        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_lo
    1328                    and (cell == MEMC_ADDR_LO) )
    1329         {
     1303                   and (cell == MEMC_ADDR_LO)
     1304                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
     1305        {
     1306            assert( ((wdata % (m_words*vci_param_int::B)) == 0) and
     1307            "VCI_MEM_CACHE CONFIG ERROR: The buffer must be aligned on a cache line");
     1308
    13301309            need_rsp         = true;
    13311310            error            = 0;
     
    13341313        }
    13351314        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_hi
    1336                    and (cell == MEMC_ADDR_HI) )
     1315                   and (cell == MEMC_ADDR_HI)
     1316                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
    13371317        {
    13381318            need_rsp         = true;
     
    13421322        }
    13431323        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set buf_lines
    1344                    and (cell == MEMC_BUF_LENGTH) )
     1324                   and (cell == MEMC_BUF_LENGTH)
     1325                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
    13451326        {
    13461327            need_rsp         = true;
    13471328            error            = 0;
    13481329            size_t lines = (size_t)(p_vci_tgt.wdata.read()/(m_words<<2));
    1349             if ( r_config_address.read()/(m_words*vci_param_int::B) ) lines++;
    1350             r_config_nlines  = lines;
     1330            if ( r_config_address.read()%(m_words*4) ) lines++;
     1331            r_config_cmd_lines  = lines;
     1332            r_config_rsp_lines  = lines;
    13511333        }
    13521334        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set cmd type
    1353                    and (cell == MEMC_CMD_TYPE) )
     1335                   and (cell == MEMC_CMD_TYPE)
     1336                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
    13541337        {
    13551338            need_rsp         = false;
     
    13861369          << " address = " << std::hex << p_vci_tgt.address.read()
    13871370          << " / wdata = " << p_vci_tgt.wdata.read()
     1371          << " / need_rsp = " << need_rsp
    13881372          << " / error = " << error << std::endl;
    13891373#endif
     
    14891473  //    MULTI_ACK FSM
    14901474  /////////////////////////////////////////////////////////////////////////
    1491   // This FSM controls the response to the multicast update or multicast
    1492   // inval coherence requests sent by the memory cache to the L1 caches and
    1493   // update the UPT.
     1475  // This FSM controls the response to the multicast update requests sent
     1476  // by the memory cache to the L1 caches and update the UPT.
    14941477  //
    14951478  // - The FSM decrements the proper entry in UPT,
     
    14971480  // - If required, it sends a request to the TGT_RSP FSM to complete
    14981481  //   a pending  write transaction.
    1499   // - If required, it sends an acknowledge to the CONFIG FSM to signal
    1500   //   completion of a line inval.
    15011482  //
    15021483  // All those multi-ack packets are one flit packet.
    1503   // The index in the UPT is defined in the UPDTID field.
     1484  // The index in the UPT is defined in the TRDID field.
    15041485  ////////////////////////////////////////////////////////////////////////
    15051486
     
    16181599        r_multi_ack_nline = m_upt.nline(r_multi_ack_upt_index.read());
    16191600        bool need_rsp     = m_upt.need_rsp(r_multi_ack_upt_index.read());
    1620         bool need_ack     = m_upt.need_ack(r_multi_ack_upt_index.read());
    16211601
    16221602        // clear the UPT entry
     
    16241604
    16251605        if      ( need_rsp ) r_multi_ack_fsm = MULTI_ACK_WRITE_RSP;
    1626         else if ( need_ack ) r_multi_ack_fsm = MULTI_ACK_CONFIG_ACK;
    16271606        else                 r_multi_ack_fsm = MULTI_ACK_IDLE;
    16281607
     
    16551634        break;
    16561635    }
    1657     //////////////////////////
    1658     case MULTI_ACK_CONFIG_ACK:    // Signals multi-inval completion to CONFIG FSM
    1659                                   // Wait if pending request
    1660     {
    1661         if ( r_multi_ack_to_config_ack.read() ) break;
    1662 
    1663         r_multi_ack_to_config_ack   = true;
    1664         r_multi_ack_fsm              = MULTI_ACK_IDLE;
    1665 
    1666 #if DEBUG_MEMC_MULTI_ACK
    1667 if(m_debug)
    1668 std::cout << "  <MEMC " << name() << " MULTI_ACK_CONFIG_ACK>"
    1669           << " Signals inval completion to CONFIG FSM" << std::endl;
    1670 #endif
    1671         break;
    1672     }
    16731636  } // end switch r_multi_ack_fsm
    16741637
     
    16781641  // The CONFIG FSM handles the VCI configuration requests (INVAL & SYNC).
    16791642  // The target buffer can have any size, and there is one single command for
    1680   // all cache lines covered by the target buffer.
    1681   // An INVAL or SYNC configuration request is defined by the followinf registers:
    1682   // - bool      r_config_cmd        : INVAL / SYNC / NOP)
     1643  // all cache lines covered by the target buffer.
     1644  //
     1645  // An INVAL or SYNC configuration operation is defined by the following registers:
     1646  // - bool      r_config_cmd        : INVAL / SYNC / NOP
     1647
    16831648  // - uint64_t  r_config_address    : buffer base address
    1684   // - uint32_t  r_config_nlines     : number of lines covering buffer
     1649  // - uint32_t  r_config_cmd_lines  : number of lines to be handled
     1650  // - uint32_t  r_config_rsp_lines  : number of lines not completed
     1651 
    16851652  //
    16861653  // For both INVAL and SYNC commands, the CONFIG FSM contains the loop handling
    1687   // all cache lines covered by the target buffer.
    16881654  //
     1655  // all cache lines covered by the buffer. The various lines of a given buffer
     1656  // can be pipelined: the CONFIG FSM does not wait the response for line (n) to send
     1657  // the command for line (n+1). It decrements the r_config_cmd_lines counter until
     1658  // the last request has been registered in TRT (for a SYNC), or in IVT (for an INVAL).
     1659  //
    16891660  // - INVAL request:
    1690   //   For each line, it access to the DIR array.
     1661  //   For each line, it access to the DIR.
    16911662  //   In case of miss, it does nothing, and a response is requested to TGT_RSP FSM.
    16921663  //   In case of hit, with no copies in L1 caches, the line is invalidated and
    16931664  //   a response is requested to TGT_RSP FSM.
    16941665  //   If there is copies, a multi-inval, or a broadcast-inval coherence transaction
    1695   //   is launched and registered in UPT. The multi-inval transaction is signaled
    1696   //   by the r_multi_ack_to config_ack or r_cleanup_to_config_ack flip-flops.
    1697   //   The config inval response is sent only when the last line has been invalidated.
    16981666  //
     1667  //   is launched and registered in UPT. The multi-inval transaction completion
     1668  //   is signaled by the CLEANUP FSM by decrementing the r_config_rsp_lines counter.
     1669  //   The CONFIG INVAL response is sent only when the last line has been invalidated.
     1670  //   TODO : The target buffer address must be aligned on a cache line boundary.
     1671  //   This constraint can be released, but it requires to make 2 PUT transactions
     1672  //   for the first and the last line...
     1673  //
    16991674  // - SYNC request:
    1700   //
    1701   //  ...  Not implemented yet ...
     1675  //   For each line, it access to the DIR.
     1676  //   In case of miss, it does nothing, and a response is requested to TGT_RSP FSM.
     1677  //   In case of hit, a PUT transaction is registered in TRT and a request is sent
     1678  //   to IXR_CMD FSM. The IXR_RSP FSM decrements the r_config_rsp_lines counter
     1679  //   when a PUT response is received.
     1680  //   The CONFIG SYNC response is sent only when the last PUT response is received.
    17021681  //
    17031682  // From the software point of view, a configuration request is a sequence
    1704   // of 6 atomic accesses in an uncached segment:
     1683  // of 6 atomic accesses in an uncached segment. A dedicated lock is used
     1684  // to handle only one configuration command at a given time:
    17051685  // - Read  MEMC_LOCK       : Get the lock
    17061686  // - Write MEMC_ADDR_LO    : Set the buffer address LSB
     
    17241704std::cout << "  <MEMC " << name() << " CONFIG_IDLE> Config Request received"
    17251705          << " address = " << std::hex << r_config_address.read()
    1726           << " / nlines = " << std::dec << r_config_nlines.read()
     1706          << " / nlines = " << std::dec << r_config_cmd_lines.read()
    17271707          << " / type = " << r_config_cmd.read() << std::endl;
    17281708#endif
     
    17311711      }
    17321712      /////////////////
    1733       case CONFIG_LOOP:   // test last line
    1734       {
    1735           if ( r_config_nlines.read() == 0 )
     1713      case CONFIG_LOOP:   // test last line to be handled
     1714      {
     1715          if ( r_config_cmd_lines.read() == 0 )
    17361716          {
    17371717              r_config_cmd = MEMC_CMD_NOP;
    1738               r_config_fsm = CONFIG_RSP;
     1718              r_config_fsm = CONFIG_WAIT;
    17391719          }
    17401720          else
     
    17471727std::cout << "  <MEMC " << name() << " CONFIG_LOOP>"
    17481728          << " address = " << std::hex << r_config_address.read()   
    1749           << " / nlines = " << std::dec << r_config_nlines.read()
     1729          << " / nlines = " << std::dec << r_config_cmd_lines.read()
    17501730          << " / command = " << r_config_cmd.read() << std::endl;
    17511731#endif
    17521732          break;
    17531733      }
     1734      /////////////////
     1735      case CONFIG_WAIT:   // wait completion (last response)
     1736      {
     1737          if ( r_config_rsp_lines.read() == 0 )  // last response received
     1738          {
     1739              r_config_fsm = CONFIG_RSP;
     1740          }
     1741
     1742#if DEBUG_MEMC_CONFIG
     1743if(m_debug)
     1744std::cout << "  <MEMC " << name() << " CONFIG_WAIT>"
     1745          << " / lines to do = " << std::dec << r_config_rsp_lines.read() << std::endl;
     1746#endif
     1747          break;
     1748      }
     1749      ////////////////
     1750      case CONFIG_RSP:  // request TGT_RSP FSM to return response
     1751      {
     1752          if ( not r_config_to_tgt_rsp_req.read() )
     1753          {
     1754              r_config_to_tgt_rsp_srcid  = r_config_srcid.read();
     1755              r_config_to_tgt_rsp_trdid  = r_config_trdid.read();
     1756              r_config_to_tgt_rsp_pktid  = r_config_pktid.read();
     1757              r_config_to_tgt_rsp_error  = false;
     1758              r_config_to_tgt_rsp_req    = true;
     1759              r_config_fsm               = CONFIG_IDLE;
     1760
     1761#if DEBUG_MEMC_CONFIG
     1762if(m_debug)
     1763std::cout << "  <MEMC " << name() << " CONFIG_RSP> Request TGT_RSP FSM to return response:"
     1764          << " error = " << r_config_to_tgt_rsp_error.read()
     1765          << " / rsrcid = " << std::hex << r_config_srcid.read()
     1766          << " / rtrdid = " << std::hex << r_config_trdid.read()
     1767          << " / rpktid = " << std::hex << r_config_pktid.read() << std::endl;
     1768#endif
     1769          }
     1770          break;
     1771
     1772      }
     1773
    17541774      ////////////////////
    17551775      case CONFIG_DIR_REQ:  // Request directory lock
     
    17701790      case CONFIG_DIR_ACCESS:   // Access directory and decode config command
    17711791      {
     1792          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and
     1793          "MEMC ERROR in CONFIG_DIR_ACCESS state: bad DIR allocation");
     1794
    17721795          size_t way = 0;
    17731796          DirectoryEntry entry = m_cache_directory.read(r_config_address.read(), way);
     
    17811804              r_config_dir_is_cnt     = entry.is_cnt;
    17821805              r_config_dir_count      = entry.count;
    1783               r_config_dir_next_ptr   = entry.ptr;
    1784 
    1785               r_config_fsm    = CONFIG_DIR_IVT_LOCK;
     1806              r_config_dir_lock       = entry.lock;
     1807              r_config_dir_ptr        = entry.ptr;
     1808
     1809              r_config_fsm    = CONFIG_IVT_LOCK;
    17861810          }
    17871811          else if ( entry.valid and                       // hit & sync command
     
    17891813                    (r_config_cmd.read() == MEMC_CMD_SYNC) )
    17901814          {
    1791               std::cout << "VCI_MEM_CACHE ERROR: "
    1792                         << "SYNC config request not implemented yet" << std::endl;
    1793               exit(0);
     1815              r_config_fsm = CONFIG_TRT_LOCK;
    17941816          }
    17951817          else                                            // return to LOOP
    17961818          {
    1797               r_config_nlines  = r_config_nlines.read() - 1;
    1798               r_config_address = r_config_address.read() + (m_words<<2);
    1799               r_config_fsm     = CONFIG_LOOP;
     1819              r_config_cmd_lines = r_config_cmd_lines.read() - 1;
     1820              r_config_rsp_lines = r_config_rsp_lines.read() - 1;
     1821              r_config_cmd_lines = r_config_cmd_lines.read() - 1;
     1822              r_config_address   = r_config_address.read() + (m_words<<2);
     1823              r_config_fsm       = CONFIG_LOOP;
    18001824          }
    18011825
     
    18111835          break;
    18121836      }
    1813       /////////////////////////
    1814       case CONFIG_DIR_IVT_LOCK:  // enter this state in case of INVAL command
    1815                                  // Try to get both DIR & IVT locks, and return
    1816                                  // to LOOP state if IVT full.
    1817                                  // Register inval in IVT, and invalidate the
    1818                                  // directory if IVT not full.
    1819       {
     1837      /////////////////////
     1838      case CONFIG_TRT_LOCK:      // enter this state in case of SYNC command
     1839                                 // to a dirty cache line
     1840                                 // keep DIR lock, and try to get TRT lock
     1841                                 // return to LOOP state if TRT full
     1842                                 // reset dirty bit in DIR and register a PUT
     1843                                 // trabsaction in TRT if not full.
     1844      {
     1845          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and
     1846          "MEMC ERROR in CONFIG_TRT_LOCK state: bad DIR allocation");
     1847
     1848          if ( r_alloc_trt_fsm.read() == ALLOC_TRT_CONFIG )
     1849          {
     1850              size_t index = 0;
     1851              bool   wok   = not m_trt.full(index);
     1852
     1853              if ( not wok )
     1854              {
     1855                  r_config_fsm = CONFIG_LOOP;
     1856              }
     1857              else
     1858              {
     1859                  size_t          way = r_config_dir_way.read();
     1860                  size_t          set = m_y[r_config_address.read()];
     1861
     1862                  // reset dirty bit in DIR
     1863                  DirectoryEntry  entry;
     1864                  entry.valid       = true;
     1865                  entry.dirty       = false;
     1866                  entry.tag         = m_z[r_config_address.read()];
     1867                  entry.is_cnt      = r_config_dir_is_cnt.read();
     1868                  entry.lock        = r_config_dir_lock.read();
     1869                  entry.ptr         = r_config_dir_ptr.read();
     1870                  entry.count       = r_config_dir_count.read();
     1871                  entry.owner.inst  = r_config_dir_copy_inst.read();
     1872                  entry.owner.srcid = r_config_dir_copy_srcid.read();
     1873                  m_cache_directory.write( set,
     1874                                           way,
     1875                                           entry );
     1876
     1877                  r_config_trt_index = index;
     1878                  r_config_fsm       = CONFIG_TRT_SET;
     1879              }
     1880
     1881#if DEBUG_MEMC_CONFIG
     1882if(m_debug)
     1883std::cout << "  <MEMC " << name() << " CONFIG_TRT_LOCK> Access TRT: "
     1884          << " wok = " << std::dec << wok
     1885          << " index = " << index << std::endl;
     1886#endif
     1887          }
     1888          break;
     1889      }
     1890      ////////////////////
     1891      case CONFIG_TRT_SET:       // read data in cache
     1892                                 // and post a PUT request in TRT
     1893      {
     1894          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and
     1895          "MEMC ERROR in CONFIG_TRT_SET state: bad DIR allocation");
     1896
     1897          assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CONFIG) and
     1898          "MEMC ERROR in CONFIG_TRT_SET state: bad TRT allocation");
     1899
     1900          // read data into cache
     1901          size_t          way = r_config_dir_way.read();
     1902          size_t          set = m_y[r_config_address.read()];
     1903
     1904          sc_signal<data_t> config_data[16];
     1905          m_cache_data.read_line( way,
     1906                                  set,
     1907                                  config_data );
     1908           
     1909          // post a PUT request in TRT
     1910          std::vector<data_t> data_vector;
     1911          data_vector.clear();
     1912          for(size_t i=0; i<m_words; i++) data_vector.push_back(config_data[i].read());
     1913          m_trt.set( r_config_trt_index.read(),
     1914                     false,                               // PUT
     1915                     m_nline[r_config_address.read()],    // nline
     1916                     0,                                   // srcid:       unused
     1917                     0,                                   // trdid:       unused
     1918                     0,                                   // pktid:       unused
     1919                     false,                               // not proc_read
     1920                     0,                                   // read_length: unused
     1921                     0,                                   // word_index:  unused
     1922                     std::vector<be_t>(m_words,0xF),                         
     1923                     data_vector);
     1924
     1925#if DEBUG_MEMC_CONFIG
     1926if(m_debug)
     1927          m_trt.print(0);
     1928std::cout << "  <MEMC " << name() << " CONFIG_TRT_SET> PUT request in TRT:"
     1929          << " address = " << std::hex << r_config_address.read()
     1930          << " index = " << std::dec << r_config_trt_index.read() << std::endl;
     1931#endif
     1932          break;
     1933      }
     1934      ////////////////////
     1935      case CONFIG_PUT_REQ:       // PUT request to IXR_CMD_FSM
     1936      {
     1937          if ( not r_config_to_ixr_cmd_req.read() )
     1938          {
     1939              r_config_to_ixr_cmd_req   = true;
     1940              r_config_to_ixr_cmd_index = r_config_trt_index.read();
     1941
     1942              // prepare next iteration
     1943              r_config_cmd_lines              = r_config_cmd_lines.read() - 1;
     1944              r_config_address                = r_config_address.read() + (m_words<<2);
     1945              r_config_fsm                    = CONFIG_LOOP;
     1946
     1947#if DEBUG_MEMC_CONFIG
     1948if(m_debug)
     1949std::cout << "  <MEMC " << name() << " CONFIG_PUT_REQ> PUT request to IXR_CMD_FSM"
     1950          << " / address = " << std::hex << r_config_address.read() << std::endl;
     1951#endif
     1952          }
     1953          break;
     1954      }
     1955      /////////////////////
     1956      case CONFIG_IVT_LOCK:  // enter this state in case of INVAL command
     1957                             // Keep DIR lock and Try to get IVT lock.
     1958                             // Return to LOOP state if IVT full.
     1959                             // Register inval in IVT, and invalidate the
     1960                             // directory if IVT not full.
     1961      {
     1962          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and
     1963          "MEMC ERROR in CONFIG_IVT_LOCK state: bad DIR allocation");
     1964
    18201965          if ( r_alloc_ivt_fsm.read() == ALLOC_IVT_CONFIG )
    18211966          {
     
    18261971              {
    18271972                  m_cache_directory.inval( way, set );
    1828                   r_config_nlines  = r_config_nlines.read() - 1;
    1829                   r_config_address = r_config_address.read() + (m_words<<2);
    1830                   r_config_fsm     = CONFIG_LOOP;
    1831 
    1832 #if DEBUG_MEMC_CONFIG
    1833 if(m_debug)
    1834 std::cout << "  <MEMC " << name() << " CONFIG_DIR_IVT_LOCK>"
     1973                  r_config_cmd_lines  = r_config_cmd_lines.read() - 1;
     1974                  r_config_rsp_lines  = r_config_rsp_lines.read() - 1;
     1975                  r_config_address    = r_config_address.read() + (m_words<<2);
     1976                  r_config_fsm        = CONFIG_LOOP;
     1977
     1978 #if DEBUG_MEMC_CONFIG
     1979if(m_debug)
     1980std::cout << "  <MEMC " << name() << " CONFIG_IVT_LOCK>"
    18351981          << " No copies in L1 : inval DIR entry"  << std::endl;
    18361982#endif
     
    18632009                      r_config_ivt_index = index;
    18642010                      if ( broadcast )  r_config_fsm = CONFIG_BC_SEND;
    1865                       else              r_config_fsm = CONFIG_INV_SEND;
     2011                      else              r_config_fsm = CONFIG_INVAL_SEND;
    18662012
    18672013#if DEBUG_MEMC_CONFIG
    18682014if(m_debug)
    1869 std::cout << "  <MEMC " << name() << " CONFIG_DIR_IVT_LOCK>"
     2015std::cout << "  <MEMC " << name() << " CONFIG_IVT_LOCK>"
    18702016          << " Inval DIR entry and register inval in IVT"
    18712017          << " : index = " << std::dec << index
     
    18792025#if DEBUG_MEMC_CONFIG
    18802026if(m_debug)
    1881 std::cout << "  <MEMC " << name() << " CONFIG_DIR_IVT_LOCK>"
     2027std::cout << "  <MEMC " << name() << " CONFIG_IVT_LOCK>"
    18822028          << " IVT full : release DIR & IVT locks and retry" << std::endl;
    18832029#endif
     
    18932039              not r_config_to_cc_send_brdcast_req.read() )
    18942040          {
     2041              // post bc inval request
    18952042              r_config_to_cc_send_multi_req   = false;
    18962043              r_config_to_cc_send_brdcast_req = true;
    18972044              r_config_to_cc_send_trdid       = r_config_ivt_index.read();
    18982045              r_config_to_cc_send_nline       = m_nline[(addr_t)(r_config_address.read())];
    1899               r_cleanup_to_config_ack         = false;
    1900               r_config_fsm                    = CONFIG_BC_WAIT;
     2046
     2047              // prepare next iteration
     2048              r_config_cmd_lines              = r_config_cmd_lines.read() - 1;
     2049              r_config_address                = r_config_address.read() + (m_words<<2);
     2050              r_config_fsm                    = CONFIG_LOOP;
    19012051
    19022052#if DEBUG_MEMC_CONFIG
     
    19092059          break;
    19102060      }
    1911       ////////////////////
    1912       case CONFIG_BC_WAIT:      // wait broadcast completion to return to LOOP
    1913       {
    1914           if ( r_cleanup_to_config_ack.read() )
    1915           {
    1916               r_config_fsm     = CONFIG_LOOP;
    1917               r_config_nlines  = r_config_nlines.read() - 1;
    1918               r_config_address = r_config_address.read() + (m_words<<2);
    1919           }
    1920 
    1921 #if DEBUG_MEMC_CONFIG
    1922 if(m_debug)
    1923 std::cout << "  <MEMC " << name() << " CONFIG_BC_WAIT> Waiting BC completion "
    1924           << " done = " << r_cleanup_to_config_ack.read()
    1925           << std::endl;
    1926 #endif
    1927           break;
    1928       }
    1929       /////////////////////
    1930       case CONFIG_INV_SEND:    // Post a multi inval request to CC_SEND FSM
     2061      ///////////////////////
     2062      case CONFIG_INVAL_SEND:    // Post a multi inval request to CC_SEND FSM
    19312063      {
    19322064          if( not r_config_to_cc_send_multi_req.read() and
     
    19372069              r_config_to_cc_send_trdid       = r_config_ivt_index.read();
    19382070              r_config_to_cc_send_nline       = m_nline[(addr_t)(r_config_address.read())];
    1939               r_multi_ack_to_config_ack       = false;
    1940 
     2071
     2072              // post data into FIFO
    19412073              config_to_cc_send_fifo_srcid    = r_config_dir_copy_srcid.read();
    19422074              config_to_cc_send_fifo_inst     = r_config_dir_copy_inst.read();
    19432075              config_to_cc_send_fifo_put      = true;
    19442076
    1945               if ( r_config_dir_count.read() == 1 )  r_config_fsm = CONFIG_INV_WAIT;
    1946               else                                   r_config_fsm = CONFIG_HEAP_REQ;
    1947 
     2077              if ( r_config_dir_count.read() == 1 )  // one copy
     2078              {
     2079                  // prepare next iteration
     2080                  r_config_cmd_lines          = r_config_cmd_lines.read() - 1;
     2081                  r_config_address            = r_config_address.read() + (m_words<<2);
     2082                  r_config_fsm                = CONFIG_LOOP;
     2083              }
     2084              else                                   // several copies
     2085              {
     2086                  r_config_fsm = CONFIG_HEAP_REQ;
     2087              }
     2088 
    19482089#if DEBUG_MEMC_CONFIG
    19492090if(m_debug)
    1950 std::cout << "  <MEMC " << name() << " CONFIG_INV_SEND>"
     2091std::cout << "  <MEMC " << name() << " CONFIG_INVAL_SEND>"
    19512092          << " Post multi inval request to CC_SEND FSM"
    19522093          << " / address = " << std::hex << r_config_address.read()
     
    19632104          {
    19642105              r_config_fsm       = CONFIG_HEAP_SCAN;
    1965               r_config_heap_next = r_config_dir_next_ptr.read();
     2106              r_config_heap_next = r_config_dir_ptr.read();
    19662107          }
    19672108
     
    20102151          if ( m_heap.is_full() )
    20112152          {
    2012               last_entry.next = r_config_dir_next_ptr.read();
     2153              last_entry.next = r_config_dir_ptr.read();
    20132154              m_heap.unset_full();
    20142155          }
     
    20182159          }
    20192160
    2020           m_heap.write_free_ptr( r_config_dir_next_ptr.read() );
     2161          m_heap.write_free_ptr( r_config_dir_ptr.read() );
    20212162          m_heap.write( r_config_heap_next.read(), last_entry );
    2022           r_config_fsm = CONFIG_INV_WAIT;
     2163
     2164          // prepare next iteration
     2165          r_config_cmd_lines          = r_config_cmd_lines.read() - 1;
     2166          r_config_address            = r_config_address.read() + (m_words<<2);
     2167          r_config_fsm                = CONFIG_LOOP;
    20232168
    20242169#if DEBUG_MEMC_CONFIG
     
    20282173#endif
    20292174          break;
    2030       }
    2031       /////////////////////
    2032       case CONFIG_INV_WAIT:      // wait inval completion to return to LOOP
    2033       {
    2034           if ( r_multi_ack_to_config_ack.read() )
    2035           {
    2036               r_config_fsm     = CONFIG_LOOP;
    2037               r_config_nlines  = r_config_nlines.read() - 1;
    2038               r_config_address = r_config_address.read() + (m_words<<2);
    2039           }
    2040 
    2041 #if DEBUG_MEMC_CONFIG
    2042 if(m_debug)
    2043 std::cout << "  <MEMC " << name() << " CONFIG_INV_WAIT> Waiting inval completion "
    2044           << " done = " << r_multi_ack_to_config_ack.read()
    2045           << std::endl;
    2046 #endif
    2047           break;
    2048       }
    2049 
    2050       ////////////////
    2051       case CONFIG_RSP:  // request TGT_RSP FSM to return response
    2052       {
    2053           if ( not r_config_to_tgt_rsp_req.read() )
    2054           {
    2055               r_config_to_tgt_rsp_srcid  = r_config_srcid.read();
    2056               r_config_to_tgt_rsp_trdid  = r_config_trdid.read();
    2057               r_config_to_tgt_rsp_pktid  = r_config_pktid.read();
    2058               r_config_to_tgt_rsp_error  = false;
    2059               r_config_to_tgt_rsp_req    = true;
    2060               r_config_fsm               = CONFIG_IDLE;
    2061 
    2062 #if DEBUG_MEMC_CONFIG
    2063 if(m_debug)
    2064 std::cout << "  <MEMC " << name() << " CONFIG_RSP> Request TGT_RSP FSM to return response:"
    2065           << " error = " << r_config_to_tgt_rsp_error.read()
    2066           << " / rsrcid = " << std::hex << r_config_srcid.read() << std::endl;
    2067 #endif
    2068           }
    2069           break;
    2070 
    20712175      }
    20722176  }  // end switch r_config_fsm
     
    21222226    case READ_DIR_REQ:  // Get the lock to the directory
    21232227    {
    2124       if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
    2125       {
    2126         r_read_fsm = READ_DIR_LOCK;
    2127         m_cpt_read_fsm_n_dir_lock++;
    2128       }
     2228        if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
     2229        {
     2230          r_read_fsm = READ_DIR_LOCK;
     2231          m_cpt_read_fsm_n_dir_lock++;
     2232    }
    21292233
    21302234#if DEBUG_MEMC_READ
     
    21412245    case READ_DIR_LOCK:  // check directory for hit / miss
    21422246    {
    2143       if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
    2144       {
     2247        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and
     2248        "MEMC ERROR in READ_DIR_LOCK state: Bad DIR allocation");
     2249
    21452250        size_t way = 0;
    21462251        DirectoryEntry entry =
    2147           m_cache_directory.read(m_cmd_read_addr_fifo.read(), way);
     2252        m_cache_directory.read(m_cmd_read_addr_fifo.read(), way);
    21482253        if(((m_cmd_read_pktid_fifo.read() & 0x7) == TYPE_LL) and not r_read_ll_done.read())   // access the global table ONLY when we have an LL cmd
    21492254        {
     
    21642269        r_read_copy       = entry.owner.srcid;
    21652270
    2166 #if L1_MULTI_CACHE
    2167         r_read_copy_cache = entry.owner.cache_id;
    2168 #endif
    21692271        r_read_copy_inst  = entry.owner.inst;
    21702272        r_read_ptr        = entry.ptr; // pointer to the heap
     
    22162318}
    22172319#endif
    2218       }
    2219       else
    2220       {
    2221         std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_DIR_LOCK state"
    2222                   << "Bad DIR allocation"   << std::endl;
    2223         exit(0);
    2224       }
    22252320      break;
    22262321    }
     
    23182413
    23192414    {
    2320       if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
    2321       {
     2415         assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and
     2416        "MEMC ERROR in READ_DIR_HIT state: Bad DIR allocation");
    23222417        // check if this is an instruction read, this means pktid is either
    23232418        // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
     
    23352430
    23362431        m_cache_data.read_line(way, set, r_read_data);
    2337 
    2338         if(m_monitor_ok) check_monitor( m_cmd_read_addr_fifo.read(), r_read_data[0], true);
    23392432
    23402433        // update the cache directory
     
    23532446          {
    23542447            entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
    2355 #if L1_MULTI_CACHE
    2356             entry.owner.cache_id = m_cmd_read_pktid_fifo.read();
    2357 #endif
    23582448            entry.owner.inst     = inst_read;
    23592449            entry.count          = r_read_count.read() + 1;
     
    23622452          {
    23632453            entry.owner.srcid    = 0;
    2364 #if L1_MULTI_CACHE
    2365             entry.owner.cache_id = 0;
    2366 #endif
    23672454            entry.owner.inst     = false;
    23682455            entry.count          = r_read_count.read() + 1;
     
    23722459        {
    23732460          entry.owner.srcid     = r_read_copy.read();
    2374 #if L1_MULTI_CACHE
    2375           entry.owner.cache_id  = r_read_copy_cache.read();
    2376 #endif
    23772461          entry.owner.inst      = r_read_copy_inst.read();
    23782462          entry.count           = r_read_count.read();
     
    23942478        m_cache_directory.write(set, way, entry);
    23952479        r_read_fsm    = READ_RSP;
    2396       }
    2397       break;
     2480        break;
    23982481    }
    23992482    ///////////////////
     
    24362519
    24372520        m_cache_data.read_line(way, set, r_read_data);
    2438 
    2439         if(m_monitor_ok) check_monitor( m_cmd_read_addr_fifo.read(), r_read_data[0], true);
    24402521
    24412522        // update the cache directory
     
    24522533        {
    24532534          entry.owner.srcid    = r_read_copy.read();
    2454 #if L1_MULTI_CACHE
    2455           entry.owner.cache_id = r_read_copy_cache.read();
    2456 #endif
    24572535          entry.owner.inst     = r_read_copy_inst.read();
    24582536          entry.ptr            = m_heap.next_free_ptr();   // set pointer on the heap
     
    24612539        {
    24622540          entry.owner.srcid    = 0;
    2463 #if L1_MULTI_CACHE
    2464           entry.owner.cache_id = 0;
    2465 #endif
    24662541          entry.owner.inst     = false;
    24672542          entry.ptr            = 0;
     
    25292604        HeapEntry heap_entry;
    25302605        heap_entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
    2531 #if L1_MULTI_CACHE
    2532         heap_entry.owner.cache_id = m_cmd_read_pktid_fifo.read();
    2533 #endif
    25342606        heap_entry.owner.inst     = ((m_cmd_read_pktid_fifo.read() & 0x2) != 0);
    25352607
     
    25952667        HeapEntry last_entry;
    25962668        last_entry.owner.srcid    = 0;
    2597 #if L1_MULTI_CACHE
    2598         last_entry.owner.cache_id = 0;
    2599 #endif
    26002669        last_entry.owner.inst     = false;
    26012670
     
    27182787#if DEBUG_MEMC_READ
    27192788if(m_debug)
    2720 std::cout << "  <MEMC " << name() << " READ_TRT_SET> Write in Transaction Table:"
     2789          m_trt.print(0);
     2790std::cout << "  <MEMC " << name() << " READ_TRT_SET> Set a GET in TGT:"
    27212791          << " address = " << std::hex << m_cmd_read_addr_fifo.read()
    27222792          << " / srcid = " << std::hex << m_cmd_read_srcid_fifo.read() << std::endl;
     
    27342804        cmd_read_fifo_get       = true;
    27352805        r_read_to_ixr_cmd_req   = true;
    2736         r_read_to_ixr_cmd_nline = m_nline[(addr_t)(m_cmd_read_addr_fifo.read())];
    2737         r_read_to_ixr_cmd_trdid = r_read_trt_index.read();
     2806        //r_read_to_ixr_cmd_nline = m_nline[(addr_t)(m_cmd_read_addr_fifo.read())];
     2807        r_read_to_ixr_cmd_index = r_read_trt_index.read();
    27382808        r_read_fsm              = READ_IDLE;
    27392809
     
    27622832  //   If the data is cached by other processors, a coherence transaction must
    27632833  //   be launched (sc requests always require a coherence transaction):
    2764   //   It is a multicast update if the line is not in counter mode, and the processor
     2834  //   It is a multicast update if the line is not in counter mode: the processor
    27652835  //   takes the lock protecting the Update Table (UPT) to register this transaction.
    2766   //   It is a broadcast invalidate if the line is in counter mode.
    27672836  //   If the UPT is full, it releases the lock(s) and retry. Then, it sends
    27682837  //   a multi-update request to all owners of the line (but the writer),
     
    27702839  //   does not respond to the writing processor, as this response will be sent by
    27712840  //   the MULTI_ACK FSM when all update responses have been received.
     2841  //   It is a broadcast invalidate if the line is in counter mode: The line
     2842  //   should be erased in memory cache, and written in XRAM with a PUT transaction,
     2843  //   after registration in TRT.
    27722844  //
    27732845  // - In case of MISS, the WRITE FSM takes the lock protecting the transaction
    27742846  //   table (TRT). If a read transaction to the XRAM for this line already exists,
    27752847  //   it writes in the TRT (write buffer). Otherwise, if a TRT entry is free,
    2776   //   the WRITE FSM register a new transaction in TRT, and sends a read line request
     2848  //   the WRITE FSM register a new transaction in TRT, and sends a GET request
    27772849  //   to the XRAM. If the TRT is full, it releases the lock, and waits.
    27782850  //   Finally, the WRITE FSM returns an aknowledge response to the writing processor.
     
    28492921
    28502922        // check that the next word is in the same cache line
    2851         if((m_nline[(addr_t)(r_write_address.read())]       !=
    2852             m_nline[(addr_t)(m_cmd_write_addr_fifo.read())]))
    2853         {
    2854           std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_NEXT state" << std::endl
    2855                     << "all words in a write burst must be in same cache line" << std::endl;
    2856 
    2857           exit(0);
    2858         }
     2923        assert( (m_nline[(addr_t)(r_write_address.read())] ==
     2924               m_nline[(addr_t)(m_cmd_write_addr_fifo.read())]) and
     2925        "MEMC ERROR in WRITE_NEXT state: Illegal write burst");
    28592926
    28602927        // consume a word in the FIFO & write it in the local buffer
     
    29222989        // erase any possible new reservation when we release the lock on the
    29232990        // directory
    2924         m_llsc_table.sw(nline);
     2991        m_llsc_table.sw(m_nline[(addr_t)r_write_address.read()],r_write_word_index.read(),r_write_word_index.read()+r_write_word_count.read());
    29252992
    29262993        //m_llsc_table.sw(r_write_address.read());
     
    29443011    case WRITE_DIR_LOCK:     // access directory to check hit/miss
    29453012    {
    2946       if(r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE)
    2947       {
     3013        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3014        "MEMC ERROR in ALLOC_DIR_LOCK state: Bad DIR allocation");
    29483015        size_t  way = 0;
    29493016        DirectoryEntry entry(m_cache_directory.read(r_write_address.read(), way));
     
    29563023          r_write_tag        = entry.tag;
    29573024          r_write_copy       = entry.owner.srcid;
    2958 #if L1_MULTI_CACHE
    2959           r_write_copy_cache = entry.owner.cache_id;
    2960 #endif
    29613025          r_write_copy_inst  = entry.owner.inst;
    29623026          r_write_count      = entry.count;
     
    29703034            if(entry.is_cnt && entry.count)
    29713035            {
    2972               r_write_fsm = WRITE_DIR_READ;
     3036              r_write_fsm = WRITE_BC_DIR_READ;
    29733037            }
    29743038            else
     
    30123076}
    30133077#endif
    3014       }
    3015       else
    3016       {
    3017         std::cout << "VCI_MEM_CACHE ERROR " << name()
    3018                   << " WRITE_DIR_LOCK state"        << std::endl
    3019                   << "bad DIR allocation"           << std::endl;
    3020 
    3021         exit(0);
    3022       }
    30233078      break;
    30243079    }
     
    30763131    }
    30773132
    3078 
    3079     ////////////////////
    3080     case WRITE_DIR_READ:  // read the cache and complete the buffer when be!=0xF
    3081     {
    3082       // update local buffer
    3083       size_t set  = m_y[(addr_t)(r_write_address.read())];
    3084       size_t way  = r_write_way.read();
    3085       for(size_t word=0 ; word<m_words ; word++)
    3086       {
    3087         data_t mask = 0;
    3088         if(r_write_be[word].read() & 0x1) mask = mask | 0x000000FF;
    3089         if(r_write_be[word].read() & 0x2) mask = mask | 0x0000FF00;
    3090         if(r_write_be[word].read() & 0x4) mask = mask | 0x00FF0000;
    3091         if(r_write_be[word].read() & 0x8) mask = mask | 0xFF000000;
    3092 
    3093         // complete only if mask is not null (for energy consumption)
    3094         r_write_data[word]  = (r_write_data[word].read() & mask) |
    3095                               (m_cache_data.read(way, set, word) & ~mask);
    3096 
    3097       } // end for
    3098 
    3099       // test if a coherence broadcast is required
    3100       r_write_fsm = WRITE_BC_TRT_LOCK;
    3101 
    3102 #if DEBUG_MEMC_WRITE
    3103 if(m_debug)
    3104 std::cout << "  <MEMC " << name() << " WRITE_DIR_READ>"
    3105           << " Read the cache to complete local buffer" << std::endl;
    3106 #endif
    3107       break;
    3108     }
    3109 
    31103133    ///////////////////
    31113134    case WRITE_DIR_HIT:
    31123135    {
     3136      assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3137      "MEMC ERROR in ALLOC_DIR_HIT state: Bad DIR allocation");
     3138 
    31133139      // update the cache directory
    31143140      // update directory with Dirty bit
     
    31213147      entry.lock           = r_write_lock.read();
    31223148      entry.owner.srcid    = r_write_copy.read();
    3123 #if L1_MULTI_CACHE
    3124       entry.owner.cache_id = r_write_copy_cache.read();
    3125 #endif
    31263149      entry.owner.inst     = r_write_copy_inst.read();
    31273150      entry.count          = r_write_count.read();
     
    31543177          m_cache_data.write(way, set, word, r_write_data[word].read(), r_write_be[word].read());
    31553178
    3156           if(m_monitor_ok)
    3157           {
    3158             addr_t address = (r_write_address.read() & ~(addr_t) 0x3F) | word<<2;
    3159             check_monitor( address, r_write_data[word].read(), false);
    3160           }
    31613179        }
    31623180      }
     
    32423260                               r_write_be[word].read());
    32433261
    3244             if(m_monitor_ok)
    3245             {
    3246               addr_t address = (r_write_address.read() & ~(addr_t) 0x3F) | word<<2;
    3247               check_monitor( address, r_write_data[word].read(), false);
    3248             }
    32493262          }
    32503263        }
    32513264
    32523265#if DEBUG_MEMC_WRITE
    3253 if(m_debug)
     3266if(m_debug and wok)
    32543267{
    32553268    if(wok)
     
    33173330      for(size_t i=min ; i<max ; i++) r_write_to_cc_send_data[i] = r_write_data[i];
    33183331
    3319       if((r_write_copy.read() != r_write_srcid.read()) or(r_write_pktid.read() == TYPE_SC) or
    3320 #if L1_MULTI_CACHE
    3321           (r_write_copy_cache.read() != r_write_pktid.read()) or
    3322 #endif
    3323           r_write_copy_inst.read())
     3332      if((r_write_copy.read() != r_write_srcid.read()) or(r_write_pktid.read() == TYPE_SC) or r_write_copy_inst.read())
    33243333      {
    33253334        // put the first srcid in the fifo
     
    33273336        write_to_cc_send_fifo_inst    = r_write_copy_inst.read();
    33283337        write_to_cc_send_fifo_srcid   = r_write_copy.read();
    3329 #if L1_MULTI_CACHE
    3330         write_to_cc_send_fifo_cache_id= r_write_copy_cache.read();
    3331 #endif
    33323338        if(r_write_count.read() == 1)
    33333339        {
     
    33803386      bool dec_upt_counter;
    33813387
    3382       if(((entry.owner.srcid != r_write_srcid.read()) or (r_write_pktid.read() == TYPE_SC)) or
    3383 #if L1_MULTI_CACHE
    3384           (entry.owner.cache_id != r_write_pktid.read()) or
    3385 #endif
    3386           entry.owner.inst)             // put the next srcid in the fifo
     3388      if(((entry.owner.srcid != r_write_srcid.read()) or (r_write_pktid.read() == TYPE_SC)) or entry.owner.inst)             // put the next srcid in the fifo
    33873389      {
    33883390        dec_upt_counter                = false;
     
    33903392        write_to_cc_send_fifo_inst     = entry.owner.inst;
    33913393        write_to_cc_send_fifo_srcid    = entry.owner.srcid;
    3392 #if L1_MULTI_CACHE
    3393         write_to_cc_send_fifo_cache_id = entry.owner.cache_id;
    3394 #endif
    33953394
    33963395#if DEBUG_MEMC_WRITE
     
    35733572        bool    hit_read  = m_trt.hit_read(m_nline[addr], hit_index);
    35743573        bool    hit_write = m_trt.hit_write(m_nline[addr]);
    3575         bool    wok       = !m_trt.full(wok_index);
     3574        bool    wok       = not m_trt.full(wok_index);
    35763575        //std::cout << "MEMCACHE : WRITE MISS at " << std::hex << (uint32_t)addr << std::dec << std::endl;
    35773576        if(hit_read)      // register the modified data in TRT
     
    36413640#if DEBUG_MEMC_WRITE
    36423641if(m_debug)
     3642        m_trt.print(0);
    36433643std::cout << "  <MEMC " << name() << " WRITE_MISS_TRT_SET> Set a new entry in TRT" << std::endl;
    36443644#endif
     
    36623662        }
    36633663        m_trt.write_data_mask(r_write_trt_index.read(),
    3664                                           be_vector,
    3665                                           data_vector);
     3664                              be_vector,
     3665                              data_vector);
    36663666        r_write_fsm = WRITE_RSP;
    36673667
     
    36773677    case WRITE_MISS_XRAM_REQ: // send a GET request to IXR_CMD FSM
    36783678    {
    3679       if(!r_write_to_ixr_cmd_req)
     3679      if(not r_write_to_ixr_cmd_req.read())
    36803680      {
    36813681        r_write_to_ixr_cmd_req   = true;
    3682         r_write_to_ixr_cmd_write = false;
    3683         r_write_to_ixr_cmd_nline = m_nline[(addr_t)(r_write_address.read())];
    3684         r_write_to_ixr_cmd_trdid = r_write_trt_index.read();
     3682        r_write_to_ixr_cmd_put   = false;
     3683        r_write_to_ixr_cmd_index = r_write_trt_index.read();
    36853684        r_write_fsm              = WRITE_RSP;
    36863685
     
    36943693
    36953694    ///////////////////////
    3696     case WRITE_BC_TRT_LOCK:     // Check TRT not full
    3697     {
     3695    case WRITE_BC_DIR_READ:  // enter this state if a broadcast-inval is required
     3696                             // the cache line must be erased in mem-cache, and written
     3697                             // into XRAM. we read the cache and complete the buffer
     3698    {
     3699        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3700        "MEMC ERROR in WRITE_BC_DIR_READ state: Bad DIR allocation");
     3701 
     3702        // update local buffer
     3703        size_t set  = m_y[(addr_t)(r_write_address.read())];
     3704        size_t way  = r_write_way.read();
     3705        for(size_t word=0 ; word<m_words ; word++)
     3706        {
     3707            data_t mask = 0;
     3708            if(r_write_be[word].read() & 0x1) mask = mask | 0x000000FF;
     3709            if(r_write_be[word].read() & 0x2) mask = mask | 0x0000FF00;
     3710            if(r_write_be[word].read() & 0x4) mask = mask | 0x00FF0000;
     3711            if(r_write_be[word].read() & 0x8) mask = mask | 0xFF000000;
     3712
     3713            // complete only if mask is not null (for energy consumption)
     3714            r_write_data[word]  = (r_write_data[word].read() & mask) |
     3715                                  (m_cache_data.read(way, set, word) & ~mask);
     3716        } // end for
     3717
     3718        r_write_fsm = WRITE_BC_TRT_LOCK;
     3719
     3720#if DEBUG_MEMC_WRITE
     3721if(m_debug)
     3722std::cout << "  <MEMC " << name() << " WRITE_BC_DIR_READ>"
     3723          << " Read the cache to complete local buffer" << std::endl;
     3724#endif
     3725        break;
     3726    }
     3727
     3728    ///////////////////////
     3729    case WRITE_BC_TRT_LOCK:     // get TRT lock to check TRT not full
     3730    {
     3731      assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3732      "MEMC ERROR in WRITE_BC_TRT_LOCK state: Bad DIR allocation");
     3733
    36983734      if(r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE)
    36993735      {
    37003736        size_t wok_index = 0;
    3701         bool wok = !m_trt.full(wok_index);
     3737        bool wok = not m_trt.full(wok_index);
    37023738        if(wok)       // set a new entry in TRT
    37033739        {
     
    37263762    case WRITE_BC_IVT_LOCK:      // register BC transaction in IVT
    37273763    {
     3764      assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3765      "MEMC ERROR in WRITE_BC_IVT_LOCK state: Bad DIR allocation");
     3766
     3767      assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) and
     3768      "MEMC ERROR in WRITE_BC_IVT_LOCK state: Bad TRT allocation");
     3769
    37283770      if(r_alloc_ivt_fsm.read() == ALLOC_IVT_WRITE)
    37293771      {
     
    37673809    case WRITE_BC_DIR_INVAL:
    37683810    {
    3769       // Register a put transaction to XRAM in TRT
    3770       // and invalidate the line in directory
    3771       if((r_alloc_trt_fsm.read() != ALLOC_TRT_WRITE) or
    3772          (r_alloc_ivt_fsm.read() != ALLOC_IVT_WRITE) or
    3773          (r_alloc_dir_fsm.read() != ALLOC_DIR_WRITE))
    3774       {
    3775         std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_BC_DIR_INVAL state" << std::endl;
    3776         std::cout << "bad TRT, DIR, or IVT allocation" << std::endl;
    3777         exit(0);
    3778       }
    3779 
    3780       // register a write request to XRAM in TRT
    3781       m_trt.set(r_write_trt_index.read(),
    3782                             false,    // write request to XRAM
    3783                             m_nline[(addr_t)(r_write_address.read())],
    3784                             0,
    3785                             0,
    3786                             0,
    3787                             false,    // not a processor read
    3788                             0,        // not a single word
    3789                             0,            // word index
    3790                             std::vector<be_t> (m_words,0),
    3791                             std::vector<data_t> (m_words,0));
     3811      assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3812      "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad DIR allocation");
     3813
     3814      assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) and
     3815      "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad TRT allocation");
     3816 
     3817      assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_WRITE) and
     3818      "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad IVT allocation");
     3819
     3820      // register PUT request in TRT
     3821      std::vector<data_t> data_vector;
     3822      data_vector.clear();
     3823      for(size_t i=0; i<m_words; i++) data_vector.push_back(r_write_data[i].read());
     3824      m_trt.set( r_write_trt_index.read(),
     3825                 false,             // PUT request
     3826                 m_nline[(addr_t)(r_write_address.read())],
     3827                 0,                 // unused
     3828                 0,                 // unused
     3829                 0,                 // unused
     3830                 false,             // not a processor read
     3831                 0,                 // unused
     3832                 0,                 // unused
     3833                 std::vector<be_t> (m_words,0),
     3834                 data_vector );
    37923835
    37933836      // invalidate directory entry
     
    37963839      entry.cache_coherent= false;
    37973840      entry.dirty         = false;
    3798       entry.tag         = 0;
     3841      entry.tag           = 0;
    37993842      entry.is_cnt        = false;
    38003843      entry.lock          = false;
    38013844      entry.owner.srcid   = 0;
    3802 #if L1_MULTI_CACHE
    3803       entry.owner.cache_id= 0;
    3804 #endif
    38053845      entry.owner.inst    = false;
    38063846      entry.ptr           = 0;
     
    38133853#if DEBUG_MEMC_WRITE
    38143854if(m_debug)
     3855          m_trt.print(0);
    38153856std::cout << "  <MEMC " << name() << " WRITE_BC_DIR_INVAL> Invalidate the directory entry: @ = "
    38163857          << r_write_address.read() << " / register the put transaction in TRT:" << std::endl;
     
    38513892    case WRITE_BC_XRAM_REQ:   // Post a put request to IXR_CMD FSM
    38523893    {
    3853       if(!r_write_to_ixr_cmd_req)
     3894      if( not r_write_to_ixr_cmd_req.read() )
    38543895      {
    38553896        r_write_to_ixr_cmd_req     = true;
    3856         r_write_to_ixr_cmd_write   = true;
    3857         r_write_to_ixr_cmd_nline   = m_nline[(addr_t)(r_write_address.read())];
    3858         r_write_to_ixr_cmd_trdid   = r_write_trt_index.read();
    3859 
    3860         for(size_t i=0; i<m_words; i++) r_write_to_ixr_cmd_data[i] = r_write_data[i];
    3861 
     3897        r_write_to_ixr_cmd_put     = true;
     3898        r_write_to_ixr_cmd_index   = r_write_trt_index.read();
    38623899        r_write_fsm = WRITE_IDLE;
    38633900
     
    38763913  ///////////////////////////////////////////////////////////////////////
    38773914  // The IXR_CMD fsm controls the command packets to the XRAM :
    3878   // It handles requests from the READ, WRITE, CAS, XRAM_RSP FSMs
    3879   // with a round-robin priority.
     3915  // It handles requests from 5 FSMs with a round-robin priority:
     3916  //  READ > WRITE > CAS > XRAM_RSP > CONFIG
    38803917  //
    3881   // - It sends a single flit VCI read request to the XRAM in case of MISS
    3882   // posted by the READ, WRITE or CAS FSMs : the TRDID field contains
    3883   // the Transaction Tab index.
    3884   // The VCI response is a multi-flit packet : the N cells contain
    3885   // the N data words.
     3918  // - It sends a single flit VCI read to the XRAM in case of
     3919  //   GET request posted by the READ, WRITE or CAS FSMs.
     3920  // - It sends a multi-flit VCI write in case of PUT request posted by
     3921  //   the XRAM_RSP, WRITE, CAS, or CONFIG FSMs.
    38863922  //
    3887   // - It sends a multi-flit VCI write when the XRAM_RSP FSM, WRITE FSM
    3888   // or CAS FSM request to save a dirty line to the XRAM.
    3889   // The VCI response is a single flit packet.
     3923  // For each client, there is three steps:
     3924  // - IXR_CMD_*_IDLE : round-robin allocation to a client
     3925  // - IXR_CMD_*_TRT  : access to TRT for address and data
     3926  // - IXR_CMD_*_SEND : send the PUT or GET VCI command
     3927  //
     3928  // The address and data to be written (for a PUT) are stored in TRT.
     3929  // The trdid field contains always the TRT entry index.
    38903930  ////////////////////////////////////////////////////////////////////////
    38913931
     
    38943934    ////////////////////////
    38953935    case IXR_CMD_READ_IDLE:
    3896       if     (r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
    3897       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    3898       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
    3899       else if(r_cleanup_to_ixr_cmd_req)  r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
    3900       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
     3936      if     (r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3937      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3938      else if(r_cleanup_to_ixr_cmd_req.read())    r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3939      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
     3940      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3941      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
    39013942      break;
    39023943    ////////////////////////
    39033944    case IXR_CMD_WRITE_IDLE:
    3904       if(r_cas_to_ixr_cmd_req)           r_ixr_cmd_fsm = IXR_CMD_CAS;
    3905       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
    3906       else if(r_cleanup_to_ixr_cmd_req)  r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
    3907       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3908       else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
     3945      if     (r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3946      else if(r_cleanup_to_ixr_cmd_req.read())    r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3947      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
     3948      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3949      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3950      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
    39093951      break;
    39103952    ////////////////////////
    39113953    case IXR_CMD_CAS_IDLE:
    3912       if(r_xram_rsp_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_XRAM;
    3913       else if(r_cleanup_to_ixr_cmd_req)  r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
    3914       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3915       else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
    3916       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
     3954      if     (r_cleanup_to_ixr_cmd_req.read())    r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3955      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
     3956      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3957      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3958      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3959      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
    39173960      break;
    39183961    ////////////////////////
    39193962    case IXR_CMD_XRAM_IDLE:
    3920       if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
    3921       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3922       else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE;
    3923       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    3924       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3963      if     (r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3964      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3965      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3966      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3967      else if(r_cleanup_to_ixr_cmd_req.read())    r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3968      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
    39253969      break;
    39263970      ////////////////////////
    39273971    case IXR_CMD_CLEANUP_IDLE:
    39283972      /*ODCCP*///std::cout << "IXR_CMD_CLEANUP_IDLE" << std::endl;
    3929       if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3930       else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE;
    3931       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    3932       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
    3933       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
     3973      if     (r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3974      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3975      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3976      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
     3977      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3978      else if(r_cleanup_to_ixr_cmd_req)           r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
    39343979      break;     
    3935     //////////////////       // send a get from READ FSM
    3936     case IXR_CMD_READ:
    3937     {
    3938       if(p_vci_ixr.cmdack)
    3939       {
    3940         r_ixr_cmd_fsm = IXR_CMD_READ_IDLE;
    3941         r_read_to_ixr_cmd_req = false;
     3980    /////////////////////////
     3981    case IXR_CMD_CONFIG_IDLE:
     3982    {
     3983      if     (r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3984      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3985      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3986      else if(r_cleanup_to_ixr_cmd_req)           r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3987      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
     3988      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3989      break;
     3990    }
     3991 
     3992    //////////////////////
     3993    case IXR_CMD_READ_TRT:       // access TRT for a GET
     3994    {
     3995        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     3996        {
     3997            TransactionTabEntry entry = m_trt.read( r_read_to_ixr_cmd_index.read() );
     3998            r_ixr_cmd_address = entry.nline * (m_words<<2);
     3999            r_ixr_cmd_trdid   = r_read_to_ixr_cmd_index.read();
     4000            r_ixr_cmd_get     = true;
     4001            r_ixr_cmd_word    = 0;
     4002            r_ixr_cmd_fsm     = IXR_CMD_READ_SEND;
     4003            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    39424004
    39434005#if DEBUG_MEMC_IXR_CMD
    39444006if(m_debug)
    3945 std::cout << "  <MEMC " << name() << " IXR_CMD_READ>"
    3946           << " Send a get request to xram / address = " << std::hex
    3947           << (addr_t)(r_read_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
    3948 #endif
    3949       }
    3950       break;
    3951     }
    3952     ///////////////////
    3953     case IXR_CMD_WRITE:     // send a put or get from WRITE FSM
    3954     {
    3955       if(p_vci_ixr.cmdack)
    3956       {
    3957         if(r_write_to_ixr_cmd_write.read())   // PUT
    3958         {
    3959           if(r_ixr_cmd_cpt.read() == (m_words - 2))
    3960           {
    3961             r_ixr_cmd_cpt = 0;
    3962             r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE;
    3963             r_write_to_ixr_cmd_req = false;
    3964           }
    3965           else
    3966           {
    3967             r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    3968           }
     4007std::cout << "  <MEMC " << name() << " IXR_CMD_READ_TRT> TRT access"
     4008          << " index = " << std::dec << r_read_to_ixr_cmd_index.read()
     4009          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     4010#endif
     4011        }
     4012        break;
     4013    }
     4014    ///////////////////////
     4015    case IXR_CMD_WRITE_TRT:       // access TRT for a PUT or a GET
     4016    {
     4017        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     4018        {
     4019            TransactionTabEntry entry = m_trt.read( r_write_to_ixr_cmd_index.read() );
     4020            r_ixr_cmd_address = entry.nline * (m_words<<2);
     4021            r_ixr_cmd_trdid   = r_write_to_ixr_cmd_index.read();
     4022            r_ixr_cmd_get     = entry.xram_read;
     4023            r_ixr_cmd_word    = 0;
     4024            r_ixr_cmd_fsm     = IXR_CMD_WRITE_SEND;
     4025            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    39694026
    39704027#if DEBUG_MEMC_IXR_CMD
    39714028if(m_debug)
    3972 std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE>"
    3973           << " Send a put request to xram / address = " << std::hex
    3974           << (addr_t)((r_write_to_ixr_cmd_nline.read() * m_words +
    3975                       r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
    3976 #endif
    3977         }
    3978         else                                  // GET
    3979         {
    3980           r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE;
    3981           r_write_to_ixr_cmd_req = false;
     4029std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE_TRT> TRT access"
     4030          << " index = " << std::dec << r_write_to_ixr_cmd_index.read()
     4031          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     4032#endif
     4033        }
     4034        break;
     4035    }
     4036    /////////////////////
     4037    case IXR_CMD_CAS_TRT:       // access TRT for a PUT or a GET
     4038    {
     4039        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     4040        {
     4041            TransactionTabEntry entry = m_trt.read( r_cas_to_ixr_cmd_index.read() );
     4042            r_ixr_cmd_address = entry.nline * (m_words<<2);
     4043            r_ixr_cmd_trdid   = r_cas_to_ixr_cmd_index.read();
     4044            r_ixr_cmd_get     = entry.xram_read;
     4045            r_ixr_cmd_word    = 0;
     4046            r_ixr_cmd_fsm     = IXR_CMD_CAS_SEND;
     4047            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    39824048
    39834049#if DEBUG_MEMC_IXR_CMD
    39844050if(m_debug)
    3985 std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE>"
    3986           << " Send a get request to xram / address = " << std::hex
    3987           << (addr_t)(r_write_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
    3988 #endif
    3989         }
    3990       }
    3991       break;
    3992     }
    3993     /////////////////
    3994     case IXR_CMD_CAS:      // send a put or get command from CAS FSM
    3995     {
    3996       if(p_vci_ixr.cmdack)
    3997       {
    3998         if(r_cas_to_ixr_cmd_write.read()) // PUT
    3999         {
    4000           if(r_ixr_cmd_cpt.read() == (m_words - 2))
    4001           {
    4002             r_ixr_cmd_cpt = 0;
    4003             r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE;
    4004             r_cas_to_ixr_cmd_req = false;
    4005           }
    4006           else
    4007           {
    4008             r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    4009           }
     4051std::cout << "  <MEMC " << name() << " IXR_CMD_CAS_TRT> TRT access"
     4052          << " index = " << std::dec << r_cas_to_ixr_cmd_index.read()
     4053          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     4054#endif
     4055        }
     4056        break;
     4057    }
     4058    //////////////////////
     4059    case IXR_CMD_XRAM_TRT:       // access TRT for a PUT
     4060    {
     4061        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     4062        {
     4063            TransactionTabEntry entry = m_trt.read( r_xram_rsp_to_ixr_cmd_index.read() );
     4064            r_ixr_cmd_address = entry.nline * (m_words<<2);
     4065            r_ixr_cmd_trdid   = r_xram_rsp_to_ixr_cmd_index.read();
     4066            r_ixr_cmd_get     = false;
     4067            r_ixr_cmd_word    = 0;
     4068            r_ixr_cmd_fsm     = IXR_CMD_XRAM_SEND;
     4069            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    40104070
    40114071#if DEBUG_MEMC_IXR_CMD
    40124072if(m_debug)
    4013 std::cout << "  <MEMC " << name() << " IXR_CMD_CAS>"
    4014           << " Send a put request to xram / address = " << std::hex
    4015           << (addr_t)( (r_cas_to_ixr_cmd_nline.read() * m_words +
    4016                       r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
    4017 #endif
    4018         }
    4019         else                            // GET
    4020         {
    4021           r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE;
    4022           r_cas_to_ixr_cmd_req = false;
     4073std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM_TRT> TRT access"
     4074          << " index = " << std::dec << r_xram_rsp_to_ixr_cmd_index.read()
     4075          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     4076#endif
     4077        }
     4078        break;
     4079    }
     4080    //////////////////////
     4081    case IXR_CMD_CLEANUP_TRT:       // access TRT for a PUT
     4082    {
     4083        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     4084        {
     4085         
     4086            TransactionTabEntry entry = m_trt.read( r_cleanup_to_ixr_cmd_index.read() );
     4087            r_ixr_cmd_address = entry.nline * (m_words<<2);
     4088            r_ixr_cmd_trdid   = r_cleanup_to_ixr_cmd_index.read();
     4089            r_ixr_cmd_get     = false;
     4090            r_ixr_cmd_word    = 0;
     4091            r_ixr_cmd_fsm     = IXR_CMD_CLEANUP_DATA_SEND;
     4092            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    40234093
    40244094#if DEBUG_MEMC_IXR_CMD
    40254095if(m_debug)
    4026 std::cout << "  <MEMC " << name() << " IXR_CMD_CAS>"
    4027           << " Send a get request to xram / address = " << std::hex
    4028           << (addr_t)(r_cas_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
    4029 #endif
    4030         }
    4031       }
    4032       break;
    4033     }
    4034     //////////////////
    4035     case IXR_CMD_XRAM:     // send a put from XRAM_RSP FSM
    4036     {
    4037       if(p_vci_ixr.cmdack)
    4038       {
    4039         if(r_ixr_cmd_cpt.read() == (m_words - 2))
    4040         {
    4041           r_ixr_cmd_cpt = 0;
    4042           r_ixr_cmd_fsm = IXR_CMD_XRAM_IDLE;
    4043           r_xram_rsp_to_ixr_cmd_req = false;
     4096std::cout << "  <MEMC " << name() << " IXR_CMD_CLEANUP_TRT> TRT access"
     4097          << " index = " << std::dec << r_cleanup_to_ixr_cmd_index.read()
     4098          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     4099#endif
     4100        }
     4101        break;
     4102    }
     4103    ////////////////////////
     4104    case IXR_CMD_CONFIG_TRT:       // access TRT for a PUT
     4105    {
     4106        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     4107        {
     4108            TransactionTabEntry entry = m_trt.read( r_config_to_ixr_cmd_index.read() );
     4109            r_ixr_cmd_address = entry.nline * (m_words<<2);
     4110            r_ixr_cmd_trdid   = r_config_to_ixr_cmd_index.read();
     4111            r_ixr_cmd_get     = false;
     4112            r_ixr_cmd_word    = 0;
     4113            r_ixr_cmd_fsm     = IXR_CMD_CONFIG_SEND;
     4114            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
     4115
     4116#if DEBUG_MEMC_IXR_CMD
     4117if(m_debug)
     4118std::cout << "  <MEMC " << name() << " IXR_CMD_CONFIG_TRT> TRT access"
     4119          << " index = " << std::dec << r_config_to_ixr_cmd_index.read()
     4120          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     4121#endif
     4122        }
     4123        break;
     4124    }
     4125
     4126    ///////////////////////
     4127    case IXR_CMD_READ_SEND:      // send a get from READ FSM
     4128    {
     4129        if(p_vci_ixr.cmdack)
     4130        {
     4131            r_ixr_cmd_fsm         = IXR_CMD_READ_IDLE;
     4132            r_read_to_ixr_cmd_req = false;
     4133
     4134#if DEBUG_MEMC_IXR_CMD
     4135if(m_debug)
     4136std::cout << "  <MEMC " << name() << " IXR_CMD_READ_SEND> GET request:" << std::hex
     4137          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4138#endif
     4139        }
     4140        break;
     4141    }
     4142    ////////////////////////
     4143    case IXR_CMD_WRITE_SEND:     // send a put or get from WRITE FSM
     4144    {
     4145        if(p_vci_ixr.cmdack)
     4146        {
     4147            if(r_write_to_ixr_cmd_put.read())   // PUT
     4148            {
     4149                if(r_ixr_cmd_word.read() == (m_words - 2))
     4150                {
     4151                    r_ixr_cmd_fsm          = IXR_CMD_WRITE_IDLE;
     4152                    r_write_to_ixr_cmd_req = false;
     4153                }
     4154                else
     4155                {
     4156                    r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
     4157                }
     4158
     4159#if DEBUG_MEMC_IXR_CMD
     4160if(m_debug)
     4161std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE_SEND> PUT request:" << std::hex
     4162          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4163#endif
     4164            }
     4165            else                                  // GET
     4166            {
     4167                r_ixr_cmd_fsm          = IXR_CMD_WRITE_IDLE;
     4168                r_write_to_ixr_cmd_req = false;
     4169
     4170#if DEBUG_MEMC_IXR_CMD
     4171if(m_debug)
     4172std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE_SEND> GET request:" << std::hex
     4173          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4174#endif
     4175            }
     4176        }
     4177        break;
     4178    }
     4179    //////////////////////
     4180    case IXR_CMD_CAS_SEND:      // send a put or get command from CAS FSM
     4181    {
     4182        if(p_vci_ixr.cmdack)
     4183        {
     4184            if(r_cas_to_ixr_cmd_put.read()) // PUT
     4185            {
     4186                if(r_ixr_cmd_word.read() == (m_words - 2))
     4187                {
     4188                    r_ixr_cmd_fsm        = IXR_CMD_CAS_IDLE;
     4189                    r_cas_to_ixr_cmd_req = false;
     4190                }
     4191                else
     4192                {
     4193                    r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
     4194                }
     4195
     4196#if DEBUG_MEMC_IXR_CMD
     4197if(m_debug)
     4198std::cout << "  <MEMC " << name() << " IXR_CMD_CAS_SEND> PUT request:" << std::hex
     4199          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4200#endif
     4201            }
     4202            else                            // GET
     4203            {
     4204                r_ixr_cmd_fsm        = IXR_CMD_CAS_IDLE;
     4205                r_cas_to_ixr_cmd_req = false;
     4206
     4207#if DEBUG_MEMC_IXR_CMD
     4208if(m_debug)
     4209std::cout << "  <MEMC " << name() << " IXR_CMD_CAS_SEND> GET request:" << std::hex
     4210          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4211#endif
     4212            }
     4213        }
     4214        break;
     4215    }
     4216    ///////////////////////
     4217    case IXR_CMD_XRAM_SEND:     // send a put from XRAM_RSP FSM
     4218    {
     4219        if(p_vci_ixr.cmdack.read())
     4220        {
     4221            if(r_ixr_cmd_word.read() == (m_words - 2))
     4222            {
     4223                r_ixr_cmd_fsm = IXR_CMD_XRAM_IDLE;
     4224                r_xram_rsp_to_ixr_cmd_req = false;
     4225            }
     4226            else
     4227            {
     4228                r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
     4229            }
     4230#if DEBUG_MEMC_IXR_CMD
     4231if(m_debug)
     4232std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM_SEND> PUT request:" << std::hex
     4233          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4234#endif
     4235        }
     4236        break;
     4237    }
     4238
     4239      ////////////////////////
     4240    case IXR_CMD_CLEANUP_DATA_SEND:     // send a put command to XRAM
     4241    {
     4242      if(p_vci_ixr.cmdack.read())
     4243      {
     4244        /*ODCCP*/ //std::cout << "IXR_CMD_CLEANUP_DATA_SEND STATE at cycle : " << std::dec << m_cpt_cycles << std::endl;
     4245        if(r_ixr_cmd_word.read() == (m_words - 2))
     4246        {
     4247          /*ODCCP*/ //std::cout << "IXR_CMD_CLEANUP_DATA_SEND GO TO IXR_CMD_CLEANUP_IDLE" << std::endl;
     4248          r_ixr_cmd_fsm = IXR_CMD_CLEANUP_IDLE;
     4249          r_cleanup_to_ixr_cmd_req = false;
     4250          //r_ixr_cmd_word = 0;
     4251          //r_xram_rsp_to_ixr_cmd_inval_ncc_pending = false;
    40444252        }
    40454253        else
    40464254        {
    4047           r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    4048         }
    4049 
    4050 #if DEBUG_MEMC_IXR_CMD
    4051 if(m_debug)
    4052 std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM>"
    4053           << " Send a put request to xram / address = " << std::hex
    4054           << (addr_t)( (r_xram_rsp_to_ixr_cmd_nline.read() * m_words +
    4055                        r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
    4056 #endif
    4057       }
    4058       break;
    4059     }
    4060 
    4061       ////////////////////////
    4062     case IXR_CMD_CLEANUP_DATA:     // send a put command to XRAM
    4063       /*ODCCP*///std::cout << "IXR_CMD_CLEANUP_DATA" << std::endl;
    4064       if(p_vci_ixr.cmdack)
    4065       {
    4066         if(r_ixr_cmd_cpt.read() == (m_words - 2))
    4067         {
    4068           r_ixr_cmd_cpt = 0;
    4069           r_ixr_cmd_fsm = IXR_CMD_CLEANUP_IDLE;
    4070           r_xram_rsp_to_ixr_cmd_inval_ncc_pending = false;
    4071           r_cleanup_to_ixr_cmd_req = false;
    4072         }
    4073         else
    4074         {
    4075           r_ixr_cmd_cpt = r_ixr_cmd_cpt.read() + 2;
     4255          r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
    40764256        }
    40774257
     
    40794259        if(m_debug)
    40804260        {
    4081           std::cout << "  <MEMC " << name() << ".IXR_CMD_CLEANUP_DATA> Send a put request to xram" << std::endl;
    4082         }
    4083 #endif
    4084       }
    4085       break;
    4086 
     4261          std::cout << "  <MEMC " << name() << ".IXR_CMD_CLEANUP_DATA_SEND> Send a put request to xram" << std::endl;
     4262        }
     4263#endif
     4264      }
     4265      break;
     4266    }
     4267
     4268    /////////////////////////
     4269    case IXR_CMD_CONFIG_SEND:     // send a put from CONFIG FSM
     4270    {
     4271        if(p_vci_ixr.cmdack.read())
     4272        {
     4273            if(r_ixr_cmd_word.read() == (m_words - 2))
     4274            {
     4275                r_ixr_cmd_fsm = IXR_CMD_CONFIG_IDLE;
     4276                r_config_to_ixr_cmd_req = false;
     4277            }
     4278            else
     4279            {
     4280                r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
     4281            }
     4282
     4283#if DEBUG_MEMC_IXR_CMD
     4284if(m_debug)
     4285std::cout << "  <MEMC " << name() << " IXR_CMD_CONFIG_SEND> PUT request:" << std::hex
     4286          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4287#endif
     4288        }
     4289        break;
     4290    }
    40874291  } // end switch r_ixr_cmd_fsm
    40884292
     
    40914295  ////////////////////////////////////////////////////////////////////////////
    40924296  // The IXR_RSP FSM receives the response packets from the XRAM,
    4093   // for both put transaction, and get transaction.
     4297  // for both PUT transaction, and GET transaction.
    40944298  //
    4095   // - A response to a put request is a single-cell VCI packet.
    4096   // The Transaction Tab index is contained in the RTRDID field.
     4299  // - A response to a PUT request is a single-cell VCI packet.
     4300  // The TRT index is contained in the RTRDID field.
    40974301  // The FSM takes the lock protecting the TRT, and the corresponding
    4098   // entry is erased.
     4302  // entry is erased. If an acknowledge was required (in case of software SYNC)
     4303  // the r_config_rsp_lines counter is decremented. 
    40994304  //
    4100   // - A response to a get request is a multi-cell VCI packet.
    4101   // The Transaction Tab index is contained in the RTRDID field.
     4305  // - A response to a GET request is a multi-cell VCI packet.
     4306  // The TRT index is contained in the RTRDID field.
    41024307  // The N cells contain the N words of the cache line in the RDATA field.
    41034308  // The FSM takes the lock protecting the TRT to store the line in the TRT
    41044309  // (taking into account the write requests already stored in the TRT).
    4105   // When the line is completely written, the corresponding rok signal is set.
     4310  // When the line is completely written, the r_ixr_rsp_to_xram_rsp_rok[index] 
     4311  // signal is set to inform the XRAM_RSP FSM.
    41064312  ///////////////////////////////////////////////////////////////////////////////
    41074313
     
    41114317    case IXR_RSP_IDLE:  // test transaction type: PUT/GET
    41124318    {
    4113       if(p_vci_ixr.rspval.read())
    4114       {
    4115         r_ixr_rsp_cpt   = 0;
    4116         r_ixr_rsp_trt_index = p_vci_ixr.rtrdid.read();
    4117         if(p_vci_ixr.reop.read() and !(p_vci_ixr.rerror.read() &0x1))   // PUT transaction
    4118         {
    4119           r_ixr_rsp_fsm = IXR_RSP_ACK;
    4120 
    4121 #if DEBUG_MEMC_IXR_RSP
    4122 if(m_debug)
    4123 std::cout << "  <MEMC " << name()
    4124           << " IXR_RSP_IDLE> Response from XRAM to a put transaction" << std::endl;
    4125 #endif
    4126         }
    4127         else                                                         // GET transaction
    4128         {
    4129           r_ixr_rsp_fsm = IXR_RSP_TRT_READ;
     4319          if(p_vci_ixr.rspval.read())
     4320          {
     4321              r_ixr_rsp_cpt       = 0;
     4322              r_ixr_rsp_trt_index = p_vci_ixr.rtrdid.read();
     4323
     4324              assert( ((p_vci_ixr.rerror.read() & 0x1) == 0) and
     4325              "MEMC ERROR in IXR_RSP state: XRAM response error !");
     4326
     4327              if(p_vci_ixr.reop.read())   // PUT
     4328              {
     4329                  r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE;
     4330              }
     4331
     4332              else                       // GET transaction
     4333              {
     4334                  r_ixr_rsp_fsm = IXR_RSP_TRT_READ;
    41304335
    41314336#if DEBUG_MEMC_IXR_RSP
     
    41344339          << " IXR_RSP_IDLE> Response from XRAM to a get transaction" << std::endl;
    41354340#endif
    4136         }
    4137       }
    4138       break;
    4139     }
    4140     /////////////////
    4141     case IXR_RSP_ACK:        // Aknowledge the VCI response for a PUT
    4142     {
    4143       if(p_vci_ixr.rspval.read()) r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE;
    4144 
    4145 #if DEBUG_MEMC_IXR_RSP
    4146 if(m_debug)
    4147 std::cout << "  <MEMC " << name() << " IXR_RSP_ACK>" << std::endl;
    4148 #endif
     4341              }     
     4342          }
    41494343      break;
    41504344    }
    41514345    ////////////////////////
     4346    case IXR_RSP_ACK:     // Acknowledge PUT transaction
     4347    {
     4348        r_ixr_rsp_fsm = IXR_RSP_IDLE;
     4349        break;
     4350    }
     4351
     4352   ////////////////////////
    41524353    case IXR_RSP_TRT_ERASE:   // erase the entry in the TRT
    4153     {
    4154       if(r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP)
    4155       {
    4156         m_trt.erase(r_ixr_rsp_trt_index.read());
    4157         r_ixr_rsp_fsm = IXR_RSP_IDLE;
    4158 
     4354                              // decrease the line counter if config request
     4355    {
     4356        if(r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP)
     4357        {
     4358            size_t  index = r_ixr_rsp_trt_index.read();
     4359            if (m_trt.is_config(index) ) r_config_rsp_lines = r_config_rsp_lines.read() - 1;
     4360            m_trt.erase(index);
     4361            r_ixr_rsp_fsm = IXR_RSP_IDLE;
     4362
     4363//            std::cout << "remove a valid slot in trt index = " << r_ixr_rsp_trt_index.read()<< std::endl;
    41594364#if DEBUG_MEMC_IXR_RSP
    41604365if(m_debug)
     
    41624367          << r_ixr_rsp_trt_index.read() << std::endl;
    41634368#endif
    4164       m_cpt_ixr_fsm_n_trt_lock++;
    4165       }
    4166 
    4167       m_cpt_ixr_fsm_trt_lock++;
    4168 
    4169       break;
     4369        }
     4370        break;
    41704371    }
    41714372    //////////////////////
    41724373    case IXR_RSP_TRT_READ:    // write a 64 bits data in the TRT
    41734374    {
    4174       if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and  p_vci_ixr.rspval)
    4175       {
    4176         size_t      index    = r_ixr_rsp_trt_index.read();
    4177         bool        eop      = p_vci_ixr.reop.read();
    4178         wide_data_t data     = p_vci_ixr.rdata.read();
    4179         bool        error    = ((p_vci_ixr.rerror.read() & 0x1) == 1);
    4180 
    4181         assert(((eop == (r_ixr_rsp_cpt.read() == (m_words-2))) or p_vci_ixr.rerror.read())
    4182                and "Error in VCI_MEM_CACHE : invalid length for a response from XRAM");
    4183 
    4184         m_trt.write_rsp( index,
    4185                          r_ixr_rsp_cpt.read(),
    4186                          data,
    4187                          error);
    4188 
    4189         r_ixr_rsp_cpt = r_ixr_rsp_cpt.read() + 2;
    4190 
    4191         if(eop)
    4192         {
    4193           r_ixr_rsp_to_xram_rsp_rok[r_ixr_rsp_trt_index.read()]=true;
    4194           r_ixr_rsp_fsm = IXR_RSP_IDLE;
    4195         }
     4375          if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and  p_vci_ixr.rspval)
     4376          {
     4377              size_t      index    = r_ixr_rsp_trt_index.read();
     4378              size_t      word     = r_ixr_rsp_cpt.read();
     4379              bool        eop      = p_vci_ixr.reop.read();
     4380              wide_data_t data     = p_vci_ixr.rdata.read();
     4381              bool        error    = ((p_vci_ixr.rerror.read() & 0x1) == 1);
     4382
     4383              assert(((eop == (word == (m_words-2))) or error) and
     4384              "MEMC ERROR in IXR_RSP_TRT_READ state : invalid response from XRAM");
     4385 
     4386              m_trt.write_rsp( index,
     4387                               word,
     4388                               data );
     4389
     4390              r_ixr_rsp_cpt = word + 2;
     4391
     4392              if(eop)
     4393              {
     4394                r_ixr_rsp_to_xram_rsp_rok[r_ixr_rsp_trt_index.read()]=true;
     4395                r_ixr_rsp_fsm = IXR_RSP_IDLE;
     4396              }
    41964397
    41974398#if DEBUG_MEMC_IXR_RSP
     
    41994400std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_READ> Writing a word in TRT : "
    42004401          << " index = " << std::dec << index
    4201           << " / word = " << r_ixr_rsp_cpt.read()
     4402          << " / word = " << word
    42024403          << " / data = " << std::hex << data << std::endl;
    42034404#endif
     
    42124413  //                XRAM_RSP FSM
    42134414  ////////////////////////////////////////////////////////////////////////////
    4214   // The XRAM_RSP FSM handles the incoming cache lines from the XRAM.
     4415  // The XRAM_RSP FSM handles the incoming cache lines after an XRAM GET.
    42154416  // The cache line has been written in the TRT by the IXR_CMD_FSM.
    42164417  // As the IXR_RSP FSM and the XRAM_RSP FSM are running in parallel,
    4217   // there is as many flip-flops r_ixr_rsp_to_xram_rsp_rok[i]
    4218   // as the number of entries in the TRT, that are handled with
    4219   // a round-robin priority...
     4418  // there is as many flip-flops r_ixr_rsp_to_xram_rsp_rok[i] as the number
     4419  // of entries in the TRT, that are handled with a round-robin priority...
    42204420  //
    4221   // When a response is available, the corresponding TRT entry
    4222   // is copied in a local buffer to be written in the cache.
    4223   // The FSM takes the lock protecting the TRT, and the lock protecting the DIR.
    4224   // It selects a cache slot and writes the line in the cache.
     4421  // The FSM takes the lock protecting TRT, and the lock protecting DIR.
     4422  // The selected TRT entry is copied in the local buffer r_xram_rsp_trt_buf.
     4423  // It selects a cache slot and save the victim line in another local buffer
     4424  // r_xram_rsp_victim_***.
     4425  // It writes the line extracted from TRT in the cache.
    42254426  // If it was a read MISS, the XRAM_RSP FSM send a request to the TGT_RSP
    42264427  // FSM to return the cache line to the registered processor.
     
    42374438    case XRAM_RSP_IDLE: // scan the XRAM responses / select a TRT index (round robin)
    42384439    {
    4239       size_t ptr   = r_xram_rsp_trt_index.read();
    4240       size_t lines = m_trt_lines;
    4241       for(size_t i=0 ; i<lines ; i++)
    4242       {
    4243         size_t index = (i+ptr+1) %lines;
    4244         if(r_ixr_rsp_to_xram_rsp_rok[index])
    4245         {
    4246           r_xram_rsp_trt_index             = index;
    4247           r_ixr_rsp_to_xram_rsp_rok[index] = false;
    4248           r_xram_rsp_fsm                   = XRAM_RSP_DIR_LOCK;
     4440        size_t old   = r_xram_rsp_trt_index.read();
     4441        size_t lines = m_trt_lines;
     4442        for(size_t i=0 ; i<lines ; i++)
     4443        {
     4444            size_t index = (i+old+1) %lines;
     4445            if(r_ixr_rsp_to_xram_rsp_rok[index])
     4446            {
     4447                r_xram_rsp_trt_index             = index;
     4448                r_ixr_rsp_to_xram_rsp_rok[index] = false;
     4449                r_xram_rsp_fsm                   = XRAM_RSP_DIR_LOCK;
    42494450
    42504451#if DEBUG_MEMC_XRAM_RSP
     
    42544455          << " index = " << std::dec << index << std::endl;
    42554456#endif
    4256           break;
    4257         }
    4258       }
     4457                break;
     4458            }
     4459        }
    42594460      break;
    42604461    }
     
    42694470        size_t  index = r_xram_rsp_trt_index.read();
    42704471        r_xram_rsp_trt_buf.copy( m_trt.read(index) );
    4271 
    42724472        r_xram_rsp_fsm = XRAM_RSP_TRT_COPY;
    42734473
     
    42884488                            // and copy it in a local buffer
    42894489    {
    4290       if ( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
    4291            (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) )
    4292       {
     4490        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
     4491        "MEMC ERROR in XRAM_RSP_TRT_COPY state: Bad DIR allocation");
     4492
     4493        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
     4494        "MEMC ERROR in XRAM_RSP_TRT_COPY state: Bad TRT allocation");
     4495
    42934496        // selects & extracts a victim line from cache
    42944497        size_t way = 0;
     
    43194522        r_xram_rsp_victim_dirty     = victim.dirty or (!victim.cache_coherent && (victim.count == 1)); //a NCC line is by default considered as dirty in the L1: we must take a reservation on a TRT entry
    43204523
    4321 
    4322         if(!r_xram_rsp_trt_buf.rerror)
    4323         {
    4324           if (!victim.cache_coherent and r_xram_rsp_to_ixr_cmd_inval_ncc_pending.read()) //there can not be two L2 invalidation on NCC line at the same time
    4325           {
    4326             r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    4327           }
    4328           else
    4329           {
    4330             r_xram_rsp_fsm = XRAM_RSP_INVAL_LOCK;
    4331           }
    4332         }
    4333         else
    4334         {
    4335           r_xram_rsp_fsm = XRAM_RSP_ERROR_ERASE;
    4336         }
    4337 
    4338 #if DEBUG_MEMC_XRAM_RSP
     4524        if( not r_xram_rsp_trt_buf.rerror ) r_xram_rsp_fsm = XRAM_RSP_IVT_LOCK;
     4525        else                                r_xram_rsp_fsm = XRAM_RSP_ERROR_ERASE;
     4526
     4527 #if DEBUG_MEMC_XRAM_RSP
    43394528if(m_debug)
    43404529std::cout << "  <MEMC " << name() << " XRAM_RSP_TRT_COPY>"
    4341           << " Select a slot: "
     4530          << " Select a victim slot: "
    43424531          << " way = " << std::dec << way
    43434532          << " / set = " << set
    43444533          << " / inval_required = " << inval << std::endl;
    43454534#endif
    4346       }
    4347       else
    4348       {
    4349         std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_TRT_COPY"
    4350                   << " bad TRT or DIR allocation" << std::endl;
    4351         exit(0);
    4352       }
    4353       break;
    4354     }
    4355     /////////////////////////
    4356     case XRAM_RSP_INVAL_LOCK: // Take the IVT lock to check a possible pending inval
    4357     {
    4358       if(r_alloc_ivt_fsm == ALLOC_IVT_XRAM_RSP)
    4359       {
    4360         size_t index = 0;
    4361         size_t index_victim = 0;
    4362         if(m_ivt.search_inval(r_xram_rsp_trt_buf.nline, index) or
    4363            m_ivt.search_inval(r_xram_rsp_victim_nline.read(), index_victim))
    4364         {
    4365           r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
     4535        break;
     4536    }
     4537    ///////////////////////
     4538    case XRAM_RSP_IVT_LOCK:   // Keep DIR and TRT locks and take the IVT lock
     4539                              // to check a possible pending inval
     4540    {
     4541        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
     4542        "MEMC ERROR in XRAM_RSP_IVT_LOCK state: Bad DIR allocation");
     4543
     4544        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
     4545        "MEMC ERROR in XRAM_RSP_IVT_LOCK state: Bad TRT allocation");
     4546
     4547        if(r_alloc_ivt_fsm == ALLOC_IVT_XRAM_RSP)
     4548        {
     4549            size_t index = 0;
     4550            if(m_ivt.search_inval(r_xram_rsp_trt_buf.nline, index))  // pending inval
     4551            {
     4552                r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    43664553
    43674554#if DEBUG_MEMC_XRAM_RSP
    43684555if(m_debug)
    4369 std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
     4556std::cout << "  <MEMC " << name() << " XRAM_RSP_IVT_LOCK>"
    43704557          << " Get acces to IVT, but line invalidation registered"
    4371           << " / nline = " << std::hex << r_xram_rsp_trt_buf.nline
     4558          << " / address = " << std::hex << r_xram_rsp_trt_buf.nline*m_words*4
    43724559          << " / index = " << std::dec << index << std::endl;
    43734560#endif
    43744561
    4375         }
    4376         else if(m_ivt.is_full() and r_xram_rsp_victim_inval.read()) // IVT full
    4377         {
    4378           r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    4379           m_upt.print();
     4562            }
     4563            else if(m_ivt.is_full() and r_xram_rsp_victim_inval.read()) // IVT full
     4564            {
     4565                r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    43804566
    43814567#if DEBUG_MEMC_XRAM_RSP
    43824568if(m_debug)
    4383 std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
     4569std::cout << "  <MEMC " << name() << " XRAM_RSP_IVT_LOCK>"
    43844570          << " Get acces to IVT, but inval required and IVT full" << std::endl;
    43854571#endif
    4386         }
    4387         else
    4388         {
    4389           r_xram_rsp_fsm = XRAM_RSP_DIR_UPDT;
     4572            }
     4573            else
     4574            {
     4575                r_xram_rsp_fsm = XRAM_RSP_DIR_UPDT;
    43904576
    43914577#if DEBUG_MEMC_XRAM_RSP
    43924578if(m_debug)
    4393 std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
    4394           << " Get acces to IVT" << std::endl;
    4395 #endif
    4396         }
    4397         m_cpt_xram_rsp_fsm_n_upt_lock++;
    4398       }
    4399 
    4400       m_cpt_xram_rsp_fsm_upt_lock++;
    4401 
    4402       break;
     4579std::cout << "  <MEMC " << name() << " XRAM_RSP_IVT_LOCK>"
     4580          << " Get acces to IVT / no pending inval request" << std::endl;
     4581#endif
     4582            }
     4583        }
     4584        break;
    44034585    }
    44044586    /////////////////////////
     
    44154597    }
    44164598    ///////////////////////
    4417     case XRAM_RSP_DIR_UPDT:   // updates the cache (both data & directory)
    4418                               // and possibly set an inval request in IVT
    4419     {
    4420       // check if this is an instruction read, this means pktid is either
    4421       // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
    4422       // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
    4423       bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) and r_xram_rsp_trt_buf.proc_read;
    4424 
    4425       // check if this is a cached read, this means pktid is either
    4426       // TYPE_READ_DATA_MISS 0bX001 with TSAR encoding
    4427       // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
    4428       bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) and r_xram_rsp_trt_buf.proc_read;
    4429 
    4430       bool dirty = false;
    4431 
    4432       // update cache data
    4433       size_t set   = r_xram_rsp_victim_set.read();
    4434       size_t way   = r_xram_rsp_victim_way.read();
    4435       for(size_t word=0; word<m_words ; word++)
    4436       {
    4437         m_cache_data.write(way, set, word, r_xram_rsp_trt_buf.wdata[word]);
    4438 
    4439         dirty = dirty or (r_xram_rsp_trt_buf.wdata_be[word] != 0);
    4440 
    4441         if(m_monitor_ok)
    4442         {
    4443           addr_t address = r_xram_rsp_trt_buf.nline<<6 | word<<2;
    4444           check_monitor( address, r_xram_rsp_trt_buf.wdata[word], false);
    4445         }
    4446       }
     4599    case XRAM_RSP_DIR_UPDT:   // updates the cache (both data & directory),
     4600                              // erases the TRT entry if victim not dirty,
     4601                              // and set inval request in IVT if required
     4602    {
     4603        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
     4604        "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad DIR allocation");
     4605
     4606        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
     4607        "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad TRT allocation");
     4608 
     4609        assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_XRAM_RSP) and
     4610        "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad IVT allocation");
     4611
     4612        // check if this is an instruction read, this means pktid is either
     4613        // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
     4614        // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
     4615
     4616        // check if this is a cached read, this means pktid is either
     4617        // TYPE_READ_DATA_MISS 0bX001 with TSAR encoding
     4618        // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
     4619        bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) and r_xram_rsp_trt_buf.proc_read;
     4620 
     4621        bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) and r_xram_rsp_trt_buf.proc_read;
     4622 
     4623        bool dirty = false;
     4624
     4625        // update cache data
     4626        size_t set   = r_xram_rsp_victim_set.read();
     4627        size_t way   = r_xram_rsp_victim_way.read();
     4628        for(size_t word=0; word<m_words ; word++)
     4629        {
     4630          m_cache_data.write(way, set, word, r_xram_rsp_trt_buf.wdata[word]);
     4631          dirty = dirty or (r_xram_rsp_trt_buf.wdata_be[word] != 0);
     4632
     4633        }
    44474634
    44484635      // update cache directory
     
    44584645      {
    44594646        entry.owner.srcid   = r_xram_rsp_trt_buf.srcid;
    4460 #if L1_MULTI_CACHE
    4461         entry.owner.cache_id= r_xram_rsp_trt_buf.pktid;
    4462 #endif
    44634647        entry.owner.inst    = inst_read;
    44644648        entry.count         = 1;
     
    44664650      else
    44674651      {
    4468         entry.owner.srcid    = r_xram_rsp_trt_buf.srcid;
    4469 #if L1_MULTI_CACHE
    4470         entry.owner.cache_id = 0;
    4471 #endif
     4652        entry.owner.srcid    = 0;
    44724653        entry.owner.inst     = 0;
    44734654        entry.count          = 0;
     
    44954676
    44964677        r_xram_rsp_ivt_index = index;
    4497         if(!wok)
    4498         {
    4499           std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_DIR_UPDT"
    4500                     << " invalidate_tab entry free but write unsuccessful" << std::endl;
    4501           exit(0);
    4502         }
     4678        assert( wok and
     4679        "MEMC ERROR in XRAM_RSP_DIR_UPDT state: IVT should not be full");
     4680 
    45034681      }
    45044682      if (!r_xram_rsp_victim_coherent.read())
    45054683      {
    45064684        //m_llsc_table.sw(r_xram_rsp_victim_nline.read()*m_words*4);
    4507         m_llsc_table.sw(r_xram_rsp_victim_nline.read());
     4685        m_llsc_table.sw(r_xram_rsp_victim_nline.read(), 0, m_words - 1);
    45084686      }
    45094687#if DEBUG_MEMC_XRAM_RSP
     
    45394717    case XRAM_RSP_TRT_DIRTY:  // set the TRT entry (write to XRAM) if the victim is dirty or not coherent (RWT)
    45404718    {
    4541       if(r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP)
    4542       {
    4543 
    4544         m_trt.set(r_xram_rsp_trt_index.read(),
    4545                               false,       // write to XRAM
    4546                               r_xram_rsp_victim_nline.read(),  // line index
    4547                               0,
    4548                               0,
    4549                               0,
    4550                               false,
    4551                               0,
    4552                               0,
    4553                               std::vector<be_t> (m_words,0),
    4554                               std::vector<data_t> (m_words,0));
    4555 
    4556 #if DEBUG_MEMC_XRAM_RSP
    4557 if(m_debug)
     4719        if(r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP)
     4720        {
     4721            std::vector<data_t> data_vector;
     4722            data_vector.clear();
     4723            for(size_t i=0; i<m_words; i++)
     4724            {
     4725                data_vector.push_back(r_xram_rsp_victim_data[i].read());
     4726            }
     4727            m_trt.set( r_xram_rsp_trt_index.read(),
     4728                       false,                             // PUT
     4729                       r_xram_rsp_victim_nline.read(),    // line index
     4730                       0,                                 // unused
     4731                       0,                                 // unused
     4732                       0,                                 // unused
     4733                       false,                             // not proc_read
     4734                       0,                                 // unused
     4735                       0,                                 // unused
     4736                       std::vector<be_t>(m_words,0xF),                         
     4737                       data_vector);
     4738 #if DEBUG_MEMC_XRAM_RSP
     4739if(m_debug)
     4740            m_trt.print(0);
    45584741std::cout << "  <MEMC " << name() << " XRAM_RSP_TRT_DIRTY>"
    45594742          << " Set TRT entry for the put transaction"
    45604743          << " / dirty victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
    45614744#endif
     4745       
     4746        if( not r_xram_rsp_victim_coherent )
     4747            std::cout << "a victim coherent not sent trt index =" << r_xram_rsp_trt_index.read() << std::endl;
    45624748        if(r_xram_rsp_trt_buf.proc_read)         r_xram_rsp_fsm = XRAM_RSP_DIR_RSP;
    45634749        else if(r_xram_rsp_victim_inval.read())  r_xram_rsp_fsm = XRAM_RSP_INVAL;
     
    45734759    case XRAM_RSP_DIR_RSP:     // Request a response to TGT_RSP FSM
    45744760    {
    4575       if(!r_xram_rsp_to_tgt_rsp_req.read())
     4761      if( not r_xram_rsp_to_tgt_rsp_req.read())
    45764762      {
    45774763        r_xram_rsp_to_tgt_rsp_srcid = r_xram_rsp_trt_buf.srcid;
     
    46274813        xram_rsp_to_cc_send_fifo_srcid     = r_xram_rsp_victim_copy.read();
    46284814        xram_rsp_to_cc_send_fifo_inst      = r_xram_rsp_victim_copy_inst.read();
    4629 #if L1_MULTI_CACHE
    4630         xram_rsp_to_cc_send_fifo_cache_id  = r_xram_rsp_victim_copy_cache.read();
    4631 #endif
    46324815        xram_rsp_to_cc_send_fifo_put       = multi_req;
    4633         r_xram_rsp_next_ptr                 = r_xram_rsp_victim_ptr.read();
    4634 
    4635         if(r_xram_rsp_victim_dirty)  r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
     4816        r_xram_rsp_next_ptr                = r_xram_rsp_victim_ptr.read();
     4817
     4818        if(r_xram_rsp_victim_dirty and r_xram_rsp_victim_coherent)  r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
    46364819        else if(not_last_multi_req)  r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ;
    46374820        else                         r_xram_rsp_fsm = XRAM_RSP_IDLE;
    46384821
     4822// std::cout << "cleanup sent for trt index =" << r_xram_rsp_trt_index.read() << std::endl;
    46394823#if DEBUG_MEMC_XRAM_RSP
    46404824if(m_debug)
    46414825std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL>"
    46424826          << " Send an inval request to CC_SEND FSM"
    4643           << " / victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
     4827          << " / address = " << r_xram_rsp_victim_nline.read()*m_words*4 << std::endl;
    46444828#endif
    46454829      }
     
    46494833    case XRAM_RSP_WRITE_DIRTY:  // send a write request to IXR_CMD FSM
    46504834    {
    4651       if(!r_xram_rsp_to_ixr_cmd_req.read() and !r_xram_rsp_to_ixr_cmd_inval_ncc_pending.read())
    4652       {
    4653         r_xram_rsp_to_ixr_cmd_req = true;
    4654         r_xram_rsp_to_ixr_cmd_nline = r_xram_rsp_victim_nline.read();
    4655         r_xram_rsp_to_ixr_cmd_trdid = r_xram_rsp_trt_index.read();
    4656         for(size_t i=0; i<m_words ; i++)
    4657         {
    4658             r_xram_rsp_to_ixr_cmd_data[i] = r_xram_rsp_victim_data[i];
    4659               std::cout << "data L2 = " << std::hex << r_xram_rsp_victim_data[i] << std::dec << std::endl;
    4660         }
    4661         m_cpt_write_dirty++;
     4835        if ( not r_xram_rsp_to_ixr_cmd_req.read() )
     4836        {
     4837            r_xram_rsp_to_ixr_cmd_req = true;
     4838            r_xram_rsp_to_ixr_cmd_index = r_xram_rsp_trt_index.read();
     4839 
     4840            m_cpt_write_dirty++;
    46624841       
    4663         if ((!r_xram_rsp_victim_coherent.read()) and (r_xram_rsp_victim_count.read() == 1)) //if NCC, we save the data in case of not dirty L1
    4664         {
    4665           r_xram_rsp_to_ixr_cmd_req = false;
    4666           r_xram_rsp_to_ixr_cmd_inval_ncc_pending = true;
    4667           r_xram_rsp_fsm = XRAM_RSP_IDLE;
    4668           break;
    4669         }
    4670 
    4671         bool multi_req = !r_xram_rsp_victim_is_cnt.read() and r_xram_rsp_victim_inval.read();
    4672         bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1);
    4673 
    4674         if(not_last_multi_req)   r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ;
    4675         else                     r_xram_rsp_fsm = XRAM_RSP_IDLE;
     4842            bool multi_req = not r_xram_rsp_victim_is_cnt.read() and
     4843              r_xram_rsp_victim_inval.read();
     4844            bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1);
     4845
     4846            if(not_last_multi_req)   r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ;
     4847            else                     r_xram_rsp_fsm = XRAM_RSP_IDLE;
    46764848
    46774849#if DEBUG_MEMC_XRAM_RSP
     
    46814853          << " / victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
    46824854#endif
    4683       }
    4684       break;
     4855         }
     4856        break;
    46854857    }
    46864858    /////////////////////////
     
    47114883
    47124884        xram_rsp_to_cc_send_fifo_srcid    = entry.owner.srcid;
    4713 #if L1_MULTI_CACHE
    4714         xram_rsp_to_cc_send_fifo_cache_id = entry.owner.cache_id;
    4715 #endif
    47164885        xram_rsp_to_cc_send_fifo_inst  = entry.owner.inst;
    47174886        xram_rsp_to_cc_send_fifo_put   = true;
     
    47574926      HeapEntry last_entry;
    47584927      last_entry.owner.srcid    = 0;
    4759 #if L1_MULTI_CACHE
    4760       last_entry.owner.cache_id = 0;
    4761 #endif
    47624928      last_entry.owner.inst     = false;
    47634929      if(m_heap.is_full())
     
    47834949      break;
    47844950    }
    4785     // ///////////////////////
     4951    /////////////////////////
    47864952    case XRAM_RSP_ERROR_ERASE:  // erase TRT entry in case of error
    47874953    {
     
    48735039      r_cleanup_contains_data = false;
    48745040
    4875       if(srcid >= m_initiators)
    4876       {
    4877         std::cout
    4878             << "VCI_MEM_CACHE ERROR " << name()
    4879             << " CLEANUP_IDLE state"  << std::endl
    4880             << "illegal srcid for cleanup request" << std::endl;
    4881 
    4882         exit(0);
    4883       }
     5041      assert( (srcid < m_initiators) and
     5042      "MEMC ERROR in CLEANUP_IDLE state : illegal SRCID value");
    48845043
    48855044      m_cpt_cleanup++;
     
    50265185      r_cleanup_copy         = entry.owner.srcid;
    50275186      r_cleanup_copy_inst    = entry.owner.inst;
    5028 #if L1_MULTI_CACHE
    5029       r_cleanup_copy_cache   = entry.owner.cache_id;
    5030 #endif
    50315187
    50325188      //RWT
     
    50345190      m_cache_data.read_line(way, set, r_cleanup_old_data);
    50355191      r_cleanup_coherent = entry.cache_coherent;
    5036 
    5037 
    50385192
    50395193      if(entry.valid)      // hit : the copy must be cleared
     
    51015255      bool   match_srcid = (r_cleanup_copy.read() == r_cleanup_srcid.read());
    51025256
    5103 #if L1_MULTI_CACHE
    5104       match_srcid       &= (r_cleanup_copy_cache.read() == r_cleanup_pktid.read());
    5105 #endif
    5106 
    51075257      bool   match_inst  = (r_cleanup_copy_inst.read() == r_cleanup_inst.read());
    51085258      bool   match       = match_srcid and match_inst;
     
    51495299          entry.owner.srcid    = r_read_to_cleanup_srcid.read();
    51505300          entry.owner.inst     = 0;
    5151 #if L1_MULTI_CACHE
    5152           entry.owner.cache_id = r_cleanup_copy_cache.read();
    5153 #endif
    51545301        }
    51555302        else
     
    51585305          entry.owner.srcid    = r_cleanup_copy.read();
    51595306          entry.owner.inst     = r_cleanup_copy_inst.read();
    5160 #if L1_MULTI_CACHE
    5161           entry.owner.cache_id = r_cleanup_copy_cache.read();
    5162 #endif
    51635307        }
    51645308        if (r_read_to_cleanup_is_ll.read())
     
    51725316        entry.owner.srcid    = 0;
    51735317        entry.owner.inst     = 0;
    5174 #if L1_MULTI_CACHE
    5175         entry.owner.cache_id = 0;
    5176 #endif
    5177       }
    5178 
     5318      }
    51795319
    51805320      if (r_cleanup_contains_data.read())
     
    51845324          m_cache_data.write(way, set, word, r_cleanup_data[word].read(), 0xF);
    51855325        }
    5186         m_llsc_table.sw(r_cleanup_nline.read());
     5326        m_llsc_table.sw(r_cleanup_nline.read(), 0 , m_words - 1);
    51875327        //m_llsc_table.sw(r_cleanup_nline.read()*m_words*4);
    51885328      }
    51895329
    5190 
    51915330      m_cache_directory.write(set, way, entry);
    5192 
    51935331
    51945332      /*RWT*/
     
    53465484      // 1. the matching copy is directly in the directory
    53475485      // 2. the matching copy is the first copy in the heap
    5348       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    5349       {
    5350         std::cout
    5351             << "VCI_MEM_CACHE ERROR " << name()
    5352             << " CLEANUP_HEAP_LOCK state"
    5353             << " bad HEAP allocation" << std::endl;
    5354 
    5355         exit(0);
    5356       }
     5486      assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and
     5487      "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation");
    53575488
    53585489      size_t way            = r_cleanup_way.read();
     
    53765507      r_cleanup_prev_inst   = heap_entry.owner.inst;
    53775508
    5378 #if L1_MULTI_CACHE
    5379       match_dir  = match_dir  and(r_cleanup_copy_cache.read() == r_cleanup_pktid.read());
    5380       match_heap = match_heap and(heap_entry.owner.cache_id   == r_cleanup_pktid.read());
    5381       r_cleanup_prev_cache_id = heap_entry.owner.cache_id;
    5382 #endif
    5383 
    5384       if(not match_dir and not match_heap and last)
    5385       {
    5386         std::cout
    5387             << "VCI_MEM_CACHE ERROR " << name()
    5388             << " CLEANUP_HEAP_LOCK state"
    5389             << " hit but copy not found"
    5390             << std::endl;
    5391 /**/
    5392         std::cout
    5393           << "r_cleanup_srcid = " << r_cleanup_srcid.read()
    5394           << " / r_cleanup_inst = " << r_cleanup_inst.read() << std::endl
    5395           << "r_cleanup_copy = " << r_cleanup_copy.read()
    5396           << " / r_cleanup_copy_inst = " << r_cleanup_copy_inst.read() << std::endl
    5397           << "heap_entry.owner.srcid = " << heap_entry.owner.srcid
    5398           << " / heap_entry.owner.inst = " << heap_entry.owner.inst << std::endl
    5399 /**/
    5400           << "nline = " << r_cleanup_nline << std::endl;
    5401         exit(0);
    5402       }
    5403 
    5404       if(match_dir and match_heap)
    5405       {
    5406         std::cout
    5407             << "VCI_MEM_CACHE ERROR " << name()
    5408             << " CLEANUP_HEAP_LOCK state"
    5409             << " two copies matching the cleanup owner id"
    5410             << std::endl;
    5411 /**/
    5412         std::cout
    5413           << "r_cleanup_srcid = " << r_cleanup_srcid.read()
    5414           << " / r_cleanup_inst = " << r_cleanup_inst.read() << std::endl
    5415           << "r_cleanup_copy = " << r_cleanup_copy.read()
    5416           << " / r_cleanup_copy_inst = " << r_cleanup_copy_inst.read() << std::endl
    5417           << "heap_entry.owner.srcid = " << heap_entry.owner.srcid
    5418           << " / heap_entry.owner.inst = " << heap_entry.owner.inst << std::endl
    5419 /**/
    5420           << "nline = " << r_cleanup_nline << std::endl;
    5421         exit(0);
    5422       }
     5509      assert( (not last or match_dir or match_heap) and
     5510      "MEMC ERROR in CLEANUP_HEAP_LOCK state: hit but no copy found");
     5511
     5512      assert( (not match_dir or not match_heap) and
     5513      "MEMC ERROR in CLEANUP_HEAP_LOCK state: two matching copies found");
    54235514
    54245515      DirectoryEntry dir_entry;
     
    54395530        dir_entry.owner.srcid    = heap_entry.owner.srcid;
    54405531        dir_entry.owner.inst     = heap_entry.owner.inst;
    5441 
    5442 #if L1_MULTI_CACHE
    5443         dir_entry.owner.cache_id = heap_entry.owner.cache_id;
    5444 #endif
    5445 
    54465532        r_cleanup_next_ptr       = r_cleanup_ptr.read();
    54475533        r_cleanup_fsm            = CLEANUP_HEAP_FREE;
     
    54565542        dir_entry.owner.srcid    = r_cleanup_copy.read();
    54575543        dir_entry.owner.inst     = r_cleanup_copy_inst.read();
    5458 
    5459 #if L1_MULTI_CACHE
    5460         dir_entry.owner.cache_id = r_cleanup_copy_cache.read();
    5461 #endif
    5462 
    54635544        r_cleanup_next_ptr       = r_cleanup_ptr.read();
    54645545        r_cleanup_fsm            = CLEANUP_HEAP_FREE;
     
    54725553        dir_entry.owner.srcid    = r_cleanup_copy.read();
    54735554        dir_entry.owner.inst     = r_cleanup_copy_inst.read();
    5474 
    5475 #if L1_MULTI_CACHE
    5476         dir_entry.owner.cache_id = r_cleanup_copy_cache.read();
    5477 #endif
    5478 
    54795555        r_cleanup_next_ptr       = heap_entry.next;
    54805556        r_cleanup_fsm            = CLEANUP_HEAP_SEARCH;
     
    54825558
    54835559      m_cache_directory.write(set,way,dir_entry);
    5484 
    54855560
    54865561#if DEBUG_MEMC_CLEANUP
     
    55085583      // This state is handling the case where the copy
    55095584      // is in the heap, but is not the first in the linked list
    5510       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    5511       {
    5512         std::cout
    5513             << "VCI_MEM_CACHE ERROR " << name()
    5514             << " CLEANUP_HEAP_SEARCH state"
    5515             << " bad HEAP allocation" << std::endl;
    5516 
    5517         exit(0);
    5518       }
     5585      assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and
     5586     "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation");
    55195587
    55205588      HeapEntry heap_entry  = m_heap.read(r_cleanup_next_ptr.read());
     
    55255593      bool match_heap       = match_heap_srcid and match_heap_inst;
    55265594
    5527 #if L1_MULTI_CACHE
    5528       match_heap = match_heap and(heap_entry.owner.cache_id == r_cleanup_pktid.read());
    5529 #endif
    5530 
    5531       if(not match_heap and last)
    5532       {
    5533         std::cout
    5534             << "VCI_MEM_CACHE_ERROR " << name()
    5535             << " CLEANUP_HEAP_SEARCH state"
    5536             << " cleanup on valid line but copy not found"
    5537             << std::endl;
    5538 
    5539         exit(0);
    5540       }
    5541 
    5542       // the matching copy must be removed
     5595      assert( (not last or match_heap) and
     5596      "MEMC ERROR in CLEANUP_HEAP_SEARCH state: no copy found");
     5597
     5598       // the matching copy must be removed
    55435599      if(match_heap)
    55445600      {
     
    55545610        r_cleanup_prev_inst     = heap_entry.owner.inst;
    55555611        r_cleanup_next_ptr      = heap_entry.next;
    5556 
    55575612        r_cleanup_fsm           = CLEANUP_HEAP_SEARCH;
    5558 
    5559 #if L1_MULTI_CACHE
    5560         r_cleanup_prev_cache_id = heap_entry.owner.cache_id;
    5561 #endif
    55625613      }
    55635614
     
    55955646    case CLEANUP_HEAP_CLEAN:    // remove a copy in the linked list
    55965647    {
    5597       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    5598       {
    5599         std::cout
    5600             << "VCI_MEM_CACHE ERROR " << name()
    5601             << " CLEANUP_HEAP_CLEAN state"
    5602             << "Bad HEAP allocation"  << std::endl;
    5603 
    5604         exit(0);
    5605       }
     5648     assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and
     5649     "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation");
    56065650
    56075651      HeapEntry heap_entry;
    56085652      heap_entry.owner.srcid    = r_cleanup_prev_srcid.read();
    56095653      heap_entry.owner.inst     = r_cleanup_prev_inst.read();
    5610 
    5611 #if L1_MULTI_CACHE
    5612       heap_entry.owner.cache_id = r_cleanup_prev_cache_id.read();
    5613 #endif
    5614 
    56155654      bool last = (r_cleanup_next_ptr.read() == r_cleanup_ptr.read());
    56165655
     
    56415680                              // and becomes the head of the list of free entries
    56425681    {
    5643       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    5644       {
    5645         std::cout
    5646             << "VCI_MEM_CACHE ERROR " << name()
    5647             << " CLEANUP_HEAP_CLEAN state" << std::endl
    5648             << "Bad HEAP allocation" << std::endl;
    5649 
    5650         exit(0);
    5651       }
    5652 
     5682     assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and
     5683     "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation");
    56535684      HeapEntry heap_entry;
    56545685      heap_entry.owner.srcid    = 0;
    56555686      heap_entry.owner.inst     = false;
    5656 
    5657 #if L1_MULTI_CACHE
    5658       heap_entry.owner.cache_id = 0;
    5659 #endif
    56605687
    56615688      if(m_heap.is_full())
     
    57065733#endif
    57075734        m_cpt_cleanup_fsm_n_upt_lock++;
    5708         break;
    5709       }
    5710 
    5711       // pending inval
    5712       r_cleanup_write_srcid = m_ivt.srcid(index);
    5713       r_cleanup_write_trdid = m_ivt.trdid(index);
    5714       r_cleanup_write_pktid = m_ivt.pktid(index);
    5715       r_cleanup_need_rsp    = m_ivt.need_rsp(index);
    5716       r_cleanup_need_ack    = m_ivt.need_ack(index);
    5717       r_cleanup_index       = index;
    5718 
    5719       r_cleanup_fsm         = CLEANUP_IVT_DECREMENT;
    5720 
     5735      }
     5736      else
     5737      {
     5738        // pending inval
     5739        r_cleanup_write_srcid = m_ivt.srcid(index);
     5740        r_cleanup_write_trdid = m_ivt.trdid(index);
     5741        r_cleanup_write_pktid = m_ivt.pktid(index);
     5742        r_cleanup_need_rsp    = m_ivt.need_rsp(index);
     5743        r_cleanup_need_ack    = m_ivt.need_ack(index);
     5744        r_cleanup_index       = index;
     5745        r_cleanup_fsm         = CLEANUP_IVT_DECREMENT;
    57215746#if DEBUG_MEMC_CLEANUP
    57225747if(m_debug)
     
    57275752          << " / ivt_entry = " << index << std::endl;
    57285753#endif
     5754      }
    57295755      break;
    57305756    }
     
    57325758    case CLEANUP_IVT_DECREMENT: // decrement response counter in IVT matching entry
    57335759    {
    5734       if(r_alloc_ivt_fsm.read() != ALLOC_IVT_CLEANUP)
    5735       {
    5736         std::cout
    5737             << "VCI_MEM_CACHE ERROR "         << name()
    5738             << " CLEANUP_IVT_DECREMENT state" << std::endl
    5739             << "Bad IVT allocation"
    5740             << std::endl;
    5741 
    5742         exit(0);
    5743       }
     5760      assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CLEANUP) and
     5761      "MEMC ERROR in CLEANUP_IVT_DECREMENT state: Bad IVT allocation");
    57445762
    57455763      size_t count = 0;
    57465764      m_ivt.decrement(r_cleanup_index.read(), count);
    5747 
    57485765
    57495766      if(count == 0)   // multi inval transaction completed
     
    57755792    case CLEANUP_IVT_CLEAR:    // Clear IVT entry
    57765793    {
    5777       if(r_alloc_ivt_fsm.read() != ALLOC_IVT_CLEANUP)
    5778       {
    5779         std::cout
    5780             << "VCI_MEM_CACHE ERROR "     << name()
    5781             << " CLEANUP_IVT_CLEAR state" << std::endl
    5782             << "Bad IVT allocation"
    5783             << std::endl;
    5784 
    5785         exit(0);
    5786       }
     5794      assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CLEANUP) and
     5795      "MEMC ERROR in CLEANUP_IVT_CLEAR state : bad IVT allocation");
    57875796
    57885797      m_ivt.clear(r_cleanup_index.read());
    57895798
     5799      if ( r_cleanup_need_ack.read() )
     5800      {
     5801          assert( (r_config_rsp_lines.read() > 0) and
     5802          "MEMC ERROR in CLEANUP_IVT_CLEAR state");
     5803
     5804          r_config_rsp_lines = r_config_rsp_lines.read() - 1;
     5805      }
     5806
    57905807      if      ( r_cleanup_need_rsp.read() ) r_cleanup_fsm = CLEANUP_WRITE_RSP;
    5791       else if ( r_cleanup_need_ack.read() ) r_cleanup_fsm = CLEANUP_CONFIG_ACK;
    57925808      else if ( r_cleanup_ncc.read()      ) r_cleanup_fsm = CLEANUP_IXR_REQ;
    57935809      else                                  r_cleanup_fsm = CLEANUP_SEND_CLACK;
     
    57995815          << " IVT_index = " << r_cleanup_index.read() << std::endl;
    58005816#endif
    5801       break;
    5802     }
     5817          break;
     5818      }
    58035819    ///////////////////////
    58045820    case CLEANUP_WRITE_RSP:    // response to a previous write on the direct network
     
    58125828      r_cleanup_to_tgt_rsp_trdid   = r_cleanup_write_trdid.read();
    58135829      r_cleanup_to_tgt_rsp_pktid   = r_cleanup_write_pktid.read();
    5814       r_cleanup_to_tgt_rsp_type    = true;
     5830      r_cleanup_to_tgt_rsp_type    = true; 
    58155831
    58165832      if (r_cleanup_ncc.read())
     
    58335849      break;
    58345850    }
    5835     ////////////////////////
    5836     case CLEANUP_CONFIG_ACK:   // signals inval completion to CONFIG FSM
    5837                                // wait if pending request
    5838     {
    5839       if ( r_cleanup_to_config_ack.read() ) break;
    5840 
    5841       r_cleanup_to_config_ack      = true;
    5842       r_cleanup_fsm                = CLEANUP_SEND_CLACK;
    5843 
    5844 #if DEBUG_MEMC_CLEANUP
    5845 if(m_debug)
    5846 std::cout << "  <MEMC " << name() << " CLEANUP_CONFIG_ACK>"
    5847           << " Acknowledge broacast inval completion" << std::endl;
    5848 #endif
    5849       break;
    5850     }
    5851 
    58525851    /////////////////////////
    58535852    case CLEANUP_IXR_REQ:
    58545853    {
    5855    
    58565854      //Send a request to the ixr to write the data in the XRAM using the prereserved TRT entry
    58575855      if (r_alloc_trt_fsm.read() == ALLOC_TRT_CLEANUP)
    58585856      {
    5859         if(!r_cleanup_to_ixr_cmd_req.read())
     5857        if( not r_cleanup_to_ixr_cmd_req.read())
    58605858        {
    58615859          size_t index = 0;
     
    58645862          assert (hit and "CLEANUP_IXR_REQ found no matching entry in TRT");
    58655863
    5866             r_cleanup_to_ixr_cmd_req     = true;
    5867 
    5868             for(size_t i = 0; i < m_words; i++){
    5869               r_cleanup_to_ixr_cmd_data[i]   = r_cleanup_data[i];
     5864          r_cleanup_to_ixr_cmd_req     = true;
     5865
     5866          if (r_cleanup_contains_data.read())
     5867          { 
     5868            std::vector<data_t> data_vector;
     5869            data_vector.clear();
     5870
     5871            for(size_t i=0; i<m_words; i++)
     5872            {
     5873              data_vector.push_back(r_cleanup_data[i]);
    58705874            }
    58715875
    5872             r_cleanup_to_ixr_cmd_srcid   = r_cleanup_srcid.read();
    5873             r_cleanup_to_ixr_cmd_trdid   = index;
    5874             r_cleanup_to_ixr_cmd_pktid   = r_cleanup_pktid.read();
    5875             r_cleanup_to_ixr_cmd_nline   = r_cleanup_nline.read();
    5876             r_cleanup_to_ixr_cmd_ncc_l1_dirty = r_cleanup_contains_data.read();
    5877             r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5876            m_trt.set(index,
     5877                      false,       // write to XRAM
     5878                      r_cleanup_nline.read(),  // line index
     5879                      0,
     5880                      0,
     5881                      0,
     5882                      false,
     5883                      0,
     5884                      0,
     5885                      std::vector<be_t> (m_words,0),
     5886                      data_vector);
     5887          }
     5888//std::cout << "cleanup with a non coherent ligne in trt index = " << index << std::endl;
     5889          r_cleanup_to_ixr_cmd_srcid        = r_cleanup_srcid.read();
     5890          r_cleanup_to_ixr_cmd_index        = index;
     5891          r_cleanup_to_ixr_cmd_pktid        = r_cleanup_pktid.read();
     5892          r_cleanup_to_ixr_cmd_nline        = r_cleanup_nline.read();
     5893          //r_cleanup_to_ixr_cmd_l1_dirty_ncc = r_cleanup_contains_data.read();
     5894          r_cleanup_fsm = CLEANUP_SEND_CLACK;
    58785895#if DEBUG_MEMC_CLEANUP
    58795896      if(m_debug)
    58805897      {
     5898        m_trt.print(0);
    58815899        std::cout
    58825900            << "  <MEMC " << name()
     
    59936011          r_cas_wdata = m_cmd_cas_wdata_fifo.read();
    59946012
    5995         if(r_cas_cpt.read() >3)  // more than 4 flits...
    5996         {
    5997           std::cout << "VCI_MEM_CACHE ERROR in CAS_IDLE state : illegal CAS command"
    5998                     << std::endl;
    5999           exit(0);
    6000         }
    6001 
    6002         if(r_cas_cpt.read() ==2)
     6013        assert( (r_cas_cpt.read() <= 3) and  // no more than 4 flits...
     6014        "MEMC ERROR in CAS_IDLE state: illegal CAS command");
     6015
     6016         if(r_cas_cpt.read() ==2)
    60036017          r_cas_wdata = m_cmd_cas_wdata_fifo.read();
    60046018
     
    60346048    case CAS_DIR_LOCK:  // Read the directory
    60356049    {
    6036       if(r_alloc_dir_fsm.read() == ALLOC_DIR_CAS)
    6037       {
     6050        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     6051        "MEMC ERROR in CAS_DIR_LOCK: Bad DIR allocation");
     6052
    60386053        size_t way = 0;
    60396054        DirectoryEntry entry(m_cache_directory.read(m_cmd_cas_addr_fifo.read(), way));
     
    60456060        r_cas_way        = way;
    60466061        r_cas_copy       = entry.owner.srcid;
    6047 #if L1_MULTI_CACHE
    6048         r_cas_copy_cache = entry.owner.cache_id;
    6049 #endif
    60506062        r_cas_copy_inst  = entry.owner.inst;
    60516063        r_cas_ptr        = entry.ptr;
     
    60656077        }
    60666078#endif
    6067       }
    6068       else
    6069       {
    6070         std::cout
    6071             << "VCI_MEM_CACHE ERROR " << name()
    6072             << " CAS_DIR_LOCK state" << std::endl
    6073             << "Bad DIR allocation"   << std::endl;
    6074 
    6075         exit(0);
    6076       }
    6077 
    6078       break;
     6079        break;
    60796080    }
    60806081    /////////////////////
     
    60946095      entry.tag            = r_cas_tag.read();
    60956096      entry.owner.srcid    = r_cas_copy.read();
    6096 #if L1_MULTI_CACHE
    6097       entry.owner.cache_id = r_cas_copy_cache.read();
    6098 #endif
    60996097      entry.owner.inst     = r_cas_copy_inst.read();
    61006098      entry.count          = r_cas_count.read();
     
    61566154    {
    61576155      // The CAS is a success => sw access to the llsc_global_table
    6158       // BUG LLSC
    6159       addr_t      nline      = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6160       m_llsc_table.sw(nline);
    61616156      //m_llsc_table.sw(m_cmd_cas_addr_fifo.read());
    61626157          /**//*std::cout << "MEMCACHE : from proc " << m_cmd_cas_srcid_fifo.read()
    61636158                        << " | @ " << std::hex << m_cmd_cas_addr_fifo.read()
    61646159                        << " | WRITE (cas triggered)" << std::endl;*/
     6160      m_llsc_table.sw(m_nline[(addr_t)m_cmd_cas_addr_fifo.read()],m_x[(addr_t)(m_cmd_cas_addr_fifo.read())],m_x[(addr_t)(m_cmd_cas_addr_fifo.read())]);
    61656161
    61666162      // test coherence request
     
    61706166        {
    61716167          r_cas_fsm = CAS_BC_TRT_LOCK;    // broadcast invalidate required
     6168#if DEBUG_MEMC_CAS
     6169if(m_debug)
     6170std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
     6171          << " Broacast Inval required"
     6172          << " / copies = " << r_cas_count.read() << std::endl;
     6173#endif
     6174
    61726175        }
    61736176        else if(!r_cas_to_cc_send_multi_req.read() and
     
    61756178        {
    61766179          r_cas_fsm = CAS_UPT_LOCK;       // multi update required
     6180#if DEBUG_MEMC_CAS
     6181if(m_debug)
     6182std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
     6183          << " Multi Inval required"
     6184          << " / copies = " << r_cas_count.read() << std::endl;
     6185#endif
    61776186        }
    61786187        else
    61796188        {
    61806189          r_cas_fsm = CAS_WAIT;
     6190#if DEBUG_MEMC_CAS
     6191if(m_debug)
     6192std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
     6193          << " CC_SEND FSM busy: release all locks and retry" << std::endl;
     6194#endif
    61816195        }
    61826196      }
     
    61936207
    61946208        r_cas_fsm = CAS_RSP_SUCCESS;
    6195 
    6196         // monitor
    6197         if(m_monitor_ok)
    6198         {
    6199           addr_t address = m_cmd_cas_addr_fifo.read();
    6200           check_monitor( address, r_cas_wdata.read(), false);
    6201 
    6202           if(r_cas_cpt.read() == 4)
    6203             check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);
    6204         }
    62056209
    62066210#if DEBUG_MEMC_CAS
     
    62566260          r_cas_fsm = CAS_UPT_HEAP_LOCK;
    62576261
    6258           // monitor
    6259           if(m_monitor_ok)
    6260           {
    6261             addr_t address = m_cmd_cas_addr_fifo.read();
    6262             check_monitor( address, r_cas_wdata.read(), false);
    6263 
    6264             if(r_cas_cpt.read() ==4)
    6265               check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);
    6266           }
    62676262        }
    62686263        else       //  releases the locks protecting UPT and DIR UPT full
     
    63506345        cas_to_cc_send_fifo_inst    = r_cas_copy_inst.read();
    63516346        cas_to_cc_send_fifo_srcid   = r_cas_copy.read();
    6352 #if L1_MULTI_CACHE
    6353         cas_to_cc_send_fifo_cache_id= r_cas_copy_cache.read();
    6354 #endif
    63556347        if(r_cas_count.read() == 1)  // one single copy
    63566348        {
     
    63876379      HeapEntry entry = m_heap.read(r_cas_ptr.read());
    63886380      cas_to_cc_send_fifo_srcid    = entry.owner.srcid;
    6389 #if L1_MULTI_CACHE
    6390       cas_to_cc_send_fifo_cache_id = entry.owner.cache_id;
    6391 #endif
    63926381      cas_to_cc_send_fifo_inst     = entry.owner.inst;
    63936382      cas_to_cc_send_fifo_put = true;
     
    64216410    case CAS_BC_TRT_LOCK:      // check the TRT to register a PUT transaction
    64226411    {
    6423       if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)
    6424       {
    6425         if(!r_cas_to_ixr_cmd_req)    // we can transfer the request to IXR_CMD FSM
    6426         {
    6427           // fill the data buffer
    6428           size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6429           for(size_t i = 0; i<m_words; i++)
    6430           {
    6431             if(i == word)
     6412        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     6413        "MEMC ERROR in CAS_BC_TRT_LOCK state: Bas DIR allocation");
     6414
     6415        if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)
     6416        {
     6417            size_t wok_index = 0;
     6418            bool   wok       = !m_trt.full(wok_index);
     6419            if( wok )
    64326420            {
    6433               r_cas_to_ixr_cmd_data[i] = r_cas_wdata.read();
    6434             }
    6435             else if((i == word+1) and (r_cas_cpt.read() == 4))   // 64 bit CAS
    6436             {
    6437               r_cas_to_ixr_cmd_data[i] = m_cmd_cas_wdata_fifo.read();
     6421                r_cas_trt_index = wok_index;
     6422                r_cas_fsm       = CAS_BC_IVT_LOCK;
    64386423            }
    64396424            else
    64406425            {
    6441               r_cas_to_ixr_cmd_data[i] = r_cas_data[i].read();
     6426                r_cas_fsm       = CAS_WAIT;
     6427                m_cpt_cas_fsm_n_trt_lock++;
    64426428            }
    6443           }
    6444           size_t wok_index = 0;
    6445           bool   wok       = !m_trt.full(wok_index);
    6446           if(wok)
    6447           {
    6448             r_cas_trt_index = wok_index;
    6449             r_cas_fsm       = CAS_BC_IVT_LOCK;
    6450           }
    6451           else
    6452           {
    6453             r_cas_fsm       = CAS_WAIT;
    6454           }
    6455         }
    6456         else
    6457         {
    6458           r_cas_fsm = CAS_WAIT;
    6459         }
    6460         m_cpt_cas_fsm_n_trt_lock++;
    6461       }
    6462 
     6429
     6430#if DEBUG_MEMC_CAS
     6431if(m_debug)
     6432std::cout << "  <MEMC " << name() << " CAS_BC_TRT_LOCK> Check TRT"
     6433          << " : wok = " << wok << " / index = " << wok_index << std::endl;
     6434#endif
     6435        }
    64636436      m_cpt_cas_fsm_trt_lock++;
    64646437
     
    65026475            m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read());
    65036476
    6504           // monitor
    6505           if(m_monitor_ok)
    6506           {
    6507             addr_t address = m_cmd_cas_addr_fifo.read();
    6508             check_monitor( address, r_cas_wdata.read(), false);
    6509 
    6510             if(r_cas_cpt.read() ==4)
    6511               check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);
    6512           }
    65136477          r_cas_upt_index = index;
    65146478          r_cas_fsm = CAS_BC_DIR_INVAL;
     
    65376501    case CAS_BC_DIR_INVAL:  // Register the PUT transaction in TRT, and inval the DIR entry
    65386502    {
    6539       if((r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
    6540          (r_alloc_ivt_fsm.read() == ALLOC_IVT_CAS) and
    6541          (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS))
    6542       {
    6543         // set TRT
    6544         m_trt.set(r_cas_trt_index.read(),
    6545                               false,    // PUT request to XRAM
    6546                               m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())],
    6547                               0,
    6548                               0,
    6549                               0,
    6550                               false,    // not a processor read
    6551                               0,
    6552                               0,
    6553                               std::vector<be_t> (m_words,0),
    6554                               std::vector<data_t> (m_words,0));
     6503        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     6504        "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad DIR allocation");
     6505
     6506        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
     6507        "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad TRT allocation");
     6508
     6509        assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CAS) and
     6510        "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad IVT allocation");
     6511
     6512        std::vector<data_t> data_vector;
     6513        data_vector.clear();
     6514        size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
     6515        for(size_t i=0; i<m_words; i++)
     6516        {
     6517            if(i == word)                                        // first modified word
     6518                data_vector.push_back( r_cas_wdata.read() );     
     6519            else if((i == word+1) and (r_cas_cpt.read() == 4))   // second modified word
     6520                data_vector.push_back( m_cmd_cas_wdata_fifo.read() );
     6521            else                                                 // unmodified words
     6522                data_vector.push_back( r_cas_data[i].read() );
     6523        }
     6524        m_trt.set( r_cas_trt_index.read(),
     6525                   false,    // PUT request
     6526                   m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())],
     6527                   0,
     6528                   0,
     6529                   0,
     6530                   false,    // not a processor read
     6531                   0,
     6532                   0,
     6533                   std::vector<be_t> (m_words,0),
     6534                   data_vector );
    65556535
    65566536        // invalidate directory entry
     
    65586538        entry.valid         = false;
    65596539        entry.dirty         = false;
    6560         entry.tag         = 0;
     6540        entry.tag           = 0;
    65616541        entry.is_cnt        = false;
    65626542        entry.lock          = false;
    65636543        entry.count         = 0;
    65646544        entry.owner.srcid   = 0;
    6565 #if L1_MULTI_CACHE
    6566         entry.owner.cache_id= 0;
    6567 #endif
    65686545        entry.owner.inst    = false;
    65696546        entry.ptr           = 0;
     
    65766553#if DEBUG_MEMC_CAS
    65776554if(m_debug)
    6578 std::cout << "  <MEMC " << name()
    6579           << " CAS_BC_DIR_INVAL> Register the PUT in TRT and invalidate DIR entry"
    6580           << " / nline = " << std::hex << m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())]
    6581           << " / set = " << std::dec << set << " / way = " << way << std::endl;
    6582 #endif
    6583       }
    6584       else
    6585       {
    6586         assert(false and "LOCK ERROR in CAS_FSM, STATE = CAS_BC_DIR_INVAL");
    6587       }
     6555        m_trt.print(0);
     6556std::cout << "  <MEMC " << name() << " CAS_BC_DIR_INVAL> Inval DIR & register in TRT:"
     6557          << " address = " << m_cmd_cas_addr_fifo.read() << std::endl;
     6558#endif
    65886559      break;
    65896560    }
     
    65916562    case CAS_BC_CC_SEND:  // Request the broadcast inval to CC_SEND FSM
    65926563    {
    6593       if(!r_cas_to_cc_send_multi_req.read() and
    6594           !r_cas_to_cc_send_brdcast_req.read())
     6564      if( not r_cas_to_cc_send_multi_req.read() and
     6565          not r_cas_to_cc_send_brdcast_req.read())
    65956566      {
    65966567        r_cas_to_cc_send_multi_req    = false;
     
    66086579    case CAS_BC_XRAM_REQ: // request the IXR FSM to start a put transaction
    66096580    {
    6610       if(!r_cas_to_ixr_cmd_req)
     6581      if( not r_cas_to_ixr_cmd_req.read() )
    66116582      {
    66126583        r_cas_to_ixr_cmd_req     = true;
    6613         r_cas_to_ixr_cmd_write   = true;
    6614         r_cas_to_ixr_cmd_nline   = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6615         r_cas_to_ixr_cmd_trdid   = r_cas_trt_index.read();
     6584        r_cas_to_ixr_cmd_put     = true;
     6585        r_cas_to_ixr_cmd_index   = r_cas_trt_index.read();
    66166586        r_cas_fsm                = CAS_IDLE;
    66176587        cmd_cas_fifo_get         = true;
     
    66226592std::cout << "  <MEMC " << name()
    66236593          << " CAS_BC_XRAM_REQ> Request a PUT transaction to IXR_CMD FSM" << std::hex
    6624           << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
     6594          << " / address = " << (addr_t) m_cmd_cas_addr_fifo.read()
    66256595          << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    66266596#endif
    66276597      }
    6628       else
    6629       {
    6630         std::cout << "ERROR in MEM_CACHE / CAS_BC_XRAM_REQ state"
    6631                   << " : request should not have been previously set" << std::endl;
    6632       }
     6598     
    66336599      break;
    66346600    }
     
    66366602    case CAS_RSP_FAIL:  // request TGT_RSP FSM to send a failure response
    66376603    {
    6638       if(!r_cas_to_tgt_rsp_req)
    6639       {
    6640         cmd_cas_fifo_get     = true;
     6604      if( not r_cas_to_tgt_rsp_req.read() )
     6605      {
     6606        cmd_cas_fifo_get       = true;
    66416607        r_cas_cpt              = 0;
    6642         r_cas_to_tgt_rsp_req = true;
     6608        r_cas_to_tgt_rsp_req   = true;
    66436609        r_cas_to_tgt_rsp_data  = 1;
    66446610        r_cas_to_tgt_rsp_srcid = m_cmd_cas_srcid_fifo.read();
     
    66586624    case CAS_RSP_SUCCESS:  // request TGT_RSP FSM to send a success response
    66596625    {
    6660       if(!r_cas_to_tgt_rsp_req)
     6626      if( not r_cas_to_tgt_rsp_req.read() )
    66616627      {
    66626628        cmd_cas_fifo_get       = true;
     
    66876653        bool hit_write = m_trt.hit_write(
    66886654                           m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]);
    6689         bool wok = !m_trt.full(index);
     6655        bool wok = not m_trt.full(index);
    66906656
    66916657#if DEBUG_MEMC_CAS
     
    67196685    case CAS_MISS_TRT_SET: // register the GET transaction in TRT
    67206686    {
    6721       if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)
    6722       {
     6687        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
     6688        "MEMC ERROR in CAS_MISS_TRT_SET state: Bad TRT allocation");
     6689
    67236690        std::vector<be_t> be_vector;
    67246691        std::vector<data_t> data_vector;
     
    67326699
    67336700        m_trt.set(r_cas_trt_index.read(),
    6734                               true,   // read request
    6735                               m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],
    6736                               m_cmd_cas_srcid_fifo.read(),
    6737                               m_cmd_cas_trdid_fifo.read(),
    6738                               m_cmd_cas_pktid_fifo.read(),
    6739                               false,    // write request from processor
    6740                               0,
    6741                               0,
    6742                               be_vector,
    6743                               data_vector);
     6701                  true,   // read request
     6702                  m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],
     6703                  m_cmd_cas_srcid_fifo.read(),
     6704                  m_cmd_cas_trdid_fifo.read(),
     6705                  m_cmd_cas_pktid_fifo.read(),
     6706                  false,    // write request from processor
     6707                  0,
     6708                  0,
     6709                  be_vector,
     6710                  data_vector);
    67446711        r_cas_fsm = CAS_MISS_XRAM_REQ;
    67456712
     
    67476714        if(m_debug)
    67486715        {
     6716          m_trt.print(0);
    67496717          std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_SET> Register a GET transaction in TRT" << std::hex
    67506718                    << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
     
    67526720        }
    67536721#endif
    6754       }
    67556722      break;
    67566723    }
     
    67586725    case CAS_MISS_XRAM_REQ:  // request the IXR_CMD FSM to fetch the missing line
    67596726    {
    6760       if(!r_cas_to_ixr_cmd_req)
     6727      if( not r_cas_to_ixr_cmd_req.read() )
    67616728      {
    67626729        r_cas_to_ixr_cmd_req        = true;
    6763         r_cas_to_ixr_cmd_write      = false;
    6764         r_cas_to_ixr_cmd_trdid      = r_cas_trt_index.read();
    6765         r_cas_to_ixr_cmd_nline      = m_nline[(addr_t) m_cmd_cas_addr_fifo.read()];
     6730        r_cas_to_ixr_cmd_put        = false;
     6731        r_cas_to_ixr_cmd_index      = r_cas_trt_index.read();
    67666732        r_cas_fsm                   = CAS_WAIT;
    67676733
    67686734#if DEBUG_MEMC_CAS
    6769         if(m_debug)
    6770         {
    6771           std::cout << "  <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction to IXR_CMD FSM" << std::hex
    6772                     << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
    6773                     << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    6774         }
     6735if(m_debug)
     6736std::cout << "  <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction"
     6737          << " / address = " << std::hex << (addr_t) m_cmd_cas_addr_fifo.read()
     6738          << " / trt_index = " << std::dec << r_cas_trt_index.read() << std::endl;
    67756739#endif
    67766740      }
     
    76437607        r_tgt_rsp_cpt = r_cleanup_to_tgt_rsp_first_word.read();
    76447608      }
    7645 
    76467609      else if(r_config_to_tgt_rsp_req)    r_tgt_rsp_fsm = TGT_RSP_CONFIG;
    76477610      else if(r_tgt_cmd_to_tgt_rsp_req)   r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
     
    77807743    }
    77817744    /////////////////////
    7782     case TGT_RSP_TGT_CMD: // send the response for a segmentation violation
     7745    case TGT_RSP_TGT_CMD: // send the response for a configuration access
    77837746    {
    77847747      if ( p_vci_tgt.rspack )
     
    77927755  std::cout
    77937756    << "  <MEMC " << name()
    7794     << " TGT_RSP_TGT_CMD> Segmentation violation response"
     7757    << " TGT_RSP_TGT_CMD> Send response for a configuration access"
    77957758    << " / rsrcid = " << std::hex << r_tgt_cmd_to_tgt_rsp_srcid.read()
    77967759    << " / rtrdid = " << r_tgt_cmd_to_tgt_rsp_trdid.read()
    77977760    << " / rpktid = " << r_tgt_cmd_to_tgt_rsp_pktid.read()
     7761    << " / error = " << r_tgt_cmd_to_tgt_rsp_error.read()
    77987762    << std::endl;
    77997763}
     
    79167880#endif
    79177881
    7918 
    79197882        uint32_t last_word_idx = r_cleanup_to_tgt_rsp_first_word.read() + r_cleanup_to_tgt_rsp_length.read() - 1;
    79207883        bool is_ll = ((r_cleanup_to_tgt_rsp_pktid.read() & 0x7) == TYPE_LL);
     
    79727935          }
    79737936        }
    7974 
    79757937      }
    79767938      break;
     
    81148076              else if (r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    81158077                  r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
    8116            
    81178078              else
    81188079                  m_cpt_upt_unused++;
     
    81458106              else if (r_cas_fsm.read() == CAS_UPT_LOCK)
    81468107                  r_alloc_upt_fsm = ALLOC_UPT_CAS;
    8147            
    81488108              else
    81498109                  m_cpt_upt_unused++;
     
    81788138              r_alloc_ivt_fsm = ALLOC_IVT_READ;
    81798139           
    8180             else if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     8140            else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    81818141              r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    81828142
     
    81888148                  r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    81898149       
    8190             else if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     8150            else if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    81918151              r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    81928152
     
    82008160          if (r_read_fsm.read() != READ_IVT_LOCK)
    82018161          {
    8202             if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     8162            if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    82038163              r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    82048164
     
    82108170                  r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    82118171       
    8212             else if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     8172            else if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    82138173              r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    82148174         
     
    82178177                (r_write_fsm.read() == WRITE_MISS_IVT_LOCK))
    82188178              r_alloc_ivt_fsm = ALLOC_IVT_WRITE;
    8219 
    82208179            else
    82218180              m_cpt_ivt_unused++;
     
    82258184      //////////////////////////
    82268185      case ALLOC_IVT_XRAM_RSP:         // allocated to XRAM_RSP FSM
    8227           if(r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK)
     8186          if(r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK)
    82288187          {
    82298188            if ((r_cleanup_fsm.read() == CLEANUP_IVT_LOCK) or
     
    82348193              r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    82358194
    8236             else if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     8195            else if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    82378196              r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    82388197
     
    82598218              r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    82608219
    8261             else if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     8220            else if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    82628221              r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    82638222
     
    82708229              r_alloc_ivt_fsm = ALLOC_IVT_READ;
    82718230
    8272             else if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     8231            else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    82738232              r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    82748233
     
    82828241          if (r_cas_fsm.read() != CAS_BC_IVT_LOCK)
    82838242          {
    8284             if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     8243            if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    82858244              r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    82868245
     
    82938252              r_alloc_ivt_fsm = ALLOC_IVT_READ;
    82948253
    8295             else if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     8254            else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    82968255              r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    82978256
     
    83078266      //////////////////////////
    83088267      case ALLOC_IVT_CONFIG:           // allocated to CONFIG FSM
    8309           if (r_config_fsm.read() != CONFIG_DIR_IVT_LOCK)
     8268          if (r_config_fsm.read() != CONFIG_IVT_LOCK)
    83108269          {
    83118270            if ((r_write_fsm.read() == WRITE_BC_IVT_LOCK) or
     
    83178276              r_alloc_ivt_fsm = ALLOC_IVT_READ;
    83188277
    8319             else if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     8278            else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    83208279              r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    83218280
     
    83268285            else if(r_cas_fsm.read() == CAS_BC_IVT_LOCK)
    83278286              r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    8328 
    83298287            else
    83308288              m_cpt_ivt_unused++;
     
    83618319    if ( (r_config_fsm.read()    != CONFIG_DIR_REQ) and
    83628320         (r_config_fsm.read()    != CONFIG_DIR_ACCESS) and
    8363          (r_config_fsm.read()    != CONFIG_DIR_IVT_LOCK) )
     8321         (r_config_fsm.read()    != CONFIG_TRT_LOCK) and
     8322         (r_config_fsm.read()    != CONFIG_TRT_SET) and
     8323         (r_config_fsm.read()    != CONFIG_IVT_LOCK) )
    83648324    {
    83658325        if(r_read_fsm.read() == READ_DIR_REQ)
     
    84178377      if(((r_write_fsm.read()       != WRITE_DIR_REQ)  and
    84188378          (r_write_fsm.read()       != WRITE_DIR_LOCK)  and
    8419           (r_write_fsm.read()       != WRITE_DIR_READ)  and
     8379          (r_write_fsm.read()       != WRITE_BC_DIR_READ)  and
    84208380          (r_write_fsm.read()       != WRITE_DIR_HIT)  and
    84218381          (r_write_fsm.read()       != WRITE_BC_TRT_LOCK)  and
     
    85308490      if( (r_xram_rsp_fsm.read() != XRAM_RSP_DIR_LOCK) and
    85318491        (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) and
    8532         (r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK))
     8492        (r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK))
    85338493      {
    85348494        if(r_config_fsm.read() == CONFIG_DIR_REQ)
     
    85798539          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    85808540
     8541        else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8542                (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     8543                (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     8544                (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8545                (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     8546                (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     8547          r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     8548 
    85818549        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    85828550                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     
    85878555          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    85888556
     8557        else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     8558          r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     8559 
    85898560        else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
    85908561          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     
    86078578          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    86088579
     8580        else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8581               (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     8582               (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     8583               (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8584               (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     8585               (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     8586          r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     8587 
    86098588        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    86108589                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     
    86188597          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    86198598
     8599        else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     8600          r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     8601
    86208602        else if(r_read_fsm.read() == READ_TRT_LOCK)
    86218603          r_alloc_trt_fsm = ALLOC_TRT_READ;
     
    86348616          (r_cas_fsm.read() != CAS_BC_IVT_LOCK))
    86358617      {
    8636         if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    8637             (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     8618       if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8619          (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     8620          (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     8621          (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8622          (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     8623          (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     8624           r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     8625 
     8626        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     8627               (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    86388628          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    86398629
     
    86458635          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    86468636
     8637        else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     8638          r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     8639 
    86478640        else if(r_read_fsm.read() == READ_TRT_LOCK)
    86488641          r_alloc_trt_fsm = ALLOC_TRT_READ;
     
    86588651        m_cpt_cas_fsm_trt_used++;
    86598652      break;
     8653      ///////////////////////
     8654      case ALLOC_TRT_IXR_CMD:
     8655          if((r_ixr_cmd_fsm.read() != IXR_CMD_READ_TRT) and
     8656             (r_ixr_cmd_fsm.read() != IXR_CMD_WRITE_TRT) and
     8657             (r_ixr_cmd_fsm.read() != IXR_CMD_CAS_TRT) and
     8658             (r_ixr_cmd_fsm.read() != IXR_CMD_XRAM_TRT) and
     8659             (r_ixr_cmd_fsm.read() != IXR_CMD_CLEANUP_TRT) and
     8660             (r_ixr_cmd_fsm.read() != IXR_CMD_CONFIG_TRT))
     8661          {
     8662              if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     8663                 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     8664                  r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     8665
     8666              else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     8667                      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     8668                  r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     8669
     8670              else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     8671                  r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     8672
     8673
     8674              else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     8675                  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     8676
     8677              else if(r_read_fsm.read() == READ_TRT_LOCK)
     8678                  r_alloc_trt_fsm = ALLOC_TRT_READ;
     8679
     8680              else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     8681                      (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     8682                  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     8683
     8684              else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     8685                      (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     8686                  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     8687          }
     8688          break;
    86608689
    86618690    ////////////////////////
     
    86658694          (r_xram_rsp_fsm.read()  != XRAM_RSP_TRT_COPY)  and
    86668695          (r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_UPDT)  and
    8667           (r_xram_rsp_fsm.read()  != XRAM_RSP_INVAL_LOCK))
     8696          (r_xram_rsp_fsm.read()  != XRAM_RSP_IVT_LOCK))
    86688697      {
    86698698        if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     
    86858714          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    86868715
     8716        else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     8717          r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     8718 
     8719        else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8720               (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     8721               (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     8722               (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8723               (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     8724               (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     8725          r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     8726
    86878727        else
    86888728          m_cpt_trt_unused++;
     
    86978737          (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ))
    86988738      {
     8739        if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     8740          r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
    86998741       
    8700         if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     8742        else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
    87018743          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    87028744
     
    87118753                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    87128754          r_alloc_trt_fsm = ALLOC_TRT_CAS;
     8755
     8756        else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8757                (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     8758                (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     8759                (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8760                (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     8761                (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     8762          r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
    87138763
    87148764        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     
    87468796            (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    87478797          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    8748       }
    8749       break;
     8798
     8799        else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     8800          r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     8801
     8802        else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8803                (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     8804                (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     8805                (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8806                (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     8807                (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     8808          r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     8809      }
     8810      break;
     8811      //////////////////////
     8812      case ALLOC_TRT_CONFIG:
     8813          if((r_config_fsm.read() != CONFIG_TRT_LOCK) and
     8814             (r_config_fsm.read() != CONFIG_TRT_SET))
     8815          {
     8816              if(r_read_fsm.read() == READ_TRT_LOCK)
     8817                  r_alloc_trt_fsm = ALLOC_TRT_READ;
     8818
     8819              else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     8820                      (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     8821                  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     8822
     8823              else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     8824                      (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     8825                  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     8826
     8827              else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8828                      (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     8829                      (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     8830                      (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8831                      (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     8832                      (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     8833                  r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     8834
     8835              else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     8836                      (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     8837                  r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     8838
     8839              else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     8840                  r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     8841
     8842              else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     8843                      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     8844                  r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     8845          }
     8846          break;
     8847
    87508848
    87518849  } // end switch alloc_trt_fsm
     
    90349132  m_write_to_cc_send_srcid_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,
    90359133                                        write_to_cc_send_fifo_srcid );
    9036 #if L1_MULTI_CACHE
    9037   m_write_to_cc_send_cache_id_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,
    9038                                            write_to_cc_send_fifo_cache_id );
    9039 #endif
    90409134
    90419135  ////////////////////////////////////////////////////////////////////////////////////
     
    90479141  m_config_to_cc_send_srcid_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,
    90489142                                         config_to_cc_send_fifo_srcid );
    9049 #if L1_MULTI_CACHE
    9050   m_config_to_cc_send_cache_id_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,
    9051                                             config_to_cc_send_fifo_cache_id );
    9052 #endif
    90539143
    90549144  ////////////////////////////////////////////////////////////////////////////////////
     
    90609150  m_xram_rsp_to_cc_send_srcid_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,
    90619151                                           xram_rsp_to_cc_send_fifo_srcid );
    9062 #if L1_MULTI_CACHE
    9063   m_xram_rsp_to_cc_send_cache_id_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,
    9064                                               xram_rsp_to_cc_send_fifo_cache_id );
    9065 #endif
    90669152
    90679153  ////////////////////////////////////////////////////////////////////////////////////
     
    90739159  m_cas_to_cc_send_srcid_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,
    90749160                                      cas_to_cc_send_fifo_srcid );
    9075 #if L1_MULTI_CACHE
    9076   m_cas_to_cc_send_cache_id_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,
    9077                                          cas_to_cc_send_fifo_cache_id );
    9078 #endif
    9079 
    90809161  m_cpt_cycles++;
    90819162
     
    90899170  // Command signals on the p_vci_ixr port
    90909171  ////////////////////////////////////////////////////////////
    9091 
    9092   p_vci_ixr.be      = 0xFF;   // nor transmited to external ram
     9172  // DATA width is 8 bytes
     9173  // The following values are not transmitted to XRAM
     9174  //   p_vci_ixr.be
     9175  //   p_vci_ixr.pktid 
     9176  //   p_vci_ixr.cons
     9177  //   p_vci_ixr.wrap
     9178  //   p_vci_ixr.contig
     9179  //   p_vci_ixr.clen
     9180  //   p_vci_ixr.cfixed
     9181
     9182  p_vci_ixr.plen    = 64;
     9183  p_vci_ixr.srcid   = m_srcid_x;
     9184  p_vci_ixr.trdid   = r_ixr_cmd_trdid.read();
     9185  p_vci_ixr.address = (addr_t)r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2);
     9186  p_vci_ixr.be      = 0xFF;
    90939187  p_vci_ixr.pktid   = 0;
    9094   p_vci_ixr.srcid   = m_srcid_x;
    90959188  p_vci_ixr.cons    = false;
    90969189  p_vci_ixr.wrap    = false;
     
    90989191  p_vci_ixr.clen    = 0;
    90999192  p_vci_ixr.cfixed  = false;
    9100   p_vci_ixr.plen    = 64;
    9101 
    9102   if(r_ixr_cmd_fsm.read() == IXR_CMD_READ)
    9103   {
    9104     p_vci_ixr.cmd       = vci_param_ext::CMD_READ;
    9105     p_vci_ixr.cmdval    = true;
    9106     p_vci_ixr.address   = (addr_t)(r_read_to_ixr_cmd_nline.read() * m_words * 4);
    9107     p_vci_ixr.wdata     = 0;
    9108     p_vci_ixr.trdid     = r_read_to_ixr_cmd_trdid.read();
    9109     p_vci_ixr.eop       = true;
     9193
     9194  if ( (r_ixr_cmd_fsm.read() == IXR_CMD_READ_SEND) or
     9195       (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_SEND) or
     9196       (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_SEND) or
     9197       (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_SEND) or
     9198       (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_SEND) )
     9199   {
     9200      p_vci_ixr.cmdval    = true;
     9201   
     9202      if ( r_ixr_cmd_get.read() )  // GET
     9203      {
     9204          p_vci_ixr.cmd     = vci_param_ext::CMD_READ;
     9205          p_vci_ixr.wdata   = 0;
     9206          p_vci_ixr.eop     = true;
     9207      }
     9208      else                         // PUT
     9209      {
     9210          size_t word       = r_ixr_cmd_word.read();
     9211          p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
     9212          p_vci_ixr.wdata   = ((wide_data_t)(r_ixr_cmd_wdata[word].read()))  |
     9213                              ((wide_data_t)(r_ixr_cmd_wdata[word+1].read()) << 32);
     9214          p_vci_ixr.eop     = (word == (m_words-2));
     9215      }
    91109216  }
    9111   else if(r_ixr_cmd_fsm.read() == IXR_CMD_CAS)
    9112   {
    9113     if(r_cas_to_ixr_cmd_write.read())
    9114     {
    9115       size_t word       = r_ixr_cmd_cpt.read();
    9116       p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
    9117       p_vci_ixr.cmdval  = true;
    9118       p_vci_ixr.address = (addr_t)( (r_cas_to_ixr_cmd_nline.read() * m_words + word) * 4 );
    9119       p_vci_ixr.wdata   = ((wide_data_t)(r_cas_to_ixr_cmd_data[word].read()))  |
    9120                           ((wide_data_t)(r_cas_to_ixr_cmd_data[word+1].read()) << 32);
    9121       p_vci_ixr.trdid   = r_cas_to_ixr_cmd_trdid.read();
    9122       p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-2));
    9123     }
    9124     else
    9125     {
    9126       p_vci_ixr.cmd     = vci_param_ext::CMD_READ;
    9127       p_vci_ixr.cmdval  = true;
    9128       p_vci_ixr.address = (addr_t)(r_cas_to_ixr_cmd_nline.read() *m_words*4);
    9129       p_vci_ixr.wdata   = 0;
    9130       p_vci_ixr.trdid   = r_cas_to_ixr_cmd_trdid.read();
    9131       p_vci_ixr.eop     = true;
    9132     }
    9133   }
    9134   else if(r_ixr_cmd_fsm.read() == IXR_CMD_WRITE)
    9135   {
    9136     if(r_write_to_ixr_cmd_write.read())
    9137     {
    9138       p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
    9139       p_vci_ixr.cmdval  = true;
    9140       p_vci_ixr.address = (addr_t)( (r_write_to_ixr_cmd_nline.read() * m_words +
    9141                                      r_ixr_cmd_cpt.read()) * 4 );
    9142       p_vci_ixr.wdata   = ((wide_data_t)(r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    9143                           ((wide_data_t)(r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32));
    9144       p_vci_ixr.trdid   = r_write_to_ixr_cmd_trdid.read();
    9145       p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-2));
    9146     }
    9147     else
    9148     {
    9149       p_vci_ixr.cmd     = vci_param_ext::CMD_READ;
    9150       p_vci_ixr.cmdval  = true;
    9151       p_vci_ixr.address = (addr_t)(r_write_to_ixr_cmd_nline.read() *m_words*4);
    9152       p_vci_ixr.wdata   = 0;
    9153       p_vci_ixr.trdid   = r_write_to_ixr_cmd_trdid.read();
    9154       p_vci_ixr.eop     = true;
    9155     }
    9156   }
    9157   else if(r_ixr_cmd_fsm.read() == IXR_CMD_XRAM)
    9158   {
    9159     p_vci_ixr.cmd       = vci_param_ext::CMD_WRITE;
    9160     p_vci_ixr.cmdval    = true;
    9161     p_vci_ixr.address   = (addr_t)( (r_xram_rsp_to_ixr_cmd_nline.read() * m_words +
    9162                                    r_ixr_cmd_cpt.read()) * 4 );
    9163     p_vci_ixr.wdata     = ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    9164                           ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32));
    9165     p_vci_ixr.trdid     = r_xram_rsp_to_ixr_cmd_trdid.read();
    9166     p_vci_ixr.eop       = (r_ixr_cmd_cpt == (m_words-2));
    9167   }
    9168   else if (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_DATA)
     9217  else if (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_DATA_SEND)
    91699218  {
    91709219    p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
    91719220    p_vci_ixr.cmdval  = true;
    9172     p_vci_ixr.address = (addr_t)((r_cleanup_to_ixr_cmd_nline.read() * m_words + r_ixr_cmd_cpt.read()) * 4);
    9173     if (r_cleanup_to_ixr_cmd_ncc_l1_dirty.read()) //if L1 was dirty, the correct data is in the cleanup
    9174     {
    9175       p_vci_ixr.wdata   = ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    9176           ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32));
    9177       if(r_cleanup_to_ixr_cmd_nline.read() == 0x12bb)
    9178         std::cout << "IXR data dirty = " << std::hex << p_vci_ixr.wdata << std::dec << std::endl;
    9179     }
    9180     else //if L1 was not dirty, the data is in the L2
    9181     {
    9182       p_vci_ixr.wdata   = ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    9183           ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32));
    9184       if(r_cleanup_to_ixr_cmd_nline.read() == 0x12bb)
    9185         std::cout << "IXR data not dirty = " << std::hex << p_vci_ixr.wdata << std::dec << std::endl;
    9186     }
    9187     p_vci_ixr.trdid   = r_cleanup_to_ixr_cmd_trdid.read();
    9188     p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words - 2));
     9221    /*p_vci_ixr.address = (addr_t)((r_cleanup_to_ixr_cmd_nline.read() * m_words +
     9222                                    r_ixr_cmd_word.read()) * 4);*/
     9223    p_vci_ixr.address = (addr_t)r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2);
     9224    p_vci_ixr.wdata   = ((wide_data_t)(r_ixr_cmd_wdata[r_ixr_cmd_word.read()].read()) |
     9225          ((wide_data_t)(r_ixr_cmd_wdata[r_ixr_cmd_word.read() + 1].read()) << 32));
     9226    p_vci_ixr.trdid   = r_cleanup_to_ixr_cmd_index.read();
     9227    p_vci_ixr.eop     = (r_ixr_cmd_word == (m_words - 2));
    91899228  }
     9229
    91909230  else
    91919231  {
    9192     p_vci_ixr.cmdval    = false;
    9193     p_vci_ixr.cmd       = vci_param_ext::CMD_READ;
    9194     p_vci_ixr.address   = 0;
    9195     p_vci_ixr.wdata     = 0;
    9196     p_vci_ixr.trdid     = 0;
    9197     p_vci_ixr.eop       = false;
     9232     p_vci_ixr.cmdval    = false;
    91989233  }
    91999234
     
    92029237  ////////////////////////////////////////////////////
    92039238
    9204   if(((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and
    9205       (r_ixr_rsp_fsm.read()   == IXR_RSP_TRT_READ)) or
    9206       (r_ixr_rsp_fsm.read()   == IXR_RSP_ACK))
    9207 
    9208     p_vci_ixr.rspack = true;
    9209 
    9210   else
    9211     p_vci_ixr.rspack = false;
     9239  if( (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ) or
     9240      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) )
     9241  {
     9242      p_vci_ixr.rspack = (r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP);
     9243  }
     9244  else if (r_ixr_rsp_fsm.read() == IXR_RSP_ACK)
     9245  {
     9246      p_vci_ixr.rspack = true;
     9247  }
     9248  else // r_ixr_rsp_fsm == IXR_RSP_IDLE
     9249  {
     9250      p_vci_ixr.rspack = false;
     9251  }
    92129252
    92139253  ////////////////////////////////////////////////////
     
    92799319    {
    92809320      p_vci_tgt.rspval  = true;
    9281       p_vci_tgt.rdata   = 0;
     9321      p_vci_tgt.rdata   = r_tgt_cmd_to_tgt_rsp_rdata.read();
    92829322      p_vci_tgt.rsrcid  = r_tgt_cmd_to_tgt_rsp_srcid.read();
    92839323      p_vci_tgt.rtrdid  = r_tgt_cmd_to_tgt_rsp_trdid.read();
     
    99049944  ////////////////////////////////////////////////////////////////////
    99059945
    9906   switch(r_cleanup_fsm.read())
     9946  if ( r_cleanup_fsm.read() == CLEANUP_SEND_CLACK )
    99079947  {
    9908     case CLEANUP_IDLE:
    9909     case CLEANUP_GET_NLINE:
    9910     case CLEANUP_DIR_REQ:
    9911     case CLEANUP_DIR_LOCK:
    9912     case CLEANUP_DIR_WRITE:
    9913     case CLEANUP_HEAP_REQ:
    9914     case CLEANUP_HEAP_LOCK:
    9915     case CLEANUP_HEAP_SEARCH:
    9916     case CLEANUP_HEAP_CLEAN:
    9917     case CLEANUP_HEAP_FREE:
    9918     case CLEANUP_IVT_LOCK:
    9919     case CLEANUP_IVT_DECREMENT:
    9920     case CLEANUP_IVT_CLEAR:
    9921     case CLEANUP_WRITE_RSP:
    9922     case CLEANUP_CONFIG_ACK:
    9923       p_dspin_clack.write = false;
    9924       p_dspin_clack.eop   = false;
    9925       p_dspin_clack.data  = 0;
    9926 
    9927       break;
    9928 
    9929     case CLEANUP_SEND_CLACK:
    9930       {
    9931         uint8_t cleanup_ack_type;
    9932         if(r_cleanup_inst.read())
    9933         {
     9948      uint8_t cleanup_ack_type;
     9949      if(r_cleanup_inst.read())
     9950      {
    99349951          cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_INST;
    9935         }
    9936         else
    9937         {
     9952      }
     9953      else
     9954      {
    99389955          cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_DATA;
    9939         }
    9940 
    9941         uint64_t flit = 0;
    9942         uint64_t dest =
    9943           r_cleanup_srcid.read() <<
     9956      }
     9957
     9958      uint64_t flit = 0;
     9959      uint64_t dest = r_cleanup_srcid.read() <<
    99449960          (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
    99459961
     
    99649980            DspinDhccpParam::CLACK_TYPE);
    99659981
    9966         p_dspin_clack.eop   = true;
    9967         p_dspin_clack.write = true;
    9968         p_dspin_clack.data  = flit;
    9969       }
    9970       break;
     9982      p_dspin_clack.eop   = true;
     9983      p_dspin_clack.write = true;
     9984      p_dspin_clack.data  = flit;
    99719985  }
    9972 
     9986  else
     9987  {
     9988      p_dspin_clack.write = false;
     9989      p_dspin_clack.eop   = false;
     9990      p_dspin_clack.data  = 0;
     9991  }
    99739992  ///////////////////////////////////////////////////////////////////
    99749993  //  p_dspin_p2m port (CC_RECEIVE FSM)
Note: See TracChangeset for help on using the changeset viewer.