Changeset 140


Ignore:
Timestamp:
Mar 9, 2011, 4:11:43 PM (13 years ago)
Author:
kane
Message:

yAjout du multi_cache : plusieurs processeur peuvent ce partager le même cache L1.
2 remarques, (1) deux nouveaux paramètres : nb_cpu, nb_cache. Pour avoir un cache dont le comportement est identique à la version d'avant, mettre ces paramètres à 1.
(2) le port d'interruption est maintenant un tableau dépendant du nombre de processeur.
Voir le fichier "platforms/caba-ring-ccxcachev4_memcachev4-mips32el/top.cpp" pour plus de détails.

--Cette ligne, et les suivantes ci-dessous, seront ignorées--

M platforms/tsarv4_dspin_generic_32/tsarv4_dspin_generic_32_top.cpp
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/segmentation.h
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/top.cpp
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/configuration/default.cfg
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/configuration/gen_config.sh
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/dhrystone/dhry21a.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/define.h
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/matrix_multiplication/matrix_multiplication.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/common/common.c
A platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/self_code_modifying
A platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/self_code_modifying/self_code_modifying.c
A platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/self_code_modifying/self_code_modifying.h
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark.h
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_sort.c
A platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_self_code_modifying.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_matrix_multiplication.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/Makefile
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/Makefile
M platforms/tsarv4_vgmn_generic_32/tsarv4_vgmn_generic_32_top.cpp
M modules/vci_cc_xcache_wrapper_v4/caba/source/include/vci_cc_xcache_wrapper_v4.h
M modules/vci_cc_xcache_wrapper_v4/caba/source/src/vci_cc_xcache_wrapper_v4.cpp
M modules/vci_mem_cache_v4/caba/source/include/vci_mem_cache_v4.h
M modules/vci_mem_cache_v4/caba/source/include/mem_cache_directory_v4.h
M modules/vci_mem_cache_v4/caba/source/src/vci_mem_cache_v4.cpp

Location:
trunk
Files:
4 added
21 edited

Legend:

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

    r134 r140  
    3131
    3232#include <inttypes.h>
     33#include <fstream>
    3334#include <systemc>
    3435#include <queue>
     
    7172 *     4    - one access with round robin priority
    7273 *
     74 * CC_XCACHE_WRAPPER_MULTI_CACHE :
     75 *     1    - icache static partitionnement
     76 *     2    - icache dedicated
     77 *
    7378 * CC_XCACHE_WRAPPER_STOP_SIMULATION :
    7479 *   stop simulation if processor is stall after a long time
     
    8186 *   Number of cycle before to prinf debug message
    8287 *
    83  * CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION
    84  *   Print transaction between the cpu and the cache
     88 * CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     89 *   Print transaction between :
     90 *     - the cpu and the cache (icache and dcache)
     91 *     - vci
     92 *     - cleanup
     93 *     - coherency
    8594 */
    8695
    8796// implementation
    8897#ifndef CC_XCACHE_WRAPPER_SELECT_VICTIM
    89 #define CC_XCACHE_WRAPPER_SELECT_VICTIM             0
     98#define CC_XCACHE_WRAPPER_SELECT_VICTIM               1
    9099#endif
    91100#ifndef CC_XCACHE_WRAPPER_FIFO_RSP
    92 #define CC_XCACHE_WRAPPER_FIFO_RSP                  0
     101#define CC_XCACHE_WRAPPER_FIFO_RSP                    1
    93102#endif
    94103#ifndef CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
    95 #define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE     1
     104#define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE       1
    96105#endif
    97106#ifndef CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT
    98 #define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT 1
     107#define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT   1
    99108#endif
    100109#ifndef CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME
    101 #define CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME        0
     110#define CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME          2
    102111#endif
    103112#ifndef CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY
    104 #define CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY          2
     113#define CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY            4
     114#endif 
     115#ifndef CC_XCACHE_WRAPPER_MULTI_CACHE
     116#define CC_XCACHE_WRAPPER_MULTI_CACHE                 2
    105117#endif 
    106118// debugging
    107119#ifndef CC_XCACHE_WRAPPER_STOP_SIMULATION
    108 #define CC_XCACHE_WRAPPER_STOP_SIMULATION           1
     120#define CC_XCACHE_WRAPPER_STOP_SIMULATION             1
    109121#endif
    110122#ifndef CC_XCACHE_WRAPPER_DEBUG
    111 #define CC_XCACHE_WRAPPER_DEBUG                     0
     123#define CC_XCACHE_WRAPPER_DEBUG                       0
    112124#endif
    113125#ifndef CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN
    114 #define CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN           200000
    115 #endif
    116 #ifndef CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION
    117 #define CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION  0
     126#define CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN             949900
     127#endif
     128#ifndef CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     129#define CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION      0
     130#define CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION_PATH "log"
     131#endif
     132
     133// don't change
     134#if not CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
     135#undef  CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT
     136#define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT   0
    118137#endif
    119138
     
    204223    enum cleanup_fsm_state_e {
    205224        CLEANUP_IDLE,
    206         CLEANUP_DCACHE,
    207         CLEANUP_ICACHE,
     225        CLEANUP_REQ,
     226        CLEANUP_RSP_DCACHE,
     227        CLEANUP_RSP_ICACHE,
    208228    };
    209229
     
    231251    sc_in<bool>                             p_clk;
    232252    sc_in<bool>                             p_resetn;
    233     sc_in<bool>                             p_irq[iss_t::n_irq];
     253    sc_in<bool>                          ** p_irq;//[m_nb_cpu][iss_t::n_irq];
    234254    soclib::caba::VciInitiator<vci_param>   p_vci_ini_rw;
    235255    soclib::caba::VciInitiator<vci_param>   p_vci_ini_c;
     
    241261    const soclib::common::AddressDecodingTable<vci_addr_t, bool>    m_cacheability_table;
    242262    const soclib::common::Segment                                   m_segment;
    243     iss_t               m_iss;
     263    iss_t            ** m_iss; //[m_nb_cpu]
    244264    const uint32_t      m_srcid_rw;   
    245265    const uint32_t      m_srcid_c;   
    246266   
     267    const size_t        m_nb_cpu;
     268    const size_t        m_nb_icache;
     269    const size_t        m_nb_dcache;
     270    const size_t        m_nb_cache;
    247271    const size_t        m_dcache_ways;
    248272    const size_t        m_dcache_words;
     
    258282    bool                m_stop_simulation;
    259283    uint32_t            m_stop_simulation_nb_frz_cycles_max;
    260     uint32_t            m_stop_simulation_nb_frz_cycles;
     284    uint32_t          * m_stop_simulation_nb_frz_cycles; //[m_nb_cpu]
    261285#endif // CC_XCACHE_WRAPPER_STOP_SIMULATION
    262286
    263287    // REGISTERS
    264     sc_signal<int>          r_dcache_fsm;
    265     sc_signal<int>          r_dcache_fsm_save;
    266     sc_signal<addr_40>      r_dcache_addr_save;
    267     sc_signal<data_t>       r_dcache_wdata_save;
    268     sc_signal<data_t>       r_dcache_rdata_save;
    269     sc_signal<int>          r_dcache_type_save;
    270     sc_signal<be_t>         r_dcache_be_save;
    271     sc_signal<bool>         r_dcache_cached_save;
    272     sc_signal<bool>         r_dcache_cleanup_req;
    273     sc_signal<addr_40>      r_dcache_cleanup_line;
    274     sc_signal<bool>         r_dcache_miss_req;
    275     sc_signal<size_t>       r_dcache_miss_way;
    276     sc_signal<size_t>       r_dcache_miss_set;
    277     sc_signal<bool>         r_dcache_unc_req;
    278     sc_signal<bool>         r_dcache_sc_req;
    279     sc_signal<bool>         r_dcache_inval_rsp;
    280     sc_signal<size_t>       r_dcache_update_addr;
    281     sc_signal<data_64>      r_dcache_ll_data;
    282     sc_signal<addr_40>      r_dcache_ll_addr;
    283     sc_signal<bool>         r_dcache_ll_valid;
    284     sc_signal<bool>         r_dcache_previous_unc;
    285 
    286     sc_signal<int>          r_icache_fsm;
    287     sc_signal<int>          r_icache_fsm_save;
    288     sc_signal<addr_40>      r_icache_addr_save;
    289     sc_signal<bool>         r_icache_miss_req;
    290     sc_signal<size_t>       r_icache_miss_way;
    291     sc_signal<size_t>       r_icache_miss_set;
    292     sc_signal<bool>         r_icache_unc_req;
    293     sc_signal<bool>         r_icache_cleanup_req;
    294     sc_signal<addr_40>      r_icache_cleanup_line;
    295     sc_signal<bool>         r_icache_inval_rsp;
    296     sc_signal<size_t>       r_icache_update_addr;
     288    sc_signal<uint32_t>     r_cpu_prior;
     289    sc_signal<uint32_t>   * r_icache_lock;//[m_nb_icache]
     290    sc_signal<uint32_t>   * r_dcache_lock;//[m_nb_dcache]
     291    sc_signal<bool>       * r_dcache_sync;//[m_nb_dcache]
     292
     293    sc_signal<int>        * r_dcache_fsm;          //[m_nb_dcache]
     294    sc_signal<int>        * r_dcache_fsm_save;     //[m_nb_dcache]
     295    sc_signal<addr_40>    * r_dcache_addr_save;    //[m_nb_dcache]
     296    sc_signal<data_t>     * r_dcache_wdata_save;   //[m_nb_dcache]
     297    sc_signal<data_t>     * r_dcache_rdata_save;   //[m_nb_dcache]
     298    sc_signal<int>        * r_dcache_type_save;    //[m_nb_dcache]
     299    sc_signal<be_t>       * r_dcache_be_save;      //[m_nb_dcache]
     300    sc_signal<bool>       * r_dcache_cached_save;  //[m_nb_dcache]
     301    sc_signal<bool>       * r_dcache_cleanup_req;  //[m_nb_dcache]
     302    sc_signal<addr_40>    * r_dcache_cleanup_line; //[m_nb_dcache]
     303    sc_signal<bool>       * r_dcache_miss_req;     //[m_nb_dcache]
     304    sc_signal<size_t>     * r_dcache_miss_way;     //[m_nb_dcache]
     305    sc_signal<size_t>     * r_dcache_miss_set;     //[m_nb_dcache]
     306    sc_signal<bool>       * r_dcache_unc_req;      //[m_nb_dcache]
     307    sc_signal<bool>       * r_dcache_sc_req;       //[m_nb_dcache]
     308    sc_signal<bool>       * r_dcache_inval_rsp;    //[m_nb_dcache]
     309    sc_signal<size_t>     * r_dcache_update_addr;  //[m_nb_dcache]
     310    sc_signal<data_64>   ** r_dcache_ll_data;      //[m_nb_dcache][m_nb_cpu]
     311    sc_signal<addr_40>   ** r_dcache_ll_addr;      //[m_nb_dcache][m_nb_cpu]
     312    sc_signal<bool>      ** r_dcache_ll_valid;     //[m_nb_dcache][m_nb_cpu]
     313    sc_signal<uint32_t>   * r_dcache_num_cpu_save; //[m_nb_dcache]
     314    sc_signal<bool>       * r_dcache_previous_unc; //[m_nb_dcache]
     315                                                   
     316    sc_signal<int>        * r_icache_fsm;          //[m_nb_icache]
     317    sc_signal<int>        * r_icache_fsm_save;     //[m_nb_icache]
     318    sc_signal<addr_40>    * r_icache_addr_save;    //[m_nb_icache]
     319    sc_signal<bool>       * r_icache_miss_req;     //[m_nb_icache]
     320    sc_signal<size_t>     * r_icache_miss_way;     //[m_nb_icache]
     321    sc_signal<size_t>     * r_icache_miss_set;     //[m_nb_icache]
     322    sc_signal<bool>       * r_icache_unc_req;      //[m_nb_icache]
     323    sc_signal<bool>       * r_icache_cleanup_req;  //[m_nb_icache]
     324    sc_signal<addr_40>    * r_icache_cleanup_line; //[m_nb_icache]
     325    sc_signal<bool>       * r_icache_inval_rsp;    //[m_nb_icache]
     326    sc_signal<size_t>     * r_icache_update_addr;  //[m_nb_icache]
     327    sc_signal<bool>       * r_icache_buf_unc_valid;//[m_nb_icache]
    297328
    298329    sc_signal<int>          r_vci_cmd_fsm;
     
    301332    sc_signal<size_t>       r_vci_cmd_cpt;       
    302333    sc_signal<bool>         r_vci_cmd_dcache_prior;
    303      
     334    sc_signal<uint32_t>     r_vci_cmd_num_cache;
     335
    304336    sc_signal<int>          r_vci_rsp_fsm;
    305     sc_signal<bool>         r_vci_rsp_ins_error;   
    306     sc_signal<bool>         r_vci_rsp_data_error;   
    307337    sc_signal<size_t>       r_vci_rsp_cpt; 
    308     sc_signal<bool>         r_vci_rsp_ack;
     338              bool          s_vci_rsp_ack;
     339    sc_signal<uint32_t>     r_vci_rsp_num_cache;
     340    sc_signal<bool>       * r_vci_rsp_ins_error;  //[m_nb_icache]
     341    sc_signal<bool>       * r_vci_rsp_data_error; //[m_nb_dcache]
    309342
    310343#if CC_XCACHE_WRAPPER_FIFO_RSP
    311     std::queue<data_t>      r_icache_miss_buf;
    312     std::queue<data_t>      r_dcache_miss_buf;
     344    std::queue<data_t>    * r_icache_miss_buf;    //[m_nb_icache]
     345    std::queue<data_t>    * r_dcache_miss_buf;    //[m_nb_dcache]
    313346#else
    314     bool                   *r_icache_miss_val;    //[m_icache_words]
    315     data_t                 *r_icache_miss_buf;    //[m_icache_words]
    316     bool                   *r_dcache_miss_val;    //[m_dcache_words]
    317     data_t                 *r_dcache_miss_buf;    //[m_dcache_words]
    318 #endif
    319     sc_signal<bool>         r_icache_buf_unc_valid;
    320 
    321     data_t                 *r_tgt_buf;            //[m_cache_words]
    322     be_t                   *r_tgt_be;             //[m_cache_words]
     347    bool                 ** r_icache_miss_val;    //[m_nb_icache][m_icache_words]
     348    data_t               ** r_icache_miss_buf;    //[m_nb_icache][m_icache_words]
     349    bool                 ** r_dcache_miss_val;    //[m_nb_dcache][m_dcache_words]
     350    data_t               ** r_dcache_miss_buf;    //[m_nb_dcache][m_dcache_words]
     351#endif
     352    data_t                * r_tgt_buf;            //[m_cache_words]
     353    be_t                  * r_tgt_be;             //[m_cache_words]
    323354#if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
    324355    sc_signal<uint32_t>     r_cache_word;
     
    326357
    327358    sc_signal<int>          r_vci_tgt_fsm;
    328     sc_signal<addr_40>      r_tgt_addr;
     359    sc_signal<addr_40>      r_tgt_iaddr;
     360    sc_signal<addr_40>      r_tgt_daddr;
    329361    sc_signal<size_t>       r_tgt_word;
    330362    sc_signal<bool>         r_tgt_update;
     
    335367    sc_signal<size_t>       r_tgt_trdid;
    336368  //sc_signal<size_t>       r_tgt_plen;
    337     sc_signal<bool>         r_tgt_icache_req;
    338     sc_signal<bool>         r_tgt_dcache_req;
    339     sc_signal<bool>         r_tgt_icache_rsp;
    340     sc_signal<bool>         r_tgt_dcache_rsp;
     369    sc_signal<uint32_t>     r_tgt_num_cache;
     370    sc_signal<bool>       * r_tgt_icache_req; //[m_nb_icache]
     371    sc_signal<bool>       * r_tgt_icache_rsp; //[m_nb_icache]
     372    sc_signal<bool>       * r_tgt_dcache_req; //[m_nb_dcache]
     373    sc_signal<bool>       * r_tgt_dcache_rsp; //[m_nb_dcache]
    341374
    342375    sc_signal<int>          r_cleanup_fsm;              // controls initiator port of the coherence network
    343 
    344     MultiWriteBuffer<addr_40>   r_wbuf;
    345     GenericCache<vci_addr_t>    r_icache;
    346     GenericCache<vci_addr_t>    r_dcache;
    347 
    348 #if CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION
    349     std::ofstream               log_dcache_transaction_file;
     376    sc_signal<uint32_t>     r_cleanup_num_cache;
     377    sc_signal<bool>         r_cleanup_icache;
     378
     379    MultiWriteBuffer<addr_40>** r_wbuf;
     380    GenericCache<vci_addr_t> ** r_icache;
     381    GenericCache<vci_addr_t> ** r_dcache;
     382
     383#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     384    std::ofstream             * log_transaction_file_icache; //[m_nb_cpu]
     385    std::ofstream             * log_transaction_file_dcache; //[m_nb_cpu]
     386    std::ofstream               log_transaction_file_cmd;
     387    std::ofstream               log_transaction_file_tgt;
     388    std::ofstream               log_transaction_file_cleanup;
    350389#endif
    351390
    352391    // Activity counters
    353     uint32_t m_cpt_dcache_data_read;             // * DCACHE DATA READ
    354     uint32_t m_cpt_dcache_data_write;            // * DCACHE DATA WRITE
    355     uint32_t m_cpt_dcache_dir_read;              // * DCACHE DIR READ
    356     uint32_t m_cpt_dcache_dir_write;             // * DCACHE DIR WRITE
    357                                                  
    358     uint32_t m_cpt_icache_data_read;             // * ICACHE DATA READ
    359     uint32_t m_cpt_icache_data_write;            // * ICACHE DATA WRITE
    360     uint32_t m_cpt_icache_dir_read;              // * ICACHE DIR READ
    361     uint32_t m_cpt_icache_dir_write;             // * ICACHE DIR WRITE
    362 
    363     uint32_t m_cpt_cc_update_icache;             // number of coherence update packets (for icache)
    364     uint32_t m_cpt_cc_update_dcache;             // number of coherence update packets (for dcache)
    365     uint32_t m_cpt_cc_inval_broadcast;           // number of coherence inval packets
    366     uint32_t m_cpt_cc_inval_icache;              // number of coherence inval packets
    367     uint32_t m_cpt_cc_inval_dcache;              // number of coherence inval packets
    368     uint32_t m_cpt_cc_update_icache_word_useful; // number of valid word in coherence update packets
    369     uint32_t m_cpt_cc_update_dcache_word_useful; // number of valid word in coherence update packets
    370 
    371     uint32_t m_cpt_frz_cycles;                   // * number of cycles where the cpu is frozen
    372     uint32_t m_cpt_total_cycles;                     // total number of cycles
    373 
    374     uint32_t m_cpt_data_read;                    //   number of data read
    375     uint32_t m_cpt_data_read_miss;               //   number of data read miss
    376     uint32_t m_cpt_data_read_uncached;           //   number of data read uncached
    377     uint32_t m_cpt_data_write;                   //   number of data write
    378     uint32_t m_cpt_data_write_miss;              //   number of data write miss
    379     uint32_t m_cpt_data_write_uncached;          //   number of data write uncached
    380     uint32_t m_cpt_ins_miss;                     // * number of instruction miss
    381 
    382     uint32_t m_cost_write_frz;                   // * number of frozen cycles related to write buffer         
    383     uint32_t m_cost_data_miss_frz;               // * number of frozen cycles related to data miss
    384     uint32_t m_cost_unc_read_frz;                // * number of frozen cycles related to uncached read
    385     uint32_t m_cost_ins_miss_frz;                // * number of frozen cycles related to ins miss
    386 
    387     uint32_t m_cpt_imiss_transaction;            // * number of VCI instruction miss transactions
    388     uint32_t m_cpt_dmiss_transaction;            // * number of VCI data miss transactions
    389     uint32_t m_cpt_unc_transaction;              // * number of VCI uncached read transactions
    390     uint32_t m_cpt_data_write_transaction;       // * number of VCI write transactions
    391 
    392     uint32_t m_cost_imiss_transaction;           // * cumulated duration for VCI IMISS transactions
    393     uint32_t m_cost_dmiss_transaction;           // * cumulated duration for VCI DMISS transactions
    394     uint32_t m_cost_unc_transaction;             // * cumulated duration for VCI UNC transactions
    395     uint32_t m_cost_write_transaction;           // * cumulated duration for VCI WRITE transactions
    396     uint32_t m_length_write_transaction;         // * cumulated length for VCI WRITE transactions
     392    uint32_t   m_cpt_dcache_data_read;             // * DCACHE DATA READ
     393    uint32_t   m_cpt_dcache_data_write;            // * DCACHE DATA WRITE
     394    uint32_t   m_cpt_dcache_dir_read;              // * DCACHE DIR READ
     395    uint32_t   m_cpt_dcache_dir_write;             // * DCACHE DIR WRITE
     396                                                   
     397    uint32_t   m_cpt_icache_data_read;             // * ICACHE DATA READ
     398    uint32_t   m_cpt_icache_data_write;            // * ICACHE DATA WRITE
     399    uint32_t   m_cpt_icache_dir_read;              // * ICACHE DIR READ
     400    uint32_t   m_cpt_icache_dir_write;             // * ICACHE DIR WRITE
     401               
     402    uint32_t   m_cpt_cc_update_icache;             // number of coherence update packets (for icache)
     403    uint32_t   m_cpt_cc_update_dcache;             // number of coherence update packets (for dcache)
     404    uint32_t   m_cpt_cc_inval_broadcast;           // number of coherence inval packets
     405    uint32_t   m_cpt_cc_inval_icache;              // number of coherence inval packets
     406    uint32_t   m_cpt_cc_inval_dcache;              // number of coherence inval packets
     407    uint32_t   m_cpt_cc_update_icache_word_useful; // number of valid word in coherence update packets
     408    uint32_t   m_cpt_cc_update_dcache_word_useful; // number of valid word in coherence update packets
     409               
     410    uint32_t * m_cpt_frz_cycles;                       // * number of cycles where the cpu is frozen
     411    uint32_t   m_cpt_total_cycles;                     // total number of cycles
     412               
     413    uint32_t   m_cpt_data_read;                    //   number of data read
     414    uint32_t   m_cpt_data_read_miss;               //   number of data read miss
     415    uint32_t   m_cpt_data_read_uncached;           //   number of data read uncached
     416    uint32_t   m_cpt_data_write;                   //   number of data write
     417    uint32_t   m_cpt_data_write_miss;              //   number of data write miss
     418    uint32_t   m_cpt_data_write_uncached;          //   number of data write uncached
     419    uint32_t   m_cpt_ins_miss;                     // * number of instruction miss
     420               
     421    uint32_t   m_cost_write_frz;                   // * number of frozen cycles related to write buffer         
     422    uint32_t   m_cost_data_miss_frz;               // * number of frozen cycles related to data miss
     423    uint32_t   m_cost_unc_read_frz;                // * number of frozen cycles related to uncached read
     424    uint32_t   m_cost_ins_miss_frz;                // * number of frozen cycles related to ins miss
     425               
     426    uint32_t   m_cpt_imiss_transaction;            // * number of VCI instruction miss transactions
     427    uint32_t   m_cpt_dmiss_transaction;            // * number of VCI data miss transactions
     428    uint32_t   m_cpt_unc_transaction;              // * number of VCI uncached read transactions
     429    uint32_t   m_cpt_data_write_transaction;       // * number of VCI write transactions
     430               
     431    uint32_t   m_cost_imiss_transaction;           // * cumulated duration for VCI IMISS transactions
     432    uint32_t   m_cost_dmiss_transaction;           // * cumulated duration for VCI DMISS transactions
     433    uint32_t   m_cost_unc_transaction;             // * cumulated duration for VCI UNC transactions
     434    uint32_t   m_cost_write_transaction;           // * cumulated duration for VCI WRITE transactions
     435    uint32_t   m_length_write_transaction;         // * cumulated length for VCI WRITE transactions
     436
     437    uint32_t * m_cpt_icache_access; //[m_nb_icache]
     438    uint32_t * m_cpt_dcache_access; //[m_nb_dcache]
     439
     440    uint32_t ** m_cpt_fsm_dcache;  //[m_nb_dcache]
     441    uint32_t ** m_cpt_fsm_icache;  //[m_nb_icache]
     442    uint32_t  * m_cpt_fsm_cmd;
     443    uint32_t  * m_cpt_fsm_rsp;
     444    uint32_t  * m_cpt_fsm_tgt;
     445    uint32_t  * m_cpt_fsm_cleanup;
     446
     447    // Non blocking multi-cache
     448    typename iss_t::InstructionRequest  * ireq        ; //[m_nb_icache]
     449    typename iss_t::InstructionResponse * irsp        ; //[m_nb_icache]
     450    bool                                * ireq_cached ; //[m_nb_icache]
     451    uint32_t                            * ireq_num_cpu; //[m_nb_dcache]
     452    typename iss_t::DataRequest         * dreq        ; //[m_nb_dcache]
     453    typename iss_t::DataResponse        * drsp        ; //[m_nb_dcache]
     454    bool                                * dreq_cached ; //[m_nb_dcache]
     455    uint32_t                            * dreq_num_cpu; //[m_nb_dcache]
     456
     457    const uint32_t m_num_cache_LSB;
     458    const uint32_t m_num_cache_MSB;
     459          addr_40  m_num_cache_LSB_mask;
     460          addr_40  m_num_cache_mask;
    397461
    398462protected:
     
    409473                       const soclib::common::IntTab &initiator_index_c,
    410474                       const soclib::common::IntTab &target_index,
     475                       size_t nb_cpu,
     476                       size_t nb_cache,
    411477                       size_t icache_ways,
    412478                       size_t icache_sets,
     
    435501    void genMoore();
    436502
    437     soclib_static_assert((int)iss_t::SC_ATOMIC == (int)vci_param::STORE_COND_ATOMIC);
     503    uint32_t get_num_cache     (addr_40 & addr);
     504    uint32_t get_num_cache_only(addr_40   addr);
     505    void     set_num_cache     (addr_40 & addr, uint32_t num_cache);
     506    addr_40  set_num_cache_only(addr_40   addr, uint32_t num_cache);
     507
     508    soclib_static_assert((int)iss_t::SC_ATOMIC     == (int)vci_param::STORE_COND_ATOMIC);
    438509    soclib_static_assert((int)iss_t::SC_NOT_ATOMIC == (int)vci_param::STORE_COND_NOT_ATOMIC);
    439510};
  • trunk/modules/vci_cc_xcache_wrapper_v4/caba/source/src/vci_cc_xcache_wrapper_v4.cpp

    r134 r140  
    5555///////////////////////////////////////////////////////////////////////////////
    5656
    57 #include <cassert>
    5857#include <iomanip>
    5958#include "arithmetics.h"
     59#include "size.h"
    6060#include "../include/vci_cc_xcache_wrapper_v4.h"
    6161
     62// =====[ DEBUG ]====================================
     63
     64#define ASSERT_VERBOSE
     65#define ASSERT_NCYCLES m_cpt_total_cycles
     66
     67#include "debug.h"
     68
    6269#if CC_XCACHE_WRAPPER_DEBUG
    63 # define PRINTF(msg...) do { if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN) printf(msg); } while (0);
     70# define PRINTF(msg...) PRINTF_COND(m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN,msg)
    6471#else
    6572# define PRINTF(msg...)
    6673#endif
    6774
    68 # define ASSERT(cond,msg) assert ((cond) and msg);
    69 
     75// =====[ FIFO_RSP ]=================================
     76
     77// FIXME : une FIFO avec le numéro du cache !
    7078#if CC_XCACHE_WRAPPER_FIFO_RSP
    71 # define CACHE_MISS_BUF_ALLOC
    72 # define CACHE_MISS_BUF_DEALLOC
    73 # define CACHE_MISS_BUF_RESET(c)        while (r_##c##cache_miss_buf.size()>0) {r_##c##cache_miss_buf.pop();}
    74 # define CACHE_MISS_BUF_REQ_INIT(c)
    75 # define CACHE_MISS_BUF_RSP_VAL(c,n)    (r_##c##cache_miss_buf.size()>0)
    76 # define CACHE_MISS_BUF_RSP_ACK(c)      (r_##c##cache_miss_buf.size()<2)
    77 # define CACHE_MISS_BUF_RSP_DATA(c,n)   r_##c##cache_miss_buf.front()
    78 # define CACHE_MISS_BUF_RSP_POP(c)      do { r_##c##cache_miss_buf.pop();} while (0)
    79 # define CACHE_MISS_BUF_RSP_PUSH(c,n,d) do { r_##c##cache_miss_buf.push(d);} while (0)
    80 # define CACHE_MISS_BUF_RSP_PRINT(c)    do { PRINTF("    * cache_miss_buf - size : %d\n",r_##c##cache_miss_buf.size());} while (0)
     79# define CACHE_MISS_BUF_ALLOC             do { \
     80                                              r_icache_miss_buf = new std::queue<data_t> [m_nb_icache]; \
     81                                              r_dcache_miss_buf = new std::queue<data_t> [m_nb_dcache]; \
     82                                          } while (0)
     83# define CACHE_MISS_BUF_DEALLOC           do { \
     84                                              delete [] r_icache_miss_buf; \
     85                                              delete [] r_dcache_miss_buf; \
     86                                          } while (0)
     87# define CACHE_MISS_BUF_RESET(c)          do { \
     88                                              for (uint32_t x=0; x<m_nb_##c##cache; ++x) { \
     89                                                  while (r_##c##cache_miss_buf[x].size()>0) { \
     90                                                      r_##c##cache_miss_buf[x].pop(); \
     91                                                  } \
     92                                              } \
     93                                          } while (0)
     94# define CACHE_MISS_BUF_REQ_INIT(c,x)     
     95# define CACHE_MISS_BUF_RSP_VAL(c,x,n)    (r_##c##cache_miss_buf[x].size()>0)
     96# define CACHE_MISS_BUF_RSP_ACK(c,x)      (r_##c##cache_miss_buf[x].size()<2)
     97# define CACHE_MISS_BUF_RSP_DATA(c,x,n)   r_##c##cache_miss_buf[x].front()
     98# define CACHE_MISS_BUF_RSP_POP(c,x)      do {                                            \
     99                                              r_##c##cache_miss_buf[x].pop(); \
     100                                          } while (0)
     101# define CACHE_MISS_BUF_RSP_PUSH(c,x,n,d) do { \
     102                                              r_##c##cache_miss_buf[x].push(d); \
     103                                          } while (0)
     104# define CACHE_MISS_BUF_RSP_PRINT(c)      do { \
     105                                              for (uint32_t x=0; x<m_nb_##c##cache; ++x) { \
     106                                                  PRINTF("    * cache_miss_buf - size : %d\n",r_##c##cache_miss_buf[x].size()); \
     107                                              } \
     108                                          } while (0)
     109#else                                     
     110# define CACHE_MISS_BUF_ALLOC             do { \
     111                                              r_icache_miss_val = new bool   * [m_nb_icache]; \
     112                                              r_icache_miss_buf = new data_t * [m_nb_icache]; \
     113                                              for (uint32_t x=0; x<m_nb_icache;++x) { \
     114                                                  r_icache_miss_val [x] = new bool   [m_icache_words]; \
     115                                                  r_icache_miss_buf [x] = new data_t [m_icache_words]; \
     116                                              } \
     117                                              r_dcache_miss_val = new bool   * [m_nb_dcache]; \
     118                                              r_dcache_miss_buf = new data_t * [m_nb_dcache]; \
     119                                              for (uint32_t x=0; x<m_nb_dcache;++x) { \
     120                                                  r_dcache_miss_val [x] = new bool   [m_dcache_words]; \
     121                                                  r_dcache_miss_buf [x] = new data_t [m_dcache_words]; \
     122                                              } \
     123                                          } while (0)
     124# define CACHE_MISS_BUF_DEALLOC           do { \
     125                                              for (uint32_t x=0; x<m_nb_icache;++x) { \
     126                                                  delete [] r_icache_miss_val[x]; \
     127                                                  delete [] r_icache_miss_buf[x]; \
     128                                              } \
     129                                              delete [] r_icache_miss_val; \
     130                                              delete [] r_icache_miss_buf; \
     131                                              for (uint32_t x=0; x<m_nb_dcache;++x) { \
     132                                                  delete [] r_dcache_miss_val[x]; \
     133                                                  delete [] r_dcache_miss_buf[x]; \
     134                                              } \
     135                                              delete [] r_dcache_miss_val; \
     136                                              delete [] r_dcache_miss_buf; \
     137                                          } while (0)
     138# define CACHE_MISS_BUF_RESET(c)           
     139# define CACHE_MISS_BUF_REQ_INIT(c,x)     do { \
     140                                              for (uint32_t i=0; i<m_##c##cache_words;++i) \
     141                                                  r_##c##cache_miss_val[x][i] = false; \
     142                                          } while (0)
     143# define CACHE_MISS_BUF_RSP_VAL(c,x,n)    r_##c##cache_miss_val[x][n]
     144# define CACHE_MISS_BUF_RSP_ACK(c,x)      true
     145# define CACHE_MISS_BUF_RSP_DATA(c,x,n)   r_##c##cache_miss_buf[x][n]
     146# define CACHE_MISS_BUF_RSP_POP(c,x)         
     147# define CACHE_MISS_BUF_RSP_PUSH(c,x,n,d) do { \
     148                                              r_##c##cache_miss_val[x][n] = true; \
     149                                              r_##c##cache_miss_buf[x][n] = d; \
     150                                          } while (0)
     151# define CACHE_MISS_BUF_RSP_PRINT(c)      do { \
     152                                              for (uint32_t x=0; x<m_nb_##c##cache;++x) \
     153                                                  for (uint32_t i=0; i<m_##c##cache_words;++i) \
     154                                                      PRINTF("%d %x |",r_##c##cache_miss_val[x][i],r_##c##cache_miss_buf[x][i]); PRINTF("\n"); \
     155                                          } while (0)
     156#endif
     157
     158// =====[ MULTI_CACHE ]==============================
     159
     160#if (CC_XCACHE_WRAPPER_MULTI_CACHE==1)
     161# define get_num_icache(     addr,num_cpu)   get_num_cache     (addr)         
     162# define get_num_icache_only(addr,num_cpu)   get_num_cache_only(addr)         
     163# define set_num_icache(     addr,num_cache) set_num_cache     (addr,num_cache)
     164# define set_num_icache_only(addr,num_cache) set_num_cache_only(addr,num_cache)
     165# define get_num_dcache(     addr)           get_num_cache     (addr)         
     166# define get_num_dcache_only(addr)           get_num_cache_only(addr)         
     167# define set_num_dcache(     addr,num_cache) set_num_cache     (addr,num_cache)
     168# define set_num_dcache_only(addr,num_cache) set_num_cache_only(addr,num_cache)
     169#elif (CC_XCACHE_WRAPPER_MULTI_CACHE==2)
     170# define get_num_icache(     addr,num_cpu)   num_cpu
     171# define get_num_icache_only(addr,num_cpu)   num_cpu
     172# define set_num_icache(     addr,num_cache) do  {} while (0)
     173# define set_num_icache_only(addr,num_cache) addr
     174# define get_num_dcache(     addr)           get_num_cache     (addr)         
     175# define get_num_dcache_only(addr)           get_num_cache_only(addr)         
     176# define set_num_dcache(     addr,num_cache) set_num_cache     (addr,num_cache)
     177# define set_num_dcache_only(addr,num_cache) set_num_cache_only(addr,num_cache)
    81178#else
    82 # define CACHE_MISS_BUF_ALLOC           do { \
    83                                         r_icache_miss_val = new bool  [m_icache_words]; \
    84                                         r_icache_miss_buf = new data_t[m_icache_words]; \
    85                                         r_dcache_miss_val = new bool  [m_dcache_words]; \
    86                                         r_dcache_miss_buf = new data_t[m_dcache_words]; \
    87                                         } while (0)
    88 # define CACHE_MISS_BUF_DEALLOC         do { \
    89                                         delete [] r_icache_miss_val; \
    90                                         delete [] r_icache_miss_buf; \
    91                                         delete [] r_dcache_miss_val; \
    92                                         delete [] r_dcache_miss_buf; \
    93                                         } while (0)
    94 # define CACHE_MISS_BUF_RESET(c)
    95 # define CACHE_MISS_BUF_REQ_INIT(c)     do {for (uint32_t i=0; i<m_##c##cache_words;++i) r_##c##cache_miss_val[i] = false;} while (0)
    96 # define CACHE_MISS_BUF_RSP_VAL(c,n)    r_##c##cache_miss_val[n]
    97 # define CACHE_MISS_BUF_RSP_ACK(c)      true
    98 # define CACHE_MISS_BUF_RSP_DATA(c,n)   r_##c##cache_miss_buf[n]
    99 # define CACHE_MISS_BUF_RSP_POP(c)
    100 # define CACHE_MISS_BUF_RSP_PUSH(c,n,d) do {r_##c##cache_miss_val[n] = true; r_##c##cache_miss_buf[n] = d;} while (0)
    101 # define CACHE_MISS_BUF_RSP_PRINT(c)    do {for (uint32_t i=0; i<m_##c##cache_words;++i) PRINTF("%d %x |",r_##c##cache_miss_val[i],r_##c##cache_miss_buf[i]); PRINTF("\n");} while (0)
     179#error "Invalid value to CC_XCACHE_WRAPPER_MULTI_CACHE"
    102180#endif
    103181
     
    170248        const char *cleanup_fsm_state_str[] = {
    171249            "CLEANUP_IDLE",
    172             "CLEANUP_DCACHE",
    173             "CLEANUP_ICACHE",
     250            "CLEANUP_REQ",
     251            "CLEANUP_RSP_DCACHE",
     252            "CLEANUP_RSP_ICACHE",
    174253        };
    175254    }
     
    189268            const soclib::common::IntTab &initiator_index_c,
    190269            const soclib::common::IntTab &target_index,
     270            size_t nb_cpu,
     271            size_t nb_dcache,
    191272            size_t icache_ways,
    192273            size_t icache_sets,
     
    210291            m_cacheability_table(mtp.getCacheabilityTable<vci_addr_t>()),
    211292            m_segment(mtc.getSegment(target_index)),
    212             m_iss(this->name(), proc_id),
    213293            m_srcid_rw(mtp.indexForId(initiator_index_rw)),
    214294            m_srcid_c(mtc.indexForId(initiator_index_c)),
    215295
     296            m_nb_cpu(nb_cpu),
     297#if   (CC_XCACHE_WRAPPER_MULTI_CACHE==1)
     298            m_nb_icache(nb_dcache),
     299#elif (CC_XCACHE_WRAPPER_MULTI_CACHE==2)
     300            m_nb_icache(m_nb_cpu),
     301#endif
     302            m_nb_dcache(nb_dcache),
     303            m_nb_cache((m_nb_dcache>m_nb_icache)?m_nb_dcache:m_nb_icache),
    216304            m_dcache_ways(dcache_ways),
    217305            m_dcache_words(dcache_words),
    218             m_dcache_words_shift(uint32_log2(dcache_words)+2),
     306            m_dcache_words_shift(uint32_log2(dcache_words)+uint32_log2(sizeof(data_t))),
    219307            m_dcache_yzmask((~0)<<m_dcache_words_shift),
    220308            m_icache_ways(icache_ways),
    221309            m_icache_words(icache_words),
    222             m_icache_words_shift(uint32_log2(icache_words)+2),
     310            m_icache_words_shift(uint32_log2(icache_words)+uint32_log2(sizeof(data_t))),
    223311            m_icache_yzmask((~0)<<m_icache_words_shift),
    224312            m_cache_words((dcache_words)?dcache_words:icache_words),
    225313
    226             r_dcache_fsm("r_dcache_fsm"),
    227             r_dcache_fsm_save("r_dcache_fsm_save"),
    228             r_dcache_addr_save("r_dcache_addr_save"),
    229             r_dcache_wdata_save("r_dcache_wdata_save"),
    230             r_dcache_rdata_save("r_dcache_rdata_save"),
    231             r_dcache_type_save("r_dcache_type_save"),
    232             r_dcache_be_save("r_dcache_be_save"),
    233             r_dcache_cached_save("r_dcache_cached_save"),
    234             r_dcache_cleanup_req("r_dcache_cleanup_req"),
    235             r_dcache_cleanup_line("r_dcache_cleanup_line"),
    236             r_dcache_miss_req("r_dcache_miss_req"),
    237             r_dcache_miss_way("r_dcache_miss_way"),
    238             r_dcache_miss_set("r_dcache_miss_set"),
    239             r_dcache_unc_req("r_dcache_unc_req"),
    240             r_dcache_sc_req("r_dcache_sc_req"),
    241             r_dcache_inval_rsp("r_dcache_inval_rsp"),
    242             r_dcache_update_addr("r_dcache_update_addr"),
    243             r_dcache_ll_data("r_dcache_ll_data"),
    244             r_dcache_ll_addr("r_dcache_ll_addr"),
    245             r_dcache_ll_valid("r_dcache_ll_valid"),
    246             r_dcache_previous_unc("r_dcache_previous_unc"),
    247 
    248             r_icache_fsm("r_icache_fsm"),
    249             r_icache_fsm_save("r_icache_fsm_save"),
    250             r_icache_addr_save("r_icache_addr_save"),
    251             r_icache_miss_req("r_icache_miss_req"),
    252             r_icache_miss_way("r_icache_miss_way"),
    253             r_icache_miss_set("r_icache_miss_set"),
    254             r_icache_unc_req("r_icache_unc_req"),
    255             r_icache_cleanup_req("r_icache_cleanup_req"),
    256             r_icache_cleanup_line("r_icache_cleanup_line"),
    257             r_icache_inval_rsp("r_icache_inval_rsp"),
    258             r_icache_update_addr("r_icache_update_addr"),
     314            r_cpu_prior("r_cpu_prior"),
    259315
    260316            r_vci_cmd_fsm("r_vci_cmd_fsm"),
     
    263319            r_vci_cmd_cpt("r_vci_cmd_cpt"),
    264320            r_vci_cmd_dcache_prior("r_vci_cmd_dcache_prior"),
     321            r_vci_cmd_num_cache("r_vci_cmd_num_cache"),
    265322
    266323            r_vci_rsp_fsm("r_vci_rsp_fsm"),
    267             r_vci_rsp_ins_error("r_vci_rsp_ins_error"),
    268             r_vci_rsp_data_error("r_vci_rsp_data_error"),
    269324            r_vci_rsp_cpt("r_vci_rsp_cpt"),
    270             r_vci_rsp_ack("r_vci_rsp_ack"),
    271 
    272             r_icache_buf_unc_valid("r_icache_buf_unc_valid"),
     325          //s_vci_rsp_ack("s_vci_rsp_ack"),
     326            r_vci_rsp_num_cache("r_vci_rsp_num_cache"),
    273327
    274328#if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
     
    277331
    278332            r_vci_tgt_fsm("r_vci_tgt_fsm"),
    279             r_tgt_addr("r_tgt_addr"),
     333            r_tgt_iaddr("r_tgt_iaddr"),
     334            r_tgt_daddr("r_tgt_daddr"),
    280335            r_tgt_word("r_tgt_word"),
    281336            r_tgt_update("r_tgt_update"),
     
    286341            r_tgt_trdid("r_tgt_trdid"),
    287342         // r_tgt_plen("r_tgt_plen"),
    288             r_tgt_icache_req("r_tgt_icache_req"),
    289             r_tgt_dcache_req("r_tgt_dcache_req"),
    290             r_tgt_icache_rsp("r_tgt_icache_rsp"),
    291             r_tgt_dcache_rsp("r_tgt_dcache_rsp"),
     343            r_tgt_num_cache("r_tgt_num_cache"),
    292344
    293345            r_cleanup_fsm("r_cleanup_fsm"),
    294 
    295             r_wbuf("r_wbuf", wbuf_nwords, wbuf_nlines, wbuf_timeout, dcache_words),
    296             r_icache("icache", icache_ways, icache_sets, icache_words),
    297             r_dcache("dcache", dcache_ways, dcache_sets, dcache_words)
     346            r_cleanup_num_cache("r_cleanup_num_cache"),
     347            r_cleanup_icache("r_cleanup_icache"),
     348
     349            m_num_cache_LSB(uint32_log2(icache_words) + uint32_log2(sizeof(data_t))),
     350            m_num_cache_MSB(uint32_log2(nb_dcache) + m_num_cache_LSB)
    298351            {
    299352                // Size of word is 32 bits
    300                 ASSERT( (icache_words*vci_param::B) < (1<<vci_param::K),
    301                         "I need more PLEN bits");
    302 
    303                 ASSERT( (vci_param::T > 2) and ((1<<(vci_param::T-1)) >= wbuf_nlines),
    304                         "I need more TRDID bits");
    305 
     353                ASSERT((icache_words*vci_param::B) < (1<<vci_param::K),
     354                       "Need more PLEN bits.");
     355
     356                ASSERT((vci_param::T > 2) and ((1<<(vci_param::T-1)) >= (wbuf_nlines/m_nb_dcache)),
     357                       "Need more TRDID bits.");
     358
     359                ASSERT(uint32_log2(nb_dcache) <= (1<<vci_param::P),
     360                       "Need more PKTID bits.");
     361               
     362                ASSERT(IS_POW_OF_2(m_nb_dcache),
     363                       "nb_dcache must be a power of 2.");
     364
     365                ASSERT(IS_POW_OF_2(m_nb_cpu) and (m_nb_cpu <= m_nb_dcache) and (m_nb_cpu > 0),
     366                       "nb cpu must be a multiple of nb cache.");
     367
     368                ASSERT(IS_POW_OF_2(m_icache_ways) and (m_nb_icache <= m_icache_ways),
     369                       "nb icache ways must be a multiple of nb cache.");
     370
     371                ASSERT(IS_POW_OF_2(m_dcache_ways) and (m_nb_dcache <= m_dcache_ways),
     372                       "nb dcache ways must be a multiple of nb cache.");
     373
     374                ASSERT(icache_words == dcache_words,
     375                       "icache_words must be equal at dcache_words.");
     376
     377                ASSERT(IS_POW_OF_2(wbuf_nlines) and (m_nb_dcache <= wbuf_nlines),
     378                       "wbuf_nlines must be a multiple of nb cache.");
     379
     380                // FIXME : s'adapter à la taille des requêtes XTN_READ/XTN_WRITE
     381                ASSERT((m_nb_dcache == 1) or (dcache_words >= 16),
     382                       "When multi cache is activated, need 4 bits (16 word) to the cache set .");
     383
     384                p_irq = new sc_in<bool> * [m_nb_cpu];
     385                for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     386                    p_irq [num_cpu] = new sc_in<bool> [iss_t::n_irq];
     387
     388                m_iss = new iss_t * [m_nb_cpu];
     389                for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     390                {
     391                    std::ostringstream iss_name("");
     392                    iss_name << this->name() << "_" << num_cpu;
     393
     394                    m_iss[num_cpu] = new iss_t (iss_name.str().c_str(), proc_id+num_cpu);
     395                }
     396               
    306397                CACHE_MISS_BUF_ALLOC;
    307398
    308                 r_tgt_buf = new data_t[m_cache_words];
    309                 r_tgt_be  = new be_t  [m_cache_words];
     399                r_icache_lock          = new sc_signal<uint32_t>[m_nb_icache];
     400                r_dcache_lock          = new sc_signal<uint32_t>[m_nb_dcache];
     401                r_dcache_sync          = new sc_signal<bool>    [m_nb_dcache];
     402
     403                r_icache_fsm           = new sc_signal<int>     [m_nb_icache];
     404                r_icache_fsm_save      = new sc_signal<int>     [m_nb_icache];
     405                r_icache_addr_save     = new sc_signal<addr_40> [m_nb_icache];
     406                r_icache_miss_req      = new sc_signal<bool>    [m_nb_icache];
     407                r_icache_miss_way      = new sc_signal<size_t>  [m_nb_icache];
     408                r_icache_miss_set      = new sc_signal<size_t>  [m_nb_icache];
     409                r_icache_unc_req       = new sc_signal<bool>    [m_nb_icache];
     410                r_icache_cleanup_req   = new sc_signal<bool>    [m_nb_icache];
     411                r_icache_cleanup_line  = new sc_signal<addr_40> [m_nb_icache];
     412                r_icache_inval_rsp     = new sc_signal<bool>    [m_nb_icache];
     413                r_icache_update_addr   = new sc_signal<size_t>  [m_nb_icache];
     414                r_icache_buf_unc_valid = new sc_signal<bool>    [m_nb_icache];
     415
     416                r_dcache_fsm           = new sc_signal<int>     [m_nb_dcache];
     417                r_dcache_fsm_save      = new sc_signal<int>     [m_nb_dcache];
     418                r_dcache_addr_save     = new sc_signal<addr_40> [m_nb_dcache];
     419                r_dcache_wdata_save    = new sc_signal<data_t>  [m_nb_dcache];
     420                r_dcache_rdata_save    = new sc_signal<data_t>  [m_nb_dcache];
     421                r_dcache_type_save     = new sc_signal<int>     [m_nb_dcache];
     422                r_dcache_be_save       = new sc_signal<be_t>    [m_nb_dcache];
     423                r_dcache_cached_save   = new sc_signal<bool>    [m_nb_dcache];
     424                r_dcache_cleanup_req   = new sc_signal<bool>    [m_nb_dcache];
     425                r_dcache_cleanup_line  = new sc_signal<addr_40> [m_nb_dcache];
     426                r_dcache_miss_req      = new sc_signal<bool>    [m_nb_dcache];
     427                r_dcache_miss_way      = new sc_signal<size_t>  [m_nb_dcache];
     428                r_dcache_miss_set      = new sc_signal<size_t>  [m_nb_dcache];
     429                r_dcache_unc_req       = new sc_signal<bool>    [m_nb_dcache];
     430                r_dcache_sc_req        = new sc_signal<bool>    [m_nb_dcache];
     431                r_dcache_inval_rsp     = new sc_signal<bool>    [m_nb_dcache];
     432                r_dcache_update_addr   = new sc_signal<size_t>  [m_nb_dcache];
     433                r_dcache_previous_unc  = new sc_signal<bool>    [m_nb_dcache];
     434
     435                r_dcache_num_cpu_save  = new sc_signal<uint32_t>   [m_nb_dcache];
     436                r_dcache_ll_data       = new sc_signal<data_64>  * [m_nb_dcache];
     437                r_dcache_ll_addr       = new sc_signal<addr_40>  * [m_nb_dcache];
     438                r_dcache_ll_valid      = new sc_signal<bool>     * [m_nb_dcache];
     439                for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     440                {
     441                    r_dcache_ll_data    [num_cache] = new sc_signal<data_64>  [m_nb_cpu];
     442                    r_dcache_ll_addr    [num_cache] = new sc_signal<addr_40>  [m_nb_cpu];
     443                    r_dcache_ll_valid   [num_cache] = new sc_signal<bool>     [m_nb_cpu];
     444                }
     445
     446                r_tgt_icache_req       = new sc_signal<bool>    [m_nb_icache];
     447                r_tgt_icache_rsp       = new sc_signal<bool>    [m_nb_icache];
     448                r_tgt_dcache_req       = new sc_signal<bool>    [m_nb_dcache];
     449                r_tgt_dcache_rsp       = new sc_signal<bool>    [m_nb_dcache];
     450
     451                r_tgt_buf              = new data_t             [m_cache_words];
     452                r_tgt_be               = new be_t               [m_cache_words];
     453
     454                r_vci_rsp_ins_error    = new sc_signal<bool>    [m_nb_icache];
     455                r_vci_rsp_data_error   = new sc_signal<bool>    [m_nb_dcache];
     456
     457                ireq                   = new typename iss_t::InstructionRequest  [m_nb_icache];
     458                irsp                   = new typename iss_t::InstructionResponse [m_nb_icache];
     459                ireq_cached            = new bool                                [m_nb_icache];
     460                ireq_num_cpu           = new uint32_t                            [m_nb_dcache];
     461
     462                dreq                   = new typename iss_t::DataRequest         [m_nb_dcache];
     463                drsp                   = new typename iss_t::DataResponse        [m_nb_dcache];
     464                dreq_cached            = new bool                                [m_nb_dcache];
     465                dreq_num_cpu           = new uint32_t                            [m_nb_dcache];
     466
     467                m_cpt_icache_access = new uint32_t [m_nb_icache];
     468                m_cpt_dcache_access = new uint32_t [m_nb_dcache];
     469
     470               
     471                m_cpt_fsm_dcache  = new uint32_t * [m_nb_dcache];
     472                m_cpt_fsm_icache  = new uint32_t * [m_nb_icache];
     473                for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     474                    m_cpt_fsm_dcache[num_cache]  = new uint32_t [soclib::common::size(dcache_fsm_state_str )];
     475                for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     476                    m_cpt_fsm_icache[num_cache]  = new uint32_t [soclib::common::size(icache_fsm_state_str )];
     477                m_cpt_fsm_cmd     = new uint32_t [soclib::common::size(cmd_fsm_state_str    )];
     478                m_cpt_fsm_rsp     = new uint32_t [soclib::common::size(rsp_fsm_state_str    )];
     479                m_cpt_fsm_tgt     = new uint32_t [soclib::common::size(tgt_fsm_state_str    )];
     480                m_cpt_fsm_cleanup = new uint32_t [soclib::common::size(cleanup_fsm_state_str)];
     481
     482                m_cpt_frz_cycles  = new uint32_t [m_nb_cpu];
     483                // r_icache_fsm("r_icache_fsm"),
     484                // r_icache_fsm_save("r_icache_fsm_save"),
     485                // r_icache_addr_save("r_icache_addr_save"),
     486                // r_icache_miss_req("r_icache_miss_req"),
     487                // r_icache_miss_way("r_icache_miss_way"),
     488                // r_icache_miss_set("r_icache_miss_set"),
     489                // r_icache_unc_req("r_icache_unc_req"),
     490                // r_icache_cleanup_req("r_icache_cleanup_req"),
     491                // r_icache_cleanup_line("r_icache_cleanup_line"),
     492                // r_icache_inval_rsp("r_icache_inval_rsp"),
     493                // r_icache_update_addr("r_icache_update_addr"),
     494                // r_icache_buf_unc_valid("r_icache_buf_unc_valid"),
     495
     496                // r_dcache_fsm("r_dcache_fsm"),
     497                // r_dcache_fsm_save("r_dcache_fsm_save"),
     498                // r_dcache_addr_save("r_dcache_addr_save"),
     499                // r_dcache_wdata_save("r_dcache_wdata_save"),
     500                // r_dcache_rdata_save("r_dcache_rdata_save"),
     501                // r_dcache_type_save("r_dcache_type_save"),
     502                // r_dcache_be_save("r_dcache_be_save"),
     503                // r_dcache_cached_save("r_dcache_cached_save"),
     504                // r_dcache_cleanup_req("r_dcache_cleanup_req"),
     505                // r_dcache_cleanup_line("r_dcache_cleanup_line"),
     506                // r_dcache_miss_req("r_dcache_miss_req"),
     507                // r_dcache_miss_way("r_dcache_miss_way"),
     508                // r_dcache_miss_set("r_dcache_miss_set"),
     509                // r_dcache_unc_req("r_dcache_unc_req"),
     510                // r_dcache_sc_req("r_dcache_sc_req"),
     511                // r_dcache_inval_rsp("r_dcache_inval_rsp"),
     512                // r_dcache_update_addr("r_dcache_update_addr"),
     513                // r_dcache_ll_data("r_dcache_ll_data"),
     514                // r_dcache_ll_addr("r_dcache_ll_addr"),
     515                // r_dcache_ll_valid("r_dcache_ll_valid"),
     516                // r_dcache_previous_unc("r_dcache_previous_unc"),
     517
     518                // r_tgt_icache_req("r_tgt_icache_req"),
     519                // r_tgt_icache_rsp("r_tgt_icache_rsp"),
     520
     521                // r_tgt_dcache_req("r_tgt_dcache_req"),
     522                // r_tgt_dcache_rsp("r_tgt_dcache_rsp"),
     523
     524                // r_vci_rsp_ins_error("r_vci_rsp_ins_error"),
     525                // r_vci_rsp_data_error("r_vci_rsp_data_error"),
     526
     527                size_t _icache_ways  = icache_ways /m_nb_icache;
     528                size_t _icache_sets  = icache_sets ;
     529                size_t _dcache_ways  = dcache_ways /m_nb_dcache;
     530                size_t _dcache_sets  = dcache_sets ;
     531                size_t _icache_words = icache_words;
     532                size_t _dcache_words = dcache_words;
     533
     534                size_t _wbuf_nwords  = wbuf_nwords ;
     535                size_t _wbuf_nlines  = wbuf_nlines /m_nb_dcache;
     536                size_t _wbuf_timeout = wbuf_timeout;
     537
     538
     539                std::cout << "<VciCcXCacheWrapperV4> Parameters :" << std::endl;
     540                std::cout << "  * nb_cpu             : " << nb_cpu << std::endl;
     541                std::cout << "  * nb_cache           : " << m_nb_icache << " icache(s), " << m_nb_dcache << " dcache(s)" << std::endl;
     542                std::cout << "  * icache (total)     : " <<  icache_ways << " way(s), " <<  icache_sets << " set(s), " <<  icache_words << " word(s)" << std::endl;
     543                std::cout << "  * icache (per cache) : " << _icache_ways << " way(s), " << _icache_sets << " set(s), " << _icache_words << " word(s)" << std::endl;
     544                std::cout << "  * dcache (total)     : " <<  dcache_ways << " way(s), " <<  dcache_sets << " set(s), " <<  dcache_words << " word(s)" << std::endl;
     545                std::cout << "  * dcache (per cache) : " << _dcache_ways << " way(s), " << _dcache_sets << " set(s), " << _dcache_words << " word(s)" << std::endl;
     546                std::cout << "  * wbuf   (total)     : " <<  wbuf_nlines << " line(s), " <<  wbuf_nwords << " word(s), timeout : " <<  wbuf_timeout << std::endl;
     547                std::cout << "  * wbuf   (per cache) : " << _wbuf_nlines << " line(s), " << _wbuf_nwords << " word(s), timeout : " << _wbuf_timeout << std::endl;
     548
     549                r_icache = new GenericCache<vci_addr_t>  * [m_nb_icache];
     550                r_dcache = new GenericCache<vci_addr_t>  * [m_nb_dcache];
     551                r_wbuf   = new MultiWriteBuffer<addr_40> * [m_nb_dcache];
     552
     553               for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     554                {
     555                    r_icache [num_cache] = new GenericCache<vci_addr_t>  ("icache", _icache_ways, _icache_sets, _icache_words);
     556                }
     557               for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     558                {
     559                    r_dcache [num_cache] = new GenericCache<vci_addr_t>  ("dcache", _dcache_ways, _dcache_sets, _dcache_words);
     560                    r_wbuf   [num_cache] = new MultiWriteBuffer<addr_40> ("r_wbuf", _wbuf_nwords, _wbuf_nlines, _wbuf_timeout, _dcache_words);
     561                }
     562
     563                m_num_cache_LSB_mask = 0;
     564                for (uint32_t i=0; i<m_num_cache_LSB; ++i)
     565                {
     566                    m_num_cache_LSB_mask <<= 1;
     567                    m_num_cache_LSB_mask  |= 1;
     568                }
     569                m_num_cache_mask = 0;
     570                for (uint32_t i=0; i<(m_num_cache_MSB-m_num_cache_LSB); ++i)
     571                {
     572                    m_num_cache_mask <<= 1;
     573                    m_num_cache_mask  |= 1;
     574                }
    310575
    311576                SC_METHOD(transition);
     
    316581                dont_initialize();
    317582                sensitive << p_clk.neg();
    318 
    319583
    320584                typename iss_t::CacheInfo cache_info;
     
    326590                cache_info.dcache_assoc     = dcache_ways;
    327591                cache_info.dcache_n_lines   = dcache_sets;
    328                 m_iss.setCacheInfo(cache_info);
    329 
     592
     593                for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     594                    m_iss[num_cpu]->setCacheInfo(cache_info);
     595               
    330596#if CC_XCACHE_WRAPPER_STOP_SIMULATION
    331597                m_stop_simulation               = false;
    332                 m_stop_simulation_nb_frz_cycles = 0;
     598                m_stop_simulation_nb_frz_cycles = new uint32_t [m_nb_cpu];
     599                for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     600                m_stop_simulation_nb_frz_cycles [num_cpu] = 0;
    333601#endif // CC_XCACHE_WRAPPER_STOP_SIMULATION
    334602
    335 #if CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION
    336                 std::ostringstream filename("");
    337                 filename << "Instruction_flow_" << proc_id << ".log";
    338                
    339                 log_dcache_transaction_file.open(filename.str().c_str() ,std::ios::out | std::ios::trunc);
     603#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     604                log_transaction_file_icache = new std::ofstream [m_nb_cpu];
     605                log_transaction_file_dcache = new std::ofstream [m_nb_cpu];
     606                for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     607                {
     608                    {
     609                        std::ostringstream filename("");
     610                        filename << CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION_PATH << "/Transaction_icache-" << proc_id << "_" << num_cpu << ".log";
     611                        log_transaction_file_icache[num_cpu].open(filename.str().c_str() ,std::ios::out | std::ios::trunc);
     612                    }
     613                    {
     614                        std::ostringstream filename("");
     615                        filename << CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION_PATH << "/Transaction_dcache-" << proc_id << "_" << num_cpu << ".log";
     616                        log_transaction_file_dcache[num_cpu].open(filename.str().c_str() ,std::ios::out | std::ios::trunc);
     617                    }
     618                }
     619
     620                {
     621                    std::ostringstream filename("");
     622                    filename << CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION_PATH << "/Transaction_cmd-" << proc_id << ".log";
     623                    log_transaction_file_cmd.open(filename.str().c_str() ,std::ios::out | std::ios::trunc);
     624                }
     625                {
     626                    std::ostringstream filename("");
     627                    filename << CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION_PATH << "/Transaction_tgt-" << proc_id << ".log";
     628                    log_transaction_file_tgt.open(filename.str().c_str() ,std::ios::out | std::ios::trunc);
     629                }
     630                {
     631                    std::ostringstream filename("");
     632                    filename << CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION_PATH << "/Transaction_cleanup-" << proc_id << ".log";
     633                    log_transaction_file_cleanup.open(filename.str().c_str() ,std::ios::out | std::ios::trunc);
     634                }
    340635#endif
    341636            } // end constructor
     
    345640    ///////////////////////////////////
    346641    {
    347 #if CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION
    348         log_dcache_transaction_file.close();
    349 #endif
    350 
     642        delete [] m_stop_simulation_nb_frz_cycles;
     643
     644#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     645        for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     646        {
     647            log_transaction_file_dcache[num_cpu].close();
     648            log_transaction_file_icache[num_cpu].close();
     649        }
     650        delete [] log_transaction_file_dcache;
     651        delete [] log_transaction_file_icache;
     652
     653        log_transaction_file_cmd    .close();
     654        log_transaction_file_tgt    .close();
     655        log_transaction_file_cleanup.close();
     656#endif
     657
     658        delete [] r_icache_lock         ;
     659        delete [] r_dcache_lock         ;
     660        delete [] r_dcache_sync         ;
     661
     662        delete [] r_icache_fsm          ;
     663        delete [] r_icache_fsm_save     ;
     664        delete [] r_icache_addr_save    ;
     665        delete [] r_icache_miss_req     ;
     666        delete [] r_icache_miss_way     ;
     667        delete [] r_icache_miss_set     ;
     668        delete [] r_icache_unc_req      ;
     669        delete [] r_icache_cleanup_req  ;
     670        delete [] r_icache_cleanup_line ;
     671        delete [] r_icache_inval_rsp    ;
     672        delete [] r_icache_update_addr  ;
     673        delete [] r_icache_buf_unc_valid;
     674
     675        delete [] r_dcache_fsm          ;
     676        delete [] r_dcache_fsm_save     ;
     677        delete [] r_dcache_addr_save    ;
     678        delete [] r_dcache_wdata_save   ;
     679        delete [] r_dcache_rdata_save   ;
     680        delete [] r_dcache_type_save    ;
     681        delete [] r_dcache_be_save      ;
     682        delete [] r_dcache_cached_save  ;
     683        delete [] r_dcache_cleanup_req  ;
     684        delete [] r_dcache_cleanup_line ;
     685        delete [] r_dcache_miss_req     ;
     686        delete [] r_dcache_miss_way     ;
     687        delete [] r_dcache_miss_set     ;
     688        delete [] r_dcache_unc_req      ;
     689        delete [] r_dcache_sc_req       ;
     690        delete [] r_dcache_inval_rsp    ;
     691        delete [] r_dcache_update_addr  ;
     692        delete [] r_dcache_previous_unc ;
     693
     694        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     695        {
     696            delete [] r_dcache_ll_data    [num_cache];
     697            delete [] r_dcache_ll_addr    [num_cache];
     698            delete [] r_dcache_ll_valid   [num_cache];
     699        }
     700        delete [] r_dcache_num_cpu_save ;
     701        delete [] r_dcache_ll_data      ;
     702        delete [] r_dcache_ll_addr      ;
     703        delete [] r_dcache_ll_valid     ;
     704
     705        delete [] r_tgt_icache_req      ;
     706        delete [] r_tgt_icache_rsp      ;
     707        delete [] r_tgt_dcache_req      ;
     708        delete [] r_tgt_dcache_rsp      ;
     709
     710        delete [] r_tgt_be ;
    351711        delete [] r_tgt_buf;
    352         delete [] r_tgt_be ;
     712
     713        delete [] r_vci_rsp_ins_error   ;
     714        delete [] r_vci_rsp_data_error  ;
     715
     716        delete [] ireq           ;
     717        delete [] irsp           ;
     718        delete [] ireq_cached    ;
     719        delete [] ireq_num_cpu   ;
     720        delete [] dreq           ;
     721        delete [] drsp           ;
     722        delete [] dreq_cached    ;
     723        delete [] dreq_num_cpu   ;
     724
     725        delete [] m_cpt_frz_cycles;
     726
     727        delete [] m_cpt_icache_access   ;
     728        delete [] m_cpt_dcache_access   ;
     729
     730        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     731        delete [] m_cpt_fsm_dcache [num_cache];
     732        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     733        delete [] m_cpt_fsm_icache [num_cache];
     734       
     735        delete [] m_cpt_fsm_dcache ;
     736        delete [] m_cpt_fsm_icache ;
     737        delete [] m_cpt_fsm_cmd    ;
     738        delete [] m_cpt_fsm_rsp    ;
     739        delete [] m_cpt_fsm_tgt    ;
     740        delete [] m_cpt_fsm_cleanup;
     741
     742        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     743        {
     744            delete r_icache [num_cache];
     745        }
     746        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     747        {
     748            delete r_wbuf   [num_cache];
     749            delete r_dcache [num_cache];
     750        }
     751        delete [] r_wbuf;
     752        delete [] r_icache;
     753        delete [] r_dcache;
     754
    353755
    354756        CACHE_MISS_BUF_DEALLOC;
     757
     758        for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     759        {
     760            delete    m_iss [num_cpu];
     761            delete [] p_irq [num_cpu];
     762        }
     763        delete [] m_iss;
     764        delete [] p_irq;
    355765    }
    356766
     
    359769    ////////////////////////
    360770    {
     771        for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
    361772        std::cout << "CPU " << m_srcid_rw << " : CPI = "
    362             << (float)m_cpt_total_cycles/(m_cpt_total_cycles - m_cpt_frz_cycles) << std::endl ;
     773                  << (float)m_cpt_total_cycles/(m_cpt_total_cycles - m_cpt_frz_cycles[num_cpu]) << std::endl ;
    363774    }
    364775    ////////////////////////
     
    366777    ////////////////////////
    367778    {
    368         float run_cycles = (float)(m_cpt_total_cycles - m_cpt_frz_cycles);
    369 
    370779        uint32_t m_cpt_data_read_cached  = m_cpt_data_read-m_cpt_data_read_uncached;
    371780        uint32_t m_cpt_data_write_cached = m_cpt_data_write-m_cpt_data_write_uncached;
    372781        std::cout << "------------------------------------" << std:: dec << std::endl;
    373782        std::cout << "CPU " << m_srcid_rw << " / Time = " << m_cpt_total_cycles << std::endl;
    374         std::cout << "- CPI                            : " << (float)m_cpt_total_cycles/run_cycles << std::endl ;
    375         std::cout << "- IPC                            : " << (float)run_cycles/m_cpt_total_cycles << std::endl ;
     783        for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     784        {
     785            float run_cycles = (float)(m_cpt_total_cycles - m_cpt_frz_cycles[num_cpu]);
     786
     787            std::cout << "- CPI                            : [" << num_cpu << "] "<< (float)m_cpt_total_cycles/run_cycles << std::endl ;
     788            std::cout << "- IPC                            : [" << num_cpu << "] "<< (float)run_cycles/m_cpt_total_cycles << std::endl ;
     789        }
    376790        std::cout << "- DATA READ *                    : " << m_cpt_data_read << std::endl ;
    377791        std::cout << "  + Uncached                     : " << m_cpt_data_read_uncached << " (" << (float)m_cpt_data_read_uncached*100.0/(float)m_cpt_data_read << "%)" << std::endl ;
     
    404818        std::cout << "  + DCACHE Only                  : " << (float)m_cpt_cc_inval_dcache   *100.0/(float)m_cpt_cc_inval << "%" << std::endl;
    405819        std::cout << "  + BROADCAST                    : " << (float)m_cpt_cc_inval_broadcast*100.0/(float)m_cpt_cc_inval << "%" << std::endl;
     820
     821        uint32_t m_cpt_icache_access_all = 0;
     822        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     823            m_cpt_icache_access_all += m_cpt_icache_access [num_cache];
     824
     825        std::cout << "- ICACHE ACCESS                  : " << m_cpt_icache_access_all << std::endl;
     826        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     827            std::cout << "  + [" << num_cache << "] : " << m_cpt_icache_access [num_cache] << " (" << (float)m_cpt_icache_access [num_cache]*100.0/(float)m_cpt_icache_access_all << "%)" << std::endl;
     828
     829        uint32_t m_cpt_dcache_access_all = 0;
     830        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     831            m_cpt_dcache_access_all += m_cpt_dcache_access [num_cache];
     832
     833        std::cout << "- DCACHE ACCESS                  : " << m_cpt_dcache_access_all << std::endl;
     834        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     835            std::cout << "  + [" << num_cache << "] : " << m_cpt_dcache_access [num_cache] << " (" << (float)m_cpt_dcache_access [num_cache]*100.0/(float)m_cpt_dcache_access_all << "%)" << std::endl;
     836
     837        std::cout << "- DCACHE FSM" << std::endl;
     838        for (uint32_t i=0; i<soclib::common::size(dcache_fsm_state_str ); ++i)
     839        {
     840            std::cout << "  + "  << dcache_fsm_state_str[i] << " :\t ";
     841            for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     842                std::cout << m_cpt_fsm_dcache [num_cache][i] << ", ";
     843            std::cout << std::endl;
     844        }
     845        std::cout << "- ICACHE FSM" << std::endl;
     846        for (uint32_t i=0; i<soclib::common::size(icache_fsm_state_str ); ++i)
     847        {
     848            std::cout << "  + "  << icache_fsm_state_str[i] << " :\t ";
     849            for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     850                std::cout << m_cpt_fsm_icache [num_cache][i] << ", ";
     851            std::cout << std::endl;
     852        }
     853        std::cout << "- CMD FSM" << std::endl;
     854        for (uint32_t i=0; i<soclib::common::size(cmd_fsm_state_str ); ++i)
     855            std::cout << "  + " << cmd_fsm_state_str[i] << " :\t " << m_cpt_fsm_cmd [i] << std::endl;
     856        std::cout << "- RSP FSM" << std::endl;
     857        for (uint32_t i=0; i<soclib::common::size(rsp_fsm_state_str ); ++i)
     858            std::cout << "  + " << rsp_fsm_state_str[i] << " :\t " << m_cpt_fsm_rsp [i] << std::endl;
     859        std::cout << "- TGT FSM" << std::endl;
     860        for (uint32_t i=0; i<soclib::common::size(tgt_fsm_state_str ); ++i)
     861            std::cout << "  + "  << tgt_fsm_state_str[i] << " :\t " << m_cpt_fsm_tgt [i] << std::endl;
     862        std::cout << "- CLEANUP FSM" << std::endl;
     863        for (uint32_t i=0; i<soclib::common::size(cleanup_fsm_state_str ); ++i)
     864            std::cout << "  + "  << cleanup_fsm_state_str[i] << " :\t " << m_cpt_fsm_cleanup [i] << std::endl;
     865
    406866        std::cout << "* : accepted or not by the cache" << std::endl ;
    407867
    408         r_wbuf.printStatistics();
     868        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     869            r_wbuf[num_cache]->printStatistics();
    409870    }
    410871
     
    421882        typename iss_t::DataRequest         dreq;
    422883
    423         m_iss.getRequests( ireq, dreq );
    424884        std::cout << std::dec << "Proc \"" << name() << "\"" << std::endl;
    425         std::cout << ireq << std::endl;
    426         std::cout << dreq << std::endl;
    427         std::cout << "  " << dcache_fsm_state_str[r_dcache_fsm]
    428                   << "  " << icache_fsm_state_str[r_icache_fsm]
    429                   << "  " << cmd_fsm_state_str[r_vci_cmd_fsm]
     885
     886        for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     887        {
     888            m_iss[num_cpu]->getRequests( ireq, dreq );
     889            std::cout << ireq << std::endl;
     890            std::cout << dreq << std::endl;
     891        }
     892        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     893        std::cout << "  " << icache_fsm_state_str[r_icache_fsm[num_cache]] << std::endl;
     894        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     895        std::cout << "  " << dcache_fsm_state_str[r_dcache_fsm[num_cache]] << std::endl;
     896           
     897        std::cout << "  " << cmd_fsm_state_str[r_vci_cmd_fsm]
    430898                  << "  " << rsp_fsm_state_str[r_vci_rsp_fsm]
    431899                  << "  " << tgt_fsm_state_str[r_vci_tgt_fsm]
     
    434902        if(mode & 0x1)
    435903        {
    436             r_wbuf.printTrace((mode>>1)&1);
     904            for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     905                r_wbuf[num_cache]->printTrace((mode>>1)&1);
    437906        }
    438907        if(mode & 0x4)
    439908        {
    440909            std::cout << "  Data cache" << std::endl;
    441             r_dcache.printTrace();
     910            for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     911                r_dcache[num_cache]->printTrace();
    442912        }
    443913        if(mode & 0x8)
    444914        {
    445915            std::cout << "  Instruction cache" << std::endl;
    446             r_icache.printTrace();
     916            for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     917                r_icache[num_cache]->printTrace();
    447918        }
    448 
    449         // if(mode & 0x10)
    450         // {
    451         //     std::cout << "  Icache miss buffer : ";
    452         //     CACHE_MISS_BUF_RSP_PRINT(i);
    453         //     std::cout << std::endl;
    454 
    455         //     std::cout << "  Dcache miss buffer : ";
    456         //     CACHE_MISS_BUF_RSP_PRINT(d);
    457         //     std::cout << std::endl;
    458         // }
    459919    }
    460920
     
    465925        if ( not p_resetn.read() ) {
    466926
    467             m_iss.reset();
     927            r_cpu_prior = 0;
     928
     929            for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     930                m_iss[num_cpu]->reset();
    468931
    469932            // FSM states
    470             r_dcache_fsm  = DCACHE_IDLE;
    471             r_icache_fsm  = ICACHE_IDLE;
     933            for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     934            {
     935                r_icache_fsm [num_cache] = ICACHE_IDLE;
     936
     937                r_icache_lock[num_cache] = m_nb_cpu;
     938            }
     939            for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     940            {
     941                r_dcache_fsm [num_cache] = DCACHE_IDLE;
     942
     943                r_dcache_lock[num_cache] = m_nb_cpu;
     944                r_dcache_sync[num_cache] = false;
     945            }
     946
    472947            r_vci_cmd_fsm = CMD_IDLE;
    473948            r_vci_rsp_fsm = RSP_IDLE;
     
    475950            r_cleanup_fsm = CLEANUP_IDLE;
    476951
     952            for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     953            {
    477954            // write buffer & caches
    478             r_wbuf.reset();
    479             r_icache.reset();
    480             r_dcache.reset();
     955            r_icache[num_cache]->reset();
    481956
    482957            // synchronisation flip-flops from ICACHE & DCACHE FSMs to VCI  FSMs
    483             r_icache_miss_req    = false;
    484             r_icache_unc_req     = false;
    485             r_icache_cleanup_req = false;
    486             r_dcache_miss_req    = false;
    487             r_dcache_unc_req     = false;
    488             r_dcache_sc_req      = false;
    489             r_dcache_cleanup_req = false;
    490             r_dcache_previous_unc= false;
     958            r_icache_miss_req    [num_cache] = false;
     959            r_icache_unc_req     [num_cache] = false;
     960            r_icache_cleanup_req [num_cache] = false;
     961
     962            // internal messages in DCACHE et ICACHE FSMs
     963            r_icache_inval_rsp   [num_cache] = false;
     964
     965            // error signals from the VCI RSP FSM to the ICACHE or DCACHE FSMs
     966            r_icache_buf_unc_valid [num_cache] = false;
    491967
    492968            // synchronisation flip-flops from TGT FSM to ICACHE & DCACHE FSMs
    493             r_tgt_icache_req     = false;
    494             r_tgt_dcache_req     = false;
    495             r_tgt_icache_rsp     = false;
    496             r_tgt_dcache_rsp     = false;
     969            r_tgt_icache_req     [num_cache] = false;
     970            r_tgt_icache_rsp     [num_cache] = false;
     971
     972            r_vci_rsp_ins_error  [num_cache] = false;
     973            }// end for num_cache
     974
     975            for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     976            {
     977            // write buffer & caches
     978            r_wbuf  [num_cache]->reset();
     979            r_dcache[num_cache]->reset();
     980
     981            // synchronisation flip-flops from ICACHE & DCACHE FSMs to VCI  FSMs
     982            r_dcache_miss_req    [num_cache] = false;
     983            r_dcache_unc_req     [num_cache] = false;
     984            r_dcache_sc_req      [num_cache] = false;
     985            r_dcache_cleanup_req [num_cache] = false;
     986            r_dcache_previous_unc[num_cache] = false;
     987
     988            // internal messages in DCACHE et ICACHE FSMs
     989            r_dcache_inval_rsp   [num_cache] = false;
     990
     991            // error signals from the VCI RSP FSM to the ICACHE or DCACHE FSMs
     992            for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     993                r_dcache_ll_valid      [num_cache][num_cpu] = false;
     994
     995            // synchronisation flip-flops from TGT FSM to ICACHE & DCACHE FSMs
     996            r_tgt_dcache_req     [num_cache] = false;
     997            r_tgt_dcache_rsp     [num_cache] = false;
     998
     999            r_vci_rsp_data_error [num_cache] = false;
     1000            }// end for num_cache
    4971001
    4981002#if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
     
    5001004#endif
    5011005
    502 
    503             // internal messages in DCACHE et ICACHE FSMs
    504             r_icache_inval_rsp   = false;
    505             r_dcache_inval_rsp   = false;
    506 
    507             // error signals from the VCI RSP FSM to the ICACHE or DCACHE FSMs
    508             r_dcache_ll_valid      = false;
    509             r_icache_buf_unc_valid = false;
    510 
    5111006            r_vci_cmd_dcache_prior = false;
    512 
    513             r_vci_rsp_data_error   = false;
    514             r_vci_rsp_ins_error    = false;
    5151007
    5161008            CACHE_MISS_BUF_RESET(i);
     
    5351027            m_cpt_cc_update_dcache_word_useful = 0;
    5361028
    537             m_cpt_frz_cycles   = 0;
     1029            for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     1030            m_cpt_frz_cycles [num_cpu]  = 0;
    5381031            m_cpt_total_cycles = 0;
    5391032
     
    5631056            m_length_write_transaction = 0;
    5641057
     1058            for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1059            {
     1060                m_cpt_icache_access [num_cache] = 0;
     1061
     1062                for (uint32_t i=0; i<soclib::common::size(icache_fsm_state_str ); ++i)
     1063                    m_cpt_fsm_icache  [num_cache][i] = 0;
     1064            }
     1065            for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     1066            {
     1067                m_cpt_dcache_access [num_cache] = 0;
     1068
     1069                for (uint32_t i=0; i<soclib::common::size(dcache_fsm_state_str ); ++i)
     1070                    m_cpt_fsm_dcache  [num_cache][i] = 0;
     1071            }
     1072
     1073            for (uint32_t i=0; i<soclib::common::size(cmd_fsm_state_str    ); ++i)
     1074                m_cpt_fsm_cmd     [i] = 0;
     1075            for (uint32_t i=0; i<soclib::common::size(rsp_fsm_state_str    ); ++i)
     1076                m_cpt_fsm_rsp     [i] = 0;
     1077            for (uint32_t i=0; i<soclib::common::size(tgt_fsm_state_str    ); ++i)
     1078                m_cpt_fsm_tgt     [i] = 0;
     1079            for (uint32_t i=0; i<soclib::common::size(cleanup_fsm_state_str); ++i)
     1080                m_cpt_fsm_cleanup [i] = 0;
     1081
    5651082            return;
    5661083        }
     
    5691086
    5701087        PRINTF("--------------------------------------------\n");
    571         PRINTF("  * CC_XCACHE_WRAPPER \"%s\" - Time = %d\n",name().c_str(),(uint32_t)m_cpt_total_cycles);
    572         PRINTF("    * fsm dcache          = %s\n",dcache_fsm_state_str[r_dcache_fsm]);
    573         PRINTF("    * fsm icache          = %s\n",icache_fsm_state_str[r_icache_fsm]);
    574         PRINTF("    * fsm cmd             = %s\n",cmd_fsm_state_str[r_vci_cmd_fsm]);
    575         PRINTF("    * fsm rsp             = %s\n",rsp_fsm_state_str[r_vci_rsp_fsm]);
    576         PRINTF("    * fsm tgt             = %s\n",tgt_fsm_state_str[r_vci_tgt_fsm]);
    577         PRINTF("    * fsm cleanup         = %s\n",cleanup_fsm_state_str[r_cleanup_fsm]);
    578         PRINTF("    * ll info             : %d %llx %llx\n",r_dcache_ll_valid.read(), (uint64_t)r_dcache_ll_addr.read(), (uint64_t)r_dcache_ll_data.read());
    579         PRINTF("    * dcache_previous_unc : %d\n",r_dcache_previous_unc.read());
     1088        PRINTF("  * CC_XCACHE_WRAPPER \"%s\" Transition - Time = %d\n",name().c_str(),(uint32_t)m_cpt_total_cycles);
     1089        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     1090        PRINTF("    * fsm dcache              = [%.2d] %s - (%.2d) %llx (%llx)\n",num_cache,dcache_fsm_state_str[r_dcache_fsm[num_cache]],r_dcache_lock[num_cache].read(),(uint64_t)r_dcache_addr_save[num_cache].read(),(uint64_t)set_num_dcache_only(r_dcache_addr_save[num_cache].read(),num_cache));
     1091        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1092        PRINTF("    * fsm icache              = [%.2d] %s - (%.2d) %llx (%llx)\n",num_cache,icache_fsm_state_str[r_icache_fsm[num_cache]],r_icache_lock[num_cache].read(),(uint64_t)r_icache_addr_save[num_cache].read(),(uint64_t)set_num_icache_only(r_icache_addr_save[num_cache].read(),num_cache));
     1093        PRINTF("    * fsm cmd                 = (%.2d) %s\n",r_vci_cmd_num_cache.read(), cmd_fsm_state_str[r_vci_cmd_fsm]);
     1094        PRINTF("    * fsm rsp                 = (%.2d) %s\n",r_vci_rsp_num_cache.read(), rsp_fsm_state_str[r_vci_rsp_fsm]);
     1095        PRINTF("    * fsm tgt                 = (%.2d) %s - i %llx d %llx\n",r_tgt_num_cache.read(), tgt_fsm_state_str[r_vci_tgt_fsm],(uint64_t)r_tgt_iaddr.read(),(uint64_t)r_tgt_daddr.read());
     1096      //PRINTF("    * fsm tgt                 =      %s - %llx\n",tgt_fsm_state_str[r_vci_tgt_fsm],(uint64_t)r_tgt_addr.read());
     1097        PRINTF("    * fsm cleanup             = (%.2d) %s\n",r_cleanup_num_cache.read(), cleanup_fsm_state_str[r_cleanup_fsm]);
     1098        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     1099        {
     1100            for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     1101                PRINTF("    * ll info                 : [%.2d][%.2d] %d %llx (%llx) %llx\n"
     1102                       ,num_cache
     1103                       ,num_cpu
     1104                       ,          r_dcache_ll_valid [num_cache][num_cpu].read()
     1105                       ,(uint64_t)r_dcache_ll_addr  [num_cache][num_cpu].read()
     1106                       ,(uint64_t)set_num_dcache_only(r_dcache_ll_addr [num_cache][num_cpu].read(),num_cache)
     1107                       ,(uint64_t)r_dcache_ll_data [num_cache][num_cpu].read());
     1108
     1109            PRINTF("    * dcache_previous_unc     : [%.2d] %d\n",num_cache,r_dcache_previous_unc[num_cache].read());
     1110
     1111#if CC_XCACHE_WRAPPER_DEBUG
     1112            if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN)
     1113                r_wbuf[num_cache]->printTrace(1);
     1114#endif
     1115        }
    5801116        // CACHE_MISS_BUF_RSP_PRINT(i);
    5811117        // CACHE_MISS_BUF_RSP_PRINT(d);
    5821118
    583 #if CC_XCACHE_WRAPPER_DEBUG
    584         if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN)
    585             {
    586                 r_wbuf.printTrace(1);
    587             }
    588 #endif
     1119        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     1120        m_cpt_fsm_dcache  [num_cache][r_dcache_fsm[num_cache]] ++;
     1121        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1122        m_cpt_fsm_icache  [num_cache][r_icache_fsm[num_cache]] ++;
     1123        m_cpt_fsm_cmd     [r_vci_cmd_fsm] ++;
     1124        m_cpt_fsm_rsp     [r_vci_rsp_fsm] ++;
     1125        m_cpt_fsm_tgt     [r_vci_tgt_fsm] ++;
     1126        m_cpt_fsm_cleanup [r_cleanup_fsm] ++;
    5891127
    5901128        m_cpt_total_cycles++;
     
    6261164                if ( p_vci_tgt.cmdval.read() )
    6271165                {
    628                     PRINTF("    * <TGT> request\n");
     1166                    PRINTF("    * <TGT> Request\n");
    6291167
    6301168                    addr_40 address = p_vci_tgt.address.read();
     
    6341172                        std::cout << "error in component VCI_CC_XCACHE_WRAPPER " << name() << std::endl;
    6351173                        std::cout << "coherence request is not a write" << std::endl;
    636                         std::cout << "oddress = " << std::hex << address << std::dec << std::endl;
     1174                        std::cout << "address = " << std::hex << address << std::dec << std::endl;
    6371175                        std::cout << "srcid   = " << p_vci_tgt.srcid.read() << std::endl;
    6381176                        exit(0);
     
    6441182                        std::cout << "error in component VCI_CC_XCACHE_WRAPPER " << name() << std::endl;
    6451183                        std::cout << "out of segment coherence request" << std::endl;
    646                         std::cout << "oddress = " << std::hex << address << std::dec << std::endl;
     1184                        std::cout << "address = " << std::hex << address << std::dec << std::endl;
    6471185                        std::cout << "srcid   = " << p_vci_tgt.srcid.read() << std::endl;
    6481186                        exit(0);
    6491187                    }
    6501188
    651                     r_tgt_addr = (((addr_40) ((p_vci_tgt.be.read() & 0x3) << 32)) |
    652                                  ((addr_40) (p_vci_tgt.wdata.read()))) * m_dcache_words * 4;     
    653                     r_tgt_srcid = p_vci_tgt.srcid.read();
    654                     r_tgt_trdid = p_vci_tgt.trdid.read();
    655                     r_tgt_pktid = p_vci_tgt.pktid.read();
    656                  // r_tgt_plen  = p_vci_tgt.plen.read();
     1189                    addr_40 tgt_addr  = ((((addr_40)p_vci_tgt.be.read() & 0x3) << 32) | ((addr_40) p_vci_tgt.wdata.read())) << (addr_40)m_dcache_words_shift;
     1190                    // * m_dcache_words * 4;
     1191
     1192                    addr_40 tgt_iaddr = tgt_addr;
     1193                    addr_40 tgt_daddr = tgt_addr;
     1194
     1195                    PRINTF("    * <TGT> srcid            : %d\n",(uint32_t)p_vci_tgt.srcid.read());
     1196                    PRINTF("    * <TGT> trdid            : %d\n",(uint32_t)p_vci_tgt.trdid.read());
     1197                    PRINTF("    * <TGT> pktid            : %d\n",(uint32_t)p_vci_tgt.pktid.read());
     1198                    PRINTF("    * <TGT> address (before) : %llx\n",(uint64_t)tgt_iaddr);
     1199
     1200                    r_tgt_srcid     = p_vci_tgt.srcid.read();
     1201                    r_tgt_trdid     = p_vci_tgt.trdid.read();
     1202                    r_tgt_pktid     = p_vci_tgt.pktid.read();
     1203                 // r_tgt_plen      = p_vci_tgt.plen.read();
    6571204                   
    658                     PRINTF("    * <TGT> address : %llx\n",(uint64_t)address);
    659                     PRINTF("    * <TGT> address : %llx\n",(uint64_t)((((addr_40) ((p_vci_tgt.be.read() & 0x3) << 32)) |
    660                                                                       ((addr_40) (p_vci_tgt.wdata.read()))) * m_dcache_words * 4));
    661 
     1205                    // BROADCAST
    6621206                    if ( (address&0x3) == 0x3 )   // broadcast invalidate for data or instruction type
    6631207                    {
     
    6711215                        // r_tgt_brdcast= true;
    6721216                        r_vci_tgt_fsm = TGT_REQ_BROADCAST;
     1217                        uint32_t tgt_num_cache;
     1218                        tgt_num_cache = get_num_icache(tgt_iaddr,0); // none effect (else CC_XCACHE_WRAPPER_MULTI_CACHE==1)
     1219                        tgt_num_cache = get_num_dcache(tgt_daddr);
     1220                        r_tgt_num_cache = tgt_num_cache;
     1221
     1222                        PRINTF("    * <TGT> REQ_BROADCAST\n");
     1223                        PRINTF("    * <TGT> num_cache (data) : %d\n",tgt_num_cache);
     1224
    6731225                        m_cpt_cc_inval_broadcast++ ;
     1226
     1227#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     1228                        {
     1229                            log_transaction_file_tgt
     1230                                << "[" << m_cpt_total_cycles << "] "
     1231                                << "BROADCAST  "
     1232                                << std::hex
     1233                                << " L " << std::setw(10) << (uint64_t)tgt_addr
     1234                                << std::dec
     1235                                << " - " << tgt_num_cache
     1236                                << std::endl;
     1237                        }
     1238#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     1239
    6741240                    }
    6751241                    else                    // multi-update or multi-invalidate for data type
     
    6771243                        uint32_t cell = address - m_segment.baseAddress(); // addr_40
    6781244                        // r_tgt_brdcast = false;
     1245
    6791246                        if (cell == 0)
    6801247                        {                                       // invalidate data
     
    6871254                            r_tgt_update = false;
    6881255                            r_vci_tgt_fsm = TGT_REQ_DCACHE;
     1256                            uint32_t tgt_num_cache = get_num_dcache(tgt_daddr); // static partionnement
     1257                            r_tgt_num_cache = tgt_num_cache;
     1258                           
     1259                            PRINTF("    * <TGT> REQ_DCACHE\n");
     1260                            PRINTF("    * <TGT> num_cache        : %d\n",tgt_num_cache);
     1261
    6891262                            m_cpt_cc_inval_dcache++ ;
     1263
     1264#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     1265                            {
     1266                                log_transaction_file_tgt
     1267                                    << "[" << m_cpt_total_cycles << "] "
     1268                                    << "INVAL DATA "
     1269                                    << std::hex
     1270                                    << " L " << std::setw(10) << (uint64_t)tgt_addr
     1271                                    << std::dec
     1272                                    << " - " << tgt_num_cache
     1273                                    << std::endl;
     1274                            }
     1275#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     1276
    6901277                        }
    6911278                        else if (cell == 4)                     // invalidate instruction
     
    6991286                            r_tgt_update = false;
    7001287                            r_vci_tgt_fsm = TGT_REQ_ICACHE;
     1288                            uint32_t tgt_num_cpu   = p_vci_tgt.pktid.read();
     1289                            uint32_t tgt_num_cache = get_num_icache(tgt_iaddr,tgt_num_cpu);
     1290                            r_tgt_num_cache = tgt_num_cache;
     1291                           
     1292                            PRINTF("    * <TGT> REQ_ICACHE\n");
     1293                            PRINTF("    * <TGT> num_cache        : %d\n",tgt_num_cache);
     1294
    7011295                            m_cpt_cc_inval_icache++ ;
     1296
     1297#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     1298                            {
     1299                                log_transaction_file_tgt
     1300                                    << "[" << m_cpt_total_cycles << "] "
     1301                                    << "INVAL INS  "
     1302                                    << std::hex
     1303                                    << " L " << std::setw(10) << (uint64_t)tgt_addr
     1304                                    << std::dec
     1305                                    << " - " << tgt_num_cache
     1306                                    << std::endl;
     1307                            }
     1308#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     1309
    7021310                        }
    7031311                        else if ( (cell == 8) or (cell==12) )    // update data or instruction
     
    7131321                                m_cpt_cc_update_dcache++;
    7141322                                r_tgt_update_data = true;
     1323
     1324                                uint32_t tgt_num_cache = get_num_dcache(tgt_daddr);
     1325                                r_tgt_num_cache = tgt_num_cache;
     1326                               
     1327                                PRINTF("    * <TGT> UPDT_WORD DATA\n");
     1328                                PRINTF("    * <TGT> num_cache        : %d\n",tgt_num_cache);
     1329
     1330#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     1331                                {
     1332                                    log_transaction_file_tgt
     1333                                        << "[" << m_cpt_total_cycles << "] "
     1334                                        << "UPT DATA   "
     1335                                        << std::hex
     1336                                        << " L " << std::setw(10) << (uint64_t)tgt_addr
     1337                                        << std::dec
     1338                                        << " - " << tgt_num_cache
     1339                                        << std::endl;
     1340                                }
     1341#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
    7151342                            }
    7161343                            else
     
    7181345                                m_cpt_cc_update_icache++;
    7191346                                r_tgt_update_data = false;
     1347
     1348                                uint32_t tgt_num_cpu   = p_vci_tgt.pktid.read();
     1349                                uint32_t tgt_num_cache = get_num_icache(tgt_iaddr,tgt_num_cpu);
     1350                                r_tgt_num_cache = tgt_num_cache;
     1351                               
     1352                                PRINTF("    * <TGT> UPDT_WORD INSTRUCTION\n");
     1353                                PRINTF("    * <TGT> num_cache        : %d\n",tgt_num_cache);
     1354
     1355#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     1356                                {
     1357                                    log_transaction_file_tgt
     1358                                        << "[" << m_cpt_total_cycles << "] "
     1359                                        << "UPT INS    "
     1360                                        << std::hex
     1361                                        << " L " << std::setw(10) << (uint64_t)tgt_addr
     1362                                        << std::dec
     1363                                        << " - " << tgt_num_cache
     1364                                        << std::endl;
     1365                                }
     1366#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
    7201367                            }
    7211368                            r_tgt_update = true;
     
    7241371
    7251372                    } // end if address
     1373                   
     1374                    r_tgt_iaddr      = tgt_iaddr;
     1375                    r_tgt_daddr      = tgt_daddr;
     1376                    PRINTF("    * <TGT> address (after)  : i %llx, d %llx\n",(uint64_t)tgt_iaddr,(uint64_t)tgt_daddr);
     1377
    7261378                } // end if cmdval
    7271379                break;
     
    7391391                    r_tgt_word = p_vci_tgt.wdata.read(); // the first modified word index
    7401392#ifdef COHERENCE_DEBUG
    741                     std::cout << "PROC " << m_srcid_rw << " update, line : " << std::hex << r_tgt_addr.read() << " word : " << p_vci_tgt.wdata.read() << std::dec << std::endl;
     1393                    std::cout << "PROC " << m_srcid_rw << " update, line : " << std::hex << r_tgt_daddr.read() << " word : " << p_vci_tgt.wdata.read() << std::dec << std::endl;
    7421394#endif
    7431395                    r_vci_tgt_fsm = TGT_UPDT_DATA;
     
    7891441
    7901442            case TGT_REQ_BROADCAST:
    791                 if ( not r_tgt_icache_req.read() and not r_tgt_dcache_req.read() )
    792                 {
    793                     r_vci_tgt_fsm = TGT_RSP_BROADCAST;
    794                     r_tgt_icache_req = true;
    795                     r_tgt_dcache_req = true;
     1443                {
     1444                    bool tgt_icache_req;
     1445
     1446#if   (CC_XCACHE_WRAPPER_MULTI_CACHE==1)
     1447                    tgt_icache_req = r_tgt_icache_req[r_tgt_num_cache].read();
     1448#elif (CC_XCACHE_WRAPPER_MULTI_CACHE==2)
     1449                    tgt_icache_req = false;
     1450                    for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1451                        tgt_icache_req |= r_tgt_icache_req[num_cache].read();
     1452#endif
     1453                    if (not tgt_icache_req and not r_tgt_dcache_req[r_tgt_num_cache].read())
     1454                    {
     1455                        r_vci_tgt_fsm = TGT_RSP_BROADCAST;
     1456
     1457#if   (CC_XCACHE_WRAPPER_MULTI_CACHE==1)
     1458                        r_tgt_icache_req[r_tgt_num_cache] = true;
     1459#elif (CC_XCACHE_WRAPPER_MULTI_CACHE==2)
     1460                        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1461                        r_tgt_icache_req[      num_cache] = true;
     1462#endif
     1463
     1464                        r_tgt_dcache_req[r_tgt_num_cache] = true;
     1465                    }
    7961466                }
    7971467                break;
     
    7991469            case TGT_REQ_ICACHE:
    8001470                {
    801                     if ( not r_tgt_icache_req.read() )
     1471                    // Request treated by the icache
     1472                    if ( not r_tgt_icache_req[r_tgt_num_cache].read() )
    8021473                    {
    8031474                        r_vci_tgt_fsm = TGT_RSP_ICACHE;
    804                         r_tgt_icache_req = true;
     1475                        r_tgt_icache_req[r_tgt_num_cache] = true;
    8051476                    }
    8061477                    break;
     
    8081479
    8091480            case TGT_REQ_DCACHE:
    810                 if ( not r_tgt_dcache_req.read() )
    811                 {
    812                     r_vci_tgt_fsm = TGT_RSP_DCACHE;
    813                     r_tgt_dcache_req = true;
    814                 }
    815                 break;
    816 
     1481                {
     1482                    // Request treated by the dcache
     1483
     1484                    if ( not r_tgt_dcache_req[r_tgt_num_cache].read() )
     1485                    {
     1486                        r_vci_tgt_fsm = TGT_RSP_DCACHE;
     1487                        r_tgt_dcache_req[r_tgt_num_cache] = true;
     1488                    }
     1489                    break;
     1490                }
    8171491            case TGT_RSP_BROADCAST:
    818                 if ( not r_tgt_icache_req.read() and not r_tgt_dcache_req.read() )
    819                 {
    820                     // one response
    821                     if ( not r_tgt_icache_rsp or not r_tgt_dcache_rsp )
     1492                {
     1493                    PRINTF("      * <TGT> dcache[%d] : %d - %d\n",(uint32_t)r_tgt_num_cache, (uint32_t)r_tgt_dcache_req[r_tgt_num_cache].read(),(uint32_t)r_tgt_dcache_rsp[r_tgt_num_cache].read());
     1494                    for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1495                        PRINTF("      * <TGT> icache[%d] : %d - %d\n",(uint32_t)num_cache, (uint32_t)r_tgt_icache_req[num_cache].read(),(uint32_t)r_tgt_icache_rsp[num_cache].read());
     1496
     1497                    bool tgt_icache_req;
     1498                   
     1499#if   (CC_XCACHE_WRAPPER_MULTI_CACHE==1)
     1500                    tgt_icache_req = r_tgt_icache_req[r_tgt_num_cache].read();
     1501#elif (CC_XCACHE_WRAPPER_MULTI_CACHE==2)
     1502                    tgt_icache_req = false;
     1503                    for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1504                        tgt_icache_req |= r_tgt_icache_req[num_cache].read();
     1505#endif
     1506                    if (not tgt_icache_req and not r_tgt_dcache_req[r_tgt_num_cache].read())
    8221507                    {
    823                         if ( p_vci_tgt.rspack.read() )
     1508                        bool     tgt_icache_rsp;
     1509                        uint32_t tgt_icache_rsp_num_cache;
     1510                       
     1511#if   (CC_XCACHE_WRAPPER_MULTI_CACHE==1)
     1512                        tgt_icache_rsp_num_cache = r_tgt_num_cache;
     1513                        tgt_icache_rsp = r_tgt_icache_rsp[r_tgt_num_cache].read();
     1514#elif (CC_XCACHE_WRAPPER_MULTI_CACHE==2)
     1515                        tgt_icache_rsp_num_cache = 0;
     1516                        for (;tgt_icache_rsp_num_cache<m_nb_icache; ++tgt_icache_rsp_num_cache)
    8241517                        {
    825                             r_vci_tgt_fsm = TGT_IDLE;
    826                             r_tgt_icache_rsp = false;
    827                             r_tgt_dcache_rsp = false;
     1518                            PRINTF("      * <TGT> icache[%d] : %d\n",(uint32_t)tgt_icache_rsp_num_cache, (uint32_t)r_tgt_icache_rsp[tgt_icache_rsp_num_cache].read());
     1519                           
     1520                            if (r_tgt_icache_rsp[tgt_icache_rsp_num_cache].read())
     1521                                break;
    8281522                        }
    829                     }
    830 
    831                     // if data and instruction have the inval line, need two responses 
    832                     if ( r_tgt_icache_rsp and r_tgt_dcache_rsp )
    833                     {
    834                         if ( p_vci_tgt.rspack.read() )
     1523
     1524                        tgt_icache_rsp = (tgt_icache_rsp_num_cache<m_nb_icache);
     1525#endif
     1526
     1527                        PRINTF("      * <TGT> icache_rsp [%d] : %d\n",tgt_icache_rsp_num_cache,(uint32_t) tgt_icache_rsp);
     1528                        PRINTF("      * <TGT> dcache_rsp [%d] : %d\n",(uint32_t)r_tgt_num_cache,(uint32_t) r_tgt_dcache_rsp[r_tgt_num_cache]);
     1529
     1530                        if (tgt_icache_rsp or r_tgt_dcache_rsp[r_tgt_num_cache])
    8351531                        {
    836                             r_tgt_icache_rsp = false; // only reset one for respond the second time
     1532                            // Have send one response
     1533                            if ( p_vci_tgt.rspack.read())
     1534                            {
     1535                                // reset dcache if activated
     1536                                if (r_tgt_dcache_rsp[r_tgt_num_cache])
     1537                                    r_tgt_dcache_rsp[r_tgt_num_cache] = false;
     1538                                else
     1539                                    // reset one icache
     1540                                    r_tgt_icache_rsp[tgt_icache_rsp_num_cache] = false;
     1541                            }
    8371542                        }
    838                     }
    839 
    840                     // if there is no need for a response
    841                     if ( not r_tgt_icache_rsp and not r_tgt_dcache_rsp )
     1543
     1544                        // // one response
     1545                        // if ( not r_tgt_icache_rsp[r_tgt_num_cache] or not r_tgt_dcache_rsp[r_tgt_num_cache] )
     1546                        // {
     1547                        //     if ( p_vci_tgt.rspack.read() )
     1548                        //     {
     1549                        //         r_vci_tgt_fsm = TGT_IDLE;
     1550                        //         r_tgt_icache_rsp[r_tgt_num_cache] = false;
     1551                        //         r_tgt_dcache_rsp[r_tgt_num_cache] = false;
     1552                        //     }
     1553                        // }
     1554                       
     1555                        // // if data and instruction have the inval line, need two responses 
     1556                        // if ( r_tgt_icache_rsp[r_tgt_num_cache] and r_tgt_dcache_rsp[r_tgt_num_cache] )
     1557                        // {
     1558                        //     if ( p_vci_tgt.rspack.read() )
     1559                        //     {
     1560                        //         r_tgt_icache_rsp[r_tgt_num_cache] = false; // only reset one for respond the second time
     1561                        //     }
     1562                        // }
     1563
     1564                        PRINTF("      * <TGT> icache_rsp    : %d\n",(uint32_t) r_tgt_icache_rsp);
     1565                        PRINTF("      * <TGT> dcache_rsp[%d] : %d\n",(uint32_t)r_tgt_num_cache,(uint32_t)r_tgt_dcache_rsp[r_tgt_num_cache].read());
     1566                        // if there is no need for a response
     1567                        if (not tgt_icache_rsp and not r_tgt_dcache_rsp[r_tgt_num_cache] )
     1568                        {
     1569                            r_vci_tgt_fsm = TGT_IDLE;
     1570                        }
     1571                       
     1572                    }
     1573                    break;
     1574                }
     1575                ////////////////////
     1576            case TGT_RSP_ICACHE:
     1577                {
     1578                    bool transaction_rsp = (p_vci_tgt.rspack.read() or not r_tgt_icache_rsp[r_tgt_num_cache].read()) and not r_tgt_icache_req[r_tgt_num_cache].read();
     1579
     1580                    PRINTF("      * <TGT> RSP_ICACHE : transaction : %d ((%d or not %d) and not %d)\n",transaction_rsp
     1581                           ,(int)p_vci_tgt.rspack.read()
     1582                           ,(int)r_tgt_icache_rsp[r_tgt_num_cache].read()
     1583                           ,(int)r_tgt_icache_req[r_tgt_num_cache].read()
     1584                           );
     1585
     1586                    if (transaction_rsp)
    8421587                    {
    8431588                        r_vci_tgt_fsm = TGT_IDLE;
    844                     }
    845 
    846                 }
    847                 break;
    848                 ////////////////////
    849             case TGT_RSP_ICACHE:
    850                 {
    851                     if ( (p_vci_tgt.rspack.read() or not r_tgt_icache_rsp.read()) and not r_tgt_icache_req.read() )
     1589                        r_tgt_icache_rsp[r_tgt_num_cache] = false;
     1590                    }
     1591                    break;
     1592                }
     1593
     1594            case TGT_RSP_DCACHE:
     1595                {
     1596                    bool transaction_rsp = (p_vci_tgt.rspack.read() or not r_tgt_dcache_rsp[r_tgt_num_cache].read()) and not r_tgt_dcache_req[r_tgt_num_cache].read();
     1597
     1598                    PRINTF("      * <TGT> RSP_DCACHE : transaction : %d\n",transaction_rsp);
     1599
     1600                    if (transaction_rsp)
    8521601                    {
    8531602                        r_vci_tgt_fsm = TGT_IDLE;
    854                         r_tgt_icache_rsp = false;
     1603                        r_tgt_dcache_rsp[r_tgt_num_cache] = false;
    8551604                    }
    8561605                    break;
    8571606                }
    858 
    859             case TGT_RSP_DCACHE:
    860                 {
    861                     if ( (p_vci_tgt.rspack.read() or not r_tgt_dcache_rsp.read()) and not r_tgt_dcache_req.read() )
    862                     {
    863                         r_vci_tgt_fsm = TGT_IDLE;
    864                         r_tgt_dcache_rsp = false;
    865                     }
    866                     break;
    867                 }
    8681607        } // end switch TGT_FSM
     1608
     1609        /////////////////////////////////////////////////////////////////////
     1610        // Interface between CPU and CACHE FSM
     1611        ///////////////////////////////////////////////////////////////////////
     1612
     1613        uint32_t ireq_num_cache [m_nb_cpu];
     1614        uint32_t dreq_num_cache [m_nb_cpu];
     1615        bool     have_sync = false;
     1616
     1617        {
     1618            typename iss_t::InstructionRequest _ireq = ISS_IREQ_INITIALIZER;
     1619            typename iss_t::DataRequest        _dreq = ISS_DREQ_INITIALIZER;
     1620
     1621            for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1622            {
     1623                ireq [num_cache] = _ireq;
     1624              //irsp [num_cache] = _irsp;
     1625            }
     1626            for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     1627            {
     1628                dreq [num_cache] = _dreq;
     1629              //drsp [num_cache] = _drsp;
     1630               
     1631                have_sync |= r_dcache_sync [num_cache];
     1632            }
     1633        }
     1634
     1635        for (uint32_t _num_cpu=0; _num_cpu<m_nb_cpu; ++_num_cpu)
     1636        {
     1637            // round robin priority
     1638            uint32_t num_cpu = (r_cpu_prior+_num_cpu)%m_nb_cpu;
     1639
     1640            typename iss_t::InstructionRequest _ireq = ISS_IREQ_INITIALIZER;
     1641            typename iss_t::DataRequest        _dreq = ISS_DREQ_INITIALIZER;
     1642           
     1643            m_iss[num_cpu]->getRequests(_ireq, _dreq);
     1644
     1645            addr_40  addr;
     1646            uint32_t num_cache;
     1647
     1648            addr      = (addr_40)_ireq.addr;
     1649            num_cache = get_num_icache(addr,num_cpu);
     1650
     1651            // test if already used
     1652            if (not ireq[num_cache].valid and
     1653                (r_icache_lock [num_cache] == m_nb_cpu) or
     1654                (r_icache_lock [num_cache] == num_cpu))
     1655            {
     1656                bool valid = _ireq.valid;
     1657
     1658                if (valid)
     1659                {
     1660                    PRINTF("    * <CPU2CACHE> ICACHE :    Transaction between cpu %d and cache %d (lock)\n",num_cpu,num_cache);
     1661                    ireq_num_cache [num_cpu  ] = num_cache;
     1662                    r_icache_lock [num_cache] = num_cpu;
     1663                }
     1664                else
     1665                {
     1666                    PRINTF("    * <CPU2CACHE> ICACHE : No Transaction between cpu %d and cache %d : invalid\n",num_cpu,num_cache);
     1667                    ireq_num_cache [num_cpu] = m_nb_icache;
     1668                }
     1669
     1670                ireq_cached    [num_cache] = m_cacheability_table[(vci_addr_t)_ireq.addr];
     1671                ireq_num_cpu   [num_cache] = num_cpu;
     1672                ireq           [num_cache] = _ireq;
     1673                ireq           [num_cache].addr = addr;
     1674            }
     1675            else
     1676            {
     1677                PRINTF("    * <CPU2CACHE> ICACHE : No transaction (cpu %d)\n",num_cpu);
     1678
     1679                ireq_num_cache [num_cpu] = m_nb_icache;
     1680            }
     1681
     1682            addr      = (addr_40)_dreq.addr;
     1683            num_cache = get_num_dcache(addr);
     1684
     1685            // test if already used
     1686            if (not dreq[num_cache].valid and
     1687                not have_sync and
     1688                (r_dcache_lock [num_cache] == m_nb_cpu) or
     1689                (r_dcache_lock [num_cache] == num_cpu))
     1690            {
     1691                bool valid = _dreq.valid;
     1692
     1693                if (valid)
     1694                {
     1695                    PRINTF("    * <CPU2CACHE> DCACHE :    Transaction between cpu %d and cache %d (lock)\n",num_cpu,num_cache);
     1696                    dreq_num_cache [num_cpu  ] = num_cache;
     1697                    r_dcache_lock [num_cache] = num_cpu;
     1698                }
     1699                else
     1700                {
     1701                    PRINTF("    * <CPU2CACHE> DCACHE : No Transaction between cpu %d and cache %d : invalid\n",num_cpu,num_cache);
     1702                    dreq_num_cache [num_cpu] = m_nb_dcache;
     1703                }
     1704
     1705                dreq_cached    [num_cache] = m_cacheability_table[(vci_addr_t)_dreq.addr];
     1706                dreq_num_cpu   [num_cache] = num_cpu;
     1707                dreq           [num_cache] = _dreq;
     1708                dreq           [num_cache].addr = addr;
     1709            }
     1710            else
     1711            {
     1712                PRINTF("    * <CPU2CACHE> DCACHE : No transaction (cpu %d)\n",num_cpu);
     1713
     1714                dreq_num_cache [num_cpu] = m_nb_dcache;
     1715            }
     1716
     1717
     1718#if CC_XCACHE_WRAPPER_DEBUG
     1719        if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN)
     1720        {
     1721            std::cout << "    * <CPU2CACHE> Instruction Request   : " << ireq_num_cache[num_cpu] << " - " << _ireq << std::endl
     1722                      << "    * <CPU2CACHE> Data        Request   : " << dreq_num_cache[num_cpu] << " - " << _dreq << std::endl;
     1723        }
     1724#endif
     1725        }
     1726
     1727        // round robin priority
     1728        r_cpu_prior = (r_cpu_prior+1)%m_nb_cpu;
    8691729
    8701730        /////////////////////////////////////////////////////////////////////
     
    8991759        //    flip-flop. It is reset by the ICACHE FSM.
    9001760        ///////////////////////////////////////////////////////////////////////
    901 
    902         typename iss_t::InstructionRequest  ireq = ISS_IREQ_INITIALIZER;
    903         typename iss_t::InstructionResponse irsp = ISS_IRSP_INITIALIZER;
    904 
    905         typename iss_t::DataRequest         dreq = ISS_DREQ_INITIALIZER;
    906         typename iss_t::DataResponse        drsp = ISS_DRSP_INITIALIZER;
    907 
    908         m_iss.getRequests( ireq, dreq );
    909 
    910 #if CC_XCACHE_WRAPPER_DEBUG
    911         if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN)
    912             std::cout << "    * Instruction Request  : " << ireq << std::endl;
    913 #endif
    914 
    915         switch(r_icache_fsm) {
     1761       
     1762        for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     1763        {
     1764            typename iss_t::InstructionRequest  _ireq = ireq [num_cache];
     1765            typename iss_t::InstructionResponse _irsp = ISS_IRSP_INITIALIZER;
     1766
     1767        switch(r_icache_fsm[num_cache]) {
    9161768            /////////////////
    9171769            case ICACHE_IDLE:
    9181770                {
    919                     if ( r_tgt_icache_req ) {   // external request
    920                         if ( ireq.valid ) m_cost_ins_miss_frz++;
    921                         r_icache_fsm = ICACHE_CC_CHECK;
    922                         r_icache_fsm_save = r_icache_fsm.read();
     1771                    if ( r_tgt_icache_req[num_cache] ) {   // external request
     1772                        // if ( _ireq.valid ) m_cost_ins_miss_frz++;
     1773                        r_icache_fsm     [num_cache] = ICACHE_CC_CHECK;
     1774                        r_icache_fsm_save[num_cache] = r_icache_fsm[num_cache];
    9231775                        break;
    9241776                    }
    925                     if ( ireq.valid ) {
    926                         data_t  icache_ins = 0;
    927                         bool    icache_hit = false;
    928                         bool    icache_cached = m_cacheability_table[(vci_addr_t)ireq.addr];
    929                         bool    icache_cleanup_hit = r_icache_cleanup_req and (((addr_40)ireq.addr >> (addr_40)m_icache_words_shift) == r_icache_cleanup_line.read());
     1777                    if ( _ireq.valid ) {
     1778                        data_t   icache_ins         = 0;
     1779                        bool     icache_hit         = false;
     1780                        bool     icache_cached      = ireq_cached  [num_cache];
     1781                        // uint32_t icache_num_cpu     = ireq_num_cpu [num_cache];
     1782                        bool     icache_cleanup_hit = r_icache_cleanup_req[num_cache] and (((addr_40)_ireq.addr >> (addr_40)m_icache_words_shift) == r_icache_cleanup_line[num_cache].read());
    9301783
    9311784                        // icache_hit & icache_ins evaluation
    9321785                        if ( icache_cached ) {
    933                             icache_hit = r_icache.read((vci_addr_t) ireq.addr, &icache_ins);
     1786                            icache_hit = r_icache[num_cache]->read((vci_addr_t) _ireq.addr, &icache_ins);
    9341787                        } else {
    9351788                            // if uncache, again in the icache_miss_buf
    936                             icache_hit = ( r_icache_buf_unc_valid and ((addr_40) ireq.addr == (addr_40)r_icache_addr_save));
    937                             icache_ins = CACHE_MISS_BUF_RSP_DATA(i,0);
    938                             CACHE_MISS_BUF_RSP_POP(i);
     1789                            icache_hit = (r_icache_buf_unc_valid[num_cache] and ((addr_40) _ireq.addr == (addr_40)r_icache_addr_save[num_cache]));
     1790                            icache_ins = CACHE_MISS_BUF_RSP_DATA(i,num_cache,0);
     1791
     1792                            if (icache_hit)
     1793                                CACHE_MISS_BUF_RSP_POP(i,num_cache);
    9391794                        }
    9401795
    941                         PRINTF("    * <ICACHE> hit %d - cached %d - cleanup_hit %d\n",icache_hit, icache_cached, icache_cleanup_hit);
    942 
    943                         ASSERT( not (icache_hit and icache_cleanup_hit),
    944                                 "Icache hit and icache_cleanup_hit");
    945 
    946                         if ( not icache_hit and not icache_cleanup_hit) {
    947                             m_cpt_ins_miss++;
    948                             m_cost_ins_miss_frz++;
    949                             r_icache_addr_save = (addr_40) ireq.addr;
    950 
    951                             CACHE_MISS_BUF_REQ_INIT(i);
    952 
    953                             if ( icache_cached ) {
     1796                        PRINTF("    * <ICACHE [%d]> hit %d - cached %d - cleanup_hit %d\n",num_cache, icache_hit, icache_cached, icache_cleanup_hit);
     1797
     1798                        // ASSERT( not (icache_hit and icache_cleanup_hit),
     1799                        //         "Icache hit and icache_cleanup_hit");
     1800
     1801                        if (icache_hit and icache_cleanup_hit)
     1802                        {
     1803                            PRINTF("    * <ICACHE [%d]> Warning : icache hit and icache_cleanup_hit\n",num_cache);
     1804                            icache_hit = false;
     1805                        }
     1806                        else
     1807                        {
     1808                            if ( not icache_hit and not icache_cleanup_hit)
     1809                            {
     1810                                m_cpt_ins_miss++;
     1811                                m_cost_ins_miss_frz++;
     1812                                r_icache_addr_save[num_cache] = (addr_40) _ireq.addr;
     1813                               
     1814                                CACHE_MISS_BUF_REQ_INIT(i,num_cache);
     1815                               
     1816                                if ( icache_cached )
     1817                                {
    9541818#if CC_XCACHE_WRAPPER_SELECT_VICTIM
    955                                 r_icache_fsm = ICACHE_MISS_VICTIM;
     1819                                    r_icache_fsm     [num_cache] = ICACHE_MISS_VICTIM;
    9561820#else
    957                                 r_icache_fsm = ICACHE_MISS_WAIT;
    958 #endif
    959                                 r_icache_miss_req = true;
    960                                
    961                             } else {
    962                                 r_icache_fsm = ICACHE_UNC_WAIT;
    963                                 r_icache_unc_req = true;
     1821                                    r_icache_fsm     [num_cache] = ICACHE_MISS_WAIT;
     1822#endif
     1823                                    r_icache_miss_req[num_cache] = true;
     1824                                   
     1825                                }
     1826                                else
     1827                                {
     1828                                    r_icache_fsm    [num_cache] = ICACHE_UNC_WAIT;
     1829                                    r_icache_unc_req[num_cache] = true;
     1830                                }
    9641831                            }
    965                         } else {
    966                             r_icache_buf_unc_valid = false;
     1832                            else
     1833                            {
     1834                                r_icache_buf_unc_valid[num_cache] = false;
     1835                            }
     1836                            m_cpt_icache_dir_read += m_icache_ways;
     1837                            m_cpt_icache_data_read += m_icache_ways;
    9671838                        }
    968                         m_cpt_icache_dir_read += m_icache_ways;
    969                         m_cpt_icache_data_read += m_icache_ways;
    970                         irsp.valid          = icache_hit;
    971                         irsp.instruction    = icache_ins;
     1839
     1840                        _irsp.valid          = icache_hit;
     1841                        _irsp.instruction    = icache_ins;
    9721842                    }
    9731843                    break;
     
    9771847            case ICACHE_MISS_VICTIM:
    9781848                {
    979                     if (not r_icache_cleanup_req)
     1849                    if (not r_icache_cleanup_req[num_cache])
    9801850                    {
    9811851                        size_t     way;
    9821852                        size_t     set;
    983                         vci_addr_t addr = (vci_addr_t) r_icache_addr_save.read();
     1853                        vci_addr_t addr = (vci_addr_t) r_icache_addr_save[num_cache].read();
    9841854                        vci_addr_t victim;
    9851855                       
    986                         r_icache_cleanup_req  = r_icache.victim_select(addr, &victim, &way, &set );
    987                         r_icache_cleanup_line = (addr_40) victim;
    988                         r_icache_miss_way    = way;
    989                         r_icache_miss_set    = set;
     1856                        r_icache_cleanup_req [num_cache] = r_icache[num_cache]->victim_select(addr, &victim, &way, &set );
     1857                        r_icache_cleanup_line[num_cache] = (addr_40) victim;
     1858                        r_icache_miss_way    [num_cache] = way;
     1859                        r_icache_miss_set    [num_cache] = set;
    9901860                       
    991                         r_icache_fsm = ICACHE_MISS_WAIT;
     1861                        r_icache_fsm         [num_cache] = ICACHE_MISS_WAIT;
    9921862                    }
    9931863                    break;
     
    9981868                {
    9991869                    m_cost_ins_miss_frz++;
    1000                     if ( r_tgt_icache_req ) {   // external request
    1001                         r_icache_fsm = ICACHE_CC_CHECK;
    1002                         r_icache_fsm_save = r_icache_fsm.read();
     1870                    if ( r_tgt_icache_req[num_cache] ) {   // external request
     1871                        r_icache_fsm      [num_cache] = ICACHE_CC_CHECK;
     1872                        r_icache_fsm_save [num_cache] = r_icache_fsm[num_cache].read();
    10031873                        break;
    10041874                    }
    10051875
    1006                     bool val = CACHE_MISS_BUF_RSP_VAL(i,0);
    1007 
    1008                     PRINTF("    * <ICACHE> val                  : %d\n",val);
     1876                    bool val = CACHE_MISS_BUF_RSP_VAL(i,num_cache,0);
     1877
     1878                    PRINTF("    * <ICACHE [%d]> val                  : %d\n",num_cache,val);
    10091879
    10101880                    if (val)
    10111881                    {
    1012                         PRINTF("    * <ICACHE> r_icache_inval_rsp   : %d\n",(int) r_icache_inval_rsp  );
    1013                         PRINTF("    * <ICACHE> r_vci_rsp_ins_error  : %d\n",(int) r_vci_rsp_ins_error );
    1014                         PRINTF("    * <ICACHE> r_icache_cleanup_req : %d\n",(int) r_icache_cleanup_req);
    1015 
    1016                         // if (not r_icache_inval_rsp )
    1017                         // {
    1018                             // Miss read response and no invalidation
    1019                             if ( r_vci_rsp_ins_error ) {
    1020                                 r_icache_fsm = ICACHE_ERROR;
    1021                             } else {
     1882                        PRINTF("    * <ICACHE [%d]> r_icache_inval_rsp   : %d\n",num_cache,(int) r_icache_inval_rsp  [num_cache]);
     1883                        PRINTF("    * <ICACHE [%d]> r_vci_rsp_ins_error  : %d\n",num_cache,(int) r_vci_rsp_ins_error [num_cache]);
     1884                        PRINTF("    * <ICACHE [%d]> r_icache_cleanup_req : %d\n",num_cache,(int) r_icache_cleanup_req[num_cache]);
     1885
     1886                        // Miss read response and no invalidation
     1887                        if ( r_vci_rsp_ins_error [num_cache]) {
     1888                            r_icache_fsm[num_cache] = ICACHE_ERROR;
     1889                        } else {
    10221890#if not CC_XCACHE_WRAPPER_SELECT_VICTIM
    1023                                 if (not r_icache_cleanup_req.read())
    1024 #endif
    1025                                 {
    1026                                     r_icache_update_addr = 0;
    1027                                     r_icache_fsm         = ICACHE_MISS_UPDT;
    1028                                 }
     1891                            if (not r_icache_cleanup_req[num_cache].read())
     1892#endif
     1893                            {
     1894                                r_icache_update_addr[num_cache] = 0;
     1895                                r_icache_fsm        [num_cache] = ICACHE_MISS_UPDT;
    10291896                            }
    1030                         // }
    1031                         // else
    1032                         // {
    1033                         //     r_icache_inval_rsp = false;
    1034                            
    1035                         //     // Miss read response and invalidation
    1036                         //     if ( r_vci_rsp_ins_error )
    1037                         //         r_icache_fsm = ICACHE_ERROR;
    1038                         //     else
    1039                         //         r_icache_fsm = ICACHE_CC_CLEANUP;
    1040                         // }
     1897                        }
    10411898                    }
    10421899                    break;
     
    10461903                {
    10471904                    m_cost_ins_miss_frz++;
    1048                     if ( r_tgt_icache_req ) {   // external request
    1049                         r_icache_fsm = ICACHE_CC_CHECK;
    1050                         r_icache_fsm_save = r_icache_fsm.read();
     1905                    if ( r_tgt_icache_req[num_cache] ) {   // external request
     1906                        r_icache_fsm     [num_cache] = ICACHE_CC_CHECK;
     1907                        r_icache_fsm_save[num_cache] = r_icache_fsm[num_cache].read();
    10511908                        break;
    10521909                    }
    10531910
    1054                     bool ok = CACHE_MISS_BUF_RSP_VAL(i,0);
     1911                    bool ok = CACHE_MISS_BUF_RSP_VAL(i,num_cache,0);
     1912
     1913                    PRINTF("    * <ICACHE [%d]> ok                   : %d\n",num_cache,ok);
     1914                    PRINTF("    * <ICACHE [%d]> error                : %d\n",num_cache,(uint32_t)r_vci_rsp_ins_error [num_cache]);
    10551915
    10561916                    if (ok)
    10571917                    {
    1058                         if ( r_vci_rsp_ins_error ) {
    1059                             r_icache_fsm = ICACHE_ERROR;
     1918                        if ( r_vci_rsp_ins_error [num_cache]) {
     1919                            r_icache_fsm[num_cache] = ICACHE_ERROR;
    10601920                        } else {
    1061                             r_icache_fsm = ICACHE_IDLE;
    1062                             r_icache_buf_unc_valid = true;
     1921                            r_icache_fsm [num_cache] = ICACHE_IDLE;
     1922                            r_icache_buf_unc_valid[num_cache] = true;
    10631923                        }
    10641924                    }
     
    10681928            case ICACHE_ERROR:
    10691929                {
    1070                     if ( (addr_40)ireq.addr == (addr_40)r_icache_addr_save ) {
    1071                         irsp.error          = true;
    1072                         irsp.valid          = true;
    1073                     }
    1074                     r_icache_fsm = ICACHE_IDLE;
    1075                     r_vci_rsp_ins_error = false;
     1930                    if ( (addr_40)_ireq.addr == (addr_40)r_icache_addr_save[num_cache] ) {
     1931                        _irsp.error          = true;
     1932                        _irsp.valid          = true;
     1933                    }
     1934                    r_icache_fsm        [num_cache] = ICACHE_IDLE;
     1935                    r_vci_rsp_ins_error [num_cache] = false;
    10761936                    break;
    10771937                }
     
    10791939            case ICACHE_MISS_UPDT:
    10801940                {
    1081                     size_t     word = r_icache_update_addr.read();
    1082                     vci_addr_t addr = (vci_addr_t) r_icache_addr_save.read();
     1941                    size_t     word =              r_icache_update_addr[num_cache].read();
     1942                    vci_addr_t addr = (vci_addr_t) r_icache_addr_save  [num_cache].read();
    10831943                    size_t     way  = 0;
    10841944                    size_t     set  = 0;
    10851945
     1946#if CC_XCACHE_WRAPPER_SELECT_VICTIM
     1947                    way = r_icache_miss_way[num_cache].read();
     1948                    set = r_icache_miss_set[num_cache].read();
     1949#else
    10861950                    // need invalid rsp, don't select a victim
    1087                     if (not r_icache_inval_rsp )
     1951                    if (not r_icache_inval_rsp[num_cache])
    10881952                    {
    1089 #if CC_XCACHE_WRAPPER_SELECT_VICTIM
    1090                         way = r_icache_miss_way.read();
    1091                         set = r_icache_miss_set.read();
    1092 #else
    1093 
    10941953                        // First word : select an victim !
    10951954                        if (word == 0)
     
    10981957                       
    10991958                            // r_icache_cleanup_req is false because is the transition condition to go in ICACHE_MISS_UPDT state
    1100                             r_icache_cleanup_req  = r_icache.victim_select(addr, &victim, &way, &set );
    1101                             r_icache.victim_update_tag(addr, way, set);
     1959                            r_icache_cleanup_req[num_cache]  = r_icache[num_cache]->victim_select(addr, &victim, &way, &set );
     1960                            r_icache[num_cache]->victim_update_tag(addr, way, set);
    11021961                       
    1103                             r_icache_cleanup_line = (addr_40) victim;
    1104                             r_icache_miss_way    = way;
    1105                             r_icache_miss_set    = set;
     1962                            r_icache_cleanup_line[num_cache] = (addr_40) victim;
     1963                            r_icache_miss_way    [num_cache] = way;
     1964                            r_icache_miss_set    [num_cache] = set;
    11061965                        }
    11071966                        else
    11081967                        {
    1109                             way = r_icache_miss_way.read();
    1110                             set = r_icache_miss_set.read();
     1968                            way = r_icache_miss_way[num_cache].read();
     1969                            set = r_icache_miss_set[num_cache].read();
    11111970                        }
    1112 #endif
    1113                     }
    1114                     bool val = CACHE_MISS_BUF_RSP_VAL(i,word);
     1971                    }
     1972#endif
     1973                    bool val = CACHE_MISS_BUF_RSP_VAL(i,num_cache,word);
    11151974
    11161975                    if (val)
    11171976                    {
    1118                         PRINTF("    * <ICACHE> rsp_val            : %d/%d\n",(int)r_icache_update_addr,m_icache_words);
    1119                         PRINTF("    * <ICACHE> r_icache_inval_rsp : %d\n",(int)r_icache_inval_rsp);
    1120                         PRINTF("    * <ICACHE> ins : %x\n",(int)CACHE_MISS_BUF_RSP_DATA(i,word));
     1977                        PRINTF("    * <ICACHE [%d]> rsp_val            : %d/%d\n",num_cache,(int)r_icache_update_addr[num_cache],m_icache_words);
     1978                        PRINTF("    * <ICACHE [%d]> r_icache_inval_rsp : %d\n"   ,num_cache,(int)r_icache_inval_rsp[num_cache]);
     1979                        PRINTF("    * <ICACHE [%d]> ins                : %x\n"   ,num_cache,(int)CACHE_MISS_BUF_RSP_DATA(i,num_cache,word));
    11211980
    11221981                        // m_cpt_icache_dir_write++;
    11231982                        // m_cpt_icache_data_write++;
    1124                         // if ( ireq.valid ) m_cost_ins_miss_frz++;
     1983                        // if ( _ireq.valid ) m_cost_ins_miss_frz++;
    11251984
    11261985                        // if need invalid rsp, don't modify the cache, but pop the buf_rsp
    1127                         if (not r_icache_inval_rsp )
    1128                             r_icache.write(way, set, word, CACHE_MISS_BUF_RSP_DATA(i,word));
    1129                         CACHE_MISS_BUF_RSP_POP(i);
    1130 
    1131                         r_icache_update_addr = ++word;
     1986                        if (not r_icache_inval_rsp[num_cache])
     1987                            r_icache[num_cache]->write(way, set, word, CACHE_MISS_BUF_RSP_DATA(i,num_cache,word));
     1988
     1989                        CACHE_MISS_BUF_RSP_POP(i,num_cache);
     1990
     1991                        r_icache_update_addr[num_cache] = ++word;
    11321992                           
    11331993                        // if last word, finish the update
    11341994                        if (word >= m_icache_words)
    11351995                        {
     1996#if CC_XCACHE_WRAPPER_SELECT_VICTIM
     1997                            // in all case (inval_rsp or not), update the victim tag
     1998                            r_icache[num_cache]->victim_update_tag(addr, way, set);
     1999#endif
     2000
    11362001                            // Last word : if previous invalid_rsp, can cleanup, else update the TAG
    1137                             if (r_icache_inval_rsp)
     2002                            if (r_icache_inval_rsp[num_cache])
    11382003                            {
    1139                                 r_icache_inval_rsp  = false;
    1140                                 r_icache_fsm = ICACHE_CC_CLEANUP;
     2004                                r_icache_inval_rsp[num_cache] = false;
     2005                                r_icache_fsm      [num_cache] = ICACHE_CC_CLEANUP;
    11412006                            }
    11422007                            else
    11432008                            {
    1144 #if CC_XCACHE_WRAPPER_SELECT_VICTIM
    1145                                 r_icache.victim_update_tag(addr, way, set);
    1146 #endif
    1147                                 r_icache_fsm = ICACHE_IDLE;
     2009                                r_icache_fsm [num_cache] = ICACHE_IDLE;
    11482010                            }
    11492011                        }
     
    11562018                {
    11572019                    // external cache invalidate request
    1158                     if ( r_tgt_icache_req )     
     2020                    if ( r_tgt_icache_req[num_cache])     
    11592021                    {
    1160                         r_icache_fsm = ICACHE_CC_CHECK;
    1161                         r_icache_fsm_save = r_icache_fsm.read();
     2022                        r_icache_fsm     [num_cache] = ICACHE_CC_CHECK;
     2023                        r_icache_fsm_save[num_cache] = r_icache_fsm[num_cache].read();
    11622024                        break;
    11632025                    }
    11642026                    // cleanup
    1165                     if(not r_icache_cleanup_req){
    1166                         r_icache_cleanup_req = true;
    1167                         r_icache_cleanup_line = r_icache_addr_save.read() >> m_icache_words_shift;
    1168                         r_icache_fsm = ICACHE_IDLE;
     2027                    if(not r_icache_cleanup_req[num_cache]){
     2028                        r_icache_cleanup_req [num_cache] = true;
     2029                        r_icache_cleanup_line[num_cache] = r_icache_addr_save[num_cache].read() >> m_icache_words_shift;
     2030                        r_icache_fsm         [num_cache] = ICACHE_IDLE;
     2031
     2032                        // FIXME : too many access at the cache in this cycle
     2033                        m_cpt_icache_dir_read += m_icache_ways;
     2034                        r_icache[num_cache]->inval((addr_40)r_icache_addr_save[num_cache]);
    11692035                    }
    11702036                    break;
     
    11762042                    m_cpt_icache_dir_read  += m_icache_ways;
    11772043                    m_cpt_icache_data_read += m_icache_ways;
    1178                     addr_40 ad = r_tgt_addr;
     2044                    addr_40 ad = r_tgt_iaddr;
    11792045                    data_t  icache_rdata = 0;
    11802046
    1181                     if((r_icache_fsm_save == ICACHE_MISS_WAIT) and
    1182                             ( (r_icache_addr_save.read() & ~((m_icache_words<<2)-1)) == (ad & ~((m_icache_words<<2)-1)))) {
    1183                         r_icache_inval_rsp = true;
    1184                         r_tgt_icache_req = false;
     2047                    PRINTF("    * <ICACHE [%d]> CC_CHECK\n",num_cache);
     2048
     2049                    if((r_icache_fsm_save[num_cache] == ICACHE_MISS_WAIT) and
     2050                       ((r_icache_addr_save[num_cache].read() & ~((m_icache_words<<2)-1)) == (ad & ~((m_icache_words<<2)-1)))) {
     2051                        PRINTF("    * <ICACHE [%d]> have request, need inval rsp\n",num_cache);
     2052
     2053                        r_icache_inval_rsp[num_cache] = true;
     2054                        r_tgt_icache_req  [num_cache] = false;
    11852055                        if(r_tgt_update){    // Also send a cleanup and answer
    1186                             r_tgt_icache_rsp     = true;
     2056                            PRINTF("    * <ICACHE [%d]> send a cleanup and answer\n",num_cache);
     2057                            r_tgt_icache_rsp[num_cache] = true;
    11872058                        } else {            // Also send a cleanup but don't answer
    1188                             r_tgt_icache_rsp     = false;
     2059                            PRINTF("    * <ICACHE [%d]> send a cleanup and but don't answer\n",num_cache);
     2060                            r_tgt_icache_rsp[num_cache] = false;
    11892061                        }
    1190                         r_icache_fsm = r_icache_fsm_save;
     2062                        r_icache_fsm[num_cache] = r_icache_fsm_save[num_cache];
    11912063                    } else {
    1192                         bool    icache_hit   = r_icache.read(ad, &icache_rdata);
    1193                         if ( icache_hit and r_tgt_update )
     2064                        bool    icache_hit   = r_icache[num_cache]->read(ad, &icache_rdata);
     2065
     2066                        PRINTF("    * <ICACHE [%d]> have no request, hit cache : %d\n",num_cache,icache_hit);
     2067
     2068                        if ( icache_hit and r_tgt_update)
    11942069                        {
    11952070#if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
     
    11982073                            data_t   rdata = 0;
    11992074
    1200                             r_icache.read(ad+word*4,&rdata);
     2075                            r_icache[num_cache]->read(ad+word*4,&rdata);
    12012076                            r_tgt_buf[word] = (mask & r_tgt_buf[word]) | (~mask & rdata);
    12022077                           
     
    12102085                            if (word==m_icache_words)
    12112086                            {
    1212                                 r_icache_fsm = ICACHE_CC_UPDT;
     2087                                r_icache_fsm[num_cache] = ICACHE_CC_UPDT;
    12132088
    12142089#if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT
     
    12222097                            r_cache_word = word;
    12232098#else //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
    1224                             r_icache_fsm = ICACHE_CC_UPDT;
     2099                            r_icache_fsm[num_cache] = ICACHE_CC_UPDT;
    12252100                            // complete the line buffer in case of update
    12262101                            for(size_t i=0; i<m_icache_words; i++){
    12272102                                data_t rdata = 0;
    1228                                 r_icache.read(ad + i*4,&rdata);
     2103                                r_icache[num_cache]->read(ad + i*4,&rdata);
    12292104                                data_t mask = vci_param::be2mask(r_tgt_be[i]);
    12302105                                r_tgt_buf[i] = (mask & r_tgt_buf[i]) | (~mask & rdata);
    12312106                            }
    12322107#endif //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
    1233                         } else if ( icache_hit and not r_tgt_update ) {
    1234                             r_icache_fsm = ICACHE_CC_INVAL;
     2108                        } else if ( icache_hit and not r_tgt_update) {
     2109                            r_icache_fsm[num_cache] = ICACHE_CC_INVAL;
    12352110                        } else { // instruction not found (can happen)
    1236                             r_tgt_icache_req = false;
     2111                            r_tgt_icache_req[num_cache] = false;
    12372112                            if(r_tgt_update){
    1238                                 r_tgt_icache_rsp = true;
     2113                                r_tgt_icache_rsp[num_cache] = true;
    12392114                            } else {
    1240                                 r_tgt_icache_rsp = false;
     2115                                r_tgt_icache_rsp[num_cache] = false;
    12412116                            }
    1242                             r_icache_fsm = r_icache_fsm_save;
     2117                            r_icache_fsm[num_cache] = r_icache_fsm_save[num_cache];
    12432118                        }
    12442119                    }
     
    12482123            case ICACHE_CC_INVAL: 
    12492124                {                       
    1250                     addr_40    ad  = r_tgt_addr;
    1251                     if ( ireq.valid ) m_cost_ins_miss_frz++;
     2125                    addr_40 ad  = r_tgt_iaddr;
     2126                    // if ( _ireq.valid ) m_cost_ins_miss_frz++;
    12522127                    m_cpt_icache_dir_read += m_icache_ways;
    1253                     r_tgt_icache_rsp = true;
    1254                     r_icache.inval(ad);
    1255                     r_tgt_icache_req = false;
    1256                     r_icache_fsm = r_icache_fsm_save;
     2128                    r_tgt_icache_rsp[num_cache] = true;
     2129                    r_icache[num_cache]->inval(ad);
     2130                    r_tgt_icache_req[num_cache] = false;
     2131                    r_icache_fsm    [num_cache] = r_icache_fsm_save[num_cache];
    12572132                    break;
    12582133                }   
     
    12602135            case ICACHE_CC_UPDT:
    12612136                {                       
    1262                     addr_40 ad = r_tgt_addr.read();
     2137                    addr_40 ad = r_tgt_iaddr.read();
    12632138                    m_cpt_icache_dir_write++;
    12642139                    m_cpt_icache_data_write++;
     
    12682143
    12692144                    if(r_tgt_be[word])
    1270                         r_icache.write(ad+word*4, r_tgt_buf[word]);
     2145                        r_icache[num_cache]->write(ad+word*4, r_tgt_buf[word]);
    12712146
    12722147                    word ++;
     
    12792154                    if (word==m_icache_words)
    12802155                    {
    1281                         r_tgt_icache_req = false;
    1282                         r_tgt_icache_rsp = true;
    1283                         r_icache_fsm     = r_icache_fsm_save.read();
     2156                        r_tgt_icache_req[num_cache] = false;
     2157                        r_tgt_icache_rsp[num_cache] = true;
     2158                        r_icache_fsm    [num_cache] = r_icache_fsm_save[num_cache].read();
    12842159                        word = 0;
    12852160                    }
     
    12882163                    data_t* buf    = r_tgt_buf;
    12892164                    for(size_t i=0; i<m_icache_words;i++){
    1290                         if(r_tgt_be[i]) r_icache.write( ad + i*4, buf[i]);
    1291                     }
    1292                     r_tgt_icache_req = false;
    1293                     r_tgt_icache_rsp = true;
    1294                     r_icache_fsm     = r_icache_fsm_save.read();
     2165                        if(r_tgt_be[i]) r_icache[num_cache]->write( ad + i*4, buf[i]);
     2166                    }
     2167                    r_tgt_icache_req [num_cache] = false;
     2168                    r_tgt_icache_rsp [num_cache] = true;
     2169                    r_icache_fsm     [num_cache] = r_icache_fsm_save[num_cache].read();
    12952170#endif //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
    12962171
     
    12982173                }   
    12992174
    1300         } // end switch r_icache_fsm
    1301 
    1302 #if CC_XCACHE_WRAPPER_DEBUG
    1303         if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN)
    1304             std::cout << "    * Instruction Response : " << irsp << std::endl;
    1305 #endif
     2175        }// end switch r_icache_fsm
     2176
     2177        irsp [num_cache] = _irsp;
     2178        if (_ireq.valid and _irsp.valid)
     2179        {
     2180            PRINTF("    * <CPU2CACHE> Transaction between cpu %d and Icache %d (unlock)\n",r_icache_lock [num_cache].read(),num_cache);
     2181
     2182            r_icache_lock       [num_cache] = m_nb_cpu;
     2183            m_cpt_icache_access [num_cache] ++;
     2184        }
     2185
     2186        }// end for num_cache
    13062187
    13072188        //////////////////////////////////////////////////////////////////////://///////////
     
    13612242        ///////////////////////////////////////////////////////////////////////////////////
    13622243
    1363 #if CC_XCACHE_WRAPPER_DEBUG
    1364         if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN)
    1365             std::cout << "    * Data        Request  : " << dreq << std::endl;
    1366 #endif
    1367 
    1368         switch ( r_dcache_fsm ) {
     2244        for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache)
     2245        {
     2246            typename iss_t::DataRequest  _dreq = dreq [num_cache];
     2247            typename iss_t::DataResponse _drsp = ISS_DRSP_INITIALIZER;
     2248
     2249        switch ( r_dcache_fsm[num_cache]) {
    13692250
    13702251                /////////////////
    13712252            case DCACHE_IDLE:
    13722253                {
    1373                     if ( r_tgt_dcache_req ) {   // external request
    1374                         r_dcache_fsm = DCACHE_CC_CHECK;
    1375                         r_dcache_fsm_save = r_dcache_fsm;
     2254                    if ( r_tgt_dcache_req[num_cache]) {   // external request
     2255                        r_dcache_fsm     [num_cache] = DCACHE_CC_CHECK;
     2256                        r_dcache_fsm_save[num_cache] = r_dcache_fsm[num_cache];
    13762257                        break;
    13772258                    }
    13782259
    1379                     if ( dreq.valid ) {
    1380                         PRINTF("    * <DCACHE> Have dreq\n");
     2260                    if ( _dreq.valid ) {
     2261                        PRINTF("    * <DCACHE [%d]> Have dreq\n",num_cache);
    13812262
    13822263                        data_t      dcache_rdata       = 0;
    1383                         // dcache_cached and dcache_hit don't used with dreq.type == {DATA_SC, XTN_READ, XTN_WRITE}
    1384                         bool        dcache_cached      = m_cacheability_table[(vci_addr_t)dreq.addr];
    1385                         bool        dcache_hit         = r_dcache.read((vci_addr_t) dreq.addr, &dcache_rdata);
    1386                         bool        dcache_cleanup_hit = r_dcache_cleanup_req and (((addr_40)dreq.addr >> (addr_40)m_dcache_words_shift) == r_dcache_cleanup_line.read());
    1387 
    1388                         PRINTF("    * <DCACHE> hit %d - cached %d - cleanup_hit %d\n",dcache_hit, dcache_cached, dcache_cleanup_hit);
     2264                        // dcache_cached and dcache_hit don't used with _dreq.type == {DATA_SC, XTN_READ, XTN_WRITE}
     2265                        bool        dcache_cached      = dreq_cached  [num_cache];
     2266                        uint32_t    dcache_num_cpu     = dreq_num_cpu [num_cache];
     2267                        bool        dcache_hit         = r_dcache[num_cache]->read((vci_addr_t) _dreq.addr, &dcache_rdata);
     2268                        bool        dcache_cleanup_hit = r_dcache_cleanup_req[num_cache] and (((addr_40)_dreq.addr >> (addr_40)m_dcache_words_shift) == r_dcache_cleanup_line[num_cache].read());
     2269
     2270                        PRINTF("    * <DCACHE [%d]> hit %d - cached %d - cleanup_hit %d\n",num_cache,dcache_hit, dcache_cached, dcache_cleanup_hit);
    13892271                       
    13902272                        m_cpt_dcache_data_read += m_dcache_ways;
    13912273                        m_cpt_dcache_dir_read  += m_dcache_ways;
    13922274
    1393                         switch( dreq.type ) {
     2275                        switch( _dreq.type ) {
    13942276                            case iss_t::DATA_READ:
    13952277                            case iss_t::DATA_LL:
     
    14002282                                        {
    14012283                                            // address is in the cache : return the word
    1402                                             r_dcache_fsm = DCACHE_IDLE;
    1403                                             drsp.valid   = true;
    1404                                             drsp.rdata   = dcache_rdata; // return read data (cf dcache_hit)
     2284                                            r_dcache_fsm [num_cache] = DCACHE_IDLE;
     2285
     2286                                            _drsp.valid   = true;
     2287                                            _drsp.rdata   = dcache_rdata; // return read data (cf dcache_hit)
    14052288                                           
    14062289                                            // if the request is a Load Linked instruction, save request information
    1407                                             if(dreq.type == iss_t::DATA_LL)
     2290                                            if(_dreq.type == iss_t::DATA_LL)
    14082291                                                {
    1409                                                     PRINTF("    * <DCACHE> ll_valid = true\n");
    1410 
    1411                                                     r_dcache_ll_valid = true;
    1412                                                     r_dcache_ll_data = dcache_rdata;
    1413                                                     r_dcache_ll_addr = (vci_addr_t) dreq.addr;
     2292                                                    PRINTF("    * <DCACHE [%d]> ll_valid = true\n",num_cache);
     2293
     2294                                                    r_dcache_ll_valid  [num_cache][dcache_num_cpu] = true;
     2295                                                    r_dcache_ll_data   [num_cache][dcache_num_cpu] = dcache_rdata;
     2296                                                    r_dcache_ll_addr   [num_cache][dcache_num_cpu] = (vci_addr_t) _dreq.addr;
    14142297#ifdef COHERENCE_DEBUG
    1415                                                     std::cout << "Value returned for LL at address : " << std::hex << dreq.addr << " data : " << std::dec << dcache_rdata<< std::endl;
    1416                                                     r_dcache.read((vci_addr_t) dreq.addr, &dcache_rdata);
    1417                                                     std::cout << "Value stored at this  address : " << std::hex << dreq.addr << " data : " << std::dec << dcache_rdata<< std::endl;
     2298                                                    std::cout << "Value returned for LL at address : " << std::hex << _dreq.addr << " data : " << std::dec << dcache_rdata<< std::endl;
     2299                                                    r_dcache[num_cache]->read((vci_addr_t) _dreq.addr, &dcache_rdata);
     2300                                                    std::cout << "Value stored at this  address : " << std::hex << _dreq.addr << " data : " << std::dec << dcache_rdata<< std::endl;
    14182301#endif
    14192302                                                }
     
    14232306                                            if (not dcache_cleanup_hit)
    14242307                                            {
    1425                                                 CACHE_MISS_BUF_REQ_INIT(d);
     2308                                                CACHE_MISS_BUF_REQ_INIT(d,num_cache);
    14262309                                               
    14272310                                                // Miss : send signal at the CMD_FSM (via r_dcache_miss_req or r_dcache_unc_req)
     
    14292312                                                    m_cpt_data_read_miss++;
    14302313                                                    m_cost_data_miss_frz++;
    1431                                                     r_dcache_miss_req = true;
     2314                                                    r_dcache_miss_req [num_cache] = true;
    14322315#if CC_XCACHE_WRAPPER_SELECT_VICTIM
    1433                                                     r_dcache_fsm = DCACHE_MISS_VICTIM;
     2316                                                    r_dcache_fsm [num_cache] = DCACHE_MISS_VICTIM;
    14342317#else
    1435                                                     r_dcache_fsm = DCACHE_MISS_WAIT;
     2318                                                    r_dcache_fsm [num_cache] = DCACHE_MISS_WAIT;
    14362319#endif
    14372320                                                   
    14382321                                                } else {
    1439                                                     if (not r_dcache_previous_unc.read()) // strongly order to the uncached access
     2322                                                    if (not r_dcache_previous_unc[num_cache].read()) // strongly order to the uncached access
    14402323                                                    {
    1441                                                         r_dcache_previous_unc = true;
     2324                                                        r_dcache_previous_unc[num_cache] = true;
    14422325                                                       
    14432326                                                        m_cpt_data_read_uncached++;
    14442327                                                        m_cost_unc_read_frz++;
    1445                                                         r_dcache_unc_req = true;
    1446                                                         r_dcache_fsm = DCACHE_UNC_WAIT;
     2328                                                        r_dcache_unc_req[num_cache] = true;
     2329                                                        r_dcache_fsm    [num_cache] = DCACHE_UNC_WAIT;
    14472330                                                    }
    14482331                                                }
     
    14532336                            case iss_t::DATA_SC:
    14542337                            {
    1455                                 PRINTF("    * <DCACHE> DATA_SC - ll_valid = %d\n",r_dcache_ll_valid.read());
    1456 
    1457                                 if (not r_dcache_previous_unc.read() and not dcache_cleanup_hit) // strongly order to the uncached access
     2338                                PRINTF("    * <DCACHE [%d]> DATA_SC - ll_valid = %d, num_cpu = %d\n",num_cache,r_dcache_ll_valid[num_cache][dcache_num_cpu].read(),dcache_num_cpu);
     2339
     2340                                if (not r_dcache_previous_unc[num_cache].read() and not dcache_cleanup_hit) // strongly order to the uncached access
    14582341                                {
    14592342                                    //m_cpt_data_read_unc++; // instruction must read the memory in uncached mode
     
    14622345                                    // if previous load linked (with the same address), make a transaction
    14632346                                    // else, keep in IDLE state and return 1 (no OK)
    1464                                     if(r_dcache_ll_valid.read() and (r_dcache_ll_addr.read() == (vci_addr_t)dreq.addr)){
    1465                                         PRINTF("    * <DCACHE> have previous load linked\n");
     2347                                    if( r_dcache_ll_valid[num_cache][dcache_num_cpu].read() and
     2348                                       (r_dcache_ll_addr [num_cache][dcache_num_cpu].read() == (vci_addr_t)_dreq.addr)){
     2349                                        PRINTF("    * <DCACHE [%d]> have previous load linked\n",num_cache);
    14662350                                       
    1467                                         r_dcache_previous_unc = true;
    1468 
    1469                                         r_dcache_sc_req   = true;
    1470 
    1471                                         CACHE_MISS_BUF_REQ_INIT(d);
    1472 
    1473                                         r_dcache_fsm = DCACHE_SC_WAIT;
     2351                                        r_dcache_previous_unc[num_cache] = true;
     2352                                        r_dcache_sc_req      [num_cache] = true;
     2353
     2354                                        CACHE_MISS_BUF_REQ_INIT(d,num_cache);
     2355
     2356                                        r_dcache_fsm         [num_cache] = DCACHE_SC_WAIT;
    14742357                                    } else {
    1475                                         PRINTF("    * <DCACHE> don't have previous load linked\n");
     2358                                        PRINTF("    * <DCACHE [%d]> don't have previous load linked\n",num_cache);
    14762359                                       
    1477                                         drsp.valid = true;
    1478                                         drsp.rdata = 1; // SC rsp NOK
    1479                                         r_dcache_ll_valid = false;
     2360                                        _drsp.valid = true;
     2361                                        _drsp.rdata = 1; // SC rsp NOK
     2362                                        r_dcache_ll_valid[num_cache][dcache_num_cpu] = false;
    14802363                                    }
    14812364                                }
     
    14862369                            case iss_t::XTN_WRITE:
    14872370                                {
    1488                                     bool drsp_valid = false;
     2371                                    bool valid = false;
    14892372                                    // only DCACHE INVALIDATE and SYNC request are supported
    1490                                     switch (dreq.addr>>2)
     2373                                    switch (_dreq.addr>>2)
    14912374                                        {
    14922375                                        case iss_t::XTN_DCACHE_INVAL :
    14932376                                            {
    1494                                                 drsp_valid = true;
    1495                                                 r_dcache_fsm = DCACHE_INVAL;
     2377                                                valid = true;
     2378                                                r_dcache_fsm[num_cache] = DCACHE_INVAL;
    14962379                                                break;
    14972380                                            }
     
    15012384                                                //  * gain : 1 cycle
    15022385                                                //  * cost : can be on the critical path
    1503                                                 if (r_wbuf.empty())
     2386
     2387                                                bool empty=true;
     2388                                                for (uint32_t i=0; i<m_nb_dcache; ++i)
     2389                                                    empty &= r_wbuf[i]->empty();
     2390
     2391                                                if (empty)
    15042392                                                    {
    1505                                                         drsp_valid = true;
    1506                                                         r_dcache_fsm = DCACHE_IDLE;
     2393                                                        valid = true;
     2394                                                        r_dcache_fsm [num_cache] = DCACHE_IDLE;
    15072395                                                    }
    15082396                                                else
    15092397                                                    {
    1510                                                         drsp_valid = false;
    1511                                                         r_dcache_fsm = DCACHE_SYNC;
     2398                                                        valid = false;
     2399                                                        r_dcache_fsm [num_cache] = DCACHE_SYNC;
     2400                                                        r_dcache_sync[num_cache] = true;
    15122401                                                    }
    15132402                                                break;
     
    15162405                                            {
    15172406                                                // std::cout << "Warning in VCI_CC_XCACHE_WRAPPER " << name() << std::endl;
    1518                                                 // std::cout << "Unsupported  external access : " << (dreq.addr>>2) << std::endl;
    1519 
    1520                                                 r_dcache_fsm = DCACHE_IDLE;
     2407                                                // std::cout << "Unsupported  external access : " << (_dreq.addr>>2) << std::endl;
     2408
     2409                                                r_dcache_fsm [num_cache] = DCACHE_IDLE;
    15212410                                            }
    1522                                         }//end switch (dreq.addr>>2)
    1523 
    1524                                     drsp.valid = drsp_valid;
    1525                                     drsp.rdata = 0;
     2411                                        }//end switch (_dreq.addr>>2)
     2412
     2413                                    _drsp.valid = valid;
     2414                                    _drsp.rdata = 0;
    15262415                                    break;
    15272416                                }
    15282417                            case iss_t::DATA_WRITE:
    15292418
    1530                                 if (dcache_cached or not r_dcache_previous_unc.read()) // strongly order to the uncached access
     2419                                PRINTF("    * <DCACHE [%d]> r_dcache_previous_unc : %d\n",num_cache,r_dcache_previous_unc[num_cache].read());
     2420
     2421                                if (dcache_cached or not r_dcache_previous_unc[num_cache].read()) // strongly order to the uncached access
    15312422                                {
    1532                                     bool drsp_valid;
    1533 
    1534                                     drsp_valid = r_wbuf.write((addr_40) dreq.addr, dreq.be, dreq.wdata, dcache_cached);
    1535 
    1536                                     if (drsp_valid)
     2423                                    bool valid;
     2424                                    addr_40 addr = _dreq.addr;
     2425                                    set_num_dcache(addr,num_cache);
     2426
     2427                                    // FIXME : virer le set_num_dcache !
     2428                                    valid = r_wbuf[num_cache]->write(addr, _dreq.be, _dreq.wdata, dcache_cached);
     2429
     2430                                    PRINTF("    * <DCACHE [%d]> r_wbuf valid          : %d\n",num_cache,valid);
     2431
     2432                                    if (valid)
    15372433                                    {
    15382434                                        m_cpt_data_write++;
     
    15402436                                        if (not dcache_cached)
    15412437                                        {
    1542                                             r_dcache_previous_unc = true;
     2438                                            r_dcache_previous_unc[num_cache] = true;
    15432439                                            m_cpt_data_write_uncached++;
    15442440                                        }
     
    15462442                                            m_cpt_data_write_miss++;
    15472443                                       
    1548                                         if ( dcache_hit) {
    1549                                             r_dcache_fsm = DCACHE_WRITE_UPDT;
     2444                                        if (dcache_hit) {
     2445                                            // update data cache
     2446                                            r_dcache_fsm[num_cache] = DCACHE_WRITE_UPDT;
    15502447                                        } else {
    1551                                             r_dcache_fsm = DCACHE_IDLE;
     2448                                            // write accepted
     2449                                            r_dcache_fsm [num_cache] = DCACHE_IDLE;
    15522450                                        }
    15532451                                    }
    15542452
    1555                                     drsp.valid = drsp_valid;
    1556                                     drsp.rdata = 0;
     2453                                    _drsp.valid = valid;
     2454                                    _drsp.rdata = 0;
    15572455                                }
    15582456                                break;
    1559                         } // end switch dreq.type
    1560 
    1561                         r_dcache_addr_save      = (addr_40) dreq.addr;
    1562                         r_dcache_type_save      = dreq.type;
    1563                         r_dcache_wdata_save     = dreq.wdata;
    1564                         r_dcache_be_save        = dreq.be;
    1565                         r_dcache_rdata_save     = dcache_rdata;
    1566                         r_dcache_cached_save    = dcache_cached;
    1567                        
    1568                     } else {    // end if dreq.valid
    1569                         r_dcache_fsm = DCACHE_IDLE;
     2457                        } // end switch _dreq.type
     2458
     2459                        r_dcache_addr_save   [num_cache] = (addr_40) _dreq.addr;
     2460                        r_dcache_type_save   [num_cache] = _dreq.type;
     2461                        r_dcache_wdata_save  [num_cache] = _dreq.wdata;
     2462                        r_dcache_be_save     [num_cache] = _dreq.be;
     2463                        r_dcache_rdata_save  [num_cache] = dcache_rdata;
     2464                        r_dcache_cached_save [num_cache] = dcache_cached;
     2465                        r_dcache_num_cpu_save[num_cache] = dcache_num_cpu;
     2466   
     2467                    } else {    // end if _dreq.valid
     2468                        r_dcache_fsm [num_cache] = DCACHE_IDLE;
    15702469                    }
    15712470                   
     
    15762475                {
    15772476                    m_cpt_dcache_data_write++;
    1578                     data_t mask = vci_param::be2mask(r_dcache_be_save);
    1579                     data_t wdata = (mask & r_dcache_wdata_save) | (~mask & r_dcache_rdata_save);
    1580                     vci_addr_t ad = r_dcache_addr_save.read();
    1581                     r_dcache.write(ad, wdata);
    1582 
    1583                     r_dcache_fsm = DCACHE_IDLE;
     2477                    data_t mask = vci_param::be2mask(r_dcache_be_save[num_cache]);
     2478                    data_t wdata = (mask & r_dcache_wdata_save[num_cache]) | (~mask & r_dcache_rdata_save[num_cache]);
     2479                    vci_addr_t ad = r_dcache_addr_save[num_cache].read();
     2480                    r_dcache[num_cache]->write(ad, wdata);
     2481
     2482                    r_dcache_fsm [num_cache] = DCACHE_IDLE;
    15842483
    15852484                    break;
     
    15892488            case DCACHE_MISS_VICTIM:
    15902489                {
    1591                     if (not r_dcache_cleanup_req.read())
     2490                    if (not r_dcache_cleanup_req[num_cache].read())
    15922491                     {
    15932492                         size_t     way;
    15942493                         size_t     set;
    1595                          vci_addr_t addr = (vci_addr_t) r_dcache_addr_save.read();
     2494                         vci_addr_t addr = (vci_addr_t) r_dcache_addr_save[num_cache].read();
    15962495                         vci_addr_t victim;
     2496                         bool       victim_val = r_dcache[num_cache]->victim_select(addr, &victim, &way, &set );
    15972497                         
    1598                          r_dcache_cleanup_req  = r_dcache.victim_select(addr, &victim, &way, &set );
    1599                          r_dcache_cleanup_line = (addr_40) victim;
    1600                          r_dcache_miss_way     = way;
    1601                          r_dcache_miss_set     = set;
    1602                          
    1603                          r_dcache_fsm = DCACHE_MISS_WAIT;
     2498                         r_dcache_cleanup_req  [num_cache] = victim_val;
     2499                         r_dcache_cleanup_line [num_cache] = (addr_40) victim;
     2500                         r_dcache_miss_way     [num_cache] = way;
     2501                         r_dcache_miss_set     [num_cache] = set;
     2502                 
     2503                         PRINTF("    * <DCACHE [%d]> MISS_VICTIM : Victim %d - %llx (way %d, set %d)\n",num_cache,victim_val, (uint64_t)victim, way, set);
     2504       
     2505                         r_dcache_fsm          [num_cache] = DCACHE_MISS_WAIT;
    16042506                     }
    16052507                   
     
    16112513                {
    16122514
    1613                     if ( dreq.valid ) m_cost_data_miss_frz++;
    1614                     if ( r_tgt_dcache_req.read() ) {   // external request
    1615                         r_dcache_fsm = DCACHE_CC_CHECK;
    1616                         r_dcache_fsm_save = r_dcache_fsm;
     2515                    // if ( _dreq.valid ) m_cost_data_miss_frz++;
     2516                    if ( r_tgt_dcache_req[num_cache].read() ) {   // external request
     2517                        r_dcache_fsm      [num_cache] = DCACHE_CC_CHECK;
     2518                        r_dcache_fsm_save [num_cache] = r_dcache_fsm[num_cache];
    16172519                        break;
    16182520                    }
    16192521
    1620                     bool val = CACHE_MISS_BUF_RSP_VAL(d,0);
     2522                    bool val = CACHE_MISS_BUF_RSP_VAL(d,num_cache,0);
    16212523                    if (val)
    16222524                    {
    1623                         // if (not r_dcache_inval_rsp )
    1624                         //  {
    1625 
    16262525                        // Miss read response and no invalidation
    1627                         if ( r_vci_rsp_data_error )
     2526                        if (r_vci_rsp_data_error[num_cache])
    16282527                        {
    1629                             r_dcache_fsm = DCACHE_ERROR;
     2528                            r_dcache_fsm [num_cache] = DCACHE_ERROR;
    16302529                        }
    16312530                        else
    16322531                        {
    16332532#if not CC_XCACHE_WRAPPER_SELECT_VICTIM
    1634                             if (not r_dcache_cleanup_req.read())
     2533                            if (not r_dcache_cleanup_req[num_cache].read())
    16352534#endif
    16362535                            {
    1637                                 r_dcache_update_addr = 0;
    1638                                 r_dcache_fsm        = DCACHE_MISS_UPDT;
     2536                                r_dcache_update_addr[num_cache] = 0;
     2537                                r_dcache_fsm        [num_cache] = DCACHE_MISS_UPDT;
    16392538                            }
    16402539                        }
    1641                         //  }
    1642                         // else
    1643                         // {
    1644                         //     r_dcache_inval_rsp  = false;
    1645 
    1646                         //     // Miss read response and invalidation
    1647                         //     if ( r_vci_rsp_data_error ) {
    1648                         //         r_dcache_fsm = DCACHE_ERROR;
    1649                         //     } else {
    1650                         //         r_dcache_fsm = DCACHE_CC_CLEANUP;
    1651                         //     }
    1652                         // }
    16532540                    }
    16542541                    break;
     
    16572544            case DCACHE_MISS_UPDT:
    16582545                {
    1659                     size_t     word = r_dcache_update_addr.read();
    1660                     vci_addr_t addr = (vci_addr_t) r_dcache_addr_save.read();
     2546                    size_t     word = r_dcache_update_addr[num_cache].read();
     2547                    vci_addr_t addr = (vci_addr_t) r_dcache_addr_save[num_cache].read();
    16612548                    size_t     way  = 0;
    16622549                    size_t     set  = 0;
    16632550                   
    16642551                    // need invalid rsp, don't select a victim
    1665                     if (not r_dcache_inval_rsp )
     2552#if CC_XCACHE_WRAPPER_SELECT_VICTIM
     2553                    way = r_dcache_miss_way[num_cache].read();
     2554                    set = r_dcache_miss_set[num_cache].read();
     2555#else
     2556                    if (not r_dcache_inval_rsp[num_cache] )
    16662557                    {
    1667 #if CC_XCACHE_WRAPPER_SELECT_VICTIM
    1668                         way = r_dcache_miss_way.read();
    1669                         set = r_dcache_miss_set.read();
    1670 #else
    16712558                        // First word : select an victim !
    16722559                        if (word == 0)
     
    16752562                       
    16762563                            // r_dcache_cleanup_req is false (condition to enter in DCACHE_MISS_UPDT
    1677                             r_dcache_cleanup_req  = r_dcache.victim_select(addr, &victim, &way, &set );
    1678                             r_dcache.victim_update_tag(addr, way, set);
    1679                             r_dcache_cleanup_line = (addr_40) victim;
    1680 
    1681                             r_dcache_miss_way     = way;
    1682                             r_dcache_miss_set     = set;
     2564                            r_dcache_cleanup_req [num_cache]  = r_dcache[num_cache]->victim_select(addr, &victim, &way, &set );
     2565                            r_dcache[num_cache]->victim_update_tag(addr, way, set);
     2566                            r_dcache_cleanup_line[num_cache] = (addr_40) victim;
     2567
     2568                            r_dcache_miss_way [num_cache] = way;
     2569                            r_dcache_miss_set [num_cache] = set;
    16832570                        }
    16842571                        else
    16852572                        {
    1686                             way = r_dcache_miss_way.read();
    1687                             set = r_dcache_miss_set.read();
     2573                            way = r_dcache_miss_way[num_cache].read();
     2574                            set = r_dcache_miss_set[num_cache].read();
    16882575                        }
    1689 #endif
    1690                     }
    1691 
    1692                     bool val = CACHE_MISS_BUF_RSP_VAL(d,word);
    1693                     if (val)
     2576                    }
     2577#endif
     2578
     2579                    PRINTF("    * <DCACHE [%d]> MISS_UPDT : Victim way %d, set %d\n",num_cache, way, set);
     2580
     2581                    if (CACHE_MISS_BUF_RSP_VAL(d,num_cache,word))
    16942582                    {
    16952583                        // m_cpt_dcache_dir_write++;
    1696                         // if ( ireq.valid ) m_cost_data_miss_frz++;
     2584                        // if ( _dreq.valid ) m_cost_data_miss_frz++;
    16972585
    16982586                        // if need invalid rsp, don't modify the cache, but pop the buf_rsp
    1699                         if (not r_dcache_inval_rsp )
     2587                        // (power save)
     2588                        if (not r_dcache_inval_rsp[num_cache])
    17002589                        {
    1701                             r_dcache.write(way, set, word, CACHE_MISS_BUF_RSP_DATA(d,word));
     2590                            r_dcache[num_cache]->write(way, set, word, CACHE_MISS_BUF_RSP_DATA(d,num_cache,word));
    17022591                            m_cpt_dcache_data_write++;
    17032592                        }
    17042593
    1705                         CACHE_MISS_BUF_RSP_POP(d);
    1706                         r_dcache_update_addr = ++word;
     2594                        CACHE_MISS_BUF_RSP_POP(d,num_cache);
     2595                        r_dcache_update_addr[num_cache] = ++word;
    17072596                           
    17082597                        // if last word, finish the update
    17092598                        if (word >= m_dcache_words)
    17102599                        {
     2600#if CC_XCACHE_WRAPPER_SELECT_VICTIM
     2601                            // in all case (inval_rsp or not), update the victim tag
     2602                            // because victim is already cleanup
     2603                            r_dcache[num_cache]->victim_update_tag(addr, way, set);
     2604#endif
     2605
    17112606                            // Last word : if previous invalid_rsp, can cleanup, else update the TAG
    1712                             if (r_dcache_inval_rsp)
     2607                            if (r_dcache_inval_rsp[num_cache])
    17132608                            {
    1714                                 r_dcache_inval_rsp  = false;
    1715                                 r_dcache_fsm = DCACHE_CC_CLEANUP;
     2609                                r_dcache_inval_rsp[num_cache] = false;
     2610                                r_dcache_fsm      [num_cache] = DCACHE_CC_CLEANUP;
    17162611                            }
    17172612                            else
    17182613                            {
    1719 #if CC_XCACHE_WRAPPER_SELECT_VICTIM
    1720                                 r_dcache.victim_update_tag(addr, way, set);
    1721 #endif
    1722                                 r_dcache_fsm = DCACHE_IDLE;
     2614                                r_dcache_fsm [num_cache] = DCACHE_IDLE;
    17232615                            }
    17242616                        }
     
    17302622            case DCACHE_UNC_WAIT:
    17312623                {
    1732                     if ( dreq.valid ) m_cost_unc_read_frz++;
    1733                     if ( r_tgt_dcache_req ) {   // external request
    1734                         r_dcache_fsm = DCACHE_CC_CHECK;
    1735                         r_dcache_fsm_save = r_dcache_fsm;
     2624                    // if ( _dreq.valid ) m_cost_unc_read_frz++;
     2625                    if ( r_tgt_dcache_req[num_cache] ) {   // external request
     2626                        r_dcache_fsm     [num_cache] = DCACHE_CC_CHECK;
     2627                        r_dcache_fsm_save[num_cache] = r_dcache_fsm[num_cache];
    17362628                        break;
    17372629                    }
    17382630
    1739                     bool ok = CACHE_MISS_BUF_RSP_VAL(d,0);
     2631                    bool ok = CACHE_MISS_BUF_RSP_VAL(d,num_cache,0);
    17402632
    17412633                    if (ok) {
    1742                         if ( r_vci_rsp_data_error ) {
    1743                             r_dcache_fsm = DCACHE_ERROR;
     2634                        if (r_vci_rsp_data_error[num_cache]) {
     2635                            r_dcache_fsm[num_cache] = DCACHE_ERROR;
    17442636                        } else {
    1745                             data_t rdata = CACHE_MISS_BUF_RSP_DATA(d,0);
    1746                             CACHE_MISS_BUF_RSP_POP(d);
    1747 
    1748                             if(dreq.type == iss_t::DATA_LL){
    1749                                 PRINTF("    * <DCACHE> ll_valid = true\n");
    1750 
    1751                                 r_dcache_ll_valid = true;
    1752                                 r_dcache_ll_data = rdata;
    1753                                 r_dcache_ll_addr = (vci_addr_t) dreq.addr;
     2637                            data_t rdata = CACHE_MISS_BUF_RSP_DATA(d,num_cache,0);
     2638                            CACHE_MISS_BUF_RSP_POP(d,num_cache);
     2639
     2640                            if(_dreq.type == iss_t::DATA_LL){
     2641                                PRINTF("    * <DCACHE [%d]> ll_valid = true\n",num_cache);
     2642
     2643                                r_dcache_ll_valid  [num_cache][r_dcache_num_cpu_save[num_cache]] = true;
     2644                                r_dcache_ll_data   [num_cache][r_dcache_num_cpu_save[num_cache]] = rdata;
     2645                                r_dcache_ll_addr   [num_cache][r_dcache_num_cpu_save[num_cache]] = (vci_addr_t) _dreq.addr;
    17542646                            }
    1755                             r_dcache_fsm = DCACHE_IDLE;
    1756                             drsp.valid = true;
    1757                             drsp.rdata = rdata;
     2647                            r_dcache_fsm [num_cache] = DCACHE_IDLE;
     2648
     2649                            _drsp.valid = true;
     2650                            _drsp.rdata = rdata;
    17582651                        }
    17592652                    }
     
    17632656            case DCACHE_SC_WAIT:
    17642657                {
    1765                     if ( dreq.valid ) m_cost_unc_read_frz++;
    1766                     if ( r_tgt_dcache_req ) {   // external request
    1767                         r_dcache_fsm = DCACHE_CC_CHECK;
    1768                         r_dcache_fsm_save = r_dcache_fsm;
     2658                    // if ( _dreq.valid ) m_cost_unc_read_frz++;
     2659                    if ( r_tgt_dcache_req[num_cache] ) {   // external request
     2660                        r_dcache_fsm      [num_cache] = DCACHE_CC_CHECK;
     2661                        r_dcache_fsm_save [num_cache] = r_dcache_fsm [num_cache];
    17692662                        break;
    17702663                    }
    17712664
    1772                     bool ok = CACHE_MISS_BUF_RSP_VAL(d,0);
     2665                    bool ok = CACHE_MISS_BUF_RSP_VAL(d,num_cache,0);
    17732666
    17742667                    if (ok) {
    1775                         if ( r_vci_rsp_data_error ) {
    1776                             r_dcache_fsm = DCACHE_ERROR;
     2668                        if (r_vci_rsp_data_error[num_cache]) {
     2669                            r_dcache_fsm [num_cache] = DCACHE_ERROR;
    17772670                        } else {
    1778                             r_dcache_fsm = DCACHE_IDLE;
    1779                             drsp.valid = true;
    1780                             drsp.rdata = CACHE_MISS_BUF_RSP_DATA(d,0);
    1781                             CACHE_MISS_BUF_RSP_POP(d);
    1782                             r_dcache_ll_valid = false;
     2671                            r_dcache_fsm [num_cache] = DCACHE_IDLE;
     2672
     2673                            _drsp.valid = true;
     2674                            _drsp.rdata = CACHE_MISS_BUF_RSP_DATA(d,num_cache,0);
     2675                            CACHE_MISS_BUF_RSP_POP(d,num_cache);
     2676                            r_dcache_ll_valid [num_cache][r_dcache_num_cpu_save[num_cache]] = false;
    17832677                        }
    17842678                    }
     
    17892683            case DCACHE_ERROR:
    17902684                {
    1791                     r_dcache_fsm = DCACHE_IDLE;
    1792                     r_vci_rsp_data_error = false;
    1793                     drsp.error = true;
    1794                     drsp.valid = true;
     2685                    r_dcache_fsm        [num_cache] = DCACHE_IDLE;
     2686
     2687                    r_vci_rsp_data_error[num_cache] = false;
     2688                    _drsp.error = true;
     2689                    _drsp.valid = true;
    17952690                    break;
    17962691                }
     
    17982693            case DCACHE_INVAL:
    17992694                {
    1800                     if ( r_tgt_dcache_req.read() ) {   // external request
    1801                         r_dcache_fsm = DCACHE_CC_CHECK;
    1802                         r_dcache_fsm_save = r_dcache_fsm;
     2695                    if ( r_tgt_dcache_req[num_cache].read() ) {   // external request
     2696                        r_dcache_fsm      [num_cache] = DCACHE_CC_CHECK;
     2697                        r_dcache_fsm_save [num_cache] = r_dcache_fsm [num_cache];
    18032698                        break;
    18042699                    }
    1805                     if( not r_dcache_cleanup_req.read() ){
     2700                    if( not r_dcache_cleanup_req [num_cache].read() ){
    18062701                        m_cpt_dcache_dir_read += m_dcache_ways;
    1807                         vci_addr_t  ad  = r_dcache_addr_save.read();
    1808                         r_dcache_cleanup_req = r_dcache.inval(ad);
    1809                         r_dcache_cleanup_line = r_dcache_addr_save.read() >> m_dcache_words_shift;
    1810 
    1811                         r_dcache_fsm = DCACHE_IDLE;
     2702                        vci_addr_t  ad  = r_dcache_addr_save [num_cache].read();
     2703                        r_dcache_cleanup_req  [num_cache] = r_dcache[num_cache]->inval(ad);
     2704                        r_dcache_cleanup_line [num_cache] = r_dcache_addr_save [num_cache].read() >> m_dcache_words_shift;
     2705
     2706                        r_dcache_fsm          [num_cache] = DCACHE_IDLE;
    18122707                    }
    18132708                    break;
     
    18152710            case DCACHE_SYNC :
    18162711                {
    1817                     if ( r_tgt_dcache_req ) {   // external request
    1818                         r_dcache_fsm = DCACHE_CC_CHECK;
    1819                         r_dcache_fsm_save = r_dcache_fsm;
     2712                    if ( r_tgt_dcache_req[num_cache] ) {   // external request
     2713                        r_dcache_fsm     [num_cache] = DCACHE_CC_CHECK;
     2714                        r_dcache_fsm_save[num_cache] = r_dcache_fsm[num_cache];
    18202715                        break;
    18212716                    }
    18222717
    1823                     if (r_wbuf.empty())
    1824                         {
    1825                             drsp.valid = true; // end, can accept the sync request
    1826                             r_dcache_fsm = DCACHE_IDLE;
    1827                         }
     2718                    bool empty=true;
     2719                    for (uint32_t i=0; i<m_nb_dcache; ++i)
     2720                        empty &= r_wbuf[i]->empty();
     2721                   
     2722                    if (empty)
     2723                    {
     2724                        _drsp.valid = true; // end, can accept the sync request
     2725                        r_dcache_fsm [num_cache] = DCACHE_IDLE;
     2726                        r_dcache_sync[num_cache] = false;
     2727                    }
    18282728                    break;
    18292729                }
     
    18312731            case DCACHE_CC_CHECK:   // read directory in case of invalidate or update request
    18322732                {
    1833                     addr_40  ad          = r_tgt_addr;
     2733                    addr_40  ad          = r_tgt_daddr;
    18342734                    data_t  dcache_rdata = 0;
    18352735
    1836                     if((r_dcache_fsm_save == DCACHE_MISS_WAIT) and
    1837                             ( (r_dcache_addr_save.read() & ~((m_dcache_words<<2)-1)) == (ad & ~((m_dcache_words<<2)-1)))) {
    1838                         r_dcache_inval_rsp = true;
    1839                         r_tgt_dcache_req = false;
     2736                    PRINTF("    * <DCACHE [%d]> CC_CHECK\n",num_cache);
     2737
     2738                    if((r_dcache_fsm_save[num_cache] == DCACHE_MISS_WAIT) and
     2739                       ((r_dcache_addr_save[num_cache].read() & ~((m_dcache_words<<2)-1)) == (ad & ~((m_dcache_words<<2)-1)))) {
     2740                        PRINTF("    * <DCACHE [%d]> have request, need inval rsp\n",num_cache);
     2741
     2742                        r_dcache_inval_rsp[num_cache] = true;
     2743                        r_tgt_dcache_req  [num_cache] = false;
    18402744                        if(r_tgt_update){    // Also send a cleanup and answer
    1841                             r_tgt_dcache_rsp     = true;
     2745                            PRINTF("    * <DCACHE [%d]> send a cleanup and answer\n",num_cache);
     2746                            r_tgt_dcache_rsp[num_cache]     = true;
    18422747                        } else {            // Also send a cleanup but don't answer
    1843                             r_tgt_dcache_rsp     = false;
     2748                            PRINTF("    * <DCACHE [%d]> send a cleanup and but don't answer\n",num_cache);
     2749                            r_tgt_dcache_rsp[num_cache]     = false;
    18442750                        }
    1845                         r_dcache_fsm = r_dcache_fsm_save;
     2751                        r_dcache_fsm[num_cache] = r_dcache_fsm_save[num_cache];
    18462752                    } else {
    1847                         bool    dcache_hit   = r_dcache.read(ad, &dcache_rdata);
     2753                        bool    dcache_hit   = r_dcache[num_cache]->read(ad, &dcache_rdata);
     2754
     2755                        PRINTF("    * <DCACHE [%d]> have no request, hit cache : %d, update : %d\n",num_cache,dcache_hit,(uint32_t)r_tgt_update);
    18482756
    18492757                        m_cpt_dcache_data_read += m_dcache_ways;
     
    18602768                            data_t   rdata = 0;
    18612769
    1862                             r_dcache.read(ad+word*4,&rdata);
     2770                            r_dcache[num_cache]->read(ad+word*4,&rdata);
    18632771                           
    18642772                            r_tgt_buf[word] = (mask & r_tgt_buf[word]) | (~mask & rdata);
     
    18732781                            if (word==m_dcache_words)
    18742782                            {
    1875                                 r_dcache_fsm = DCACHE_CC_UPDT;
     2783                                r_dcache_fsm[num_cache] = DCACHE_CC_UPDT;
    18762784#if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT
    18772785                                for (word=0; word<m_dcache_words; ++word)
     
    18872795                            for(size_t i=0; i<m_dcache_words; i++){
    18882796                                data_t rdata = 0;
    1889                                 r_dcache.read(ad + i*4,&rdata);
     2797                                r_dcache[num_cache]->read(ad + i*4,&rdata);
    18902798                                data_t mask = vci_param::be2mask(r_tgt_be[i]);
    18912799                                r_tgt_buf[i] = (mask & r_tgt_buf[i]) | (~mask & rdata);
    18922800                            }
    1893                             r_dcache_fsm = DCACHE_CC_UPDT;
     2801                            r_dcache_fsm[num_cache] = DCACHE_CC_UPDT;
    18942802#endif //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
    18952803                        } else if ( dcache_hit and not r_tgt_update ) {
    1896                             r_dcache_fsm = DCACHE_CC_INVAL;
     2804                            r_dcache_fsm[num_cache] = DCACHE_CC_INVAL;
    18972805                        } else {
    18982806                            if(r_tgt_update){
    1899                                 r_tgt_dcache_rsp = true;
     2807                                r_tgt_dcache_rsp[num_cache] = true;
    19002808                            } else {
    1901                                 r_tgt_dcache_rsp = false;
     2809                                r_tgt_dcache_rsp[num_cache] = false;
    19022810                            }
    1903                             r_tgt_dcache_req = false;
    1904                             r_dcache_fsm = r_dcache_fsm_save;
     2811                            r_tgt_dcache_req[num_cache] = false;
     2812                            r_dcache_fsm    [num_cache] = r_dcache_fsm_save[num_cache];
    19052813                        }
    19062814                    }
     
    19102818            case DCACHE_CC_UPDT:    // update directory and data cache       
    19112819                {
    1912                     addr_40 ad = r_tgt_addr;
     2820                    addr_40 ad = r_tgt_daddr;
    19132821
    19142822                    m_cpt_dcache_dir_write++;
     
    19232831                   
    19242832                    if(r_tgt_be[word])
    1925                         r_dcache.write(ad+word*4, r_tgt_buf[word]);
     2833                        r_dcache[num_cache]->write(ad+word*4, r_tgt_buf[word]);
    19262834# ifdef COHERENCE_DEBUG
    19272835                    std::cout << " address " << std::hex << ad+word*4 << " data " << std::dec << r_tgt_buf[word] << std::endl;
    19282836                    data_t rdata = 0xAAAAAAAA;
    1929                     r_dcache.read(ad+word*4,&rdata);
     2837                    r_dcache[num_cache]->read(ad+word*4,&rdata);
    19302838                    std::cout << "data written " << rdata << std::endl;
    19312839# endif
     
    19402848                    if (word==m_dcache_words)
    19412849                    {
    1942                         r_tgt_dcache_req = false;
    1943                         r_tgt_dcache_rsp = true;
    1944                         r_dcache_fsm = r_dcache_fsm_save;
     2850                        r_tgt_dcache_req[num_cache] = false;
     2851                        r_tgt_dcache_rsp[num_cache] = true;
     2852                        r_dcache_fsm    [num_cache] = r_dcache_fsm_save[num_cache];
    19452853                        word = 0;
    19462854                    }
     
    19502858                    for(size_t i=0; i<m_dcache_words; i++){
    19512859                        if(r_tgt_be[i]) {
    1952                             r_dcache.write( ad + i*4, buf[i]);
     2860                            r_dcache[num_cache]->write( ad + i*4, buf[i]);
    19532861# ifdef COHERENCE_DEBUG
    19542862                            std::cout << " address " << std::hex << ad+i*4 << " data " << std::dec << buf[i] << std::endl;
    19552863                            data_t rdata = 0xAAAAAAAA;
    1956                             r_dcache.read(ad + i*4,&rdata);
     2864                            r_dcache[num_cache]->read(ad + i*4,&rdata);
    19572865                            std::cout << "data written " << rdata << std::endl;
    19582866# endif //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE
    19592867                        }
    19602868                    }
    1961                     r_tgt_dcache_req = false;
    1962                     r_tgt_dcache_rsp = true;
    1963                     r_dcache_fsm = r_dcache_fsm_save;
     2869                    r_tgt_dcache_req[num_cache] = false;
     2870                    r_tgt_dcache_rsp[num_cache] = true;
     2871                    r_dcache_fsm    [num_cache] = r_dcache_fsm_save[num_cache];
    19642872#endif
    19652873                    break;
     
    19682876            case DCACHE_CC_INVAL:   // invalidate a cache line
    19692877                {
    1970                     addr_40  ad      = r_tgt_addr;
    1971                     r_tgt_dcache_rsp = true;
    1972                     r_dcache.inval(ad);
    1973                     r_tgt_dcache_req = false;
    1974                     r_dcache_fsm = r_dcache_fsm_save;
     2878                    addr_40  ad      = r_tgt_daddr;
     2879                    r_tgt_dcache_rsp[num_cache] = true;
     2880                    r_dcache        [num_cache]->inval(ad);
     2881                    r_tgt_dcache_req[num_cache] = false;
     2882                    r_dcache_fsm    [num_cache] = r_dcache_fsm_save[num_cache];
    19752883                    break;
    19762884                }
     
    19792887                {
    19802888                    // external cache invalidate request
    1981                     if ( r_tgt_dcache_req )   
     2889                    if ( r_tgt_dcache_req[num_cache] )   
    19822890                    {
    1983                         r_dcache_fsm = DCACHE_CC_CHECK;
    1984                         r_dcache_fsm_save = r_dcache_fsm;
     2891                        r_dcache_fsm     [num_cache] = DCACHE_CC_CHECK;
     2892                        r_dcache_fsm_save[num_cache] = r_dcache_fsm[num_cache];
    19852893                        break;
    19862894                    }       
    19872895                    // cleanup
    1988                     if(not r_dcache_cleanup_req){
    1989                         r_dcache_cleanup_req = true;
    1990                         r_dcache_cleanup_line = r_dcache_addr_save.read() >> m_dcache_words_shift;
    1991                         r_dcache_fsm = DCACHE_IDLE;
     2896                    if(not r_dcache_cleanup_req[num_cache]){
     2897                        r_dcache_cleanup_req  [num_cache] = true;
     2898                        r_dcache_cleanup_line [num_cache] = r_dcache_addr_save[num_cache].read() >> m_dcache_words_shift;
     2899                        r_dcache_fsm          [num_cache] = DCACHE_IDLE;
     2900
     2901                        // FIXME : too many access at the cache in this cycle
     2902                        m_cpt_dcache_dir_read += m_dcache_ways;
     2903                        r_dcache[num_cache]->inval((addr_40)r_dcache_addr_save[num_cache]);
    19922904                    }
    19932905                    break;
     
    19992911        // The update() method must be called at each cycle to update the internal state.
    20002912        // All pending write requests must be locked in case of SYNC
    2001         bool wbuf_flush=(r_dcache_fsm == DCACHE_SYNC);
     2913
     2914        // bool have_sync=(r_dcache_fsm[num_cache] == DCACHE_SYNC);
    20022915#if   (CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME==1)
    2003         r_wbuf.update_multi_scan      (wbuf_flush);
     2916        r_wbuf[num_cache]->update_multi_scan      (have_sync);
    20042917#elif (CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME==2)
    2005         r_wbuf.update_round_robin_scan(wbuf_flush);
     2918        r_wbuf[num_cache]->update_round_robin_scan(have_sync);
    20062919#elif (CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME==3)
    2007         r_wbuf.update_one_scan        (wbuf_flush);
     2920        r_wbuf[num_cache]->update_one_scan        (have_sync);
    20082921#else
    2009         r_wbuf.update                 (wbuf_flush);
     2922        r_wbuf[num_cache]->update                 (have_sync);
     2923#endif
     2924
     2925        drsp [num_cache] = _drsp;
     2926        if (_dreq.valid and _drsp.valid)
     2927        {
     2928            PRINTF("    * <CPU2CACHE> Transaction between cpu %d and Dcache %d (unlock)\n",r_dcache_lock [num_cache].read(),num_cache);
     2929
     2930            r_dcache_lock       [num_cache] = m_nb_cpu;
     2931            m_cpt_dcache_access [num_cache] ++;
     2932        }
     2933
     2934        }// end for num_cache
     2935
     2936        /////////// execute one iss cycle /////////////////////////////////////////////
     2937
     2938        for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu)
     2939        {
     2940            // Test if the resquest is accepted
     2941            typename iss_t::InstructionResponse _irsp = ISS_IRSP_INITIALIZER;
     2942            typename iss_t::DataResponse        _drsp = ISS_DRSP_INITIALIZER;
     2943
     2944            if (ireq_num_cache[num_cpu]<m_nb_icache)
     2945                _irsp = irsp[ireq_num_cache[num_cpu]];
     2946            if (dreq_num_cache[num_cpu]<m_nb_dcache)
     2947                _drsp = drsp[dreq_num_cache[num_cpu]];
     2948
     2949#if CC_XCACHE_WRAPPER_STOP_SIMULATION  or CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     2950            typename iss_t::InstructionRequest  _ireq = ISS_IREQ_INITIALIZER;
     2951            typename iss_t::DataRequest         _dreq = ISS_DREQ_INITIALIZER;
     2952
     2953            if (ireq_num_cache[num_cpu]<m_nb_icache)
     2954                _ireq = ireq[ireq_num_cache[num_cpu]];
     2955            if (dreq_num_cache[num_cpu]<m_nb_dcache)
     2956                _dreq = dreq[dreq_num_cache[num_cpu]];
    20102957#endif
    20112958
    20122959#if CC_XCACHE_WRAPPER_DEBUG
    2013         if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN)
    2014             std::cout << "    * Data        Response : " << drsp << std::endl;
    2015 #endif
    2016 
    2017         /////////// execute one iss cycle /////////////////////////////////////////////
    2018         {
    2019             uint32_t it = 0;
    2020             for (size_t i=0; i<(size_t)iss_t::n_irq; i++)
    2021                 if(p_irq[i].read()) it |= (1<<i);
    2022             m_iss.executeNCycles(1, irsp, drsp, it);
    2023         }
    2024 
    2025         if ( (ireq.valid and not irsp.valid) or
    2026              (dreq.valid and not drsp.valid))
    2027         {
    2028             m_cpt_frz_cycles++;
     2960            if (m_cpt_total_cycles>=CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN)
     2961            {
     2962
     2963                std::cout << "    * CPU                    : " << num_cpu << std::endl
     2964                          << "      * Instruction Cache    : " << ireq_num_cache[num_cpu] << ", valid : " << (ireq_num_cache[num_cpu]<m_nb_icache) << std::endl
     2965                          << "      * Instruction Request  : " << _ireq << std::endl
     2966                          << "      * Instruction Response : " << _irsp << std::endl
     2967                          << "      * Data        Cache    : " << dreq_num_cache[num_cpu] << ", valid : " << (dreq_num_cache[num_cpu]<m_nb_dcache) << std::endl
     2968                          << "      * Data        Request  : " << _dreq << std::endl
     2969                          << "      * Data        Response : " << _drsp << std::endl;
     2970            }
     2971#endif
     2972
     2973            if ((_ireq.valid and not _irsp.valid) or
     2974                (_dreq.valid and not _drsp.valid))
     2975            {
     2976                m_cpt_frz_cycles [num_cpu]++;
    20292977#if CC_XCACHE_WRAPPER_STOP_SIMULATION
    2030             m_stop_simulation_nb_frz_cycles ++;
     2978                m_stop_simulation_nb_frz_cycles [num_cpu]++;
     2979               
     2980                if (m_stop_simulation and (m_stop_simulation_nb_frz_cycles [num_cpu]>= m_stop_simulation_nb_frz_cycles_max))
     2981                {
     2982                    std::cout << std::dec << "CC_XCACHE_WRAPPER \"" << name() << "\" (" << num_cpu << ") : cycle " << m_cpt_total_cycles << ", the cpu is frozen since " << m_stop_simulation_nb_frz_cycles [num_cpu]<< " cycles." << std::endl;
     2983                    ASSERT(false,"CPU : anormal activity"); // exit
     2984                }
     2985            }
     2986            else
     2987            {
     2988                m_stop_simulation_nb_frz_cycles [num_cpu] = 0; // reinit counter
     2989#endif //CC_XCACHE_WRAPPER_STOP_SIMULATION
     2990            }
    20312991           
    2032             if (m_stop_simulation and (m_stop_simulation_nb_frz_cycles >= m_stop_simulation_nb_frz_cycles_max))
     2992#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     2993            if (_ireq.valid and _irsp.valid)
    20332994            {
    2034                 std::cout << std::dec << "CC_XCACHE_WRAPPER \"" << name() << "\" : cycle " << m_cpt_total_cycles << ", the cpu is frozen since " << m_stop_simulation_nb_frz_cycles << " cycles." << std::endl;
    2035                 ASSERT(false,"CPU : anormal activity"); // exit
     2995                log_transaction_file_icache [num_cpu]
     2996                    << "[" << m_cpt_total_cycles << "]"
     2997                    << std::hex
     2998                    << " @ "     << std::setw(8) << (uint32_t)_ireq.addr
     2999                    << " ("      << std::setw(8) << (uint32_t)set_num_icache_only(_ireq.addr,ireq_num_cache[num_cpu])
     3000                    << " - L "     << std::setw(8) <<((uint32_t)set_num_icache_only(_ireq.addr,ireq_num_cache[num_cpu])&m_icache_yzmask) << ")"
     3001                    << " I "     << std::setw(8) << (uint32_t)_irsp.instruction
     3002                    << " error "                 << (uint32_t)_irsp.error
     3003                    << std::dec
     3004                    << std::endl;
    20363005            }
    2037         }
    2038         else
    2039         {
    2040             m_stop_simulation_nb_frz_cycles = 0; // reinit counter
    2041 #endif //CC_XCACHE_WRAPPER_STOP_SIMULATION
    2042         }
    2043 
    2044 
    2045 #if CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION
    2046         if (dreq.valid and drsp.valid)
    2047         {
    2048             log_dcache_transaction_file
    2049                 << "[" << m_cpt_total_cycles << "]"
    2050                 << std::hex
    2051                 << " @ "     << std::setw(8) << (uint32_t)dreq.addr
    2052                 << " be "    << std::setw(1) << (uint32_t)dreq.be
    2053                 << " W "     << std::setw(8) << (uint32_t)dreq.wdata
    2054                 << " R "     << std::setw(8) << (uint32_t)drsp.rdata
    2055                 << " error "            << (uint32_t)drsp.error
    2056                 << std::dec
    2057                 << " "  << type_str(dreq.type);
    2058 
    2059             if ((dreq.type == iss_t::XTN_READ) or
    2060                 (dreq.type == iss_t::XTN_WRITE))
    2061                 //log_dcache_transaction_file << xtn_str(dreq.addr>>2);
    2062                 switch (dreq.addr>>2)
    2063                 {
    2064                 case iss_t::XTN_DCACHE_INVAL : log_dcache_transaction_file << " INVAL"; break;
    2065                 case iss_t::XTN_SYNC         : log_dcache_transaction_file << " SYNC"; break;
    2066                 default                      : log_dcache_transaction_file << " invalid"; break;
    2067                 }                                                                           
    2068 
    2069             log_dcache_transaction_file << std::endl;
    2070 
    2071             // printf("[%d] @ %.8x be %.1x W %.8x R %.8x error %d - %s"
    2072             //        ,(uint32_t)m_cpt_total_cycles
    2073             //        ,(uint32_t)dreq.addr
    2074             //        ,(uint32_t)dreq.be
    2075             //        ,(uint32_t)dreq.wdata
    2076             //        ,(uint32_t)drsp.rdata
    2077             //        ,(uint32_t)drsp.error
    2078             //        ,type_str(dreq.type));
    2079             // if ((dreq.type == iss_t::XTN_READ) or
    2080             //     (dreq.type == iss_t::XTN_WRITE))
    2081             //     //     printf(" %s",xtn_str(dreq.addr>>2));
    2082             //     switch (dreq.addr>>2)
    2083             //     {
    2084             //     case iss_t::XTN_DCACHE_INVAL : printf(" INVAL"); break;
    2085             //     case iss_t::XTN_SYNC         : printf(" SYNC"); break;
    2086             //     default                      : printf(" invalid"); break;
    2087             //     }                                                                           
    2088             // printf("\n");
    2089         }
    2090 #endif //CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION
     3006
     3007            if (_dreq.valid and _drsp.valid)
     3008            {
     3009                log_transaction_file_dcache [num_cpu]
     3010                    << "[" << m_cpt_total_cycles << "]"
     3011                    << std::hex
     3012                    << " @ "     << std::setw(8) << (uint32_t)_dreq.addr
     3013                    << " ("      << std::setw(8) << (uint32_t)set_num_dcache_only(_dreq.addr,dreq_num_cache[num_cpu])
     3014                    << " - L "   << std::setw(8) <<((uint32_t)set_num_dcache_only(_dreq.addr,dreq_num_cache[num_cpu])&m_dcache_yzmask) << ")"
     3015                    << " be "    << std::setw(1) << (uint32_t)_dreq.be
     3016                    << " W "     << std::setw(8) << (uint32_t)_dreq.wdata
     3017                    << " R "     << std::setw(8) << (uint32_t)_drsp.rdata
     3018                    << " error "                 << (uint32_t)_drsp.error
     3019                    << std::dec
     3020                    << " "  << type_str(_dreq.type);
     3021               
     3022                if ((_dreq.type == iss_t::XTN_READ) or
     3023                    (_dreq.type == iss_t::XTN_WRITE))
     3024                    //log_transaction_file_dcache [num_cpu] << xtn_str(_dreq.addr>>2);
     3025                    switch (_dreq.addr>>2)
     3026                    {
     3027                    case iss_t::XTN_DCACHE_INVAL : log_transaction_file_dcache [num_cpu]<< " INVAL"; break;
     3028                    case iss_t::XTN_SYNC         : log_transaction_file_dcache [num_cpu]<< " SYNC"; break;
     3029                    default                      : log_transaction_file_dcache [num_cpu]<< " invalid"; break;
     3030                    }
     3031               
     3032                log_transaction_file_dcache [num_cpu]<< std::endl;
     3033            }
     3034#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3035           
     3036            {
     3037                uint32_t it = 0;
     3038                for (size_t i=0; i<(size_t)iss_t::n_irq; i++)
     3039                    if(p_irq[num_cpu][i].read()) it |= (1<<i);
     3040               
     3041                m_iss[num_cpu]->executeNCycles(1, _irsp, _drsp, it);
     3042            }
     3043        }//end num_cpu
    20913044
    20923045        ////////////////////////////////////////////////////////////////////////////
     
    21133066
    21143067            case CLEANUP_IDLE:
    2115             {   
    2116                 if ( p_vci_ini_c.cmdack )
    2117                 {
    2118                     if      (r_dcache_cleanup_req)      r_cleanup_fsm = CLEANUP_DCACHE;
    2119                     else if (r_icache_cleanup_req)      r_cleanup_fsm = CLEANUP_ICACHE;
     3068            {
     3069                uint32_t num_cache          = 0;
     3070                bool     cleanup_dcache_req = false;
     3071                bool     cleanup_icache_req = false;
     3072
     3073                // dcache is prior
     3074                for (uint32_t i=0; i<m_nb_dcache; ++i)
     3075                {
     3076                    PRINTF("      * <CLEANUP> dcache_cleanup_req : [%d] %d\n",i,(int)r_dcache_cleanup_req[i]);
     3077                    cleanup_dcache_req |= r_dcache_cleanup_req[i];
     3078                    if (cleanup_dcache_req)
     3079                    {
     3080                        PRINTF("      * <CLEANUP> ... find\n");
     3081                        num_cache=i;
     3082                        break;
     3083                    }
     3084                }
     3085 
     3086                if (not cleanup_dcache_req)
     3087                for (uint32_t i=0; i<m_nb_icache; ++i)
     3088                {
     3089                    PRINTF("      * <CLEANUP> icache_cleanup_req : [%d] %d\n",i,(int)r_icache_cleanup_req[i]);
     3090
     3091                    cleanup_icache_req |= r_icache_cleanup_req[i];
     3092                    if (cleanup_icache_req)
     3093                    {
     3094                        PRINTF("      * <CLEANUP> ... find\n");
     3095                        num_cache=i;
     3096                        break;
     3097                    }
     3098                }
     3099
     3100                PRINTF("      * <CLEANUP> cleanup_icache_req : %d\n",cleanup_icache_req);
     3101                PRINTF("      * <CLEANUP> cleanup_dcache_req : %d\n",cleanup_dcache_req);
     3102                PRINTF("      * <CLEANUP> num_cache          : %d\n",num_cache);
     3103
     3104                if (cleanup_icache_req or cleanup_dcache_req)
     3105                {
     3106                    r_cleanup_fsm       = CLEANUP_REQ;
     3107                    r_cleanup_icache    = cleanup_icache_req;
     3108                    r_cleanup_num_cache = num_cache;
     3109
     3110                    PRINTF("      * <CLEANUP> address            : %llx\n",((cleanup_icache_req)?((uint64_t)set_num_icache_only(r_icache_cleanup_line[num_cache].read()<<m_icache_words_shift,num_cache)):((uint64_t)set_num_dcache_only(r_dcache_cleanup_line[num_cache].read()<<m_dcache_words_shift,num_cache))));
     3111
     3112#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3113                    log_transaction_file_cleanup
     3114                        << "[" << m_cpt_total_cycles << "] "
     3115                        << ((cleanup_icache_req)?("icache "):("dcache "))
     3116                        << num_cache << " : "
     3117                        << std::hex
     3118                        << " L "     << std::setw(10) << ((cleanup_icache_req)?((uint64_t)set_num_icache_only(r_icache_cleanup_line[num_cache].read()<<m_icache_words_shift,num_cache)):((uint64_t)set_num_dcache_only(r_dcache_cleanup_line[num_cache].read()<<m_dcache_words_shift,num_cache)))
     3119                        // << " (" << std::setw(10) << addr << ")"
     3120                        << std::dec
     3121                        << std::endl;
     3122#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3123
    21203124                }
    21213125                break;
    21223126            }
    2123             case CLEANUP_DCACHE:
     3127            case CLEANUP_REQ:
     3128            {
     3129                if ( p_vci_ini_c.cmdack )
     3130                {
     3131                    if (r_cleanup_icache)
     3132                        r_cleanup_fsm = CLEANUP_RSP_ICACHE;
     3133                    else
     3134                        r_cleanup_fsm = CLEANUP_RSP_DCACHE;
     3135                }
     3136                break;
     3137            }
     3138            case CLEANUP_RSP_DCACHE:
    21243139            {
    21253140                if ( p_vci_ini_c.rspval )
    21263141                {
    21273142                    PRINTF("      * <CLEANUP> rerror : %d (%d)\n",(uint32_t)p_vci_ini_c.rerror.read(),0x2 & ( (1 << vci_param::E) - 1));
     3143                    PRINTF("      * <CLEANUP> rpktid : %d, r_cleanup_num_cache : %d\n",(uint32_t)p_vci_ini_c.rpktid.read(), (uint32_t)r_cleanup_num_cache);
    21283144
    21293145                    ASSERT(p_vci_ini_c.reop and (p_vci_ini_c.rtrdid.read() == TYPE_DATA_CLEANUP),
    2130                             "illegal response packet received for a cleanup transaction");
     3146                           "illegal response packet received for a cleanup transaction");
    21313147                    ASSERT(p_vci_ini_c.rerror.read() == vci_param::ERR_NORMAL,
    21323148                           "error signaled in a cleanup response" );
    2133                    
     3149                    ASSERT(p_vci_ini_c.rpktid.read() == (sc_dt::sc_uint<vci_param::P>)r_cleanup_num_cache,
     3150                           "invalid pktid in a cleanup response");
     3151
    21343152                    r_cleanup_fsm = CLEANUP_IDLE;
    2135                     r_dcache_cleanup_req = false;
    2136                     // m_cpt_cc_cleanup_data++; TODO
     3153                    r_dcache_cleanup_req[r_cleanup_num_cache] = false;
     3154                    // m_cpt_cc_cleanup_data++;
    21373155                }
    21383156                break;
    21393157            }
    2140             case CLEANUP_ICACHE:
     3158            case CLEANUP_RSP_ICACHE:
    21413159            {
    21423160                if ( p_vci_ini_c.rspval )
     
    21503168                   
    21513169                    r_cleanup_fsm = CLEANUP_IDLE;
    2152                     r_icache_cleanup_req = false;
    2153                     // m_cpt_cc_cleanup_ins++; TODO
     3170                    r_icache_cleanup_req[r_cleanup_num_cache] = false;
     3171                    // m_cpt_cc_cleanup_ins++;
    21543172                }
    21553173                break;
     
    21953213                // if (r_vci_rsp_fsm != RSP_IDLE) break;
    21963214
    2197                 size_t  min;
    2198                 size_t  max;
    2199 
     3215                size_t  wbuf_min   = 0;
     3216                size_t  wbuf_max   = 0;
     3217#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3218                addr_40 wbuf_addr  = 0;
     3219                size_t  wbuf_index = 0;
     3220#endif
    22003221                r_vci_cmd_cpt = 0;
    22013222
     
    22043225                // multi_write_buffer access is conditionnal with dcache_miss_req and icache_miss_req
    22053226
    2206 #if   (CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY==1)
    2207                 //  1) two access authorized
    2208                 bool dcache_miss_req =  r_dcache_miss_req;
    2209                 bool icache_miss_req =  r_icache_miss_req;
    2210 #elif (CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY==2)
    2211                 //  2) one access with static priority (dcache prior)
    2212                 bool dcache_miss_req = r_dcache_miss_req; // dcache prior
    2213                 bool icache_miss_req = not dcache_miss_req and r_icache_miss_req;
     3227                bool     dcache_miss_req      = false;
     3228                bool     icache_miss_req      = false;
     3229                uint32_t dcache_miss_num_cache = 0;
     3230                uint32_t icache_miss_num_cache = 0;
     3231                addr_40  addr = 0;
     3232
     3233                {
     3234                    for (; dcache_miss_num_cache<m_nb_dcache; ++dcache_miss_num_cache)
     3235                    {
     3236                        dcache_miss_req = r_dcache_miss_req[dcache_miss_num_cache];
     3237                        if (dcache_miss_req)
     3238                            break;
     3239                    }
     3240                    for (; icache_miss_num_cache<m_nb_icache; ++icache_miss_num_cache)
     3241                    {
     3242                        icache_miss_req = r_icache_miss_req[icache_miss_num_cache];
     3243                        if (icache_miss_req)
     3244                            break;
     3245                    }
     3246
     3247                    PRINTF("      * <CMD> icache_miss_req (before) : %d\n",icache_miss_req);
     3248                    PRINTF("      * <CMD> dcache_miss_req (before) : %d\n",dcache_miss_req);
     3249
     3250// #if   (CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY==1)
     3251//                     //  1) two access authorized
     3252//                     dcache_miss_req =  r_dcache_miss_req[cache_miss_num_cache];
     3253//                     icache_miss_req =  r_icache_miss_req[cache_miss_num_cache];
     3254// #el
     3255#if   (CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY==2)
     3256                    //  2) one access with static priority (dcache prior)
     3257                    icache_miss_req &= not dcache_miss_req;
    22143258#elif (CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY==3)
    2215                 //  3) one access with static priority (icache prior)
    2216                 bool icache_miss_req = r_icache_miss_req;
    2217                 bool dcache_miss_req = not icache_miss_req and r_dcache_miss_req; // dcache prior
     3259                    //  3) one access with static priority (icache prior)
     3260                    dcache_miss_req &= not icache_miss_req;
    22183261#elif (CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY==4)
    2219                 //  4) one access with round robin priority
    2220                 bool dcache_miss_req = ((r_dcache_miss_req and not r_icache_miss_req) or // only dcache
    2221                                         (r_dcache_miss_req and r_vci_cmd_dcache_prior)); // dcache prior
    2222                 bool icache_miss_req = not dcache_miss_req and r_icache_miss_req;
     3262                    //  4) one access with round robin priority
     3263                    dcache_miss_req = ((dcache_miss_req and not icache_miss_req) or // only dcache
     3264                                       (dcache_miss_req and r_vci_cmd_dcache_prior)); // dcache prior
     3265                    icache_miss_req &= not dcache_miss_req;
    22233266#else
    22243267#error "Invalid value to CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY"
    22253268#endif
     3269
     3270                    PRINTF("      * <CMD> icache_miss_req (after ) : %d\n",icache_miss_req);
     3271                    PRINTF("      * <CMD> dcache_miss_req (after ) : %d\n",dcache_miss_req);
     3272
     3273                    PRINTF("      * <CMD> icache_miss_num_cache    : %d\n",icache_miss_num_cache);
     3274                    PRINTF("      * <CMD> dcache_miss_num_cache    : %d\n",dcache_miss_num_cache);
     3275
     3276                    if (icache_miss_req or dcache_miss_req)
     3277                    {
     3278                        addr = (icache_miss_req)?r_icache_addr_save[icache_miss_num_cache].read():r_dcache_addr_save[dcache_miss_num_cache].read();
     3279
     3280                        PRINTF("      * <CMD> addr                     : %llx\n",(uint64_t)addr);
     3281
     3282                        if (icache_miss_req)
     3283                        {
     3284                            // FIXME :
     3285                            // si wbuf contient des addresses partionné, set_num_icache puis get_num_dcache
     3286                            // dcache_miss_num_cache = icache_miss_num_cache;
     3287                            set_num_icache(addr,icache_miss_num_cache);
     3288                            // get_num_dcache(addr,dcache_miss_num_cache);
     3289                        }
     3290                        else
     3291                            set_num_dcache(addr,dcache_miss_num_cache);
     3292
     3293                        PRINTF("      * <CMD> addr                     : %llx\n",(uint64_t)addr);
     3294                    }
     3295                }
     3296
     3297                uint32_t dcache_unc_num_cache = 0;
     3298                for (; dcache_unc_num_cache<m_nb_dcache; ++dcache_unc_num_cache)
     3299                    if (r_dcache_unc_req[dcache_unc_num_cache])
     3300                        break;
     3301                uint32_t icache_unc_num_cache = 0;
     3302                for (; icache_unc_num_cache<m_nb_icache; ++icache_unc_num_cache)
     3303                    if (r_icache_unc_req[icache_unc_num_cache])
     3304                        break;
     3305                uint32_t dcache_sc_num_cache = 0;
     3306                for (; dcache_sc_num_cache<m_nb_dcache; ++dcache_sc_num_cache)
     3307                    if (r_dcache_sc_req[dcache_sc_num_cache])
     3308                        break;
     3309                uint32_t dcache_write_num_cache = 0;
     3310                for (; dcache_write_num_cache<m_nb_dcache; ++dcache_write_num_cache)
     3311                {
     3312#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3313                    if ( r_wbuf[dcache_write_num_cache]->debug_rok(&wbuf_min, &wbuf_max, &wbuf_addr, &wbuf_index))
     3314                        break;
     3315#else
     3316                    if ( r_wbuf[dcache_write_num_cache]->rok(&wbuf_min, &wbuf_max))
     3317                        break;
     3318#endif
     3319                }
     3320               
    22263321                // 1 - Data Read
    2227                 if (dcache_miss_req and r_wbuf.miss(r_dcache_addr_save))
     3322                if (dcache_miss_req and r_wbuf[dcache_miss_num_cache]->miss(addr))
    22283323                {
    2229                     r_vci_cmd_fsm = CMD_DATA_MISS;
    2230                     r_dcache_miss_req = false;
     3324                    r_vci_cmd_fsm       = CMD_DATA_MISS;
     3325                    r_vci_cmd_num_cache = dcache_miss_num_cache;
     3326                    r_dcache_miss_req[dcache_miss_num_cache] = false;
    22313327                    m_cpt_dmiss_transaction++;
     3328
     3329
     3330#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3331                    {
     3332                        log_transaction_file_cmd
     3333                            << "[" << m_cpt_total_cycles << "] "
     3334                            << "CMD DATA MISS  "
     3335                            << "(" << dcache_miss_num_cache << ") "
     3336                            << std::hex
     3337                            << " @ " << std::setw(10) << (uint64_t)addr
     3338                            << " (L " << std::setw(10) << ((uint64_t)addr&(uint64_t)m_dcache_yzmask) << ")"
     3339                            << std::dec
     3340                            << std::endl;
     3341                    }
     3342#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3343
    22323344                }
    22333345
    22343346                // 2 - Data Read Uncachable
    2235                 else if ( r_dcache_unc_req )
     3347                else if (dcache_unc_num_cache < m_nb_dcache) // have r_dcache_unc_req
    22363348                {
    2237                     r_vci_cmd_fsm = CMD_DATA_UNC;
    2238                     r_dcache_unc_req = false;
    2239                  // m_cpt_data_unc_transaction++;
     3349                    r_vci_cmd_fsm       = CMD_DATA_UNC;
     3350                    r_vci_cmd_num_cache = dcache_unc_num_cache;
     3351                    r_dcache_unc_req[dcache_unc_num_cache] = false;
     3352                    // m_cpt_data_unc_transaction++;
     3353
     3354#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3355                    {
     3356                        addr_40 addr = (addr_40) r_dcache_addr_save[dcache_unc_num_cache].read() & ~0x3;
     3357                        set_num_dcache(addr,dcache_unc_num_cache);
     3358                       
     3359                        log_transaction_file_cmd
     3360                            << "[" << m_cpt_total_cycles << "] "
     3361                            << "CMD DATA UNC   "
     3362                            << "(" << dcache_unc_num_cache << ") "
     3363                            << std::hex
     3364                            << " @ " << std::setw(10) << (uint64_t)addr
     3365                            << " (L " << std::setw(10) << ((uint64_t)addr&(uint64_t)m_dcache_yzmask) << ")"
     3366                            << std::dec
     3367                            << std::endl;
     3368                    }
     3369#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
    22403370                }
    22413371
    22423372                // 3 - Instruction Miss
    2243                 else if (icache_miss_req and r_wbuf.miss(r_icache_addr_save))
     3373                else if (icache_miss_req and r_wbuf[icache_miss_num_cache]->miss(addr))
     3374              //else if (icache_miss_req and r_wbuf[dcache_miss_num_cache]->miss(addr))
    22443375                {
    2245                     r_vci_cmd_fsm = CMD_INS_MISS;
    2246                     r_icache_miss_req = false;
     3376                    r_vci_cmd_fsm       = CMD_INS_MISS;
     3377                    r_vci_cmd_num_cache = icache_miss_num_cache;
     3378                    r_icache_miss_req[icache_miss_num_cache] = false;
    22473379                    m_cpt_imiss_transaction++;
     3380
     3381#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3382                    {
     3383                        log_transaction_file_cmd
     3384                            << "[" << m_cpt_total_cycles << "] "
     3385                            << "CMD INS  MISS  "
     3386                            << "(" << icache_miss_num_cache << ") "
     3387                            << std::hex
     3388                            << " @ " << std::setw(10) << (uint64_t)addr
     3389                            << " (L " << std::setw(10) << ((uint64_t)addr&(uint64_t)m_icache_yzmask) << ")"
     3390                            << std::dec
     3391                            << std::endl;
     3392                    }
     3393#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
    22483394                }
    22493395
    22503396                // 4 - Instruction Uncachable
    2251                 else if ( r_icache_unc_req )
     3397                else if (icache_unc_num_cache < m_nb_icache) // have r_icache_unc_req
    22523398                {
    2253                     r_vci_cmd_fsm = CMD_INS_UNC;
    2254                     r_icache_unc_req = false;
     3399                    r_vci_cmd_fsm       = CMD_INS_UNC;
     3400                    r_vci_cmd_num_cache = icache_unc_num_cache;
     3401                    r_icache_unc_req[icache_unc_num_cache] = false;
    22553402                 // m_cpt_ins_unc_transaction++;
     3403
     3404#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3405                    {
     3406                        addr_40 addr = (addr_40) r_icache_addr_save[icache_unc_num_cache].read() & ~0x3;
     3407                        set_num_dcache(addr,icache_unc_num_cache);
     3408                       
     3409                        log_transaction_file_cmd
     3410                            << "[" << m_cpt_total_cycles << "] "
     3411                            << "CMD INS  UNC   "
     3412                            << "(" << icache_unc_num_cache << ") "
     3413                            << std::hex
     3414                            << " @ " << std::setw(10) << (uint64_t)addr
     3415                            << " (L " << std::setw(10) << ((uint64_t)addr&(uint64_t)m_icache_yzmask) << ")"
     3416                            << std::dec
     3417                            << std::endl;
     3418                    }
     3419#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
    22563420                }
    22573421
    22583422                // 5 - Data Write
    2259                 else if ( r_wbuf.rok(&min, &max) )
     3423                else if (dcache_write_num_cache < m_nb_dcache) // have r_wbuf.rok(&wbuf_min, &wbuf_max)
    22603424                {
    2261                     r_vci_cmd_fsm = CMD_DATA_WRITE;
    2262                     r_vci_cmd_cpt = min;
    2263                     r_vci_cmd_min = min;
    2264                     r_vci_cmd_max = max;
     3425                    r_vci_cmd_num_cache = dcache_write_num_cache;
     3426                    r_vci_cmd_fsm       = CMD_DATA_WRITE;
     3427                    r_vci_cmd_cpt       = wbuf_min;
     3428                    r_vci_cmd_min       = wbuf_min;
     3429                    r_vci_cmd_max       = wbuf_max;
    22653430                    m_cpt_data_write_transaction++;
    2266                     m_length_write_transaction += (max-min+1);
     3431                    m_length_write_transaction += (wbuf_max-wbuf_min+1);
     3432
     3433#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3434                    {
     3435                        addr_40 addr = (addr_40) wbuf_addr&~0x3;
     3436                       
     3437                        log_transaction_file_cmd
     3438                            << "[" << m_cpt_total_cycles << "] "
     3439                            << "CMD DATA WRITE "
     3440                            << "(" << dcache_write_num_cache << ") "
     3441                            << std::hex
     3442                            << " @ " << std::setw(10) << (uint64_t)addr
     3443                            << " (L " << std::setw(10) << ((uint64_t)addr&(uint64_t)m_dcache_yzmask) << ")"
     3444                            << " [" << wbuf_min << ":" << wbuf_max << "]"
     3445                            << " {" << wbuf_index << "}"
     3446                            << std::dec
     3447                            << std::endl;
     3448                    }
     3449#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
    22673450                }
    22683451
    22693452                // 6 - Data Store Conditionnal
    2270                 else if ( r_dcache_sc_req )
     3453                else if (dcache_sc_num_cache < m_nb_dcache) // have r_dcache_sc_req
    22713454                {
    2272                     r_vci_cmd_fsm = CMD_DATA_SC;
    2273                     r_vci_cmd_max = 1;
     3455                    r_vci_cmd_fsm       = CMD_DATA_SC;
     3456                    r_vci_cmd_num_cache = dcache_sc_num_cache;
     3457                    r_vci_cmd_max       = 1;
    22743458                    m_cpt_unc_transaction++;
    2275                     r_dcache_sc_req = false;
     3459                    r_dcache_sc_req[dcache_sc_num_cache] = false;
     3460
     3461#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3462                    {
     3463                        addr_40 addr = (addr_40) r_dcache_addr_save[dcache_sc_num_cache].read() & ~0x3;
     3464                        set_num_dcache(addr,dcache_sc_num_cache);
     3465                       
     3466                        log_transaction_file_cmd
     3467                            << "[" << m_cpt_total_cycles << "] "
     3468                            << "CMD DATA SC    "
     3469                            << "(" << dcache_sc_num_cache << ") "
     3470                            << std::hex
     3471                            << " @ " << std::setw(10) << (uint64_t)addr
     3472                            << " (L " << std::setw(10) << ((uint64_t)addr&(uint64_t)m_dcache_yzmask) << ")"
     3473                            << std::dec
     3474                            << std::endl;
     3475                    }
     3476#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
    22763477                }
    22773478
     
    22833484                    if (r_vci_cmd_cpt == r_vci_cmd_max) {
    22843485                        r_vci_cmd_fsm = CMD_IDLE ;
    2285                         r_wbuf.sent() ;
     3486                        r_wbuf[r_vci_cmd_num_cache]->sent() ;
    22863487                    }
    22873488                }
     
    23393540                if( p_vci_ini_rw.rspval.read() )
    23403541                {
    2341                     PRINTF("      * <RSP> have rsp - trdid : %x\n",(uint32_t)p_vci_ini_rw.rtrdid.read());
     3542                    PRINTF("      * <RSP> have rsp - trdid : %x - num_cache : %d\n",(uint32_t)p_vci_ini_rw.rtrdid.read(),(uint32_t)p_vci_ini_rw.rpktid.read());
     3543
     3544                    ASSERT(p_vci_ini_rw.rpktid.read() <= (1<<vci_param::P),
     3545                           "invalid pktid in a cleanup response");
    23423546
    23433547                    r_vci_rsp_cpt = 0;
    23443548
    23453549                    if ((p_vci_ini_rw.rtrdid.read()>>(vci_param::T-1)) != 0 )
     3550                    {
    23463551                        r_vci_rsp_fsm = RSP_DATA_WRITE;
     3552
     3553#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3554                        {
     3555                            log_transaction_file_cmd
     3556                                << "[" << m_cpt_total_cycles << "] "
     3557                                << "RSP DATA WRITE "
     3558                                << "(" << p_vci_ini_rw.rpktid.read() << ") "
     3559                                << "{" << (p_vci_ini_rw.rtrdid.read() - (1<<(vci_param::T-1))) << "}"
     3560                                << std::endl;
     3561                        }
     3562#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3563                    }
    23473564                    else
    23483565                    {
    23493566                        switch (p_vci_ini_rw.rtrdid.read())
    23503567                        {
    2351                         case TYPE_INS_MISS     : r_vci_rsp_fsm = RSP_INS_MISS;     break;
    2352                         case TYPE_INS_UNC      : r_vci_rsp_fsm = RSP_INS_UNC;      break;
    2353                         case TYPE_DATA_MISS    : r_vci_rsp_fsm = RSP_DATA_MISS;    break;
    2354                         case TYPE_DATA_UNC     : r_vci_rsp_fsm = RSP_DATA_UNC;     break;
    2355                         case TYPE_DATA_SC      : r_vci_rsp_fsm = RSP_DATA_SC;      break;
     3568                        case TYPE_INS_MISS     :
     3569                            {
     3570                                r_vci_rsp_fsm = RSP_INS_MISS;
     3571
     3572#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3573                                {
     3574                                    log_transaction_file_cmd
     3575                                        << "[" << m_cpt_total_cycles << "] "
     3576                                        << "RSP INS  MISS  "
     3577                                        << "(" << p_vci_ini_rw.rpktid.read() << ") "
     3578                                        << std::endl;
     3579                                }
     3580#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3581
     3582                                break;
     3583                            }
     3584                        case TYPE_INS_UNC      :
     3585                            {
     3586                                r_vci_rsp_fsm = RSP_INS_UNC;
     3587
     3588#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3589                                {
     3590                                    log_transaction_file_cmd
     3591                                        << "[" << m_cpt_total_cycles << "] "
     3592                                        << "RSP INS  UNC   "
     3593                                        << "(" << p_vci_ini_rw.rpktid.read() << ") "
     3594                                        << std::endl;
     3595                                }
     3596#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3597
     3598                                break;
     3599                            }
     3600                        case TYPE_DATA_MISS    :
     3601                            {
     3602                                r_vci_rsp_fsm = RSP_DATA_MISS;
     3603
     3604#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3605                                {
     3606                                    log_transaction_file_cmd
     3607                                        << "[" << m_cpt_total_cycles << "] "
     3608                                        << "RSP DATA MISS  "
     3609                                        << "(" << p_vci_ini_rw.rpktid.read() << ") "
     3610                                        << std::endl;
     3611                                }
     3612#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3613
     3614                                break;
     3615                            }
     3616                        case TYPE_DATA_UNC     :
     3617                            {
     3618                                r_vci_rsp_fsm = RSP_DATA_UNC;
     3619
     3620#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3621                                {
     3622                                    log_transaction_file_cmd
     3623                                        << "[" << m_cpt_total_cycles << "] "
     3624                                        << "RSP DATA UNC   "
     3625                                        << "(" << p_vci_ini_rw.rpktid.read() << ") "
     3626                                        << std::endl;
     3627                                }
     3628#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3629
     3630                                break;
     3631                            }
     3632                        case TYPE_DATA_SC      :
     3633                            {
     3634                                r_vci_rsp_fsm = RSP_DATA_SC;
     3635
     3636#if CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3637                                {
     3638                                    log_transaction_file_cmd
     3639                                        << "[" << m_cpt_total_cycles << "] "
     3640                                        << "RSP DATA SC    "
     3641                                        << "(" << p_vci_ini_rw.rpktid.read() << ") "
     3642                                        << std::endl;
     3643                                }
     3644#endif //CC_XCACHE_WRAPPER_DEBUG_FILE_TRANSACTION
     3645
     3646                                break;
     3647                            }
    23563648                        default :
    23573649                            {
     
    23603652                        }
    23613653                    }
     3654
     3655                    r_vci_rsp_num_cache = p_vci_ini_rw.rpktid.read();
    23623656                }
    23633657                break;
     
    23663660
    23673661                m_cost_imiss_transaction++;
    2368                 PRINTF("      * <RSP> rspval/ack : %d - %d\n",(uint32_t)p_vci_ini_rw.rspval.read(), (uint32_t)r_vci_rsp_ack);
    2369 
    2370                 if (p_vci_ini_rw.rspval.read() and r_vci_rsp_ack)
     3662                PRINTF("      * <RSP> rspval/ack : %d - %d\n",(uint32_t)p_vci_ini_rw.rspval.read(), (uint32_t)s_vci_rsp_ack);
     3663
     3664                if (p_vci_ini_rw.rspval.read() and s_vci_rsp_ack)
    23713665                {
    23723666                    PRINTF("      * <RSP> have rsp - r_vci_rsp_cpt : %d/%d\n",(uint32_t)r_vci_rsp_cpt.read(),(uint32_t)m_icache_words);
     
    23763670                            "The VCI response packet for instruction miss is too long" );
    23773671                    r_vci_rsp_cpt = r_vci_rsp_cpt + 1;
    2378                     CACHE_MISS_BUF_RSP_PUSH(i,r_vci_rsp_cpt,(data_t)p_vci_ini_rw.rdata.read());
     3672                    CACHE_MISS_BUF_RSP_PUSH(i,r_vci_rsp_num_cache,r_vci_rsp_cpt,(data_t)p_vci_ini_rw.rdata.read());
    23793673                    if ( p_vci_ini_rw.reop.read() )
    23803674                    {
     
    23833677                        ASSERT( ((r_vci_rsp_cpt == m_icache_words - 1) or
    23843678                                 p_vci_ini_rw.rerror.read() or
    2385                                  (r_vci_rsp_ins_error.read()&0x1)),
     3679                                 (r_vci_rsp_ins_error[r_vci_rsp_num_cache].read()&0x1)),
    23863680                                "The VCI response packet for instruction miss is too short");
    23873681                        r_vci_rsp_cpt    = 0;
     
    23893683
    23903684                    }
    2391                     if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_ins_error = true;
     3685                    if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_ins_error[r_vci_rsp_num_cache] = true;
    23923686                }
    23933687                break;
     
    23963690
    23973691                m_cost_imiss_transaction++;
    2398                 if (p_vci_ini_rw.rspval.read() and r_vci_rsp_ack)
     3692                if (p_vci_ini_rw.rspval.read() and s_vci_rsp_ack)
    23993693                {
    24003694                    ASSERT(p_vci_ini_rw.reop.read(),
    24013695                           "illegal VCI response packet for uncached instruction");
    24023696
    2403                     CACHE_MISS_BUF_RSP_PUSH(i,0,(data_t)p_vci_ini_rw.rdata.read());
     3697                    CACHE_MISS_BUF_RSP_PUSH(i,r_vci_rsp_num_cache,0,(data_t)p_vci_ini_rw.rdata.read());
    24043698
    24053699                    r_vci_rsp_fsm = RSP_IDLE;
    24063700
    2407                     if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_ins_error = true;
     3701                    if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_ins_error[r_vci_rsp_num_cache] = true;
    24083702                }
    24093703                break;
     
    24123706
    24133707                m_cost_dmiss_transaction++;
    2414                 if (p_vci_ini_rw.rspval.read() and r_vci_rsp_ack)
     3708                if (p_vci_ini_rw.rspval.read() and s_vci_rsp_ack)
    24153709                {
    24163710                    PRINTF("      * <RSP> have rspval - error : %d\n",(int)p_vci_ini_rw.rerror.read());
     
    24203714                    r_vci_rsp_cpt = r_vci_rsp_cpt + 1;
    24213715
    2422                     CACHE_MISS_BUF_RSP_PUSH(d,r_vci_rsp_cpt,(data_t)p_vci_ini_rw.rdata.read());
     3716                    CACHE_MISS_BUF_RSP_PUSH(d,r_vci_rsp_num_cache,r_vci_rsp_cpt,(data_t)p_vci_ini_rw.rdata.read());
    24233717
    24243718                    if ( p_vci_ini_rw.reop.read() ) {
    24253719                        ASSERT( ((r_vci_rsp_cpt == m_dcache_words - 1)
    24263720                                 or (p_vci_ini_rw.rerror.read()&0x1)
    2427                                  or r_vci_rsp_data_error.read()),
     3721                                 or r_vci_rsp_data_error[r_vci_rsp_num_cache].read()),
    24283722                                "illegal VCI response packet for data read miss");
    24293723                        r_vci_rsp_cpt     = 0;
    24303724                        r_vci_rsp_fsm     = RSP_IDLE;
    24313725                    }
    2432                     if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_data_error = true;
     3726                    if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_data_error[r_vci_rsp_num_cache] = true;
    24333727                }
    24343728                break;
    24353729
    24363730            case RSP_DATA_WRITE:
    2437 
    24383731                m_cost_write_transaction++;
    24393732                if (p_vci_ini_rw.rspval.read())
     
    24443737                           "A VCI response packet must contain one flit for a write transaction");
    24453738                    r_vci_rsp_fsm = RSP_IDLE;
    2446                     bool cached = r_wbuf.completed(p_vci_ini_rw.rtrdid.read() - (1<<(vci_param::T-1)) );
     3739                    bool cached = r_wbuf[r_vci_rsp_num_cache]->completed(p_vci_ini_rw.rtrdid.read() - (1<<(vci_param::T-1)));
    24473740
    24483741                    PRINTF("      * <RSP> cached : %d\n",cached);
    24493742
    24503743                    if (not cached)
    2451                         r_dcache_previous_unc = false;
    2452 
    2453                     if ((p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL) m_iss.setWriteBerr();
     3744                        r_dcache_previous_unc[r_vci_rsp_num_cache] = false;
     3745
     3746                    // FIXME : r_vci_rsp_num_cache != num_cpu ! -> pktid
     3747                    if ((p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL) m_iss[r_vci_rsp_num_cache]->setWriteBerr();
    24543748                }
    24553749                break;
     
    24573751            case RSP_DATA_UNC:
    24583752                m_cost_unc_transaction++;
    2459                 if (p_vci_ini_rw.rspval.read() and r_vci_rsp_ack)
     3753                if (p_vci_ini_rw.rspval.read() and s_vci_rsp_ack)
    24603754                {
    24613755                    ASSERT(p_vci_ini_rw.reop.read(),
    24623756                           "illegal VCI response packet for data read uncached");
    24633757
    2464                     CACHE_MISS_BUF_RSP_PUSH(d,0,(data_t)p_vci_ini_rw.rdata.read());
     3758                    CACHE_MISS_BUF_RSP_PUSH(d,r_vci_rsp_num_cache,0,(data_t)p_vci_ini_rw.rdata.read());
    24653759
    24663760                    r_vci_rsp_fsm = RSP_IDLE;
    2467                     r_dcache_previous_unc = false;
    2468 
    2469                     if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_data_error = true;
     3761                    r_dcache_previous_unc[r_vci_rsp_num_cache] = false;
     3762
     3763                    if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_data_error[r_vci_rsp_num_cache] = true;
    24703764                }
    24713765                break;
     
    24733767            case RSP_DATA_SC:
    24743768                m_cost_unc_transaction++;
    2475                 if (p_vci_ini_rw.rspval.read() and r_vci_rsp_ack)
     3769                if (p_vci_ini_rw.rspval.read() and s_vci_rsp_ack)
    24763770                {
    24773771                    ASSERT(p_vci_ini_rw.reop.read(),
    24783772                           "illegal VCI response packet for data SC");
    24793773
    2480                     CACHE_MISS_BUF_RSP_PUSH(d,0,(data_t)p_vci_ini_rw.rdata.read());
     3774                    CACHE_MISS_BUF_RSP_PUSH(d,r_vci_rsp_num_cache,0,(data_t)p_vci_ini_rw.rdata.read());
    24813775
    24823776                    r_vci_rsp_fsm = RSP_IDLE;
    2483                     r_dcache_previous_unc = false;
    2484 
    2485                     if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_data_error = true;
     3777                    r_dcache_previous_unc[r_vci_rsp_num_cache] = false;
     3778
     3779                    if ( (p_vci_ini_rw.rerror.read()&0x1) != vci_param::ERR_NORMAL ) r_vci_rsp_data_error[r_vci_rsp_num_cache] = true;
    24863780                }
    24873781                break;
     
    24893783        } // end switch r_vci_rsp_fsm
    24903784
    2491     } // end transition()
     3785   } // end transition()
    24923786
    24933787    //////////////////////////////////////////////////////////////////////////////////
     
    24953789    //////////////////////////////////////////////////////////////////////////////////
    24963790    {
     3791        PRINTF("--------------------------------------------\n");
     3792        PRINTF("  * CC_XCACHE_WRAPPER \"%s\" genMoore - Time = %d\n",name().c_str(),(uint32_t)m_cpt_total_cycles);
    24973793
    24983794        // VCI initiator response
    24993795        switch ( r_cleanup_fsm.read() ) {
    2500 
    25013796            case CLEANUP_IDLE:
    25023797                p_vci_ini_c.rspack  = false;
    2503                 p_vci_ini_c.cmdval  = r_icache_cleanup_req || r_dcache_cleanup_req;
    2504                 if ( r_dcache_cleanup_req )
    2505                 {
    2506                     p_vci_ini_c.address =  r_dcache_cleanup_line.read() * (m_dcache_words << 2);
    2507                     p_vci_ini_c.trdid   = TYPE_DATA_CLEANUP;
     3798                p_vci_ini_c.cmdval  = false;
     3799                p_vci_ini_c.address = 0;
     3800                p_vci_ini_c.wdata   = 0;
     3801                p_vci_ini_c.be      = 0;
     3802                p_vci_ini_c.plen    = 0;
     3803                p_vci_ini_c.cmd     = vci_param::CMD_WRITE;
     3804                p_vci_ini_c.trdid   = 0;
     3805                p_vci_ini_c.pktid   = 0;
     3806                p_vci_ini_c.srcid   = 0;
     3807                p_vci_ini_c.cons    = false;
     3808                p_vci_ini_c.wrap    = false;
     3809                p_vci_ini_c.contig  = false;
     3810                p_vci_ini_c.clen    = 0;
     3811                p_vci_ini_c.cfixed  = false;
     3812                p_vci_ini_c.eop     = false;
     3813                break;
     3814
     3815            case CLEANUP_REQ:
     3816                {
     3817                addr_40 addr;
     3818                if (r_cleanup_icache)
     3819                {
     3820                    addr = r_icache_cleanup_line[r_cleanup_num_cache].read()<<m_icache_words_shift;
     3821                    set_num_icache(addr,r_cleanup_num_cache);
     3822
     3823                    PRINTF("      * <CLEANUP> icache             : %llx\n",(uint64_t)addr);
    25083824                }
    25093825                else
    25103826                {
    2511                     p_vci_ini_c.address =  r_icache_cleanup_line.read() * (m_icache_words << 2);
    2512                     p_vci_ini_c.trdid   = TYPE_INS_CLEANUP;
    2513                 }
    2514                 p_vci_ini_c.wdata  = 0;
    2515                 p_vci_ini_c.be     = 0xF;
    2516                 p_vci_ini_c.plen   = 4;
    2517                 p_vci_ini_c.cmd    = vci_param::CMD_WRITE;
    2518                 p_vci_ini_c.pktid  = 0;
    2519                 p_vci_ini_c.srcid  = m_srcid_c;
    2520                 p_vci_ini_c.cons   = false;
    2521                 p_vci_ini_c.wrap   = false;
    2522                 p_vci_ini_c.contig = false;
    2523                 p_vci_ini_c.clen   = 0;
    2524                 p_vci_ini_c.cfixed = false;
    2525                 p_vci_ini_c.eop    = true;
     3827                    addr = r_dcache_cleanup_line[r_cleanup_num_cache].read()<<m_dcache_words_shift;
     3828                    set_num_dcache(addr,r_cleanup_num_cache);
     3829
     3830                    PRINTF("      * <CLEANUP> dcache             : %llx\n",(uint64_t)addr);
     3831                }
     3832
     3833                p_vci_ini_c.rspack  = false;
     3834                p_vci_ini_c.cmdval  = true;
     3835                p_vci_ini_c.address = addr;
     3836                p_vci_ini_c.wdata   = 0;
     3837                p_vci_ini_c.be      = 0xF;
     3838                p_vci_ini_c.plen    = 4;
     3839                p_vci_ini_c.cmd     = vci_param::CMD_WRITE;
     3840                p_vci_ini_c.trdid   = (r_cleanup_icache)?TYPE_INS_CLEANUP:TYPE_DATA_CLEANUP;
     3841                p_vci_ini_c.pktid   = (sc_dt::sc_uint<vci_param::P>)r_cleanup_num_cache;
     3842                p_vci_ini_c.srcid   = m_srcid_c;
     3843                p_vci_ini_c.cons    = false;
     3844                p_vci_ini_c.wrap    = false;
     3845                p_vci_ini_c.contig  = false;
     3846                p_vci_ini_c.clen    = 0;
     3847                p_vci_ini_c.cfixed  = false;
     3848                p_vci_ini_c.eop     = true;
     3849
    25263850                break;
    2527 
    2528            case CLEANUP_DCACHE:
     3851                }
     3852
     3853           case CLEANUP_RSP_DCACHE:
    25293854                p_vci_ini_c.rspack  = true;
    25303855                p_vci_ini_c.cmdval  = false;
     
    25453870                break;
    25463871
    2547            case CLEANUP_ICACHE:
     3872           case CLEANUP_RSP_ICACHE:
    25483873                p_vci_ini_c.rspack  = true;
    25493874                p_vci_ini_c.cmdval  = false;
     
    25683893
    25693894        switch (r_vci_cmd_fsm.read() ) {
    2570 
    25713895            case CMD_IDLE:
     3896                {
    25723897                p_vci_ini_rw.cmdval  = false;
    25733898                p_vci_ini_rw.address = 0;
     
    25873912
    25883913                break;
    2589 
     3914                }
    25903915            case CMD_DATA_UNC:
     3916                {
    25913917                p_vci_ini_rw.cmdval = true;
    2592                 p_vci_ini_rw.address = (addr_40) r_dcache_addr_save.read() & ~0x3;
    2593                 switch( r_dcache_type_save ) {
     3918
     3919                addr_40 addr = (addr_40) r_dcache_addr_save[r_vci_cmd_num_cache].read() & ~0x3;
     3920                set_num_dcache(addr,r_vci_cmd_num_cache);
     3921
     3922                PRINTF("      * <CMD> DATA_UNC   : %d - %llx\n",(uint32_t)r_vci_cmd_num_cache,(uint64_t)(addr));
     3923
     3924                p_vci_ini_rw.address = addr;
     3925                switch( r_dcache_type_save[r_vci_cmd_num_cache] ) {
    25943926                    case iss_t::DATA_READ:
    25953927                        p_vci_ini_rw.wdata = 0;
    2596                         p_vci_ini_rw.be  = r_dcache_be_save.read();
     3928                        p_vci_ini_rw.be  = r_dcache_be_save[r_vci_cmd_num_cache].read();
    25973929                        p_vci_ini_rw.cmd = vci_param::CMD_READ;
    25983930                        break;
     
    26073939                p_vci_ini_rw.plen = 4;
    26083940                p_vci_ini_rw.trdid  = TYPE_DATA_UNC;   // data cache uncached read
    2609                 p_vci_ini_rw.pktid  = 0;
     3941                p_vci_ini_rw.pktid  = (sc_dt::sc_uint<vci_param::P>)r_vci_cmd_num_cache;
    26103942                p_vci_ini_rw.srcid  = m_srcid_rw;
    26113943                p_vci_ini_rw.cons   = false;
     
    26173949
    26183950                break;
    2619 
     3951                }
    26203952            case CMD_DATA_SC:
     3953                {
    26213954                p_vci_ini_rw.cmdval = true;
    2622                 p_vci_ini_rw.address = (addr_40) r_dcache_addr_save.read() & ~0x3;
     3955
     3956                addr_40 addr = (addr_40) r_dcache_addr_save[r_vci_cmd_num_cache].read() & ~0x3;
     3957                set_num_dcache(addr,r_vci_cmd_num_cache);
     3958
     3959                PRINTF("      * <CMD> DATA_SC    : %d - %llx\n",(uint32_t)r_vci_cmd_num_cache,(uint64_t)(addr));
     3960
     3961                p_vci_ini_rw.address = addr;
    26233962                if(r_vci_cmd_max.read() == 3){
    26243963                    ASSERT(false, "Not handled yet");
     
    26263965                    switch(r_vci_cmd_cpt.read()){
    26273966                        case 0:
    2628                             p_vci_ini_rw.wdata = (uint32_t)(r_dcache_ll_data.read() & 0xFFFFFFFF);
     3967                            p_vci_ini_rw.wdata = (uint32_t)(r_dcache_ll_data[r_vci_cmd_num_cache][r_dcache_num_cpu_save[r_vci_cmd_num_cache]].read() & 0xFFFFFFFF);
    26293968                            break;
    26303969                        case 1:
    2631                             p_vci_ini_rw.wdata = r_dcache_wdata_save.read();
     3970                            p_vci_ini_rw.wdata = r_dcache_wdata_save[r_vci_cmd_num_cache].read();
    26323971                            break;
    26333972                    }
     
    26373976                p_vci_ini_rw.plen   = 4*(r_vci_cmd_max.read()+1);
    26383977                p_vci_ini_rw.trdid  = TYPE_DATA_SC;   // data cache uncached read
    2639                 p_vci_ini_rw.pktid  = 0;
     3978                p_vci_ini_rw.pktid  = (sc_dt::sc_uint<vci_param::P>)r_vci_cmd_num_cache;
    26403979                p_vci_ini_rw.srcid  = m_srcid_rw;
    26413980                p_vci_ini_rw.cons   = true;
     
    26473986
    26483987                break;
    2649 
     3988                }
    26503989            case CMD_DATA_WRITE:
     3990                {
    26513991                p_vci_ini_rw.cmdval  = true;
    2652                 p_vci_ini_rw.address = r_wbuf.getAddress(r_vci_cmd_cpt)&~0x3;
    2653                 p_vci_ini_rw.wdata   = r_wbuf.getData(r_vci_cmd_cpt);
    2654                 p_vci_ini_rw.be      = r_wbuf.getBe(r_vci_cmd_cpt);
     3992
     3993                addr_40 addr       = (addr_40) r_wbuf[r_vci_cmd_num_cache]->getAddress(r_vci_cmd_cpt)&~0x3;
     3994
     3995                PRINTF("      * <CMD> DATA_WRITE : %d - %llx\n",(uint32_t)r_vci_cmd_num_cache,(uint64_t)(addr));
     3996
     3997                p_vci_ini_rw.address = addr;
     3998                p_vci_ini_rw.wdata   = r_wbuf[r_vci_cmd_num_cache]->getData(r_vci_cmd_cpt);
     3999                p_vci_ini_rw.be      = r_wbuf[r_vci_cmd_num_cache]->getBe(r_vci_cmd_cpt);
    26554000                p_vci_ini_rw.plen    = (r_vci_cmd_max - r_vci_cmd_min + 1)<<2;
    26564001                p_vci_ini_rw.cmd     = vci_param::CMD_WRITE;
    2657                 p_vci_ini_rw.trdid   = r_wbuf.getIndex() + (1<<(vci_param::T-1));
    2658                 p_vci_ini_rw.pktid   = 0;
     4002                p_vci_ini_rw.trdid   = r_wbuf[r_vci_cmd_num_cache]->getIndex() + (1<<(vci_param::T-1));
     4003                p_vci_ini_rw.pktid   = (sc_dt::sc_uint<vci_param::P>)r_vci_cmd_num_cache;
    26594004                p_vci_ini_rw.srcid   = m_srcid_rw;
    26604005                p_vci_ini_rw.cons    = false;
     
    26664011
    26674012                break;
    2668 
     4013                }
    26694014            case CMD_DATA_MISS:
     4015                {
    26704016                p_vci_ini_rw.cmdval = true;
    2671                 p_vci_ini_rw.address = r_dcache_addr_save.read() & (addr_40) m_dcache_yzmask;
     4017
     4018                addr_40 addr = r_dcache_addr_save[r_vci_cmd_num_cache].read() & (addr_40) m_dcache_yzmask;
     4019                set_num_dcache(addr,r_vci_cmd_num_cache);
     4020
     4021                PRINTF("      * <CMD> DATA_MISS  : %d - %llx\n",(uint32_t)r_vci_cmd_num_cache,(uint64_t)(addr));
     4022
     4023                p_vci_ini_rw.address = addr;
    26724024                p_vci_ini_rw.be     = 0xF;
    26734025                p_vci_ini_rw.plen   = m_dcache_words << 2;
    26744026                p_vci_ini_rw.cmd    = vci_param::CMD_READ;
    26754027                p_vci_ini_rw.trdid  = TYPE_DATA_MISS;   // data cache cached read
    2676                 p_vci_ini_rw.pktid  = 0;
     4028                p_vci_ini_rw.pktid  = (sc_dt::sc_uint<vci_param::P>)r_vci_cmd_num_cache;
    26774029                p_vci_ini_rw.srcid  = m_srcid_rw;
    26784030                p_vci_ini_rw.cons   = false;
     
    26844036
    26854037                break;
    2686 
     4038                }
    26874039            case CMD_INS_MISS:
     4040                {
    26884041                p_vci_ini_rw.cmdval = true;
    2689                 p_vci_ini_rw.address = r_icache_addr_save.read() & (addr_40) m_icache_yzmask;
     4042
     4043                addr_40 addr = r_icache_addr_save[r_vci_cmd_num_cache].read() & (addr_40) m_icache_yzmask;
     4044                set_num_icache(addr,r_vci_cmd_num_cache);
     4045
     4046                PRINTF("      * <CMD> INS_MISS   : %d - %llx\n",(uint32_t)r_vci_cmd_num_cache,(uint64_t)(addr));
     4047
     4048                p_vci_ini_rw.address = addr;
    26904049                p_vci_ini_rw.be     = 0xF;
    26914050                p_vci_ini_rw.plen   = m_icache_words << 2;
    26924051                p_vci_ini_rw.cmd    = vci_param::CMD_READ;
    26934052                p_vci_ini_rw.trdid  = TYPE_INS_MISS;   // ins cache cached read
    2694                 p_vci_ini_rw.pktid  = 0;
     4053                p_vci_ini_rw.pktid  = (sc_dt::sc_uint<vci_param::P>)r_vci_cmd_num_cache;
    26954054                p_vci_ini_rw.srcid  = m_srcid_rw;
    26964055                p_vci_ini_rw.cons   = false;
     
    27024061
    27034062                break;
    2704 
     4063                }
    27054064            case CMD_INS_UNC:
     4065                {
    27064066                p_vci_ini_rw.cmdval = true;
    2707                 p_vci_ini_rw.address = r_icache_addr_save.read() & ~0x3;
     4067
     4068                addr_40 addr = r_icache_addr_save[r_vci_cmd_num_cache].read() & ~0x3;
     4069                set_num_icache(addr,r_vci_cmd_num_cache);
     4070
     4071                PRINTF("      * <CMD> INS_UNC    : %d - %llx\n",(uint32_t)r_vci_cmd_num_cache,(uint64_t)(addr));
     4072
     4073                p_vci_ini_rw.address = addr;
    27084074                p_vci_ini_rw.be     = 0xF;
    27094075                p_vci_ini_rw.plen   = 4;
    27104076                p_vci_ini_rw.cmd    = vci_param::CMD_READ;
    27114077                p_vci_ini_rw.trdid  = TYPE_INS_UNC;   // ins cache uncached read
    2712                 p_vci_ini_rw.pktid  = 0;
     4078                p_vci_ini_rw.pktid  = (sc_dt::sc_uint<vci_param::P>)r_vci_cmd_num_cache;
    27134079                p_vci_ini_rw.srcid  = m_srcid_rw;
    27144080                p_vci_ini_rw.cons   = false;
     
    27204086
    27214087                break;
    2722 
     4088                }
    27234089        } // end switch r_vci_cmd_fsm
    27244090
    2725         bool ack;
    2726 
    2727         switch (r_vci_rsp_fsm.read() ) {
    2728         case RSP_IDLE       : ack = false; break;
    2729         case RSP_DATA_WRITE : ack = true; break;
    2730         case RSP_INS_MISS   :
    2731         case RSP_INS_UNC    : ack = CACHE_MISS_BUF_RSP_ACK(i); break;
    2732         case RSP_DATA_MISS  :
    2733         case RSP_DATA_UNC   :
    2734         case RSP_DATA_SC    : ack = CACHE_MISS_BUF_RSP_ACK(d); break;
    2735         } // end switch r_vci_cmd_fsm
    2736 
    2737         r_vci_rsp_ack       = ack;
    2738         p_vci_ini_rw.rspack = ack;
    2739        
     4091        {
     4092            bool ack;
     4093           
     4094            switch (r_vci_rsp_fsm.read() ) {
     4095            case RSP_DATA_WRITE : ack = true; break;
     4096            case RSP_INS_MISS   :
     4097            case RSP_INS_UNC    : ack = CACHE_MISS_BUF_RSP_ACK(i,r_vci_rsp_num_cache); break;
     4098            case RSP_DATA_MISS  :
     4099            case RSP_DATA_UNC   :
     4100            case RSP_DATA_SC    : ack = CACHE_MISS_BUF_RSP_ACK(d,r_vci_rsp_num_cache); break;
     4101               
     4102            case RSP_IDLE       :
     4103            default             : ack = false; break;
     4104               
     4105            } // end switch r_vci_cmd_fsm
     4106           
     4107            s_vci_rsp_ack       = ack;
     4108            p_vci_ini_rw.rspack = ack;
     4109
     4110            PRINTF("      * <RSP> rspack : %d\n", ack);
     4111        }
     4112
    27404113        // VCI_TGT
     4114
     4115        // PRINTF("      * <TGT> srcid : %d\n", r_tgt_srcid.read());
    27414116
    27424117        switch ( r_vci_tgt_fsm.read() ) {
     
    27504125
    27514126            case TGT_RSP_BROADCAST:
    2752                 p_vci_tgt.cmdack  = false;
    2753                 p_vci_tgt.rspval  = not r_tgt_icache_req.read() and not r_tgt_dcache_req.read() and ( r_tgt_icache_rsp | r_tgt_dcache_rsp );
    2754                 p_vci_tgt.rsrcid  = r_tgt_srcid.read();
    2755                 p_vci_tgt.rpktid  = r_tgt_pktid.read();
    2756                 p_vci_tgt.rtrdid  = r_tgt_trdid.read();
    2757                 p_vci_tgt.rdata   = 0;
    2758                 p_vci_tgt.rerror  = 0x2 & ( (1 << vci_param::E) - 1); // Write OK
    2759                 p_vci_tgt.reop    = true;
    2760                 break;
    2761 
     4127                {
     4128                    bool tgt_icache_req;
     4129                    bool tgt_icache_rsp;
     4130
     4131#if   (CC_XCACHE_WRAPPER_MULTI_CACHE==1)
     4132                    tgt_icache_req = r_tgt_icache_req[r_tgt_num_cache].read();
     4133                    tgt_icache_rsp = r_tgt_icache_rsp[r_tgt_num_cache].read();
     4134#elif (CC_XCACHE_WRAPPER_MULTI_CACHE==2)
     4135                    tgt_icache_req = false;
     4136                    tgt_icache_rsp = false;
     4137                    for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache)
     4138                    {
     4139                        tgt_icache_req |= r_tgt_icache_req[num_cache].read();
     4140                        tgt_icache_rsp |= r_tgt_icache_rsp[num_cache].read();
     4141                    }
     4142#endif
     4143
     4144                    bool rspval = ((not tgt_icache_req and not r_tgt_dcache_req[r_tgt_num_cache].read())
     4145                                   and (tgt_icache_rsp | r_tgt_dcache_rsp[r_tgt_num_cache]));
     4146
     4147                    PRINTF("      * <TGT> RSP_BROADCAST : rspval : %d (i %d %d, d %d %d)\n",rspval,tgt_icache_req,tgt_icache_rsp, r_tgt_dcache_req[r_tgt_num_cache].read(), r_tgt_dcache_rsp[r_tgt_num_cache].read());
     4148                   
     4149                    p_vci_tgt.cmdack  = false;
     4150                    p_vci_tgt.rspval  = rspval;
     4151                    p_vci_tgt.rsrcid  = r_tgt_srcid.read();
     4152                    p_vci_tgt.rpktid  = r_tgt_pktid.read();
     4153                    p_vci_tgt.rtrdid  = r_tgt_trdid.read();
     4154                    p_vci_tgt.rdata   = 0;
     4155                    p_vci_tgt.rerror  = 0x2 & ( (1 << vci_param::E) - 1); // Write OK
     4156                    p_vci_tgt.reop    = true;
     4157                    break;
     4158                }
    27624159            case TGT_RSP_ICACHE:
    2763                 p_vci_tgt.cmdack  = false;
    2764                 p_vci_tgt.rspval  = not r_tgt_icache_req.read() and r_tgt_icache_rsp.read();
    2765                 p_vci_tgt.rsrcid  = r_tgt_srcid.read();
    2766                 p_vci_tgt.rpktid  = r_tgt_pktid.read();
    2767                 p_vci_tgt.rtrdid  = r_tgt_trdid.read();
    2768                 p_vci_tgt.rdata   = 0;
    2769                 p_vci_tgt.rerror  = 0x2 & ( (1 << vci_param::E) - 1); // Write OK
    2770                 p_vci_tgt.reop    = true;
    2771                 break;
    2772 
     4160                {
     4161                    bool rspval = not r_tgt_icache_req[r_tgt_num_cache].read() and r_tgt_icache_rsp[r_tgt_num_cache].read();
     4162
     4163                    PRINTF("      * <TGT> RSP_ICACHE : rspval : %d\n",rspval);
     4164
     4165                    p_vci_tgt.cmdack  = false;
     4166                    p_vci_tgt.rspval  = rspval;
     4167                    p_vci_tgt.rsrcid  = r_tgt_srcid.read();
     4168                    p_vci_tgt.rpktid  = r_tgt_pktid.read();
     4169                    p_vci_tgt.rtrdid  = r_tgt_trdid.read();
     4170                    p_vci_tgt.rdata   = 0;
     4171                    p_vci_tgt.rerror  = 0x2 & ( (1 << vci_param::E) - 1); // Write OK
     4172                    p_vci_tgt.reop    = true;
     4173                    break;
     4174                }
    27734175            case TGT_RSP_DCACHE:
    2774                 p_vci_tgt.cmdack  = false;
    2775                 p_vci_tgt.rspval  = not r_tgt_dcache_req.read() and r_tgt_dcache_rsp.read();
    2776                 p_vci_tgt.rsrcid  = r_tgt_srcid.read();
    2777                 p_vci_tgt.rpktid  = r_tgt_pktid.read();
    2778                 p_vci_tgt.rtrdid  = r_tgt_trdid.read();
    2779                 p_vci_tgt.rdata   = 0;
    2780                 p_vci_tgt.rerror  = 0x2 & ( (1 << vci_param::E) - 1); // Write OK
    2781                 p_vci_tgt.reop    = true;
    2782                 break;
    2783 
     4176                {
     4177                    bool rspval = not r_tgt_dcache_req[r_tgt_num_cache].read() and r_tgt_dcache_rsp[r_tgt_num_cache].read();
     4178
     4179                    PRINTF("      * <TGT> RSP_DCACHE : rspval : %d\n",rspval);
     4180                   
     4181                    p_vci_tgt.cmdack  = false;
     4182                    p_vci_tgt.rspval  = rspval;
     4183                    p_vci_tgt.rsrcid  = r_tgt_srcid.read();
     4184                    p_vci_tgt.rpktid  = r_tgt_pktid.read();
     4185                    p_vci_tgt.rtrdid  = r_tgt_trdid.read();
     4186                    p_vci_tgt.rdata   = 0;
     4187                    p_vci_tgt.rerror  = 0x2 & ( (1 << vci_param::E) - 1); // Write OK
     4188                    p_vci_tgt.reop    = true;
     4189                    break;
     4190                }
    27844191            case TGT_REQ_BROADCAST:
    27854192            case TGT_REQ_ICACHE:
     
    28144221    }
    28154222
     4223    //////////////////////////////////////////////////////////////////////////////////
     4224    tmpl(uint32_t)::get_num_cache(addr_40 & addr)
     4225    //////////////////////////////////////////////////////////////////////////////////
     4226    {
     4227        uint32_t num_cache = get_num_cache_only(addr);
     4228
     4229        addr = ((addr&m_num_cache_LSB_mask) | // keep LSB
     4230                ((addr>>m_num_cache_MSB)<<m_num_cache_LSB)); // set MSB
     4231
     4232        return num_cache;
     4233    }
     4234
     4235    //////////////////////////////////////////////////////////////////////////////////
     4236    tmpl(uint32_t)::get_num_cache_only(addr_40 addr)
     4237    //////////////////////////////////////////////////////////////////////////////////
     4238    {
     4239        return (addr>>m_num_cache_LSB)&m_num_cache_mask;
     4240    }
     4241
     4242    //////////////////////////////////////////////////////////////////////////////////
     4243    tmpl(void)::set_num_cache(addr_40 & addr, uint32_t num_cache)
     4244    //////////////////////////////////////////////////////////////////////////////////
     4245    {
     4246        addr = ((addr&m_num_cache_LSB_mask) | // keep LSB
     4247                ((addr_40)num_cache << m_num_cache_LSB) |
     4248                ((addr>>m_num_cache_LSB)<<m_num_cache_MSB)); // set MSB
     4249    }
     4250
     4251    //////////////////////////////////////////////////////////////////////////////////
     4252    // fixme : mettre le type addr_40
     4253    tmpl(sc_dt::sc_uint<40>)::set_num_cache_only(addr_40 addr, uint32_t num_cache)
     4254    //////////////////////////////////////////////////////////////////////////////////
     4255    {
     4256        return ((addr&m_num_cache_LSB_mask) | // keep LSB
     4257                ((addr_40)num_cache << m_num_cache_LSB) |
     4258                ((addr>>m_num_cache_LSB)<<m_num_cache_MSB)); // set MSB
     4259    }
     4260
     4261
    28164262}} // end namespace
    28174263
  • trunk/modules/vci_mem_cache_v4/caba/source/include/mem_cache_directory_v4.h

    r57 r140  
    66#include <cassert>
    77#include "arithmetics.h"
     8
     9#define L1_MULTI_CACHE      1
    810
    911namespace soclib { namespace caba {
     
    3739      bool      inst;       // Is the owner an ICache ?
    3840      size_t    srcid;      // The SRCID of the owner
     41#if L1_MULTI_CACHE
     42      size_t    cache_id;   // In multi_cache configuration
     43#endif
    3944
    4045    ////////////////////////
    4146    // Constructors
    4247    ////////////////////////
    43       Owner(bool i_inst,size_t i_srcid){
     48      Owner(bool   i_inst
     49            ,size_t i_srcid
     50#if L1_MULTI_CACHE
     51            ,size_t i_cache_id
     52#endif
     53            ){
    4454        inst    = i_inst;
    4555        srcid   = i_srcid;
     56#if L1_MULTI_CACHE
     57        cache_id= i_cache_id;
     58#endif
    4659      }
    4760
     
    4962        inst    = a.inst;
    5063        srcid   = a.srcid;
     64#if L1_MULTI_CACHE
     65        cache_id= a.cache_id;
     66#endif
    5167      }
    5268
     
    5470        inst    = false;
    5571        srcid   = 0;
     72#if L1_MULTI_CACHE
     73        cache_id= 0;
     74#endif
    5675      }
    5776      // end constructors
     
    89108      owner.inst    = 0;
    90109      owner.srcid   = 0;
     110#if L1_MULTI_CACHE
     111      owner.cache_id= 0;
     112#endif
    91113      ptr           = 0;
    92114    }
     
    137159    {
    138160      std::cout << "Valid = " << valid << " ; IS COUNT = " << is_cnt << " ; Dirty = " << dirty << " ; Lock = "
    139         << lock << " ; Tag = " << std::hex << tag << std::dec << " ; Count = " << count << " ; Owner = " << owner.srcid << " " << owner.inst << " ; Pointer = " << ptr << std::endl;
     161                << lock
     162                << " ; Tag = " << std::hex << tag << std::dec
     163                << " ; Count = " << count
     164                << " ; Owner = " << owner.srcid
     165#if L1_MULTI_CACHE
     166                << "." << owner.cache_id
     167#endif
     168                << " " << owner.inst
     169                << " ; Pointer = " << ptr << std::endl;
    140170    }
    141171
     
    346376    ////////////////////////
    347377      HeapEntry()
    348       :owner(false,0)
     378      :owner(false,0
     379#if L1_MULTI_CACHE
     380             ,0
     381#endif
     382             )
    349383      {
    350384        next = 0;
     
    355389    ////////////////////////
    356390      HeapEntry(const HeapEntry &entry){
     391        owner.inst  = entry.owner.inst;
    357392        owner.srcid = entry.owner.srcid;
    358         owner.inst  = entry.owner.inst;
    359         next        = entry.next;
     393#if L1_MULTI_CACHE
     394        owner.cache_id = entry.owner.cache_id;
     395#endif       
     396        next           = entry.next;
    360397      } // end constructor
    361398
     
    364401    /////////////////////////////////////////////////////////////////////
    365402      void copy(const HeapEntry &entry){
    366         owner.srcid = entry.owner.srcid;
    367         owner.inst  = entry.owner.inst;
    368         next        = entry.next;
     403        owner.inst     = entry.owner.inst;
     404        owner.srcid    = entry.owner.srcid;
     405#if L1_MULTI_CACHE
     406        owner.cache_id = entry.owner.cache_id;
     407#endif
     408        next           = entry.next;
    369409      } // end copy()
    370410
     
    374414      void print(){
    375415        std::cout
    376         << " -- owner.srcid : " << std::dec << owner.srcid << std::endl
    377         << " -- owner.inst  : " << std::dec << owner.inst << std::endl
    378         << " -- next        : " << std::dec << next << std::endl;
     416        << " -- owner.inst     : " << std::dec << owner.inst << std::endl
     417        << " -- owner.srcid    : " << std::dec << owner.srcid << std::endl
     418#if L1_MULTI_CACHE
     419        << " -- owner.cache_id : " << std::dec << owner.cache_id << std::endl
     420#endif
     421        << " -- next           : " << std::dec << next << std::endl;
    379422
    380423      } // end print()
  • trunk/modules/vci_mem_cache_v4/caba/source/include/vci_mem_cache_v4.h

    r138 r140  
    405405      sc_signal<int>         r_read_fsm;        // FSM state
    406406      sc_signal<size_t>      r_read_copy;       // Srcid of the first copy
     407      sc_signal<size_t>      r_read_copy_cache; // Srcid of the first copy
    407408      sc_signal<bool>        r_read_copy_inst;  // Type of the first copy
    408409      sc_signal<tag_t>       r_read_tag;            // cache line tag (in directory)
     
    450451      sc_signal<tag_t>     r_write_tag;             // cache line tag (in directory)
    451452      sc_signal<size_t>    r_write_copy;            // first owner of the line
     453      sc_signal<size_t>    r_write_copy_cache;      // first owner of the line
    452454      sc_signal<bool>      r_write_copy_inst;       // is this owner a ICache ?
    453455      sc_signal<size_t>    r_write_count;           // number of copies
     
    483485      GenericFifo<bool>    m_write_to_init_cmd_inst_fifo;   // fifo for the L1 type
    484486      GenericFifo<size_t>  m_write_to_init_cmd_srcid_fifo;  // fifo for srcids
     487      GenericFifo<size_t>  m_write_to_init_cmd_cache_id_fifo;  // fifo for srcids
    485488
    486489      // Buffer between WRITE fsm and INIT_RSP fsm (Decrement UPT entry)
     
    516519
    517520      sc_signal<copy_t>      r_cleanup_copy;        // first copy
     521      sc_signal<copy_t>      r_cleanup_copy_cache;  // first copy
    518522      sc_signal<size_t>      r_cleanup_copy_inst;   // type of the first copy
    519523      sc_signal<copy_t>      r_cleanup_count;       // number of copies
     
    521525      sc_signal<size_t>      r_cleanup_prev_ptr;    // previous pointer to the heap
    522526      sc_signal<size_t>      r_cleanup_prev_srcid;  // srcid of previous heap entry
     527      sc_signal<size_t>      r_cleanup_prev_cache_id;  // srcid of previous heap entry
    523528      sc_signal<bool>        r_cleanup_prev_inst;   // inst bit of previous heap entry
    524529      sc_signal<size_t>      r_cleanup_next_ptr;    // next pointer to the heap
     
    552557      sc_signal<size_t>    r_llsc_cpt;              // size of command
    553558      sc_signal<copy_t>    r_llsc_copy;             // Srcid of the first copy
     559      sc_signal<copy_t>    r_llsc_copy_cache;   // Srcid of the first copy
    554560      sc_signal<bool>      r_llsc_copy_inst;    // Type of the first copy
    555561      sc_signal<size_t>    r_llsc_count;            // number of copies
     
    590596      GenericFifo<bool>    m_llsc_to_init_cmd_inst_fifo;    // fifo for the L1 type
    591597      GenericFifo<size_t>  m_llsc_to_init_cmd_srcid_fifo;   // fifo for srcids
     598      GenericFifo<size_t>  m_llsc_to_init_cmd_cache_id_fifo;// fifo for srcids
    592599
    593600      // Buffer between LLSC fsm and INIT_RSP fsm (Decrement UPT entry)
     
    620627      sc_signal<addr_t>    r_xram_rsp_victim_nline;     // victim line index
    621628      sc_signal<copy_t>    r_xram_rsp_victim_copy;      // victim line first copy
     629      sc_signal<copy_t>    r_xram_rsp_victim_copy_cache;// victim line first copy
    622630      sc_signal<bool>      r_xram_rsp_victim_copy_inst; // victim line type of first copy
    623631      sc_signal<size_t>    r_xram_rsp_victim_count;         // victim line number of copies
     
    644652      GenericFifo<bool>     m_xram_rsp_to_init_cmd_inst_fifo;       // fifo for the L1 type
    645653      GenericFifo<size_t>   m_xram_rsp_to_init_cmd_srcid_fifo;      // fifo for srcids
     654      GenericFifo<size_t>   m_xram_rsp_to_init_cmd_cache_id_fifo;      // fifo for srcids
    646655
    647656      // Buffer between XRAM_RSP fsm and IXR_CMD fsm (XRAM write)
  • trunk/modules/vci_mem_cache_v4/caba/source/src/vci_mem_cache_v4.cpp

    r138 r140  
    2929#include "../include/vci_mem_cache_v4.h"
    3030
    31 //#define TDEBUG // Transaction tab debug
    32 //#define IDEBUG // Update tab debug
    33 //#define DDEBUG // Directory debug
    34 //#define LOCK_DEBUG // Lock debug
     31// #define TDEBUG // Transaction tab debug
     32// #define IDEBUG // Update tab debug
     33// #define DDEBUG // Directory debug
     34// #define LOCK_DEBUG // Lock debug
     35
    3536#define DEBUG_VCI_MEM_CACHE 0
    36 #define DEBUG_START_CYCLE   200000
     37#define DEBUG_START_CYCLE   949900
    3738#define RANDOMIZE_SC
    3839
     40#define ASSERT_VERBOSE
     41#define ASSERT_NCYCLES m_cpt_cycles
     42
     43#include "debug.h"
     44
    3945#if DEBUG_VCI_MEM_CACHE
    40 # define PRINTF(msg...) do { if (m_cpt_cycles > DEBUG_START_CYCLE) printf(msg); } while (0);
     46# define PRINTF(msg...) PRINTF_COND(m_cpt_cycles > DEBUG_START_CYCLE,msg)
    4147#else
    4248# define PRINTF(msg...)
     
    301307    m_write_to_init_cmd_inst_fifo("m_write_to_init_cmd_inst_fifo",8),
    302308    m_write_to_init_cmd_srcid_fifo("m_write_to_init_cmd_srcid_fifo",8),
     309#if L1_MULTI_CACHE
     310    m_write_to_init_cmd_cache_id_fifo("m_write_to_init_cmd_cache_id_fifo",8),
     311#endif
    303312    r_init_rsp_fsm("r_init_rsp_fsm"),
    304313    r_cleanup_fsm("r_cleanup_fsm"),
     
    306315    m_llsc_to_init_cmd_inst_fifo("m_llsc_to_init_cmd_inst_fifo",8),
    307316    m_llsc_to_init_cmd_srcid_fifo("m_llsc_to_init_cmd_srcid_fifo",8),
     317#if L1_MULTI_CACHE
     318    m_llsc_to_init_cmd_cache_id_fifo("m_llsc_to_init_cmd_cache_id_fifo",8),
     319#endif
    308320    r_ixr_rsp_fsm("r_ixr_rsp_fsm"),
    309321    r_xram_rsp_fsm("r_xram_rsp_fsm"),
    310322    m_xram_rsp_to_init_cmd_inst_fifo("m_xram_rsp_to_init_cmd_inst_fifo",8),
    311323    m_xram_rsp_to_init_cmd_srcid_fifo("m_xram_rsp_to_init_cmd_srcid_fifo",8),
     324#if L1_MULTI_CACHE
     325    m_xram_rsp_to_init_cmd_cache_id_fifo("m_xram_rsp_to_init_cmd_cache_id_fifo",8),
     326#endif
    312327    r_ixr_cmd_fsm("r_ixr_cmd_fsm"),
    313328    r_tgt_rsp_fsm("r_tgt_rsp_fsm"),
     
    532547      m_write_to_init_cmd_inst_fifo.init();
    533548      m_write_to_init_cmd_srcid_fifo.init();
     549#if L1_MULTI_CACHE
     550      m_write_to_init_cmd_cache_id_fifo.init();
     551#endif
    534552
    535553      r_cleanup_to_tgt_rsp_req  = false;
     
    545563      m_llsc_to_init_cmd_inst_fifo.init();
    546564      m_llsc_to_init_cmd_srcid_fifo.init();
     565#if L1_MULTI_CACHE
     566      m_llsc_to_init_cmd_cache_id_fifo.init();
     567#endif
    547568
    548569      for(size_t i=0; i<TRANSACTION_TAB_LINES ; i++){
     
    557578      m_xram_rsp_to_init_cmd_inst_fifo.init();
    558579      m_xram_rsp_to_init_cmd_srcid_fifo.init();
     580#if L1_MULTI_CACHE
     581      m_xram_rsp_to_init_cmd_cache_id_fifo.init();
     582#endif
    559583
    560584      r_ixr_cmd_cpt         = 0;
     
    591615    bool    cmd_llsc_fifo_get = false;
    592616
    593     bool    write_to_init_cmd_fifo_put   = false;
    594     bool    write_to_init_cmd_fifo_get   = false;
    595     bool    write_to_init_cmd_fifo_inst  = false;
    596     size_t  write_to_init_cmd_fifo_srcid = 0;
    597 
    598     bool    xram_rsp_to_init_cmd_fifo_put   = false;
    599     bool    xram_rsp_to_init_cmd_fifo_get   = false;
    600     bool    xram_rsp_to_init_cmd_fifo_inst  = false;
    601     size_t  xram_rsp_to_init_cmd_fifo_srcid = 0;
    602 
    603     bool    llsc_to_init_cmd_fifo_put   = false;
    604     bool    llsc_to_init_cmd_fifo_get   = false;
    605     bool    llsc_to_init_cmd_fifo_inst  = false;
    606     size_t  llsc_to_init_cmd_fifo_srcid = 0;
     617    bool    write_to_init_cmd_fifo_put      = false;
     618    bool    write_to_init_cmd_fifo_get      = false;
     619    bool    write_to_init_cmd_fifo_inst     = false;
     620    size_t  write_to_init_cmd_fifo_srcid    = 0;
     621#if L1_MULTI_CACHE
     622    size_t  write_to_init_cmd_fifo_cache_id = 0;
     623#endif
     624
     625    bool    xram_rsp_to_init_cmd_fifo_put      = false;
     626    bool    xram_rsp_to_init_cmd_fifo_get      = false;
     627    bool    xram_rsp_to_init_cmd_fifo_inst     = false;
     628    size_t  xram_rsp_to_init_cmd_fifo_srcid    = 0;
     629#if L1_MULTI_CACHE
     630    size_t  xram_rsp_to_init_cmd_fifo_cache_id = 0;
     631#endif
     632
     633    bool    llsc_to_init_cmd_fifo_put      = false;
     634    bool    llsc_to_init_cmd_fifo_get      = false;
     635    bool    llsc_to_init_cmd_fifo_inst     = false;
     636    size_t  llsc_to_init_cmd_fifo_srcid    = 0;
     637#if L1_MULTI_CACHE
     638    size_t  llsc_to_init_cmd_fifo_cache_id = 0;
     639#endif
    607640
    608641#if DEBUG_VCI_MEM_CACHE
     
    628661#endif
    629662
     663#ifdef IDEBUG
     664if(m_cpt_cycles > DEBUG_START_CYCLE){
     665        std::cout << sc_time_stamp() << " " << name() << " INIT_RSP_UPT_LOCK update table : " << std::endl;
     666        m_update_tab.print();
     667}
     668#endif
     669
    630670    ////////////////////////////////////////////////////////////////////////////////////
    631671    //          TGT_CMD FSM
     
    651691          if ( p_vci_tgt.cmdval ) {
    652692
    653               PRINTF("  * <TGT> Request from %d at address %llx\n",(uint32_t)p_vci_tgt.srcid.read(),(uint64_t)p_vci_tgt.address.read());
     693              PRINTF("  * <MEM_CACHE.TGT> Request from %d.%d (%d) at address %llx\n",(uint32_t)p_vci_tgt.srcid.read(),(uint32_t)p_vci_tgt.pktid.read(),(uint32_t)p_vci_tgt.trdid.read(),(uint64_t)p_vci_tgt.address.read());
    654694
    655695            if ( p_vci_tgt.cmd.read() == vci_param::CMD_READ )
     
    676716
    677717        {
    678           assert(((m_x[(vci_addr_t)p_vci_tgt.address.read()]+(p_vci_tgt.plen.read()>>2))<=16)
    679               && "VCI_MEM_CACHE All read request to the MemCache must stay within a cache line");
     718            ASSERT(((m_x[(vci_addr_t)p_vci_tgt.address.read()]+(p_vci_tgt.plen.read()>>2))<=16),
     719                  "VCI_MEM_CACHE All read request to the MemCache must stay within a cache line");
    680720
    681721          if ( p_vci_tgt.cmdval && m_cmd_read_addr_fifo.wok() ) {
     
    744784
    745785          if ( p_vci_ini.rspval ) {
    746 
    747             assert ( ( p_vci_ini.rtrdid.read() < m_update_tab.size() )
    748                 && "VCI_MEM_CACHE UPT index too large in VCI response paquet received by memory cache" );
    749             assert ( p_vci_ini.reop
    750                 && "VCI_MEM_CACHE All response packets to update/invalidate requests must be one cell" );
     786            PRINTF("  * <MEM_CACHE.INIT_RSP> rsp val - trdid %d\n",(uint32_t)p_vci_ini.rtrdid.read());
     787
     788            ASSERT (( p_vci_ini.rtrdid.read() < m_update_tab.size())
     789                    ,"VCI_MEM_CACHE UPT index too large in VCI response paquet received by memory cache" );
     790            ASSERT (p_vci_ini.reop
     791                    ,"VCI_MEM_CACHE All response packets to update/invalidate requests must be one cell") ;
    751792            r_init_rsp_upt_index = p_vci_ini.rtrdid.read();
    752793            r_init_rsp_fsm = INIT_RSP_UPT_LOCK;
     
    772813#endif
    773814            while(!valid);
    774             assert ( valid
    775                 && "VCI_MEM_CACHE Invalid UPT entry in VCI response paquet received by memory cache" );
     815            ASSERT ( valid
     816                     ,"VCI_MEM_CACHE Invalid UPT entry in VCI response paquet received by memory cache" );
    776817
    777818            if ( count == 0 ) r_init_rsp_fsm = INIT_RSP_UPT_CLEAR;
     
    830871    ////////////////////////////////////////////////////////////////////////////////////
    831872
    832     PRINTF("  * TOP : Request from %d at address %llx\n",(uint32_t)m_cmd_read_srcid_fifo.read(),(uint64_t)m_cmd_read_addr_fifo.read());
     873    PRINTF("  * <MEM_CACHE.TOP> Request from %d.%d at address %llx\n",(uint32_t)m_cmd_read_srcid_fifo.read(),(uint32_t)m_cmd_read_pktid_fifo.read(),(uint64_t)m_cmd_read_addr_fifo.read());
    833874
    834875    switch ( r_read_fsm.read() ) {
     
    838879        {
    839880          if (m_cmd_read_addr_fifo.rok()) {
    840             PRINTF("  * <READ> Request from %d at address %llx\n",(uint32_t)m_cmd_read_srcid_fifo.read(),(uint64_t)m_cmd_read_addr_fifo.read());
     881            PRINTF("  * <MEM_CACHE.READ> Request from %d.%d at address %llx\n",(uint32_t)m_cmd_read_srcid_fifo.read(),(uint32_t)m_cmd_read_pktid_fifo.read(),(uint64_t)m_cmd_read_addr_fifo.read());
    841882
    842883            m_cpt_read++;
     
    858899}
    859900#endif
    860             r_read_is_cnt   = entry.is_cnt;
    861             r_read_dirty    = entry.dirty;
    862             r_read_lock     = entry.lock;
    863             r_read_tag      = entry.tag;
    864             r_read_way      = way;
    865             r_read_count    = entry.count;
    866             r_read_copy     = entry.owner.srcid;
    867             r_read_copy_inst= entry.owner.inst;
    868             r_read_ptr      = entry.ptr;
     901            r_read_is_cnt     = entry.is_cnt;
     902            r_read_dirty      = entry.dirty;
     903            r_read_lock       = entry.lock;
     904            r_read_tag        = entry.tag;
     905            r_read_way        = way;
     906            r_read_count      = entry.count;
     907            r_read_copy       = entry.owner.srcid;
     908#if L1_MULTI_CACHE
     909            r_read_copy_cache = entry.owner.cache_id;
     910#endif
     911            r_read_copy_inst  = entry.owner.inst;
     912            r_read_ptr        = entry.ptr;
    869913
    870914            bool cached_read = (m_cmd_read_trdid_fifo.read() & 0x1);
     
    910954              if(!is_cnt){ // Not counter mode
    911955                entry.owner.srcid   = m_cmd_read_srcid_fifo.read();
     956#if L1_MULTI_CACHE
     957                entry.owner.cache_id= m_cmd_read_pktid_fifo.read();
     958#endif
     959
    912960                entry.owner.inst    = inst_read;
    913961                entry.count         = r_read_count.read() + 1;
    914962              } else { // Counter mode
    915963                entry.owner.srcid   = 0;
     964#if L1_MULTI_CACHE
     965                entry.owner.cache_id= 0;
     966#endif
    916967                entry.owner.inst    = false;
    917968                entry.count         = r_read_count.read() + 1;
     
    919970            } else { // Uncached read
    920971              entry.owner.srcid     = r_read_copy.read();
     972#if L1_MULTI_CACHE
     973              entry.owner.cache_id  = r_read_copy_cache.read();
     974#endif
     975
    921976              entry.owner.inst      = r_read_copy_inst.read();
    922977              entry.count           = r_read_count.read();
     
    9561011            if(!is_cnt){ // Not counter mode
    9571012                entry.owner.srcid   = r_read_copy.read();
     1013#if L1_MULTI_CACHE
     1014                entry.owner.cache_id= r_read_copy_cache.read();
     1015#endif
    9581016                entry.owner.inst    = r_read_copy_inst.read();
    9591017                entry.count         = r_read_count.read() + 1;
     
    9611019            } else { // Counter mode
    9621020                entry.owner.srcid   = 0;
     1021#if L1_MULTI_CACHE
     1022                entry.owner.cache_id= 0;
     1023#endif
    9631024                entry.owner.inst    = false;
    9641025                entry.count         = r_read_count.read() + 1;
     
    10081069            bool inst_read = (m_cmd_read_trdid_fifo.read() & 0x2);
    10091070            HeapEntry new_heap_entry;
    1010             new_heap_entry.owner.srcid  = m_cmd_read_srcid_fifo.read();
    1011             new_heap_entry.owner.inst   = inst_read;
     1071            new_heap_entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
     1072#if L1_MULTI_CACHE
     1073            new_heap_entry.owner.cache_id = m_cmd_read_pktid_fifo.read();
     1074#endif
     1075            new_heap_entry.owner.inst     = inst_read;
    10121076            if(r_read_count.read() == 1){ // creation of a new list
    10131077              new_heap_entry.next         = m_heap_directory.next_free_ptr();
     
    10231087            r_read_fsm = READ_RSP;
    10241088          } else {
    1025             assert(false && "MEMCACHE Error : Bad HEAP allocation");
     1089              ASSERT(false,"MEMCACHE Error : Bad HEAP allocation");
    10261090          }
    10271091          break;
     
    10391103            }
    10401104          } else {
    1041             assert(false && "MEMCACHE Error : Bad HEAP allocation");
     1105              ASSERT(false,"MEMCACHE Error : Bad HEAP allocation");
    10421106          }
    10431107          break;
     
    10481112          if(r_alloc_heap_fsm.read() == ALLOC_HEAP_READ){
    10491113            HeapEntry last_entry;
    1050             last_entry.owner.srcid = 0;
    1051             last_entry.owner.inst  = false;
     1114            last_entry.owner.srcid    = 0;
     1115#if L1_MULTI_CACHE
     1116            last_entry.owner.cache_id = 0;
     1117#endif
     1118            last_entry.owner.inst     = false;
    10521119            if(m_heap_directory.is_full()){
    10531120              last_entry.next      = r_read_ptr.read();
     
    10591126            r_read_fsm = READ_RSP;
    10601127          } else {
    1061             assert(false && "MEMCACHE Error : Bad HEAP allocation");
     1128              ASSERT(false,"MEMCACHE Error : Bad HEAP allocation");
    10621129          }
    10631130          break;
     
    11071174        {
    11081175          if ( r_alloc_trt_fsm.read() == ALLOC_TRT_READ ) {
    1109             m_transaction_tab.set(r_read_trt_index.read(),
     1176              m_transaction_tab.set(r_read_trt_index.read(),
    11101177                true,
    11111178                m_nline[(vci_addr_t)(m_cmd_read_addr_fifo.read())],
     
    11781245        {
    11791246          if ( m_cmd_write_addr_fifo.rok()) {
     1247              PRINTF("  * <MEM_CACHE.WRITE> KANE Request from %d.%d (%d) at address %llx\n",(uint32_t)m_cmd_write_srcid_fifo.read(),(uint32_t)m_cmd_write_pktid_fifo.read(),(uint32_t) m_cmd_write_trdid_fifo.read(), (uint64_t)m_cmd_write_addr_fifo.read());
     1248
    11801249            m_cpt_write++;
    11811250            m_cpt_write_cells++;
     
    12121281
    12131282            // check that the next word is in the same cache line
    1214             assert( (m_nline[(vci_addr_t)(r_write_address.read())] == m_nline[(vci_addr_t)(m_cmd_write_addr_fifo.read())]) 
    1215                 && "VCI_MEM_CACHE write error in vci_mem_cache : write burst over a line" );
     1283            ASSERT( (m_nline[(vci_addr_t)(r_write_address.read())] == m_nline[(vci_addr_t)(m_cmd_write_addr_fifo.read())]) 
     1284                    ,"VCI_MEM_CACHE write error in vci_mem_cache : write burst over a line" );
    12161285            // consume a word in the FIFO & write it in the local buffer
    12171286            cmd_write_fifo_get=true;
     
    12391308              r_write_tag       = entry.tag;
    12401309              r_write_copy      = entry.owner.srcid;
     1310#if L1_MULTI_CACHE
     1311              r_write_copy_cache= entry.owner.cache_id;
     1312#endif
    12411313              r_write_copy_inst = entry.owner.inst;
    12421314              r_write_count     = entry.count;
     
    12871359          // update directory with Dirty bit
    12881360          DirectoryEntry entry;
    1289           entry.valid       = true;
    1290           entry.dirty       = true;
    1291           entry.tag             = r_write_tag.read();
    1292           entry.is_cnt      = r_write_is_cnt.read();
    1293           entry.lock        = r_write_lock.read();
    1294           entry.owner.srcid = r_write_copy.read();
    1295           entry.owner.inst  = r_write_copy_inst.read();
    1296           entry.count       = r_write_count.read();
    1297           entry.ptr         = r_write_ptr.read();
    1298           size_t set        = m_y[(vci_addr_t)(r_write_address.read())];
    1299           size_t way        = r_write_way.read();
     1361          entry.valid         = true;
     1362          entry.dirty         = true;
     1363          entry.tag               = r_write_tag.read();
     1364          entry.is_cnt        = r_write_is_cnt.read();
     1365          entry.lock          = r_write_lock.read();
     1366          entry.owner.srcid   = r_write_copy.read();
     1367#if L1_MULTI_CACHE
     1368          entry.owner.cache_id= r_write_copy_cache.read();
     1369#endif
     1370          entry.owner.inst    = r_write_copy_inst.read();
     1371          entry.count         = r_write_count.read();
     1372          entry.ptr           = r_write_ptr.read();
     1373          size_t set          = m_y[(vci_addr_t)(r_write_address.read())];
     1374          size_t way          = r_write_way.read();
    13001375          m_cache_directory.write(set, way, entry);
    13011376
    1302           bool owner = (r_write_copy.read()==r_write_srcid.read()) && !r_write_copy_inst.read();
     1377          bool owner = (((r_write_copy.read()==r_write_srcid.read())
     1378#if L1_MULTI_CACHE
     1379                         and (r_write_copy_cache.read()==r_write_pktid.read())
     1380#endif
     1381                         ) and not r_write_copy_inst.read());
     1382
    13031383          bool no_update = (r_write_count.read()==0) || ( owner && (r_write_count.read()==1));
    13041384
     
    13871467      case WRITE_UPT_REQ:
    13881468        {
    1389           assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE) &&
    1390                     "MemCache ERROR : bad HEAP allocation");
     1469          ASSERT( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE)
     1470                  ,"MemCache ERROR : bad HEAP allocation");
    13911471          if( !r_write_to_init_cmd_multi_req.read() &&
    13921472              !r_write_to_init_cmd_brdcast_req.read()  ){
     
    14071487            }
    14081488           
    1409             if( (r_write_copy.read() != r_write_srcid.read()) || r_write_copy_inst.read() ) {
     1489            if((r_write_copy.read() != r_write_srcid.read()) or
     1490#if L1_MULTI_CACHE
     1491               (r_write_copy_cache.read() != r_write_pktid.read()) or
     1492#endif
     1493               r_write_copy_inst.read() ) {
    14101494              // We put the first copy in the fifo
    14111495              write_to_init_cmd_fifo_put     = true;
    14121496              write_to_init_cmd_fifo_inst    = r_write_copy_inst.read();
    14131497              write_to_init_cmd_fifo_srcid   = r_write_copy.read();
     1498#if L1_MULTI_CACHE
     1499              write_to_init_cmd_fifo_cache_id= r_write_copy_cache.read();
     1500#endif
    14141501              if(r_write_count.read() == 1){
    14151502                r_write_fsm = WRITE_IDLE;
     
    14271514      case WRITE_UPDATE:        // send a multi-update request to INIT_CMD fsm
    14281515        {
    1429           assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE) &&
    1430                     "MemCache ERROR : bad HEAP allocation");
     1516          ASSERT( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE)
     1517                  ,"MemCache ERROR : bad HEAP allocation");
    14311518          HeapEntry entry = m_heap_directory.read(r_write_ptr.read());
    1432           write_to_init_cmd_fifo_inst  = entry.owner.inst;
    1433           write_to_init_cmd_fifo_srcid = entry.owner.srcid;
     1519          write_to_init_cmd_fifo_inst     = entry.owner.inst;
     1520          write_to_init_cmd_fifo_srcid    = entry.owner.srcid;
     1521#if L1_MULTI_CACHE
     1522          write_to_init_cmd_fifo_cache_id = entry.owner.cache_id;
     1523#endif
     1524         
    14341525          bool dec_upt_counter = r_write_to_dec.read();
    1435           if( (entry.owner.srcid != r_write_srcid.read()) || entry.owner.inst ){
     1526          if( (entry.owner.srcid != r_write_srcid.read()) or
     1527#if L1_MULTI_CACHE
     1528              (entry.owner.cache_id != r_write_pktid.read()) or
     1529#endif
     1530              entry.owner.inst){
    14361531            write_to_init_cmd_fifo_put = true;
    14371532          } else {
     
    14711566        {
    14721567          if ( !r_write_to_tgt_rsp_req.read() ) {
     1568
     1569            PRINTF("  * <MEM_CACHE.WRITE> YURI Request from %d.%d (%d)\n",(uint32_t)r_write_srcid.read(), (uint32_t)r_write_trdid.read(), (uint32_t)r_write_pktid.read());
     1570
    14731571            r_write_to_tgt_rsp_req          = true;
    14741572            r_write_to_tgt_rsp_srcid    = r_write_srcid.read();
     
    16441742      case WRITE_DIR_INVAL:
    16451743        {
    1646             assert(((r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE ) &&
     1744            ASSERT(((r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE ) &&
    16471745                    (r_alloc_upt_fsm.read() == ALLOC_UPT_WRITE ) &&
    1648                     (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE ))&&
    1649                     "MemCache ERROR : bad TRT,DIR or UPT allocation error");
     1746                    (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE ))
     1747                   ,"MemCache ERROR : bad TRT,DIR or UPT allocation error");
    16501748            m_transaction_tab.set(r_write_trt_index.read(),
    16511749                false,                          // write request to XRAM
     
    16751773            entry.lock          = false;
    16761774            entry.owner.srcid   = 0;
     1775#if L1_MULTI_CACHE
     1776            entry.owner.cache_id= 0;
     1777#endif
    16771778            entry.owner.inst    = false;
    16781779            entry.ptr           = 0;
     
    18901991            data_t data         = p_vci_ixr.rdata.read();
    18911992            size_t index        = r_ixr_rsp_trt_index.read();
    1892             assert( ((eop == (r_ixr_rsp_cpt.read() == (m_words-1))) ||
    1893                      p_vci_ixr.rerror.read())
    1894                 && "Error in VCI_MEM_CACHE : invalid length for a response from XRAM");
     1993            ASSERT(((eop == (r_ixr_rsp_cpt.read() == (m_words-1))) ||
     1994                    p_vci_ixr.rerror.read())
     1995                   ,"Error in VCI_MEM_CACHE : invalid length for a response from XRAM");
    18951996            m_transaction_tab.write_rsp(index, r_ixr_rsp_cpt.read(), data, p_vci_ixr.rerror.read()&0x1);
    18961997            r_ixr_rsp_cpt = r_ixr_rsp_cpt.read() + 1;
     
    19882089
    19892090            r_xram_rsp_victim_copy      = victim.owner.srcid;
     2091#if L1_MULTI_CACHE
     2092            r_xram_rsp_victim_copy_cache= victim.owner.cache_id;
     2093#endif
    19902094            r_xram_rsp_victim_copy_inst = victim.owner.inst;
    19912095            r_xram_rsp_victim_count     = victim.count;
     
    20052109if(m_cpt_cycles > DEBUG_START_CYCLE){
    20062110        std::cout << "XRAM_RSP FSM in XRAM_RSP_TRT_COPY state" << std::endl;
    2007         std::cout << "Victim way : " << std::hex << way << " set " << std::hex << set << std::endl;
     2111        std::cout << "Victim way : " << std::hex << way << " set " << set << std::dec << std::endl;
    20082112        victim.print();
    20092113}
     
    20932197          entry.ptr       = 0;
    20942198          if(cached_read) {
    2095             if(inst_read) {
    2096               entry.owner.srcid = r_xram_rsp_trt_buf.srcid;
    2097               entry.owner.inst  = true;
    2098               entry.count       = 1;
    2099             } else {
    2100               entry.owner.srcid = r_xram_rsp_trt_buf.srcid;
    2101               entry.owner.inst  = false;
    2102               entry.count       = 1;
    2103             }
     2199              entry.owner.srcid   = r_xram_rsp_trt_buf.srcid;
     2200#if L1_MULTI_CACHE
     2201              entry.owner.cache_id= r_xram_rsp_trt_buf.pktid;
     2202#endif
     2203              entry.owner.inst    = inst_read;
     2204              entry.count         = 1;
    21042205          } else {
    2105             entry.owner.srcid = 0;
    2106             entry.owner.inst  = 0;
    2107             entry.count       = 0;
     2206            entry.owner.srcid    = 0;
     2207#if L1_MULTI_CACHE
     2208            entry.owner.cache_id = 0;
     2209#endif
     2210            entry.owner.inst     = 0;
     2211            entry.count          = 0;
    21082212          }
    21092213          m_cache_directory.write(set, way, entry);
     
    21252229
    21262230          if(r_xram_rsp_victim_inval.read()){
    2127             bool    brdcast = r_xram_rsp_victim_is_cnt.read();
    2128             size_t index;
     2231            bool   brdcast = r_xram_rsp_victim_is_cnt.read();
     2232            size_t index = 0;
    21292233            size_t count_copies = r_xram_rsp_victim_count.read();
    2130 
     2234           
     2235            //@@
    21312236            bool         wok = m_update_tab.set(false,  // it's an inval transaction
    21322237                brdcast,                          // set brdcast bit
    21332238                false,  // it does not need a response
    2134                 0,
    2135                 0,
    2136                 0,
     2239                0,//srcid
     2240                0,//trdid
     2241                0,//pktid
    21372242                r_xram_rsp_victim_nline.read(),
    21382243                count_copies,
     
    21472252            r_xram_rsp_upt_index = index;
    21482253            if(!wok) {
    2149               assert(false && "mem_cache error : xram_rsp_dir_upt, an update_tab entry was free but write unsuccessful");
     2254                ASSERT(false,"mem_cache error : xram_rsp_dir_upt, an update_tab entry was free but write unsuccessful");
    21502255            }
    21512256          }
     
    22342339            xram_rsp_to_init_cmd_fifo_srcid     = r_xram_rsp_victim_copy.read();
    22352340            xram_rsp_to_init_cmd_fifo_inst      = r_xram_rsp_victim_copy_inst.read();
     2341#if L1_MULTI_CACHE
     2342            xram_rsp_to_init_cmd_fifo_cache_id  = r_xram_rsp_victim_copy_cache.read();
     2343#endif
    22362344            xram_rsp_to_init_cmd_fifo_put       = multi_req;
    22372345           
     
    22772385          if( r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP ) {
    22782386            HeapEntry entry = m_heap_directory.read(r_xram_rsp_next_ptr.read());
    2279             xram_rsp_to_init_cmd_fifo_srcid = entry.owner.srcid;
     2387            xram_rsp_to_init_cmd_fifo_srcid    = entry.owner.srcid;
     2388#if L1_MULTI_CACHE
     2389            xram_rsp_to_init_cmd_fifo_cache_id = entry.owner.cache_id;
     2390#endif
    22802391            xram_rsp_to_init_cmd_fifo_inst  = entry.owner.inst;
    22812392            xram_rsp_to_init_cmd_fifo_put   = true;
     
    22972408      case XRAM_RSP_HEAP_LAST:  // last member of the list
    22982409        {
    2299           assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP) &&
    2300                   "MemCache ERROR : bad HEAP allocation");
     2410          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP)
     2411                 ,"MemCache ERROR : bad HEAP allocation");
    23012412          size_t free_pointer = m_heap_directory.next_free_ptr();
    23022413
    23032414          HeapEntry last_entry;
    2304           last_entry.owner.srcid = 0;
    2305           last_entry.owner.inst  = false;
     2415          last_entry.owner.srcid    = 0;
     2416#if L1_MULTI_CACHE
     2417          last_entry.owner.cache_id = 0;
     2418#endif
     2419          last_entry.owner.inst     = false;
    23062420          if(m_heap_directory.is_full()){
    23072421            last_entry.next     = r_xram_rsp_next_ptr.read();
     
    23772491        {
    23782492          if ( p_vci_tgt_cleanup.cmdval.read() ) {
    2379             assert( (p_vci_tgt_cleanup.srcid.read() < m_initiators) &&
    2380             "VCI_MEM_CACHE error in a cleanup request : received SRCID is larger than the number of initiators");
     2493            ASSERT((p_vci_tgt_cleanup.srcid.read() < m_initiators)
     2494                   ,"VCI_MEM_CACHE error in a cleanup request : received SRCID is larger than the number of initiators");
    23812495
    23822496            bool reached = false;
     
    23912505                 reached)
    23922506            {
     2507              PRINTF("  * <MEM_CACHE.CLEANUP> Request from %d.%d at address %llx\n",(uint32_t)p_vci_tgt_cleanup.srcid.read(),(uint32_t)p_vci_tgt_cleanup.pktid.read(),(uint64_t)p_vci_tgt_cleanup.address.read());
     2508
    23932509              m_cpt_cleanup++;
    23942510
     
    24252541            r_cleanup_way           = way;
    24262542            r_cleanup_copy      = entry.owner.srcid;
     2543#if L1_MULTI_CACHE
     2544            r_cleanup_copy_cache= entry.owner.cache_id;
     2545#endif
    24272546            r_cleanup_copy_inst = entry.owner.inst;
    24282547            r_cleanup_count     = entry.count;
    24292548            r_cleanup_ptr       = entry.ptr;
    2430 
    24312549
    24322550            // In case of hit, the copy must be cleaned in the copies bit-vector
     
    24462564      case CLEANUP_DIR_WRITE:
    24472565        {
    2448           assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CLEANUP ) &&
    2449                 "MemCache ERROR : Bad DIR allocation");
     2566          ASSERT((r_alloc_dir_fsm.read() == ALLOC_DIR_CLEANUP)
     2567                 ,"MemCache ERROR : Bad DIR allocation");
    24502568          size_t way      = r_cleanup_way.read();
    24512569#define L2 soclib::common::uint32_log2
     
    24532571#undef L2
    24542572          bool cleanup_inst  = r_cleanup_trdid.read() & 0x1;
    2455           bool match_srcid   = (r_cleanup_copy.read() == r_cleanup_srcid.read());
     2573          bool match_srcid   = ((r_cleanup_copy.read() == r_cleanup_srcid.read())
     2574#if L1_MULTI_CACHE
     2575                                and (r_cleanup_copy_cache.read() == r_cleanup_pktid.read())
     2576#endif
     2577                                );
    24562578          bool match_inst    = (r_cleanup_copy_inst.read()  == cleanup_inst);
    24572579          bool match         = match_srcid && match_inst;
     
    24672589          if(r_cleanup_is_cnt.read()) { // Directory is a counter
    24682590            entry.count  = r_cleanup_count.read() -1;
    2469             entry.owner.srcid = 0;
    2470             entry.owner.inst  = 0;
     2591            entry.owner.srcid   = 0;
     2592#if L1_MULTI_CACHE
     2593            entry.owner.cache_id= 0;
     2594#endif
     2595            entry.owner.inst    = 0;
    24712596            // response to the cache
    24722597            r_cleanup_fsm = CLEANUP_RSP;
     
    24742599          else{                         // Directory is a list
    24752600            if(match) { // hit
    2476               entry.count       = 0; // no more copy
    2477               entry.owner.srcid = 0;
    2478               entry.owner.inst  = 0;
    2479               r_cleanup_fsm     = CLEANUP_RSP;
     2601              entry.count         = 0; // no more copy
     2602              entry.owner.srcid   = 0;
     2603#if L1_MULTI_CACHE
     2604              entry.owner.cache_id=0;
     2605#endif
     2606              entry.owner.inst    = 0;
     2607              r_cleanup_fsm       = CLEANUP_RSP;
    24802608            } else { // miss
    2481               entry.count       = r_cleanup_count.read();
    2482               entry.owner.srcid = r_cleanup_copy.read();
    2483               entry.owner.inst  = r_cleanup_copy_inst.read();
    2484               r_cleanup_fsm     = CLEANUP_UPT_LOCK;
     2609              entry.count          = r_cleanup_count.read();
     2610              entry.owner.srcid    = r_cleanup_copy.read();
     2611#if L1_MULTI_CACHE
     2612              entry.owner.cache_id = r_cleanup_copy_cache.read();
     2613#endif
     2614              entry.owner.inst     = r_cleanup_copy_inst.read();
     2615              r_cleanup_fsm        = CLEANUP_UPT_LOCK;
    24852616            }
    24862617          }
     
    25012632            bool cleanup_inst       = r_cleanup_trdid.read() & 0x1;
    25022633            bool match_dir_srcid    = (r_cleanup_copy.read() == r_cleanup_srcid.read());
     2634#if L1_MULTI_CACHE
     2635            bool match_dir_cache_id = (r_cleanup_copy_cache.read() == r_cleanup_pktid.read());
     2636#endif
    25032637            bool match_dir_inst     = (r_cleanup_copy_inst.read()  == cleanup_inst);
    2504             bool match_dir          = match_dir_srcid && match_dir_inst;
     2638            bool match_dir          = match_dir_srcid and match_dir_cache_id and match_dir_inst;
    25052639            bool match_heap_srcid   = (heap_entry.owner.srcid == r_cleanup_srcid.read());
     2640#if L1_MULTI_CACHE
     2641            bool match_heap_cache_id= (heap_entry.owner.cache_id == r_cleanup_pktid.read());
     2642#endif
    25062643            bool match_heap_inst    = (heap_entry.owner.inst  == cleanup_inst);
    2507             bool match_heap         = match_heap_srcid && match_heap_inst;
    2508 
    2509             r_cleanup_prev_ptr = r_cleanup_ptr.read();
    2510             r_cleanup_prev_srcid = heap_entry.owner.srcid;
    2511             r_cleanup_prev_inst  = heap_entry.owner.inst;
     2644            bool match_heap         = match_heap_srcid and match_heap_cache_id and match_heap_inst;
     2645
     2646#if L1_MULTI_CACHE
     2647            PRINTF("  * <MEM_CACHE.CLEANUP> match_dir  %d (match_dir_srcid  %d, match_dir_cache_id  %d, match_dir_inst  %d)\n",
     2648                   match_dir , match_dir_srcid , match_dir_cache_id , match_dir_inst);
     2649            PRINTF("  * <MEM_CACHE.CLEANUP> match_heap %d (match_heap_srcid %d, match_heap_cache_id %d, match_heap_inst %d)\n",
     2650                   match_heap, match_heap_srcid, match_heap_cache_id, match_heap_inst);
     2651#else
     2652            PRINTF("  * <MEM_CACHE.CLEANUP> match_dir  %d (match_dir_srcid  %d, match_dir_inst  %d)\n",
     2653                   match_dir , match_dir_srcid , match_dir_inst);
     2654            PRINTF("  * <MEM_CACHE.CLEANUP> match_heap %d (match_heap_srcid %d, match_heap_inst %d)\n",
     2655                   match_heap, match_heap_srcid, match_heap_inst);
     2656#endif
     2657            PRINTF("  * <MEM_CACHE.CLEANUP> last %d\n",last);
     2658
     2659            r_cleanup_prev_ptr      = r_cleanup_ptr.read();
     2660            r_cleanup_prev_srcid    = heap_entry.owner.srcid;
     2661#if L1_MULTI_CACHE
     2662            r_cleanup_prev_cache_id = heap_entry.owner.cache_id;
     2663#endif
     2664
     2665            r_cleanup_prev_inst     = heap_entry.owner.inst;
    25122666
    25132667            if(match_dir){
    25142668              DirectoryEntry dir_entry;
    2515               dir_entry.valid       = true;
    2516               dir_entry.is_cnt      = r_cleanup_is_cnt.read();
    2517               dir_entry.dirty       = r_cleanup_dirty.read();
    2518               dir_entry.tag             = r_cleanup_tag.read();
    2519               dir_entry.lock        = r_cleanup_lock.read();
    2520               dir_entry.ptr         = heap_entry.next;
    2521               dir_entry.count       = r_cleanup_count.read()-1;
    2522               dir_entry.owner.srcid = heap_entry.owner.srcid;
    2523               dir_entry.owner.inst  = heap_entry.owner.inst;
     2669              dir_entry.valid          = true;
     2670              dir_entry.is_cnt         = r_cleanup_is_cnt.read();
     2671              dir_entry.dirty          = r_cleanup_dirty.read();
     2672              dir_entry.tag                = r_cleanup_tag.read();
     2673              dir_entry.lock           = r_cleanup_lock.read();
     2674              dir_entry.ptr            = heap_entry.next;
     2675              dir_entry.count          = r_cleanup_count.read()-1;
     2676              dir_entry.owner.srcid    = heap_entry.owner.srcid;
     2677#if L1_MULTI_CACHE
     2678              dir_entry.owner.cache_id = heap_entry.owner.cache_id;
     2679#endif
     2680              dir_entry.owner.inst     = heap_entry.owner.inst;
    25242681              m_cache_directory.write(set,way,dir_entry);
    2525               r_cleanup_next_ptr    = r_cleanup_ptr.read();
    2526               r_cleanup_fsm         = CLEANUP_HEAP_FREE;
     2682              r_cleanup_next_ptr       = r_cleanup_ptr.read();
     2683              r_cleanup_fsm            = CLEANUP_HEAP_FREE;
    25272684            }
    25282685            else if(match_heap){
    25292686              DirectoryEntry dir_entry;
    2530               dir_entry.valid       = true;
    2531               dir_entry.is_cnt      = r_cleanup_is_cnt.read();
    2532               dir_entry.dirty       = r_cleanup_dirty.read();
    2533               dir_entry.tag             = r_cleanup_tag.read();
    2534               dir_entry.lock        = r_cleanup_lock.read();
    2535               dir_entry.ptr         = heap_entry.next;
    2536               dir_entry.count       = r_cleanup_count.read()-1;
    2537               dir_entry.owner.srcid = r_cleanup_copy.read();
    2538               dir_entry.owner.inst  = r_cleanup_copy_inst.read();
     2687              dir_entry.valid          = true;
     2688              dir_entry.is_cnt         = r_cleanup_is_cnt.read();
     2689              dir_entry.dirty          = r_cleanup_dirty.read();
     2690              dir_entry.tag                = r_cleanup_tag.read();
     2691              dir_entry.lock           = r_cleanup_lock.read();
     2692              dir_entry.ptr            = heap_entry.next;
     2693              dir_entry.count          = r_cleanup_count.read()-1;
     2694              dir_entry.owner.srcid    = r_cleanup_copy.read();
     2695#if L1_MULTI_CACHE
     2696              dir_entry.owner.cache_id = r_cleanup_copy_cache.read();
     2697#endif
     2698              dir_entry.owner.inst     = r_cleanup_copy_inst.read();
    25392699              m_cache_directory.write(set,way,dir_entry);
    2540               r_cleanup_next_ptr    = r_cleanup_ptr.read();
    2541               r_cleanup_fsm         = CLEANUP_HEAP_FREE;
     2700              r_cleanup_next_ptr       = r_cleanup_ptr.read();
     2701              r_cleanup_fsm            = CLEANUP_HEAP_FREE;
    25422702            }
    25432703            else{
     
    25522712                dir_entry.count         = r_cleanup_count.read()-1;
    25532713                dir_entry.owner.srcid   = r_cleanup_copy.read();
     2714#if L1_MULTI_CACHE
     2715                dir_entry.owner.cache_id= r_cleanup_copy_cache.read();
     2716#endif
    25542717                dir_entry.owner.inst    = r_cleanup_copy_inst.read();
    25552718                m_cache_directory.write(set,way,dir_entry);
     
    25592722
    25602723              } else{
    2561                 assert(false && "MemCache ERROR : CLEANUP hit but line not shared");
     2724                  ASSERT(false,"MemCache ERROR : CLEANUP hit but line not shared");
    25622725              }
    25632726            }
     
    25682731      case CLEANUP_HEAP_SEARCH:
    25692732        {
    2570           assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&
    2571                     "MemCache ERROR : bad HEAP allocation");
     2733          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP)
     2734                 ,"MemCache ERROR : bad HEAP allocation");
    25722735          HeapEntry heap_entry = m_heap_directory.read(r_cleanup_next_ptr.read());
    25732736          bool last = (heap_entry.next == r_cleanup_next_ptr.read());
    25742737          bool cleanup_inst       = r_cleanup_trdid.read() & 0x1;
    2575           bool match_heap_srcid   = (heap_entry.owner.srcid == r_cleanup_srcid.read());
     2738          bool match_heap_srcid   = ((heap_entry.owner.srcid == r_cleanup_srcid.read())
     2739#if L1_MULTI_CACHE
     2740                                     and (heap_entry.owner.cache_id == r_cleanup_pktid.read())
     2741#endif
     2742                                     );
    25762743          bool match_heap_inst    = (heap_entry.owner.inst  == cleanup_inst);
    25772744          bool match_heap         = match_heap_srcid && match_heap_inst;
     
    25832750          else{
    25842751            if(last) {
    2585               assert(false && "MemCache ERROR : CLEANUP hit but line not shared");
     2752                ASSERT(false,"MemCache ERROR : CLEANUP hit but line not shared");
    25862753            } else {
    2587               r_cleanup_prev_ptr = r_cleanup_next_ptr.read();
    2588               r_cleanup_prev_srcid = heap_entry.owner.srcid;
    2589               r_cleanup_prev_inst  = heap_entry.owner.inst;
     2754              r_cleanup_prev_ptr      = r_cleanup_next_ptr.read();
     2755              r_cleanup_prev_srcid    = heap_entry.owner.srcid;
     2756#if L1_MULTI_CACHE
     2757              r_cleanup_prev_cache_id = heap_entry.owner.cache_id;
     2758#endif
     2759              r_cleanup_prev_inst     = heap_entry.owner.inst;
    25902760              r_cleanup_next_ptr = heap_entry.next;
    25912761              r_cleanup_fsm      = CLEANUP_HEAP_SEARCH;
     
    25982768      case CLEANUP_HEAP_CLEAN:
    25992769        {
    2600           assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&
    2601                     "MemCache ERROR : bad HEAP allocation");
     2770            ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP)
     2771                   ,"MemCache ERROR : bad HEAP allocation");
    26022772          bool last = (r_cleanup_next_ptr.read() == r_cleanup_ptr.read());
    26032773          HeapEntry heap_entry;
    2604           heap_entry.owner.srcid = r_cleanup_prev_srcid.read();
    2605           heap_entry.owner.inst  = r_cleanup_prev_inst.read();
     2774          heap_entry.owner.srcid    = r_cleanup_prev_srcid.read();
     2775#if L1_MULTI_CACHE
     2776          heap_entry.owner.cache_id = r_cleanup_prev_cache_id.read();
     2777#endif
     2778          heap_entry.owner.inst     = r_cleanup_prev_inst.read();
    26062779          if(last){ // this is the last entry of the list of copies
    26072780            heap_entry.next     = r_cleanup_prev_ptr.read();
     
    26162789      case CLEANUP_HEAP_FREE:
    26172790        {
    2618           assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&
    2619                     "MemCache ERROR : bad HEAP allocation");
     2791          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP)
     2792                 ,"MemCache ERROR : bad HEAP allocation");
    26202793          HeapEntry heap_entry;
    2621           heap_entry.owner.srcid = 0;
    2622           heap_entry.owner.inst  = false;
     2794          heap_entry.owner.srcid    = 0;
     2795#if L1_MULTI_CACHE
     2796          heap_entry.owner.cache_id = 0;
     2797#endif
     2798          heap_entry.owner.inst     = false;
    26232799          if(m_heap_directory.is_full()){
    26242800            heap_entry.next     = r_cleanup_next_ptr.read();
     
    27602936                r_llsc_wdata = m_cmd_llsc_wdata_fifo.read();
    27612937            if(r_llsc_cpt.read()>3)
    2762                 assert(false && "MEMCACHE error : SC too long");
     2938                ASSERT(false,"MEMCACHE error : SC too long");
    27632939            if(r_llsc_cpt.read()==2){
    27642940                r_llsc_wdata = m_cmd_llsc_wdata_fifo.read();
     
    27742950            size_t way = 0;
    27752951            DirectoryEntry entry(m_cache_directory.read(m_cmd_llsc_addr_fifo.read(), way));
    2776             r_llsc_is_cnt   = entry.is_cnt;
    2777             r_llsc_dirty    = entry.dirty;
    2778             r_llsc_tag      = entry.tag;
    2779             r_llsc_way      = way;
    2780             r_llsc_copy     = entry.owner.srcid;
    2781             r_llsc_copy_inst= entry.owner.inst;
    2782             r_llsc_ptr      = entry.ptr;
    2783             r_llsc_count    = entry.count;
     2952            r_llsc_is_cnt     = entry.is_cnt;
     2953            r_llsc_dirty      = entry.dirty;
     2954            r_llsc_tag        = entry.tag;
     2955            r_llsc_way        = way;
     2956            r_llsc_copy       = entry.owner.srcid;
     2957#if L1_MULTI_CACHE
     2958            r_llsc_copy_cache = entry.owner.cache_id;
     2959#endif
     2960
     2961            r_llsc_copy_inst  = entry.owner.inst;
     2962            r_llsc_ptr        = entry.ptr;
     2963            r_llsc_count      = entry.count;
    27842964            if ( entry.valid ){
    27852965                r_llsc_fsm = SC_DIR_HIT_READ;
     
    27982978          // update directory (lock & dirty bits
    27992979          DirectoryEntry entry;
    2800           entry.valid       = true;
    2801           entry.is_cnt      = r_llsc_is_cnt.read();
    2802           entry.dirty       = true;
    2803           entry.lock        = true;
    2804           entry.tag             = r_llsc_tag.read();
    2805           entry.owner.srcid = r_llsc_copy.read();
    2806           entry.owner.inst  = r_llsc_copy_inst.read();
    2807           entry.count       = r_llsc_count.read();
    2808           entry.ptr         = r_llsc_ptr.read();
     2980          entry.valid          = true;
     2981          entry.is_cnt         = r_llsc_is_cnt.read();
     2982          entry.dirty          = true;
     2983          entry.lock           = true;
     2984          entry.tag                = r_llsc_tag.read();
     2985          entry.owner.srcid    = r_llsc_copy.read();
     2986#if L1_MULTI_CACHE
     2987          entry.owner.cache_id = r_llsc_copy_cache.read();
     2988#endif
     2989          entry.owner.inst     = r_llsc_copy_inst.read();
     2990          entry.count          = r_llsc_count.read();
     2991          entry.ptr            = r_llsc_ptr.read();
    28092992          m_cache_directory.write(set, way, entry);
    28102993
     
    29383121      case SC_UPT_REQ:  // Request the update
    29393122        {
    2940           assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC) &&
    2941                     "MemCache ERROR : bad HEAP allocation");
     3123          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC)
     3124                 ,"MemCache ERROR : bad HEAP allocation");
    29423125          if( !r_llsc_to_init_cmd_multi_req.read() &&
    29433126              !r_llsc_to_init_cmd_brdcast_req.read()  ){
     
    29593142            llsc_to_init_cmd_fifo_inst    = r_llsc_copy_inst.read();
    29603143            llsc_to_init_cmd_fifo_srcid   = r_llsc_copy.read();
     3144#if L1_MULTI_CACHE
     3145            llsc_to_init_cmd_fifo_cache_id= r_llsc_copy_cache.read();
     3146#endif
    29613147            if(r_llsc_count.read() == 1){
    29623148#ifdef LOCK_DEBUG
     
    29783164      case SC_UPDATE:           // send a multi-update request to INIT_CMD fsm
    29793165        {
    2980           assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC) &&
    2981                     "MemCache ERROR : bad HEAP allocation");
     3166          ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC)
     3167                 ,"MemCache ERROR : bad HEAP allocation");
    29823168          HeapEntry entry = m_heap_directory.read(r_llsc_ptr.read());
    2983           llsc_to_init_cmd_fifo_inst  = entry.owner.inst;
    2984           llsc_to_init_cmd_fifo_srcid = entry.owner.srcid;
     3169          llsc_to_init_cmd_fifo_srcid    = entry.owner.srcid;
     3170#if L1_MULTI_CACHE
     3171          llsc_to_init_cmd_fifo_cache_id = entry.owner.cache_id;
     3172#endif
     3173          llsc_to_init_cmd_fifo_inst     = entry.owner.inst;
    29853174          llsc_to_init_cmd_fifo_put = true;
    29863175
     
    31063295            entry.count         = 0;
    31073296            entry.owner.srcid   = 0;
     3297#if L1_MULTI_CACHE
     3298            entry.owner.cache_id= 0;
     3299#endif
    31083300            entry.owner.inst    = false;
    31093301            entry.ptr           = 0;
     
    31143306            r_llsc_fsm = SC_INVAL;
    31153307          } else {
    3116             assert(false && "LOCK ERROR in LLSC_FSM, STATE = LLSC_DIR_INVAL");
     3308              ASSERT(false,"LOCK ERROR in LLSC_FSM, STATE = LLSC_DIR_INVAL");
    31173309          }
    31183310
     
    31503342            r_llsc_cpt = 0;
    31513343          } else {
    3152             assert( false && "MEM_CACHE, LLSC FSM : SC_XRAM_SEND state : the request should not have been previously set");
     3344              ASSERT(false,"MEM_CACHE, LLSC FSM : SC_XRAM_SEND state : the request should not have been previously set");
    31533345          }
    31543346          break;
     
    41094301        m_write_to_init_cmd_inst_fifo.put_and_get(write_to_init_cmd_fifo_inst);
    41104302        m_write_to_init_cmd_srcid_fifo.put_and_get(write_to_init_cmd_fifo_srcid);
     4303#if L1_MULTI_CACHE
     4304        m_write_to_init_cmd_cache_id_fifo.put_and_get(write_to_init_cmd_fifo_cache_id);
     4305#endif
    41114306      } else {
    41124307        m_write_to_init_cmd_inst_fifo.simple_put(write_to_init_cmd_fifo_inst);
    41134308        m_write_to_init_cmd_srcid_fifo.simple_put(write_to_init_cmd_fifo_srcid);
     4309#if L1_MULTI_CACHE
     4310        m_write_to_init_cmd_cache_id_fifo.simple_put(write_to_init_cmd_fifo_cache_id);
     4311#endif
    41144312      }
    41154313    } else {
     
    41174315        m_write_to_init_cmd_inst_fifo.simple_get();
    41184316        m_write_to_init_cmd_srcid_fifo.simple_get();
     4317#if L1_MULTI_CACHE
     4318        m_write_to_init_cmd_cache_id_fifo.simple_get();
     4319#endif
    41194320      }
    41204321    }
     
    41274328        m_xram_rsp_to_init_cmd_inst_fifo.put_and_get(xram_rsp_to_init_cmd_fifo_inst);
    41284329        m_xram_rsp_to_init_cmd_srcid_fifo.put_and_get(xram_rsp_to_init_cmd_fifo_srcid);
     4330#if L1_MULTI_CACHE
     4331        m_xram_rsp_to_init_cmd_cache_id_fifo.put_and_get(xram_rsp_to_init_cmd_fifo_cache_id);
     4332#endif
    41294333      } else {
    41304334        m_xram_rsp_to_init_cmd_inst_fifo.simple_put(xram_rsp_to_init_cmd_fifo_inst);
    41314335        m_xram_rsp_to_init_cmd_srcid_fifo.simple_put(xram_rsp_to_init_cmd_fifo_srcid);
     4336#if L1_MULTI_CACHE
     4337        m_xram_rsp_to_init_cmd_cache_id_fifo.simple_put(xram_rsp_to_init_cmd_fifo_cache_id);
     4338#endif
    41324339      }
    41334340    } else {
     
    41354342        m_xram_rsp_to_init_cmd_inst_fifo.simple_get();
    41364343        m_xram_rsp_to_init_cmd_srcid_fifo.simple_get();
     4344#if L1_MULTI_CACHE
     4345        m_xram_rsp_to_init_cmd_cache_id_fifo.simple_get();
     4346#endif
    41374347      }
    41384348    }
     
    41454355        m_llsc_to_init_cmd_inst_fifo.put_and_get(llsc_to_init_cmd_fifo_inst);
    41464356        m_llsc_to_init_cmd_srcid_fifo.put_and_get(llsc_to_init_cmd_fifo_srcid);
     4357#if L1_MULTI_CACHE
     4358        m_llsc_to_init_cmd_cache_id_fifo.put_and_get(llsc_to_init_cmd_fifo_cache_id);
     4359#endif
    41474360      } else {
    4148         m_llsc_to_init_cmd_inst_fifo.simple_put(llsc_to_init_cmd_fifo_inst);
    4149         m_llsc_to_init_cmd_srcid_fifo.simple_put(llsc_to_init_cmd_fifo_srcid);
     4361          m_llsc_to_init_cmd_inst_fifo.simple_put(llsc_to_init_cmd_fifo_inst);
     4362          m_llsc_to_init_cmd_srcid_fifo.simple_put(llsc_to_init_cmd_fifo_srcid);
     4363#if L1_MULTI_CACHE
     4364          m_llsc_to_init_cmd_cache_id_fifo.simple_put(llsc_to_init_cmd_fifo_cache_id);
     4365#endif
    41504366      }
    41514367    } else {
    4152       if ( llsc_to_init_cmd_fifo_get ) {
    4153         m_llsc_to_init_cmd_inst_fifo.simple_get();
    4154         m_llsc_to_init_cmd_srcid_fifo.simple_get();
     4368        if ( llsc_to_init_cmd_fifo_get ) {
     4369            m_llsc_to_init_cmd_inst_fifo.simple_get();
     4370            m_llsc_to_init_cmd_srcid_fifo.simple_get();
     4371#if L1_MULTI_CACHE
     4372            m_llsc_to_init_cmd_cache_id_fifo.simple_get();
     4373#endif
    41554374      }
    41564375    }
     
    41604379    m_cpt_cycles++;
    41614380
    4162   } // end transition()
     4381    } // end transition()
    41634382
    41644383  /////////////////////////////
     
    42974516        break;
    42984517      case TGT_RSP_READ:
     4518          PRINTF("  * <MEM_CACHE.TGT> RSP_READ     : srcid %d, trdid %d, pktid %d\n"
     4519                 ,(uint32_t)r_read_to_tgt_rsp_srcid.read()
     4520                 ,(uint32_t)r_read_to_tgt_rsp_trdid.read()
     4521                 ,(uint32_t)r_read_to_tgt_rsp_pktid.read()
     4522                 );
     4523
    42994524        p_vci_tgt.rspval   = true;
    43004525        p_vci_tgt.rdata    = r_read_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read();
     
    43064531        break;
    43074532      case TGT_RSP_WRITE:
     4533          PRINTF("  * <MEM_CACHE.TGT> RSP_WRITE    : BURP srcid %d, trdid %d, pktid %d\n"
     4534                 ,(uint32_t)r_write_to_tgt_rsp_srcid.read()
     4535                 ,(uint32_t)r_write_to_tgt_rsp_trdid.read()
     4536                 ,(uint32_t)r_write_to_tgt_rsp_pktid.read()
     4537                 );
     4538
    43084539        p_vci_tgt.rspval   = true;
    43094540        p_vci_tgt.rdata    = 0;
     
    43154546        break;
    43164547      case TGT_RSP_CLEANUP:
     4548          PRINTF("  * <MEM_CACHE.TGT> RSP_CLEANUP  : srcid %d, trdid %d, pktid %d\n"
     4549                 ,(uint32_t)r_cleanup_to_tgt_rsp_srcid.read()
     4550                 ,(uint32_t)r_cleanup_to_tgt_rsp_trdid.read()
     4551                 ,(uint32_t)r_cleanup_to_tgt_rsp_pktid.read()
     4552                 );
     4553
    43174554        p_vci_tgt.rspval   = true;
    43184555        p_vci_tgt.rdata    = 0;
     
    43244561        break;
    43254562      case TGT_RSP_LLSC:
     4563          PRINTF("  * <MEM_CACHE.TGT> RSP_LLSC     : srcid %d, trdid %d, pktid %d\n"
     4564                 ,(uint32_t)r_llsc_to_tgt_rsp_srcid.read()
     4565                 ,(uint32_t)r_llsc_to_tgt_rsp_trdid.read()
     4566                 ,(uint32_t)r_llsc_to_tgt_rsp_pktid.read()
     4567                 );
     4568
    43264569        p_vci_tgt.rspval   = true;
    43274570        p_vci_tgt.rdata    = r_llsc_to_tgt_rsp_data.read();
     
    43334576        break;
    43344577      case TGT_RSP_XRAM:
     4578          PRINTF("  * <MEM_CACHE.TGT> RSP_XRAM     : srcid %d, trdid %d, pktid %d\n"
     4579                 ,(uint32_t)r_xram_rsp_to_tgt_rsp_srcid.read()
     4580                 ,(uint32_t)r_xram_rsp_to_tgt_rsp_trdid.read()
     4581                 ,(uint32_t)r_xram_rsp_to_tgt_rsp_pktid.read()
     4582                 );
     4583
    43354584        p_vci_tgt.rspval   = true;
    43364585        p_vci_tgt.rdata    = r_xram_rsp_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read();
     
    43434592        break;
    43444593      case TGT_RSP_INIT:
     4594          PRINTF("  * <MEM_CACHE.TGT> RSP_INIT     : srcid %d, trdid %d, pktid %d\n"
     4595                 ,(uint32_t)r_init_rsp_to_tgt_rsp_srcid.read()
     4596                 ,(uint32_t)r_init_rsp_to_tgt_rsp_trdid.read()
     4597                 ,(uint32_t)r_init_rsp_to_tgt_rsp_pktid.read()
     4598                 );
     4599
    43454600        p_vci_tgt.rspval   = true;
    43464601        p_vci_tgt.rdata    = 0;
     
    43594614    p_vci_ini.cmd     = vci_param::CMD_WRITE;
    43604615    p_vci_ini.srcid   = m_srcid_ini;
    4361     p_vci_ini.pktid   = 0;
    43624616    p_vci_ini.cons    = true;
    43634617    p_vci_ini.wrap    = false;
     
    43774631        p_vci_ini.plen    = 0;
    43784632        p_vci_ini.trdid   = 0;
     4633        p_vci_ini.pktid   = 0;
    43794634        p_vci_ini.eop     = false;
    43804635        break;
    43814636      case INIT_CMD_INVAL_NLINE:
     4637      {
     4638        PRINTF("  * <MEM_CACHE.INIT_CMD> INVAL_NLINE : trdid %d, pktid %d\n"
     4639               ,(uint32_t)r_xram_rsp_to_init_cmd_trdid.read()
     4640               ,(uint32_t)m_xram_rsp_to_init_cmd_cache_id_fifo.read()
     4641               );
     4642       
    43824643        p_vci_ini.cmdval  = m_xram_rsp_to_init_cmd_inst_fifo.rok();
    43834644        if(m_xram_rsp_to_init_cmd_inst_fifo.rok()){
     
    43924653        p_vci_ini.plen    = 4;
    43934654        p_vci_ini.trdid   = r_xram_rsp_to_init_cmd_trdid.read();
     4655        p_vci_ini.pktid   = m_xram_rsp_to_init_cmd_cache_id_fifo.read();
    43944656        p_vci_ini.eop     = true;
    43954657        break;
     4658      }
    43964659      case INIT_CMD_XRAM_BRDCAST:
    43974660        p_vci_ini.cmdval  = true;
     
    44014664        p_vci_ini.plen    = 4;
    44024665        p_vci_ini.trdid   = r_xram_rsp_to_init_cmd_trdid.read();
     4666        p_vci_ini.pktid   = 0;
    44034667        p_vci_ini.eop     = true;
    44044668        break;
     
    44124676        p_vci_ini.eop     = true;
    44134677        p_vci_ini.trdid   = r_write_to_init_cmd_trdid.read();
     4678        p_vci_ini.pktid   = 0;
    44144679        break;
    44154680      case INIT_CMD_UPDT_NLINE:
     
    44294694        p_vci_ini.eop     = false;
    44304695        p_vci_ini.trdid   = r_write_to_init_cmd_trdid.read();
     4696        p_vci_ini.pktid   = m_write_to_init_cmd_cache_id_fifo.read();
    44314697        break;
    44324698      case INIT_CMD_UPDT_INDEX:
     
    44414707        p_vci_ini.plen    = 4 * (r_write_to_init_cmd_count.read() + 2);
    44424708        p_vci_ini.trdid   = r_write_to_init_cmd_trdid.read();
     4709        p_vci_ini.pktid   = m_write_to_init_cmd_cache_id_fifo.read();
    44434710        p_vci_ini.eop     = false;
    44444711        break;
     
    44564723        p_vci_ini.plen    = 4 * (r_write_to_init_cmd_count.read() + 2);
    44574724        p_vci_ini.trdid   = r_write_to_init_cmd_trdid.read();
     4725        p_vci_ini.pktid   = m_write_to_init_cmd_cache_id_fifo.read();
    44584726        p_vci_ini.eop     = ( r_init_cmd_cpt.read() == (r_write_to_init_cmd_count.read()-1) );
    44594727        break;
     
    44674735        p_vci_ini.eop     = true;
    44684736        p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
     4737        p_vci_ini.pktid   = 0;
    44694738        break;
    44704739      case INIT_CMD_SC_UPDT_NLINE:
     
    44884757        p_vci_ini.eop     = false;
    44894758        p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
     4759        p_vci_ini.pktid   = m_llsc_to_init_cmd_cache_id_fifo.read();
    44904760        break;
    44914761      case INIT_CMD_SC_UPDT_INDEX:
     
    45044774        }
    45054775        p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
     4776        p_vci_ini.pktid   = m_llsc_to_init_cmd_cache_id_fifo.read();
    45064777        p_vci_ini.eop     = false;
    45074778        break;
     
    45164787        p_vci_ini.be      = 0xF;
    45174788        p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
     4789        p_vci_ini.pktid   = m_llsc_to_init_cmd_cache_id_fifo.read();
    45184790        if(r_llsc_to_init_cmd_is_long.read()){
    45194791            p_vci_ini.plen    = 4 * 4;
     
    45354807        p_vci_ini.plen    = 4 * 4;
    45364808        p_vci_ini.trdid   = r_llsc_to_init_cmd_trdid.read();
     4809        p_vci_ini.pktid   = m_llsc_to_init_cmd_cache_id_fifo.read();
    45374810        p_vci_ini.eop     = true;
    45384811        break;
     
    45674840      case CLEANUP_RSP:
    45684841        {
     4842            PRINTF("  * <MEM_CACHE.CLEANUP_RSP> Respons to %d.%d\n",(uint32_t)r_cleanup_srcid.read(),(uint32_t)r_cleanup_pktid.read());
     4843
    45694844          p_vci_tgt_cleanup.rspval = true;
    45704845          p_vci_tgt_cleanup.rdata  = 0;
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/Makefile

    r137 r140  
    11#NO_SOFT                =  1
    22ARCH                    =  mips32el
    3 #SIMULATION_ARGS        =  100000
    4 #SOCLIB_CC_ADD_ARGS     = "-DCC_XCACHE_WRAPPER_DEBUG=1"
    5 SOCLIB_CC_ADD_ARGS=-t systemcass
     3#SIMULATION_ARGS        = 
     4#SOCLIB_CC_ADD_ARGS     = -t systemc_32
     5SOCLIB_CC_ADD_ARGS      = -t systemcass
    66SOCLIB                  ?= $(shell soclib-cc --getpath)
    77export SOCLIB
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/configuration/default.cfg

    r134 r140  
    114
     21 1
    234 64 16
    344 64 16
    4 8 8 16
     54 8 16
    5616 256 16 4096
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/configuration/gen_config.sh

    r134 r140  
    11#!/bin/bash
    22
    3 #               archi1  archi2  archi3  archi4
    4 archi_name=(    "00512" "16384" "01024" "02048");
    5 iways=(         "1"     "4"     "16"    "4"    );
    6 isets=(         "8"     "64"    "1"     "8"    );
    7 iwords=(        "16"    "16"    "16"    "16"   );
    8 dways=(         "1"     "4"     "16"    "4"    );
    9 dsets=(         "8"     "64"    "1"     "8"    );
    10 dwords=(        "16"    "16"    "16"    "16"   );
    11 memc_nways=(    "4"     "16"    "8"     "2"    );
    12 memc_nsets=(    "4"     "256"   "64"    "32"   );
    13 memc_words=(    "16"    "16"    "16"    "16"   );
    14 memc_heap_size=("4096"  "4096"  "4096"  "4096" );
     3#               archi1  archi2  archi3       archi4  archi5
     4archi_name=(    "min"   "tsar"  "full_assoc" "2k"    "4k"   );
     5iways=(         "1"     "4"     "16"         "4"     "4"    );
     6isets=(         "8"     "64"    "1"          "8"     "16"   );
     7iwords=(        "16"    "16"    "16"         "16"    "16"   );
     8dways=(         "1"     "4"     "16"         "4"     "4"    );
     9dsets=(         "8"     "64"    "1"          "8"     "16"   );
     10dwords=(        "16"    "16"    "16"         "16"    "16"   );
     11memc_nways=(    "4"     "16"    "8"          "2"     "16"   );
     12memc_nsets=(    "4"     "256"   "64"         "32"    "64"   );
     13memc_words=(    "16"    "16"    "16"         "16"    "16"   );
     14memc_heap_size=("4096"  "4096"  "4096"       "4096"  "4096" );
    1515
    16 nb_proc=( "1" "15" "+1" "4");
    17 wnwords=( "1" "16" "*2" "8");
    18 wnlines=( "1" "8"  "*2" "8");
    19 wtimeout=("1" "1024" "*4" "16");
     16nb_proc=(        "1" "15"   "+1" "4");
     17nb_cpu_by_cache=("1" "15"   "*2" "1");
     18nb_cache=(       "1" "16"   "*2" "1");
     19#wnwords=(        "1" "16"   "*2" "4");
     20#wnlines=(        "1" "8"    "*2" "8");
     21#wtimeout=(       "1" "1024" "*4" "16");
     22
     23wnwords=(        "4"  "4"  "*2" "4");
     24wnlines=(        "8"  "8"  "*2" "8");
     25wtimeout=(       "16" "16" "*4" "16");
    2026
    2127archi_default="1";
     28gen_cfg=0;
    2229
    2330function gen_file ()
    2431{
    25         filename=$(printf "x%.2d-xcache_%s-wbuf_%.2d_%.2d_%.4d.cfg" ${1} ${archi_name[${2}]} ${3} ${4} ${5});
     32        filename=$(printf "archi_%s-x%.2d_%.2d_%.2d-wbuf_%.2d_%.2d_%.4d.cfg" ${archi_name[${4}]} ${1} ${2} ${3} ${5} ${6} ${7});
    2633
    2734        echo ${filename};
    2835
    29         echo "${1}" > ${filename};
    30         echo "${iways[${2}]} ${isets[${2}]} ${iwords[${2}]}" >> ${filename};
    31         echo "${dways[${2}]} ${dsets[${2}]} ${dwords[${2}]}" >> ${filename};
    32         echo "${3} ${4} ${5}" >> ${filename};
    33         echo "${memc_nways[${2}]} ${memc_nsets[${2}]} ${memc_words[${2}]} ${memc_heap_size[${2}]}" >> ${filename};
     36        echo "${1}" >  ${filename};
     37        echo "${2} ${3}" >> ${filename};
     38        echo "${iways[${4}]} ${isets[${4}]} ${iwords[${4}]}" >> ${filename};
     39        echo "${dways[${4}]} ${dsets[${4}]} ${dwords[${4}]}" >> ${filename};
     40        echo "${5} ${6} ${7}" >> ${filename};
     41        echo "${memc_nways[${4}]} ${memc_nsets[${4}]} ${memc_words[${4}]} ${memc_heap_size[${4}]}" >> ${filename};
    3442}
    3543
     
    4149        echo ${filename};
    4250
    43         echo "${nb_proc[3]}" > ${filename};
     51        echo "${nb_proc[3]}"  >  ${filename};
     52        echo "${nb_cpu_by_cache[3]} ${nb_cache[3]}" >> ${filename};
    4453        echo "${iways[${archi}]} ${isets[${archi}]} ${iwords[${archi}]}" >> ${filename};
    4554        echo "${dways[${archi}]} ${dsets[${archi}]} ${dwords[${archi}]}" >> ${filename};
     
    5059gen_default ${archi_default};
    5160
    52 nb_archi=${#iways[*]};
     61if test ${gen_cfg} -ne 0; then
     62    nb_archi=${#iways[*]};
     63   
     64    num_archi=0;
     65    while test ${num_archi} -lt ${nb_archi}; do
     66        num_proc=${nb_proc[0]};
     67        while test ${num_proc} -le ${nb_proc[1]}; do
     68            num_cpu_by_cache=${nb_cpu_by_cache[0]};
     69            while test ${num_cpu_by_cache} -le ${nb_cpu_by_cache[1]}; do
    5370
    54 num_archi=0;
    55 while test ${num_archi} -lt ${nb_archi}; do
    56     num_proc=${nb_proc[0]};
    57     while test ${num_proc} -le ${nb_proc[1]}; do
    58         num_words=${wnwords[0]};
    59         while test ${num_words} -le ${wnwords[1]}; do
    60             num_lines=${wnlines[0]};
    61             while test ${num_lines} -le ${wnlines[1]}; do
    62                 num_timeout=${wtimeout[0]};
    63                 while test ${num_timeout} -le ${wtimeout[1]}; do
     71                if test $((${num_proc} * ${num_cpu_by_cache})) -le ${nb_cpu_by_cache[1]}; then
    6472
    65                     gen_file ${num_proc} ${num_archi} ${num_words} ${num_lines} ${num_timeout};
     73                num_cache=${nb_cache[0]};
     74                while test ${num_cache} -le ${nb_cache[1]}; do
     75               
     76                    if test ${num_cache} -ge ${num_cpu_by_cache}; then
     77                    if test ${num_cpu_by_cache} -ne 1 -o ${num_cache} -eq 1; then
    6678
    67                     num_timeout=$((${num_timeout} ${wtimeout[2]}));
     79                    num_words=${wnwords[0]};
     80                    while test ${num_words} -le ${wnwords[1]}; do
     81                        num_lines=${wnlines[0]};
     82                        while test ${num_lines} -le ${wnlines[1]}; do
     83                            num_timeout=${wtimeout[0]};
     84                            while test ${num_timeout} -le ${wtimeout[1]}; do
     85                               
     86                                gen_file ${num_proc} ${num_cpu_by_cache} ${num_cache} ${num_archi} ${num_words} ${num_lines} ${num_timeout};
     87                               
     88                                num_timeout=$((${num_timeout} ${wtimeout[2]}));
     89                            done;
     90                            num_lines=$((${num_lines} ${wnlines[2]}));
     91                        done;
     92                        num_words=$((${num_words} ${wnwords[2]}));
     93                    done;
     94                    fi;
     95                    fi;
     96                    num_cache=$((${num_cache} ${nb_cache[2]}));
    6897                done;
    69                 num_lines=$((${num_lines} ${wnlines[2]}));
     98                fi;
     99                num_cpu_by_cache=$((${num_cpu_by_cache} ${nb_cpu_by_cache[2]}));
    70100            done;
    71             num_words=$((${num_words} ${wnwords[2]}));
     101            num_proc=$((${num_proc} ${nb_proc[2]}));
    72102        done;
    73         num_proc=$((${num_proc} ${nb_proc[2]}));
     103        num_archi=$((${num_archi}+1));
    74104    done;
    75     num_archi=$((${num_archi}+1));
    76 done;
     105fi;
    77106
    78 
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/segmentation.h

    r134 r140  
    3535#define MC_M_SIZE       0x000F0000
    3636
     37#define MC_R_BASE       0x20200000
     38#define MC_R_SIZE       0x00000008
     39
     40#define MC_U_BASE       0x30000000
     41#define MC_U_SIZE       0x000F0000
     42
    3743//////////////////////////////////////////////////////////
    3844//      System devices
     
    5157#define C_PROC_SIZE     0x00000010
    5258#define C_PROC_SPAN     0x01000000
    53 
    54 #define MC_R_BASE       0x20200000
    55 #define MC_R_SIZE       0x00000008
    56 
    57 //#define C_MC_M_BASE   0x00200000
    58 //#define C_MC_M_SIZE   0x00000008
    59 
    60 //#define XRAM_BASE     0xB0200000
    61 //#define XRAM_SIZE     0x00000008
    62 
    63 //#define CLEANUP_OFFSET  0x20200000
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/Makefile

    r134 r140  
    1 ADD_OBJS        =       stdio.o stdlib.o exception.o system.o \
    2                         $(patsubst %.c,%.o,$(wildcard *.c)) \
    3                         $(patsubst common/%.c,common/%.o,$(wildcard common/*.c)) \
    4                         $(patsubst irq/%.c,irq/%.o,$(wildcard irq/*.c)) \
    5                         $(patsubst benchmark/%.c,benchmark/%.o,$(wildcard benchmark/*.c)) \
     1ADD_OBJS        =       \
     2                        $(patsubst self_code_modifying/%.c,self_code_modifying/%.o,$(wildcard self_code_modifying/*.c))  \
    63                        $(patsubst matrix_multiplication/%.c,matrix_multiplication/%.o,$(wildcard matrix_multiplication/*.c)) \
    74                        $(patsubst sort/%.c,sort/%.o,$(wildcard sort/*.c)) \
    8                         $(patsubst dhrystone/%.c,dhrystone/%.o,$(wildcard dhrystone/*.c))
     5                        $(patsubst dhrystone/%.c,dhrystone/%.o,$(wildcard dhrystone/*.c)) \
     6                        $(patsubst benchmark/%.c,benchmark/%.o,$(wildcard benchmark/*.c)) \
     7                        $(patsubst irq/%.c,irq/%.o,$(wildcard irq/*.c)) \
     8                        $(patsubst common/%.c,common/%.o,$(wildcard common/*.c)) \
     9                        $(patsubst %.c,%.o,$(wildcard *.c)) \
     10                        stdio.o stdlib.o exception.o system.o
     11
    912
    1013ADD_CFLAGS      =
     14ADD_LDFLAGS     =
    1115SOCLIB          ?=      $(shell soclib-cc --getpath)
    1216
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark.c

    r134 r140  
    66void benchmark (void)
    77{
    8   /* if(procnum() != 0) */
    9   /*   EXIT(0); */
    10 
    11   int result = 0;
     8  int result      = 0;
     9  int num_cpu     = procnum();
    1210  int cycle_begin = cycle_begin = cpu_cycles();
    13 
    14   switch (procnum())
    15     {
    16     default :
    17       {
     11 
     12  if (num_cpu < BENCHMARK_NB_THREAD)
     13   switch (num_cpu)
     14     {
     15     default :
     16        {
    1817#if BENCHMARK_MATRIX_MULTIPLICATION_MT
    19         int result_mm_mt = benchmark_matrix_multiplication_mt();
    20         result += result_mm_mt;
     18          int result_mm_mt = benchmark_matrix_multiplication_mt();
     19          result += result_mm_mt;
    2120#endif
    2221#if BENCHMARK_DHRYSTONE
    23         int result_dhrystone = benchmark_dhrystone();
    24         result += result_dhrystone;
     22          int result_dhrystone = benchmark_dhrystone();
     23          result += result_dhrystone;
    2524#endif
    26 #if BENCHMARK_SORT
    27         int result_sort = benchmark_sort();
    28         result += result_sort;
     25#if BENCHMARK_SORT_ALL
     26          int result_sort_all = benchmark_sort_all();
     27          result += result_sort_all;
     28#endif
     29#if BENCHMARK_SORT_BUBBLE
     30          int result_sort_bubble = benchmark_sort_bubble();
     31          result += result_sort_bubble;
     32#endif
     33#if BENCHMARK_SORT_INSERTION
     34          int result_sort_insertion = benchmark_sort_insertion();
     35          result += result_sort_insertion;
     36#endif
     37#if BENCHMARK_SORT_SELECTION
     38          int result_sort_selection = benchmark_sort_selection();
     39          result += result_sort_selection;
     40#endif
     41#if BENCHMARK_SORT_SHELL
     42          int result_sort_shell = benchmark_sort_shell();
     43          result += result_sort_shell;
    2944#endif
    3045#if BENCHMARK_MATRIX_MULTIPLICATION_ST
    31         int result_mm_st = benchmark_matrix_multiplication_st();
    32         result += result_mm_st;
     46          int result_mm_st = benchmark_matrix_multiplication_st();
     47          result += result_mm_st;
    3348#endif
    34 
    35         printf("\n");
    36         printf("--------------------------------\n");
    37         printf( "Partial results :\n");
     49#if BENCHMARK_SELF_CODE_MODIFYING
     50          int result_self_code_modifying = benchmark_self_code_modifying();
     51          result += result_self_code_modifying;
     52#endif
     53         
     54          printf("\n");
     55          printf("--------------------------------\n");
     56          printf( "Partial results :\n");
    3857#if BENCHMARK_MATRIX_MULTIPLICATION_MT
    39         printf(" * MM MT           : %d\n",result_mm_mt);
     58          printf(" * MM MT               : %d\n",result_mm_mt);
    4059#endif
    4160#if BENCHMARK_DHRYSTONE
    42         printf(" * DHRYSTONE       : %d\n",result_dhrystone);
     61          printf(" * DHRYSTONE           : %d\n",result_dhrystone);
    4362#endif
    44 #if BENCHMARK_SORT
    45         printf(" * SORT            : %d\n",result_sort);
     63#if BENCHMARK_SORT_ALL
     64          printf(" * SORT_ALL            : %d\n",result_sort_all);
     65#endif
     66#if BENCHMARK_SORT_BUBBLE
     67          printf(" * SORT_BUBBLE         : %d\n",result_sort_bubble);
     68#endif
     69#if BENCHMARK_SORT_INSERTION
     70          printf(" * SORT_INSERTION      : %d\n",result_sort_insertion);
     71#endif
     72#if BENCHMARK_SORT_SELECTION
     73          printf(" * SORT_SELECTION      : %d\n",result_sort_selection);
     74#endif
     75#if BENCHMARK_SORT_SHELL
     76          printf(" * SORT_SHELL          : %d\n",result_sort_shell);
    4677#endif
    4778#if BENCHMARK_MATRIX_MULTIPLICATION_ST
    48         printf(" * MM ST           : %d\n",result_mm_st);
     79          printf(" * MM ST               : %d\n",result_mm_st);
    4980#endif
    50         printf("--------------------------------\n");
    51        break;
     81#if BENCHMARK_SELF_CODE_MODIFYING
     82          printf(" * SELF_CODE_MODIFYING : %d\n",result_self_code_modifying);
     83#endif
     84          printf("--------------------------------\n");
     85          break;
     86        }
    5287      }
    53     }
    5488
    5589  printf("\n");
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark.h

    r134 r140  
    55
    66void benchmark                         (void);
    7 int  benchmark_sort                    (void);
     7int  benchmark_sort_all                (void);
     8int  benchmark_sort_bubble             (void);
     9int  benchmark_sort_insert             (void);
     10int  benchmark_sort_selection          (void);
     11int  benchmark_sort_shell              (void);
    812int  benchmark_dhrystone               (void);
    913int  benchmark_matrix_multiplication_st(void);
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_matrix_multiplication.c

    r134 r140  
    127127  /* matrix_multiplication_print(matrix_local_d, size); */
    128128 
     129#if VERIFICATION_MATRIX_MULTIPLICATION
    129130  printf(" * Verification... ");
    130131 
    131132  benchmark_matrix_validation (matrix_local_d, size);
     133#endif
    132134 
    133135  printf(" * Free...\n");
     
    230232  if (matrix_nb_thread_stop == matrix_nb_thread_start)
    231233    {
     234#if VERIFICATION_MATRIX_MULTIPLICATION
    232235      printf(" * Verification... ");
    233236
    234237      benchmark_matrix_validation (matrix_global_d, size);
     238#endif
    235239     
    236240      printf(" * Free...\n");
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_sort.c

    r134 r140  
    99static uint32_t sort_lock;
    1010
    11 int _benchmark_sort (unsigned int size)
     11int _benchmark_sort (sort_t sort_type,
     12                     unsigned int size)
     13{
     14  printf(" * Size : %d\n",size);
     15
     16  unsigned int* SortArray;
     17 
     18  int cycle_begin;
     19
     20  int num_cpu=procnum();
     21 
     22  printf(" * Algo : %s\n",sort_str(sort_type));
     23 
     24  printf("   * Init...\n");
     25 
     26  lock_lock(&sort_lock);
     27  SortArray = (unsigned int*) malloc(size*sizeof(unsigned int));
     28  lock_unlock(&sort_lock);
     29 
     30  unsigned int seed = num_cpu;
     31  int i;
     32  for (i=0; i<size; ++i)
     33    {
     34      seed = seed * 1103515245 + 12345;
     35      SortArray[i] = seed&0xff;
     36    }
     37  printf("   * Sort... \n");
     38 
     39  cycle_begin = cpu_cycles();
     40  sort((unsigned int *) (SortArray), (unsigned int) size, sort_type);
     41  int cycle_exec = cpu_cycles()-cycle_begin;
     42 
     43  printf("   * Executed in %d cycles\n",cycle_exec);
     44 
     45  int result = cycle_exec;
     46 
     47#if VERIFICATION_SORT     
     48  printf("   * Verification... ");
     49 
     50  for (i = 1; i < size; i++)
     51    {
     52      /* printf("%d ",SortArray[i-1]); */
     53     
     54      if (SortArray[i] < SortArray[i-1])
     55        {
     56          printf("KO !!!\n");
     57          EXIT(1);
     58        }
     59    }
     60  printf("OK\n");
     61#endif
     62 
     63  free (SortArray);
     64
     65  return result;
     66}
     67
     68int _benchmark_sort_all (unsigned int size)
     69{
     70  printf("\n");
     71  printf("================================\n");
     72  printf("Benchmark Sort (ALL)\n");
     73  printf("================================\n");
     74  printf("\n");
     75
     76  int result = 0;
     77  int num_cpu=procnum();
     78  sort_t _sort_type;
     79  const sort_t nb_sort_type = 4;
     80 
     81  for (_sort_type=0; _sort_type < nb_sort_type; _sort_type++)
     82    result += _benchmark_sort((_sort_type+num_cpu)%nb_sort_type,size);
     83 
     84  return result;
     85}
     86
     87int _benchmark_sort_one (sort_t sort_type,
     88                         unsigned int size)
    1289{
    1390  printf("\n");
     
    1794  printf("\n");
    1895
    19   printf(" * Size : %d\n",size);
    20 
    21   unsigned int* SortArray;
    22  
    23   int cycle_begin, result;
    24 
    25   result = 0;
    26  
    27   int p=procnum();
    28  
    29   sort_t _sort_type;
    30   const sort_t nb_sort_type = 4;
    31  
    32   for (_sort_type=0; _sort_type < nb_sort_type; _sort_type++)
    33     {
    34       sort_t sort_type = (_sort_type+p)%nb_sort_type;
    35      
    36       printf(" * Algo : %s\n",sort_str(sort_type));
    37      
    38       printf("   * Init...\n");
    39      
    40       lock_lock(&sort_lock);
    41       SortArray = (unsigned int*) malloc(size*sizeof(unsigned int));
    42       lock_unlock(&sort_lock);
    43      
    44       unsigned int seed = p;
    45       int i;
    46       for (i=0; i<size; ++i)
    47         {
    48           seed = seed * 1103515245 + 12345;
    49           SortArray[i] = seed&0xff;
    50         }
    51       printf("   * Sort... \n");
    52      
    53       cycle_begin = cpu_cycles();
    54       sort((unsigned int *) (SortArray), (unsigned int) size, sort_type);
    55       int cycle_exec = cpu_cycles()-cycle_begin;
    56      
    57       printf("   * Executed in %d cycles\n",cycle_exec);
    58      
    59       result += cycle_exec;
    60      
    61       printf("   * Verification... ");
    62      
    63       for (i = 1; i < size; i++)
    64         {
    65           /* printf("%d ",SortArray[i-1]); */
    66          
    67           if (SortArray[i] < SortArray[i-1])
    68             {
    69               printf("KO !!!\n");
    70               EXIT(1);
    71             }
    72         }
    73       printf("OK\n");
    74 
    75       free (SortArray);
    76 
    77     }
    78  
    79   return result;
     96  return _benchmark_sort(sort_type,size);
    8097}
    8198
    82 int benchmark_sort (void) { return _benchmark_sort(SORT_SIZE); }
    83 
    84  
     99int benchmark_sort_all       (void) { return _benchmark_sort_all(SORT_ALL_SIZE); }
     100int benchmark_sort_bubble    (void) { return _benchmark_sort_one(SORT_BUBBLE   ,SORT_BUBBLE_SIZE   ); }
     101int benchmark_sort_insertion (void) { return _benchmark_sort_one(SORT_INSERTION,SORT_INSERTION_SIZE); }
     102int benchmark_sort_selection (void) { return _benchmark_sort_one(SORT_SELECTION,SORT_SELECTION_SIZE); }
     103int benchmark_sort_shell     (void) { return _benchmark_sort_one(SORT_SHELL    ,SORT_SHELL_SIZE    ); }
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/common/common.c

    r134 r140  
    4141    }
    4242
     43  pause();
     44 
    4345  while(1);
    4446}
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/define.h

    r134 r140  
    33
    44// List of benchmark
     5#define BENCHMARK_NB_THREAD                   4
     6
    57#define BENCHMARK_DHRYSTONE                   0
    6 #define BENCHMARK_SORT                        0
     8#define BENCHMARK_SORT_ALL                    0
     9#define BENCHMARK_SORT_BUBBLE                 0
     10#define BENCHMARK_SORT_INSERTION              0
     11#define BENCHMARK_SORT_SELECTION              0
     12#define BENCHMARK_SORT_SHELL                  1
    713#define BENCHMARK_MATRIX_MULTIPLICATION_ST    0
    8 #define BENCHMARK_MATRIX_MULTIPLICATION_MT    1
     14#define BENCHMARK_MATRIX_MULTIPLICATION_MT    0
     15#define BENCHMARK_SELF_CODE_MODIFYING         0
    916
    1017#define VERBOSE_SORT                          0
    1118
     19#define VERIFICATION_SORT                     0
     20#define VERIFICATION_MATRIX_MULTIPLICATION    0
     21
    1222// Benchmark size
    1323#define DHRYSTONE_NB_RUNS                     5000
    14 #define SORT_SIZE                             850
     24#define SORT_ALL_SIZE                         1000
     25#define SORT_BUBBLE_SIZE                      1500
     26#define SORT_INSERTION_SIZE                   2300
     27#define SORT_SELECTION_SIZE                   1600
     28#define SORT_SHELL_SIZE                       4000
    1529#define MATRIX_MULTIPLICATION_ST_SIZE         50
    16 #define MATRIX_MULTIPLICATION_MT_SIZE         75
     30#define MATRIX_MULTIPLICATION_MT_SIZE         96
    1731#define MATRIX_MULTIPLICATION_MT_LOCK_BY_LINE 1
     32#define SELF_CODE_MODIFYING_NB_RUNS           10
    1833
    1934// Timer configuration
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/dhrystone/dhry21a.c

    r134 r140  
    7676  DOUBLE   dtime();
    7777
    78         One_Fifty       Int_1_Loc;
    79   REG   One_Fifty       Int_2_Loc;
     78        One_Fifty       Int_1_Loc = 0;
     79  REG   One_Fifty       Int_2_Loc = 0;
    8080        One_Fifty       Int_3_Loc;
    8181  REG   char            Ch_Index;
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/matrix_multiplication/matrix_multiplication.c

    r134 r140  
    22#include "stdio.h"
    33#include "system.h"
     4#include "stdint.h"
    45
    56void matrix_multiplication_st (int ** a,
     
    89                               unsigned int n)
    910{
    10   int x, y;
     11  uint32_t x, y;
    1112
    1213  for (x=0; x<n; ++x)
     
    1617      for (y=0; y<n; ++y)
    1718        {
    18           int i;
     19          uint32_t i;
    1920
    2021          int tmp = 0;
     
    2829}
    2930
    30 static int lock;
    31 static int next;
     31static uint32_t lock;
     32static uint32_t next;
    3233
    3334void matrix_multiplication_mt (int ** a,
     
    3738                               int lock_by_line)
    3839{
    39   int x, y;
     40  uint32_t x, y;
    4041
    4142  while (1)
  • trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/top.cpp

    r137 r140  
    3131#  define PARAM_VCI                         4,8,32,1,1,1,8,4,4,1
    3232
     33#  define USE_OLD_XCACHE                    0
     34#  define USE_VGMN                          1
    3335#  define NB_PROC_MIN                       1
    3436#  define NB_PROC_MAX                       15
    35 //                                          min_latency, fifo_depth
     37//                                          fifo_depth
    3638#  define PARAM_RING_P                      2
    3739#  define PARAM_RING_C                      2
    3840#  define PARAM_RING_X                      2
    3941//                                          pti    , hwi    , wti, irq
    40 #  define PARAM_XICU                        nb_proc, nb_proc, 0  , nb_proc
     42#  define PARAM_XICU                        nb_proc*nb_cpu_by_cache, nb_proc*nb_cpu_by_cache, 0  , nb_proc*nb_cpu_by_cache
     43//#define PARAM_XICU                        nb_proc, nb_proc, 0  , nb_proc
    4144
    4245// * Debug
     
    4649                                           
    4750// * Simulation                             
    48 #  define FILE_DEFAULT                      "configuration/default.cfg"
     51#  define CONFIG_DEFAULT                      "configuration/default.cfg"
    4952#  define NCYCLES_DEFAULT                   0
    5053#  define SOFT_DEFAULT                      "soft/bin.soft"
     
    5356void usage (char * funcname)
    5457{
    55   std::cout << funcname << " [nb_cycle [file [soft]]] " << std::endl;
    56   std::cout << " * nb_cycle : number of simulated cycle, if 0 then no stop condition. (default : " << NCYCLES_DEFAULT << " cycle(s))" << std::endl;
    57   std::cout << " * file     : Configuration file : nb_proc, iways, isets, iwords, dways, dsets, dwords, wnwords, wnlines, wtimeout, memc_nways, memc_nsets, memc_words, memc_heap_size. (default : " << FILE_DEFAULT << " cycle(s))" << std::endl;
    58   std::cout << " * soft     : software executed by this platforms. (default : \"" << SOFT_DEFAULT << "\")" << std::endl;
     58  std::cout << funcname << " [option] " << std::endl;
     59  std::cout << " * -NCYCLES int : number of simulated cycle, if 0 then no stop condition." << std::endl;
     60  std::cout << "                  default : " << NCYCLES_DEFAULT << " cycle(s)" << std::endl;
     61  std::cout << " * -CFG string  : configuration file" << std::endl;
     62  std::cout << "                    - nb_proc," << std::endl;
     63  std::cout << "                    - nb_cpu_by_cache, nb_dcache," << std::endl;
     64  std::cout << "                    - iways, isets, iwords," << std::endl;
     65  std::cout << "                    - dways, dsets, dwords," << std::endl;
     66  std::cout << "                    - wnwords, wnlines, wtimeout," << std::endl;
     67  std::cout << "                    - memc_nways, memc_nsets, memc_words, memc_heap_size." << std::endl;
     68  std::cout << "                  default : \"" << CONFIG_DEFAULT << "\"" << std::endl;
     69  std::cout << " * -SOFT string : software executed by this platform." << std::endl;
     70  std::cout << "                  default : \"" << SOFT_DEFAULT << "\"" << std::endl;
    5971
    6072  exit(1);
     
    6375int _main(int argc, char *argv[])
    6476{
    65         if ((argc < 1) or (argc > 4))
    66           {
    67             std::cout << "Invalid parameters number." << std::endl;
    68             usage(argv[0]);
    69           }
    70 
    71 #if not SOCVIEW
    72         int  ncycles = 0;
    73 
    74         if (argc >= 2)
    75           ncycles = std::atoi(argv[1]);
    76         else
    77           ncycles = NCYCLES_DEFAULT;
     77        int    ncycles = NCYCLES_DEFAULT;
     78        char * config  = CONFIG_DEFAULT;
     79        char * soft    = SOFT_DEFAULT;
     80
     81        if (argc > 1)
     82          {
     83            for( int n=1 ; n<argc ; n=n+2 )
     84              {
     85                if( (strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc) )
     86                  {
     87                    ncycles = atoi(argv[n+1]);
     88                  }
     89                else if( (strcmp(argv[n],"-CFG") == 0) && (n+1<argc) )
     90                  {
     91                    // strcpy(config, argv[n+1]);
     92                    config = argv[n+1];
     93                  }
     94                else if( (strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) )
     95                  {
     96                    // strcpy(soft, argv[n+1]);
     97                    soft = argv[n+1];
     98                  }
     99                else
     100                  {
     101                    usage(argv[0]);
     102                  }
     103              }
     104          }
    78105
    79106        if (ncycles == 0)
    80107          ncycles = -1;
    81 #endif
    82108
    83109        uint32_t nb_proc;
     110        uint32_t nb_cpu_by_cache;
     111        uint32_t nb_dcache;
    84112        uint32_t iways, isets, iwords;
    85113        uint32_t dways, dsets, dwords;
     
    88116
    89117        std::ifstream inFile;
    90         const char * filename = (argc>=3)?argv[2]:FILE_DEFAULT;
     118        const char * filename = config;
    91119
    92120        inFile.open(filename);
     
    102130        nb_proc         =std::atoi(str.c_str());
    103131        if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);}
     132        nb_cpu_by_cache =std::atoi(str.c_str());
     133        if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);}
     134        nb_dcache       =std::atoi(str.c_str());
     135        if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);}
    104136        iways           =std::atoi(str.c_str());
    105137        if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);}
     
    128160        memc_heap_size  =std::atoi(str.c_str());
    129161
    130         if ((nb_proc<NB_PROC_MIN) or
    131             (nb_proc>NB_PROC_MAX))
     162        if (((nb_proc*nb_cpu_by_cache)<NB_PROC_MIN) or
     163            ((nb_proc*nb_cpu_by_cache)>NB_PROC_MAX))
    132164          {
    133165            std::cout << "Parameters nb_proc is out of bound." << std::endl;
     
    135167          }
    136168
    137         char * soft;
    138 
    139         if (argc >= 4)
    140           soft = argv[3];
    141         else
    142           soft = SOFT_DEFAULT;
    143 
    144169        std::cout << "  * Parameters : " << std::endl;
    145170        std::cout << "    * nb_proc          : " << nb_proc          << std::endl;
     171        std::cout << "    * nb_cpu_by_cache  : " << nb_cpu_by_cache  << std::endl;
     172        std::cout << "    * nb_dcache        : " << nb_dcache        << std::endl;
    146173        std::cout << "    * iways            : " << iways            << std::endl;
    147174        std::cout << "    * isets            : " << isets            << std::endl;
     
    180207        maptabp.add(Segment("mc_r"     , MC_R_BASE     , MC_R_SIZE     , IntTab(2), false, true, IntTab(0)));
    181208        maptabp.add(Segment("mc_m"     , MC_M_BASE     , MC_M_SIZE     , IntTab(2), true));
    182         // maptabp.add(Segment("ptba"     , PTD_ADDR      , TAB_SIZE      , IntTab(2), true));
     209        // maptabp.add(Segment("mc_u"     , MC_U_BASE     , MC_U_SIZE     , IntTab(2), false));
     210      //maptabp.add(Segment("ptba"     , PTD_ADDR      , TAB_SIZE      , IntTab(2), true));
    183211        maptabp.add(Segment("xicu"     , XICU_BASE     , XICU_SIZE     , IntTab(3), false));
    184212        maptabp.add(Segment("simhelper", SIMHELPER_BASE, SIMHELPER_SIZE, IntTab(4), false));
     
    187215
    188216        soclib::common::MappingTable maptabc(32, IntTab(8), IntTab(8), 0x00300000);
     217        // for (uint32_t i=0; i<nb_proc; ++i)
     218        //   for (uint32_t j=0; j<nb_cpu_by_cache; ++j)
     219        //   {
     220        //     std::ostringstream str;
     221        //     str << "c_proc_" << i << "_" << j;
     222        //     maptabc.add(Segment(str.str().c_str(), C_PROC_BASE+(i*nb_cpu_by_cache+j)*C_PROC_SPAN, C_PROC_SIZE , IntTab(i), false, true, IntTab(i)));
     223        //   }
    189224        for (uint32_t i=0; i<nb_proc; ++i)
    190225        {
     
    195230        maptabc.add(Segment("mc_r"    , MC_R_BASE  , MC_R_SIZE   , IntTab(nb_proc), false, false));
    196231        maptabc.add(Segment("mc_m"    , MC_M_BASE  , MC_M_SIZE   , IntTab(nb_proc), false, false));
     232        // maptabc.add(Segment("mc_u"    , MC_U_BASE  , MC_U_SIZE   , IntTab(nb_proc), false, false));
    197233        maptabc.add(Segment("reset"   , RESET_BASE , RESET_SIZE  , IntTab(nb_proc), false, false));
    198234        maptabc.add(Segment("excep"   , EXCEP_BASE , EXCEP_SIZE  , IntTab(nb_proc), false, false));
    199235        maptabc.add(Segment("text"    , TEXT_BASE  , TEXT_SIZE   , IntTab(nb_proc), false, false));
    200         // maptabc.add(Segment("ptba"    , PTD_ADDR   , TAB_SIZE    , IntTab(nb_proc), false, false));
     236      //maptabc.add(Segment("ptba"    , PTD_ADDR   , TAB_SIZE    , IntTab(nb_proc), false, false));
    201237
    202238        std::cout << maptabc << std::endl;
     
    204240        soclib::common::MappingTable maptabx(32, IntTab(8), IntTab(8), 0x00300000);
    205241        maptabx.add(Segment("xram" , MC_M_BASE , MC_M_SIZE , IntTab(0), false));
     242        // maptabx.add(Segment("uram" , MC_U_BASE , MC_U_SIZE , IntTab(0), false));
    206243        maptabx.add(Segment("reset", RESET_BASE, RESET_SIZE, IntTab(0), false));
    207244        maptabx.add(Segment("excep", EXCEP_BASE, EXCEP_SIZE, IntTab(0), false));
     
    215252        sc_signal<bool> signal_resetn("resetn");
    216253   
    217         sc_signal<bool> ** signal_proc_it = soclib::common::alloc_elems<sc_signal<bool> >("proc_it", nb_proc, 6);
     254        sc_signal<bool> *** signal_proc_it = soclib::common::alloc_elems<sc_signal<bool> >("proc_it", nb_proc, nb_cpu_by_cache, 6);
    218255
    219256        soclib::caba::VciSignals<vci_param> * signal_vci_ini_rw_proc = soclib::common::alloc_elems<soclib::caba::VciSignals<vci_param> >("vci_ini_rw_proc", nb_proc);
     
    236273        soclib::caba::VciSignals<vci_param> signal_vci_tgt_cleanup_memc("vci_tgt_cleanup_memc");
    237274
    238         sc_signal<bool> * signal_tty_irq = soclib::common::alloc_elems<sc_signal<bool> >("signal_tty_irq", nb_proc);
     275        sc_signal<bool> ** signal_tty_irq = soclib::common::alloc_elems<sc_signal<bool> >("signal_tty_irq", nb_proc, nb_cpu_by_cache);
    239276
    240277        soclib::common::Loader loader(soft);
     
    245282        for (uint32_t i=0; i<nb_proc; ++i)
    246283          {
     284            uint32_t num_cpu = i*nb_cpu_by_cache;
     285
    247286            std::ostringstream str;
    248             str << "proc_" << i;
    249 
    250             proc[i] = new soclib::caba::VciCcXCacheWrapperV4<vci_param, proc_iss > (str.str().c_str(), i, maptabp, maptabc, IntTab(i),IntTab(i),IntTab(i)
     287            str << "proc_" << num_cpu;
     288
     289            proc[i] = new soclib::caba::VciCcXCacheWrapperV4<vci_param, proc_iss > (str.str().c_str(), num_cpu, maptabp, maptabc, IntTab(i),IntTab(i),IntTab(i)
     290#if USE_OLD_XCACHE
    251291                                                                                    ,iways, isets, iwords
    252292                                                                                    ,dways, dsets, dwords
    253                                                                                     ,wnwords, wnlines, wtimeout
     293#else
     294                                                                                    ,nb_cpu_by_cache   
     295                                                                                    ,nb_dcache
     296                                                                                    ,iways*nb_cpu_by_cache, isets, iwords
     297                                                                                    ,dways*nb_cpu_by_cache, dsets, dwords
     298                                                                                    ,wnwords, wnlines*nb_cpu_by_cache, wtimeout
     299#endif
    254300                                                                                    );
    255301
     
    267313        //                                  x_init    c_init          p_tgt     c_tgt
    268314        soclib::caba::VciMemCacheV4<vci_param>
    269           memc("memc",maptabp,maptabc,maptabx,IntTab(0),IntTab(nb_proc),IntTab(2),IntTab(nb_proc), memc_nways, memc_nsets, memc_words, memc_heap_size);
     315        memc("memc",maptabp,maptabc,maptabx,IntTab(0),IntTab(nb_proc),IntTab(2),IntTab(nb_proc), memc_nways, memc_nsets, memc_words, memc_heap_size);
    270316
    271317        std::vector<std::string> tty_name;
    272         for (uint32_t i=0; i<nb_proc; ++i)
     318        for (uint32_t i=0; i<nb_proc*nb_cpu_by_cache; ++i)
    273319          {
    274320            std::ostringstream str;
     
    308354          {
    309355            proc[i]->p_clk(signal_clk); 
    310             proc[i]->p_resetn(signal_resetn); 
    311             proc[i]->p_irq[0](signal_proc_it[i][0]);
    312             proc[i]->p_irq[1](signal_proc_it[i][1]);
    313             proc[i]->p_irq[2](signal_proc_it[i][2]);
    314             proc[i]->p_irq[3](signal_proc_it[i][3]);
    315             proc[i]->p_irq[4](signal_proc_it[i][4]);
    316             proc[i]->p_irq[5](signal_proc_it[i][5]);
     356            proc[i]->p_resetn(signal_resetn);
     357            for (uint32_t j=0; j<nb_cpu_by_cache; ++j)
     358              {
     359                proc[i]->p_irq[j][0](signal_proc_it[i][j][0]);
     360                proc[i]->p_irq[j][1](signal_proc_it[i][j][1]);
     361                proc[i]->p_irq[j][2](signal_proc_it[i][j][2]);
     362                proc[i]->p_irq[j][3](signal_proc_it[i][j][3]);
     363                proc[i]->p_irq[j][4](signal_proc_it[i][j][4]);
     364                proc[i]->p_irq[j][5](signal_proc_it[i][j][5]);
     365              }
    317366            proc[i]->p_vci_ini_rw(signal_vci_ini_rw_proc[i]);
    318367            proc[i]->p_vci_ini_c(signal_vci_ini_c_proc[i]);
     
    328377        tty.p_vci(signal_vci_tgt_tty);
    329378        for (uint32_t i=0; i<nb_proc; ++i)
    330           tty.p_irq[i](signal_tty_irq[i]);
     379          for (uint32_t j=0; j<nb_cpu_by_cache; ++j)
     380            tty.p_irq[i*nb_cpu_by_cache+j](signal_tty_irq[i][j]);
    331381
    332382        xicu.p_clk(signal_clk);
     
    334384        xicu.p_vci(signal_vci_tgt_xicu);
    335385        for (uint32_t i=0; i<nb_proc; ++i)
    336         {
    337           xicu.p_hwi[i](signal_tty_irq[i]);
    338           xicu.p_irq[i](signal_proc_it[i][0]);
    339         }
     386          for (uint32_t j=0; j<nb_cpu_by_cache; ++j)
     387          {
     388            xicu.p_hwi[i*nb_cpu_by_cache+j](signal_tty_irq[i][j]);
     389            xicu.p_irq[i*nb_cpu_by_cache+j](signal_proc_it[i][j][0]);
     390          }
    340391
    341392        simhelper.p_clk(signal_clk);
     
    392443        debug();
    393444#elif DEBUG_TOP
    394         for (int32_t i=0; i<ncycles; ++i)
     445
     446        uint32_t num_cycle=0;
     447        while(1)
    395448          {
    396449            std::cout << std::endl
    397                       << std::dec << "===== [ cycle " << i << " ]======" << std::endl
     450                      << std::dec << "===== [ cycle " << num_cycle << " ]======" << std::endl
    398451                      << std::endl;
    399452           
     
    402455            // for (uint32_t i=0; i<nb_proc; ++i)
    403456            //   proc[i]->print_trace(1);
     457            num_cycle ++;
    404458          }
    405459#else
     
    418472          proc[i]->print_stats();
    419473
    420         soclib::common::dealloc_elems<sc_signal<bool>                     >(signal_tty_irq         , nb_proc);
     474        soclib::common::dealloc_elems<sc_signal<bool>                     >(signal_tty_irq         , nb_proc, nb_cpu_by_cache);
    421475        soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_tgt_proc    , nb_proc);
    422476        soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_ini_c_proc  , nb_proc);
    423477        soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_ini_rw_proc , nb_proc);
    424         soclib::common::dealloc_elems<sc_signal<bool>                     >(signal_proc_it         , nb_proc, 6);
     478        soclib::common::dealloc_elems<sc_signal<bool>                     >(signal_proc_it         , nb_proc, nb_cpu_by_cache, 6);
    425479
    426480        for (uint32_t i=0; i<nb_proc; ++i)
  • trunk/platforms/tsarv4_dspin_generic_32/tsarv4_dspin_generic_32_top.cpp

    r134 r140  
    370370    // IRQ signals (one signal per proc)
    371371
    372     sc_signal<bool>***  signal_proc_it =
    373         alloc_elems<sc_signal<bool> >("signal_proc_it", xmax, ymax, nprocs);
     372    sc_signal<bool>**** signal_proc_it =
     373      alloc_elems<sc_signal<bool> >("signal_proc_it", 1,xmax, ymax, nprocs);
    374374
    375375    sc_signal<bool>*    signal_irq_mtty =
     
    548548                    IntTab(cluster(x,y),PROC_SRCID+p),  // SRCID_C
    549549                    IntTab(cluster(x,y),PROC_SRCID+p),  // TGTID_C
     550                    1,1,
    550551                    4,64,16,4,64,16,                    // Icache and Dcache sizes
    551552                    4,8,16);
     
    743744                proc[x][y][p]->p_vci_ini_c              (signal_vci_ini_c_proc[x][y][p]);
    744745                proc[x][y][p]->p_vci_tgt                (signal_vci_tgt_c_proc[x][y][p]);
    745                 proc[x][y][p]->p_irq[0]                 (signal_proc_it[x][y][p]);
     746                proc[x][y][p]->p_irq[0][0]                      (signal_proc_it[0][x][y][p]);
    746747                for ( size_t j = 1 ; j < 6 ; j++ )
    747748                {
    748                     proc[x][y][p]->p_irq[j]             (signal_false);
     749                    proc[x][y][p]->p_irq[0][j]          (signal_false);
    749750                }
    750751            }
     
    756757            for ( size_t p = 0 ; p < nprocs ; p++ )
    757758            {
    758                 xicu[x][y]->p_irq[p]                    (signal_proc_it[x][y][p]);
     759                xicu[x][y]->p_irq[p]                    (signal_proc_it[0][x][y][p]);
    759760            }
    760761
  • trunk/platforms/tsarv4_vgmn_generic_32/tsarv4_vgmn_generic_32_top.cpp

    r134 r140  
    372372   
    373373    // IRQ signals (one signal per proc)
    374     sc_signal<bool>***  signal_proc_it =
    375         alloc_elems<sc_signal<bool> >("signal_proc_it", xmax, ymax, nprocs);
     374    sc_signal<bool>**** signal_proc_it =
     375      alloc_elems<sc_signal<bool> >("signal_proc_it", 1,xmax, ymax, nprocs);
    376376
    377377    sc_signal<bool>*    signal_irq_mtty =
     
    539539                    IntTab(cluster(x,y), PROC_SRCID+p),         // SRCID_C
    540540                    IntTab(cluster(x,y), PROC_SRCID+p),         // TGTID_C
     541                    1,1,
    541542                    4,64,16,4,64,16                             // Icache and Dcache sizes
    542543                    ,4,8,16
     
    715716                proc[x][y][p]->p_vci_ini_c              (signal_vci_ini_c_proc[x][y][p]);
    716717                proc[x][y][p]->p_vci_tgt                (signal_vci_tgt_c_proc[x][y][p]);
    717                 proc[x][y][p]->p_irq[0]                 (signal_proc_it[x][y][p]);
     718                proc[x][y][p]->p_irq[0][0]              (signal_proc_it[0][x][y][p]);
    718719                for ( size_t j = 1 ; j < 6 ; j++ )
    719720                {
    720                     proc[x][y][p]->p_irq[j]             (signal_false);
     721                    proc[x][y][p]->p_irq[0][j]          (signal_false);
    721722                }
    722723            }
     
    728729            for ( size_t p = 0 ; p < nprocs ; p++ )
    729730            {
    730                 xicu[x][y]->p_irq[p]                    (signal_proc_it[x][y][p]);
     731                xicu[x][y]->p_irq[p]                    (signal_proc_it[0][x][y][p]);
    731732            }
    732733
Note: See TracChangeset for help on using the changeset viewer.