- Timestamp:
- Mar 9, 2011, 4:11:43 PM (14 years ago)
- 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 31 31 32 32 #include <inttypes.h> 33 #include <fstream> 33 34 #include <systemc> 34 35 #include <queue> … … 71 72 * 4 - one access with round robin priority 72 73 * 74 * CC_XCACHE_WRAPPER_MULTI_CACHE : 75 * 1 - icache static partitionnement 76 * 2 - icache dedicated 77 * 73 78 * CC_XCACHE_WRAPPER_STOP_SIMULATION : 74 79 * stop simulation if processor is stall after a long time … … 81 86 * Number of cycle before to prinf debug message 82 87 * 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 85 94 */ 86 95 87 96 // implementation 88 97 #ifndef CC_XCACHE_WRAPPER_SELECT_VICTIM 89 #define CC_XCACHE_WRAPPER_SELECT_VICTIM 098 #define CC_XCACHE_WRAPPER_SELECT_VICTIM 1 90 99 #endif 91 100 #ifndef CC_XCACHE_WRAPPER_FIFO_RSP 92 #define CC_XCACHE_WRAPPER_FIFO_RSP 0101 #define CC_XCACHE_WRAPPER_FIFO_RSP 1 93 102 #endif 94 103 #ifndef CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 95 #define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 1104 #define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 1 96 105 #endif 97 106 #ifndef CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT 98 #define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT 1107 #define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT 1 99 108 #endif 100 109 #ifndef CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME 101 #define CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME 0110 #define CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME 2 102 111 #endif 103 112 #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 105 117 #endif 106 118 // debugging 107 119 #ifndef CC_XCACHE_WRAPPER_STOP_SIMULATION 108 #define CC_XCACHE_WRAPPER_STOP_SIMULATION 1120 #define CC_XCACHE_WRAPPER_STOP_SIMULATION 1 109 121 #endif 110 122 #ifndef CC_XCACHE_WRAPPER_DEBUG 111 #define CC_XCACHE_WRAPPER_DEBUG 0123 #define CC_XCACHE_WRAPPER_DEBUG 0 112 124 #endif 113 125 #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 118 137 #endif 119 138 … … 204 223 enum cleanup_fsm_state_e { 205 224 CLEANUP_IDLE, 206 CLEANUP_DCACHE, 207 CLEANUP_ICACHE, 225 CLEANUP_REQ, 226 CLEANUP_RSP_DCACHE, 227 CLEANUP_RSP_ICACHE, 208 228 }; 209 229 … … 231 251 sc_in<bool> p_clk; 232 252 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]; 234 254 soclib::caba::VciInitiator<vci_param> p_vci_ini_rw; 235 255 soclib::caba::VciInitiator<vci_param> p_vci_ini_c; … … 241 261 const soclib::common::AddressDecodingTable<vci_addr_t, bool> m_cacheability_table; 242 262 const soclib::common::Segment m_segment; 243 iss_t m_iss;263 iss_t ** m_iss; //[m_nb_cpu] 244 264 const uint32_t m_srcid_rw; 245 265 const uint32_t m_srcid_c; 246 266 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; 247 271 const size_t m_dcache_ways; 248 272 const size_t m_dcache_words; … … 258 282 bool m_stop_simulation; 259 283 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] 261 285 #endif // CC_XCACHE_WRAPPER_STOP_SIMULATION 262 286 263 287 // 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] 297 328 298 329 sc_signal<int> r_vci_cmd_fsm; … … 301 332 sc_signal<size_t> r_vci_cmd_cpt; 302 333 sc_signal<bool> r_vci_cmd_dcache_prior; 303 334 sc_signal<uint32_t> r_vci_cmd_num_cache; 335 304 336 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;307 337 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] 309 342 310 343 #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] 313 346 #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] 323 354 #if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 324 355 sc_signal<uint32_t> r_cache_word; … … 326 357 327 358 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; 329 361 sc_signal<size_t> r_tgt_word; 330 362 sc_signal<bool> r_tgt_update; … … 335 367 sc_signal<size_t> r_tgt_trdid; 336 368 //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] 341 374 342 375 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; 350 389 #endif 351 390 352 391 // 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; 397 461 398 462 protected: … … 409 473 const soclib::common::IntTab &initiator_index_c, 410 474 const soclib::common::IntTab &target_index, 475 size_t nb_cpu, 476 size_t nb_cache, 411 477 size_t icache_ways, 412 478 size_t icache_sets, … … 435 501 void genMoore(); 436 502 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); 438 509 soclib_static_assert((int)iss_t::SC_NOT_ATOMIC == (int)vci_param::STORE_COND_NOT_ATOMIC); 439 510 }; -
trunk/modules/vci_cc_xcache_wrapper_v4/caba/source/src/vci_cc_xcache_wrapper_v4.cpp
r134 r140 55 55 /////////////////////////////////////////////////////////////////////////////// 56 56 57 #include <cassert>58 57 #include <iomanip> 59 58 #include "arithmetics.h" 59 #include "size.h" 60 60 #include "../include/vci_cc_xcache_wrapper_v4.h" 61 61 62 // =====[ DEBUG ]==================================== 63 64 #define ASSERT_VERBOSE 65 #define ASSERT_NCYCLES m_cpt_total_cycles 66 67 #include "debug.h" 68 62 69 #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) 64 71 #else 65 72 # define PRINTF(msg...) 66 73 #endif 67 74 68 # define ASSERT(cond,msg) assert ((cond) and msg); 69 75 // =====[ FIFO_RSP ]================================= 76 77 // FIXME : une FIFO avec le numéro du cache ! 70 78 #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) 81 178 #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" 102 180 #endif 103 181 … … 170 248 const char *cleanup_fsm_state_str[] = { 171 249 "CLEANUP_IDLE", 172 "CLEANUP_DCACHE", 173 "CLEANUP_ICACHE", 250 "CLEANUP_REQ", 251 "CLEANUP_RSP_DCACHE", 252 "CLEANUP_RSP_ICACHE", 174 253 }; 175 254 } … … 189 268 const soclib::common::IntTab &initiator_index_c, 190 269 const soclib::common::IntTab &target_index, 270 size_t nb_cpu, 271 size_t nb_dcache, 191 272 size_t icache_ways, 192 273 size_t icache_sets, … … 210 291 m_cacheability_table(mtp.getCacheabilityTable<vci_addr_t>()), 211 292 m_segment(mtc.getSegment(target_index)), 212 m_iss(this->name(), proc_id),213 293 m_srcid_rw(mtp.indexForId(initiator_index_rw)), 214 294 m_srcid_c(mtc.indexForId(initiator_index_c)), 215 295 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), 216 304 m_dcache_ways(dcache_ways), 217 305 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))), 219 307 m_dcache_yzmask((~0)<<m_dcache_words_shift), 220 308 m_icache_ways(icache_ways), 221 309 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))), 223 311 m_icache_yzmask((~0)<<m_icache_words_shift), 224 312 m_cache_words((dcache_words)?dcache_words:icache_words), 225 313 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"), 259 315 260 316 r_vci_cmd_fsm("r_vci_cmd_fsm"), … … 263 319 r_vci_cmd_cpt("r_vci_cmd_cpt"), 264 320 r_vci_cmd_dcache_prior("r_vci_cmd_dcache_prior"), 321 r_vci_cmd_num_cache("r_vci_cmd_num_cache"), 265 322 266 323 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"),269 324 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"), 273 327 274 328 #if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE … … 277 331 278 332 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"), 280 335 r_tgt_word("r_tgt_word"), 281 336 r_tgt_update("r_tgt_update"), … … 286 341 r_tgt_trdid("r_tgt_trdid"), 287 342 // 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"), 292 344 293 345 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) 298 351 { 299 352 // 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 306 397 CACHE_MISS_BUF_ALLOC; 307 398 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 } 310 575 311 576 SC_METHOD(transition); … … 316 581 dont_initialize(); 317 582 sensitive << p_clk.neg(); 318 319 583 320 584 typename iss_t::CacheInfo cache_info; … … 326 590 cache_info.dcache_assoc = dcache_ways; 327 591 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 330 596 #if CC_XCACHE_WRAPPER_STOP_SIMULATION 331 597 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; 333 601 #endif // CC_XCACHE_WRAPPER_STOP_SIMULATION 334 602 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 } 340 635 #endif 341 636 } // end constructor … … 345 640 /////////////////////////////////// 346 641 { 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 ; 351 711 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 353 755 354 756 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; 355 765 } 356 766 … … 359 769 //////////////////////// 360 770 { 771 for (uint32_t num_cpu=0; num_cpu<m_nb_cpu; ++num_cpu) 361 772 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 ; 363 774 } 364 775 //////////////////////// … … 366 777 //////////////////////// 367 778 { 368 float run_cycles = (float)(m_cpt_total_cycles - m_cpt_frz_cycles);369 370 779 uint32_t m_cpt_data_read_cached = m_cpt_data_read-m_cpt_data_read_uncached; 371 780 uint32_t m_cpt_data_write_cached = m_cpt_data_write-m_cpt_data_write_uncached; 372 781 std::cout << "------------------------------------" << std:: dec << std::endl; 373 782 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 } 376 790 std::cout << "- DATA READ * : " << m_cpt_data_read << std::endl ; 377 791 std::cout << " + Uncached : " << m_cpt_data_read_uncached << " (" << (float)m_cpt_data_read_uncached*100.0/(float)m_cpt_data_read << "%)" << std::endl ; … … 404 818 std::cout << " + DCACHE Only : " << (float)m_cpt_cc_inval_dcache *100.0/(float)m_cpt_cc_inval << "%" << std::endl; 405 819 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 406 866 std::cout << "* : accepted or not by the cache" << std::endl ; 407 867 408 r_wbuf.printStatistics(); 868 for (uint32_t num_cache=0; num_cache<m_nb_dcache; ++num_cache) 869 r_wbuf[num_cache]->printStatistics(); 409 870 } 410 871 … … 421 882 typename iss_t::DataRequest dreq; 422 883 423 m_iss.getRequests( ireq, dreq );424 884 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] 430 898 << " " << rsp_fsm_state_str[r_vci_rsp_fsm] 431 899 << " " << tgt_fsm_state_str[r_vci_tgt_fsm] … … 434 902 if(mode & 0x1) 435 903 { 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); 437 906 } 438 907 if(mode & 0x4) 439 908 { 440 909 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(); 442 912 } 443 913 if(mode & 0x8) 444 914 { 445 915 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(); 447 918 } 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 // }459 919 } 460 920 … … 465 925 if ( not p_resetn.read() ) { 466 926 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(); 468 931 469 932 // 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 472 947 r_vci_cmd_fsm = CMD_IDLE; 473 948 r_vci_rsp_fsm = RSP_IDLE; … … 475 950 r_cleanup_fsm = CLEANUP_IDLE; 476 951 952 for (uint32_t num_cache=0; num_cache<m_nb_icache; ++num_cache) 953 { 477 954 // write buffer & caches 478 r_wbuf.reset(); 479 r_icache.reset(); 480 r_dcache.reset(); 955 r_icache[num_cache]->reset(); 481 956 482 957 // 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; 491 967 492 968 // 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 497 1001 498 1002 #if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE … … 500 1004 #endif 501 1005 502 503 // internal messages in DCACHE et ICACHE FSMs504 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 FSMs508 r_dcache_ll_valid = false;509 r_icache_buf_unc_valid = false;510 511 1006 r_vci_cmd_dcache_prior = false; 512 513 r_vci_rsp_data_error = false;514 r_vci_rsp_ins_error = false;515 1007 516 1008 CACHE_MISS_BUF_RESET(i); … … 535 1027 m_cpt_cc_update_dcache_word_useful = 0; 536 1028 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; 538 1031 m_cpt_total_cycles = 0; 539 1032 … … 563 1056 m_length_write_transaction = 0; 564 1057 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 565 1082 return; 566 1083 } … … 569 1086 570 1087 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 } 580 1116 // CACHE_MISS_BUF_RSP_PRINT(i); 581 1117 // CACHE_MISS_BUF_RSP_PRINT(d); 582 1118 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] ++; 589 1127 590 1128 m_cpt_total_cycles++; … … 626 1164 if ( p_vci_tgt.cmdval.read() ) 627 1165 { 628 PRINTF(" * <TGT> request\n");1166 PRINTF(" * <TGT> Request\n"); 629 1167 630 1168 addr_40 address = p_vci_tgt.address.read(); … … 634 1172 std::cout << "error in component VCI_CC_XCACHE_WRAPPER " << name() << std::endl; 635 1173 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; 637 1175 std::cout << "srcid = " << p_vci_tgt.srcid.read() << std::endl; 638 1176 exit(0); … … 644 1182 std::cout << "error in component VCI_CC_XCACHE_WRAPPER " << name() << std::endl; 645 1183 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; 647 1185 std::cout << "srcid = " << p_vci_tgt.srcid.read() << std::endl; 648 1186 exit(0); 649 1187 } 650 1188 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(); 657 1204 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 662 1206 if ( (address&0x3) == 0x3 ) // broadcast invalidate for data or instruction type 663 1207 { … … 671 1215 // r_tgt_brdcast= true; 672 1216 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 673 1225 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 674 1240 } 675 1241 else // multi-update or multi-invalidate for data type … … 677 1243 uint32_t cell = address - m_segment.baseAddress(); // addr_40 678 1244 // r_tgt_brdcast = false; 1245 679 1246 if (cell == 0) 680 1247 { // invalidate data … … 687 1254 r_tgt_update = false; 688 1255 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 689 1262 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 690 1277 } 691 1278 else if (cell == 4) // invalidate instruction … … 699 1286 r_tgt_update = false; 700 1287 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 701 1295 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 702 1310 } 703 1311 else if ( (cell == 8) or (cell==12) ) // update data or instruction … … 713 1321 m_cpt_cc_update_dcache++; 714 1322 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 715 1342 } 716 1343 else … … 718 1345 m_cpt_cc_update_icache++; 719 1346 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 720 1367 } 721 1368 r_tgt_update = true; … … 724 1371 725 1372 } // 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 726 1378 } // end if cmdval 727 1379 break; … … 739 1391 r_tgt_word = p_vci_tgt.wdata.read(); // the first modified word index 740 1392 #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; 742 1394 #endif 743 1395 r_vci_tgt_fsm = TGT_UPDT_DATA; … … 789 1441 790 1442 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 } 796 1466 } 797 1467 break; … … 799 1469 case TGT_REQ_ICACHE: 800 1470 { 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() ) 802 1473 { 803 1474 r_vci_tgt_fsm = TGT_RSP_ICACHE; 804 r_tgt_icache_req = true;1475 r_tgt_icache_req[r_tgt_num_cache] = true; 805 1476 } 806 1477 break; … … 808 1479 809 1480 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 } 817 1491 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()) 822 1507 { 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) 824 1517 { 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; 828 1522 } 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]) 835 1531 { 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 } 837 1542 } 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) 842 1587 { 843 1588 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) 852 1601 { 853 1602 r_vci_tgt_fsm = TGT_IDLE; 854 r_tgt_ icache_rsp= false;1603 r_tgt_dcache_rsp[r_tgt_num_cache] = false; 855 1604 } 856 1605 break; 857 1606 } 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 }868 1607 } // 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; 869 1729 870 1730 ///////////////////////////////////////////////////////////////////// … … 899 1759 // flip-flop. It is reset by the ICACHE FSM. 900 1760 /////////////////////////////////////////////////////////////////////// 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]) { 916 1768 ///////////////// 917 1769 case ICACHE_IDLE: 918 1770 { 919 if ( r_tgt_icache_req ) { // external request920 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]; 923 1775 break; 924 1776 } 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()); 930 1783 931 1784 // icache_hit & icache_ins evaluation 932 1785 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); 934 1787 } else { 935 1788 // 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); 939 1794 } 940 1795 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 { 954 1818 #if CC_XCACHE_WRAPPER_SELECT_VICTIM 955 r_icache_fsm= ICACHE_MISS_VICTIM;1819 r_icache_fsm [num_cache] = ICACHE_MISS_VICTIM; 956 1820 #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 } 964 1831 } 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; 967 1838 } 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; 972 1842 } 973 1843 break; … … 977 1847 case ICACHE_MISS_VICTIM: 978 1848 { 979 if (not r_icache_cleanup_req )1849 if (not r_icache_cleanup_req[num_cache]) 980 1850 { 981 1851 size_t way; 982 1852 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(); 984 1854 vci_addr_t victim; 985 1855 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; 990 1860 991 r_icache_fsm = ICACHE_MISS_WAIT;1861 r_icache_fsm [num_cache] = ICACHE_MISS_WAIT; 992 1862 } 993 1863 break; … … 998 1868 { 999 1869 m_cost_ins_miss_frz++; 1000 if ( r_tgt_icache_req ) { // external request1001 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(); 1003 1873 break; 1004 1874 } 1005 1875 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); 1009 1879 1010 1880 if (val) 1011 1881 { 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 { 1022 1890 #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; 1029 1896 } 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 } 1041 1898 } 1042 1899 break; … … 1046 1903 { 1047 1904 m_cost_ins_miss_frz++; 1048 if ( r_tgt_icache_req ) { // external request1049 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(); 1051 1908 break; 1052 1909 } 1053 1910 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]); 1055 1915 1056 1916 if (ok) 1057 1917 { 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; 1060 1920 } 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; 1063 1923 } 1064 1924 } … … 1068 1928 case ICACHE_ERROR: 1069 1929 { 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; 1076 1936 break; 1077 1937 } … … 1079 1939 case ICACHE_MISS_UPDT: 1080 1940 { 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(); 1083 1943 size_t way = 0; 1084 1944 size_t set = 0; 1085 1945 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 1086 1950 // need invalid rsp, don't select a victim 1087 if (not r_icache_inval_rsp 1951 if (not r_icache_inval_rsp[num_cache]) 1088 1952 { 1089 #if CC_XCACHE_WRAPPER_SELECT_VICTIM1090 way = r_icache_miss_way.read();1091 set = r_icache_miss_set.read();1092 #else1093 1094 1953 // First word : select an victim ! 1095 1954 if (word == 0) … … 1098 1957 1099 1958 // 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); 1102 1961 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; 1106 1965 } 1107 1966 else 1108 1967 { 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(); 1111 1970 } 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); 1115 1974 1116 1975 if (val) 1117 1976 { 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)); 1121 1980 1122 1981 // m_cpt_icache_dir_write++; 1123 1982 // m_cpt_icache_data_write++; 1124 // if ( ireq.valid ) m_cost_ins_miss_frz++;1983 // if ( _ireq.valid ) m_cost_ins_miss_frz++; 1125 1984 1126 1985 // 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; 1132 1992 1133 1993 // if last word, finish the update 1134 1994 if (word >= m_icache_words) 1135 1995 { 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 1136 2001 // 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]) 1138 2003 { 1139 r_icache_inval_rsp 1140 r_icache_fsm = ICACHE_CC_CLEANUP;2004 r_icache_inval_rsp[num_cache] = false; 2005 r_icache_fsm [num_cache] = ICACHE_CC_CLEANUP; 1141 2006 } 1142 2007 else 1143 2008 { 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; 1148 2010 } 1149 2011 } … … 1156 2018 { 1157 2019 // external cache invalidate request 1158 if ( r_tgt_icache_req 2020 if ( r_tgt_icache_req[num_cache]) 1159 2021 { 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(); 1162 2024 break; 1163 2025 } 1164 2026 // 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]); 1169 2035 } 1170 2036 break; … … 1176 2042 m_cpt_icache_dir_read += m_icache_ways; 1177 2043 m_cpt_icache_data_read += m_icache_ways; 1178 addr_40 ad = r_tgt_ addr;2044 addr_40 ad = r_tgt_iaddr; 1179 2045 data_t icache_rdata = 0; 1180 2046 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; 1185 2055 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; 1187 2058 } 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; 1189 2061 } 1190 r_icache_fsm = r_icache_fsm_save;2062 r_icache_fsm[num_cache] = r_icache_fsm_save[num_cache]; 1191 2063 } 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) 1194 2069 { 1195 2070 #if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE … … 1198 2073 data_t rdata = 0; 1199 2074 1200 r_icache .read(ad+word*4,&rdata);2075 r_icache[num_cache]->read(ad+word*4,&rdata); 1201 2076 r_tgt_buf[word] = (mask & r_tgt_buf[word]) | (~mask & rdata); 1202 2077 … … 1210 2085 if (word==m_icache_words) 1211 2086 { 1212 r_icache_fsm = ICACHE_CC_UPDT;2087 r_icache_fsm[num_cache] = ICACHE_CC_UPDT; 1213 2088 1214 2089 #if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT … … 1222 2097 r_cache_word = word; 1223 2098 #else //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 1224 r_icache_fsm = ICACHE_CC_UPDT;2099 r_icache_fsm[num_cache] = ICACHE_CC_UPDT; 1225 2100 // complete the line buffer in case of update 1226 2101 for(size_t i=0; i<m_icache_words; i++){ 1227 2102 data_t rdata = 0; 1228 r_icache .read(ad + i*4,&rdata);2103 r_icache[num_cache]->read(ad + i*4,&rdata); 1229 2104 data_t mask = vci_param::be2mask(r_tgt_be[i]); 1230 2105 r_tgt_buf[i] = (mask & r_tgt_buf[i]) | (~mask & rdata); 1231 2106 } 1232 2107 #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; 1235 2110 } else { // instruction not found (can happen) 1236 r_tgt_icache_req = false;2111 r_tgt_icache_req[num_cache] = false; 1237 2112 if(r_tgt_update){ 1238 r_tgt_icache_rsp = true;2113 r_tgt_icache_rsp[num_cache] = true; 1239 2114 } else { 1240 r_tgt_icache_rsp = false;2115 r_tgt_icache_rsp[num_cache] = false; 1241 2116 } 1242 r_icache_fsm = r_icache_fsm_save;2117 r_icache_fsm[num_cache] = r_icache_fsm_save[num_cache]; 1243 2118 } 1244 2119 } … … 1248 2123 case ICACHE_CC_INVAL: 1249 2124 { 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++; 1252 2127 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]; 1257 2132 break; 1258 2133 } … … 1260 2135 case ICACHE_CC_UPDT: 1261 2136 { 1262 addr_40 ad = r_tgt_ addr.read();2137 addr_40 ad = r_tgt_iaddr.read(); 1263 2138 m_cpt_icache_dir_write++; 1264 2139 m_cpt_icache_data_write++; … … 1268 2143 1269 2144 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]); 1271 2146 1272 2147 word ++; … … 1279 2154 if (word==m_icache_words) 1280 2155 { 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(); 1284 2159 word = 0; 1285 2160 } … … 1288 2163 data_t* buf = r_tgt_buf; 1289 2164 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(); 1295 2170 #endif //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 1296 2171 … … 1298 2173 } 1299 2174 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 1306 2187 1307 2188 //////////////////////////////////////////////////////////////////////:///////////// … … 1361 2242 /////////////////////////////////////////////////////////////////////////////////// 1362 2243 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]) { 1369 2250 1370 2251 ///////////////// 1371 2252 case DCACHE_IDLE: 1372 2253 { 1373 if ( r_tgt_dcache_req 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]; 1376 2257 break; 1377 2258 } 1378 2259 1379 if ( dreq.valid ) {1380 PRINTF(" * <DCACHE > Have dreq\n");2260 if ( _dreq.valid ) { 2261 PRINTF(" * <DCACHE [%d]> Have dreq\n",num_cache); 1381 2262 1382 2263 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); 1389 2271 1390 2272 m_cpt_dcache_data_read += m_dcache_ways; 1391 2273 m_cpt_dcache_dir_read += m_dcache_ways; 1392 2274 1393 switch( dreq.type ) {2275 switch( _dreq.type ) { 1394 2276 case iss_t::DATA_READ: 1395 2277 case iss_t::DATA_LL: … … 1400 2282 { 1401 2283 // 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) 1405 2288 1406 2289 // 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) 1408 2291 { 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; 1414 2297 #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; 1418 2301 #endif 1419 2302 } … … 1423 2306 if (not dcache_cleanup_hit) 1424 2307 { 1425 CACHE_MISS_BUF_REQ_INIT(d );2308 CACHE_MISS_BUF_REQ_INIT(d,num_cache); 1426 2309 1427 2310 // Miss : send signal at the CMD_FSM (via r_dcache_miss_req or r_dcache_unc_req) … … 1429 2312 m_cpt_data_read_miss++; 1430 2313 m_cost_data_miss_frz++; 1431 r_dcache_miss_req = true;2314 r_dcache_miss_req [num_cache] = true; 1432 2315 #if CC_XCACHE_WRAPPER_SELECT_VICTIM 1433 r_dcache_fsm = DCACHE_MISS_VICTIM;2316 r_dcache_fsm [num_cache] = DCACHE_MISS_VICTIM; 1434 2317 #else 1435 r_dcache_fsm = DCACHE_MISS_WAIT;2318 r_dcache_fsm [num_cache] = DCACHE_MISS_WAIT; 1436 2319 #endif 1437 2320 1438 2321 } else { 1439 if (not r_dcache_previous_unc .read()) // strongly order to the uncached access2322 if (not r_dcache_previous_unc[num_cache].read()) // strongly order to the uncached access 1440 2323 { 1441 r_dcache_previous_unc = true;2324 r_dcache_previous_unc[num_cache] = true; 1442 2325 1443 2326 m_cpt_data_read_uncached++; 1444 2327 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; 1447 2330 } 1448 2331 } … … 1453 2336 case iss_t::DATA_SC: 1454 2337 { 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 access2338 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 1458 2341 { 1459 2342 //m_cpt_data_read_unc++; // instruction must read the memory in uncached mode … … 1462 2345 // if previous load linked (with the same address), make a transaction 1463 2346 // 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); 1466 2350 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; 1474 2357 } else { 1475 PRINTF(" * <DCACHE > don't have previous load linked\n");2358 PRINTF(" * <DCACHE [%d]> don't have previous load linked\n",num_cache); 1476 2359 1477 drsp.valid = true;1478 drsp.rdata = 1; // SC rsp NOK1479 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; 1480 2363 } 1481 2364 } … … 1486 2369 case iss_t::XTN_WRITE: 1487 2370 { 1488 bool drsp_valid = false;2371 bool valid = false; 1489 2372 // only DCACHE INVALIDATE and SYNC request are supported 1490 switch ( dreq.addr>>2)2373 switch (_dreq.addr>>2) 1491 2374 { 1492 2375 case iss_t::XTN_DCACHE_INVAL : 1493 2376 { 1494 drsp_valid = true;1495 r_dcache_fsm = DCACHE_INVAL;2377 valid = true; 2378 r_dcache_fsm[num_cache] = DCACHE_INVAL; 1496 2379 break; 1497 2380 } … … 1501 2384 // * gain : 1 cycle 1502 2385 // * 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) 1504 2392 { 1505 drsp_valid = true;1506 r_dcache_fsm = DCACHE_IDLE;2393 valid = true; 2394 r_dcache_fsm [num_cache] = DCACHE_IDLE; 1507 2395 } 1508 2396 else 1509 2397 { 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; 1512 2401 } 1513 2402 break; … … 1516 2405 { 1517 2406 // 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; 1521 2410 } 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; 1526 2415 break; 1527 2416 } 1528 2417 case iss_t::DATA_WRITE: 1529 2418 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 1531 2422 { 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) 1537 2433 { 1538 2434 m_cpt_data_write++; … … 1540 2436 if (not dcache_cached) 1541 2437 { 1542 r_dcache_previous_unc = true;2438 r_dcache_previous_unc[num_cache] = true; 1543 2439 m_cpt_data_write_uncached++; 1544 2440 } … … 1546 2442 m_cpt_data_write_miss++; 1547 2443 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; 1550 2447 } else { 1551 r_dcache_fsm = DCACHE_IDLE; 2448 // write accepted 2449 r_dcache_fsm [num_cache] = DCACHE_IDLE; 1552 2450 } 1553 2451 } 1554 2452 1555 drsp.valid = drsp_valid;1556 drsp.rdata = 0;2453 _drsp.valid = valid; 2454 _drsp.rdata = 0; 1557 2455 } 1558 2456 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; 1570 2469 } 1571 2470 … … 1576 2475 { 1577 2476 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; 1584 2483 1585 2484 break; … … 1589 2488 case DCACHE_MISS_VICTIM: 1590 2489 { 1591 if (not r_dcache_cleanup_req .read())2490 if (not r_dcache_cleanup_req[num_cache].read()) 1592 2491 { 1593 2492 size_t way; 1594 2493 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(); 1596 2495 vci_addr_t victim; 2496 bool victim_val = r_dcache[num_cache]->victim_select(addr, &victim, &way, &set ); 1597 2497 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; 1604 2506 } 1605 2507 … … 1611 2513 { 1612 2514 1613 if (dreq.valid ) m_cost_data_miss_frz++;1614 if ( r_tgt_dcache_req .read() ) { // external request1615 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]; 1617 2519 break; 1618 2520 } 1619 2521 1620 bool val = CACHE_MISS_BUF_RSP_VAL(d, 0);2522 bool val = CACHE_MISS_BUF_RSP_VAL(d,num_cache,0); 1621 2523 if (val) 1622 2524 { 1623 // if (not r_dcache_inval_rsp )1624 // {1625 1626 2525 // Miss read response and no invalidation 1627 if ( r_vci_rsp_data_error)2526 if (r_vci_rsp_data_error[num_cache]) 1628 2527 { 1629 r_dcache_fsm = DCACHE_ERROR;2528 r_dcache_fsm [num_cache] = DCACHE_ERROR; 1630 2529 } 1631 2530 else 1632 2531 { 1633 2532 #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()) 1635 2534 #endif 1636 2535 { 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; 1639 2538 } 1640 2539 } 1641 // }1642 // else1643 // {1644 // r_dcache_inval_rsp = false;1645 1646 // // Miss read response and invalidation1647 // if ( r_vci_rsp_data_error ) {1648 // r_dcache_fsm = DCACHE_ERROR;1649 // } else {1650 // r_dcache_fsm = DCACHE_CC_CLEANUP;1651 // }1652 // }1653 2540 } 1654 2541 break; … … 1657 2544 case DCACHE_MISS_UPDT: 1658 2545 { 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(); 1661 2548 size_t way = 0; 1662 2549 size_t set = 0; 1663 2550 1664 2551 // 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] ) 1666 2557 { 1667 #if CC_XCACHE_WRAPPER_SELECT_VICTIM1668 way = r_dcache_miss_way.read();1669 set = r_dcache_miss_set.read();1670 #else1671 2558 // First word : select an victim ! 1672 2559 if (word == 0) … … 1675 2562 1676 2563 // 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 1682 r_dcache_miss_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; 1683 2570 } 1684 2571 else 1685 2572 { 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(); 1688 2575 } 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)) 1694 2582 { 1695 2583 // m_cpt_dcache_dir_write++; 1696 // if ( ireq.valid ) m_cost_data_miss_frz++;2584 // if ( _dreq.valid ) m_cost_data_miss_frz++; 1697 2585 1698 2586 // 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]) 1700 2589 { 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)); 1702 2591 m_cpt_dcache_data_write++; 1703 2592 } 1704 2593 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; 1707 2596 1708 2597 // if last word, finish the update 1709 2598 if (word >= m_dcache_words) 1710 2599 { 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 1711 2606 // 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]) 1713 2608 { 1714 r_dcache_inval_rsp 1715 r_dcache_fsm = DCACHE_CC_CLEANUP;2609 r_dcache_inval_rsp[num_cache] = false; 2610 r_dcache_fsm [num_cache] = DCACHE_CC_CLEANUP; 1716 2611 } 1717 2612 else 1718 2613 { 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; 1723 2615 } 1724 2616 } … … 1730 2622 case DCACHE_UNC_WAIT: 1731 2623 { 1732 if (dreq.valid ) m_cost_unc_read_frz++;1733 if ( r_tgt_dcache_req ) { // external request1734 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]; 1736 2628 break; 1737 2629 } 1738 2630 1739 bool ok = CACHE_MISS_BUF_RSP_VAL(d, 0);2631 bool ok = CACHE_MISS_BUF_RSP_VAL(d,num_cache,0); 1740 2632 1741 2633 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; 1744 2636 } 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; 1754 2646 } 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; 1758 2651 } 1759 2652 } … … 1763 2656 case DCACHE_SC_WAIT: 1764 2657 { 1765 if (dreq.valid ) m_cost_unc_read_frz++;1766 if ( r_tgt_dcache_req ) { // external request1767 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]; 1769 2662 break; 1770 2663 } 1771 2664 1772 bool ok = CACHE_MISS_BUF_RSP_VAL(d, 0);2665 bool ok = CACHE_MISS_BUF_RSP_VAL(d,num_cache,0); 1773 2666 1774 2667 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; 1777 2670 } 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; 1783 2677 } 1784 2678 } … … 1789 2683 case DCACHE_ERROR: 1790 2684 { 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; 1795 2690 break; 1796 2691 } … … 1798 2693 case DCACHE_INVAL: 1799 2694 { 1800 if ( r_tgt_dcache_req .read() ) { // external request1801 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]; 1803 2698 break; 1804 2699 } 1805 if( not r_dcache_cleanup_req .read() ){2700 if( not r_dcache_cleanup_req [num_cache].read() ){ 1806 2701 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; 1812 2707 } 1813 2708 break; … … 1815 2710 case DCACHE_SYNC : 1816 2711 { 1817 if ( r_tgt_dcache_req ) { // external request1818 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]; 1820 2715 break; 1821 2716 } 1822 2717 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 } 1828 2728 break; 1829 2729 } … … 1831 2731 case DCACHE_CC_CHECK: // read directory in case of invalidate or update request 1832 2732 { 1833 addr_40 ad = r_tgt_ addr;2733 addr_40 ad = r_tgt_daddr; 1834 2734 data_t dcache_rdata = 0; 1835 2735 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; 1840 2744 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; 1842 2747 } 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; 1844 2750 } 1845 r_dcache_fsm = r_dcache_fsm_save;2751 r_dcache_fsm[num_cache] = r_dcache_fsm_save[num_cache]; 1846 2752 } 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); 1848 2756 1849 2757 m_cpt_dcache_data_read += m_dcache_ways; … … 1860 2768 data_t rdata = 0; 1861 2769 1862 r_dcache .read(ad+word*4,&rdata);2770 r_dcache[num_cache]->read(ad+word*4,&rdata); 1863 2771 1864 2772 r_tgt_buf[word] = (mask & r_tgt_buf[word]) | (~mask & rdata); … … 1873 2781 if (word==m_dcache_words) 1874 2782 { 1875 r_dcache_fsm = DCACHE_CC_UPDT;2783 r_dcache_fsm[num_cache] = DCACHE_CC_UPDT; 1876 2784 #if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT 1877 2785 for (word=0; word<m_dcache_words; ++word) … … 1887 2795 for(size_t i=0; i<m_dcache_words; i++){ 1888 2796 data_t rdata = 0; 1889 r_dcache .read(ad + i*4,&rdata);2797 r_dcache[num_cache]->read(ad + i*4,&rdata); 1890 2798 data_t mask = vci_param::be2mask(r_tgt_be[i]); 1891 2799 r_tgt_buf[i] = (mask & r_tgt_buf[i]) | (~mask & rdata); 1892 2800 } 1893 r_dcache_fsm = DCACHE_CC_UPDT;2801 r_dcache_fsm[num_cache] = DCACHE_CC_UPDT; 1894 2802 #endif //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 1895 2803 } 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; 1897 2805 } else { 1898 2806 if(r_tgt_update){ 1899 r_tgt_dcache_rsp = true;2807 r_tgt_dcache_rsp[num_cache] = true; 1900 2808 } else { 1901 r_tgt_dcache_rsp = false;2809 r_tgt_dcache_rsp[num_cache] = false; 1902 2810 } 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]; 1905 2813 } 1906 2814 } … … 1910 2818 case DCACHE_CC_UPDT: // update directory and data cache 1911 2819 { 1912 addr_40 ad = r_tgt_ addr;2820 addr_40 ad = r_tgt_daddr; 1913 2821 1914 2822 m_cpt_dcache_dir_write++; … … 1923 2831 1924 2832 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]); 1926 2834 # ifdef COHERENCE_DEBUG 1927 2835 std::cout << " address " << std::hex << ad+word*4 << " data " << std::dec << r_tgt_buf[word] << std::endl; 1928 2836 data_t rdata = 0xAAAAAAAA; 1929 r_dcache .read(ad+word*4,&rdata);2837 r_dcache[num_cache]->read(ad+word*4,&rdata); 1930 2838 std::cout << "data written " << rdata << std::endl; 1931 2839 # endif … … 1940 2848 if (word==m_dcache_words) 1941 2849 { 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]; 1945 2853 word = 0; 1946 2854 } … … 1950 2858 for(size_t i=0; i<m_dcache_words; i++){ 1951 2859 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]); 1953 2861 # ifdef COHERENCE_DEBUG 1954 2862 std::cout << " address " << std::hex << ad+i*4 << " data " << std::dec << buf[i] << std::endl; 1955 2863 data_t rdata = 0xAAAAAAAA; 1956 r_dcache .read(ad + i*4,&rdata);2864 r_dcache[num_cache]->read(ad + i*4,&rdata); 1957 2865 std::cout << "data written " << rdata << std::endl; 1958 2866 # endif //CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 1959 2867 } 1960 2868 } 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]; 1964 2872 #endif 1965 2873 break; … … 1968 2876 case DCACHE_CC_INVAL: // invalidate a cache line 1969 2877 { 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]; 1975 2883 break; 1976 2884 } … … 1979 2887 { 1980 2888 // external cache invalidate request 1981 if ( r_tgt_dcache_req )2889 if ( r_tgt_dcache_req[num_cache] ) 1982 2890 { 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]; 1985 2893 break; 1986 2894 } 1987 2895 // 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]); 1992 2904 } 1993 2905 break; … … 1999 2911 // The update() method must be called at each cycle to update the internal state. 2000 2912 // 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); 2002 2915 #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); 2004 2917 #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); 2006 2919 #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); 2008 2921 #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]]; 2010 2957 #endif 2011 2958 2012 2959 #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]++; 2029 2977 #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 } 2031 2991 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) 2033 2994 { 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; 2036 3005 } 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 2091 3044 2092 3045 //////////////////////////////////////////////////////////////////////////// … … 2113 3066 2114 3067 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 2120 3124 } 2121 3125 break; 2122 3126 } 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: 2124 3139 { 2125 3140 if ( p_vci_ini_c.rspval ) 2126 3141 { 2127 3142 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); 2128 3144 2129 3145 ASSERT(p_vci_ini_c.reop and (p_vci_ini_c.rtrdid.read() == TYPE_DATA_CLEANUP), 2130 3146 "illegal response packet received for a cleanup transaction"); 2131 3147 ASSERT(p_vci_ini_c.rerror.read() == vci_param::ERR_NORMAL, 2132 3148 "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 2134 3152 r_cleanup_fsm = CLEANUP_IDLE; 2135 r_dcache_cleanup_req = false;2136 // m_cpt_cc_cleanup_data++; TODO3153 r_dcache_cleanup_req[r_cleanup_num_cache] = false; 3154 // m_cpt_cc_cleanup_data++; 2137 3155 } 2138 3156 break; 2139 3157 } 2140 case CLEANUP_ ICACHE:3158 case CLEANUP_RSP_ICACHE: 2141 3159 { 2142 3160 if ( p_vci_ini_c.rspval ) … … 2150 3168 2151 3169 r_cleanup_fsm = CLEANUP_IDLE; 2152 r_icache_cleanup_req = false;2153 // m_cpt_cc_cleanup_ins++; TODO3170 r_icache_cleanup_req[r_cleanup_num_cache] = false; 3171 // m_cpt_cc_cleanup_ins++; 2154 3172 } 2155 3173 break; … … 2195 3213 // if (r_vci_rsp_fsm != RSP_IDLE) break; 2196 3214 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 2200 3221 r_vci_cmd_cpt = 0; 2201 3222 … … 2204 3225 // multi_write_buffer access is conditionnal with dcache_miss_req and icache_miss_req 2205 3226 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; 2214 3258 #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; 2218 3261 #elif (CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY==4) 2219 // 4) one access with round robin priority2220 bool dcache_miss_req = ((r_dcache_miss_req and not r_icache_miss_req) or // only dcache2221 (r_dcache_miss_req and r_vci_cmd_dcache_prior)); // dcache prior2222 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; 2223 3266 #else 2224 3267 #error "Invalid value to CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY" 2225 3268 #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 2226 3321 // 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)) 2228 3323 { 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; 2231 3327 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 2232 3344 } 2233 3345 2234 3346 // 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 2236 3348 { 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 2240 3370 } 2241 3371 2242 3372 // 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)) 2244 3375 { 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; 2247 3379 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 2248 3394 } 2249 3395 2250 3396 // 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 2252 3398 { 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; 2255 3402 // 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 2256 3420 } 2257 3421 2258 3422 // 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) 2260 3424 { 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; 2265 3430 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 2267 3450 } 2268 3451 2269 3452 // 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 2271 3454 { 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; 2274 3458 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 2276 3477 } 2277 3478 … … 2283 3484 if (r_vci_cmd_cpt == r_vci_cmd_max) { 2284 3485 r_vci_cmd_fsm = CMD_IDLE ; 2285 r_wbuf .sent() ;3486 r_wbuf[r_vci_cmd_num_cache]->sent() ; 2286 3487 } 2287 3488 } … … 2339 3540 if( p_vci_ini_rw.rspval.read() ) 2340 3541 { 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"); 2342 3546 2343 3547 r_vci_rsp_cpt = 0; 2344 3548 2345 3549 if ((p_vci_ini_rw.rtrdid.read()>>(vci_param::T-1)) != 0 ) 3550 { 2346 3551 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 } 2347 3564 else 2348 3565 { 2349 3566 switch (p_vci_ini_rw.rtrdid.read()) 2350 3567 { 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 } 2356 3648 default : 2357 3649 { … … 2360 3652 } 2361 3653 } 3654 3655 r_vci_rsp_num_cache = p_vci_ini_rw.rpktid.read(); 2362 3656 } 2363 3657 break; … … 2366 3660 2367 3661 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) 2371 3665 { 2372 3666 PRINTF(" * <RSP> have rsp - r_vci_rsp_cpt : %d/%d\n",(uint32_t)r_vci_rsp_cpt.read(),(uint32_t)m_icache_words); … … 2376 3670 "The VCI response packet for instruction miss is too long" ); 2377 3671 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()); 2379 3673 if ( p_vci_ini_rw.reop.read() ) 2380 3674 { … … 2383 3677 ASSERT( ((r_vci_rsp_cpt == m_icache_words - 1) or 2384 3678 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)), 2386 3680 "The VCI response packet for instruction miss is too short"); 2387 3681 r_vci_rsp_cpt = 0; … … 2389 3683 2390 3684 } 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; 2392 3686 } 2393 3687 break; … … 2396 3690 2397 3691 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) 2399 3693 { 2400 3694 ASSERT(p_vci_ini_rw.reop.read(), 2401 3695 "illegal VCI response packet for uncached instruction"); 2402 3696 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()); 2404 3698 2405 3699 r_vci_rsp_fsm = RSP_IDLE; 2406 3700 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; 2408 3702 } 2409 3703 break; … … 2412 3706 2413 3707 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) 2415 3709 { 2416 3710 PRINTF(" * <RSP> have rspval - error : %d\n",(int)p_vci_ini_rw.rerror.read()); … … 2420 3714 r_vci_rsp_cpt = r_vci_rsp_cpt + 1; 2421 3715 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()); 2423 3717 2424 3718 if ( p_vci_ini_rw.reop.read() ) { 2425 3719 ASSERT( ((r_vci_rsp_cpt == m_dcache_words - 1) 2426 3720 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()), 2428 3722 "illegal VCI response packet for data read miss"); 2429 3723 r_vci_rsp_cpt = 0; 2430 3724 r_vci_rsp_fsm = RSP_IDLE; 2431 3725 } 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; 2433 3727 } 2434 3728 break; 2435 3729 2436 3730 case RSP_DATA_WRITE: 2437 2438 3731 m_cost_write_transaction++; 2439 3732 if (p_vci_ini_rw.rspval.read()) … … 2444 3737 "A VCI response packet must contain one flit for a write transaction"); 2445 3738 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))); 2447 3740 2448 3741 PRINTF(" * <RSP> cached : %d\n",cached); 2449 3742 2450 3743 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(); 2454 3748 } 2455 3749 break; … … 2457 3751 case RSP_DATA_UNC: 2458 3752 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) 2460 3754 { 2461 3755 ASSERT(p_vci_ini_rw.reop.read(), 2462 3756 "illegal VCI response packet for data read uncached"); 2463 3757 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()); 2465 3759 2466 3760 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; 2470 3764 } 2471 3765 break; … … 2473 3767 case RSP_DATA_SC: 2474 3768 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) 2476 3770 { 2477 3771 ASSERT(p_vci_ini_rw.reop.read(), 2478 3772 "illegal VCI response packet for data SC"); 2479 3773 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()); 2481 3775 2482 3776 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; 2486 3780 } 2487 3781 break; … … 2489 3783 } // end switch r_vci_rsp_fsm 2490 3784 2491 3785 } // end transition() 2492 3786 2493 3787 ////////////////////////////////////////////////////////////////////////////////// … … 2495 3789 ////////////////////////////////////////////////////////////////////////////////// 2496 3790 { 3791 PRINTF("--------------------------------------------\n"); 3792 PRINTF(" * CC_XCACHE_WRAPPER \"%s\" genMoore - Time = %d\n",name().c_str(),(uint32_t)m_cpt_total_cycles); 2497 3793 2498 3794 // VCI initiator response 2499 3795 switch ( r_cleanup_fsm.read() ) { 2500 2501 3796 case CLEANUP_IDLE: 2502 3797 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); 2508 3824 } 2509 3825 else 2510 3826 { 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 2526 3850 break; 2527 2528 case CLEANUP_DCACHE: 3851 } 3852 3853 case CLEANUP_RSP_DCACHE: 2529 3854 p_vci_ini_c.rspack = true; 2530 3855 p_vci_ini_c.cmdval = false; … … 2545 3870 break; 2546 3871 2547 case CLEANUP_ ICACHE:3872 case CLEANUP_RSP_ICACHE: 2548 3873 p_vci_ini_c.rspack = true; 2549 3874 p_vci_ini_c.cmdval = false; … … 2568 3893 2569 3894 switch (r_vci_cmd_fsm.read() ) { 2570 2571 3895 case CMD_IDLE: 3896 { 2572 3897 p_vci_ini_rw.cmdval = false; 2573 3898 p_vci_ini_rw.address = 0; … … 2587 3912 2588 3913 break; 2589 3914 } 2590 3915 case CMD_DATA_UNC: 3916 { 2591 3917 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] ) { 2594 3926 case iss_t::DATA_READ: 2595 3927 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(); 2597 3929 p_vci_ini_rw.cmd = vci_param::CMD_READ; 2598 3930 break; … … 2607 3939 p_vci_ini_rw.plen = 4; 2608 3940 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; 2610 3942 p_vci_ini_rw.srcid = m_srcid_rw; 2611 3943 p_vci_ini_rw.cons = false; … … 2617 3949 2618 3950 break; 2619 3951 } 2620 3952 case CMD_DATA_SC: 3953 { 2621 3954 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; 2623 3962 if(r_vci_cmd_max.read() == 3){ 2624 3963 ASSERT(false, "Not handled yet"); … … 2626 3965 switch(r_vci_cmd_cpt.read()){ 2627 3966 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); 2629 3968 break; 2630 3969 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(); 2632 3971 break; 2633 3972 } … … 2637 3976 p_vci_ini_rw.plen = 4*(r_vci_cmd_max.read()+1); 2638 3977 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; 2640 3979 p_vci_ini_rw.srcid = m_srcid_rw; 2641 3980 p_vci_ini_rw.cons = true; … … 2647 3986 2648 3987 break; 2649 3988 } 2650 3989 case CMD_DATA_WRITE: 3990 { 2651 3991 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); 2655 4000 p_vci_ini_rw.plen = (r_vci_cmd_max - r_vci_cmd_min + 1)<<2; 2656 4001 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; 2659 4004 p_vci_ini_rw.srcid = m_srcid_rw; 2660 4005 p_vci_ini_rw.cons = false; … … 2666 4011 2667 4012 break; 2668 4013 } 2669 4014 case CMD_DATA_MISS: 4015 { 2670 4016 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; 2672 4024 p_vci_ini_rw.be = 0xF; 2673 4025 p_vci_ini_rw.plen = m_dcache_words << 2; 2674 4026 p_vci_ini_rw.cmd = vci_param::CMD_READ; 2675 4027 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; 2677 4029 p_vci_ini_rw.srcid = m_srcid_rw; 2678 4030 p_vci_ini_rw.cons = false; … … 2684 4036 2685 4037 break; 2686 4038 } 2687 4039 case CMD_INS_MISS: 4040 { 2688 4041 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; 2690 4049 p_vci_ini_rw.be = 0xF; 2691 4050 p_vci_ini_rw.plen = m_icache_words << 2; 2692 4051 p_vci_ini_rw.cmd = vci_param::CMD_READ; 2693 4052 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; 2695 4054 p_vci_ini_rw.srcid = m_srcid_rw; 2696 4055 p_vci_ini_rw.cons = false; … … 2702 4061 2703 4062 break; 2704 4063 } 2705 4064 case CMD_INS_UNC: 4065 { 2706 4066 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; 2708 4074 p_vci_ini_rw.be = 0xF; 2709 4075 p_vci_ini_rw.plen = 4; 2710 4076 p_vci_ini_rw.cmd = vci_param::CMD_READ; 2711 4077 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; 2713 4079 p_vci_ini_rw.srcid = m_srcid_rw; 2714 4080 p_vci_ini_rw.cons = false; … … 2720 4086 2721 4087 break; 2722 4088 } 2723 4089 } // end switch r_vci_cmd_fsm 2724 4090 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 2740 4113 // VCI_TGT 4114 4115 // PRINTF(" * <TGT> srcid : %d\n", r_tgt_srcid.read()); 2741 4116 2742 4117 switch ( r_vci_tgt_fsm.read() ) { … … 2750 4125 2751 4126 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 } 2762 4159 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 } 2773 4175 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 } 2784 4191 case TGT_REQ_BROADCAST: 2785 4192 case TGT_REQ_ICACHE: … … 2814 4221 } 2815 4222 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 2816 4262 }} // end namespace 2817 4263 -
trunk/modules/vci_mem_cache_v4/caba/source/include/mem_cache_directory_v4.h
r57 r140 6 6 #include <cassert> 7 7 #include "arithmetics.h" 8 9 #define L1_MULTI_CACHE 1 8 10 9 11 namespace soclib { namespace caba { … … 37 39 bool inst; // Is the owner an ICache ? 38 40 size_t srcid; // The SRCID of the owner 41 #if L1_MULTI_CACHE 42 size_t cache_id; // In multi_cache configuration 43 #endif 39 44 40 45 //////////////////////// 41 46 // Constructors 42 47 //////////////////////// 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 ){ 44 54 inst = i_inst; 45 55 srcid = i_srcid; 56 #if L1_MULTI_CACHE 57 cache_id= i_cache_id; 58 #endif 46 59 } 47 60 … … 49 62 inst = a.inst; 50 63 srcid = a.srcid; 64 #if L1_MULTI_CACHE 65 cache_id= a.cache_id; 66 #endif 51 67 } 52 68 … … 54 70 inst = false; 55 71 srcid = 0; 72 #if L1_MULTI_CACHE 73 cache_id= 0; 74 #endif 56 75 } 57 76 // end constructors … … 89 108 owner.inst = 0; 90 109 owner.srcid = 0; 110 #if L1_MULTI_CACHE 111 owner.cache_id= 0; 112 #endif 91 113 ptr = 0; 92 114 } … … 137 159 { 138 160 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; 140 170 } 141 171 … … 346 376 //////////////////////// 347 377 HeapEntry() 348 :owner(false,0) 378 :owner(false,0 379 #if L1_MULTI_CACHE 380 ,0 381 #endif 382 ) 349 383 { 350 384 next = 0; … … 355 389 //////////////////////// 356 390 HeapEntry(const HeapEntry &entry){ 391 owner.inst = entry.owner.inst; 357 392 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; 360 397 } // end constructor 361 398 … … 364 401 ///////////////////////////////////////////////////////////////////// 365 402 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; 369 409 } // end copy() 370 410 … … 374 414 void print(){ 375 415 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; 379 422 380 423 } // end print() -
trunk/modules/vci_mem_cache_v4/caba/source/include/vci_mem_cache_v4.h
r138 r140 405 405 sc_signal<int> r_read_fsm; // FSM state 406 406 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 407 408 sc_signal<bool> r_read_copy_inst; // Type of the first copy 408 409 sc_signal<tag_t> r_read_tag; // cache line tag (in directory) … … 450 451 sc_signal<tag_t> r_write_tag; // cache line tag (in directory) 451 452 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 452 454 sc_signal<bool> r_write_copy_inst; // is this owner a ICache ? 453 455 sc_signal<size_t> r_write_count; // number of copies … … 483 485 GenericFifo<bool> m_write_to_init_cmd_inst_fifo; // fifo for the L1 type 484 486 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 485 488 486 489 // Buffer between WRITE fsm and INIT_RSP fsm (Decrement UPT entry) … … 516 519 517 520 sc_signal<copy_t> r_cleanup_copy; // first copy 521 sc_signal<copy_t> r_cleanup_copy_cache; // first copy 518 522 sc_signal<size_t> r_cleanup_copy_inst; // type of the first copy 519 523 sc_signal<copy_t> r_cleanup_count; // number of copies … … 521 525 sc_signal<size_t> r_cleanup_prev_ptr; // previous pointer to the heap 522 526 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 523 528 sc_signal<bool> r_cleanup_prev_inst; // inst bit of previous heap entry 524 529 sc_signal<size_t> r_cleanup_next_ptr; // next pointer to the heap … … 552 557 sc_signal<size_t> r_llsc_cpt; // size of command 553 558 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 554 560 sc_signal<bool> r_llsc_copy_inst; // Type of the first copy 555 561 sc_signal<size_t> r_llsc_count; // number of copies … … 590 596 GenericFifo<bool> m_llsc_to_init_cmd_inst_fifo; // fifo for the L1 type 591 597 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 592 599 593 600 // Buffer between LLSC fsm and INIT_RSP fsm (Decrement UPT entry) … … 620 627 sc_signal<addr_t> r_xram_rsp_victim_nline; // victim line index 621 628 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 622 630 sc_signal<bool> r_xram_rsp_victim_copy_inst; // victim line type of first copy 623 631 sc_signal<size_t> r_xram_rsp_victim_count; // victim line number of copies … … 644 652 GenericFifo<bool> m_xram_rsp_to_init_cmd_inst_fifo; // fifo for the L1 type 645 653 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 646 655 647 656 // 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 29 29 #include "../include/vci_mem_cache_v4.h" 30 30 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 35 36 #define DEBUG_VCI_MEM_CACHE 0 36 #define DEBUG_START_CYCLE 20000037 #define DEBUG_START_CYCLE 949900 37 38 #define RANDOMIZE_SC 38 39 40 #define ASSERT_VERBOSE 41 #define ASSERT_NCYCLES m_cpt_cycles 42 43 #include "debug.h" 44 39 45 #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) 41 47 #else 42 48 # define PRINTF(msg...) … … 301 307 m_write_to_init_cmd_inst_fifo("m_write_to_init_cmd_inst_fifo",8), 302 308 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 303 312 r_init_rsp_fsm("r_init_rsp_fsm"), 304 313 r_cleanup_fsm("r_cleanup_fsm"), … … 306 315 m_llsc_to_init_cmd_inst_fifo("m_llsc_to_init_cmd_inst_fifo",8), 307 316 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 308 320 r_ixr_rsp_fsm("r_ixr_rsp_fsm"), 309 321 r_xram_rsp_fsm("r_xram_rsp_fsm"), 310 322 m_xram_rsp_to_init_cmd_inst_fifo("m_xram_rsp_to_init_cmd_inst_fifo",8), 311 323 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 312 327 r_ixr_cmd_fsm("r_ixr_cmd_fsm"), 313 328 r_tgt_rsp_fsm("r_tgt_rsp_fsm"), … … 532 547 m_write_to_init_cmd_inst_fifo.init(); 533 548 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 534 552 535 553 r_cleanup_to_tgt_rsp_req = false; … … 545 563 m_llsc_to_init_cmd_inst_fifo.init(); 546 564 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 547 568 548 569 for(size_t i=0; i<TRANSACTION_TAB_LINES ; i++){ … … 557 578 m_xram_rsp_to_init_cmd_inst_fifo.init(); 558 579 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 559 583 560 584 r_ixr_cmd_cpt = 0; … … 591 615 bool cmd_llsc_fifo_get = false; 592 616 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 607 640 608 641 #if DEBUG_VCI_MEM_CACHE … … 628 661 #endif 629 662 663 #ifdef IDEBUG 664 if(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 630 670 //////////////////////////////////////////////////////////////////////////////////// 631 671 // TGT_CMD FSM … … 651 691 if ( p_vci_tgt.cmdval ) { 652 692 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()); 654 694 655 695 if ( p_vci_tgt.cmd.read() == vci_param::CMD_READ ) … … 676 716 677 717 { 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"); 680 720 681 721 if ( p_vci_tgt.cmdval && m_cmd_read_addr_fifo.wok() ) { … … 744 784 745 785 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") ; 751 792 r_init_rsp_upt_index = p_vci_ini.rtrdid.read(); 752 793 r_init_rsp_fsm = INIT_RSP_UPT_LOCK; … … 772 813 #endif 773 814 while(!valid); 774 assert( valid775 &&"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" ); 776 817 777 818 if ( count == 0 ) r_init_rsp_fsm = INIT_RSP_UPT_CLEAR; … … 830 871 //////////////////////////////////////////////////////////////////////////////////// 831 872 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()); 833 874 834 875 switch ( r_read_fsm.read() ) { … … 838 879 { 839 880 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()); 841 882 842 883 m_cpt_read++; … … 858 899 } 859 900 #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; 869 913 870 914 bool cached_read = (m_cmd_read_trdid_fifo.read() & 0x1); … … 910 954 if(!is_cnt){ // Not counter mode 911 955 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 912 960 entry.owner.inst = inst_read; 913 961 entry.count = r_read_count.read() + 1; 914 962 } else { // Counter mode 915 963 entry.owner.srcid = 0; 964 #if L1_MULTI_CACHE 965 entry.owner.cache_id= 0; 966 #endif 916 967 entry.owner.inst = false; 917 968 entry.count = r_read_count.read() + 1; … … 919 970 } else { // Uncached read 920 971 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 921 976 entry.owner.inst = r_read_copy_inst.read(); 922 977 entry.count = r_read_count.read(); … … 956 1011 if(!is_cnt){ // Not counter mode 957 1012 entry.owner.srcid = r_read_copy.read(); 1013 #if L1_MULTI_CACHE 1014 entry.owner.cache_id= r_read_copy_cache.read(); 1015 #endif 958 1016 entry.owner.inst = r_read_copy_inst.read(); 959 1017 entry.count = r_read_count.read() + 1; … … 961 1019 } else { // Counter mode 962 1020 entry.owner.srcid = 0; 1021 #if L1_MULTI_CACHE 1022 entry.owner.cache_id= 0; 1023 #endif 963 1024 entry.owner.inst = false; 964 1025 entry.count = r_read_count.read() + 1; … … 1008 1069 bool inst_read = (m_cmd_read_trdid_fifo.read() & 0x2); 1009 1070 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; 1012 1076 if(r_read_count.read() == 1){ // creation of a new list 1013 1077 new_heap_entry.next = m_heap_directory.next_free_ptr(); … … 1023 1087 r_read_fsm = READ_RSP; 1024 1088 } else { 1025 assert(false &&"MEMCACHE Error : Bad HEAP allocation");1089 ASSERT(false,"MEMCACHE Error : Bad HEAP allocation"); 1026 1090 } 1027 1091 break; … … 1039 1103 } 1040 1104 } else { 1041 assert(false &&"MEMCACHE Error : Bad HEAP allocation");1105 ASSERT(false,"MEMCACHE Error : Bad HEAP allocation"); 1042 1106 } 1043 1107 break; … … 1048 1112 if(r_alloc_heap_fsm.read() == ALLOC_HEAP_READ){ 1049 1113 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; 1052 1119 if(m_heap_directory.is_full()){ 1053 1120 last_entry.next = r_read_ptr.read(); … … 1059 1126 r_read_fsm = READ_RSP; 1060 1127 } else { 1061 assert(false &&"MEMCACHE Error : Bad HEAP allocation");1128 ASSERT(false,"MEMCACHE Error : Bad HEAP allocation"); 1062 1129 } 1063 1130 break; … … 1107 1174 { 1108 1175 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(), 1110 1177 true, 1111 1178 m_nline[(vci_addr_t)(m_cmd_read_addr_fifo.read())], … … 1178 1245 { 1179 1246 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 1180 1249 m_cpt_write++; 1181 1250 m_cpt_write_cells++; … … 1212 1281 1213 1282 // 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" ); 1216 1285 // consume a word in the FIFO & write it in the local buffer 1217 1286 cmd_write_fifo_get=true; … … 1239 1308 r_write_tag = entry.tag; 1240 1309 r_write_copy = entry.owner.srcid; 1310 #if L1_MULTI_CACHE 1311 r_write_copy_cache= entry.owner.cache_id; 1312 #endif 1241 1313 r_write_copy_inst = entry.owner.inst; 1242 1314 r_write_count = entry.count; … … 1287 1359 // update directory with Dirty bit 1288 1360 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(); 1300 1375 m_cache_directory.write(set, way, entry); 1301 1376 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 1303 1383 bool no_update = (r_write_count.read()==0) || ( owner && (r_write_count.read()==1)); 1304 1384 … … 1387 1467 case WRITE_UPT_REQ: 1388 1468 { 1389 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE) &&1390 1469 ASSERT( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE) 1470 ,"MemCache ERROR : bad HEAP allocation"); 1391 1471 if( !r_write_to_init_cmd_multi_req.read() && 1392 1472 !r_write_to_init_cmd_brdcast_req.read() ){ … … 1407 1487 } 1408 1488 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() ) { 1410 1494 // We put the first copy in the fifo 1411 1495 write_to_init_cmd_fifo_put = true; 1412 1496 write_to_init_cmd_fifo_inst = r_write_copy_inst.read(); 1413 1497 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 1414 1501 if(r_write_count.read() == 1){ 1415 1502 r_write_fsm = WRITE_IDLE; … … 1427 1514 case WRITE_UPDATE: // send a multi-update request to INIT_CMD fsm 1428 1515 { 1429 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE) &&1430 1516 ASSERT( (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE) 1517 ,"MemCache ERROR : bad HEAP allocation"); 1431 1518 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 1434 1525 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){ 1436 1531 write_to_init_cmd_fifo_put = true; 1437 1532 } else { … … 1471 1566 { 1472 1567 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 1473 1571 r_write_to_tgt_rsp_req = true; 1474 1572 r_write_to_tgt_rsp_srcid = r_write_srcid.read(); … … 1644 1742 case WRITE_DIR_INVAL: 1645 1743 { 1646 assert(((r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE ) &&1744 ASSERT(((r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE ) && 1647 1745 (r_alloc_upt_fsm.read() == ALLOC_UPT_WRITE ) && 1648 (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE )) &&1649 1746 (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE )) 1747 ,"MemCache ERROR : bad TRT,DIR or UPT allocation error"); 1650 1748 m_transaction_tab.set(r_write_trt_index.read(), 1651 1749 false, // write request to XRAM … … 1675 1773 entry.lock = false; 1676 1774 entry.owner.srcid = 0; 1775 #if L1_MULTI_CACHE 1776 entry.owner.cache_id= 0; 1777 #endif 1677 1778 entry.owner.inst = false; 1678 1779 entry.ptr = 0; … … 1890 1991 data_t data = p_vci_ixr.rdata.read(); 1891 1992 size_t index = r_ixr_rsp_trt_index.read(); 1892 assert(((eop == (r_ixr_rsp_cpt.read() == (m_words-1))) ||1893 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"); 1895 1996 m_transaction_tab.write_rsp(index, r_ixr_rsp_cpt.read(), data, p_vci_ixr.rerror.read()&0x1); 1896 1997 r_ixr_rsp_cpt = r_ixr_rsp_cpt.read() + 1; … … 1988 2089 1989 2090 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 1990 2094 r_xram_rsp_victim_copy_inst = victim.owner.inst; 1991 2095 r_xram_rsp_victim_count = victim.count; … … 2005 2109 if(m_cpt_cycles > DEBUG_START_CYCLE){ 2006 2110 std::cout << "XRAM_RSP FSM in XRAM_RSP_TRT_COPY state" << std::endl; 2007 std::cout << "Victim way : " << std::hex << way << " set " << s td::hex << set<< std::endl;2111 std::cout << "Victim way : " << std::hex << way << " set " << set << std::dec << std::endl; 2008 2112 victim.print(); 2009 2113 } … … 2093 2197 entry.ptr = 0; 2094 2198 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; 2104 2205 } 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; 2108 2212 } 2109 2213 m_cache_directory.write(set, way, entry); … … 2125 2229 2126 2230 if(r_xram_rsp_victim_inval.read()){ 2127 bool 2128 size_t index ;2231 bool brdcast = r_xram_rsp_victim_is_cnt.read(); 2232 size_t index = 0; 2129 2233 size_t count_copies = r_xram_rsp_victim_count.read(); 2130 2234 2235 //@@ 2131 2236 bool wok = m_update_tab.set(false, // it's an inval transaction 2132 2237 brdcast, // set brdcast bit 2133 2238 false, // it does not need a response 2134 0, 2135 0, 2136 0, 2239 0,//srcid 2240 0,//trdid 2241 0,//pktid 2137 2242 r_xram_rsp_victim_nline.read(), 2138 2243 count_copies, … … 2147 2252 r_xram_rsp_upt_index = index; 2148 2253 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"); 2150 2255 } 2151 2256 } … … 2234 2339 xram_rsp_to_init_cmd_fifo_srcid = r_xram_rsp_victim_copy.read(); 2235 2340 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 2236 2344 xram_rsp_to_init_cmd_fifo_put = multi_req; 2237 2345 … … 2277 2385 if( r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP ) { 2278 2386 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 2280 2391 xram_rsp_to_init_cmd_fifo_inst = entry.owner.inst; 2281 2392 xram_rsp_to_init_cmd_fifo_put = true; … … 2297 2408 case XRAM_RSP_HEAP_LAST: // last member of the list 2298 2409 { 2299 assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP) &&2300 2410 ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP) 2411 ,"MemCache ERROR : bad HEAP allocation"); 2301 2412 size_t free_pointer = m_heap_directory.next_free_ptr(); 2302 2413 2303 2414 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; 2306 2420 if(m_heap_directory.is_full()){ 2307 2421 last_entry.next = r_xram_rsp_next_ptr.read(); … … 2377 2491 { 2378 2492 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"); 2381 2495 2382 2496 bool reached = false; … … 2391 2505 reached) 2392 2506 { 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 2393 2509 m_cpt_cleanup++; 2394 2510 … … 2425 2541 r_cleanup_way = way; 2426 2542 r_cleanup_copy = entry.owner.srcid; 2543 #if L1_MULTI_CACHE 2544 r_cleanup_copy_cache= entry.owner.cache_id; 2545 #endif 2427 2546 r_cleanup_copy_inst = entry.owner.inst; 2428 2547 r_cleanup_count = entry.count; 2429 2548 r_cleanup_ptr = entry.ptr; 2430 2431 2549 2432 2550 // In case of hit, the copy must be cleaned in the copies bit-vector … … 2446 2564 case CLEANUP_DIR_WRITE: 2447 2565 { 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"); 2450 2568 size_t way = r_cleanup_way.read(); 2451 2569 #define L2 soclib::common::uint32_log2 … … 2453 2571 #undef L2 2454 2572 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 ); 2456 2578 bool match_inst = (r_cleanup_copy_inst.read() == cleanup_inst); 2457 2579 bool match = match_srcid && match_inst; … … 2467 2589 if(r_cleanup_is_cnt.read()) { // Directory is a counter 2468 2590 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; 2471 2596 // response to the cache 2472 2597 r_cleanup_fsm = CLEANUP_RSP; … … 2474 2599 else{ // Directory is a list 2475 2600 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; 2480 2608 } 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; 2485 2616 } 2486 2617 } … … 2501 2632 bool cleanup_inst = r_cleanup_trdid.read() & 0x1; 2502 2633 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 2503 2637 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; 2505 2639 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 2506 2643 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; 2512 2666 2513 2667 if(match_dir){ 2514 2668 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; 2524 2681 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; 2527 2684 } 2528 2685 else if(match_heap){ 2529 2686 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(); 2539 2699 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; 2542 2702 } 2543 2703 else{ … … 2552 2712 dir_entry.count = r_cleanup_count.read()-1; 2553 2713 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 2554 2717 dir_entry.owner.inst = r_cleanup_copy_inst.read(); 2555 2718 m_cache_directory.write(set,way,dir_entry); … … 2559 2722 2560 2723 } else{ 2561 assert(false &&"MemCache ERROR : CLEANUP hit but line not shared");2724 ASSERT(false,"MemCache ERROR : CLEANUP hit but line not shared"); 2562 2725 } 2563 2726 } … … 2568 2731 case CLEANUP_HEAP_SEARCH: 2569 2732 { 2570 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&2571 2733 ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) 2734 ,"MemCache ERROR : bad HEAP allocation"); 2572 2735 HeapEntry heap_entry = m_heap_directory.read(r_cleanup_next_ptr.read()); 2573 2736 bool last = (heap_entry.next == r_cleanup_next_ptr.read()); 2574 2737 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 ); 2576 2743 bool match_heap_inst = (heap_entry.owner.inst == cleanup_inst); 2577 2744 bool match_heap = match_heap_srcid && match_heap_inst; … … 2583 2750 else{ 2584 2751 if(last) { 2585 assert(false &&"MemCache ERROR : CLEANUP hit but line not shared");2752 ASSERT(false,"MemCache ERROR : CLEANUP hit but line not shared"); 2586 2753 } 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; 2590 2760 r_cleanup_next_ptr = heap_entry.next; 2591 2761 r_cleanup_fsm = CLEANUP_HEAP_SEARCH; … … 2598 2768 case CLEANUP_HEAP_CLEAN: 2599 2769 { 2600 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&2601 2770 ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) 2771 ,"MemCache ERROR : bad HEAP allocation"); 2602 2772 bool last = (r_cleanup_next_ptr.read() == r_cleanup_ptr.read()); 2603 2773 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(); 2606 2779 if(last){ // this is the last entry of the list of copies 2607 2780 heap_entry.next = r_cleanup_prev_ptr.read(); … … 2616 2789 case CLEANUP_HEAP_FREE: 2617 2790 { 2618 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) &&2619 2791 ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) 2792 ,"MemCache ERROR : bad HEAP allocation"); 2620 2793 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; 2623 2799 if(m_heap_directory.is_full()){ 2624 2800 heap_entry.next = r_cleanup_next_ptr.read(); … … 2760 2936 r_llsc_wdata = m_cmd_llsc_wdata_fifo.read(); 2761 2937 if(r_llsc_cpt.read()>3) 2762 assert(false &&"MEMCACHE error : SC too long");2938 ASSERT(false,"MEMCACHE error : SC too long"); 2763 2939 if(r_llsc_cpt.read()==2){ 2764 2940 r_llsc_wdata = m_cmd_llsc_wdata_fifo.read(); … … 2774 2950 size_t way = 0; 2775 2951 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; 2784 2964 if ( entry.valid ){ 2785 2965 r_llsc_fsm = SC_DIR_HIT_READ; … … 2798 2978 // update directory (lock & dirty bits 2799 2979 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(); 2809 2992 m_cache_directory.write(set, way, entry); 2810 2993 … … 2938 3121 case SC_UPT_REQ: // Request the update 2939 3122 { 2940 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC) &&2941 3123 ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC) 3124 ,"MemCache ERROR : bad HEAP allocation"); 2942 3125 if( !r_llsc_to_init_cmd_multi_req.read() && 2943 3126 !r_llsc_to_init_cmd_brdcast_req.read() ){ … … 2959 3142 llsc_to_init_cmd_fifo_inst = r_llsc_copy_inst.read(); 2960 3143 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 2961 3147 if(r_llsc_count.read() == 1){ 2962 3148 #ifdef LOCK_DEBUG … … 2978 3164 case SC_UPDATE: // send a multi-update request to INIT_CMD fsm 2979 3165 { 2980 assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC) &&2981 3166 ASSERT((r_alloc_heap_fsm.read() == ALLOC_HEAP_LLSC) 3167 ,"MemCache ERROR : bad HEAP allocation"); 2982 3168 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; 2985 3174 llsc_to_init_cmd_fifo_put = true; 2986 3175 … … 3106 3295 entry.count = 0; 3107 3296 entry.owner.srcid = 0; 3297 #if L1_MULTI_CACHE 3298 entry.owner.cache_id= 0; 3299 #endif 3108 3300 entry.owner.inst = false; 3109 3301 entry.ptr = 0; … … 3114 3306 r_llsc_fsm = SC_INVAL; 3115 3307 } 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"); 3117 3309 } 3118 3310 … … 3150 3342 r_llsc_cpt = 0; 3151 3343 } 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"); 3153 3345 } 3154 3346 break; … … 4109 4301 m_write_to_init_cmd_inst_fifo.put_and_get(write_to_init_cmd_fifo_inst); 4110 4302 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 4111 4306 } else { 4112 4307 m_write_to_init_cmd_inst_fifo.simple_put(write_to_init_cmd_fifo_inst); 4113 4308 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 4114 4312 } 4115 4313 } else { … … 4117 4315 m_write_to_init_cmd_inst_fifo.simple_get(); 4118 4316 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 4119 4320 } 4120 4321 } … … 4127 4328 m_xram_rsp_to_init_cmd_inst_fifo.put_and_get(xram_rsp_to_init_cmd_fifo_inst); 4128 4329 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 4129 4333 } else { 4130 4334 m_xram_rsp_to_init_cmd_inst_fifo.simple_put(xram_rsp_to_init_cmd_fifo_inst); 4131 4335 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 4132 4339 } 4133 4340 } else { … … 4135 4342 m_xram_rsp_to_init_cmd_inst_fifo.simple_get(); 4136 4343 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 4137 4347 } 4138 4348 } … … 4145 4355 m_llsc_to_init_cmd_inst_fifo.put_and_get(llsc_to_init_cmd_fifo_inst); 4146 4356 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 4147 4360 } 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 4150 4366 } 4151 4367 } 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 4155 4374 } 4156 4375 } … … 4160 4379 m_cpt_cycles++; 4161 4380 4162 } // end transition()4381 } // end transition() 4163 4382 4164 4383 ///////////////////////////// … … 4297 4516 break; 4298 4517 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 4299 4524 p_vci_tgt.rspval = true; 4300 4525 p_vci_tgt.rdata = r_read_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read(); … … 4306 4531 break; 4307 4532 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 4308 4539 p_vci_tgt.rspval = true; 4309 4540 p_vci_tgt.rdata = 0; … … 4315 4546 break; 4316 4547 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 4317 4554 p_vci_tgt.rspval = true; 4318 4555 p_vci_tgt.rdata = 0; … … 4324 4561 break; 4325 4562 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 4326 4569 p_vci_tgt.rspval = true; 4327 4570 p_vci_tgt.rdata = r_llsc_to_tgt_rsp_data.read(); … … 4333 4576 break; 4334 4577 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 4335 4584 p_vci_tgt.rspval = true; 4336 4585 p_vci_tgt.rdata = r_xram_rsp_to_tgt_rsp_data[r_tgt_rsp_cpt.read()].read(); … … 4343 4592 break; 4344 4593 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 4345 4600 p_vci_tgt.rspval = true; 4346 4601 p_vci_tgt.rdata = 0; … … 4359 4614 p_vci_ini.cmd = vci_param::CMD_WRITE; 4360 4615 p_vci_ini.srcid = m_srcid_ini; 4361 p_vci_ini.pktid = 0;4362 4616 p_vci_ini.cons = true; 4363 4617 p_vci_ini.wrap = false; … … 4377 4631 p_vci_ini.plen = 0; 4378 4632 p_vci_ini.trdid = 0; 4633 p_vci_ini.pktid = 0; 4379 4634 p_vci_ini.eop = false; 4380 4635 break; 4381 4636 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 4382 4643 p_vci_ini.cmdval = m_xram_rsp_to_init_cmd_inst_fifo.rok(); 4383 4644 if(m_xram_rsp_to_init_cmd_inst_fifo.rok()){ … … 4392 4653 p_vci_ini.plen = 4; 4393 4654 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(); 4394 4656 p_vci_ini.eop = true; 4395 4657 break; 4658 } 4396 4659 case INIT_CMD_XRAM_BRDCAST: 4397 4660 p_vci_ini.cmdval = true; … … 4401 4664 p_vci_ini.plen = 4; 4402 4665 p_vci_ini.trdid = r_xram_rsp_to_init_cmd_trdid.read(); 4666 p_vci_ini.pktid = 0; 4403 4667 p_vci_ini.eop = true; 4404 4668 break; … … 4412 4676 p_vci_ini.eop = true; 4413 4677 p_vci_ini.trdid = r_write_to_init_cmd_trdid.read(); 4678 p_vci_ini.pktid = 0; 4414 4679 break; 4415 4680 case INIT_CMD_UPDT_NLINE: … … 4429 4694 p_vci_ini.eop = false; 4430 4695 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(); 4431 4697 break; 4432 4698 case INIT_CMD_UPDT_INDEX: … … 4441 4707 p_vci_ini.plen = 4 * (r_write_to_init_cmd_count.read() + 2); 4442 4708 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(); 4443 4710 p_vci_ini.eop = false; 4444 4711 break; … … 4456 4723 p_vci_ini.plen = 4 * (r_write_to_init_cmd_count.read() + 2); 4457 4724 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(); 4458 4726 p_vci_ini.eop = ( r_init_cmd_cpt.read() == (r_write_to_init_cmd_count.read()-1) ); 4459 4727 break; … … 4467 4735 p_vci_ini.eop = true; 4468 4736 p_vci_ini.trdid = r_llsc_to_init_cmd_trdid.read(); 4737 p_vci_ini.pktid = 0; 4469 4738 break; 4470 4739 case INIT_CMD_SC_UPDT_NLINE: … … 4488 4757 p_vci_ini.eop = false; 4489 4758 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(); 4490 4760 break; 4491 4761 case INIT_CMD_SC_UPDT_INDEX: … … 4504 4774 } 4505 4775 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(); 4506 4777 p_vci_ini.eop = false; 4507 4778 break; … … 4516 4787 p_vci_ini.be = 0xF; 4517 4788 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(); 4518 4790 if(r_llsc_to_init_cmd_is_long.read()){ 4519 4791 p_vci_ini.plen = 4 * 4; … … 4535 4807 p_vci_ini.plen = 4 * 4; 4536 4808 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(); 4537 4810 p_vci_ini.eop = true; 4538 4811 break; … … 4567 4840 case CLEANUP_RSP: 4568 4841 { 4842 PRINTF(" * <MEM_CACHE.CLEANUP_RSP> Respons to %d.%d\n",(uint32_t)r_cleanup_srcid.read(),(uint32_t)r_cleanup_pktid.read()); 4843 4569 4844 p_vci_tgt_cleanup.rspval = true; 4570 4845 p_vci_tgt_cleanup.rdata = 0; -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/Makefile
r137 r140 1 1 #NO_SOFT = 1 2 2 ARCH = mips32el 3 #SIMULATION_ARGS = 1000004 #SOCLIB_CC_ADD_ARGS = "-DCC_XCACHE_WRAPPER_DEBUG=1"5 SOCLIB_CC_ADD_ARGS =-t systemcass3 #SIMULATION_ARGS = 4 #SOCLIB_CC_ADD_ARGS = -t systemc_32 5 SOCLIB_CC_ADD_ARGS = -t systemcass 6 6 SOCLIB ?= $(shell soclib-cc --getpath) 7 7 export SOCLIB -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/configuration/default.cfg
r134 r140 1 1 4 2 1 1 2 3 4 64 16 3 4 4 64 16 4 88 165 4 8 16 5 6 16 256 16 4096 -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/configuration/gen_config.sh
r134 r140 1 1 #!/bin/bash 2 2 3 # archi1 archi2 archi3 archi44 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 4 archi_name=( "min" "tsar" "full_assoc" "2k" "4k" ); 5 iways=( "1" "4" "16" "4" "4" ); 6 isets=( "8" "64" "1" "8" "16" ); 7 iwords=( "16" "16" "16" "16" "16" ); 8 dways=( "1" "4" "16" "4" "4" ); 9 dsets=( "8" "64" "1" "8" "16" ); 10 dwords=( "16" "16" "16" "16" "16" ); 11 memc_nways=( "4" "16" "8" "2" "16" ); 12 memc_nsets=( "4" "256" "64" "32" "64" ); 13 memc_words=( "16" "16" "16" "16" "16" ); 14 memc_heap_size=("4096" "4096" "4096" "4096" "4096" ); 15 15 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"); 16 nb_proc=( "1" "15" "+1" "4"); 17 nb_cpu_by_cache=("1" "15" "*2" "1"); 18 nb_cache=( "1" "16" "*2" "1"); 19 #wnwords=( "1" "16" "*2" "4"); 20 #wnlines=( "1" "8" "*2" "8"); 21 #wtimeout=( "1" "1024" "*4" "16"); 22 23 wnwords=( "4" "4" "*2" "4"); 24 wnlines=( "8" "8" "*2" "8"); 25 wtimeout=( "16" "16" "*4" "16"); 20 26 21 27 archi_default="1"; 28 gen_cfg=0; 22 29 23 30 function gen_file () 24 31 { 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}); 26 33 27 34 echo ${filename}; 28 35 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}; 34 42 } 35 43 … … 41 49 echo ${filename}; 42 50 43 echo "${nb_proc[3]}" > ${filename}; 51 echo "${nb_proc[3]}" > ${filename}; 52 echo "${nb_cpu_by_cache[3]} ${nb_cache[3]}" >> ${filename}; 44 53 echo "${iways[${archi}]} ${isets[${archi}]} ${iwords[${archi}]}" >> ${filename}; 45 54 echo "${dways[${archi}]} ${dsets[${archi}]} ${dwords[${archi}]}" >> ${filename}; … … 50 59 gen_default ${archi_default}; 51 60 52 nb_archi=${#iways[*]}; 61 if 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 53 70 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 64 72 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 66 78 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]})); 68 97 done; 69 num_lines=$((${num_lines} ${wnlines[2]})); 98 fi; 99 num_cpu_by_cache=$((${num_cpu_by_cache} ${nb_cpu_by_cache[2]})); 70 100 done; 71 num_ words=$((${num_words} ${wnwords[2]}));101 num_proc=$((${num_proc} ${nb_proc[2]})); 72 102 done; 73 num_ proc=$((${num_proc} ${nb_proc[2]}));103 num_archi=$((${num_archi}+1)); 74 104 done; 75 num_archi=$((${num_archi}+1)); 76 done; 105 fi; 77 106 78 -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/segmentation.h
r134 r140 35 35 #define MC_M_SIZE 0x000F0000 36 36 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 37 43 ////////////////////////////////////////////////////////// 38 44 // System devices … … 51 57 #define C_PROC_SIZE 0x00000010 52 58 #define C_PROC_SPAN 0x01000000 53 54 #define MC_R_BASE 0x2020000055 #define MC_R_SIZE 0x0000000856 57 //#define C_MC_M_BASE 0x0020000058 //#define C_MC_M_SIZE 0x0000000859 60 //#define XRAM_BASE 0xB020000061 //#define XRAM_SIZE 0x0000000862 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)) \ 1 ADD_OBJS = \ 2 $(patsubst self_code_modifying/%.c,self_code_modifying/%.o,$(wildcard self_code_modifying/*.c)) \ 6 3 $(patsubst matrix_multiplication/%.c,matrix_multiplication/%.o,$(wildcard matrix_multiplication/*.c)) \ 7 4 $(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 9 12 10 13 ADD_CFLAGS = 14 ADD_LDFLAGS = 11 15 SOCLIB ?= $(shell soclib-cc --getpath) 12 16 -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark.c
r134 r140 6 6 void benchmark (void) 7 7 { 8 /* if(procnum() != 0) */ 9 /* EXIT(0); */ 10 11 int result = 0; 8 int result = 0; 9 int num_cpu = procnum(); 12 10 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 { 18 17 #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; 21 20 #endif 22 21 #if BENCHMARK_DHRYSTONE 23 int result_dhrystone = benchmark_dhrystone();24 result += result_dhrystone;22 int result_dhrystone = benchmark_dhrystone(); 23 result += result_dhrystone; 25 24 #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; 29 44 #endif 30 45 #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; 33 48 #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"); 38 57 #if BENCHMARK_MATRIX_MULTIPLICATION_MT 39 printf(" * MM MT: %d\n",result_mm_mt);58 printf(" * MM MT : %d\n",result_mm_mt); 40 59 #endif 41 60 #if BENCHMARK_DHRYSTONE 42 printf(" * DHRYSTONE: %d\n",result_dhrystone);61 printf(" * DHRYSTONE : %d\n",result_dhrystone); 43 62 #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); 46 77 #endif 47 78 #if BENCHMARK_MATRIX_MULTIPLICATION_ST 48 printf(" * MM ST: %d\n",result_mm_st);79 printf(" * MM ST : %d\n",result_mm_st); 49 80 #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 } 52 87 } 53 }54 88 55 89 printf("\n"); -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark.h
r134 r140 5 5 6 6 void benchmark (void); 7 int benchmark_sort (void); 7 int benchmark_sort_all (void); 8 int benchmark_sort_bubble (void); 9 int benchmark_sort_insert (void); 10 int benchmark_sort_selection (void); 11 int benchmark_sort_shell (void); 8 12 int benchmark_dhrystone (void); 9 13 int benchmark_matrix_multiplication_st(void); -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_matrix_multiplication.c
r134 r140 127 127 /* matrix_multiplication_print(matrix_local_d, size); */ 128 128 129 #if VERIFICATION_MATRIX_MULTIPLICATION 129 130 printf(" * Verification... "); 130 131 131 132 benchmark_matrix_validation (matrix_local_d, size); 133 #endif 132 134 133 135 printf(" * Free...\n"); … … 230 232 if (matrix_nb_thread_stop == matrix_nb_thread_start) 231 233 { 234 #if VERIFICATION_MATRIX_MULTIPLICATION 232 235 printf(" * Verification... "); 233 236 234 237 benchmark_matrix_validation (matrix_global_d, size); 238 #endif 235 239 236 240 printf(" * Free...\n"); -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_sort.c
r134 r140 9 9 static uint32_t sort_lock; 10 10 11 int _benchmark_sort (unsigned int size) 11 int _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 68 int _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 87 int _benchmark_sort_one (sort_t sort_type, 88 unsigned int size) 12 89 { 13 90 printf("\n"); … … 17 94 printf("\n"); 18 95 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); 80 97 } 81 98 82 int benchmark_sort (void) { return _benchmark_sort(SORT_SIZE); } 83 84 99 int benchmark_sort_all (void) { return _benchmark_sort_all(SORT_ALL_SIZE); } 100 int benchmark_sort_bubble (void) { return _benchmark_sort_one(SORT_BUBBLE ,SORT_BUBBLE_SIZE ); } 101 int benchmark_sort_insertion (void) { return _benchmark_sort_one(SORT_INSERTION,SORT_INSERTION_SIZE); } 102 int benchmark_sort_selection (void) { return _benchmark_sort_one(SORT_SELECTION,SORT_SELECTION_SIZE); } 103 int 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 41 41 } 42 42 43 pause(); 44 43 45 while(1); 44 46 } -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/define.h
r134 r140 3 3 4 4 // List of benchmark 5 #define BENCHMARK_NB_THREAD 4 6 5 7 #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 7 13 #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 9 16 10 17 #define VERBOSE_SORT 0 11 18 19 #define VERIFICATION_SORT 0 20 #define VERIFICATION_MATRIX_MULTIPLICATION 0 21 12 22 // Benchmark size 13 23 #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 15 29 #define MATRIX_MULTIPLICATION_ST_SIZE 50 16 #define MATRIX_MULTIPLICATION_MT_SIZE 7530 #define MATRIX_MULTIPLICATION_MT_SIZE 96 17 31 #define MATRIX_MULTIPLICATION_MT_LOCK_BY_LINE 1 32 #define SELF_CODE_MODIFYING_NB_RUNS 10 18 33 19 34 // Timer configuration -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/dhrystone/dhry21a.c
r134 r140 76 76 DOUBLE dtime(); 77 77 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; 80 80 One_Fifty Int_3_Loc; 81 81 REG char Ch_Index; -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/matrix_multiplication/matrix_multiplication.c
r134 r140 2 2 #include "stdio.h" 3 3 #include "system.h" 4 #include "stdint.h" 4 5 5 6 void matrix_multiplication_st (int ** a, … … 8 9 unsigned int n) 9 10 { 10 int x, y;11 uint32_t x, y; 11 12 12 13 for (x=0; x<n; ++x) … … 16 17 for (y=0; y<n; ++y) 17 18 { 18 int i;19 uint32_t i; 19 20 20 21 int tmp = 0; … … 28 29 } 29 30 30 static int lock;31 static int next;31 static uint32_t lock; 32 static uint32_t next; 32 33 33 34 void matrix_multiplication_mt (int ** a, … … 37 38 int lock_by_line) 38 39 { 39 int x, y;40 uint32_t x, y; 40 41 41 42 while (1) -
trunk/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/top.cpp
r137 r140 31 31 # define PARAM_VCI 4,8,32,1,1,1,8,4,4,1 32 32 33 # define USE_OLD_XCACHE 0 34 # define USE_VGMN 1 33 35 # define NB_PROC_MIN 1 34 36 # define NB_PROC_MAX 15 35 // min_latency,fifo_depth37 // fifo_depth 36 38 # define PARAM_RING_P 2 37 39 # define PARAM_RING_C 2 38 40 # define PARAM_RING_X 2 39 41 // 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 41 44 42 45 // * Debug … … 46 49 47 50 // * Simulation 48 # define FILE_DEFAULT "configuration/default.cfg"51 # define CONFIG_DEFAULT "configuration/default.cfg" 49 52 # define NCYCLES_DEFAULT 0 50 53 # define SOFT_DEFAULT "soft/bin.soft" … … 53 56 void usage (char * funcname) 54 57 { 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; 59 71 60 72 exit(1); … … 63 75 int _main(int argc, char *argv[]) 64 76 { 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 } 78 105 79 106 if (ncycles == 0) 80 107 ncycles = -1; 81 #endif82 108 83 109 uint32_t nb_proc; 110 uint32_t nb_cpu_by_cache; 111 uint32_t nb_dcache; 84 112 uint32_t iways, isets, iwords; 85 113 uint32_t dways, dsets, dwords; … … 88 116 89 117 std::ifstream inFile; 90 const char * filename = (argc>=3)?argv[2]:FILE_DEFAULT;118 const char * filename = config; 91 119 92 120 inFile.open(filename); … … 102 130 nb_proc =std::atoi(str.c_str()); 103 131 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]);} 104 136 iways =std::atoi(str.c_str()); 105 137 if (not (inFile >> str)){std::cout << "Invalid parameters number in configuration file." << std::endl; usage(argv[0]);} … … 128 160 memc_heap_size =std::atoi(str.c_str()); 129 161 130 if (( nb_proc<NB_PROC_MIN) or131 ( 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)) 132 164 { 133 165 std::cout << "Parameters nb_proc is out of bound." << std::endl; … … 135 167 } 136 168 137 char * soft;138 139 if (argc >= 4)140 soft = argv[3];141 else142 soft = SOFT_DEFAULT;143 144 169 std::cout << " * Parameters : " << std::endl; 145 170 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; 146 173 std::cout << " * iways : " << iways << std::endl; 147 174 std::cout << " * isets : " << isets << std::endl; … … 180 207 maptabp.add(Segment("mc_r" , MC_R_BASE , MC_R_SIZE , IntTab(2), false, true, IntTab(0))); 181 208 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)); 183 211 maptabp.add(Segment("xicu" , XICU_BASE , XICU_SIZE , IntTab(3), false)); 184 212 maptabp.add(Segment("simhelper", SIMHELPER_BASE, SIMHELPER_SIZE, IntTab(4), false)); … … 187 215 188 216 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 // } 189 224 for (uint32_t i=0; i<nb_proc; ++i) 190 225 { … … 195 230 maptabc.add(Segment("mc_r" , MC_R_BASE , MC_R_SIZE , IntTab(nb_proc), false, false)); 196 231 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)); 197 233 maptabc.add(Segment("reset" , RESET_BASE , RESET_SIZE , IntTab(nb_proc), false, false)); 198 234 maptabc.add(Segment("excep" , EXCEP_BASE , EXCEP_SIZE , IntTab(nb_proc), false, false)); 199 235 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)); 201 237 202 238 std::cout << maptabc << std::endl; … … 204 240 soclib::common::MappingTable maptabx(32, IntTab(8), IntTab(8), 0x00300000); 205 241 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)); 206 243 maptabx.add(Segment("reset", RESET_BASE, RESET_SIZE, IntTab(0), false)); 207 244 maptabx.add(Segment("excep", EXCEP_BASE, EXCEP_SIZE, IntTab(0), false)); … … 215 252 sc_signal<bool> signal_resetn("resetn"); 216 253 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); 218 255 219 256 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); … … 236 273 soclib::caba::VciSignals<vci_param> signal_vci_tgt_cleanup_memc("vci_tgt_cleanup_memc"); 237 274 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); 239 276 240 277 soclib::common::Loader loader(soft); … … 245 282 for (uint32_t i=0; i<nb_proc; ++i) 246 283 { 284 uint32_t num_cpu = i*nb_cpu_by_cache; 285 247 286 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 251 291 ,iways, isets, iwords 252 292 ,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 254 300 ); 255 301 … … 267 313 // x_init c_init p_tgt c_tgt 268 314 soclib::caba::VciMemCacheV4<vci_param> 269 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); 270 316 271 317 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) 273 319 { 274 320 std::ostringstream str; … … 308 354 { 309 355 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 } 317 366 proc[i]->p_vci_ini_rw(signal_vci_ini_rw_proc[i]); 318 367 proc[i]->p_vci_ini_c(signal_vci_ini_c_proc[i]); … … 328 377 tty.p_vci(signal_vci_tgt_tty); 329 378 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]); 331 381 332 382 xicu.p_clk(signal_clk); … … 334 384 xicu.p_vci(signal_vci_tgt_xicu); 335 385 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 } 340 391 341 392 simhelper.p_clk(signal_clk); … … 392 443 debug(); 393 444 #elif DEBUG_TOP 394 for (int32_t i=0; i<ncycles; ++i) 445 446 uint32_t num_cycle=0; 447 while(1) 395 448 { 396 449 std::cout << std::endl 397 << std::dec << "===== [ cycle " << i<< " ]======" << std::endl450 << std::dec << "===== [ cycle " << num_cycle << " ]======" << std::endl 398 451 << std::endl; 399 452 … … 402 455 // for (uint32_t i=0; i<nb_proc; ++i) 403 456 // proc[i]->print_trace(1); 457 num_cycle ++; 404 458 } 405 459 #else … … 418 472 proc[i]->print_stats(); 419 473 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); 421 475 soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_tgt_proc , nb_proc); 422 476 soclib::common::dealloc_elems<soclib::caba::VciSignals<vci_param> >(signal_vci_ini_c_proc , nb_proc); 423 477 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); 425 479 426 480 for (uint32_t i=0; i<nb_proc; ++i) -
trunk/platforms/tsarv4_dspin_generic_32/tsarv4_dspin_generic_32_top.cpp
r134 r140 370 370 // IRQ signals (one signal per proc) 371 371 372 sc_signal<bool>*** 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); 374 374 375 375 sc_signal<bool>* signal_irq_mtty = … … 548 548 IntTab(cluster(x,y),PROC_SRCID+p), // SRCID_C 549 549 IntTab(cluster(x,y),PROC_SRCID+p), // TGTID_C 550 1,1, 550 551 4,64,16,4,64,16, // Icache and Dcache sizes 551 552 4,8,16); … … 743 744 proc[x][y][p]->p_vci_ini_c (signal_vci_ini_c_proc[x][y][p]); 744 745 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]); 746 747 for ( size_t j = 1 ; j < 6 ; j++ ) 747 748 { 748 proc[x][y][p]->p_irq[ j] (signal_false);749 proc[x][y][p]->p_irq[0][j] (signal_false); 749 750 } 750 751 } … … 756 757 for ( size_t p = 0 ; p < nprocs ; p++ ) 757 758 { 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]); 759 760 } 760 761 -
trunk/platforms/tsarv4_vgmn_generic_32/tsarv4_vgmn_generic_32_top.cpp
r134 r140 372 372 373 373 // IRQ signals (one signal per proc) 374 sc_signal<bool>*** 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); 376 376 377 377 sc_signal<bool>* signal_irq_mtty = … … 539 539 IntTab(cluster(x,y), PROC_SRCID+p), // SRCID_C 540 540 IntTab(cluster(x,y), PROC_SRCID+p), // TGTID_C 541 1,1, 541 542 4,64,16,4,64,16 // Icache and Dcache sizes 542 543 ,4,8,16 … … 715 716 proc[x][y][p]->p_vci_ini_c (signal_vci_ini_c_proc[x][y][p]); 716 717 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]); 718 719 for ( size_t j = 1 ; j < 6 ; j++ ) 719 720 { 720 proc[x][y][p]->p_irq[ j] (signal_false);721 proc[x][y][p]->p_irq[0][j] (signal_false); 721 722 } 722 723 } … … 728 729 for ( size_t p = 0 ; p < nprocs ; p++ ) 729 730 { 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]); 731 732 } 732 733
Note: See TracChangeset
for help on using the changeset viewer.