- Timestamp:
- Jan 24, 2011, 5:36:50 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_cc_xcache_wrapper_v4/caba/source/include/vci_cc_xcache_wrapper_v4.h
r118 r134 32 32 #include <inttypes.h> 33 33 #include <systemc> 34 #include <queue> 34 35 #include "caba_base_module.h" 35 #include " write_buffer.h"36 #include "multi_write_buffer.h" 36 37 #include "generic_cache.h" 37 38 #include "vci_initiator.h" … … 40 41 #include "static_assert.h" 41 42 43 /* 44 * CC_XCACHE_WRAPPER_SELECT_VICTIM : 45 * The selection and the update of cache (after a read miss) 46 * are separated in two step 47 * Also, the cleanup can be send in parallel at the read miss. 48 * 49 * CC_XCACHE_WRAPPER_FIFO_RSP 50 * Two simple fifo (each 2x32 depth) receive the cache line from 51 * RAM. Instead of two buffers (m_icache_words and m_dcache_words) 52 * 53 * CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 54 * Update cache in "2*cache_words" cycles (read+mask, write) 55 * 56 * CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT 57 * Update cache with only modified data (be != 0) 58 * 59 * CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME 60 * Write buffer scheme for update step : 61 * 1 - multi_scan 62 * 2 - round_robin_scan 63 * 3 - one_scan 64 * else - default scheme 65 * 66 * CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY 67 * Write buffer access is conditionnal with dcache_miss_req and icache_miss_req 68 * 1 - two access authorized 69 * 2 - one access with static priority (dcache prior) 70 * 3 - one access with static priority (icache prior) 71 * 4 - one access with round robin priority 72 * 73 * CC_XCACHE_WRAPPER_STOP_SIMULATION : 74 * stop simulation if processor is stall after a long time 75 * (configurable with "stop_simulation" function) 76 * 77 * CC_XCACHE_WRAPPER_DEBUG : 78 * Add log to help the debugging 79 * 80 * CC_XCACHE_WRAPPER_DEBUG_CYCLE_MIN : 81 * Number of cycle before to prinf debug message 82 * 83 * CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION 84 * Print transaction between the cpu and the cache 85 */ 86 87 // implementation 88 #ifndef CC_XCACHE_WRAPPER_SELECT_VICTIM 89 #define CC_XCACHE_WRAPPER_SELECT_VICTIM 0 90 #endif 91 #ifndef CC_XCACHE_WRAPPER_FIFO_RSP 92 #define CC_XCACHE_WRAPPER_FIFO_RSP 0 93 #endif 94 #ifndef CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 95 #define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 1 96 #endif 97 #ifndef CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT 98 #define CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE_OPT 1 99 #endif 100 #ifndef CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME 101 #define CC_XCACHE_WRAPPER_WBUF_UPDATE_SCHEME 0 102 #endif 103 #ifndef CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY 104 #define CC_XCACHE_WRAPPER_VCI_CMD_PRIORITY 2 105 #endif 106 // debugging 107 #ifndef CC_XCACHE_WRAPPER_STOP_SIMULATION 108 #define CC_XCACHE_WRAPPER_STOP_SIMULATION 1 109 #endif 110 #ifndef CC_XCACHE_WRAPPER_DEBUG 111 #define CC_XCACHE_WRAPPER_DEBUG 0 112 #endif 113 #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 118 #endif 42 119 43 120 namespace soclib { … … 58 135 typedef uint32_t be_t; 59 136 typedef typename vci_param::fast_addr_t vci_addr_t; 137 60 138 enum dcache_fsm_state_e { 61 139 DCACHE_IDLE, 62 140 DCACHE_WRITE_UPDT, 63 DCACHE_WRITE_REQ, 141 #if CC_XCACHE_WRAPPER_SELECT_VICTIM 142 DCACHE_MISS_VICTIM, 143 #endif 64 144 DCACHE_MISS_WAIT, 65 145 DCACHE_MISS_UPDT, … … 67 147 DCACHE_SC_WAIT, 68 148 DCACHE_INVAL, 149 DCACHE_SYNC, 69 150 DCACHE_ERROR, 70 151 DCACHE_CC_CHECK, … … 76 157 enum icache_fsm_state_e { 77 158 ICACHE_IDLE, 159 #if CC_XCACHE_WRAPPER_SELECT_VICTIM 160 ICACHE_MISS_VICTIM, 161 #endif 78 162 ICACHE_MISS_WAIT, 79 163 ICACHE_MISS_UPDT, … … 94 178 CMD_DATA_WRITE, 95 179 CMD_DATA_SC, 96 CMD_INS_CLEANUP,97 CMD_DATA_CLEANUP,98 180 }; 99 181 … … 106 188 RSP_DATA_WRITE, 107 189 RSP_DATA_SC, 108 RSP_INS_CLEANUP,109 RSP_DATA_CLEANUP,110 190 }; 111 191 … … 122 202 }; 123 203 204 enum cleanup_fsm_state_e { 205 CLEANUP_IDLE, 206 CLEANUP_DCACHE, 207 CLEANUP_ICACHE, 208 }; 209 210 enum transaction_type_c_e { 211 // convention with memcache 212 TYPE_DATA_CLEANUP = 0x0, 213 TYPE_INS_CLEANUP = 0x1 214 }; 215 216 enum transaction_type_rw_e { 217 // convention with memcache 218 // b0 : 1 if cached 219 // b1 : 1 if instruction 220 // b2 : 1 if sc 221 TYPE_DATA_UNC = 0x0, 222 TYPE_DATA_MISS = 0x1, 223 TYPE_INS_UNC = 0x2, 224 TYPE_INS_MISS = 0x3, 225 TYPE_DATA_SC = 0x4, // sc is data and no cached 226 }; 227 124 228 public: 125 229 … … 143 247 const size_t m_dcache_ways; 144 248 const size_t m_dcache_words; 249 const uint32_t m_dcache_words_shift; 145 250 const size_t m_dcache_yzmask; 146 251 const size_t m_icache_ways; 147 252 const size_t m_icache_words; 253 const uint32_t m_icache_words_shift; 148 254 const size_t m_icache_yzmask; 255 const size_t m_cache_words; // max between m_dcache_words and m_icache_words 256 257 #if CC_XCACHE_WRAPPER_STOP_SIMULATION 258 bool m_stop_simulation; 259 uint32_t m_stop_simulation_nb_frz_cycles_max; 260 uint32_t m_stop_simulation_nb_frz_cycles; 261 #endif // CC_XCACHE_WRAPPER_STOP_SIMULATION 149 262 150 263 // REGISTERS … … 154 267 sc_signal<data_t> r_dcache_wdata_save; 155 268 sc_signal<data_t> r_dcache_rdata_save; 156 sc_signal<data_64> r_dcache_ll_data;157 sc_signal<addr_40> r_dcache_ll_addr;158 sc_signal<bool> r_dcache_ll_valid;159 269 sc_signal<int> r_dcache_type_save; 160 270 sc_signal<be_t> r_dcache_be_save; … … 163 273 sc_signal<addr_40> r_dcache_cleanup_line; 164 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; 165 277 sc_signal<bool> r_dcache_unc_req; 166 278 sc_signal<bool> r_dcache_sc_req; 167 sc_signal<bool> r_dcache_write_req;168 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; 169 285 170 286 sc_signal<int> r_icache_fsm; … … 172 288 sc_signal<addr_40> r_icache_addr_save; 173 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; 174 292 sc_signal<bool> r_icache_unc_req; 175 293 sc_signal<bool> r_icache_cleanup_req; 176 294 sc_signal<addr_40> r_icache_cleanup_line; 177 295 sc_signal<bool> r_icache_inval_rsp; 296 sc_signal<size_t> r_icache_update_addr; 178 297 179 298 sc_signal<int> r_vci_cmd_fsm; … … 181 300 sc_signal<size_t> r_vci_cmd_max; 182 301 sc_signal<size_t> r_vci_cmd_cpt; 302 sc_signal<bool> r_vci_cmd_dcache_prior; 183 303 184 304 sc_signal<int> r_vci_rsp_fsm; … … 186 306 sc_signal<bool> r_vci_rsp_data_error; 187 307 sc_signal<size_t> r_vci_rsp_cpt; 188 189 data_t *r_icache_miss_buf; 190 data_t *r_dcache_miss_buf; 308 sc_signal<bool> r_vci_rsp_ack; 309 310 #if CC_XCACHE_WRAPPER_FIFO_RSP 311 std::queue<data_t> r_icache_miss_buf; 312 std::queue<data_t> r_dcache_miss_buf; 313 #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 191 319 sc_signal<bool> r_icache_buf_unc_valid; 192 320 193 data_t *r_tgt_buf; 194 be_t *r_tgt_be; 321 data_t *r_tgt_buf; //[m_cache_words] 322 be_t *r_tgt_be; //[m_cache_words] 323 #if CC_XCACHE_WRAPPER_CC_UPDATE_MULTI_CYCLE 324 sc_signal<uint32_t> r_cache_word; 325 #endif 195 326 196 327 sc_signal<int> r_vci_tgt_fsm; … … 199 330 sc_signal<bool> r_tgt_update; 200 331 sc_signal<bool> r_tgt_update_data; 201 332 //sc_signal<bool> r_tgt_brdcast; 202 333 sc_signal<size_t> r_tgt_srcid; 203 334 sc_signal<size_t> r_tgt_pktid; 204 335 sc_signal<size_t> r_tgt_trdid; 205 336 //sc_signal<size_t> r_tgt_plen; 206 337 sc_signal<bool> r_tgt_icache_req; 207 338 sc_signal<bool> r_tgt_dcache_req; … … 209 340 sc_signal<bool> r_tgt_dcache_rsp; 210 341 211 WriteBuffer<addr_40> r_wbuf; 342 sc_signal<int> r_cleanup_fsm; // controls initiator port of the coherence network 343 344 MultiWriteBuffer<addr_40> r_wbuf; 212 345 GenericCache<vci_addr_t> r_icache; 213 346 GenericCache<vci_addr_t> r_dcache; 214 347 348 #if CC_XCACHE_WRAPPER_DEBUG_DCACHE_TRANSACTION 349 std::ofstream log_dcache_transaction_file; 350 #endif 351 215 352 // Activity counters 216 uint32_t m_cpt_dcache_data_read; // DCACHE DATA READ 217 uint32_t m_cpt_dcache_data_write; // DCACHE DATA WRITE 218 uint32_t m_cpt_dcache_dir_read; // DCACHE DIR READ 219 uint32_t m_cpt_dcache_dir_write; // DCACHE DIR WRITE 220 221 uint32_t m_cpt_icache_data_read; // ICACHE DATA READ 222 uint32_t m_cpt_icache_data_write; // ICACHE DATA WRITE 223 uint32_t m_cpt_icache_dir_read; // ICACHE DIR READ 224 uint32_t m_cpt_icache_dir_write; // ICACHE DIR WRITE 225 226 uint32_t m_cpt_cc_update; // number of coherence update packets 227 uint32_t m_cpt_cc_inval; // number of coherence inval packets 228 229 uint32_t m_cpt_frz_cycles; // number of cycles where the cpu is frozen 230 uint32_t m_cpt_total_cycles; // total number of cycles 231 232 uint32_t m_cpt_read; // total number of read instructions 233 uint32_t m_cpt_write; // total number of write instructions 234 uint32_t m_cpt_data_miss; // number of read miss 235 uint32_t m_cpt_ins_miss; // number of instruction miss 236 uint32_t m_cpt_unc_read; // number of read uncached 237 uint32_t m_cpt_write_cached; // number of cached write 238 239 uint32_t m_cost_write_frz; // number of frozen cycles related to write buffer 240 uint32_t m_cost_data_miss_frz; // number of frozen cycles related to data miss 241 uint32_t m_cost_unc_read_frz; // number of frozen cycles related to uncached read 242 uint32_t m_cost_ins_miss_frz; // number of frozen cycles related to ins miss 243 244 uint32_t m_cpt_imiss_transaction; // number of VCI instruction miss transactions 245 uint32_t m_cpt_dmiss_transaction; // number of VCI data miss transactions 246 uint32_t m_cpt_unc_transaction; // number of VCI uncached read transactions 247 uint32_t m_cpt_write_transaction; // number of VCI write transactions 248 249 uint32_t m_cost_imiss_transaction; // cumulated duration for VCI IMISS transactions 250 uint32_t m_cost_dmiss_transaction; // cumulated duration for VCI DMISS transactions 251 uint32_t m_cost_unc_transaction; // cumulated duration for VCI UNC transactions 252 uint32_t m_cost_write_transaction; // cumulated duration for VCI WRITE transactions 253 uint32_t m_length_write_transaction; // cumulated length for VCI WRITE transactions 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 254 397 255 398 protected: … … 271 414 size_t dcache_ways, 272 415 size_t dcache_sets, 273 size_t dcache_words ); 416 size_t dcache_words, 417 size_t wbuf_nwords, 418 size_t wbuf_nlines, 419 size_t wbuf_timeout 420 ); 274 421 275 422 ~VciCcXCacheWrapperV4(); … … 278 425 void print_cpi(); 279 426 void print_stats(); 427 428 // #if CC_XCACHE_WRAPPER_STOP_SIMULATION 429 void stop_simulation (uint32_t); 430 // #endif // CC_XCACHE_WRAPPER_STOP_SIMULATION 280 431 281 432 private: … … 300 451 301 452 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 302 303 304
Note: See TracChangeset
for help on using the changeset viewer.