Ignore:
Timestamp:
Jul 19, 2013, 2:34:03 PM (11 years ago)
Author:
devigne
Message:

Introducing merged components between the last trunk TSAR version
and the ODCCP modifications

Location:
branches/ODCCP/modules/vci_mem_cache
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/ODCCP/modules/vci_mem_cache/caba/source/include/mem_cache_directory.h

    r449 r460  
    9999    bool    dirty;                  // entry dirty
    100100    bool    lock;                   // entry locked
     101    bool    coherent;               // entry coherent or not
    101102    tag_t   tag;                    // tag of the entry
    102103    size_t  count;                  // number of copies
     
    110111      dirty         = false;
    111112      lock          = false;
     113      coherent      = true;
    112114      tag           = 0;
    113115      count         = 0;
     
    126128      dirty         = source.dirty;
    127129      lock          = source.lock;
     130      coherent      = source.coherent;
    128131      tag           = source.tag;
    129132      count         = source.count;
     
    141144      dirty     = false;
    142145      lock      = false;
     146      coherent  = true;
    143147      count     = 0;
    144148    }
     
    153157      dirty         = source.dirty;
    154158      lock          = source.lock;
     159      coherent  = source.coherent;
    155160      tag           = source.tag;
    156161      count     = source.count;
  • branches/ODCCP/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h

    r449 r460  
    254254        IXR_CMD_CAS_IDLE,
    255255        IXR_CMD_XRAM_IDLE,
     256        IXR_CMD_CLEANUP_IDLE,
    256257        IXR_CMD_READ,
    257258        IXR_CMD_WRITE,
    258259        IXR_CMD_CAS,
    259         IXR_CMD_XRAM
     260        IXR_CMD_XRAM,
     261        IXR_CMD_CLEANUP_DATA
    260262      };
    261263
     
    291293        CLEANUP_IDLE,
    292294        CLEANUP_GET_NLINE,
     295        CLEANUP_GET_DATA,
    293296        CLEANUP_DIR_REQ,
    294297        CLEANUP_DIR_LOCK,
     
    304307        CLEANUP_WRITE_RSP,
    305308        CLEANUP_CONFIG_ACK,
     309        CLEANUP_IXR_REQ,
     310        CLEANUP_WAIT,
    306311        CLEANUP_SEND_CLACK
    307312      };
     
    326331        ALLOC_TRT_CAS,
    327332        ALLOC_TRT_XRAM_RSP,
    328         ALLOC_TRT_IXR_RSP
     333        ALLOC_TRT_IXR_RSP,
     334        ALLOC_TRT_CLEANUP
    329335      };
    330336
     
    425431      uint32_t     m_cpt_inval_brdcast; // Number of BROADCAST INVAL
    426432      uint32_t     m_cpt_cleanup;       // Number of CLEANUP transactions
     433      uint32_t     m_cpt_cleanup_data;  // Number of CLEANUP WITH DATA transactions
    427434      uint32_t     m_cpt_ll;            // Number of LL transactions
    428435      uint32_t     m_cpt_sc;            // Number of SC transactions
    429436      uint32_t     m_cpt_cas;           // Number of CAS transactions
     437     
     438      uint32_t     m_cpt_read_fsm_dir_lock;        // wait DIR LOCK
     439      uint32_t     m_cpt_read_fsm_n_dir_lock;      // NB DIR LOCK
     440      uint32_t     m_cpt_write_fsm_dir_lock;       // wait DIR LOCK
     441      uint32_t     m_cpt_write_fsm_n_dir_lock;     // NB DIR LOCK
     442      uint32_t     m_cpt_xram_rsp_fsm_dir_lock;    // wait DIR LOCK
     443      uint32_t     m_cpt_xram_rsp_fsm_n_dir_lock;  // NB DIR LOCK
     444      uint32_t     m_cpt_cas_fsm_dir_lock;         // wait DIR LOCK
     445      uint32_t     m_cpt_cas_fsm_n_dir_lock;       // NB DIR LOCK
     446      uint32_t     m_cpt_cleanup_fsm_dir_lock;     // wait DIR LOCK
     447      uint32_t     m_cpt_cleanup_fsm_n_dir_lock;   // NB DIR LOCK
     448     
     449      uint32_t     m_cpt_dir_unused;            // NB cycles DIR LOCK unused
     450      uint32_t     m_cpt_read_fsm_dir_used;     // NB cycles DIR LOCK used
     451      uint32_t     m_cpt_write_fsm_dir_used;    // NB cycles DIR LOCK used
     452      uint32_t     m_cpt_cas_fsm_dir_used;      // NB cycles DIR LOCK used
     453      uint32_t     m_cpt_xram_rsp_fsm_dir_used; // NB cycles DIR LOCK used
     454      uint32_t     m_cpt_cleanup_fsm_dir_used;  // NB cycles DIR LOCK used
     455
     456      uint32_t     m_cpt_read_fsm_trt_lock;      // wait TRT LOCK
     457      uint32_t     m_cpt_write_fsm_trt_lock;     // wait TRT LOCK
     458      uint32_t     m_cpt_cas_fsm_trt_lock;       // wait TRT LOCK
     459      uint32_t     m_cpt_xram_rsp_fsm_trt_lock;  // wait TRT LOCK
     460      uint32_t     m_cpt_ixr_fsm_trt_lock;       // wait TRT LOCK
     461     
     462      uint32_t     m_cpt_read_fsm_n_trt_lock;      // NB TRT LOCK
     463      uint32_t     m_cpt_write_fsm_n_trt_lock;     // NB TRT LOCK
     464      uint32_t     m_cpt_cas_fsm_n_trt_lock;       // NB TRT LOCK
     465      uint32_t     m_cpt_xram_rsp_fsm_n_trt_lock;  // NB TRT LOCK
     466      uint32_t     m_cpt_ixr_fsm_n_trt_lock;       // NB TRT LOCK
     467
     468      uint32_t     m_cpt_read_fsm_trt_used;      // NB cycles TRT LOCK used
     469      uint32_t     m_cpt_write_fsm_trt_used;     // NB cycles TRT LOCK used
     470      uint32_t     m_cpt_cas_fsm_trt_used;       // NB cycles TRT LOCK used
     471      uint32_t     m_cpt_xram_rsp_fsm_trt_used;  // NB cycles TRT LOCK used
     472      uint32_t     m_cpt_ixr_fsm_trt_used;       // NB cycles TRT LOCK used
     473     
     474      uint32_t     m_cpt_trt_unused;            // NB cycles TRT LOCK unused
     475
     476      uint32_t     m_cpt_write_fsm_upt_lock;     // wait UPT LOCK
     477      uint32_t     m_cpt_xram_rsp_fsm_upt_lock;  // wait UPT LOCK
     478      uint32_t     m_cpt_multi_ack_fsm_upt_lock; // wait UPT LOCK
     479      uint32_t     m_cpt_cleanup_fsm_upt_lock;   // wait UPT LOCK
     480      uint32_t     m_cpt_cas_fsm_upt_lock;       // wait UPT LOCK
     481     
     482      uint32_t     m_cpt_write_fsm_n_upt_lock;     // NB UPT LOCK
     483      uint32_t     m_cpt_xram_rsp_fsm_n_upt_lock;  // NB UPT LOCK
     484      uint32_t     m_cpt_multi_ack_fsm_n_upt_lock; // NB UPT LOCK
     485      uint32_t     m_cpt_cleanup_fsm_n_upt_lock;   // NB UPT LOCK
     486      uint32_t     m_cpt_cas_fsm_n_upt_lock;       // NB UPT LOCK
     487     
     488      uint32_t     m_cpt_write_fsm_upt_used;     // NB cycles UPT LOCK used
     489      uint32_t     m_cpt_xram_rsp_fsm_upt_used;  // NB cycles UPT LOCK used
     490      uint32_t     m_cpt_multi_ack_fsm_upt_used; // NB cycles UPT LOCK used
     491      uint32_t     m_cpt_cleanup_fsm_upt_used;   // NB cycles UPT LOCK used
     492      uint32_t     m_cpt_cas_fsm_upt_used;       // NB cycles UPT LOCK used
     493     
     494      uint32_t     m_cpt_upt_unused;            // NB cycles UPT LOCK unused
     495
     496      uint32_t     m_cpt_read_fsm_heap_lock;     // wait HEAP LOCK
     497      uint32_t     m_cpt_write_fsm_heap_lock;    // wait HEAP LOCK
     498      uint32_t     m_cpt_cas_fsm_heap_lock;      // wait HEAP LOCK
     499      uint32_t     m_cpt_cleanup_fsm_heap_lock;  // wait HEAP LOCK
     500      uint32_t     m_cpt_xram_rsp_fsm_heap_lock; // wait HEAP LOCK
     501     
     502      uint32_t     m_cpt_read_fsm_n_heap_lock;     // NB HEAP LOCK
     503      uint32_t     m_cpt_write_fsm_n_heap_lock;    // NB HEAP LOCK
     504      uint32_t     m_cpt_cas_fsm_n_heap_lock;      // NB HEAP LOCK
     505      uint32_t     m_cpt_cleanup_fsm_n_heap_lock;  // NB HEAP LOCK
     506      uint32_t     m_cpt_xram_rsp_fsm_n_heap_lock; // NB HEAP LOCK
     507     
     508      uint32_t     m_cpt_read_fsm_heap_used;     // NB cycles HEAP LOCK used
     509      uint32_t     m_cpt_write_fsm_heap_used;    // NB cycles HEAP LOCK used
     510      uint32_t     m_cpt_cas_fsm_heap_used;      // NB cycles HEAP LOCK used
     511      uint32_t     m_cpt_cleanup_fsm_heap_used;  // NB cycles HEAP LOCK used
     512      uint32_t     m_cpt_xram_rsp_fsm_heap_used; // NB cycles HEAP LOCK used
     513     
     514      uint32_t     m_cpt_heap_unused;            // NB cycles HEAP LOCK unused
    430515
    431516      uint32_t     m_cpt_cleanup_cost;  // Number of (flits * distance) for CLEANUPs
     
    473558      ~VciMemCache();
    474559
     560      void clear_stats();
    475561      void print_stats();
    476562      void print_trace();
     
    852938      // Buffer between IXR_RSP fsm and XRAM_RSP fsm  (response from the XRAM)
    853939      sc_signal<bool>   * r_ixr_rsp_to_xram_rsp_rok; // A xram response is ready
     940      sc_signal<bool>   * r_ixr_rsp_to_xram_rsp_no_coherent; // A xram response is ready and no coherent (ODCCP)
    854941
    855942      ////////////////////////////////////////////////////
     
    861948      TransactionTabEntry r_xram_rsp_trt_buf;           // TRT entry local buffer
    862949      sc_signal<bool>     r_xram_rsp_victim_inval;      // victim line invalidate
     950      sc_signal<bool>     r_xram_rsp_victim_coherent;   // victim line coherent
    863951      sc_signal<bool>     r_xram_rsp_victim_is_cnt;     // victim line inst bit
    864952      sc_signal<bool>     r_xram_rsp_victim_dirty;      // victim line dirty bit
     
    9581046      sc_signal<int>      r_alloc_heap_fsm;
    9591047      sc_signal<unsigned> r_alloc_heap_reset_cpt;
     1048
     1049
     1050      ////////////////////////////////////////////////////
     1051      // REGISTERS FOR ODCCP
     1052      ////////////////////////////////////////////////////
     1053
     1054      sc_signal<uint32_t>  r_cleanup_data_index;
     1055      sc_signal<uint32_t>  r_cleanup_trdid;
     1056      sc_signal<uint32_t>  r_cleanup_pktid;
     1057      sc_signal<data_t>    *r_cleanup_data;          // buffer for saving data from cleanup
     1058      sc_signal<bool>      r_cleanup_contains_data;
     1059      sc_signal<bool>      r_cleanup_ncc;
     1060     
     1061      sc_signal<bool>      r_xram_rsp_to_ixr_cmd_inval_ncc_pending;
     1062     
     1063      sc_signal<bool>      r_cleanup_to_ixr_cmd_req;
     1064      sc_signal<data_t>    *r_cleanup_to_ixr_cmd_data;
     1065      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_srcid;
     1066      sc_signal<bool>      r_cleanup_to_ixr_cmd_l1_dirty_ncc; // this cleanup was dirty in L1
     1067      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_trdid;
     1068      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_pktid;
     1069      sc_signal<addr_t>    r_cleanup_to_ixr_cmd_nline;
    9601070    }; // end class VciMemCache
    9611071
  • branches/ODCCP/modules/vci_mem_cache/caba/source/include/xram_transaction.h

    r422 r460  
    293293        return false;
    294294    }
     295   
     296    ///////////////////////////////////////////////////////////////////////
     297    // The hit_write() function looks if an XRAM write transaction exists
     298    // for a given line.
     299    // Arguments :
     300    // - nline : the index (zy) of the requested line
     301    // The function returns true if a write request has already been sent
     302    ///////////////////////////////////////////////////////////////////////
     303    bool hit_write(const addr_t nline, size_t *index)
     304    {
     305        for(size_t i=0; i<size_tab; i++){
     306            if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read)) {
     307                *index = i;
     308                return true;   
     309            }
     310        }
     311        return false;
     312    }
    295313
    296314    /////////////////////////////////////////////////////////////////////
  • branches/ODCCP/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r449 r460  
    217217  "IXR_CMD_CAS_IDLE",
    218218  "IXR_CMD_XRAM_IDLE",
     219  "IXR_CMD_CLEANUP_IDLE",
    219220  "IXR_CMD_READ",
    220221  "IXR_CMD_WRITE",
    221222  "IXR_CMD_CAS",
    222   "IXR_CMD_XRAM"
     223  "IXR_CMD_XRAM",
     224  "IXR_CMD_CLEANUP_DATA"
    223225};
    224226const char *cas_fsm_str[] =
     
    250252  "CLEANUP_IDLE",
    251253  "CLEANUP_GET_NLINE",
     254  "CLEANUP_GET_DATA",
    252255  "CLEANUP_DIR_REQ",
    253256  "CLEANUP_DIR_LOCK",
     
    263266  "CLEANUP_WRITE_RSP",
    264267  "CLEANUP_CONFIG_ACK",
     268  "CLEANUP_IXR_REQ",
     269  "CLEANUP_WAIT",
    265270  "CLEANUP_SEND_CLACK"
    266271};
     
    280285  "ALLOC_TRT_CAS",
    281286  "ALLOC_TRT_XRAM_RSP",
    282   "ALLOC_TRT_IXR_RSP"
     287  "ALLOC_TRT_IXR_RSP",
     288  "ALLOC_TRT_CLEANUP"
    283289};
    284290const char *alloc_upt_fsm_str[] =
     
    333339  : soclib::caba::BaseModule(name),
    334340
     341    m_monitor_ok(false),
     342   
    335343    p_clk( "p_clk" ),
    336344    p_resetn( "p_resetn" ),
     
    496504    // Allocation for IXR_RSP FSM
    497505    r_ixr_rsp_to_xram_rsp_rok  = new sc_signal<bool>[m_trt_lines];
     506    //r_ixr_rsp_to_xram_rsp_no_coherent  = new sc_signal<bool>[m_trt_lines];
    498507
    499508    // Allocation for XRAM_RSP FSM
     
    517526    r_cas_data                 = new sc_signal<data_t>[nwords];
    518527    r_cas_rdata                = new sc_signal<data_t>[2];
     528
     529    // Allocation for ODCCP
     530    r_cleanup_data             = new sc_signal<data_t>[nwords];
     531    r_cleanup_to_ixr_cmd_data  = new sc_signal<data_t>[nwords];
    519532
    520533    // Allocation for debug
     
    631644
    632645/////////////////////////////////////////
     646tmpl(void) ::clear_stats()
     647/////////////////////////////////////////
     648{
     649    m_cpt_cycles                  = 0;
     650    m_cpt_read                    = 0;
     651    m_cpt_read_miss               = 0;
     652    m_cpt_write                   = 0;
     653    m_cpt_write_miss              = 0;
     654    m_cpt_write_cells             = 0;
     655    m_cpt_write_dirty             = 0;
     656    m_cpt_update                  = 0;
     657    m_cpt_update_mult             = 0;
     658    m_cpt_inval_brdcast           = 0;
     659    m_cpt_inval                   = 0;
     660    m_cpt_inval_mult              = 0;
     661    m_cpt_cleanup                 = 0;
     662    m_cpt_cleanup_data            = 0;
     663    m_cpt_ll                      = 0;
     664    m_cpt_sc                      = 0;
     665    m_cpt_cas                     = 0;
     666    m_cpt_trt_full                = 0;
     667    m_cpt_trt_rb                  = 0;
     668    m_cpt_dir_unused              = 0;
     669    m_cpt_upt_unused              = 0;
     670    m_cpt_heap_unused             = 0;
     671    m_cpt_trt_unused              = 0;
     672    m_cpt_read_fsm_n_dir_lock     = 0;
     673    m_cpt_read_fsm_dir_lock       = 0;
     674    m_cpt_read_fsm_dir_used       = 0;
     675    m_cpt_read_fsm_trt_lock       = 0;
     676    m_cpt_read_fsm_heap_lock      = 0;
     677    m_cpt_write_fsm_dir_lock      = 0;
     678    m_cpt_write_fsm_n_dir_lock    = 0;
     679    m_cpt_write_fsm_upt_lock      = 0;
     680    m_cpt_write_fsm_heap_lock     = 0;
     681    m_cpt_write_fsm_dir_used      = 0;
     682    m_cpt_write_fsm_trt_lock      = 0;
     683    m_cpt_cas_fsm_n_dir_lock      = 0;
     684    m_cpt_cas_fsm_dir_lock        = 0;
     685    m_cpt_cas_fsm_upt_lock        = 0;
     686    m_cpt_cas_fsm_heap_lock       = 0;
     687    m_cpt_cas_fsm_trt_lock        = 0;
     688    m_cpt_cas_fsm_dir_used        = 0;
     689    m_cpt_xram_rsp_fsm_n_dir_lock = 0;
     690    m_cpt_xram_rsp_fsm_dir_lock   = 0;
     691    m_cpt_xram_rsp_fsm_trt_lock   = 0;
     692    m_cpt_xram_rsp_fsm_upt_lock   = 0;
     693    m_cpt_xram_rsp_fsm_heap_lock  = 0;
     694    m_cpt_xram_rsp_fsm_dir_used   = 0;
     695    m_cpt_cleanup_fsm_dir_lock    = 0;
     696    m_cpt_cleanup_fsm_n_dir_lock  = 0;
     697    m_cpt_cleanup_fsm_heap_lock   = 0;
     698    m_cpt_cleanup_fsm_upt_lock    = 0;
     699    m_cpt_cleanup_fsm_dir_used    = 0;
     700    m_cpt_ixr_fsm_trt_lock        = 0;
     701    m_cpt_multi_ack_fsm_upt_lock  = 0;
     702}
     703/////////////////////////////////////////
    633704tmpl(void) ::print_stats()
    634705/////////////////////////////////////////
     
    637708  std::cout
    638709      << "MEM_CACHE " << name() << " / Time = " << m_cpt_cycles << std::endl
    639       << "- READ RATE            = " << (double) m_cpt_read/m_cpt_cycles << std::endl
    640       << "- READ TOTAL           = " << m_cpt_read << std::endl
    641       << "- READ MISS RATE       = " << (double) m_cpt_read_miss/m_cpt_read << std::endl
    642       << "- WRITE RATE           = " << (double) m_cpt_write/m_cpt_cycles << std::endl
    643       << "- WRITE TOTAL          = " << m_cpt_write << std::endl
    644       << "- WRITE MISS RATE      = " << (double) m_cpt_write_miss/m_cpt_write << std::endl
    645       << "- WRITE BURST LENGTH   = " << (double) m_cpt_write_cells/m_cpt_write << std::endl
    646       << "- WRITE BURST TOTAL    = " << m_cpt_write_cells << std::endl
    647       << "- REQUESTS TRT FULL    = " << m_cpt_trt_full << std::endl
    648       << "- READ TRT BLOKED HIT  = " << m_cpt_trt_rb << std::endl
    649       << "- UPDATE RATE          = " << (double) m_cpt_update/m_cpt_cycles << std::endl
    650       << "- UPDATE ARITY         = " << (double) m_cpt_update_mult/m_cpt_update << std::endl
    651       << "- INVAL MULTICAST RATE = " << (double)(m_cpt_inval-m_cpt_inval_brdcast) /m_cpt_cycles << std::endl
    652       << "- INVAL MULTICAST ARITY= " << (double) m_cpt_inval_mult/ (m_cpt_inval-m_cpt_inval_brdcast) << std::endl
    653       << "- INVAL BROADCAST RATE = " << (double) m_cpt_inval_brdcast/m_cpt_cycles << std::endl
    654       << "- SAVE DIRTY RATE      = " << (double) m_cpt_write_dirty/m_cpt_cycles << std::endl
    655       << "- CLEANUP RATE         = " << (double) m_cpt_cleanup/m_cpt_cycles << std::endl
    656       << "- LL RATE              = " << (double) m_cpt_ll/m_cpt_cycles << std::endl
    657       << "- SC RATE              = " << (double) m_cpt_sc/m_cpt_cycles << std::endl
    658       << "- CAS RATE             = " << (double) m_cpt_cas/m_cpt_cycles << std::endl;
     710      << "- READ RATE                              = " << (double) m_cpt_read/m_cpt_cycles << std::endl
     711      << "- READ TOTAL                             = " << m_cpt_read << std::endl
     712      << "- READ MISS RATE                         = " << (double) m_cpt_read_miss/m_cpt_read << std::endl
     713      << "- WRITE RATE                             = " << (double) m_cpt_write/m_cpt_cycles << std::endl
     714      << "- WRITE TOTAL                            = " << m_cpt_write << std::endl
     715      << "- WRITE MISS RATE                        = " << (double) m_cpt_write_miss/m_cpt_write << std::endl
     716      << "- WRITE BURST LENGTH                     = " << (double) m_cpt_write_cells/m_cpt_write << std::endl
     717      << "- WRITE BURST TOTAL                      = " << m_cpt_write_cells << std::endl
     718      << "- REQUESTS TRT FULL                      = " << m_cpt_trt_full << std::endl
     719      << "- READ TRT BLOKED HIT                    = " << m_cpt_trt_rb << std::endl
     720      << "- UPDATE RATE                            = " << (double) m_cpt_update/m_cpt_cycles << std::endl
     721      << "- UPDATE ARITY                           = " << (double) m_cpt_update_mult/m_cpt_update << std::endl
     722      << "- INVAL MULTICAST RATE                   = " << (double)(m_cpt_inval-m_cpt_inval_brdcast) /m_cpt_cycles << std::endl
     723      << "- INVAL MULTICAST ARITY                  = " << (double) m_cpt_inval_mult/ (m_cpt_inval-m_cpt_inval_brdcast) << std::endl
     724      << "- INVAL BROADCAST RATE                   = " << (double) m_cpt_inval_brdcast/m_cpt_cycles << std::endl
     725      << "- SAVE DIRTY RATE                        = " << (double) m_cpt_write_dirty/m_cpt_cycles << std::endl
     726      << "- CLEANUP RATE                           = " << (double) m_cpt_cleanup/m_cpt_cycles << std::endl
     727      << "- CLEANUP TOTAL                          = " << (double) m_cpt_cleanup << std::endl
     728      << "- CLEANUP WITH DATA RATE                 = " << (double) m_cpt_cleanup_data/m_cpt_cycles << std::endl
     729      << "- CLEANUP WITH DATA TOTAL                = " << (double) m_cpt_cleanup_data << std::endl
     730      << "- LL RATE                                = " << (double) m_cpt_ll/m_cpt_cycles << std::endl
     731      << "- SC RATE                                = " << (double) m_cpt_sc/m_cpt_cycles << std::endl
     732      << "- CAS RATE                               = " << (double) m_cpt_cas/m_cpt_cycles << std::endl << std::endl;
     733
     734     /* << "- WAIT DIR LOCK in READ_FSM              = " << (double) m_cpt_read_fsm_dir_lock/m_cpt_read_fsm_n_dir_lock << std::endl
     735      << "- NB CYCLES IN DIR LOCK in READ_FSM      = " << (double) m_cpt_read_fsm_dir_used/m_cpt_read_fsm_n_dir_lock << std::endl
     736      << "- WAIT DIR LOCK in WRITE_FSM             = " << (double) m_cpt_write_fsm_dir_lock/m_cpt_write_fsm_n_dir_lock << std::endl
     737      << "- NB CYCLES IN DIR LOCK in WRITE_FSM     = " << (double) m_cpt_write_fsm_dir_used/m_cpt_write_fsm_n_dir_lock << std::endl
     738      << "- WAIT DIR LOCK in XRAM_FSM              = " << (double) m_cpt_xram_rsp_fsm_dir_lock/m_cpt_xram_rsp_fsm_n_dir_lock << std::endl
     739      << "- NB CYCLES IN DIR LOCK in XRAM_FSM      = " << (double) m_cpt_xram_rsp_fsm_dir_used/m_cpt_xram_rsp_fsm_n_dir_lock << std::endl
     740      << "- WAIT DIR LOCK in CLEANUP_FSM           = " << (double) m_cpt_cleanup_fsm_dir_lock/m_cpt_cleanup_fsm_n_dir_lock << std::endl
     741      << "- NB CYCLES IN DIR LOCK in CLEANUP_FSM   = " << (double) m_cpt_cleanup_fsm_dir_used/m_cpt_cleanup_fsm_n_dir_lock << std::endl
     742      << "- WAIT DIR LOCK in CAS_FSM               = " << (double) m_cpt_cas_fsm_dir_lock/m_cpt_cas_fsm_n_dir_lock << std::endl
     743      << "- NB CYCLES IN LOCK in CAS_FSM           = " << (double) m_cpt_cas_fsm_dir_used/m_cpt_cas_fsm_n_dir_lock << std::endl
     744      << "- DIR UNUSED RATE                        = " << (double) m_cpt_dir_unused/m_cpt_cycles << std::endl << std::endl
     745     
     746      << "- WAIT TRT LOCK in READ_FSM              = " << (double) m_cpt_read_fsm_trt_lock/m_cpt_read_fsm_n_trt_lock << std::endl
     747      << "- NB CYCLES IN TRT LOCK in READ_FSM      = " << (double) m_cpt_read_fsm_trt_used/m_cpt_read_fsm_n_trt_lock << std::endl
     748      << "- WAIT TRT LOCK in WRITE_FSM             = " << (double) m_cpt_write_fsm_trt_lock/m_cpt_write_fsm_n_trt_lock << std::endl
     749      << "- NB CYCLES IN TRT LOCK in WRITE_FSM     = " << (double) m_cpt_write_fsm_trt_used/m_cpt_write_fsm_n_trt_lock << std::endl
     750      << "- WAIT TRT LOCK in CAS_FSM               = " << (double) m_cpt_cas_fsm_trt_lock/m_cpt_cas_fsm_n_trt_lock << std::endl
     751      << "- NB CYCLES IN TRT LOCK in CAS_FSM       = " << (double) m_cpt_cas_fsm_trt_used/m_cpt_cas_fsm_n_trt_lock << std::endl
     752      << "- WAIT TRT LOCK in XRAM_FSM              = " << (double) m_cpt_xram_rsp_fsm_trt_lock/m_cpt_xram_rsp_fsm_n_trt_lock << std::endl
     753      << "- NB CYCLES IN TRT LOCK in XRAM_FSM      = " << (double) m_cpt_xram_rsp_fsm_trt_used/m_cpt_xram_rsp_fsm_n_trt_lock << std::endl
     754      << "- WAIT TRT LOCK in IXR_FSM               = " << (double) m_cpt_ixr_fsm_trt_lock/m_cpt_ixr_fsm_n_trt_lock << std::endl
     755      << "- NB CYCLES IN TRT LOCK in IXR_FSM       = " << (double) m_cpt_ixr_fsm_trt_used/m_cpt_ixr_fsm_n_trt_lock << std::endl
     756      << "- TRT UNUSED RATE                        = " << (double) m_cpt_trt_unused/m_cpt_cycles << std::endl << std::endl
     757     
     758      << "- WAIT UPT LOCK in WRITE_FSM             = " << (double) m_cpt_write_fsm_upt_lock/m_cpt_write_fsm_n_upt_lock << std::endl
     759      << "- NB CYCLES IN UPT LOCK in WRITE_FSM     = " << (double) m_cpt_write_fsm_upt_used/m_cpt_write_fsm_n_upt_lock << std::endl
     760      << "- WAIT UPT LOCK in XRAM_FSM              = " << (double) m_cpt_xram_rsp_fsm_upt_lock/m_cpt_xram_rsp_fsm_n_upt_lock << std::endl
     761      << "- NB CYCLES IN UPT LOCK in XRAM_FSM      = " << (double) m_cpt_xram_rsp_fsm_upt_used/m_cpt_xram_rsp_fsm_n_upt_lock << std::endl
     762      << "- WAIT UPT LOCK in MULTIACK_FSM          = " << (double) m_cpt_multi_ack_fsm_upt_lock/m_cpt_multi_ack_fsm_n_upt_lock << std::endl
     763      << "- NB CYCLES IN UPT LOCK in MULTIACK_FSM  = " << (double) m_cpt_multi_ack_fsm_upt_used/m_cpt_multi_ack_fsm_n_upt_lock << std::endl
     764      << "- WAIT UPT LOCK in CLEANUP_FSM           = " << (double) m_cpt_cleanup_fsm_upt_lock/m_cpt_cleanup_fsm_n_upt_lock << std::endl
     765      << "- NB CYCLES IN UPT LOCK in CLEANUP_FSM   = " << (double) m_cpt_cleanup_fsm_upt_used/m_cpt_cleanup_fsm_n_upt_lock << std::endl
     766      << "- WAIT UPT LOCK in CAS_FSM               = " << (double) m_cpt_cas_fsm_upt_lock/m_cpt_cas_fsm_n_upt_lock << std::endl
     767      << "- NB CYCLES IN UPT LOCK in CAS_FSM       = " << (double) m_cpt_cas_fsm_upt_used/m_cpt_cas_fsm_n_upt_lock << std::endl
     768      << "- UPT UNUSED RATE                        = " << (double) m_cpt_upt_unused/m_cpt_cycles << std::endl << std::endl
     769     
     770      << "- WAIT HEAP LOCK in READ_FSM             = " << (double) m_cpt_read_fsm_heap_lock/m_cpt_read_fsm_n_heap_lock << std::endl
     771      << "- NB CYCLES IN HEAP LOCK in READ_FSM     = " << (double) m_cpt_read_fsm_heap_used/m_cpt_read_fsm_n_heap_lock << std::endl
     772      << "- WAIT HEAP LOCK in WRITE_FSM            = " << (double) m_cpt_write_fsm_heap_lock/m_cpt_write_fsm_n_heap_lock << std::endl
     773      << "- NB CYCLES IN HEAP LOCK in WRITE_FSM    = " << (double) m_cpt_write_fsm_heap_used/m_cpt_write_fsm_n_heap_lock << std::endl
     774      << "- WAIT HEAP LOCK in XRAM_FSM             = " << (double) m_cpt_xram_rsp_fsm_heap_lock/m_cpt_xram_rsp_fsm_n_heap_lock << std::endl
     775      << "- NB CYCLES IN HEAP LOCK in XRAM_FSM     = " << (double) m_cpt_xram_rsp_fsm_heap_used/m_cpt_xram_rsp_fsm_n_heap_lock << std::endl
     776      << "- WAIT HEAP LOCK in CLEANUP_FSM          = " << (double) m_cpt_cleanup_fsm_heap_lock/m_cpt_cleanup_fsm_n_heap_lock << std::endl
     777      << "- NB CYCLES IN HEAP LOCK in CLEANUP_FSM  = " << (double) m_cpt_cleanup_fsm_heap_used/m_cpt_cleanup_fsm_n_heap_lock << std::endl
     778      << "- WAIT HEAP LOCK in CAS_FSM              = " << (double) m_cpt_cas_fsm_heap_lock/m_cpt_cas_fsm_n_heap_lock << std::endl
     779      << "- NB CYCLES IN HEAP LOCK in CAS_FSM      = " << (double) m_cpt_cas_fsm_heap_used/m_cpt_cas_fsm_n_heap_lock << std::endl
     780      << "- HEAP UNUSED RATE                       = " << (double) m_cpt_heap_unused/m_cpt_cycles << std::endl;*/
    659781}
    660782
     
    664786{
    665787  delete [] r_ixr_rsp_to_xram_rsp_rok;
     788  //delete [] r_ixr_rsp_to_xram_rsp_no_coherent;
    666789
    667790  delete [] r_xram_rsp_victim_data;
     
    675798  delete [] r_write_be;
    676799  delete [] r_write_to_cc_send_data;
     800
     801  delete [] r_cleanup_data;
     802  delete [] r_cleanup_to_ixr_cmd_data;
    677803}
    678804
     
    788914    {
    789915      r_ixr_rsp_to_xram_rsp_rok[i] = false;
     916      //r_ixr_rsp_to_xram_rsp_no_coherent[i] = false;
    790917    }
    791918
     
    808935    r_tgt_rsp_key_sent  = false;
    809936
     937    // ODCCP
     938    r_cleanup_data_index       = 0;
     939    r_cleanup_trdid            = 0;
     940    r_cleanup_pktid            = 0;
     941    r_cleanup_contains_data    = false;
     942    r_cleanup_to_ixr_cmd_req   = false;
     943    r_cleanup_to_ixr_cmd_l1_dirty_ncc = false;
     944    r_xram_rsp_to_ixr_cmd_inval_ncc_pending = false;
     945    r_cleanup_to_ixr_cmd_srcid = 0;
     946    r_cleanup_to_ixr_cmd_trdid = 0;
     947    r_cleanup_to_ixr_cmd_pktid = 0;
     948    r_cleanup_to_ixr_cmd_nline = 0;
     949    for (size_t word = 0; word < m_words; word ++)
     950    {
     951      r_cleanup_to_ixr_cmd_data[word] = 0;
     952      r_cleanup_data[word] = 0;
     953    }
     954
     955
    810956    // Activity counters
    811     m_cpt_cycles        = 0;
    812     m_cpt_read          = 0;
    813     m_cpt_read_miss     = 0;
    814     m_cpt_write         = 0;
    815     m_cpt_write_miss    = 0;
    816     m_cpt_write_cells   = 0;
    817     m_cpt_write_dirty   = 0;
    818     m_cpt_update        = 0;
    819     m_cpt_update_mult   = 0;
    820     m_cpt_inval_brdcast = 0;
    821     m_cpt_inval         = 0;
    822     m_cpt_inval_mult    = 0;
    823     m_cpt_cleanup       = 0;
    824     m_cpt_ll            = 0;
    825     m_cpt_sc            = 0;
    826     m_cpt_cas           = 0;
    827     m_cpt_trt_full      = 0;
    828     m_cpt_trt_rb        = 0;
     957    m_cpt_cycles                  = 0;
     958    m_cpt_read                    = 0;
     959    m_cpt_read_miss               = 0;
     960    m_cpt_write                   = 0;
     961    m_cpt_write_miss              = 0;
     962    m_cpt_write_cells             = 0;
     963    m_cpt_write_dirty             = 0;
     964    m_cpt_update                  = 0;
     965    m_cpt_update_mult             = 0;
     966    m_cpt_inval_brdcast           = 0;
     967    m_cpt_inval                   = 0;
     968    m_cpt_inval_mult              = 0;
     969    m_cpt_cleanup                 = 0;
     970    m_cpt_cleanup_data            = 0;
     971    m_cpt_ll                      = 0;
     972    m_cpt_sc                      = 0;
     973    m_cpt_cas                     = 0;
     974    m_cpt_trt_full                = 0;
     975    m_cpt_trt_rb                  = 0;
     976    m_cpt_dir_unused              = 0;
     977    m_cpt_upt_unused              = 0;
     978    m_cpt_heap_unused             = 0;
     979    m_cpt_trt_unused              = 0;
     980    m_cpt_read_fsm_n_dir_lock     = 0;
     981    m_cpt_read_fsm_dir_lock       = 0;
     982    m_cpt_read_fsm_dir_used       = 0;
     983    m_cpt_read_fsm_trt_lock       = 0;
     984    m_cpt_read_fsm_heap_lock      = 0;
     985    m_cpt_write_fsm_dir_lock      = 0;
     986    m_cpt_write_fsm_n_dir_lock    = 0;
     987    m_cpt_write_fsm_upt_lock      = 0;
     988    m_cpt_write_fsm_heap_lock     = 0;
     989    m_cpt_write_fsm_dir_used      = 0;
     990    m_cpt_write_fsm_trt_lock      = 0;
     991    m_cpt_cas_fsm_n_dir_lock      = 0;
     992    m_cpt_cas_fsm_dir_lock        = 0;
     993    m_cpt_cas_fsm_upt_lock        = 0;
     994    m_cpt_cas_fsm_heap_lock       = 0;
     995    m_cpt_cas_fsm_trt_lock        = 0;
     996    m_cpt_cas_fsm_dir_used        = 0;
     997    m_cpt_xram_rsp_fsm_n_dir_lock = 0;
     998    m_cpt_xram_rsp_fsm_dir_lock   = 0;
     999    m_cpt_xram_rsp_fsm_trt_lock   = 0;
     1000    m_cpt_xram_rsp_fsm_upt_lock   = 0;
     1001    m_cpt_xram_rsp_fsm_heap_lock  = 0;
     1002    m_cpt_xram_rsp_fsm_dir_used   = 0;
     1003    m_cpt_cleanup_fsm_dir_lock    = 0;
     1004    m_cpt_cleanup_fsm_n_dir_lock  = 0;
     1005    m_cpt_cleanup_fsm_heap_lock   = 0;
     1006    m_cpt_cleanup_fsm_upt_lock    = 0;
     1007    m_cpt_cleanup_fsm_dir_used    = 0;
     1008    m_cpt_ixr_fsm_trt_lock        = 0;
     1009    m_cpt_multi_ack_fsm_upt_lock  = 0;
    8291010
    8301011    return;
     
    13191500    case MULTI_ACK_UPT_LOCK:
    13201501    {
     1502        m_cpt_multi_ack_fsm_upt_lock++;
    13211503        // get lock to the UPDATE table
    1322         if(r_alloc_upt_fsm.read() != ALLOC_UPT_MULTI_ACK) break;
     1504        if(r_alloc_upt_fsm.read() != ALLOC_UPT_MULTI_ACK)  break;
    13231505
    13241506        // decrement the number of expected responses
    13251507        size_t count = 0;
    13261508        bool valid   = m_upt.decrement(r_multi_ack_upt_index.read(), count);
     1509
    13271510
    13281511        if(not valid)
     
    13491532          << " entry = "       << r_multi_ack_upt_index.read()
    13501533          << " / rsp_count = " << std::dec << count << std::endl;
     1534        m_cpt_multi_ack_fsm_n_upt_lock++;
    13511535#endif
    13521536        break;
     
    18742058      {
    18752059        r_read_fsm = READ_DIR_LOCK;
     2060        m_cpt_read_fsm_n_dir_lock++;
    18762061      }
    18772062
     
    18802065std::cout << "  <MEMC " << name() << " READ_DIR_REQ> Requesting DIR lock " << std::endl;
    18812066#endif
     2067
     2068      m_cpt_read_fsm_dir_lock++;
     2069
    18822070      break;
    18832071    }
     
    19812169            if(m_monitor_ok) check_monitor( m_cmd_read_addr_fifo.read(), r_read_data[0], true);
    19822170
    1983             // update the cache directory
    1984             DirectoryEntry entry;
    1985             entry.valid   = true;
    1986             entry.is_cnt  = is_cnt;
    1987             entry.dirty   = r_read_dirty.read();
    1988             entry.tag     = r_read_tag.read();
    1989             entry.lock    = r_read_lock.read();
    1990             entry.ptr     = r_read_ptr.read();
    1991 
    1992             if(cached_read)   // Cached read => we must update the copies
    1993             {
    1994                 if(!is_cnt)  // Not counter mode
    1995                 {
    1996                     entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
     2171        // update the cache directory
     2172        DirectoryEntry entry;
     2173        entry.valid    = true;
     2174        entry.is_cnt   = is_cnt;
     2175        entry.dirty    = r_read_dirty.read();
     2176        entry.tag      = r_read_tag.read();
     2177        entry.lock     = r_read_lock.read();
     2178        entry.ptr      = r_read_ptr.read();
     2179
     2180        /*ODCCP*/ // if pktid = 0x9 that means read on no coherent line
     2181        if(m_cmd_read_pktid_fifo.read() == 0x9){
     2182          entry.coherent = false;
     2183        }
     2184        else{
     2185          entry.coherent = true;
     2186        }
     2187       
     2188        if(cached_read)   // Cached read => we must update the copies
     2189        {
     2190          if(!is_cnt)  // Not counter mode
     2191          {
     2192            entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
    19972193#if L1_MULTI_CACHE
    1998                     entry.owner.cache_id = m_cmd_read_pktid_fifo.read();
    1999 #endif
    2000                     entry.owner.inst     = inst_read;
    2001                     entry.count          = r_read_count.read() + 1;
    2002                 }
    2003                 else  // Counter mode
    2004                 {
    2005                     entry.owner.srcid    = 0;
     2194            entry.owner.cache_id = m_cmd_read_pktid_fifo.read();
     2195#endif
     2196            entry.owner.inst     = inst_read;
     2197            entry.count          = r_read_count.read() + 1;
     2198          }
     2199          else  // Counter mode
     2200          {
     2201            entry.owner.srcid    = 0;
    20062202#if L1_MULTI_CACHE
    2007                     entry.owner.cache_id = 0;
    2008 #endif
    2009                     entry.owner.inst     = false;
    2010                     entry.count          = r_read_count.read() + 1;
    2011                 }
    2012             }
    2013             else            // Uncached read
    2014             {
    2015                 entry.owner.srcid     = r_read_copy.read();
     2203            entry.owner.cache_id = 0;
     2204#endif
     2205            entry.owner.inst     = false;
     2206            entry.count          = r_read_count.read() + 1;
     2207          }
     2208        }
     2209        else            // Uncached read
     2210        {
     2211          entry.owner.srcid     = r_read_copy.read();
    20162212#if L1_MULTI_CACHE
    2017                 entry.owner.cache_id  = r_read_copy_cache.read();
    2018 #endif
    2019                 entry.owner.inst      = r_read_copy_inst.read();
    2020                 entry.count           = r_read_count.read();
    2021             }
     2213          entry.owner.cache_id  = r_read_copy_cache.read();
     2214#endif
     2215          entry.owner.inst      = r_read_copy_inst.read();
     2216          entry.count           = r_read_count.read();
     2217        }
    20222218
    20232219#if DEBUG_MEMC_READ
     
    20332229#endif
    20342230
    2035             m_cache_directory.write(set, way, entry);
    2036             r_read_fsm    = READ_RSP;
    2037         }
    2038         break;
     2231          if(m_monitor_ok)
     2232          {
     2233            char buf[80];
     2234            snprintf(buf, 80, "READ_DIR_HIT srcid %d, ins %d",
     2235                     (int)m_cmd_read_srcid_fifo.read(),
     2236                     (int)((m_cmd_read_pktid_fifo.read()&0x2)!=0));
     2237            check_monitor(m_cmd_read_addr_fifo.read(), r_read_data[0], true);
     2238          }
     2239        m_cache_directory.write(set, way, entry);
     2240        r_read_fsm    = READ_RSP;
     2241      }
     2242      break;
    20392243    }
    20402244    ///////////////////
     
    20442248      {
    20452249        r_read_fsm = READ_HEAP_LOCK;
     2250        m_cpt_read_fsm_n_heap_lock++;
    20462251      }
    20472252
     
    20512256          << " Requesting HEAP lock " << std::endl;
    20522257#endif
     2258
     2259      m_cpt_read_fsm_heap_lock++;
     2260
    20532261      break;
    20542262    }
     
    22832491      {
    22842492        size_t      index     = 0;
     2493        size_t      index_write = 0;
    22852494        addr_t      addr      = (addr_t) m_cmd_read_addr_fifo.read();
    22862495        bool        hit_read  = m_trt.hit_read(m_nline[addr], index);
    2287         bool        hit_write = m_trt.hit_write(m_nline[addr]);
     2496        bool        hit_write = m_trt.hit_write(m_nline[addr], &index_write);
    22882497        bool        wok       = !m_trt.full(index);
    22892498
     
    23062515          << " hit_read = " << hit_read
    23072516          << " / hit_write = " << hit_write
     2517          << " / Index = " << index_write
    23082518          << " / full = " << !wok << std::endl;
    2309 #endif
    2310       }
     2519        m_cpt_read_fsm_n_trt_lock++;
     2520#endif
     2521      }
     2522
     2523      m_cpt_read_fsm_trt_lock++;
     2524
    23112525      break;
    23122526    }
     
    25332747
    25342748        r_write_fsm = WRITE_DIR_LOCK;
     2749        m_cpt_write_fsm_n_dir_lock++;
    25352750      }
    25362751
     
    25402755          << std::endl;
    25412756#endif
     2757
     2758      m_cpt_write_fsm_dir_lock++;
    25422759
    25432760      break;
     
    27923009        if(wok) r_write_fsm = WRITE_UPT_HEAP_LOCK;
    27933010        else    r_write_fsm = WRITE_WAIT;
    2794       }
     3011        m_cpt_write_fsm_n_upt_lock++;
     3012      }
     3013
     3014      m_cpt_write_fsm_upt_lock++;
     3015
    27953016      break;
    27963017    }
     
    28083029#endif
    28093030        r_write_fsm = WRITE_UPT_REQ;
    2810       }
     3031        m_cpt_write_fsm_n_heap_lock++;
     3032      }
     3033
     3034      m_cpt_write_fsm_heap_lock++;
     3035
    28113036      break;
    28123037    }
     
    30933318          m_cpt_trt_full++;
    30943319        }
    3095       }
     3320        m_cpt_write_fsm_n_trt_lock++;
     3321      }
     3322
     3323      m_cpt_write_fsm_trt_lock++;
     3324
    30963325      break;
    30973326    }
     
    32123441          << " : wok = " << wok << " / index = " << wok_index << std::endl;
    32133442#endif
    3214       }
     3443        m_cpt_write_fsm_n_trt_lock++;
     3444      }
     3445
     3446      m_cpt_write_fsm_trt_lock++;
     3447
    32153448      break;
    32163449    }
     
    32393472                        nb_copies,
    32403473                        index);
    3241 
    32423474#if DEBUG_MEMC_WRITE
    32433475if( m_debug and wok )
     
    32493481        if(wok) r_write_fsm = WRITE_BC_DIR_INVAL;
    32503482        else       r_write_fsm = WRITE_WAIT;
    3251       }
     3483        m_cpt_write_fsm_n_upt_lock++;
     3484      }
     3485
     3486      m_cpt_write_fsm_upt_lock++;
     3487
    32523488      break;
    32533489    }
     
    33823618    ////////////////////////
    33833619    case IXR_CMD_READ_IDLE:
    3384     {
    33853620      if     (r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
    33863621      else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    33873622      else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3623      else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
    33883624      else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    33893625      break;
    3390     }
    33913626    ////////////////////////
    33923627    case IXR_CMD_WRITE_IDLE:
    3393     {
    3394       if     (r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
     3628      if(r_cas_to_ixr_cmd_req)           r_ixr_cmd_fsm = IXR_CMD_CAS;
    33953629      else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3630      else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
    33963631      else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    33973632      else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
    33983633      break;
    3399     }
    34003634    ////////////////////////
    34013635    case IXR_CMD_CAS_IDLE:
    3402     {
    3403       if     (r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3636      if(r_xram_rsp_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3637      else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
    34043638      else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    34053639      else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
    34063640      else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    34073641      break;
    3408     }
    34093642    ////////////////////////
    34103643    case IXR_CMD_XRAM_IDLE:
    3411     {
    3412       if     (r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3413       else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
     3644      if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
     3645      else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
     3646      else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE;
    34143647      else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    34153648      else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
    34163649      break;
    3417     }
     3650      ////////////////////////
     3651    case IXR_CMD_CLEANUP_IDLE:
     3652      if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
     3653      else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE;
     3654      else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
     3655      else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3656      else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
     3657      break;     
    34183658    //////////////////       // send a get from READ FSM
    34193659    case IXR_CMD_READ:
     
    35413781      break;
    35423782    }
     3783
     3784      ////////////////////////
     3785    case IXR_CMD_CLEANUP_DATA:     // send a put command to XRAM
     3786      if(p_vci_ixr.cmdack)
     3787      {
     3788        if(r_ixr_cmd_cpt.read() == (m_words - 2))
     3789        {
     3790          r_ixr_cmd_cpt = 0;
     3791          r_ixr_cmd_fsm = IXR_CMD_CLEANUP_IDLE;
     3792          r_cleanup_to_ixr_cmd_req = false;
     3793          r_xram_rsp_to_ixr_cmd_inval_ncc_pending = false;
     3794        }
     3795        else
     3796        {
     3797          r_ixr_cmd_cpt = r_ixr_cmd_cpt.read() + 2;
     3798        }
     3799
     3800#if DEBUG_MEMC_IXR_CMD
     3801        if(m_debug)
     3802        {
     3803          std::cout << "  <MEMC " << name() << ".IXR_CMD_CLEANUP_DATA> Send a put request to xram" << std::endl;
     3804        }
     3805#endif
     3806      }
     3807      break;
    35433808
    35443809  } // end switch r_ixr_cmd_fsm
     
    36193884          << r_ixr_rsp_trt_index.read() << std::endl;
    36203885#endif
    3621       }
     3886      m_cpt_ixr_fsm_n_trt_lock++;
     3887      }
     3888
     3889      m_cpt_ixr_fsm_trt_lock++;
     3890
    36223891      break;
    36233892    }
     
    36453914        {
    36463915          r_ixr_rsp_to_xram_rsp_rok[r_ixr_rsp_trt_index.read()]=true;
     3916          /*if(p_vci_ixr.rpktid.read()&0xF == 0x9)
     3917            r_ixr_rsp_to_xram_rsp_no_coherent[r_ixr_rsp_trt_index.read()] = true;
     3918          else
     3919            r_ixr_rsp_to_xram_rsp_no_coherent[r_ixr_rsp_trt_index.read()] = false;*/
    36473920          r_ixr_rsp_fsm = IXR_RSP_IDLE;
    36483921        }
     
    36553928          << " / data = " << std::hex << data << std::endl;
    36563929#endif
    3657       }
     3930      m_cpt_ixr_fsm_n_trt_lock++;
     3931      }
     3932      m_cpt_ixr_fsm_trt_lock++;
    36583933      break;
    36593934    }
     
    37284003          << " Get access to DIR and TRT" << std::endl;
    37294004#endif
    3730       }
     4005        m_cpt_xram_rsp_fsm_n_dir_lock++;
     4006        m_cpt_xram_rsp_fsm_n_trt_lock++;
     4007      }
     4008      m_cpt_xram_rsp_fsm_dir_lock++;
     4009      m_cpt_xram_rsp_fsm_trt_lock++;
    37314010      break;
    37324011    }
     
    37544033        r_xram_rsp_victim_copy_cache= victim.owner.cache_id;
    37554034#endif
     4035       
     4036        r_xram_rsp_victim_coherent  = victim.coherent;
    37564037        r_xram_rsp_victim_copy_inst = victim.owner.inst;
    37574038        r_xram_rsp_victim_count     = victim.count;
     
    37644045        r_xram_rsp_victim_dirty     = victim.dirty;
    37654046
     4047
    37664048        if(!r_xram_rsp_trt_buf.rerror)
    37674049        {
    3768           r_xram_rsp_fsm = XRAM_RSP_INVAL_LOCK;
     4050          /*ODCCP*/ //if victim is no coherent and there is an inval no coherent pending we wait
     4051          if(!victim.coherent and r_xram_rsp_to_ixr_cmd_inval_ncc_pending.read())
     4052          {
     4053            r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
     4054          }
     4055          else
     4056          {
     4057            r_xram_rsp_fsm = XRAM_RSP_INVAL_LOCK;
     4058          }
    37694059        }
    37704060        else
     
    38294119#endif
    38304120        }
    3831       }
     4121        m_cpt_xram_rsp_fsm_n_upt_lock++;
     4122      }
     4123
     4124      m_cpt_xram_rsp_fsm_upt_lock++;
     4125
    38324126      break;
    38334127    }
     
    38924186        entry.owner.inst    = inst_read;
    38934187        entry.count         = 1;
     4188
    38944189      }
    38954190      else
     
    39024197        entry.count          = 0;
    39034198      }
     4199
     4200      /*ODCCP*/ //if pktid = 0x9 that means line no coherent
     4201      if(r_xram_rsp_trt_buf.pktid == 0x9){
     4202        entry.coherent = false;
     4203      }
     4204      else{
     4205        entry.coherent = true;
     4206      }
     4207
    39044208      m_cache_directory.write(set, way, entry);
    39054209
     
    39504254#endif
    39514255
    3952       // If the victim is not dirty, we don't need another XRAM put transaction,
     4256      // If the victim is not dirty and coherent or victim's count egal 0 , we don't need another XRAM put transaction,
    39534257      // and we can erase the TRT entry
    3954       if(!r_xram_rsp_victim_dirty.read())  m_trt.erase(r_xram_rsp_trt_index.read());
     4258      if(!r_xram_rsp_victim_dirty.read() and (r_xram_rsp_victim_coherent.read() or (r_xram_rsp_victim_count.read() == 0)))  m_trt.erase(r_xram_rsp_trt_index.read());
    39554259
    39564260      // Next state
    3957       if(r_xram_rsp_victim_dirty.read())       r_xram_rsp_fsm = XRAM_RSP_TRT_DIRTY;
     4261      if(r_xram_rsp_victim_dirty.read() or (!r_xram_rsp_victim_coherent.read() and (r_xram_rsp_victim_count.read() == 1)))       r_xram_rsp_fsm = XRAM_RSP_TRT_DIRTY;
    39584262      else if(r_xram_rsp_trt_buf.proc_read)    r_xram_rsp_fsm = XRAM_RSP_DIR_RSP;
    39594263      else if(r_xram_rsp_victim_inval.read())  r_xram_rsp_fsm = XRAM_RSP_INVAL;
     
    39874291        else if(r_xram_rsp_victim_inval.read())  r_xram_rsp_fsm = XRAM_RSP_INVAL;
    39884292        else                                     r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
    3989       }
     4293        m_cpt_xram_rsp_fsm_n_trt_lock++;
     4294      }
     4295
     4296      m_cpt_xram_rsp_fsm_trt_lock++;
     4297
    39904298      break;
    39914299    }
     
    40094317
    40104318        if(r_xram_rsp_victim_inval)      r_xram_rsp_fsm = XRAM_RSP_INVAL;
    4011         else if(r_xram_rsp_victim_dirty) r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
     4319        else if(r_xram_rsp_victim_dirty or (!r_xram_rsp_victim_coherent.read() and (r_xram_rsp_victim_count.read() == 1))) r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
    40124320        else                             r_xram_rsp_fsm = XRAM_RSP_IDLE;
    40134321
     
    40454353        r_xram_rsp_next_ptr                 = r_xram_rsp_victim_ptr.read();
    40464354
    4047         if(r_xram_rsp_victim_dirty)  r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
     4355        if(r_xram_rsp_victim_dirty or (!r_xram_rsp_victim_coherent.read() and (r_xram_rsp_victim_count.read() == 1)))  r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
    40484356        else if(not_last_multi_req)  r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ;
    40494357        else                         r_xram_rsp_fsm = XRAM_RSP_IDLE;
     
    40614369    case XRAM_RSP_WRITE_DIRTY:  // send a write request to IXR_CMD FSM
    40624370    {
    4063       if(!r_xram_rsp_to_ixr_cmd_req.read())
    4064       {
     4371      if((!r_xram_rsp_to_ixr_cmd_req.read()) and (!r_xram_rsp_to_ixr_cmd_inval_ncc_pending.read()))
     4372      {
     4373
    40654374        r_xram_rsp_to_ixr_cmd_req = true;
    40664375        r_xram_rsp_to_ixr_cmd_nline = r_xram_rsp_victim_nline.read();
     
    40714380        }
    40724381        m_cpt_write_dirty++;
     4382       
     4383        // if victim is no coherent, we dont request a ixr command
     4384        if( (!r_xram_rsp_victim_coherent.read()) and (r_xram_rsp_victim_count.read() == 1) )
     4385        {
     4386          r_xram_rsp_to_ixr_cmd_inval_ncc_pending = true; // inval no coherent pending
     4387          r_xram_rsp_to_ixr_cmd_req = false;
     4388          r_xram_rsp_fsm = XRAM_RSP_IDLE;
     4389          break;
     4390        }
    40734391
    40744392        bool multi_req = !r_xram_rsp_victim_is_cnt.read() and r_xram_rsp_victim_inval.read();
     
    40934411      {
    40944412        r_xram_rsp_fsm = XRAM_RSP_HEAP_ERASE;
     4413        m_cpt_xram_rsp_fsm_n_heap_lock++;
    40954414      }
    40964415
     
    41004419          << " Requesting HEAP lock" << std::endl;
    41014420#endif
     4421
     4422      m_cpt_xram_rsp_fsm_heap_lock++;
     4423
    41024424      break;
    41034425    }
     
    42434565
    42444566      uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
    4245 
    42464567      uint32_t srcid =
    42474568        DspinDhccpParam::dspin_get(
     
    42644585            DspinDhccpParam::CLEANUP_NLINE_MSB) << 32;
    42654586
     4587      /*ODCCP*/ // Cleanup on no coherent line if 1
     4588      r_cleanup_ncc =
     4589        DspinDhccpParam::dspin_get(
     4590            flit,
     4591            DspinDhccpParam::CLEANUP_NCC);
     4592
    42664593      r_cleanup_inst  = (type == DspinDhccpParam::TYPE_CLEANUP_INST);
    42674594      r_cleanup_srcid = srcid;
     
    42954622    {
    42964623      if(not m_cc_receive_to_cleanup_fifo.rok()) break;
     4624     
    42974625
    42984626      uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
     
    43004628      addr_t nline = r_cleanup_nline.read() |
    43014629        DspinDhccpParam::dspin_get(flit, DspinDhccpParam::CLEANUP_NLINE_LSB);
     4630     
     4631      bool eop = DspinDhccpParam::dspin_get(flit, DspinDhccpParam::FROM_L1_EOP);
     4632     
     4633      /*ODCCP*/ // if not eop (more than 2 flits) there is a cleanup no coherent with data
     4634      if (!eop)
     4635      {
     4636        r_cleanup_contains_data = true; // this cleanup contains data
     4637        r_cleanup_fsm = CLEANUP_GET_DATA;
     4638        r_cleanup_data_index = 0;
     4639      }
     4640      else
     4641      {
     4642        r_cleanup_contains_data = false;
     4643        r_cleanup_fsm = CLEANUP_DIR_REQ;
     4644      }
    43024645
    43034646      cc_receive_to_cleanup_fifo_get = true;
    4304       r_cleanup_nline                = nline;
    4305       r_cleanup_fsm                  = CLEANUP_DIR_REQ;
     4647      r_cleanup_nline               = nline;
    43064648
    43074649#if DEBUG_MEMC_CLEANUP
     
    43144656    }
    43154657
     4658    /*ODCCP*/ // We save the cleanup's data into a buffer
     4659    case CLEANUP_GET_DATA :
     4660    {
     4661      if(not m_cc_receive_to_cleanup_fifo.rok()) break;
     4662     
     4663      assert (r_cleanup_data_index.read() < m_words and "MEM_CACHE in CLEANUP_GET_DATA : too much flits in cleanup data updt");
     4664
     4665      uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
     4666
     4667      uint32_t data =
     4668        DspinDhccpParam::dspin_get (flit, DspinDhccpParam::CLEANUP_DATA_UPDT);
     4669
     4670      r_cleanup_data[r_cleanup_data_index.read()] = data;
     4671      r_cleanup_data_index = r_cleanup_data_index.read() + 1;
     4672      cc_receive_to_cleanup_fifo_get = true;
     4673      m_cpt_cleanup_data++;
     4674
     4675      if (r_cleanup_data_index.read() == m_words - 1) // last flit
     4676      {
     4677        r_cleanup_fsm = CLEANUP_DIR_REQ;
     4678      }
     4679      break;
     4680    }
    43164681    /////////////////////
    43174682    case CLEANUP_DIR_REQ:   // Get the lock to the directory
    43184683    {
     4684      m_cpt_cleanup_fsm_dir_lock++;
     4685      // Get the lock to the directory
    43194686      if(r_alloc_dir_fsm.read() != ALLOC_DIR_CLEANUP) break;
    43204687
     
    43254692std::cout << "  <MEMC " << name() << " CLEANUP_DIR_REQ> Requesting DIR lock" << std::endl;
    43264693#endif
     4694
     4695      m_cpt_cleanup_fsm_n_dir_lock++;
     4696
    43274697      break;
    43284698    }
     
    43414711        exit(0);
    43424712      }
    4343 
    43444713      // Read the directory
    43454714      size_t way = 0;
     
    43624731      if(entry.valid)      // hit : the copy must be cleared
    43634732      {
     4733        if(entry.count < 1)
     4734        {
     4735          std::cout << "assert on line " << std::hex <<r_cleanup_nline.read() << " | at cycle " << std::dec <<m_cpt_cycles << std::endl;
     4736          std::cout << "cleanup with data ? " << r_cleanup_contains_data.read() << " | at cycle " << m_cpt_cycles << std::endl;
     4737          std::cout << "cleanup_address = " << std::hex << (r_cleanup_nline.read()*m_words*4) << std::dec << std::endl;
     4738          std::cout << "srcid = " << r_cleanup_srcid.read() << std::endl;
     4739          std::cout << "inst = " << r_cleanup_inst.read() << std::endl;
     4740          std::cout << "inst = " << r_cleanup_inst.read() << std::endl;
     4741        }
    43644742        assert(
    43654743            (entry.count > 0) and
     
    44454823      entry.valid       = true;
    44464824      entry.is_cnt      = r_cleanup_is_cnt.read();
    4447       entry.dirty       = r_cleanup_dirty.read();
     4825      entry.dirty       = r_cleanup_dirty.read() or r_cleanup_contains_data.read();
    44484826      entry.tag         = r_cleanup_tag.read();
    44494827      entry.lock        = r_cleanup_lock.read();
     
    44564834      entry.owner.cache_id = 0;
    44574835#endif
     4836      /*ODCCP*/ // if cleanup contains data we update the cache data
     4837      if (r_cleanup_contains_data.read())
     4838      {
     4839        for (size_t word = 0; word < m_words; word ++)
     4840        {
     4841          m_cache_data.write(way, set, word, r_cleanup_data[word].read(), 0xF);
     4842        }
     4843      }
     4844
    44584845
    44594846      m_cache_directory.write(set, way, entry);
     
    44844871    {
    44854872      // get the lock to the HEAP directory
     4873      m_cpt_cleanup_fsm_heap_lock++;
    44864874      if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP) break;
    44874875
     
    44974885      }
    44984886#endif
     4887      m_cpt_cleanup_fsm_n_heap_lock++;
    44994888      break;
    45004889    }
     
    45754964          << " / r_cleanup_copy_inst = " << r_cleanup_copy_inst.read() << std::endl
    45764965          << "heap_entry.owner.srcid = " << heap_entry.owner.srcid
    4577           << " / heap_entry.owner.inst = " << heap_entry.owner.inst << std::endl;
     4966          << " / heap_entry.owner.inst = " << heap_entry.owner.inst << std::endl
     4967          << " / addr = " << std::hex << (r_cleanup_nline.read() *m_words*4) << std::dec << std::endl;
    45784968/**/
    45794969
     
    48425232                             // invalidate transaction matching the cleanup
    48435233    {
     5234      m_cpt_cleanup_fsm_upt_lock++;
    48445235      if(r_alloc_upt_fsm.read() != ALLOC_UPT_CLEANUP) break;
    48455236
     
    48515242      if ( not match_inval )     // no pending inval
    48525243      {
     5244        /*ODCCP*/ // If cleanup is on no coherent line we go to CLEANUP_IXR_REQ
     5245        if (r_cleanup_ncc.read())
     5246        {
     5247          r_cleanup_fsm = CLEANUP_IXR_REQ;
     5248        }
     5249        else
     5250        {
    48535251          r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5252        }
    48545253
    48555254#if DEBUG_MEMC_CLEANUP
     
    48625261          << std::endl;
    48635262#endif
    4864           break;
     5263      m_cpt_cleanup_fsm_n_upt_lock++;
     5264        break;
    48655265      }
    48665266
     
    49085308      else             // multi inval transaction not completed
    49095309      {
    4910         r_cleanup_fsm = CLEANUP_SEND_CLACK ;
     5310        /*ODCCP*/ // If cleanup is on no coherent line we go to CLEANUP_IXR_REQ
     5311        if (r_cleanup_ncc.read())
     5312        {
     5313          r_cleanup_fsm = CLEANUP_IXR_REQ;
     5314        }
     5315        else
     5316        {
     5317          r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5318        }
    49115319      }
    49125320
     
    49385346      if      ( r_cleanup_need_rsp.read() ) r_cleanup_fsm = CLEANUP_WRITE_RSP;
    49395347      else if ( r_cleanup_need_ack.read() ) r_cleanup_fsm = CLEANUP_CONFIG_ACK;
     5348      else if ( r_cleanup_ncc.read()      ) r_cleanup_fsm = CLEANUP_IXR_REQ;
    49405349      else                                  r_cleanup_fsm = CLEANUP_SEND_CLACK;
    49415350
     
    49605369      r_cleanup_to_tgt_rsp_pktid   = r_cleanup_write_pktid.read();
    49615370
    4962       r_cleanup_fsm                = CLEANUP_SEND_CLACK;
     5371      /*ODCCP*/ // If cleanup is on no coherent line we go to CLEANUP_IXR_REQ
     5372      if (r_cleanup_ncc.read())
     5373      {
     5374        r_cleanup_fsm = CLEANUP_IXR_REQ;
     5375      }
     5376      else
     5377      {
     5378        r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5379      }
    49635380
    49645381#if DEBUG_MEMC_CLEANUP
     
    49775394    {
    49785395      if ( r_cleanup_to_config_ack.read() ) break;
    4979 
    49805396      r_cleanup_to_config_ack      = true;
    49815397      r_cleanup_fsm                = CLEANUP_SEND_CLACK;
     
    49885404      break;
    49895405    }
     5406
     5407    /*ODCCP*/
     5408    case CLEANUP_IXR_REQ:
     5409    {
     5410   
     5411      //Send a request to the ixr to write the data in the XRAM and set an entry in the TRT.
     5412      if (r_alloc_trt_fsm.read() == ALLOC_TRT_CLEANUP)
     5413      {
     5414        if(!r_cleanup_to_ixr_cmd_req.read())
     5415        {
     5416          size_t index = 0;
     5417          bool   hit   = m_trt.hit_write(r_cleanup_nline.read(), &index); // we save the index of the matching entry in TRT
     5418          if (!hit)
     5419          {
     5420            std::cout << "assert on line " << r_cleanup_nline.read() << " | at cycle " << std::dec <<m_cpt_cycles << std::endl;
     5421            for (int i=0; i<4; i++) m_trt.print(i);
     5422          }
     5423          assert (hit and "CLEANUP_IXR_REQ found no matching entry in TRT");
     5424         
     5425          r_cleanup_to_ixr_cmd_req     = true;
     5426
     5427          for(size_t i = 0; i < m_words; i++){
     5428            r_cleanup_to_ixr_cmd_data[i]   = r_cleanup_data[i];
     5429          }
     5430
     5431          r_cleanup_to_ixr_cmd_srcid        = r_cleanup_srcid.read();
     5432          r_cleanup_to_ixr_cmd_trdid        = index;
     5433          r_cleanup_to_ixr_cmd_pktid        = r_cleanup_pktid.read();
     5434          r_cleanup_to_ixr_cmd_nline        = r_cleanup_nline.read();
     5435          r_cleanup_to_ixr_cmd_l1_dirty_ncc = r_cleanup_contains_data.read();
     5436          r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5437#if DEBUG_MEMC_CLEANUP
     5438      if(m_debug)
     5439      {
     5440        std::cout
     5441            << "  <MEMC " << name()
     5442            << " CLEANUP_IXR_REQ> Send a put request to the ixr:"
     5443            << " contains data ? = " << std::dec << r_cleanup_contains_data.read()
     5444            << " srcid = "           << std::dec << r_cleanup_srcid.read()
     5445            << " pktid = "           << std::dec << r_cleanup_pktid.read()
     5446            << " trdid = "           << std::dec << index
     5447            << " nline = "           << std::hex << r_cleanup_nline.read() << std::dec
     5448            << std::endl;
     5449      }
     5450#endif
     5451        }
     5452        else
     5453        {
     5454            r_cleanup_fsm = CLEANUP_WAIT;
     5455        }
     5456      }
     5457      break;
     5458    }
     5459
     5460    case CLEANUP_WAIT :
     5461    {
     5462      r_cleanup_fsm = CLEANUP_IXR_REQ;
     5463      break;
     5464    }
     5465
    49905466    ////////////////////////
    49915467    case CLEANUP_SEND_CLACK:    // acknowledgement to a cleanup command
     
    50945570      {
    50955571        r_cas_fsm = CAS_DIR_LOCK;
     5572        m_cpt_cas_fsm_n_dir_lock++;
    50965573      }
    50975574
     
    51045581      }
    51055582#endif
     5583
     5584      m_cpt_cas_fsm_dir_lock++;
     5585
    51065586      break;
    51075587    }
     
    53475827          << " / count = " << nb_copies << std::endl;
    53485828#endif
    5349       }
     5829        m_cpt_cas_fsm_n_upt_lock++;
     5830      }
     5831
     5832      m_cpt_cas_fsm_upt_lock++;
     5833
    53505834      break;
    53515835    }
     
    53785862#endif
    53795863        r_cas_fsm = CAS_UPT_REQ;
    5380       }
     5864        m_cpt_cas_fsm_n_heap_lock++;
     5865      }
     5866
     5867      m_cpt_cas_fsm_heap_lock++;
     5868
    53815869      break;
    53825870    }
     
    55186006          r_cas_fsm = CAS_WAIT;
    55196007        }
    5520       }
     6008        m_cpt_cas_fsm_n_trt_lock++;
     6009      }
     6010
     6011      m_cpt_cas_fsm_trt_lock++;
     6012
    55216013      break;
    55226014    }
     
    55836075          r_cas_fsm = CAS_WAIT;
    55846076        }
    5585       }
     6077        m_cpt_cas_fsm_n_upt_lock++;
     6078      }
     6079
     6080      m_cpt_cas_fsm_upt_lock++;
     6081
    55866082      break;
    55876083    }
     
    57616257          r_cas_fsm       = CAS_MISS_TRT_SET;
    57626258        }
    5763       }
     6259        m_cpt_cas_fsm_n_trt_lock++;
     6260      }
     6261
     6262      m_cpt_cas_fsm_trt_lock++;
     6263
    57646264      break;
    57656265    }
     
    65317031    case CC_RECEIVE_CLEANUP_EOP:
    65327032      {
    6533         // write second CLEANUP flit in CC_RECEIVE to CLEANUP fifo
     7033        // write second CLEANUP flit in CC_RECEIVE to CLEANUP fifo or more in case of cleanup data (ODCCP)
    65347034
    65357035        if(not p_dspin_in.write or not m_cc_receive_to_cleanup_fifo.wok())
    65367036          break;
    65377037
    6538         assert(p_dspin_in.eop.read() and
     7038        /*assert(p_dspin_in.eop.read() and
    65397039            "VCI_MEM_CACHE ERROR in CC_RECEIVE : "
    6540             "CLEANUP command must have two flits");
     7040            "CLEANUP command must have two flits");*/
    65417041
    65427042        cc_receive_to_cleanup_fifo_put = true;
    6543         r_cc_receive_fsm               = CC_RECEIVE_IDLE;
     7043        if(p_dspin_in.eop.read())
     7044          r_cc_receive_fsm               = CC_RECEIVE_IDLE;
    65447045
    65457046        break;
     
    70207521                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    70217522          r_alloc_upt_fsm = ALLOC_UPT_CAS;
    7022 
    70237523        else if(r_config_fsm.read() == CONFIG_DIR_UPT_LOCK)
    70247524          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
    7025       }
     7525        else
     7526          m_cpt_upt_unused++;
     7527      }
     7528      else
     7529        m_cpt_multi_ack_fsm_upt_used++;
    70267530      break;
    70277531
     
    70467550        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    70477551          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
    7048       }
     7552
     7553        else
     7554          m_cpt_upt_unused++;
     7555      }
     7556      else
     7557        m_cpt_write_fsm_upt_used++;
    70497558      break;
    70507559
     
    70697578                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    70707579          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
    7071       }
     7580
     7581        else
     7582          m_cpt_upt_unused++;
     7583      }
     7584      else
     7585        m_cpt_xram_rsp_fsm_upt_used++;
    70727586      break;
    70737587
     
    70937607        else if(r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
    70947608          r_alloc_upt_fsm = ALLOC_UPT_XRAM_RSP;
    7095       }
     7609
     7610        else
     7611          m_cpt_upt_unused++;
     7612      }
     7613      else
     7614        m_cpt_cleanup_fsm_upt_used++;
    70967615      break;
    70977616
     
    71167635        else if(r_cleanup_fsm.read() == CLEANUP_UPT_LOCK)
    71177636          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
    7118       }
     7637
     7638        else
     7639          m_cpt_upt_unused++;
     7640      }
     7641      else
     7642        m_cpt_cas_fsm_upt_used++;
    71197643      break;
    71207644
     
    71897713        else if(r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    71907714          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    7191 
     7715       
    71927716        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
    71937717          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
    7194     }
    7195     break;
     7718       
     7719        else
     7720          m_cpt_dir_unused++;
     7721      }
     7722      else
     7723        m_cpt_read_fsm_dir_used++;
     7724      break;
    71967725
    71977726    /////////////////////
     
    72277756        else if(r_read_fsm.read() == READ_DIR_REQ)
    72287757          r_alloc_dir_fsm = ALLOC_DIR_READ;
    7229     }
    7230     break;
     7758       
     7759        else
     7760          m_cpt_dir_unused++;
     7761      }
     7762      else
     7763        m_cpt_write_fsm_dir_used++;
     7764      break;
    72317765
    72327766    ///////////////////
     
    72637797        else if(r_write_fsm.read() == WRITE_DIR_REQ)
    72647798          r_alloc_dir_fsm = ALLOC_DIR_WRITE;
    7265     }
     7799       
     7800        else
     7801          m_cpt_dir_unused++;
     7802      }
     7803      else
     7804        m_cpt_cas_fsm_dir_used++;
    72667805      break;
    72677806
     
    72877826        else if(r_cas_fsm.read() == CAS_DIR_REQ)
    72887827          r_alloc_dir_fsm = ALLOC_DIR_CAS;
    7289     }
    7290     break;
     7828
     7829        else
     7830          m_cpt_dir_unused++;
     7831      }
     7832      else
     7833        m_cpt_cleanup_fsm_dir_used++;
     7834      break;
    72917835
    72927836    ////////////////////////
     
    73107854        else if(r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    73117855          r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
    7312     }
    7313     break;
     7856
     7857        else
     7858          m_cpt_dir_unused++;
     7859      }
     7860      else
     7861        m_cpt_xram_rsp_fsm_dir_used++;
     7862      break;
    73147863
    73157864  } // end switch alloc_dir_fsm
     
    73457894                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    73467895          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    7347       }
     7896
     7897        else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7898          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     7899
     7900        else
     7901          m_cpt_trt_unused++;
     7902      }
     7903      else
     7904        m_cpt_read_fsm_trt_used++;
    73487905      break;
    73497906
     
    73657922                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    73667923          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7924       
     7925        else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7926          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    73677927
    73687928        else if(r_read_fsm.read() == READ_TRT_LOCK)
    73697929          r_alloc_trt_fsm = ALLOC_TRT_READ;
    7370       }
     7930
     7931        else
     7932          m_cpt_trt_unused++;
     7933      }
     7934      else
     7935        m_cpt_write_fsm_trt_used++;
    73717936      break;
    73727937
     
    73847949                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    73857950          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7951       
     7952        else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7953          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    73867954
    73877955        else if(r_read_fsm.read() == READ_TRT_LOCK)
     
    73917959                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    73927960          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    7393       }
     7961
     7962        else
     7963          m_cpt_trt_unused++;
     7964      }
     7965      else
     7966        m_cpt_cas_fsm_trt_used++;
    73947967      break;
    73957968
     
    74057978            (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    74067979          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7980       
     7981        else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7982          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    74077983
    74087984        else if(r_read_fsm.read() == READ_TRT_LOCK)
     
    74167992                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    74177993          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    7418       }
     7994
     7995        else
     7996          m_cpt_trt_unused++;
     7997      }
     7998      else
     7999        m_cpt_xram_rsp_fsm_trt_used++;
    74198000      break;
    74208001
     
    74248005          (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ))
    74258006      {
     8007       
     8008        if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     8009          r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     8010
     8011        else if(r_read_fsm.read() == READ_TRT_LOCK)
     8012          r_alloc_trt_fsm = ALLOC_TRT_READ;
     8013
     8014        else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     8015                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     8016          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     8017
     8018        else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     8019                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     8020          r_alloc_trt_fsm = ALLOC_TRT_CAS;
     8021
     8022        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     8023                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     8024          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     8025
     8026        else
     8027          m_cpt_trt_unused++;
     8028      }
     8029      else
     8030        m_cpt_ixr_fsm_trt_used++;
     8031      break;
     8032
     8033      ////////////////////////
     8034    case ALLOC_TRT_CLEANUP:
     8035      if(r_ixr_rsp_fsm.read() != CLEANUP_IXR_REQ)
     8036      {
    74268037        if(r_read_fsm.read() == READ_TRT_LOCK)
    74278038          r_alloc_trt_fsm = ALLOC_TRT_READ;
     
    74388049                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    74398050          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     8051
     8052        else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     8053            (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     8054          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    74408055      }
    74418056      break;
     
    74888103        else if(r_config_fsm.read() == CONFIG_HEAP_REQ)
    74898104          r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
    7490       }
     8105        else
     8106          m_cpt_heap_unused++;
     8107      }
     8108      else
     8109        m_cpt_read_fsm_heap_used++;
    74918110      break;
    74928111
     
    75118130        else if(r_read_fsm.read() == READ_HEAP_REQ)
    75128131          r_alloc_heap_fsm = ALLOC_HEAP_READ;
    7513       }
     8132
     8133        else
     8134          m_cpt_heap_unused++;
     8135      }
     8136      else
     8137        m_cpt_write_fsm_heap_used++;
    75148138      break;
    75158139
     
    75348158        else if(r_write_fsm.read() == WRITE_UPT_HEAP_LOCK)
    75358159          r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
    7536       }
     8160
     8161        else
     8162          m_cpt_heap_unused++;
     8163      }
     8164      else
     8165        m_cpt_cas_fsm_heap_used++;
    75378166      break;
    75388167
     
    75588187        else if(r_cas_fsm.read() == CAS_UPT_HEAP_LOCK)
    75598188          r_alloc_heap_fsm = ALLOC_HEAP_CAS;
    7560       }
     8189
     8190        else
     8191          m_cpt_heap_unused++;
     8192      }
     8193      else
     8194        m_cpt_cleanup_fsm_heap_used++;
    75618195      break;
    75628196
     
    76038237        if(r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ)
    76048238          r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    7605       }
     8239        else
     8240          m_cpt_heap_unused++;
     8241      }
     8242      else
     8243        m_cpt_xram_rsp_fsm_heap_used++;
    76068244      break;
    76078245
     
    76638301  ////////////////////////////////////////////////////////////////////////////////////
    76648302
     8303/*
     8304  if(cc_receive_to_cleanup_fifo_put)
     8305  {
     8306    if(cc_receive_to_cleanup_fifo_get)
     8307    {
     8308      m_cc_receive_to_cleanup_fifo.put_and_get( ( (uint64_t)(p_dspin_in.eop.read() & 0x1 ) << 32 ) | p_dspin_in.data.read());
     8309    }
     8310    else // TODO PAS METTRE 32 en DUR !!!!
     8311    {
     8312      m_cc_receive_to_cleanup_fifo.simple_put( ( (uint64_t)(p_dspin_in.eop.read() & 0x1 ) << 32 ) | p_dspin_in.data.read());
     8313      //m_cc_receive_to_cleanup_fifo.simple_put(p_dspin_in.data.read());
     8314    }
     8315  }
     8316  else
     8317  {
     8318    if(cc_receive_to_cleanup_fifo_get)
     8319    {
     8320      m_cc_receive_to_cleanup_fifo.simple_get();
     8321    }
     8322  }
     8323*/
    76658324  m_cc_receive_to_cleanup_fifo.update( cc_receive_to_cleanup_fifo_get,
    76668325                                       cc_receive_to_cleanup_fifo_put,
    7667                                        p_dspin_in.data.read() );
    7668 
     8326                                       ( (uint64_t)(p_dspin_in.eop.read() & 0x1 ) << 32 ) | p_dspin_in.data.read() );
    76698327  ////////////////////////////////////////////////////////////////////////////////////
    76708328  //    CC_RECEIVE to MULTI_ACK FIFO
     
    78148472    p_vci_ixr.trdid     = r_xram_rsp_to_ixr_cmd_trdid.read();
    78158473    p_vci_ixr.eop       = (r_ixr_cmd_cpt == (m_words-2));
     8474  }
     8475  /*ODCCP*/
     8476  else if (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_DATA)
     8477  {
     8478    p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
     8479    p_vci_ixr.cmdval  = true;
     8480    p_vci_ixr.address = (addr_t)((r_cleanup_to_ixr_cmd_nline.read() * m_words +
     8481                                    r_ixr_cmd_cpt.read()) * 4);
     8482   
     8483    if(r_cleanup_to_ixr_cmd_l1_dirty_ncc.read()) // if cleanup data contains data, we use cleanup_data buffer (cleanup dirty)
     8484    {
     8485      p_vci_ixr.wdata   = ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
     8486          ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read() + 1].read()) << 32));
     8487    }
     8488    else // if cleanup data doesnt contain data, we use xram_rsp_data buffer (cleanup not dirty)
     8489    {
     8490      p_vci_ixr.wdata   = ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
     8491          ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read() + 1].read()) << 32));
     8492    }
     8493
     8494    p_vci_ixr.trdid   = r_cleanup_to_ixr_cmd_trdid.read();
     8495    p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words - 2));
    78168496  }
    78178497  else
Note: See TracChangeset for help on using the changeset viewer.