[331] | 1 | /* -*- c++ -*- |
---|
| 2 | * File : vci_cc_vcache_wrapper.cpp |
---|
| 3 | * Copyright (c) UPMC, Lip6, SoC |
---|
| 4 | * Authors : Alain GREINER, Yang GAO |
---|
| 5 | * |
---|
| 6 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
| 7 | * |
---|
| 8 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
| 9 | * |
---|
| 10 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
| 11 | * under the terms of the GNU Lesser General Public License as published |
---|
| 12 | * by the Free Software Foundation; version 2.1 of the License. |
---|
| 13 | * |
---|
| 14 | * SoCLib is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 17 | * Lesser General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU Lesser General Public |
---|
| 20 | * License along with SoCLib; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
| 22 | * 02110-1301 USA |
---|
| 23 | * |
---|
| 24 | * SOCLIB_LGPL_HEADER_END |
---|
| 25 | * |
---|
| 26 | * Maintainers: cesar.fuguet-tortolero@lip6.fr |
---|
| 27 | * alexandre.joannou@lip6.fr |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #include <cassert> |
---|
[752] | 31 | #include <signal.h> |
---|
| 32 | |
---|
[331] | 33 | #include "arithmetics.h" |
---|
[351] | 34 | #include "../include/vci_cc_vcache_wrapper.h" |
---|
[331] | 35 | |
---|
[789] | 36 | #define DEBUG_DCACHE 1 |
---|
| 37 | #define DEBUG_ICACHE 1 |
---|
| 38 | #define DEBUG_CMD 0 |
---|
[331] | 39 | |
---|
| 40 | namespace soclib { |
---|
| 41 | namespace caba { |
---|
| 42 | |
---|
| 43 | namespace { |
---|
[789] | 44 | const char * icache_fsm_state_str[] = { |
---|
[331] | 45 | "ICACHE_IDLE", |
---|
| 46 | |
---|
| 47 | "ICACHE_XTN_TLB_FLUSH", |
---|
| 48 | "ICACHE_XTN_CACHE_FLUSH", |
---|
| 49 | "ICACHE_XTN_CACHE_FLUSH_GO", |
---|
| 50 | "ICACHE_XTN_TLB_INVAL", |
---|
| 51 | "ICACHE_XTN_CACHE_INVAL_VA", |
---|
| 52 | "ICACHE_XTN_CACHE_INVAL_PA", |
---|
| 53 | "ICACHE_XTN_CACHE_INVAL_GO", |
---|
| 54 | |
---|
| 55 | "ICACHE_TLB_WAIT", |
---|
| 56 | |
---|
| 57 | "ICACHE_MISS_SELECT", |
---|
| 58 | "ICACHE_MISS_CLEAN", |
---|
| 59 | "ICACHE_MISS_WAIT", |
---|
| 60 | "ICACHE_MISS_DATA_UPDT", |
---|
| 61 | "ICACHE_MISS_DIR_UPDT", |
---|
| 62 | |
---|
| 63 | "ICACHE_UNC_WAIT", |
---|
| 64 | |
---|
| 65 | "ICACHE_CC_CHECK", |
---|
[468] | 66 | "ICACHE_CC_UPDT", |
---|
[331] | 67 | "ICACHE_CC_INVAL", |
---|
| 68 | }; |
---|
| 69 | |
---|
[789] | 70 | const char * dcache_fsm_state_str[] = { |
---|
[331] | 71 | "DCACHE_IDLE", |
---|
| 72 | |
---|
| 73 | "DCACHE_TLB_MISS", |
---|
| 74 | "DCACHE_TLB_PTE1_GET", |
---|
| 75 | "DCACHE_TLB_PTE1_SELECT", |
---|
| 76 | "DCACHE_TLB_PTE1_UPDT", |
---|
| 77 | "DCACHE_TLB_PTE2_GET", |
---|
| 78 | "DCACHE_TLB_PTE2_SELECT", |
---|
| 79 | "DCACHE_TLB_PTE2_UPDT", |
---|
| 80 | "DCACHE_TLB_LR_UPDT", |
---|
| 81 | "DCACHE_TLB_LR_WAIT", |
---|
| 82 | "DCACHE_TLB_RETURN", |
---|
| 83 | |
---|
| 84 | "DCACHE_XTN_SWITCH", |
---|
| 85 | "DCACHE_XTN_SYNC", |
---|
| 86 | "DCACHE_XTN_IC_INVAL_VA", |
---|
| 87 | "DCACHE_XTN_IC_FLUSH", |
---|
| 88 | "DCACHE_XTN_IC_INVAL_PA", |
---|
[721] | 89 | "DCACHE_XTN_IC_PADDR_EXT", |
---|
[331] | 90 | "DCACHE_XTN_IT_INVAL", |
---|
| 91 | "DCACHE_XTN_DC_FLUSH", |
---|
| 92 | "DCACHE_XTN_DC_FLUSH_GO", |
---|
| 93 | "DCACHE_XTN_DC_INVAL_VA", |
---|
| 94 | "DCACHE_XTN_DC_INVAL_PA", |
---|
| 95 | "DCACHE_XTN_DC_INVAL_END", |
---|
| 96 | "DCACHE_XTN_DC_INVAL_GO", |
---|
| 97 | "DCACHE_XTN_DT_INVAL", |
---|
| 98 | |
---|
[384] | 99 | "DCACHE_DIRTY_GET_PTE", |
---|
[331] | 100 | "DCACHE_DIRTY_WAIT", |
---|
| 101 | |
---|
| 102 | "DCACHE_MISS_SELECT", |
---|
| 103 | "DCACHE_MISS_CLEAN", |
---|
| 104 | "DCACHE_MISS_WAIT", |
---|
| 105 | "DCACHE_MISS_DATA_UPDT", |
---|
| 106 | "DCACHE_MISS_DIR_UPDT", |
---|
| 107 | |
---|
| 108 | "DCACHE_UNC_WAIT", |
---|
| 109 | "DCACHE_LL_WAIT", |
---|
| 110 | "DCACHE_SC_WAIT", |
---|
| 111 | |
---|
| 112 | "DCACHE_CC_CHECK", |
---|
[468] | 113 | "DCACHE_CC_UPDT", |
---|
[331] | 114 | "DCACHE_CC_INVAL", |
---|
| 115 | |
---|
| 116 | "DCACHE_INVAL_TLB_SCAN", |
---|
| 117 | }; |
---|
| 118 | |
---|
[789] | 119 | const char * cmd_fsm_state_str[] = { |
---|
[331] | 120 | "CMD_IDLE", |
---|
| 121 | "CMD_INS_MISS", |
---|
| 122 | "CMD_INS_UNC", |
---|
| 123 | "CMD_DATA_MISS", |
---|
[616] | 124 | "CMD_DATA_UNC_READ", |
---|
| 125 | "CMD_DATA_UNC_WRITE", |
---|
[331] | 126 | "CMD_DATA_WRITE", |
---|
| 127 | "CMD_DATA_LL", |
---|
| 128 | "CMD_DATA_SC", |
---|
| 129 | "CMD_DATA_CAS", |
---|
| 130 | }; |
---|
| 131 | |
---|
[789] | 132 | const char * vci_pktid_type_str[] = { |
---|
[616] | 133 | "TYPE_DATA_UNC", |
---|
[423] | 134 | "TYPE_READ_DATA_MISS", |
---|
| 135 | "TYPE_READ_INS_UNC", |
---|
| 136 | "TYPE_READ_INS_MISS", |
---|
| 137 | "TYPE_WRITE", |
---|
| 138 | "TYPE_CAS", |
---|
| 139 | "TYPE_LL", |
---|
| 140 | "TYPE_SC", |
---|
| 141 | }; |
---|
| 142 | |
---|
[789] | 143 | const char * vci_cmd_type_str[] = { |
---|
[423] | 144 | "NOP or STORE_COND", |
---|
| 145 | "READ", |
---|
| 146 | "WRITE", |
---|
| 147 | "LOCKED_READ" |
---|
| 148 | }; |
---|
| 149 | |
---|
[789] | 150 | const char * rsp_fsm_state_str[] = { |
---|
[331] | 151 | "RSP_IDLE", |
---|
| 152 | "RSP_INS_MISS", |
---|
| 153 | "RSP_INS_UNC", |
---|
| 154 | "RSP_DATA_MISS", |
---|
| 155 | "RSP_DATA_UNC", |
---|
| 156 | "RSP_DATA_LL", |
---|
| 157 | "RSP_DATA_WRITE", |
---|
| 158 | }; |
---|
| 159 | |
---|
[789] | 160 | const char * cc_receive_fsm_state_str[] = { |
---|
[331] | 161 | "CC_RECEIVE_IDLE", |
---|
| 162 | "CC_RECEIVE_BRDCAST_HEADER", |
---|
| 163 | "CC_RECEIVE_BRDCAST_NLINE", |
---|
[468] | 164 | "CC_RECEIVE_INS_INVAL_HEADER", |
---|
| 165 | "CC_RECEIVE_INS_INVAL_NLINE", |
---|
| 166 | "CC_RECEIVE_INS_UPDT_HEADER", |
---|
| 167 | "CC_RECEIVE_INS_UPDT_NLINE", |
---|
| 168 | "CC_RECEIVE_INS_UPDT_DATA", |
---|
| 169 | "CC_RECEIVE_DATA_INVAL_HEADER", |
---|
| 170 | "CC_RECEIVE_DATA_INVAL_NLINE", |
---|
| 171 | "CC_RECEIVE_DATA_UPDT_HEADER", |
---|
| 172 | "CC_RECEIVE_DATA_UPDT_NLINE", |
---|
| 173 | "CC_RECEIVE_DATA_UPDT_DATA", |
---|
[331] | 174 | }; |
---|
| 175 | |
---|
[789] | 176 | const char * cc_send_fsm_state_str[] = { |
---|
[331] | 177 | "CC_SEND_IDLE", |
---|
| 178 | "CC_SEND_CLEANUP_1", |
---|
| 179 | "CC_SEND_CLEANUP_2", |
---|
| 180 | "CC_SEND_MULTI_ACK", |
---|
| 181 | }; |
---|
| 182 | } |
---|
| 183 | |
---|
[386] | 184 | #define tmpl(...) \ |
---|
| 185 | template<typename vci_param, \ |
---|
| 186 | size_t dspin_in_width, \ |
---|
| 187 | size_t dspin_out_width, \ |
---|
| 188 | typename iss_t> __VA_ARGS__ \ |
---|
| 189 | VciCcVCacheWrapper<vci_param, dspin_in_width, dspin_out_width, iss_t> |
---|
[331] | 190 | |
---|
[346] | 191 | using namespace soclib::common; |
---|
[331] | 192 | |
---|
| 193 | ///////////////////////////////// |
---|
| 194 | tmpl(/**/)::VciCcVCacheWrapper( |
---|
[789] | 195 | sc_module_name name, |
---|
| 196 | const int proc_id, |
---|
| 197 | const MappingTable &mtd, |
---|
| 198 | const IntTab &srcid, |
---|
| 199 | const size_t cc_global_id, |
---|
| 200 | const size_t itlb_ways, |
---|
| 201 | const size_t itlb_sets, |
---|
| 202 | const size_t dtlb_ways, |
---|
| 203 | const size_t dtlb_sets, |
---|
| 204 | const size_t icache_ways, |
---|
| 205 | const size_t icache_sets, |
---|
| 206 | const size_t icache_words, |
---|
| 207 | const size_t dcache_ways, |
---|
| 208 | const size_t dcache_sets, |
---|
| 209 | const size_t dcache_words, |
---|
| 210 | const size_t wbuf_nlines, |
---|
| 211 | const size_t wbuf_nwords, |
---|
| 212 | const size_t x_width, |
---|
| 213 | const size_t y_width, |
---|
| 214 | const uint32_t max_frozen_cycles, |
---|
| 215 | const uint32_t debug_start_cycle, |
---|
| 216 | const bool debug_ok) |
---|
[331] | 217 | : soclib::caba::BaseModule(name), |
---|
| 218 | |
---|
[346] | 219 | p_clk("p_clk"), |
---|
| 220 | p_resetn("p_resetn"), |
---|
| 221 | p_vci("p_vci"), |
---|
[468] | 222 | p_dspin_m2p("p_dspin_m2p"), |
---|
| 223 | p_dspin_p2m("p_dspin_p2m"), |
---|
| 224 | p_dspin_clack("p_dspin_clack"), |
---|
[331] | 225 | |
---|
[789] | 226 | m_cacheability_table( mtd.getCacheabilityTable()), |
---|
| 227 | m_srcid(mtd.indexForId(srcid)), |
---|
| 228 | m_cc_global_id(cc_global_id), |
---|
| 229 | m_nline_width(vci_param::N - (uint32_log2(dcache_words)) - 2), |
---|
| 230 | m_itlb_ways(itlb_ways), |
---|
| 231 | m_itlb_sets(itlb_sets), |
---|
| 232 | m_dtlb_ways(dtlb_ways), |
---|
| 233 | m_dtlb_sets(dtlb_sets), |
---|
| 234 | m_icache_ways(icache_ways), |
---|
| 235 | m_icache_sets(icache_sets), |
---|
| 236 | m_icache_yzmask((~0) << (uint32_log2(icache_words) + 2)), |
---|
| 237 | m_icache_words(icache_words), |
---|
| 238 | m_dcache_ways(dcache_ways), |
---|
| 239 | m_dcache_sets(dcache_sets), |
---|
| 240 | m_dcache_yzmask((~0) << (uint32_log2(dcache_words) + 2)), |
---|
| 241 | m_dcache_words(dcache_words), |
---|
| 242 | m_x_width(x_width), |
---|
| 243 | m_y_width(y_width), |
---|
| 244 | m_proc_id(proc_id), |
---|
| 245 | m_max_frozen_cycles(max_frozen_cycles), |
---|
| 246 | m_paddr_nbits(vci_param::N), |
---|
| 247 | m_debug_start_cycle(debug_start_cycle), |
---|
| 248 | m_debug_ok(debug_ok), |
---|
[721] | 249 | m_dcache_paddr_ext_reset(0), |
---|
| 250 | m_icache_paddr_ext_reset(0), |
---|
[331] | 251 | |
---|
| 252 | r_mmu_ptpr("r_mmu_ptpr"), |
---|
| 253 | r_mmu_mode("r_mmu_mode"), |
---|
| 254 | r_mmu_word_lo("r_mmu_word_lo"), |
---|
| 255 | r_mmu_word_hi("r_mmu_word_hi"), |
---|
| 256 | r_mmu_ibvar("r_mmu_ibvar"), |
---|
| 257 | r_mmu_dbvar("r_mmu_dbvar"), |
---|
| 258 | r_mmu_ietr("r_mmu_ietr"), |
---|
| 259 | r_mmu_detr("r_mmu_detr"), |
---|
| 260 | |
---|
| 261 | r_icache_fsm("r_icache_fsm"), |
---|
| 262 | r_icache_fsm_save("r_icache_fsm_save"), |
---|
| 263 | r_icache_vci_paddr("r_icache_vci_paddr"), |
---|
| 264 | r_icache_vaddr_save("r_icache_vaddr_save"), |
---|
| 265 | |
---|
| 266 | r_icache_miss_way("r_icache_miss_way"), |
---|
| 267 | r_icache_miss_set("r_icache_miss_set"), |
---|
| 268 | r_icache_miss_word("r_icache_miss_word"), |
---|
| 269 | r_icache_miss_inval("r_icache_miss_inval"), |
---|
| 270 | r_icache_miss_clack("r_icache_miss_clack"), |
---|
| 271 | |
---|
| 272 | r_icache_cc_way("r_icache_cc_way"), |
---|
| 273 | r_icache_cc_set("r_icache_cc_set"), |
---|
| 274 | r_icache_cc_word("r_icache_cc_word"), |
---|
| 275 | r_icache_cc_need_write("r_icache_cc_need_write"), |
---|
| 276 | |
---|
| 277 | r_icache_flush_count("r_icache_flush_count"), |
---|
| 278 | |
---|
| 279 | r_icache_miss_req("r_icache_miss_req"), |
---|
| 280 | r_icache_unc_req("r_icache_unc_req"), |
---|
| 281 | |
---|
| 282 | r_icache_tlb_miss_req("r_icache_tlb_read_req"), |
---|
| 283 | r_icache_tlb_rsp_error("r_icache_tlb_rsp_error"), |
---|
| 284 | |
---|
[487] | 285 | r_icache_cleanup_victim_req("r_icache_cleanup_victim_req"), |
---|
| 286 | r_icache_cleanup_victim_nline("r_icache_cleanup_victim_nline"), |
---|
| 287 | |
---|
[331] | 288 | r_icache_cc_send_req("r_icache_cc_send_req"), |
---|
| 289 | r_icache_cc_send_type("r_icache_cc_send_type"), |
---|
| 290 | r_icache_cc_send_nline("r_icache_cc_send_nline"), |
---|
| 291 | r_icache_cc_send_way("r_icache_cc_send_way"), |
---|
| 292 | r_icache_cc_send_updt_tab_idx("r_icache_cc_send_updt_tab_idx"), |
---|
| 293 | |
---|
| 294 | r_dcache_fsm("r_dcache_fsm"), |
---|
| 295 | r_dcache_fsm_cc_save("r_dcache_fsm_cc_save"), |
---|
| 296 | r_dcache_fsm_scan_save("r_dcache_fsm_scan_save"), |
---|
| 297 | |
---|
| 298 | r_dcache_wbuf_req("r_dcache_wbuf_req"), |
---|
| 299 | r_dcache_updt_req("r_dcache_updt_req"), |
---|
| 300 | r_dcache_save_vaddr("r_dcache_save_vaddr"), |
---|
| 301 | r_dcache_save_wdata("r_dcache_save_wdata"), |
---|
| 302 | r_dcache_save_be("r_dcache_save_be"), |
---|
| 303 | r_dcache_save_paddr("r_dcache_save_paddr"), |
---|
| 304 | r_dcache_save_cache_way("r_dcache_save_cache_way"), |
---|
| 305 | r_dcache_save_cache_set("r_dcache_save_cache_set"), |
---|
| 306 | r_dcache_save_cache_word("r_dcache_save_cache_word"), |
---|
| 307 | |
---|
| 308 | r_dcache_dirty_paddr("r_dcache_dirty_paddr"), |
---|
| 309 | r_dcache_dirty_way("r_dcache_dirty_way"), |
---|
| 310 | r_dcache_dirty_set("r_dcache_dirty_set"), |
---|
| 311 | |
---|
| 312 | r_dcache_vci_paddr("r_dcache_vci_paddr"), |
---|
[616] | 313 | r_dcache_vci_wdata("r_dcache_vci_wdata"), |
---|
[331] | 314 | r_dcache_vci_miss_req("r_dcache_vci_miss_req"), |
---|
| 315 | r_dcache_vci_unc_req("r_dcache_vci_unc_req"), |
---|
[627] | 316 | r_dcache_vci_unc_be("r_dcache_vci_unc_be"), |
---|
[616] | 317 | r_dcache_vci_unc_write("r_dcache_vci_unc_write"), |
---|
[331] | 318 | r_dcache_vci_cas_req("r_dcache_vci_cas_req"), |
---|
| 319 | r_dcache_vci_cas_old("r_dcache_vci_cas_old"), |
---|
| 320 | r_dcache_vci_cas_new("r_dcache_vci_cas_new"), |
---|
| 321 | r_dcache_vci_ll_req("r_dcache_vci_ll_req"), |
---|
| 322 | r_dcache_vci_sc_req("r_dcache_vci_sc_req"), |
---|
| 323 | r_dcache_vci_sc_data("r_dcache_vci_sc_data"), |
---|
| 324 | |
---|
| 325 | r_dcache_xtn_way("r_dcache_xtn_way"), |
---|
| 326 | r_dcache_xtn_set("r_dcache_xtn_set"), |
---|
| 327 | |
---|
| 328 | r_dcache_miss_type("r_dcache_miss_type"), |
---|
| 329 | r_dcache_miss_word("r_dcache_miss_word"), |
---|
| 330 | r_dcache_miss_way("r_dcache_miss_way"), |
---|
| 331 | r_dcache_miss_set("r_dcache_miss_set"), |
---|
| 332 | r_dcache_miss_inval("r_dcache_miss_inval"), |
---|
| 333 | |
---|
| 334 | r_dcache_cc_way("r_dcache_cc_way"), |
---|
| 335 | r_dcache_cc_set("r_dcache_cc_set"), |
---|
| 336 | r_dcache_cc_word("r_dcache_cc_word"), |
---|
| 337 | r_dcache_cc_need_write("r_dcache_cc_need_write"), |
---|
| 338 | |
---|
| 339 | r_dcache_flush_count("r_dcache_flush_count"), |
---|
| 340 | |
---|
| 341 | r_dcache_ll_rsp_count("r_dcache_ll_rsp_count"), |
---|
| 342 | |
---|
| 343 | r_dcache_tlb_vaddr("r_dcache_tlb_vaddr"), |
---|
| 344 | r_dcache_tlb_ins("r_dcache_tlb_ins"), |
---|
| 345 | r_dcache_tlb_pte_flags("r_dcache_tlb_pte_flags"), |
---|
| 346 | r_dcache_tlb_pte_ppn("r_dcache_tlb_pte_ppn"), |
---|
| 347 | r_dcache_tlb_cache_way("r_dcache_tlb_cache_way"), |
---|
| 348 | r_dcache_tlb_cache_set("r_dcache_tlb_cache_set"), |
---|
| 349 | r_dcache_tlb_cache_word("r_dcache_tlb_cache_word"), |
---|
| 350 | r_dcache_tlb_way("r_dcache_tlb_way"), |
---|
| 351 | r_dcache_tlb_set("r_dcache_tlb_set"), |
---|
| 352 | |
---|
| 353 | r_dcache_tlb_inval_line("r_dcache_tlb_inval_line"), |
---|
| 354 | r_dcache_tlb_inval_set("r_dcache_tlb_inval_set"), |
---|
| 355 | |
---|
| 356 | r_dcache_xtn_req("r_dcache_xtn_req"), |
---|
| 357 | r_dcache_xtn_opcode("r_dcache_xtn_opcode"), |
---|
| 358 | |
---|
[487] | 359 | r_dcache_cleanup_victim_req("r_dcache_cleanup_victim_req"), |
---|
| 360 | r_dcache_cleanup_victim_nline("r_dcache_cleanup_victim_nline"), |
---|
| 361 | |
---|
[331] | 362 | r_dcache_cc_send_req("r_dcache_cc_send_req"), |
---|
| 363 | r_dcache_cc_send_type("r_dcache_cc_send_type"), |
---|
| 364 | r_dcache_cc_send_nline("r_dcache_cc_send_nline"), |
---|
| 365 | r_dcache_cc_send_way("r_dcache_cc_send_way"), |
---|
| 366 | r_dcache_cc_send_updt_tab_idx("r_dcache_cc_send_updt_tab_idx"), |
---|
| 367 | |
---|
| 368 | r_vci_cmd_fsm("r_vci_cmd_fsm"), |
---|
| 369 | r_vci_cmd_min("r_vci_cmd_min"), |
---|
| 370 | r_vci_cmd_max("r_vci_cmd_max"), |
---|
| 371 | r_vci_cmd_cpt("r_vci_cmd_cpt"), |
---|
| 372 | r_vci_cmd_imiss_prio("r_vci_cmd_imiss_prio"), |
---|
| 373 | |
---|
| 374 | r_vci_rsp_fsm("r_vci_rsp_fsm"), |
---|
| 375 | r_vci_rsp_cpt("r_vci_rsp_cpt"), |
---|
| 376 | r_vci_rsp_ins_error("r_vci_rsp_ins_error"), |
---|
| 377 | r_vci_rsp_data_error("r_vci_rsp_data_error"), |
---|
[789] | 378 | r_vci_rsp_fifo_icache("r_vci_rsp_fifo_icache", 2), // 2 words depth |
---|
| 379 | r_vci_rsp_fifo_dcache("r_vci_rsp_fifo_dcache", 2), // 2 words depth |
---|
[331] | 380 | |
---|
| 381 | r_cc_send_fsm("r_cc_send_fsm"), |
---|
| 382 | r_cc_send_last_client("r_cc_send_last_client"), |
---|
| 383 | |
---|
| 384 | r_cc_receive_fsm("r_cc_receive_fsm"), |
---|
| 385 | r_cc_receive_data_ins("r_cc_receive_data_ins"), |
---|
| 386 | r_cc_receive_word_idx("r_cc_receive_word_idx"), |
---|
[789] | 387 | r_cc_receive_updt_fifo_be("r_cc_receive_updt_fifo_be", 2), // 2 words depth |
---|
| 388 | r_cc_receive_updt_fifo_data("r_cc_receive_updt_fifo_data", 2), // 2 words depth |
---|
| 389 | r_cc_receive_updt_fifo_eop("r_cc_receive_updt_fifo_eop", 2), // 2 words depth |
---|
[331] | 390 | |
---|
| 391 | r_cc_receive_icache_req("r_cc_receive_icache_req"), |
---|
| 392 | r_cc_receive_icache_type("r_cc_receive_icache_type"), |
---|
| 393 | r_cc_receive_icache_way("r_cc_receive_icache_way"), |
---|
| 394 | r_cc_receive_icache_set("r_cc_receive_icache_set"), |
---|
| 395 | r_cc_receive_icache_updt_tab_idx("r_cc_receive_icache_updt_tab_idx"), |
---|
| 396 | r_cc_receive_icache_nline("r_cc_receive_icache_nline"), |
---|
| 397 | |
---|
| 398 | r_cc_receive_dcache_req("r_cc_receive_dcache_req"), |
---|
| 399 | r_cc_receive_dcache_type("r_cc_receive_dcache_type"), |
---|
| 400 | r_cc_receive_dcache_way("r_cc_receive_dcache_way"), |
---|
| 401 | r_cc_receive_dcache_set("r_cc_receive_dcache_set"), |
---|
| 402 | r_cc_receive_dcache_updt_tab_idx("r_cc_receive_dcache_updt_tab_idx"), |
---|
| 403 | r_cc_receive_dcache_nline("r_cc_receive_dcache_nline"), |
---|
| 404 | |
---|
| 405 | r_iss(this->name(), proc_id), |
---|
| 406 | r_wbuf("wbuf", wbuf_nwords, wbuf_nlines, dcache_words ), |
---|
| 407 | r_icache("icache", icache_ways, icache_sets, icache_words), |
---|
| 408 | r_dcache("dcache", dcache_ways, dcache_sets, dcache_words), |
---|
| 409 | r_itlb("itlb", proc_id, itlb_ways,itlb_sets,vci_param::N), |
---|
| 410 | r_dtlb("dtlb", proc_id, dtlb_ways,dtlb_sets,vci_param::N) |
---|
| 411 | { |
---|
[421] | 412 | std::cout << " - Building VciCcVcacheWrapper : " << name << std::endl; |
---|
| 413 | |
---|
[789] | 414 | assert(((icache_words*vci_param::B) < (1 << vci_param::K)) and |
---|
[331] | 415 | "Need more PLEN bits."); |
---|
| 416 | |
---|
[789] | 417 | assert((vci_param::T > 2) and ((1 << (vci_param::T - 1)) >= (wbuf_nlines)) and |
---|
[331] | 418 | "Need more TRDID bits."); |
---|
| 419 | |
---|
[789] | 420 | assert((icache_words == dcache_words) and |
---|
[331] | 421 | "icache_words and dcache_words parameters must be equal"); |
---|
| 422 | |
---|
[789] | 423 | assert((itlb_sets == dtlb_sets) and |
---|
[331] | 424 | "itlb_sets and dtlb_sets parameters must be etqual"); |
---|
| 425 | |
---|
[789] | 426 | assert((itlb_ways == dtlb_ways) and |
---|
[331] | 427 | "itlb_ways and dtlb_ways parameters must be etqual"); |
---|
| 428 | |
---|
[789] | 429 | r_mmu_params = (uint32_log2(m_dtlb_ways) << 29) | (uint32_log2(m_dtlb_sets) << 25) | |
---|
| 430 | (uint32_log2(m_dcache_ways) << 22) | (uint32_log2(m_dcache_sets) << 18) | |
---|
| 431 | (uint32_log2(m_itlb_ways) << 15) | (uint32_log2(m_itlb_sets) << 11) | |
---|
| 432 | (uint32_log2(m_icache_ways) << 8) | (uint32_log2(m_icache_sets) << 4) | |
---|
| 433 | (uint32_log2(m_icache_words << 2)); |
---|
[331] | 434 | |
---|
[789] | 435 | r_mmu_release = (uint32_t) (1 << 16) | 0x1; |
---|
[331] | 436 | |
---|
[789] | 437 | r_dcache_in_tlb = new bool[dcache_ways * dcache_sets]; |
---|
| 438 | r_dcache_contains_ptd = new bool[dcache_ways * dcache_sets]; |
---|
[331] | 439 | |
---|
| 440 | SC_METHOD(transition); |
---|
| 441 | dont_initialize(); |
---|
| 442 | sensitive << p_clk.pos(); |
---|
| 443 | |
---|
| 444 | SC_METHOD(genMoore); |
---|
| 445 | dont_initialize(); |
---|
| 446 | sensitive << p_clk.neg(); |
---|
| 447 | |
---|
| 448 | typename iss_t::CacheInfo cache_info; |
---|
| 449 | cache_info.has_mmu = true; |
---|
[789] | 450 | cache_info.icache_line_size = icache_words * sizeof(uint32_t); |
---|
[331] | 451 | cache_info.icache_assoc = icache_ways; |
---|
| 452 | cache_info.icache_n_lines = icache_sets; |
---|
[789] | 453 | cache_info.dcache_line_size = dcache_words * sizeof(uint32_t); |
---|
[331] | 454 | cache_info.dcache_assoc = dcache_ways; |
---|
| 455 | cache_info.dcache_n_lines = dcache_sets; |
---|
| 456 | r_iss.setCacheInfo(cache_info); |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | ///////////////////////////////////// |
---|
| 460 | tmpl(/**/)::~VciCcVCacheWrapper() |
---|
| 461 | ///////////////////////////////////// |
---|
| 462 | { |
---|
| 463 | delete [] r_dcache_in_tlb; |
---|
| 464 | delete [] r_dcache_contains_ptd; |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | //////////////////////// |
---|
| 468 | tmpl(void)::print_cpi() |
---|
| 469 | //////////////////////// |
---|
| 470 | { |
---|
| 471 | std::cout << name() << " CPI = " |
---|
| 472 | << (float)m_cpt_total_cycles/(m_cpt_total_cycles - m_cpt_frz_cycles) << std::endl ; |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | //////////////////////////////////// |
---|
| 476 | tmpl(void)::print_trace(size_t mode) |
---|
| 477 | //////////////////////////////////// |
---|
| 478 | { |
---|
| 479 | // b0 : write buffer trace |
---|
[740] | 480 | // b1 : dump processor registers |
---|
[331] | 481 | // b2 : dcache trace |
---|
| 482 | // b3 : icache trace |
---|
| 483 | // b4 : dtlb trace |
---|
| 484 | // b5 : itlb trace |
---|
[740] | 485 | // b6 : SR (ISS register 32) |
---|
[331] | 486 | |
---|
| 487 | std::cout << std::dec << "PROC " << name() << std::endl; |
---|
| 488 | |
---|
| 489 | std::cout << " " << m_ireq << std::endl; |
---|
| 490 | std::cout << " " << m_irsp << std::endl; |
---|
| 491 | std::cout << " " << m_dreq << std::endl; |
---|
| 492 | std::cout << " " << m_drsp << std::endl; |
---|
| 493 | |
---|
| 494 | std::cout << " " << icache_fsm_state_str[r_icache_fsm.read()] |
---|
| 495 | << " | " << dcache_fsm_state_str[r_dcache_fsm.read()] |
---|
| 496 | << " | " << cmd_fsm_state_str[r_vci_cmd_fsm.read()] |
---|
| 497 | << " | " << rsp_fsm_state_str[r_vci_rsp_fsm.read()] |
---|
| 498 | << " | " << cc_receive_fsm_state_str[r_cc_receive_fsm.read()] |
---|
[394] | 499 | << " | " << cc_send_fsm_state_str[r_cc_send_fsm.read()] |
---|
| 500 | << " | MMU = " << r_mmu_mode.read(); |
---|
[711] | 501 | |
---|
[789] | 502 | if (r_dcache_updt_req.read()) std::cout << " | P1_UPDT"; |
---|
| 503 | if (r_dcache_wbuf_req.read()) std::cout << " | P1_WBUF"; |
---|
[331] | 504 | std::cout << std::endl; |
---|
| 505 | |
---|
[789] | 506 | if (mode & 0x01) |
---|
[331] | 507 | { |
---|
[789] | 508 | if (r_icache_miss_req.read()) std::cout << " IMISS_REQ" << std::endl; |
---|
| 509 | if (r_icache_unc_req.read()) std::cout << " IUNC_REQ" << std::endl; |
---|
| 510 | if (r_dcache_vci_miss_req.read()) std::cout << " DMISS_REQ" << std::endl; |
---|
| 511 | if (r_dcache_vci_unc_req.read()) std::cout << " DUNC_REQ" << std::endl; |
---|
[711] | 512 | |
---|
[789] | 513 | r_wbuf.printTrace((mode >> 1) & 1); |
---|
[331] | 514 | } |
---|
[789] | 515 | if (mode & 0x02) |
---|
[740] | 516 | { |
---|
| 517 | r_iss.dump(); |
---|
| 518 | } |
---|
[789] | 519 | if (mode & 0x04) |
---|
[331] | 520 | { |
---|
| 521 | std::cout << " Data Cache" << std::endl; |
---|
| 522 | r_dcache.printTrace(); |
---|
| 523 | } |
---|
[789] | 524 | if (mode & 0x08) |
---|
[331] | 525 | { |
---|
| 526 | std::cout << " Instruction Cache" << std::endl; |
---|
| 527 | r_icache.printTrace(); |
---|
| 528 | } |
---|
[789] | 529 | if (mode & 0x10) |
---|
[331] | 530 | { |
---|
| 531 | std::cout << " Data TLB" << std::endl; |
---|
| 532 | r_dtlb.printTrace(); |
---|
| 533 | } |
---|
[789] | 534 | if (mode & 0x20) |
---|
[331] | 535 | { |
---|
| 536 | std::cout << " Instruction TLB" << std::endl; |
---|
| 537 | r_itlb.printTrace(); |
---|
| 538 | } |
---|
[789] | 539 | if (mode & 0x40) |
---|
[740] | 540 | { |
---|
[789] | 541 | uint32_t status = r_iss.debugGetRegisterValue(32); |
---|
[740] | 542 | std::cout << name(); |
---|
[789] | 543 | if (status != m_previous_status ) std::cout << " NEW "; |
---|
[740] | 544 | std::cout << " status = " << std::hex << status << " " << std::endl; |
---|
| 545 | m_previous_status = status; |
---|
| 546 | } |
---|
[331] | 547 | } |
---|
| 548 | |
---|
| 549 | ////////////////////////////////////////// |
---|
[789] | 550 | tmpl(void)::cache_monitor(paddr_t addr) |
---|
[331] | 551 | ////////////////////////////////////////// |
---|
| 552 | { |
---|
[789] | 553 | bool cache_hit; |
---|
| 554 | size_t cache_way = 0; |
---|
| 555 | size_t cache_set = 0; |
---|
| 556 | size_t cache_word = 0; |
---|
| 557 | uint32_t cache_rdata = 0; |
---|
[394] | 558 | |
---|
[789] | 559 | cache_hit = r_dcache.read_neutral(addr, |
---|
| 560 | &cache_rdata, |
---|
| 561 | &cache_way, |
---|
| 562 | &cache_set, |
---|
| 563 | &cache_word); |
---|
[394] | 564 | |
---|
[789] | 565 | if (cache_hit != m_debug_previous_d_hit) |
---|
[331] | 566 | { |
---|
[394] | 567 | std::cout << "Monitor PROC " << name() |
---|
| 568 | << " DCACHE at cycle " << std::dec << m_cpt_total_cycles |
---|
| 569 | << " / HIT = " << cache_hit |
---|
| 570 | << " / PADDR = " << std::hex << addr |
---|
| 571 | << " / DATA = " << cache_rdata |
---|
| 572 | << " / WAY = " << cache_way << std::endl; |
---|
[789] | 573 | m_debug_previous_d_hit = cache_hit; |
---|
[331] | 574 | } |
---|
[394] | 575 | |
---|
[789] | 576 | cache_hit = r_icache.read_neutral(addr, |
---|
| 577 | &cache_rdata, |
---|
| 578 | &cache_way, |
---|
| 579 | &cache_set, |
---|
| 580 | &cache_word); |
---|
[394] | 581 | |
---|
[789] | 582 | if (cache_hit != m_debug_previous_i_hit) |
---|
[331] | 583 | { |
---|
[394] | 584 | std::cout << "Monitor PROC " << name() |
---|
| 585 | << " ICACHE at cycle " << std::dec << m_cpt_total_cycles |
---|
| 586 | << " / HIT = " << cache_hit |
---|
| 587 | << " / PADDR = " << std::hex << addr |
---|
| 588 | << " / DATA = " << cache_rdata |
---|
| 589 | << " / WAY = " << cache_way << std::endl; |
---|
[789] | 590 | m_debug_previous_i_hit = cache_hit; |
---|
[331] | 591 | } |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | /* |
---|
| 595 | //////////////////////// |
---|
| 596 | tmpl(void)::print_stats() |
---|
| 597 | //////////////////////// |
---|
| 598 | { |
---|
| 599 | float run_cycles = (float)(m_cpt_total_cycles - m_cpt_frz_cycles); |
---|
| 600 | std::cout << name() << std::endl |
---|
| 601 | << "- CPI = " << (float)m_cpt_total_cycles/run_cycles << std::endl |
---|
| 602 | << "- READ RATE = " << (float)m_cpt_read/run_cycles << std::endl |
---|
| 603 | << "- WRITE RATE = " << (float)m_cpt_write/run_cycles << std::endl |
---|
| 604 | << "- IMISS_RATE = " << (float)m_cpt_ins_miss/m_cpt_ins_read << std::endl |
---|
| 605 | << "- DMISS RATE = " << (float)m_cpt_data_miss/(m_cpt_read-m_cpt_unc_read) << std::endl |
---|
| 606 | << "- INS MISS COST = " << (float)m_cost_ins_miss_frz/m_cpt_ins_miss << std::endl |
---|
| 607 | << "- DATA MISS COST = " << (float)m_cost_data_miss_frz/m_cpt_data_miss << std::endl |
---|
| 608 | << "- WRITE COST = " << (float)m_cost_write_frz/m_cpt_write << std::endl |
---|
| 609 | << "- UNC COST = " << (float)m_cost_unc_read_frz/m_cpt_unc_read << std::endl |
---|
| 610 | << "- UNCACHED READ RATE = " << (float)m_cpt_unc_read/m_cpt_read << std::endl |
---|
| 611 | << "- CACHED WRITE RATE = " << (float)m_cpt_write_cached/m_cpt_write << std::endl |
---|
| 612 | << "- INS TLB MISS RATE = " << (float)m_cpt_ins_tlb_miss/m_cpt_ins_tlb_read << std::endl |
---|
| 613 | << "- DATA TLB MISS RATE = " << (float)m_cpt_data_tlb_miss/m_cpt_data_tlb_read << std::endl |
---|
| 614 | << "- ITLB MISS COST = " << (float)m_cost_ins_tlb_miss_frz/m_cpt_ins_tlb_miss << std::endl |
---|
| 615 | << "- DTLB MISS COST = " << (float)m_cost_data_tlb_miss_frz/m_cpt_data_tlb_miss << std::endl |
---|
| 616 | << "- ITLB UPDATE ACC COST = " << (float)m_cost_ins_tlb_update_acc_frz/m_cpt_ins_tlb_update_acc << std::endl |
---|
| 617 | << "- DTLB UPDATE ACC COST = " << (float)m_cost_data_tlb_update_acc_frz/m_cpt_data_tlb_update_acc << std::endl |
---|
| 618 | << "- DTLB UPDATE DIRTY COST = " << (float)m_cost_data_tlb_update_dirty_frz/m_cpt_data_tlb_update_dirty << std::endl |
---|
| 619 | << "- ITLB HIT IN DCACHE RATE= " << (float)m_cpt_ins_tlb_hit_dcache/m_cpt_ins_tlb_miss << std::endl |
---|
| 620 | << "- DTLB HIT IN DCACHE RATE= " << (float)m_cpt_data_tlb_hit_dcache/m_cpt_data_tlb_miss << std::endl |
---|
| 621 | << "- DCACHE FROZEN BY ITLB = " << (float)m_cost_ins_tlb_occup_cache_frz/m_cpt_dcache_frz_cycles << std::endl |
---|
| 622 | << "- DCACHE FOR TLB % = " << (float)m_cpt_tlb_occup_dcache/(m_dcache_ways*m_dcache_sets) << std::endl |
---|
| 623 | << "- NB CC BROADCAST = " << m_cpt_cc_broadcast << std::endl |
---|
| 624 | << "- NB CC UPDATE DATA = " << m_cpt_cc_update_data << std::endl |
---|
| 625 | << "- NB CC INVAL DATA = " << m_cpt_cc_inval_data << std::endl |
---|
| 626 | << "- NB CC INVAL INS = " << m_cpt_cc_inval_ins << std::endl |
---|
| 627 | << "- CC BROADCAST COST = " << (float)m_cost_broadcast_frz/m_cpt_cc_broadcast << std::endl |
---|
| 628 | << "- CC UPDATE DATA COST = " << (float)m_cost_updt_data_frz/m_cpt_cc_update_data << std::endl |
---|
| 629 | << "- CC INVAL DATA COST = " << (float)m_cost_inval_data_frz/m_cpt_cc_inval_data << std::endl |
---|
| 630 | << "- CC INVAL INS COST = " << (float)m_cost_inval_ins_frz/m_cpt_cc_inval_ins << std::endl |
---|
| 631 | << "- NB CC CLEANUP DATA = " << m_cpt_cc_cleanup_data << std::endl |
---|
| 632 | << "- NB CC CLEANUP INS = " << m_cpt_cc_cleanup_ins << std::endl |
---|
| 633 | << "- IMISS TRANSACTION = " << (float)m_cost_imiss_transaction/m_cpt_imiss_transaction << std::endl |
---|
| 634 | << "- DMISS TRANSACTION = " << (float)m_cost_dmiss_transaction/m_cpt_dmiss_transaction << std::endl |
---|
| 635 | << "- UNC TRANSACTION = " << (float)m_cost_unc_transaction/m_cpt_unc_transaction << std::endl |
---|
| 636 | << "- WRITE TRANSACTION = " << (float)m_cost_write_transaction/m_cpt_write_transaction << std::endl |
---|
| 637 | << "- WRITE LENGTH = " << (float)m_length_write_transaction/m_cpt_write_transaction << std::endl |
---|
| 638 | << "- ITLB MISS TRANSACTION = " << (float)m_cost_itlbmiss_transaction/m_cpt_itlbmiss_transaction << std::endl |
---|
| 639 | << "- DTLB MISS TRANSACTION = " << (float)m_cost_dtlbmiss_transaction/m_cpt_dtlbmiss_transaction << std::endl; |
---|
| 640 | } |
---|
| 641 | |
---|
| 642 | //////////////////////// |
---|
| 643 | tmpl(void)::clear_stats() |
---|
| 644 | //////////////////////// |
---|
| 645 | { |
---|
| 646 | m_cpt_dcache_data_read = 0; |
---|
| 647 | m_cpt_dcache_data_write = 0; |
---|
| 648 | m_cpt_dcache_dir_read = 0; |
---|
| 649 | m_cpt_dcache_dir_write = 0; |
---|
| 650 | m_cpt_icache_data_read = 0; |
---|
| 651 | m_cpt_icache_data_write = 0; |
---|
| 652 | m_cpt_icache_dir_read = 0; |
---|
| 653 | m_cpt_icache_dir_write = 0; |
---|
| 654 | |
---|
| 655 | m_cpt_frz_cycles = 0; |
---|
| 656 | m_cpt_dcache_frz_cycles = 0; |
---|
| 657 | m_cpt_total_cycles = 0; |
---|
| 658 | |
---|
| 659 | m_cpt_read = 0; |
---|
| 660 | m_cpt_write = 0; |
---|
| 661 | m_cpt_data_miss = 0; |
---|
| 662 | m_cpt_ins_miss = 0; |
---|
| 663 | m_cpt_unc_read = 0; |
---|
| 664 | m_cpt_write_cached = 0; |
---|
| 665 | m_cpt_ins_read = 0; |
---|
| 666 | |
---|
| 667 | m_cost_write_frz = 0; |
---|
| 668 | m_cost_data_miss_frz = 0; |
---|
| 669 | m_cost_unc_read_frz = 0; |
---|
| 670 | m_cost_ins_miss_frz = 0; |
---|
| 671 | |
---|
| 672 | m_cpt_imiss_transaction = 0; |
---|
| 673 | m_cpt_dmiss_transaction = 0; |
---|
| 674 | m_cpt_unc_transaction = 0; |
---|
| 675 | m_cpt_write_transaction = 0; |
---|
| 676 | m_cpt_icache_unc_transaction = 0; |
---|
| 677 | |
---|
| 678 | m_cost_imiss_transaction = 0; |
---|
| 679 | m_cost_dmiss_transaction = 0; |
---|
| 680 | m_cost_unc_transaction = 0; |
---|
| 681 | m_cost_write_transaction = 0; |
---|
| 682 | m_cost_icache_unc_transaction = 0; |
---|
| 683 | m_length_write_transaction = 0; |
---|
| 684 | |
---|
| 685 | m_cpt_ins_tlb_read = 0; |
---|
| 686 | m_cpt_ins_tlb_miss = 0; |
---|
| 687 | m_cpt_ins_tlb_update_acc = 0; |
---|
| 688 | |
---|
| 689 | m_cpt_data_tlb_read = 0; |
---|
| 690 | m_cpt_data_tlb_miss = 0; |
---|
| 691 | m_cpt_data_tlb_update_acc = 0; |
---|
| 692 | m_cpt_data_tlb_update_dirty = 0; |
---|
| 693 | m_cpt_ins_tlb_hit_dcache = 0; |
---|
| 694 | m_cpt_data_tlb_hit_dcache = 0; |
---|
| 695 | m_cpt_ins_tlb_occup_cache = 0; |
---|
| 696 | m_cpt_data_tlb_occup_cache = 0; |
---|
| 697 | |
---|
| 698 | m_cost_ins_tlb_miss_frz = 0; |
---|
| 699 | m_cost_data_tlb_miss_frz = 0; |
---|
| 700 | m_cost_ins_tlb_update_acc_frz = 0; |
---|
| 701 | m_cost_data_tlb_update_acc_frz = 0; |
---|
| 702 | m_cost_data_tlb_update_dirty_frz = 0; |
---|
| 703 | m_cost_ins_tlb_occup_cache_frz = 0; |
---|
| 704 | m_cost_data_tlb_occup_cache_frz = 0; |
---|
| 705 | |
---|
| 706 | m_cpt_itlbmiss_transaction = 0; |
---|
| 707 | m_cpt_itlb_ll_transaction = 0; |
---|
| 708 | m_cpt_itlb_sc_transaction = 0; |
---|
| 709 | m_cpt_dtlbmiss_transaction = 0; |
---|
| 710 | m_cpt_dtlb_ll_transaction = 0; |
---|
| 711 | m_cpt_dtlb_sc_transaction = 0; |
---|
| 712 | m_cpt_dtlb_ll_dirty_transaction = 0; |
---|
| 713 | m_cpt_dtlb_sc_dirty_transaction = 0; |
---|
| 714 | |
---|
| 715 | m_cost_itlbmiss_transaction = 0; |
---|
| 716 | m_cost_itlb_ll_transaction = 0; |
---|
| 717 | m_cost_itlb_sc_transaction = 0; |
---|
| 718 | m_cost_dtlbmiss_transaction = 0; |
---|
| 719 | m_cost_dtlb_ll_transaction = 0; |
---|
| 720 | m_cost_dtlb_sc_transaction = 0; |
---|
| 721 | m_cost_dtlb_ll_dirty_transaction = 0; |
---|
| 722 | m_cost_dtlb_sc_dirty_transaction = 0; |
---|
| 723 | |
---|
| 724 | m_cpt_cc_update_data = 0; |
---|
| 725 | m_cpt_cc_inval_ins = 0; |
---|
| 726 | m_cpt_cc_inval_data = 0; |
---|
| 727 | m_cpt_cc_broadcast = 0; |
---|
| 728 | |
---|
| 729 | m_cost_updt_data_frz = 0; |
---|
| 730 | m_cost_inval_ins_frz = 0; |
---|
| 731 | m_cost_inval_data_frz = 0; |
---|
| 732 | m_cost_broadcast_frz = 0; |
---|
| 733 | |
---|
| 734 | m_cpt_cc_cleanup_data = 0; |
---|
| 735 | m_cpt_cc_cleanup_ins = 0; |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | */ |
---|
| 739 | |
---|
| 740 | ///////////////////////// |
---|
| 741 | tmpl(void)::transition() |
---|
| 742 | ///////////////////////// |
---|
| 743 | { |
---|
[789] | 744 | if (not p_resetn.read()) |
---|
[331] | 745 | { |
---|
| 746 | r_iss.reset(); |
---|
| 747 | r_wbuf.reset(); |
---|
| 748 | r_icache.reset(); |
---|
| 749 | r_dcache.reset(); |
---|
| 750 | r_itlb.reset(); |
---|
| 751 | r_dtlb.reset(); |
---|
| 752 | |
---|
[789] | 753 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 754 | r_icache_fsm = ICACHE_IDLE; |
---|
| 755 | r_vci_cmd_fsm = CMD_IDLE; |
---|
| 756 | r_vci_rsp_fsm = RSP_IDLE; |
---|
| 757 | r_cc_receive_fsm = CC_RECEIVE_IDLE; |
---|
| 758 | r_cc_send_fsm = CC_SEND_IDLE; |
---|
[331] | 759 | |
---|
[394] | 760 | // reset data physical address extension |
---|
[721] | 761 | r_dcache_paddr_ext = m_dcache_paddr_ext_reset; |
---|
[394] | 762 | |
---|
[721] | 763 | // reset inst physical address extension |
---|
| 764 | r_icache_paddr_ext = m_icache_paddr_ext_reset; |
---|
| 765 | |
---|
[331] | 766 | // reset dcache directory extension |
---|
[789] | 767 | for (size_t i = 0; i< m_dcache_ways * m_dcache_sets; i++) |
---|
[331] | 768 | { |
---|
[789] | 769 | r_dcache_in_tlb[i] = false; |
---|
[331] | 770 | r_dcache_contains_ptd[i] = false; |
---|
| 771 | } |
---|
| 772 | |
---|
| 773 | // Response FIFOs and cleanup buffer |
---|
| 774 | r_vci_rsp_fifo_icache.init(); |
---|
| 775 | r_vci_rsp_fifo_dcache.init(); |
---|
| 776 | |
---|
| 777 | // ICACHE & DCACHE activated |
---|
[394] | 778 | // ITLB & DTLB desactivated |
---|
[331] | 779 | r_mmu_mode = 0x3; |
---|
| 780 | |
---|
[789] | 781 | // No request from ICACHE FSM to CMD FSM |
---|
[331] | 782 | r_icache_miss_req = false; |
---|
| 783 | r_icache_unc_req = false; |
---|
| 784 | |
---|
| 785 | // No request from ICACHE_FSM to DCACHE FSM |
---|
| 786 | r_icache_tlb_miss_req = false; |
---|
| 787 | |
---|
| 788 | // No request from ICACHE_FSM to CC_SEND FSM |
---|
| 789 | r_icache_cc_send_req = false; |
---|
[487] | 790 | r_icache_cleanup_victim_req = false; |
---|
[331] | 791 | |
---|
[468] | 792 | r_icache_clack_req = false; |
---|
| 793 | |
---|
[331] | 794 | // No pending write in pipeline |
---|
| 795 | r_dcache_wbuf_req = false; |
---|
| 796 | r_dcache_updt_req = false; |
---|
| 797 | |
---|
| 798 | // No request from DCACHE_FSM to CMD_FSM |
---|
| 799 | r_dcache_vci_miss_req = false; |
---|
| 800 | r_dcache_vci_unc_req = false; |
---|
| 801 | r_dcache_vci_cas_req = false; |
---|
| 802 | r_dcache_vci_ll_req = false; |
---|
| 803 | r_dcache_vci_sc_req = false; |
---|
| 804 | |
---|
| 805 | // No processor XTN request pending |
---|
| 806 | r_dcache_xtn_req = false; |
---|
| 807 | |
---|
| 808 | // No request from DCACHE FSM to CC_SEND FSM |
---|
[789] | 809 | r_dcache_cc_send_req = false; |
---|
[487] | 810 | r_dcache_cleanup_victim_req = false; |
---|
[331] | 811 | |
---|
[468] | 812 | r_dcache_clack_req = false; |
---|
| 813 | |
---|
[331] | 814 | // No request from CC_RECEIVE FSM to ICACHE/DCACHE FSMs |
---|
| 815 | r_cc_receive_icache_req = false; |
---|
| 816 | r_cc_receive_dcache_req = false; |
---|
| 817 | |
---|
| 818 | // last cc_send client was dcache |
---|
| 819 | r_cc_send_last_client = false; |
---|
| 820 | |
---|
| 821 | // No pending cleanup after a replacement |
---|
| 822 | r_icache_miss_clack = false; |
---|
| 823 | r_dcache_miss_clack = false; |
---|
| 824 | |
---|
| 825 | // No signalisation of a coherence request matching a pending miss |
---|
| 826 | r_icache_miss_inval = false; |
---|
| 827 | r_dcache_miss_inval = false; |
---|
| 828 | |
---|
[468] | 829 | r_dspin_clack_req = false; |
---|
| 830 | |
---|
[331] | 831 | // No signalisation of errors |
---|
| 832 | r_vci_rsp_ins_error = false; |
---|
| 833 | r_vci_rsp_data_error = false; |
---|
| 834 | |
---|
| 835 | // Debug variables |
---|
[394] | 836 | m_debug_previous_i_hit = false; |
---|
| 837 | m_debug_previous_d_hit = false; |
---|
[789] | 838 | m_debug_icache_fsm = false; |
---|
| 839 | m_debug_dcache_fsm = false; |
---|
| 840 | m_debug_cmd_fsm = false; |
---|
[331] | 841 | |
---|
| 842 | // activity counters |
---|
| 843 | m_cpt_dcache_data_read = 0; |
---|
| 844 | m_cpt_dcache_data_write = 0; |
---|
| 845 | m_cpt_dcache_dir_read = 0; |
---|
| 846 | m_cpt_dcache_dir_write = 0; |
---|
| 847 | m_cpt_icache_data_read = 0; |
---|
| 848 | m_cpt_icache_data_write = 0; |
---|
| 849 | m_cpt_icache_dir_read = 0; |
---|
| 850 | m_cpt_icache_dir_write = 0; |
---|
| 851 | |
---|
| 852 | m_cpt_frz_cycles = 0; |
---|
| 853 | m_cpt_total_cycles = 0; |
---|
| 854 | m_cpt_stop_simulation = 0; |
---|
| 855 | |
---|
| 856 | m_cpt_data_miss = 0; |
---|
| 857 | m_cpt_ins_miss = 0; |
---|
| 858 | m_cpt_unc_read = 0; |
---|
| 859 | m_cpt_write_cached = 0; |
---|
| 860 | m_cpt_ins_read = 0; |
---|
| 861 | |
---|
| 862 | m_cost_write_frz = 0; |
---|
| 863 | m_cost_data_miss_frz = 0; |
---|
| 864 | m_cost_unc_read_frz = 0; |
---|
| 865 | m_cost_ins_miss_frz = 0; |
---|
| 866 | |
---|
| 867 | m_cpt_imiss_transaction = 0; |
---|
| 868 | m_cpt_dmiss_transaction = 0; |
---|
| 869 | m_cpt_unc_transaction = 0; |
---|
| 870 | m_cpt_write_transaction = 0; |
---|
| 871 | m_cpt_icache_unc_transaction = 0; |
---|
| 872 | |
---|
| 873 | m_cost_imiss_transaction = 0; |
---|
| 874 | m_cost_dmiss_transaction = 0; |
---|
| 875 | m_cost_unc_transaction = 0; |
---|
| 876 | m_cost_write_transaction = 0; |
---|
| 877 | m_cost_icache_unc_transaction = 0; |
---|
| 878 | m_length_write_transaction = 0; |
---|
| 879 | |
---|
| 880 | m_cpt_ins_tlb_read = 0; |
---|
| 881 | m_cpt_ins_tlb_miss = 0; |
---|
| 882 | m_cpt_ins_tlb_update_acc = 0; |
---|
| 883 | |
---|
| 884 | m_cpt_data_tlb_read = 0; |
---|
| 885 | m_cpt_data_tlb_miss = 0; |
---|
| 886 | m_cpt_data_tlb_update_acc = 0; |
---|
| 887 | m_cpt_data_tlb_update_dirty = 0; |
---|
| 888 | m_cpt_ins_tlb_hit_dcache = 0; |
---|
| 889 | m_cpt_data_tlb_hit_dcache = 0; |
---|
| 890 | m_cpt_ins_tlb_occup_cache = 0; |
---|
| 891 | m_cpt_data_tlb_occup_cache = 0; |
---|
| 892 | |
---|
| 893 | m_cost_ins_tlb_miss_frz = 0; |
---|
| 894 | m_cost_data_tlb_miss_frz = 0; |
---|
| 895 | m_cost_ins_tlb_update_acc_frz = 0; |
---|
| 896 | m_cost_data_tlb_update_acc_frz = 0; |
---|
| 897 | m_cost_data_tlb_update_dirty_frz = 0; |
---|
| 898 | m_cost_ins_tlb_occup_cache_frz = 0; |
---|
| 899 | m_cost_data_tlb_occup_cache_frz = 0; |
---|
| 900 | |
---|
[789] | 901 | m_cpt_ins_tlb_inval = 0; |
---|
| 902 | m_cpt_data_tlb_inval = 0; |
---|
| 903 | m_cost_ins_tlb_inval_frz = 0; |
---|
| 904 | m_cost_data_tlb_inval_frz = 0; |
---|
[331] | 905 | |
---|
| 906 | m_cpt_cc_broadcast = 0; |
---|
| 907 | |
---|
[789] | 908 | m_cost_updt_data_frz = 0; |
---|
| 909 | m_cost_inval_ins_frz = 0; |
---|
| 910 | m_cost_inval_data_frz = 0; |
---|
| 911 | m_cost_broadcast_frz = 0; |
---|
[331] | 912 | |
---|
[789] | 913 | m_cpt_cc_cleanup_data = 0; |
---|
| 914 | m_cpt_cc_cleanup_ins = 0; |
---|
[331] | 915 | |
---|
| 916 | m_cpt_itlbmiss_transaction = 0; |
---|
| 917 | m_cpt_itlb_ll_transaction = 0; |
---|
| 918 | m_cpt_itlb_sc_transaction = 0; |
---|
| 919 | m_cpt_dtlbmiss_transaction = 0; |
---|
| 920 | m_cpt_dtlb_ll_transaction = 0; |
---|
| 921 | m_cpt_dtlb_sc_transaction = 0; |
---|
| 922 | m_cpt_dtlb_ll_dirty_transaction = 0; |
---|
| 923 | m_cpt_dtlb_sc_dirty_transaction = 0; |
---|
| 924 | |
---|
| 925 | m_cost_itlbmiss_transaction = 0; |
---|
| 926 | m_cost_itlb_ll_transaction = 0; |
---|
| 927 | m_cost_itlb_sc_transaction = 0; |
---|
| 928 | m_cost_dtlbmiss_transaction = 0; |
---|
| 929 | m_cost_dtlb_ll_transaction = 0; |
---|
| 930 | m_cost_dtlb_sc_transaction = 0; |
---|
| 931 | m_cost_dtlb_ll_dirty_transaction = 0; |
---|
| 932 | m_cost_dtlb_sc_dirty_transaction = 0; |
---|
| 933 | /* |
---|
| 934 | m_cpt_dcache_frz_cycles = 0; |
---|
[789] | 935 | m_cpt_read = 0; |
---|
| 936 | m_cpt_write = 0; |
---|
| 937 | m_cpt_cc_update_data = 0; |
---|
| 938 | m_cpt_cc_inval_ins = 0; |
---|
| 939 | m_cpt_cc_inval_data = 0; |
---|
[331] | 940 | */ |
---|
| 941 | |
---|
[789] | 942 | for (uint32_t i = 0; i < 32; ++i) m_cpt_fsm_icache[i] = 0; |
---|
| 943 | for (uint32_t i = 0; i < 32; ++i) m_cpt_fsm_dcache[i] = 0; |
---|
| 944 | for (uint32_t i = 0; i < 32; ++i) m_cpt_fsm_cmd[i] = 0; |
---|
| 945 | for (uint32_t i = 0; i < 32; ++i) m_cpt_fsm_rsp[i] = 0; |
---|
[331] | 946 | |
---|
| 947 | // init the llsc reservation buffer |
---|
| 948 | r_dcache_llsc_valid = false; |
---|
[423] | 949 | m_monitor_ok = false; |
---|
[331] | 950 | |
---|
| 951 | return; |
---|
| 952 | } |
---|
| 953 | |
---|
| 954 | // Response FIFOs default values |
---|
[789] | 955 | bool vci_rsp_fifo_icache_get = false; |
---|
| 956 | bool vci_rsp_fifo_icache_put = false; |
---|
| 957 | uint32_t vci_rsp_fifo_icache_data = 0; |
---|
[331] | 958 | |
---|
[789] | 959 | bool vci_rsp_fifo_dcache_get = false; |
---|
| 960 | bool vci_rsp_fifo_dcache_put = false; |
---|
| 961 | uint32_t vci_rsp_fifo_dcache_data = 0; |
---|
[331] | 962 | |
---|
| 963 | // updt fifo |
---|
[789] | 964 | bool cc_receive_updt_fifo_get = false; |
---|
| 965 | bool cc_receive_updt_fifo_put = false; |
---|
| 966 | uint32_t cc_receive_updt_fifo_be = 0; |
---|
| 967 | uint32_t cc_receive_updt_fifo_data = 0; |
---|
| 968 | bool cc_receive_updt_fifo_eop = false; |
---|
[331] | 969 | |
---|
| 970 | #ifdef INSTRUMENTATION |
---|
[789] | 971 | m_cpt_fsm_dcache [r_dcache_fsm.read() ] ++; |
---|
| 972 | m_cpt_fsm_icache [r_icache_fsm.read() ] ++; |
---|
| 973 | m_cpt_fsm_cmd [r_vci_cmd_fsm.read()] ++; |
---|
| 974 | m_cpt_fsm_rsp [r_vci_rsp_fsm.read()] ++; |
---|
| 975 | m_cpt_fsm_tgt [r_tgt_fsm.read() ] ++; |
---|
| 976 | m_cpt_fsm_cleanup[r_cleanup_cmd_fsm.read()] ++; |
---|
[331] | 977 | #endif |
---|
| 978 | |
---|
| 979 | m_cpt_total_cycles++; |
---|
| 980 | |
---|
[668] | 981 | m_debug_icache_fsm = m_debug_icache_fsm || |
---|
| 982 | ((m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok); |
---|
| 983 | m_debug_dcache_fsm = m_debug_dcache_fsm || |
---|
| 984 | ((m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok); |
---|
| 985 | m_debug_cmd_fsm = m_debug_cmd_fsm || |
---|
| 986 | ((m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok); |
---|
[331] | 987 | |
---|
| 988 | ///////////////////////////////////////////////////////////////////// |
---|
| 989 | // Get data and instruction requests from processor |
---|
| 990 | /////////////////////////////////////////////////////////////////////// |
---|
| 991 | |
---|
| 992 | r_iss.getRequests(m_ireq, m_dreq); |
---|
| 993 | |
---|
| 994 | //////////////////////////////////////////////////////////////////////////////////// |
---|
| 995 | // ICACHE_FSM |
---|
| 996 | // |
---|
| 997 | // 1/ Coherence operations |
---|
| 998 | // They are handled as interrupts generated by the CC_RECEIVE FSM. |
---|
| 999 | // - There is a coherence request when r_tgt_icache_req is set. |
---|
| 1000 | // They are taken in IDLE, MISS_WAIT, MISS_DIR_UPDT, UNC_WAIT, states. |
---|
| 1001 | // - There is a cleanup ack request when r_cleanup_icache_req is set. |
---|
| 1002 | // They are taken in IDLE, MISS_SELECT, MISS_CLEAN, MISS_WAIT, |
---|
| 1003 | // MISS_DATA_UPDT, MISS_DIR_UPDT and UNC_WAIT states. |
---|
| 1004 | // - For both types of requests, actions associated to the pre-empted state |
---|
| 1005 | // are not executed. The DCACHE FSM goes to the proper sub-FSM (CC_CHECK |
---|
| 1006 | // or CC_CLACK) to execute the requested coherence operation, and returns |
---|
| 1007 | // to the pre-empted state. |
---|
| 1008 | // |
---|
| 1009 | // 2/ Processor requests |
---|
| 1010 | // They are taken in IDLE state only. In case of cache miss, or uncacheable |
---|
| 1011 | // instruction, the ICACHE FSM request a VCI transaction to CMD FSM, |
---|
| 1012 | // using the r_icache_miss_req or r_icache_unc_req flip-flops. These |
---|
| 1013 | // flip-flops are reset when the transaction starts. |
---|
| 1014 | // - In case of miss the ICACHE FSM goes to the ICACHE_MISS_SELECT state |
---|
| 1015 | // to select a slot and possibly request a cleanup transaction to the CC_SEND FSM. |
---|
| 1016 | // It goes next to the ICACHE_MISS_WAIT state waiting a response from RSP FSM, |
---|
| 1017 | // The availability of the missing cache line is signaled by the response fifo, |
---|
| 1018 | // and the cache update is done (one word per cycle) in the ICACHE_MISS_DATA_UPDT |
---|
| 1019 | // and ICACHE_MISS_DIR_UPDT states. |
---|
| 1020 | // - In case of uncacheable instruction, the ICACHE FSM goes to ICACHE_UNC_WAIT |
---|
| 1021 | // to wait the response from the RSP FSM, through the response fifo. |
---|
| 1022 | // The missing instruction is directly returned to processor in this state. |
---|
| 1023 | // |
---|
| 1024 | // 3/ TLB miss |
---|
| 1025 | // In case of tlb miss, the ICACHE FSM request to the DCACHE FSM to update the |
---|
| 1026 | // ITLB using the r_icache_tlb_miss_req flip-flop and the r_icache_tlb_miss_vaddr |
---|
| 1027 | // register, and goes to the ICACHE_TLB_WAIT state. |
---|
| 1028 | // The tlb update is entirely done by the DCACHE FSM (who becomes the owner |
---|
| 1029 | // of ITLB until the update is completed, and reset r_icache_tlb_miss_req |
---|
| 1030 | // to signal the completion. |
---|
| 1031 | // |
---|
| 1032 | // 4/ XTN requests |
---|
| 1033 | // The DCACHE FSM signals XTN processor requests to ICACHE_FSM |
---|
| 1034 | // using the r_dcache_xtn_req flip-flop. |
---|
| 1035 | // The request opcode and the address to be invalidated are transmitted |
---|
| 1036 | // in the r_dcache_xtn_opcode and r_dcache_save_wdata registers respectively. |
---|
| 1037 | // The r_dcache_xtn_req flip-flop is reset by the ICACHE_FSM when the operation |
---|
| 1038 | // is completed. |
---|
| 1039 | // |
---|
| 1040 | // 5/ Error Handling |
---|
| 1041 | // The r_vci_rsp_ins_error flip-flop is set by the RSP FSM in case of bus error |
---|
| 1042 | // in a cache miss or uncacheable read VCI transaction. Nothing is written |
---|
| 1043 | // in the response fifo. This flip-flop is reset by the ICACHE-FSM. |
---|
| 1044 | //////////////////////////////////////////////////////////////////////////////////////// |
---|
| 1045 | |
---|
| 1046 | // default value for m_irsp |
---|
[789] | 1047 | m_irsp.valid = false; |
---|
| 1048 | m_irsp.error = false; |
---|
[331] | 1049 | m_irsp.instruction = 0; |
---|
| 1050 | |
---|
[789] | 1051 | switch (r_icache_fsm.read()) |
---|
[331] | 1052 | { |
---|
| 1053 | ///////////////// |
---|
[789] | 1054 | case ICACHE_IDLE: // In this state, we handle processor requests, XTN requests, |
---|
[331] | 1055 | // and coherence requests with a fixed priority: |
---|
| 1056 | // 1/ Coherence requests => ICACHE_CC_CHECK |
---|
| 1057 | // 2/ XTN processor requests (from DCACHE FSM) => ICACHE_XTN_* |
---|
| 1058 | // 3/ tlb miss => ICACHE_TLB_WAIT |
---|
| 1059 | // 4/ cacheable read miss => ICACHE_MISS_SELECT |
---|
| 1060 | // 5/ uncacheable read miss => ICACHE_UNC_REQ |
---|
| 1061 | { |
---|
[468] | 1062 | // coherence clack interrupt |
---|
[789] | 1063 | if (r_icache_clack_req.read()) |
---|
[468] | 1064 | { |
---|
| 1065 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1066 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1067 | break; |
---|
| 1068 | } |
---|
| 1069 | |
---|
[331] | 1070 | // coherence interrupt |
---|
[789] | 1071 | if (r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) |
---|
[331] | 1072 | { |
---|
| 1073 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1074 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1075 | break; |
---|
| 1076 | } |
---|
| 1077 | |
---|
| 1078 | // XTN requests sent by DCACHE FSM |
---|
[721] | 1079 | // These request are not executed in this IDLE state (except XTN_INST_PADDR_EXT), |
---|
| 1080 | // because they require access to icache or itlb, that are already accessed |
---|
[789] | 1081 | if (r_dcache_xtn_req.read()) |
---|
[331] | 1082 | { |
---|
[789] | 1083 | if ((int) r_dcache_xtn_opcode.read() == (int) iss_t::XTN_PTPR ) |
---|
[331] | 1084 | { |
---|
[789] | 1085 | r_icache_fsm = ICACHE_XTN_TLB_FLUSH; |
---|
[331] | 1086 | } |
---|
[789] | 1087 | else if ((int) r_dcache_xtn_opcode.read() == (int) iss_t::XTN_ICACHE_FLUSH) |
---|
[331] | 1088 | { |
---|
| 1089 | r_icache_flush_count = 0; |
---|
[789] | 1090 | r_icache_fsm = ICACHE_XTN_CACHE_FLUSH; |
---|
[331] | 1091 | } |
---|
[789] | 1092 | else if ((int) r_dcache_xtn_opcode.read() == (int) iss_t::XTN_ITLB_INVAL) |
---|
[331] | 1093 | { |
---|
[789] | 1094 | r_icache_fsm = ICACHE_XTN_TLB_INVAL; |
---|
[331] | 1095 | } |
---|
[789] | 1096 | else if ((int) r_dcache_xtn_opcode.read() == (int) iss_t::XTN_ICACHE_INVAL) |
---|
[331] | 1097 | { |
---|
[789] | 1098 | r_icache_fsm = ICACHE_XTN_CACHE_INVAL_VA; |
---|
[331] | 1099 | } |
---|
[789] | 1100 | else if ((int) r_dcache_xtn_opcode.read() == (int) iss_t::XTN_MMU_ICACHE_PA_INV) |
---|
[331] | 1101 | { |
---|
[721] | 1102 | if (sizeof(paddr_t) <= 32) |
---|
[331] | 1103 | { |
---|
[721] | 1104 | assert(r_mmu_word_hi.read() == 0 && |
---|
| 1105 | "illegal XTN request in ICACHE: high bits should be 0 for 32bit paddr"); |
---|
[789] | 1106 | r_icache_vci_paddr = (paddr_t) r_mmu_word_lo.read(); |
---|
[331] | 1107 | } |
---|
| 1108 | else |
---|
| 1109 | { |
---|
[789] | 1110 | r_icache_vci_paddr = (paddr_t) r_mmu_word_hi.read() << 32 | |
---|
| 1111 | (paddr_t) r_mmu_word_lo.read(); |
---|
[721] | 1112 | } |
---|
| 1113 | r_icache_fsm = ICACHE_XTN_CACHE_INVAL_PA; |
---|
[331] | 1114 | } |
---|
[789] | 1115 | else if ((int) r_dcache_xtn_opcode.read() == (int) iss_t::XTN_INST_PADDR_EXT) |
---|
[721] | 1116 | { |
---|
| 1117 | r_icache_paddr_ext = r_dcache_save_wdata.read(); |
---|
| 1118 | r_dcache_xtn_req = false; |
---|
| 1119 | } |
---|
[331] | 1120 | else |
---|
| 1121 | { |
---|
[789] | 1122 | assert(false and |
---|
[331] | 1123 | "undefined XTN request received by ICACHE FSM"); |
---|
| 1124 | } |
---|
| 1125 | break; |
---|
| 1126 | } // end if xtn_req |
---|
| 1127 | |
---|
| 1128 | // processor request |
---|
[789] | 1129 | if (m_ireq.valid ) |
---|
[331] | 1130 | { |
---|
[789] | 1131 | bool cacheable; |
---|
| 1132 | paddr_t paddr; |
---|
| 1133 | bool tlb_hit = false; |
---|
| 1134 | pte_info_t tlb_flags; |
---|
| 1135 | size_t tlb_way; |
---|
| 1136 | size_t tlb_set; |
---|
| 1137 | paddr_t tlb_nline; |
---|
| 1138 | uint32_t cache_inst = 0; |
---|
| 1139 | size_t cache_way; |
---|
| 1140 | size_t cache_set; |
---|
| 1141 | size_t cache_word; |
---|
| 1142 | int cache_state = CACHE_SLOT_STATE_EMPTY; |
---|
[331] | 1143 | |
---|
| 1144 | // We register processor request |
---|
| 1145 | r_icache_vaddr_save = m_ireq.addr; |
---|
[752] | 1146 | paddr = (paddr_t) m_ireq.addr; |
---|
[331] | 1147 | |
---|
| 1148 | // sytematic itlb access (if activated) |
---|
[789] | 1149 | if (r_mmu_mode.read() & INS_TLB_MASK) |
---|
[331] | 1150 | { |
---|
| 1151 | |
---|
| 1152 | #ifdef INSTRUMENTATION |
---|
[789] | 1153 | m_cpt_itlb_read++; |
---|
[331] | 1154 | #endif |
---|
[789] | 1155 | tlb_hit = r_itlb.translate(m_ireq.addr, |
---|
| 1156 | &paddr, |
---|
| 1157 | &tlb_flags, |
---|
| 1158 | &tlb_nline, // unused |
---|
| 1159 | &tlb_way, // unused |
---|
| 1160 | &tlb_set); // unused |
---|
[331] | 1161 | } |
---|
[752] | 1162 | else if (vci_param::N > 32) |
---|
[331] | 1163 | { |
---|
[752] | 1164 | paddr = paddr | ((paddr_t) r_icache_paddr_ext.read() << 32); |
---|
[331] | 1165 | } |
---|
| 1166 | |
---|
| 1167 | // systematic icache access (if activated) |
---|
[789] | 1168 | if (r_mmu_mode.read() & INS_CACHE_MASK) |
---|
[331] | 1169 | { |
---|
| 1170 | |
---|
| 1171 | |
---|
| 1172 | #ifdef INSTRUMENTATION |
---|
[789] | 1173 | m_cpt_icache_data_read++; |
---|
| 1174 | m_cpt_icache_dir_read++; |
---|
[331] | 1175 | #endif |
---|
[789] | 1176 | r_icache.read(paddr, |
---|
| 1177 | &cache_inst, |
---|
| 1178 | &cache_way, |
---|
| 1179 | &cache_set, |
---|
| 1180 | &cache_word, |
---|
| 1181 | &cache_state); |
---|
[331] | 1182 | } |
---|
| 1183 | |
---|
| 1184 | // We compute cacheability and check access rights: |
---|
| 1185 | // - If MMU activated : cacheability is defined by the C bit in the PTE, |
---|
| 1186 | // and the access rights are defined by the U and X bits in the PTE. |
---|
| 1187 | // - If MMU not activated : cacheability is defined by the segment table, |
---|
| 1188 | // and there is no access rights checking |
---|
| 1189 | |
---|
[789] | 1190 | if (not (r_mmu_mode.read() & INS_TLB_MASK)) // tlb not activated: |
---|
[331] | 1191 | { |
---|
| 1192 | // cacheability |
---|
[789] | 1193 | if (not (r_mmu_mode.read() & INS_CACHE_MASK)) cacheable = false; |
---|
| 1194 | else cacheable = m_cacheability_table[(uint64_t) m_ireq.addr]; |
---|
[331] | 1195 | } |
---|
[789] | 1196 | else // itlb activated |
---|
[331] | 1197 | { |
---|
[789] | 1198 | if (tlb_hit) // ITLB hit |
---|
[331] | 1199 | { |
---|
| 1200 | // cacheability |
---|
[789] | 1201 | if (not (r_mmu_mode.read() & INS_CACHE_MASK)) cacheable = false; |
---|
[331] | 1202 | else cacheable = tlb_flags.c; |
---|
| 1203 | |
---|
| 1204 | // access rights checking |
---|
[789] | 1205 | if (not tlb_flags.u && (m_ireq.mode == iss_t::MODE_USER)) |
---|
[331] | 1206 | { |
---|
[809] | 1207 | |
---|
| 1208 | #if DEBUG_ICACHE |
---|
| 1209 | if ( m_debug_icache_fsm ) |
---|
| 1210 | std::cout << " <PROC " << name() << " ICACHE_IDLE> MMU Privilege Violation" |
---|
| 1211 | << " : PADDR = " << std::hex << paddr << std::endl; |
---|
| 1212 | #endif |
---|
| 1213 | r_mmu_ietr = MMU_READ_PRIVILEGE_VIOLATION; |
---|
| 1214 | r_mmu_ibvar = m_ireq.addr; |
---|
| 1215 | m_irsp.valid = true; |
---|
| 1216 | m_irsp.error = true; |
---|
| 1217 | m_irsp.instruction = 0; |
---|
[331] | 1218 | break; |
---|
| 1219 | } |
---|
[789] | 1220 | else if (not tlb_flags.x) |
---|
[331] | 1221 | { |
---|
[809] | 1222 | |
---|
| 1223 | #if DEBUG_ICACHE |
---|
| 1224 | if ( m_debug_icache_fsm ) |
---|
| 1225 | std::cout << " <PROC " << name() << " ICACHE_IDLE> MMU Executable Violation" |
---|
| 1226 | << " : PADDR = " << std::hex << paddr << std::endl; |
---|
| 1227 | #endif |
---|
| 1228 | r_mmu_ietr = MMU_READ_EXEC_VIOLATION; |
---|
| 1229 | r_mmu_ibvar = m_ireq.addr; |
---|
| 1230 | m_irsp.valid = true; |
---|
| 1231 | m_irsp.error = true; |
---|
| 1232 | m_irsp.instruction = 0; |
---|
[331] | 1233 | break; |
---|
| 1234 | } |
---|
| 1235 | } |
---|
[789] | 1236 | else // ITLB miss |
---|
[331] | 1237 | { |
---|
| 1238 | |
---|
| 1239 | #ifdef INSTRUMENTATION |
---|
[789] | 1240 | m_cpt_itlb_miss++; |
---|
[331] | 1241 | #endif |
---|
| 1242 | r_icache_fsm = ICACHE_TLB_WAIT; |
---|
| 1243 | r_icache_tlb_miss_req = true; |
---|
| 1244 | break; |
---|
| 1245 | } |
---|
| 1246 | } // end if itlb activated |
---|
| 1247 | |
---|
| 1248 | // physical address registration |
---|
[789] | 1249 | r_icache_vci_paddr = paddr; |
---|
[331] | 1250 | |
---|
| 1251 | // Finally, we send the response to processor, and compute next state |
---|
[789] | 1252 | if (cacheable) |
---|
[331] | 1253 | { |
---|
[789] | 1254 | if (cache_state == CACHE_SLOT_STATE_EMPTY) // cache miss |
---|
[331] | 1255 | { |
---|
| 1256 | |
---|
| 1257 | #ifdef INSTRUMENTATION |
---|
[789] | 1258 | m_cpt_icache_miss++; |
---|
[331] | 1259 | #endif |
---|
| 1260 | // we request a VCI transaction |
---|
[789] | 1261 | r_icache_fsm = ICACHE_MISS_SELECT; |
---|
[386] | 1262 | #if DEBUG_ICACHE |
---|
[789] | 1263 | if (m_debug_icache_fsm) |
---|
| 1264 | std::cout << " <PROC " << name() << " ICACHE_IDLE> READ MISS in icache" |
---|
| 1265 | << " : PADDR = " << std::hex << paddr << std::endl; |
---|
[386] | 1266 | #endif |
---|
| 1267 | r_icache_miss_req = true; |
---|
[331] | 1268 | } |
---|
[789] | 1269 | else if (cache_state == CACHE_SLOT_STATE_ZOMBI ) // pending cleanup |
---|
[331] | 1270 | { |
---|
| 1271 | // stalled until cleanup is acknowledged |
---|
[789] | 1272 | r_icache_fsm = ICACHE_IDLE; |
---|
[331] | 1273 | } |
---|
[789] | 1274 | else // cache hit |
---|
[331] | 1275 | { |
---|
| 1276 | |
---|
| 1277 | #ifdef INSTRUMENTATION |
---|
[789] | 1278 | m_cpt_ins_read++; |
---|
[331] | 1279 | #endif |
---|
| 1280 | // return instruction to processor |
---|
| 1281 | m_irsp.valid = true; |
---|
| 1282 | m_irsp.instruction = cache_inst; |
---|
| 1283 | r_icache_fsm = ICACHE_IDLE; |
---|
[386] | 1284 | #if DEBUG_ICACHE |
---|
[789] | 1285 | if (m_debug_icache_fsm) |
---|
| 1286 | std::cout << " <PROC " << name() << " ICACHE_IDLE> READ HIT in icache" |
---|
| 1287 | << " : PADDR = " << std::hex << paddr |
---|
| 1288 | << " / INST = " << cache_inst << std::endl; |
---|
[386] | 1289 | #endif |
---|
[331] | 1290 | } |
---|
| 1291 | } |
---|
[789] | 1292 | else // non cacheable read |
---|
[331] | 1293 | { |
---|
[789] | 1294 | r_icache_unc_req = true; |
---|
| 1295 | r_icache_fsm = ICACHE_UNC_WAIT; |
---|
[386] | 1296 | |
---|
| 1297 | #if DEBUG_ICACHE |
---|
[789] | 1298 | if (m_debug_icache_fsm) |
---|
| 1299 | { |
---|
| 1300 | std::cout << " <PROC " << name() |
---|
| 1301 | << " ICACHE_IDLE> READ UNCACHEABLE in icache" |
---|
| 1302 | << " : PADDR = " << std::hex << paddr << std::endl; |
---|
| 1303 | } |
---|
[386] | 1304 | #endif |
---|
[331] | 1305 | } |
---|
| 1306 | } // end if m_ireq.valid |
---|
| 1307 | break; |
---|
| 1308 | } |
---|
| 1309 | ///////////////////// |
---|
[789] | 1310 | case ICACHE_TLB_WAIT: // Waiting the itlb update by the DCACHE FSM after a tlb miss |
---|
[331] | 1311 | // the itlb is udated by the DCACHE FSM, as well as the |
---|
| 1312 | // r_mmu_ietr and r_mmu_ibvar registers in case of error. |
---|
| 1313 | // the itlb is not accessed by ICACHE FSM until DCACHE FSM |
---|
| 1314 | // reset the r_icache_tlb_miss_req flip-flop |
---|
| 1315 | // external coherence request are accepted in this state. |
---|
| 1316 | { |
---|
[468] | 1317 | // coherence clack interrupt |
---|
[789] | 1318 | if (r_icache_clack_req.read()) |
---|
[468] | 1319 | { |
---|
| 1320 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1321 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1322 | break; |
---|
| 1323 | } |
---|
| 1324 | |
---|
[331] | 1325 | // coherence interrupt |
---|
[789] | 1326 | if (r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) |
---|
[331] | 1327 | { |
---|
| 1328 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1329 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1330 | break; |
---|
| 1331 | } |
---|
| 1332 | |
---|
[789] | 1333 | if (m_ireq.valid) m_cost_ins_tlb_miss_frz++; |
---|
[331] | 1334 | |
---|
| 1335 | // DCACHE FSM signals response by reseting the request flip-flop |
---|
[789] | 1336 | if (not r_icache_tlb_miss_req.read()) |
---|
[331] | 1337 | { |
---|
[789] | 1338 | if (r_icache_tlb_rsp_error.read()) // error reported : tlb not updated |
---|
[331] | 1339 | { |
---|
| 1340 | r_icache_tlb_rsp_error = false; |
---|
[789] | 1341 | m_irsp.error = true; |
---|
| 1342 | m_irsp.valid = true; |
---|
| 1343 | r_icache_fsm = ICACHE_IDLE; |
---|
[331] | 1344 | } |
---|
[789] | 1345 | else // tlb updated : return to IDLE state |
---|
[331] | 1346 | { |
---|
| 1347 | r_icache_fsm = ICACHE_IDLE; |
---|
| 1348 | } |
---|
| 1349 | } |
---|
| 1350 | break; |
---|
| 1351 | } |
---|
| 1352 | ////////////////////////// |
---|
[789] | 1353 | case ICACHE_XTN_TLB_FLUSH: // invalidate in one cycle all non global TLB entries |
---|
[331] | 1354 | { |
---|
| 1355 | r_itlb.flush(); |
---|
[789] | 1356 | r_dcache_xtn_req = false; |
---|
| 1357 | r_icache_fsm = ICACHE_IDLE; |
---|
[331] | 1358 | break; |
---|
| 1359 | } |
---|
| 1360 | //////////////////////////// |
---|
[789] | 1361 | case ICACHE_XTN_CACHE_FLUSH: // Invalidate sequencially all cache lines, using |
---|
[331] | 1362 | // r_icache_flush_count as a slot counter, |
---|
[789] | 1363 | // looping in this state until all slots are visited. |
---|
[331] | 1364 | // It can require two cycles per slot: |
---|
| 1365 | // We test here the slot state, and make the actual inval |
---|
| 1366 | // (if line is valid) in ICACHE_XTN_CACHE_FLUSH_GO state. |
---|
[789] | 1367 | // A cleanup request is generated for each valid line |
---|
[331] | 1368 | { |
---|
[468] | 1369 | // coherence clack interrupt |
---|
[789] | 1370 | if (r_icache_clack_req.read()) |
---|
[468] | 1371 | { |
---|
| 1372 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1373 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1374 | break; |
---|
| 1375 | } |
---|
| 1376 | |
---|
[384] | 1377 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 1378 | if (r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) |
---|
[384] | 1379 | { |
---|
| 1380 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1381 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1382 | break; |
---|
| 1383 | } |
---|
| 1384 | |
---|
[789] | 1385 | if (not r_icache_cc_send_req.read()) // blocked until previous cc_send request is sent |
---|
[331] | 1386 | { |
---|
[789] | 1387 | int state; |
---|
| 1388 | paddr_t tag; |
---|
| 1389 | size_t way = r_icache_flush_count.read()/m_icache_sets; |
---|
| 1390 | size_t set = r_icache_flush_count.read()%m_icache_sets; |
---|
[331] | 1391 | |
---|
| 1392 | #ifdef INSTRUMENTATION |
---|
[789] | 1393 | m_cpt_icache_dir_read++; |
---|
[331] | 1394 | #endif |
---|
[789] | 1395 | r_icache.read_dir(way, |
---|
| 1396 | set, |
---|
| 1397 | &tag, |
---|
| 1398 | &state); |
---|
[331] | 1399 | |
---|
[789] | 1400 | if (state == CACHE_SLOT_STATE_VALID) // inval required |
---|
[331] | 1401 | { |
---|
| 1402 | // request cleanup |
---|
| 1403 | r_icache_cc_send_req = true; |
---|
[384] | 1404 | r_icache_cc_send_nline = tag * m_icache_sets + set; |
---|
[331] | 1405 | r_icache_cc_send_way = way; |
---|
| 1406 | r_icache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 1407 | |
---|
| 1408 | // goes to ICACHE_XTN_CACHE_FLUSH_GO to make inval |
---|
[789] | 1409 | r_icache_miss_way = way; |
---|
| 1410 | r_icache_miss_set = set; |
---|
| 1411 | r_icache_fsm = ICACHE_XTN_CACHE_FLUSH_GO; |
---|
[331] | 1412 | } |
---|
[789] | 1413 | else if (r_icache_flush_count.read() == |
---|
| 1414 | (m_icache_sets*m_icache_ways - 1)) // last slot |
---|
[331] | 1415 | { |
---|
[789] | 1416 | r_dcache_xtn_req = false; |
---|
| 1417 | m_drsp.valid = true; |
---|
| 1418 | r_icache_fsm = ICACHE_IDLE; |
---|
[331] | 1419 | } |
---|
| 1420 | |
---|
| 1421 | // saturation counter, to have the same last slot condition |
---|
| 1422 | // in ICACHE_XTN_CACHE_FLUSH and ICACHE_XTN_CACHE_FLUSH_GO states |
---|
[789] | 1423 | if (r_icache_flush_count.read() < (m_icache_sets * m_icache_ways - 1)) |
---|
[331] | 1424 | { |
---|
| 1425 | r_icache_flush_count = r_icache_flush_count.read() + 1; |
---|
| 1426 | } |
---|
| 1427 | } |
---|
| 1428 | break; |
---|
| 1429 | } |
---|
| 1430 | /////////////////////////////// |
---|
[789] | 1431 | case ICACHE_XTN_CACHE_FLUSH_GO: // Switch slot state to ZOMBI for an XTN flush |
---|
[331] | 1432 | { |
---|
[789] | 1433 | size_t way = r_icache_miss_way.read(); |
---|
| 1434 | size_t set = r_icache_miss_set.read(); |
---|
[331] | 1435 | |
---|
| 1436 | #ifdef INSTRUMENTATION |
---|
[789] | 1437 | m_cpt_icache_dir_write++; |
---|
[331] | 1438 | #endif |
---|
| 1439 | |
---|
[789] | 1440 | r_icache.write_dir(way, |
---|
| 1441 | set, |
---|
| 1442 | CACHE_SLOT_STATE_ZOMBI); |
---|
[331] | 1443 | |
---|
[789] | 1444 | if (r_icache_flush_count.read() == |
---|
| 1445 | (m_icache_sets*m_icache_ways - 1)) // last slot |
---|
[331] | 1446 | { |
---|
[789] | 1447 | r_dcache_xtn_req = false; |
---|
| 1448 | m_drsp.valid = true; |
---|
| 1449 | r_icache_fsm = ICACHE_IDLE; |
---|
[331] | 1450 | } |
---|
| 1451 | else |
---|
| 1452 | { |
---|
[789] | 1453 | r_icache_fsm = ICACHE_XTN_CACHE_FLUSH; |
---|
[331] | 1454 | } |
---|
| 1455 | break; |
---|
| 1456 | } |
---|
| 1457 | |
---|
| 1458 | ////////////////////////// |
---|
[789] | 1459 | case ICACHE_XTN_TLB_INVAL: // invalidate one TLB entry selected by the virtual address |
---|
| 1460 | // stored in the r_dcache_save_wdata register |
---|
[331] | 1461 | { |
---|
| 1462 | r_itlb.inval(r_dcache_save_wdata.read()); |
---|
[789] | 1463 | r_dcache_xtn_req = false; |
---|
| 1464 | r_icache_fsm = ICACHE_IDLE; |
---|
[331] | 1465 | break; |
---|
| 1466 | } |
---|
| 1467 | /////////////////////////////// |
---|
[789] | 1468 | case ICACHE_XTN_CACHE_INVAL_VA: // Selective cache line invalidate with virtual address |
---|
[331] | 1469 | // requires 3 cycles (in case of hit on itlb and icache). |
---|
[789] | 1470 | // In this state, access TLB to translate virtual address |
---|
| 1471 | // stored in the r_dcache_save_wdata register. |
---|
[331] | 1472 | { |
---|
[789] | 1473 | paddr_t paddr; |
---|
| 1474 | bool hit; |
---|
[331] | 1475 | |
---|
| 1476 | // read physical address in TLB when MMU activated |
---|
[789] | 1477 | if (r_mmu_mode.read() & INS_TLB_MASK) // itlb activated |
---|
[331] | 1478 | { |
---|
| 1479 | |
---|
| 1480 | #ifdef INSTRUMENTATION |
---|
[789] | 1481 | m_cpt_itlb_read++; |
---|
[331] | 1482 | #endif |
---|
[789] | 1483 | hit = r_itlb.translate(r_dcache_save_wdata.read(), &paddr); |
---|
[331] | 1484 | } |
---|
[789] | 1485 | else // itlb not activated |
---|
[331] | 1486 | { |
---|
[789] | 1487 | paddr = (paddr_t) r_dcache_save_wdata.read(); |
---|
| 1488 | hit = true; |
---|
[331] | 1489 | } |
---|
| 1490 | |
---|
[789] | 1491 | if (hit) // continue the selective inval process |
---|
[331] | 1492 | { |
---|
[789] | 1493 | r_icache_vci_paddr = paddr; |
---|
| 1494 | r_icache_fsm = ICACHE_XTN_CACHE_INVAL_PA; |
---|
[331] | 1495 | } |
---|
[789] | 1496 | else // miss : send a request to DCACHE FSM |
---|
[331] | 1497 | { |
---|
| 1498 | |
---|
| 1499 | #ifdef INSTRUMENTATION |
---|
[789] | 1500 | m_cpt_itlb_miss++; |
---|
[331] | 1501 | #endif |
---|
| 1502 | r_icache_tlb_miss_req = true; |
---|
[789] | 1503 | r_icache_vaddr_save = r_dcache_save_wdata.read(); |
---|
[331] | 1504 | r_icache_fsm = ICACHE_TLB_WAIT; |
---|
| 1505 | } |
---|
| 1506 | break; |
---|
| 1507 | } |
---|
| 1508 | /////////////////////////////// |
---|
[789] | 1509 | case ICACHE_XTN_CACHE_INVAL_PA: // selective invalidate cache line with physical address |
---|
[331] | 1510 | // require 2 cycles. In this state, we read directory |
---|
| 1511 | // with address stored in r_icache_vci_paddr register. |
---|
| 1512 | { |
---|
[789] | 1513 | int state; |
---|
| 1514 | size_t way; |
---|
| 1515 | size_t set; |
---|
| 1516 | size_t word; |
---|
[331] | 1517 | |
---|
| 1518 | #ifdef INSTRUMENTATION |
---|
[789] | 1519 | m_cpt_icache_dir_read++; |
---|
[331] | 1520 | #endif |
---|
| 1521 | r_icache.read_dir(r_icache_vci_paddr.read(), |
---|
| 1522 | &state, |
---|
| 1523 | &way, |
---|
| 1524 | &set, |
---|
| 1525 | &word); |
---|
| 1526 | |
---|
[789] | 1527 | if (state == CACHE_SLOT_STATE_VALID) // inval to be done |
---|
[331] | 1528 | { |
---|
| 1529 | r_icache_miss_way = way; |
---|
| 1530 | r_icache_miss_set = set; |
---|
| 1531 | r_icache_fsm = ICACHE_XTN_CACHE_INVAL_GO; |
---|
| 1532 | } |
---|
[789] | 1533 | else // miss : acknowlege the XTN request and return |
---|
[331] | 1534 | { |
---|
| 1535 | r_dcache_xtn_req = false; |
---|
| 1536 | r_icache_fsm = ICACHE_IDLE; |
---|
| 1537 | } |
---|
| 1538 | break; |
---|
| 1539 | } |
---|
| 1540 | /////////////////////////////// |
---|
| 1541 | case ICACHE_XTN_CACHE_INVAL_GO: // Switch slot to ZOMBI state for an XTN inval |
---|
| 1542 | { |
---|
[789] | 1543 | if (not r_icache_cc_send_req.read()) // blocked until previous cc_send request not sent |
---|
[331] | 1544 | { |
---|
| 1545 | |
---|
| 1546 | #ifdef INSTRUMENTATION |
---|
[789] | 1547 | m_cpt_icache_dir_write++; |
---|
[331] | 1548 | #endif |
---|
[789] | 1549 | r_icache.write_dir(r_icache_miss_way.read(), |
---|
| 1550 | r_icache_miss_set.read(), |
---|
| 1551 | CACHE_SLOT_STATE_ZOMBI); |
---|
[331] | 1552 | |
---|
| 1553 | // request cleanup |
---|
| 1554 | r_icache_cc_send_req = true; |
---|
[789] | 1555 | r_icache_cc_send_nline = r_icache_vci_paddr.read() / (m_icache_words << 2); |
---|
[331] | 1556 | r_icache_cc_send_way = r_icache_miss_way.read(); |
---|
| 1557 | r_icache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 1558 | |
---|
| 1559 | // acknowledge the XTN request and return |
---|
[789] | 1560 | r_dcache_xtn_req = false; |
---|
| 1561 | r_icache_fsm = ICACHE_IDLE; |
---|
[331] | 1562 | } |
---|
| 1563 | break; |
---|
| 1564 | } |
---|
| 1565 | //////////////////////// |
---|
| 1566 | case ICACHE_MISS_SELECT: // Try to select a slot in associative set, |
---|
| 1567 | // Waiting in this state if no slot available. |
---|
[487] | 1568 | // If a victim slot has been choosen and the r_icache_cc_send_req is false, |
---|
| 1569 | // we send the cleanup request in this state. |
---|
| 1570 | // If not, a r_icache_cleanup_victim_req flip-flop is |
---|
| 1571 | // utilized for saving this cleanup request, and it will be sent later |
---|
| 1572 | // in state ICACHE_MISS_WAIT or ICACHE_MISS_UPDT_DIR. |
---|
| 1573 | // The r_icache_miss_clack flip-flop is set |
---|
[331] | 1574 | // when a cleanup is required |
---|
| 1575 | { |
---|
| 1576 | if (m_ireq.valid) m_cost_ins_miss_frz++; |
---|
| 1577 | |
---|
[468] | 1578 | // coherence clack interrupt |
---|
[789] | 1579 | if (r_icache_clack_req.read()) |
---|
[468] | 1580 | { |
---|
| 1581 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1582 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1583 | break; |
---|
| 1584 | } |
---|
| 1585 | |
---|
[331] | 1586 | // coherence interrupt |
---|
[789] | 1587 | if (r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) |
---|
[331] | 1588 | { |
---|
| 1589 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1590 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1591 | break; |
---|
| 1592 | } |
---|
| 1593 | |
---|
| 1594 | |
---|
[789] | 1595 | bool found; |
---|
| 1596 | bool cleanup; |
---|
| 1597 | size_t way; |
---|
| 1598 | size_t set; |
---|
| 1599 | paddr_t victim; |
---|
[487] | 1600 | |
---|
[331] | 1601 | #ifdef INSTRUMENTATION |
---|
[789] | 1602 | m_cpt_icache_dir_read++; |
---|
[331] | 1603 | #endif |
---|
[487] | 1604 | r_icache.read_select(r_icache_vci_paddr.read(), |
---|
| 1605 | &victim, |
---|
| 1606 | &way, |
---|
| 1607 | &set, |
---|
| 1608 | &found, |
---|
[789] | 1609 | &cleanup); |
---|
| 1610 | if (not found) |
---|
[487] | 1611 | { |
---|
| 1612 | break; |
---|
| 1613 | } |
---|
| 1614 | else |
---|
| 1615 | { |
---|
[789] | 1616 | r_icache_miss_way = way; |
---|
| 1617 | r_icache_miss_set = set; |
---|
[487] | 1618 | |
---|
[789] | 1619 | if (cleanup) |
---|
[331] | 1620 | { |
---|
[789] | 1621 | if (not r_icache_cc_send_req.read()) |
---|
[331] | 1622 | { |
---|
[789] | 1623 | r_icache_cc_send_req = true; |
---|
| 1624 | r_icache_cc_send_nline = victim; |
---|
| 1625 | r_icache_cc_send_way = way; |
---|
| 1626 | r_icache_cc_send_type = CC_TYPE_CLEANUP; |
---|
[331] | 1627 | } |
---|
| 1628 | else |
---|
| 1629 | { |
---|
[487] | 1630 | r_icache_cleanup_victim_req = true; |
---|
| 1631 | r_icache_cleanup_victim_nline = victim; |
---|
[331] | 1632 | } |
---|
| 1633 | |
---|
[789] | 1634 | r_icache_miss_clack = true; |
---|
| 1635 | r_icache_fsm = ICACHE_MISS_CLEAN; |
---|
[487] | 1636 | } |
---|
| 1637 | else |
---|
| 1638 | { |
---|
[789] | 1639 | r_icache_fsm = ICACHE_MISS_WAIT; |
---|
[487] | 1640 | } |
---|
| 1641 | |
---|
[331] | 1642 | #if DEBUG_ICACHE |
---|
[789] | 1643 | if (m_debug_icache_fsm) |
---|
| 1644 | { |
---|
| 1645 | std::cout << " <PROC " << name() |
---|
| 1646 | << " ICACHE_MISS_SELECT> Select a slot:" << std::dec |
---|
| 1647 | << " / WAY = " << way |
---|
| 1648 | << " / SET = " << set; |
---|
| 1649 | if (cleanup) std::cout << " / VICTIM = " << std::hex << victim << std::endl; |
---|
| 1650 | else std::cout << std::endl; |
---|
| 1651 | } |
---|
[331] | 1652 | #endif |
---|
| 1653 | } |
---|
| 1654 | break; |
---|
| 1655 | } |
---|
| 1656 | /////////////////////// |
---|
[789] | 1657 | case ICACHE_MISS_CLEAN: // switch the slot to zombi state |
---|
[331] | 1658 | { |
---|
| 1659 | if (m_ireq.valid) m_cost_ins_miss_frz++; |
---|
| 1660 | |
---|
| 1661 | #ifdef INSTRUMENTATION |
---|
[789] | 1662 | m_cpt_icache_dir_write++; |
---|
[331] | 1663 | #endif |
---|
[789] | 1664 | r_icache.write_dir(r_icache_miss_way.read(), |
---|
| 1665 | r_icache_miss_set.read(), |
---|
| 1666 | CACHE_SLOT_STATE_ZOMBI); |
---|
[331] | 1667 | #if DEBUG_ICACHE |
---|
[789] | 1668 | if (m_debug_icache_fsm) |
---|
| 1669 | { |
---|
| 1670 | std::cout << " <PROC " << name() |
---|
| 1671 | << " ICACHE_MISS_CLEAN> Switch to ZOMBI state" << std::dec |
---|
| 1672 | << " / WAY = " << r_icache_miss_way.read() |
---|
| 1673 | << " / SET = " << r_icache_miss_set.read() << std::endl; |
---|
| 1674 | } |
---|
[331] | 1675 | #endif |
---|
| 1676 | |
---|
| 1677 | r_icache_fsm = ICACHE_MISS_WAIT; |
---|
| 1678 | break; |
---|
| 1679 | } |
---|
| 1680 | ////////////////////// |
---|
[789] | 1681 | case ICACHE_MISS_WAIT: // waiting response from VCI_RSP FSM |
---|
[331] | 1682 | { |
---|
| 1683 | if (m_ireq.valid) m_cost_ins_miss_frz++; |
---|
| 1684 | |
---|
[487] | 1685 | // send cleanup victim request |
---|
[789] | 1686 | if (r_icache_cleanup_victim_req.read() and not r_icache_cc_send_req.read()) |
---|
[487] | 1687 | { |
---|
| 1688 | r_icache_cc_send_req = true; |
---|
| 1689 | r_icache_cc_send_nline = r_icache_cleanup_victim_nline; |
---|
| 1690 | r_icache_cc_send_way = r_icache_miss_way; |
---|
| 1691 | r_icache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 1692 | r_icache_cleanup_victim_req = false; |
---|
| 1693 | } |
---|
[468] | 1694 | |
---|
[488] | 1695 | // coherence clack interrupt |
---|
[789] | 1696 | if (r_icache_clack_req.read()) |
---|
[488] | 1697 | { |
---|
| 1698 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1699 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1700 | break; |
---|
| 1701 | } |
---|
| 1702 | |
---|
[331] | 1703 | // coherence interrupt |
---|
[789] | 1704 | if (r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() and not r_icache_cleanup_victim_req.read()) |
---|
[331] | 1705 | { |
---|
| 1706 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1707 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1708 | break; |
---|
| 1709 | } |
---|
| 1710 | |
---|
[789] | 1711 | if (r_vci_rsp_ins_error.read()) // bus error |
---|
[331] | 1712 | { |
---|
| 1713 | r_mmu_ietr = MMU_READ_DATA_ILLEGAL_ACCESS; |
---|
| 1714 | r_mmu_ibvar = r_icache_vaddr_save.read(); |
---|
| 1715 | m_irsp.valid = true; |
---|
| 1716 | m_irsp.error = true; |
---|
| 1717 | r_vci_rsp_ins_error = false; |
---|
| 1718 | r_icache_fsm = ICACHE_IDLE; |
---|
| 1719 | } |
---|
[789] | 1720 | else if (r_vci_rsp_fifo_icache.rok()) // response available |
---|
[331] | 1721 | { |
---|
| 1722 | r_icache_miss_word = 0; |
---|
| 1723 | r_icache_fsm = ICACHE_MISS_DATA_UPDT; |
---|
| 1724 | } |
---|
| 1725 | break; |
---|
| 1726 | } |
---|
| 1727 | /////////////////////////// |
---|
[789] | 1728 | case ICACHE_MISS_DATA_UPDT: // update the cache (one word per cycle) |
---|
[331] | 1729 | { |
---|
[789] | 1730 | if (m_ireq.valid) m_cost_ins_miss_frz++; |
---|
[331] | 1731 | |
---|
[789] | 1732 | if (r_vci_rsp_fifo_icache.rok()) // response available |
---|
[331] | 1733 | { |
---|
| 1734 | |
---|
| 1735 | #ifdef INSTRUMENTATION |
---|
[789] | 1736 | m_cpt_icache_data_write++; |
---|
[331] | 1737 | #endif |
---|
[789] | 1738 | r_icache.write(r_icache_miss_way.read(), |
---|
| 1739 | r_icache_miss_set.read(), |
---|
| 1740 | r_icache_miss_word.read(), |
---|
| 1741 | r_vci_rsp_fifo_icache.read()); |
---|
[331] | 1742 | #if DEBUG_ICACHE |
---|
[789] | 1743 | if (m_debug_icache_fsm) |
---|
| 1744 | { |
---|
| 1745 | std::cout << " <PROC " << name() |
---|
| 1746 | << " ICACHE_MISS_DATA_UPDT> Write one word:" |
---|
| 1747 | << " WDATA = " << std::hex << r_vci_rsp_fifo_icache.read() |
---|
| 1748 | << " WAY = " << r_icache_miss_way.read() |
---|
| 1749 | << " SET = " << r_icache_miss_set.read() |
---|
| 1750 | << " WORD = " << r_icache_miss_word.read() << std::endl; |
---|
| 1751 | } |
---|
[331] | 1752 | #endif |
---|
| 1753 | vci_rsp_fifo_icache_get = true; |
---|
| 1754 | r_icache_miss_word = r_icache_miss_word.read() + 1; |
---|
| 1755 | |
---|
[789] | 1756 | if (r_icache_miss_word.read() == m_icache_words - 1) // last word |
---|
[331] | 1757 | { |
---|
| 1758 | r_icache_fsm = ICACHE_MISS_DIR_UPDT; |
---|
| 1759 | } |
---|
| 1760 | } |
---|
| 1761 | break; |
---|
| 1762 | } |
---|
| 1763 | ////////////////////////// |
---|
[789] | 1764 | case ICACHE_MISS_DIR_UPDT: // Stalled if a victim line has been evicted, |
---|
[331] | 1765 | // and the cleanup ack has not been received, |
---|
| 1766 | // as indicated by r_icache_miss_clack. |
---|
| 1767 | // - If no matching coherence request (r_icache_miss_inval) |
---|
| 1768 | // switch directory slot to VALID state. |
---|
| 1769 | // - If matching coherence request, switch directory slot |
---|
| 1770 | // to ZOMBI state, and send a cleanup request. |
---|
| 1771 | { |
---|
[789] | 1772 | if (m_ireq.valid ) m_cost_ins_miss_frz++; |
---|
[331] | 1773 | |
---|
[487] | 1774 | // send cleanup victim request |
---|
[789] | 1775 | if (r_icache_cleanup_victim_req.read() and not r_icache_cc_send_req.read()) |
---|
[487] | 1776 | { |
---|
| 1777 | r_icache_cc_send_req = true; |
---|
| 1778 | r_icache_cc_send_nline = r_icache_cleanup_victim_nline; |
---|
| 1779 | r_icache_cc_send_way = r_icache_miss_way; |
---|
| 1780 | r_icache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 1781 | r_icache_cleanup_victim_req = false; |
---|
| 1782 | } |
---|
| 1783 | |
---|
[488] | 1784 | // coherence clack interrupt |
---|
[789] | 1785 | if (r_icache_clack_req.read()) |
---|
[488] | 1786 | { |
---|
| 1787 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1788 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1789 | break; |
---|
| 1790 | } |
---|
| 1791 | |
---|
[331] | 1792 | // coherence interrupt |
---|
[789] | 1793 | if (r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() and not r_icache_cleanup_victim_req.read()) |
---|
[331] | 1794 | { |
---|
| 1795 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
| 1796 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1797 | break; |
---|
| 1798 | } |
---|
| 1799 | |
---|
[789] | 1800 | if (not r_icache_miss_clack.read()) // waiting cleanup acknowledge for victim line |
---|
[331] | 1801 | { |
---|
[789] | 1802 | if (r_icache_miss_inval) // Switch slot to ZOMBI state, and new cleanup |
---|
[331] | 1803 | { |
---|
[789] | 1804 | if (not r_icache_cc_send_req.read()) |
---|
[331] | 1805 | { |
---|
| 1806 | r_icache_miss_inval = false; |
---|
| 1807 | // request cleanup |
---|
| 1808 | r_icache_cc_send_req = true; |
---|
[789] | 1809 | r_icache_cc_send_nline = r_icache_vci_paddr.read() / (m_icache_words << 2); |
---|
[331] | 1810 | r_icache_cc_send_way = r_icache_miss_way.read(); |
---|
| 1811 | r_icache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 1812 | |
---|
| 1813 | #ifdef INSTRUMENTATION |
---|
[789] | 1814 | m_cpt_icache_dir_write++; |
---|
[331] | 1815 | #endif |
---|
[789] | 1816 | r_icache.write_dir(r_icache_vci_paddr.read(), |
---|
| 1817 | r_icache_miss_way.read(), |
---|
| 1818 | r_icache_miss_set.read(), |
---|
| 1819 | CACHE_SLOT_STATE_ZOMBI); |
---|
[331] | 1820 | #if DEBUG_ICACHE |
---|
[789] | 1821 | if (m_debug_icache_fsm) |
---|
| 1822 | { |
---|
| 1823 | std::cout << " <PROC " << name() |
---|
| 1824 | << " ICACHE_MISS_DIR_UPDT> Switch cache slot to ZOMBI state" |
---|
| 1825 | << " PADDR = " << std::hex << r_icache_vci_paddr.read() |
---|
| 1826 | << " WAY = " << std::dec << r_icache_miss_way.read() |
---|
| 1827 | << " SET = " << r_icache_miss_set.read() << std::endl; |
---|
| 1828 | } |
---|
[331] | 1829 | #endif |
---|
| 1830 | } |
---|
| 1831 | else |
---|
| 1832 | break; |
---|
| 1833 | } |
---|
[789] | 1834 | else // Switch slot to VALID state |
---|
[331] | 1835 | { |
---|
| 1836 | |
---|
| 1837 | #ifdef INSTRUMENTATION |
---|
[789] | 1838 | m_cpt_icache_dir_write++; |
---|
[331] | 1839 | #endif |
---|
[789] | 1840 | r_icache.write_dir(r_icache_vci_paddr.read(), |
---|
| 1841 | r_icache_miss_way.read(), |
---|
| 1842 | r_icache_miss_set.read(), |
---|
| 1843 | CACHE_SLOT_STATE_VALID); |
---|
[331] | 1844 | #if DEBUG_ICACHE |
---|
[789] | 1845 | if (m_debug_icache_fsm) |
---|
| 1846 | { |
---|
| 1847 | std::cout << " <PROC " << name() |
---|
| 1848 | << " ICACHE_MISS_DIR_UPDT> Switch cache slot to VALID state" |
---|
| 1849 | << " PADDR = " << std::hex << r_icache_vci_paddr.read() |
---|
| 1850 | << " WAY = " << std::dec << r_icache_miss_way.read() |
---|
| 1851 | << " SET = " << r_icache_miss_set.read() << std::endl; |
---|
| 1852 | } |
---|
[331] | 1853 | #endif |
---|
| 1854 | } |
---|
| 1855 | |
---|
| 1856 | r_icache_fsm = ICACHE_IDLE; |
---|
| 1857 | } |
---|
| 1858 | break; |
---|
| 1859 | } |
---|
| 1860 | //////////////////// |
---|
[789] | 1861 | case ICACHE_UNC_WAIT: // waiting a response to an uncacheable read from VCI_RSP FSM |
---|
[331] | 1862 | { |
---|
[468] | 1863 | // coherence clack interrupt |
---|
[789] | 1864 | if (r_icache_clack_req.read()) |
---|
[468] | 1865 | { |
---|
[789] | 1866 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
[468] | 1867 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1868 | break; |
---|
| 1869 | } |
---|
| 1870 | |
---|
[331] | 1871 | // coherence interrupt |
---|
[789] | 1872 | if (r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read()) |
---|
[331] | 1873 | { |
---|
[789] | 1874 | r_icache_fsm = ICACHE_CC_CHECK; |
---|
[331] | 1875 | r_icache_fsm_save = r_icache_fsm.read(); |
---|
| 1876 | break; |
---|
| 1877 | } |
---|
| 1878 | |
---|
[789] | 1879 | if (r_vci_rsp_ins_error.read()) // bus error |
---|
[331] | 1880 | { |
---|
| 1881 | r_mmu_ietr = MMU_READ_DATA_ILLEGAL_ACCESS; |
---|
| 1882 | r_mmu_ibvar = m_ireq.addr; |
---|
| 1883 | r_vci_rsp_ins_error = false; |
---|
| 1884 | m_irsp.valid = true; |
---|
| 1885 | m_irsp.error = true; |
---|
| 1886 | r_icache_fsm = ICACHE_IDLE; |
---|
| 1887 | } |
---|
[789] | 1888 | else if (r_vci_rsp_fifo_icache.rok()) // instruction available |
---|
[331] | 1889 | { |
---|
| 1890 | vci_rsp_fifo_icache_get = true; |
---|
| 1891 | r_icache_fsm = ICACHE_IDLE; |
---|
[789] | 1892 | if (m_ireq.valid and |
---|
| 1893 | (m_ireq.addr == r_icache_vaddr_save.read())) // request unmodified |
---|
[331] | 1894 | { |
---|
| 1895 | m_irsp.valid = true; |
---|
| 1896 | m_irsp.instruction = r_vci_rsp_fifo_icache.read(); |
---|
| 1897 | } |
---|
| 1898 | } |
---|
| 1899 | break; |
---|
| 1900 | } |
---|
| 1901 | ///////////////////// |
---|
[789] | 1902 | case ICACHE_CC_CHECK: // This state is the entry point of a sub-fsm |
---|
| 1903 | // handling coherence requests. |
---|
| 1904 | // if there is a matching pending miss, it is |
---|
| 1905 | // signaled in the r_icache_miss_inval flip-flop. |
---|
| 1906 | // The return state is defined in r_icache_fsm_save. |
---|
[331] | 1907 | { |
---|
[789] | 1908 | paddr_t paddr = r_cc_receive_icache_nline.read() * m_icache_words * 4; |
---|
| 1909 | paddr_t mask = ~((m_icache_words << 2) - 1); |
---|
[331] | 1910 | |
---|
[484] | 1911 | // CLACK handler |
---|
| 1912 | // We switch the directory slot to EMPTY state |
---|
| 1913 | // and reset r_icache_miss_clack if the cleanup ack |
---|
| 1914 | // is matching a pending miss. |
---|
[789] | 1915 | if (r_icache_clack_req.read()) |
---|
[484] | 1916 | { |
---|
[331] | 1917 | |
---|
[789] | 1918 | if (m_ireq.valid) m_cost_ins_miss_frz++; |
---|
[484] | 1919 | |
---|
| 1920 | #ifdef INSTRUMENTATION |
---|
[789] | 1921 | m_cpt_icache_dir_write++; |
---|
[484] | 1922 | #endif |
---|
[789] | 1923 | r_icache.write_dir(0, |
---|
| 1924 | r_icache_clack_way.read(), |
---|
| 1925 | r_icache_clack_set.read(), |
---|
| 1926 | CACHE_SLOT_STATE_EMPTY); |
---|
[484] | 1927 | |
---|
[789] | 1928 | if ((r_icache_miss_set.read() == r_icache_clack_set.read()) and |
---|
| 1929 | (r_icache_miss_way.read() == r_icache_clack_way.read())) |
---|
[484] | 1930 | { |
---|
| 1931 | r_icache_miss_clack = false; |
---|
| 1932 | } |
---|
| 1933 | |
---|
| 1934 | r_icache_clack_req = false; |
---|
| 1935 | |
---|
| 1936 | // return to cc_save state |
---|
| 1937 | r_icache_fsm = r_icache_fsm_save.read(); |
---|
| 1938 | |
---|
| 1939 | #if DEBUG_ICACHE |
---|
[789] | 1940 | if (m_debug_icache_fsm) |
---|
| 1941 | { |
---|
| 1942 | std::cout << " <PROC " << name() |
---|
| 1943 | << " ICACHE_CC_CHECK> CC_TYPE_CLACK slot returns to empty state" |
---|
| 1944 | << " set = " << r_icache_clack_set.read() |
---|
| 1945 | << " / way = " << r_icache_clack_way.read() << std::endl; |
---|
| 1946 | } |
---|
[484] | 1947 | #endif |
---|
| 1948 | |
---|
| 1949 | break; |
---|
| 1950 | } |
---|
| 1951 | |
---|
[789] | 1952 | assert(not r_icache_cc_send_req.read() and "CC_SEND must be available in ICACHE_CC_CHECK"); |
---|
[487] | 1953 | |
---|
[468] | 1954 | // Match between MISS address and CC address |
---|
| 1955 | if (r_cc_receive_icache_req.read() and |
---|
[789] | 1956 | ((r_icache_fsm_save.read() == ICACHE_MISS_SELECT) or |
---|
| 1957 | (r_icache_fsm_save.read() == ICACHE_MISS_WAIT) or |
---|
[468] | 1958 | (r_icache_fsm_save.read() == ICACHE_MISS_DIR_UPDT)) and |
---|
[789] | 1959 | ((r_icache_vci_paddr.read() & mask) == (paddr & mask))) // matching |
---|
[331] | 1960 | { |
---|
| 1961 | // signaling the matching |
---|
[789] | 1962 | r_icache_miss_inval = true; |
---|
[331] | 1963 | |
---|
| 1964 | // in case of update, go to CC_UPDT |
---|
| 1965 | // JUST TO POP THE FIFO |
---|
| 1966 | if (r_cc_receive_icache_type.read() == CC_TYPE_UPDT) |
---|
| 1967 | { |
---|
[789] | 1968 | r_icache_fsm = ICACHE_CC_UPDT; |
---|
| 1969 | r_icache_cc_word = r_cc_receive_word_idx.read(); |
---|
[468] | 1970 | |
---|
[331] | 1971 | // just pop the fifo , don't write in icache |
---|
| 1972 | r_icache_cc_need_write = false; |
---|
| 1973 | } |
---|
| 1974 | // the request is dealt with |
---|
| 1975 | else |
---|
| 1976 | { |
---|
| 1977 | r_cc_receive_icache_req = false; |
---|
[789] | 1978 | r_icache_fsm = r_icache_fsm_save.read(); |
---|
[331] | 1979 | } |
---|
| 1980 | #if DEBUG_ICACHE |
---|
[789] | 1981 | if (m_debug_icache_fsm) |
---|
| 1982 | { |
---|
| 1983 | std::cout << " <PROC " << name() |
---|
| 1984 | << " ICACHE_CC_CHECK> Coherence request matching a pending miss:" |
---|
| 1985 | << " PADDR = " << std::hex << paddr << std::endl; |
---|
| 1986 | } |
---|
[331] | 1987 | #endif |
---|
| 1988 | } |
---|
[468] | 1989 | |
---|
| 1990 | // CC request handler |
---|
| 1991 | |
---|
[789] | 1992 | int state = 0; |
---|
| 1993 | size_t way = 0; |
---|
| 1994 | size_t set = 0; |
---|
| 1995 | size_t word = 0; |
---|
[468] | 1996 | |
---|
[331] | 1997 | #ifdef INSTRUMENTATION |
---|
[789] | 1998 | m_cpt_icache_dir_read++; |
---|
[331] | 1999 | #endif |
---|
[468] | 2000 | r_icache.read_dir(paddr, |
---|
| 2001 | &state, |
---|
| 2002 | &way, |
---|
| 2003 | &set, |
---|
| 2004 | &word); |
---|
| 2005 | |
---|
| 2006 | r_icache_cc_way = way; |
---|
| 2007 | r_icache_cc_set = set; |
---|
| 2008 | |
---|
[789] | 2009 | if (state == CACHE_SLOT_STATE_VALID) // hit |
---|
[331] | 2010 | { |
---|
[468] | 2011 | // need to update the cache state |
---|
| 2012 | if (r_cc_receive_icache_type.read() == CC_TYPE_UPDT) // hit update |
---|
| 2013 | { |
---|
| 2014 | r_icache_cc_need_write = true; |
---|
[789] | 2015 | r_icache_fsm = ICACHE_CC_UPDT; |
---|
| 2016 | r_icache_cc_word = r_cc_receive_word_idx.read(); |
---|
[468] | 2017 | } |
---|
[789] | 2018 | else if (r_cc_receive_icache_type.read() == CC_TYPE_INVAL) // hit inval |
---|
[468] | 2019 | { |
---|
[789] | 2020 | r_icache_fsm = ICACHE_CC_INVAL; |
---|
[468] | 2021 | } |
---|
[331] | 2022 | } |
---|
[468] | 2023 | else // miss |
---|
[331] | 2024 | { |
---|
[468] | 2025 | // multicast acknowledgement required in case of update |
---|
[789] | 2026 | if (r_cc_receive_icache_type.read() == CC_TYPE_UPDT) |
---|
[468] | 2027 | { |
---|
[789] | 2028 | r_icache_fsm = ICACHE_CC_UPDT; |
---|
| 2029 | r_icache_cc_word = r_cc_receive_word_idx.read(); |
---|
[331] | 2030 | |
---|
[468] | 2031 | // just pop the fifo , don't write in icache |
---|
| 2032 | r_icache_cc_need_write = false; |
---|
| 2033 | } |
---|
| 2034 | else // No response needed |
---|
| 2035 | { |
---|
| 2036 | r_cc_receive_icache_req = false; |
---|
[789] | 2037 | r_icache_fsm = r_icache_fsm_save.read(); |
---|
[468] | 2038 | } |
---|
[331] | 2039 | } |
---|
| 2040 | break; |
---|
| 2041 | } |
---|
[468] | 2042 | ///////////////////// |
---|
[789] | 2043 | case ICACHE_CC_INVAL: // hit inval : switch slot to ZOMBI state |
---|
[331] | 2044 | { |
---|
[468] | 2045 | assert (not r_icache_cc_send_req.read() && |
---|
| 2046 | "ERROR in ICACHE_CC_INVAL: the r_icache_cc_send_req " |
---|
| 2047 | "must not be set"); |
---|
[331] | 2048 | |
---|
[468] | 2049 | #ifdef INSTRUMENTATION |
---|
[789] | 2050 | m_cpt_icache_dir_read++; |
---|
[468] | 2051 | #endif |
---|
| 2052 | |
---|
| 2053 | // Switch slot state to ZOMBI and send CLEANUP command |
---|
[789] | 2054 | r_icache.write_dir(r_icache_cc_way.read(), |
---|
| 2055 | r_icache_cc_set.read(), |
---|
| 2056 | CACHE_SLOT_STATE_ZOMBI); |
---|
[468] | 2057 | |
---|
| 2058 | // coherence request completed |
---|
| 2059 | r_icache_cc_send_req = true; |
---|
| 2060 | r_icache_cc_send_nline = r_cc_receive_icache_nline.read(); |
---|
| 2061 | r_icache_cc_send_way = r_icache_cc_way.read(); |
---|
| 2062 | r_icache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 2063 | |
---|
[789] | 2064 | r_icache_fsm = r_icache_fsm_save.read(); |
---|
[468] | 2065 | |
---|
[331] | 2066 | #if DEBUG_ICACHE |
---|
[789] | 2067 | if (m_debug_icache_fsm) |
---|
| 2068 | { |
---|
| 2069 | std::cout << " <PROC " << name() |
---|
| 2070 | << " ICACHE_CC_INVAL> slot returns to ZOMBI state" |
---|
| 2071 | << " set = " << r_icache_cc_set.read() |
---|
| 2072 | << " / way = " << r_icache_cc_way.read() << std::endl; |
---|
| 2073 | } |
---|
[331] | 2074 | #endif |
---|
| 2075 | |
---|
[468] | 2076 | break; |
---|
| 2077 | } |
---|
| 2078 | //////////////////// |
---|
[789] | 2079 | case ICACHE_CC_UPDT: // hit update : write one word per cycle |
---|
[468] | 2080 | { |
---|
| 2081 | assert (not r_icache_cc_send_req.read() && |
---|
| 2082 | "ERROR in ICACHE_CC_UPDT: the r_icache_cc_send_req " |
---|
| 2083 | "must not be set"); |
---|
| 2084 | |
---|
[789] | 2085 | if (not r_cc_receive_updt_fifo_be.rok()) break; |
---|
[468] | 2086 | |
---|
| 2087 | |
---|
[789] | 2088 | size_t word = r_icache_cc_word.read(); |
---|
| 2089 | size_t way = r_icache_cc_way.read(); |
---|
| 2090 | size_t set = r_icache_cc_set.read(); |
---|
[331] | 2091 | |
---|
[468] | 2092 | if (r_icache_cc_need_write.read()) |
---|
[331] | 2093 | { |
---|
[789] | 2094 | r_icache.write(way, |
---|
| 2095 | set, |
---|
| 2096 | word, |
---|
| 2097 | r_cc_receive_updt_fifo_data.read(), |
---|
| 2098 | r_cc_receive_updt_fifo_be.read()); |
---|
[331] | 2099 | |
---|
[789] | 2100 | r_icache_cc_word = word + 1; |
---|
[331] | 2101 | |
---|
[468] | 2102 | #ifdef INSTRUMENTATION |
---|
[789] | 2103 | m_cpt_icache_data_write++; |
---|
[468] | 2104 | #endif |
---|
[331] | 2105 | |
---|
| 2106 | #if DEBUG_ICACHE |
---|
[789] | 2107 | if (m_debug_icache_fsm) |
---|
| 2108 | { |
---|
| 2109 | std::cout << " <PROC " << name() |
---|
| 2110 | << " ICACHE_CC_UPDT> Write one word " |
---|
| 2111 | << " set = " << r_icache_cc_set.read() |
---|
| 2112 | << " / way = " << r_icache_cc_way.read() |
---|
| 2113 | << " / word = " << r_icache_cc_word.read() << std::endl; |
---|
| 2114 | } |
---|
[331] | 2115 | #endif |
---|
[468] | 2116 | } |
---|
[331] | 2117 | |
---|
[789] | 2118 | if (r_cc_receive_updt_fifo_eop.read()) // last word |
---|
[331] | 2119 | { |
---|
| 2120 | // no need to write in the cache anymore |
---|
[789] | 2121 | r_icache_cc_need_write = false; |
---|
[331] | 2122 | |
---|
| 2123 | // coherence request completed |
---|
[789] | 2124 | r_cc_receive_icache_req = false; |
---|
[331] | 2125 | |
---|
[468] | 2126 | // request multicast acknowledgement |
---|
| 2127 | r_icache_cc_send_req = true; |
---|
| 2128 | r_icache_cc_send_nline = r_cc_receive_icache_nline.read(); |
---|
| 2129 | r_icache_cc_send_updt_tab_idx = r_cc_receive_icache_updt_tab_idx.read(); |
---|
| 2130 | r_icache_cc_send_type = CC_TYPE_MULTI_ACK; |
---|
| 2131 | |
---|
[789] | 2132 | r_icache_fsm = r_icache_fsm_save.read(); |
---|
[331] | 2133 | } |
---|
[468] | 2134 | //consume fifo if not eop |
---|
[789] | 2135 | cc_receive_updt_fifo_get = true; |
---|
[468] | 2136 | |
---|
[331] | 2137 | break; |
---|
| 2138 | } |
---|
[468] | 2139 | |
---|
[331] | 2140 | } // end switch r_icache_fsm |
---|
| 2141 | |
---|
| 2142 | //////////////////////////////////////////////////////////////////////////////////// |
---|
| 2143 | // DCACHE FSM |
---|
| 2144 | // |
---|
| 2145 | // 1/ Coherence operations |
---|
| 2146 | // They are handled as interrupts generated by the CC_RECEIVE FSM. |
---|
| 2147 | // - There is a coherence request when r_tgt_dcache_req is set. |
---|
| 2148 | // They are taken in IDLE, MISS_WAIT, MISS_DIR_UPDT, UNC_WAIT, LL_WAIT |
---|
| 2149 | // and SC_WAIT states. |
---|
| 2150 | // - There is a cleanup acknowledge request when r_cleanup_dcache_req is set. |
---|
| 2151 | // They are taken in IDLE, MISS_SELECT, MISS_CLEAN, MISS_WAIT, MISS_DATA_UPDT, |
---|
| 2152 | // MISS_DIR_UPDT, UNC_WAIT, LL_WAIT, SC_WAIT states. |
---|
| 2153 | // - For both types of requests, actions associated to the pre-empted state |
---|
| 2154 | // are not executed. The DCACHE FSM goes to the proper sub-FSM (CC_CHECK |
---|
| 2155 | // or CC_CLACK) to execute the requested coherence operation, and returns |
---|
| 2156 | // to the pre-empted state. |
---|
| 2157 | // |
---|
| 2158 | // 2/ TLB miss |
---|
| 2159 | // The page tables are generally cacheable. |
---|
| 2160 | // In case of miss in itlb or dtlb, the tlb miss is handled by a dedicated |
---|
| 2161 | // sub-fsm (DCACHE_TLB_MISS state), that handle possible miss in DCACHE, |
---|
| 2162 | // this sub-fsm implement the table-walk... |
---|
| 2163 | // |
---|
| 2164 | // 3/ processor requests |
---|
| 2165 | // Processor requests are taken in IDLE state only. |
---|
| 2166 | // The IDLE state implements a two stages pipe-line to handle write bursts: |
---|
| 2167 | // - Both DTLB and DCACHE are accessed in stage P0 (if processor request valid). |
---|
| 2168 | // - The registration in wbuf and the dcache update is done in stage P1 |
---|
| 2169 | // (if the processor request is a write). |
---|
| 2170 | // The two r_dcache_wbuf_req and r_dcache_updt_req flip-flops define |
---|
| 2171 | // the operations that must be done in P1 stage, and the access type |
---|
| 2172 | // (read or write) to the DATA part of DCACHE depends on r_dcache_updt_req. |
---|
| 2173 | // READ requests are delayed if a cache update is requested. |
---|
| 2174 | // WRITE or SC requests can require a PTE Dirty bit update (in memory), |
---|
| 2175 | // that is done (before handling the processor request) by a dedicated sub-fsm. |
---|
| 2176 | // If a PTE is modified, both the itlb and dtlb are selectively, but sequencially |
---|
| 2177 | // cleared by a dedicated sub_fsm (DCACHE_INVAL_TLB_SCAN state). |
---|
| 2178 | // |
---|
| 2179 | // 4/ Atomic instructions LL/SC |
---|
| 2180 | // The LL/SC address are non cacheable (systematic access to memory). |
---|
| 2181 | // The llsc buffer contains a registration for an active LL/SC operation |
---|
| 2182 | // (with an address, a registration key, an aging counter and a valid bit). |
---|
| 2183 | // - LL requests from the processor are transmitted as a one flit VCI command |
---|
| 2184 | // (CMD_LOCKED_READ as CMD, and TYPE_LL as PKTID value). PLEN must |
---|
| 2185 | // be 8 as the response is 2 flits long (data and registration key) |
---|
| 2186 | // - SC requests from the processor are systematically transmitted to the |
---|
| 2187 | // memory cache as 2 flits VCI command (CMD_STORE_COND as CMD, and TYPE_SC |
---|
| 2188 | // as PKTID value). The first flit contains the registration key, the second |
---|
| 2189 | // flit contains the data to write in case of success. |
---|
| 2190 | // The cache is not updated, as this is done in case of success by the |
---|
| 2191 | // coherence transaction. |
---|
| 2192 | // |
---|
| 2193 | // 5/ Non cacheable access: |
---|
| 2194 | // This component implement a strong order between non cacheable access |
---|
| 2195 | // (read or write) : A new non cacheable VCI transaction starts only when |
---|
[616] | 2196 | // the previous non cacheable transaction is completed. After send the VCI |
---|
| 2197 | // transaction, the DCACHE FSM wait for the respone in the DCACHE_UNC_WAIT state. |
---|
| 2198 | // So the processor is blocked until the respone arrives in CACHE L1. |
---|
[331] | 2199 | // |
---|
| 2200 | // 6/ Error handling: |
---|
| 2201 | // When the MMU is not activated, Read Bus Errors are synchronous events, |
---|
[616] | 2202 | // Some Write Bus Errors are synchronous events when the request is a non cacheable access |
---|
| 2203 | // but some Write Bus Errors are asynchronous events when the request is cacheable access |
---|
| 2204 | // (processor is not frozen). |
---|
| 2205 | // - If a Read Bus Error or a Non Cacheable Write Bus Error is detected, the VCI_RSP FSM sets the |
---|
[331] | 2206 | // r_vci_rsp_data_error flip-flop, without writing any data in the |
---|
| 2207 | // r_vci_rsp_fifo_dcache FIFO, and the synchronous error is signaled |
---|
| 2208 | // by the DCACHE FSM. |
---|
[616] | 2209 | // - If a Cacheable Write Bus Error is detected, the VCI_RSP_FSM signals |
---|
| 2210 | // the asynchronous error using the setWriteBerr() method. |
---|
[331] | 2211 | // When the MMU is activated bus error are rare events, as the MMU |
---|
| 2212 | // checks the physical address before the VCI transaction starts. |
---|
| 2213 | //////////////////////////////////////////////////////////////////////////////////////// |
---|
| 2214 | |
---|
| 2215 | // default value for m_drsp |
---|
| 2216 | m_drsp.valid = false; |
---|
| 2217 | m_drsp.error = false; |
---|
| 2218 | m_drsp.rdata = 0; |
---|
| 2219 | |
---|
[789] | 2220 | switch (r_dcache_fsm.read()) |
---|
[331] | 2221 | { |
---|
| 2222 | case DCACHE_IDLE: // There are 10 conditions to exit the IDLE state : |
---|
| 2223 | // 1) ITLB/DTLB inval request (update) => DCACHE_INVAL_TLB_SCAN |
---|
| 2224 | // 2) Coherence request (TGT FSM) => DCACHE_CC_CHECK |
---|
| 2225 | // 3) ITLB miss request (ICACHE FSM) => DCACHE_TLB_MISS |
---|
| 2226 | // 4) XTN request (processor) => DCACHE_XTN_* |
---|
| 2227 | // 5) DTLB miss (processor) => DCACHE_TLB_MISS |
---|
| 2228 | // 6) Dirty bit update (processor) => DCACHE_DIRTY_GET_PTE |
---|
| 2229 | // 7) Cacheable read miss (processor) => DCACHE_MISS_SELECT |
---|
| 2230 | // 8) Uncacheable read (processor) => DCACHE_UNC_WAIT |
---|
| 2231 | // 9) LL access (processor) => DCACHE_LL_WAIT |
---|
| 2232 | // 10) SC access (processor) => DCACHE_SC_WAIT |
---|
| 2233 | // |
---|
| 2234 | // There is a fixed priority to handle requests to DCACHE: |
---|
| 2235 | // 1/ the ITLB/DTLB invalidate requests |
---|
| 2236 | // 2/ the coherence requests, |
---|
| 2237 | // 3/ the processor requests (including DTLB miss), |
---|
| 2238 | // 4/ the ITLB miss requests, |
---|
| 2239 | // The address space processor request are handled as follows: |
---|
| 2240 | // - WRITE request is blocked if the Dirty bit mus be set. |
---|
| 2241 | // If DTLB hit, the P1 stage is activated (writes WBUF, and |
---|
| 2242 | // updates DCACHE if DCACHE hit) & processor request acknowledged. |
---|
| 2243 | // - READ request generate a simultaneouss access to DCACHE.DATA |
---|
| 2244 | // and DCACHE.DIR, but is delayed if DCACHE update required. |
---|
| 2245 | // |
---|
| 2246 | // There is 4 configurations defining the access type to |
---|
| 2247 | // DTLB, DCACHE.DATA, and DCACHE.DIR, depending on the |
---|
| 2248 | // dreq.valid (dreq) and r_dcache_updt_req (updt) signals: |
---|
| 2249 | // dreq / updt / DTLB / DCACHE.DIR / DCACHE.DATA / |
---|
| 2250 | // 0 / 0 / NOP / NOP / NOP / |
---|
| 2251 | // 0 / 1 / NOP / NOP / WRITE / |
---|
| 2252 | // 1 / 0 / READ / READ / NOP / |
---|
| 2253 | // 1 / 1 / READ / READ / WRITE / |
---|
| 2254 | // Those two registers are set at each cycle from the 3 signals |
---|
| 2255 | // updt_request, wbuf_request, wbuf_write_miss. |
---|
| 2256 | { |
---|
[789] | 2257 | paddr_t paddr; |
---|
| 2258 | pte_info_t tlb_flags; |
---|
| 2259 | size_t tlb_way; |
---|
| 2260 | size_t tlb_set; |
---|
| 2261 | paddr_t tlb_nline = 0; |
---|
| 2262 | size_t cache_way; |
---|
| 2263 | size_t cache_set; |
---|
| 2264 | size_t cache_word; |
---|
| 2265 | uint32_t cache_rdata = 0; |
---|
| 2266 | bool tlb_hit = false; |
---|
| 2267 | int cache_state = CACHE_SLOT_STATE_EMPTY; |
---|
[331] | 2268 | |
---|
[789] | 2269 | bool tlb_inval_required = false; // request TLB inval after cache update |
---|
| 2270 | bool wbuf_write_miss = false; // miss a WBUF write request |
---|
| 2271 | bool updt_request = false; // request DCACHE update in P1 stage |
---|
| 2272 | bool wbuf_request = false; // request WBUF write in P1 stage |
---|
[331] | 2273 | |
---|
[789] | 2274 | // physical address computation : systematic DTLB access if activated |
---|
[752] | 2275 | paddr = (paddr_t) m_dreq.addr; |
---|
[789] | 2276 | if (m_dreq.valid) |
---|
[331] | 2277 | { |
---|
[789] | 2278 | if (r_mmu_mode.read() & DATA_TLB_MASK) // DTLB activated |
---|
[331] | 2279 | { |
---|
[789] | 2280 | tlb_hit = r_dtlb.translate(m_dreq.addr, |
---|
| 2281 | &paddr, |
---|
| 2282 | &tlb_flags, |
---|
| 2283 | &tlb_nline, |
---|
| 2284 | &tlb_way, |
---|
| 2285 | &tlb_set); |
---|
[331] | 2286 | #ifdef INSTRUMENTATION |
---|
[789] | 2287 | m_cpt_dtlb_read++; |
---|
[331] | 2288 | #endif |
---|
| 2289 | } |
---|
[789] | 2290 | else // identity mapping |
---|
[331] | 2291 | { |
---|
[394] | 2292 | // we take into account the paddr extension |
---|
| 2293 | if (vci_param::N > 32) |
---|
[789] | 2294 | paddr = paddr | ((paddr_t) (r_dcache_paddr_ext.read()) << 32); |
---|
[331] | 2295 | } |
---|
| 2296 | } // end physical address computation |
---|
| 2297 | |
---|
| 2298 | // systematic DCACHE access depending on r_dcache_updt_req (if activated) |
---|
[789] | 2299 | if (r_mmu_mode.read() & DATA_CACHE_MASK) |
---|
[331] | 2300 | { |
---|
[752] | 2301 | |
---|
[789] | 2302 | if (m_dreq.valid and r_dcache_updt_req.read()) // read DIR and write DATA |
---|
[331] | 2303 | { |
---|
[789] | 2304 | r_dcache.read_dir(paddr, |
---|
| 2305 | &cache_state, |
---|
| 2306 | &cache_way, |
---|
| 2307 | &cache_set, |
---|
| 2308 | &cache_word); |
---|
[331] | 2309 | |
---|
[789] | 2310 | r_dcache.write(r_dcache_save_cache_way.read(), |
---|
| 2311 | r_dcache_save_cache_set.read(), |
---|
| 2312 | r_dcache_save_cache_word.read(), |
---|
| 2313 | r_dcache_save_wdata.read(), |
---|
| 2314 | r_dcache_save_be.read()); |
---|
[331] | 2315 | #ifdef INSTRUMENTATION |
---|
[789] | 2316 | m_cpt_dcache_dir_read++; |
---|
| 2317 | m_cpt_dcache_data_write++; |
---|
[331] | 2318 | #endif |
---|
| 2319 | } |
---|
[789] | 2320 | else if (m_dreq.valid and not r_dcache_updt_req.read()) // read DIR and DATA |
---|
[331] | 2321 | { |
---|
[789] | 2322 | r_dcache.read(paddr, |
---|
| 2323 | &cache_rdata, |
---|
| 2324 | &cache_way, |
---|
| 2325 | &cache_set, |
---|
| 2326 | &cache_word, |
---|
| 2327 | &cache_state); |
---|
[366] | 2328 | |
---|
[331] | 2329 | #ifdef INSTRUMENTATION |
---|
[789] | 2330 | m_cpt_dcache_dir_read++; |
---|
| 2331 | m_cpt_dcache_data_read++; |
---|
[331] | 2332 | #endif |
---|
| 2333 | } |
---|
[789] | 2334 | else if (not m_dreq.valid and r_dcache_updt_req.read()) // write DATA |
---|
[331] | 2335 | { |
---|
[789] | 2336 | r_dcache.write(r_dcache_save_cache_way.read(), |
---|
| 2337 | r_dcache_save_cache_set.read(), |
---|
| 2338 | r_dcache_save_cache_word.read(), |
---|
| 2339 | r_dcache_save_wdata.read(), |
---|
| 2340 | r_dcache_save_be.read()); |
---|
[331] | 2341 | #ifdef INSTRUMENTATION |
---|
[789] | 2342 | m_cpt_dcache_data_write++; |
---|
[331] | 2343 | #endif |
---|
| 2344 | } |
---|
| 2345 | } // end dcache access |
---|
| 2346 | |
---|
| 2347 | // DCACHE update in P1 stage can require ITLB / DTLB inval or flush |
---|
[789] | 2348 | if (r_dcache_updt_req.read()) |
---|
[331] | 2349 | { |
---|
| 2350 | size_t way = r_dcache_save_cache_way.read(); |
---|
| 2351 | size_t set = r_dcache_save_cache_set.read(); |
---|
| 2352 | |
---|
[789] | 2353 | if (r_dcache_in_tlb[way * m_dcache_sets + set]) |
---|
[331] | 2354 | { |
---|
[789] | 2355 | tlb_inval_required = true; |
---|
| 2356 | r_dcache_tlb_inval_set = 0; |
---|
| 2357 | r_dcache_tlb_inval_line = r_dcache_save_paddr.read() >> |
---|
| 2358 | (uint32_log2(m_dcache_words << 2)); |
---|
| 2359 | r_dcache_in_tlb[way * m_dcache_sets + set] = false; |
---|
[331] | 2360 | } |
---|
[789] | 2361 | else if (r_dcache_contains_ptd[way * m_dcache_sets + set]) |
---|
[331] | 2362 | { |
---|
| 2363 | r_itlb.reset(); |
---|
| 2364 | r_dtlb.reset(); |
---|
[789] | 2365 | r_dcache_contains_ptd[way * m_dcache_sets + set] = false; |
---|
[331] | 2366 | } |
---|
| 2367 | |
---|
| 2368 | #if DEBUG_DCACHE |
---|
[789] | 2369 | if (m_debug_dcache_fsm) |
---|
| 2370 | std::cout << " <PROC " << name() << " DCACHE_IDLE>" |
---|
| 2371 | << " Cache update in P1 stage" << std::dec |
---|
| 2372 | << " / WAY = " << r_dcache_save_cache_way.read() |
---|
| 2373 | << " / SET = " << r_dcache_save_cache_set.read() |
---|
| 2374 | << " / WORD = " << r_dcache_save_cache_word.read() << std::hex |
---|
| 2375 | << " / WDATA = " << r_dcache_save_wdata.read() |
---|
| 2376 | << " / BE = " << r_dcache_save_be.read() << std::endl; |
---|
[331] | 2377 | #endif |
---|
| 2378 | } // end test TLB inval |
---|
| 2379 | |
---|
| 2380 | // Try WBUF update in P1 stage |
---|
| 2381 | // Miss if the write request is non cacheable, and there is a pending |
---|
| 2382 | // non cacheable write, or if the write buffer is full. |
---|
[789] | 2383 | if (r_dcache_wbuf_req.read()) |
---|
[331] | 2384 | { |
---|
[789] | 2385 | bool wok = r_wbuf.write(r_dcache_save_paddr.read(), |
---|
| 2386 | r_dcache_save_be.read(), |
---|
| 2387 | r_dcache_save_wdata.read(), |
---|
| 2388 | true); |
---|
[331] | 2389 | #ifdef INSTRUMENTATION |
---|
[789] | 2390 | m_cpt_wbuf_write++; |
---|
[331] | 2391 | #endif |
---|
[789] | 2392 | if (not wok ) // miss if write buffer full |
---|
[616] | 2393 | { |
---|
| 2394 | wbuf_write_miss = true; |
---|
[331] | 2395 | } |
---|
| 2396 | } // end WBUF update |
---|
| 2397 | |
---|
| 2398 | // Computing the response to processor, |
---|
| 2399 | // and the next value for r_dcache_fsm |
---|
| 2400 | |
---|
| 2401 | // itlb/dtlb invalidation self-request |
---|
[789] | 2402 | if (tlb_inval_required) |
---|
[331] | 2403 | { |
---|
| 2404 | r_dcache_fsm_scan_save = r_dcache_fsm.read(); |
---|
| 2405 | r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; |
---|
| 2406 | } |
---|
| 2407 | |
---|
[468] | 2408 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 2409 | else if (r_dcache_clack_req.read()) |
---|
[468] | 2410 | { |
---|
| 2411 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 2412 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 2413 | } |
---|
[331] | 2414 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 2415 | else if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 2416 | { |
---|
| 2417 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 2418 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 2419 | } |
---|
| 2420 | |
---|
| 2421 | // processor request (READ, WRITE, LL, SC, XTN_READ, XTN_WRITE) |
---|
| 2422 | // we don't take the processor request, and registers |
---|
| 2423 | // are frozen in case of wbuf_write_miss |
---|
[789] | 2424 | else if (m_dreq.valid and not wbuf_write_miss) |
---|
[331] | 2425 | { |
---|
| 2426 | // register processor request and DCACHE response |
---|
| 2427 | r_dcache_save_vaddr = m_dreq.addr; |
---|
| 2428 | r_dcache_save_be = m_dreq.be; |
---|
| 2429 | r_dcache_save_wdata = m_dreq.wdata; |
---|
| 2430 | r_dcache_save_paddr = paddr; |
---|
| 2431 | r_dcache_save_cache_way = cache_way; |
---|
| 2432 | r_dcache_save_cache_set = cache_set; |
---|
| 2433 | r_dcache_save_cache_word = cache_word; |
---|
| 2434 | |
---|
| 2435 | // READ XTN requests from processor |
---|
| 2436 | // They are executed in this DCACHE_IDLE state. |
---|
| 2437 | // The processor must not be in user mode |
---|
| 2438 | if (m_dreq.type == iss_t::XTN_READ) |
---|
| 2439 | { |
---|
[789] | 2440 | int xtn_opcode = (int)m_dreq.addr / 4; |
---|
[331] | 2441 | |
---|
| 2442 | // checking processor mode: |
---|
| 2443 | if (m_dreq.mode == iss_t::MODE_USER) |
---|
| 2444 | { |
---|
| 2445 | r_mmu_detr = MMU_READ_PRIVILEGE_VIOLATION; |
---|
| 2446 | r_mmu_dbvar = m_dreq.addr; |
---|
| 2447 | m_drsp.valid = true; |
---|
| 2448 | m_drsp.error = true; |
---|
| 2449 | m_drsp.rdata = 0; |
---|
| 2450 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 2451 | } |
---|
| 2452 | else |
---|
| 2453 | { |
---|
[789] | 2454 | switch (xtn_opcode) |
---|
[331] | 2455 | { |
---|
| 2456 | case iss_t::XTN_INS_ERROR_TYPE: |
---|
| 2457 | m_drsp.rdata = r_mmu_ietr.read(); |
---|
| 2458 | m_drsp.valid = true; |
---|
| 2459 | m_drsp.error = false; |
---|
| 2460 | break; |
---|
| 2461 | |
---|
| 2462 | case iss_t::XTN_DATA_ERROR_TYPE: |
---|
| 2463 | m_drsp.rdata = r_mmu_detr.read(); |
---|
| 2464 | m_drsp.valid = true; |
---|
| 2465 | m_drsp.error = false; |
---|
| 2466 | break; |
---|
| 2467 | |
---|
| 2468 | case iss_t::XTN_INS_BAD_VADDR: |
---|
| 2469 | m_drsp.rdata = r_mmu_ibvar.read(); |
---|
| 2470 | m_drsp.valid = true; |
---|
| 2471 | m_drsp.error = false; |
---|
| 2472 | break; |
---|
| 2473 | |
---|
| 2474 | case iss_t::XTN_DATA_BAD_VADDR: |
---|
| 2475 | m_drsp.rdata = r_mmu_dbvar.read(); |
---|
| 2476 | m_drsp.valid = true; |
---|
| 2477 | m_drsp.error = false; |
---|
| 2478 | break; |
---|
| 2479 | |
---|
| 2480 | case iss_t::XTN_PTPR: |
---|
| 2481 | m_drsp.rdata = r_mmu_ptpr.read(); |
---|
| 2482 | m_drsp.valid = true; |
---|
| 2483 | m_drsp.error = false; |
---|
| 2484 | break; |
---|
| 2485 | |
---|
| 2486 | case iss_t::XTN_TLB_MODE: |
---|
| 2487 | m_drsp.rdata = r_mmu_mode.read(); |
---|
| 2488 | m_drsp.valid = true; |
---|
| 2489 | m_drsp.error = false; |
---|
| 2490 | break; |
---|
| 2491 | |
---|
| 2492 | case iss_t::XTN_MMU_PARAMS: |
---|
| 2493 | m_drsp.rdata = r_mmu_params; |
---|
| 2494 | m_drsp.valid = true; |
---|
| 2495 | m_drsp.error = false; |
---|
| 2496 | break; |
---|
| 2497 | |
---|
| 2498 | case iss_t::XTN_MMU_RELEASE: |
---|
| 2499 | m_drsp.rdata = r_mmu_release; |
---|
| 2500 | m_drsp.valid = true; |
---|
| 2501 | m_drsp.error = false; |
---|
| 2502 | break; |
---|
| 2503 | |
---|
| 2504 | case iss_t::XTN_MMU_WORD_LO: |
---|
| 2505 | m_drsp.rdata = r_mmu_word_lo.read(); |
---|
| 2506 | m_drsp.valid = true; |
---|
| 2507 | m_drsp.error = false; |
---|
| 2508 | break; |
---|
| 2509 | |
---|
| 2510 | case iss_t::XTN_MMU_WORD_HI: |
---|
| 2511 | m_drsp.rdata = r_mmu_word_hi.read(); |
---|
| 2512 | m_drsp.valid = true; |
---|
| 2513 | m_drsp.error = false; |
---|
| 2514 | break; |
---|
| 2515 | |
---|
[394] | 2516 | case iss_t::XTN_DATA_PADDR_EXT: |
---|
| 2517 | m_drsp.rdata = r_dcache_paddr_ext.read(); |
---|
| 2518 | m_drsp.valid = true; |
---|
| 2519 | m_drsp.error = false; |
---|
| 2520 | break; |
---|
| 2521 | |
---|
[721] | 2522 | case iss_t::XTN_INST_PADDR_EXT: |
---|
| 2523 | m_drsp.rdata = r_icache_paddr_ext.read(); |
---|
| 2524 | m_drsp.valid = true; |
---|
| 2525 | m_drsp.error = false; |
---|
| 2526 | break; |
---|
| 2527 | |
---|
[331] | 2528 | default: |
---|
[789] | 2529 | r_mmu_detr = MMU_READ_UNDEFINED_XTN; |
---|
[331] | 2530 | r_mmu_dbvar = m_dreq.addr; |
---|
| 2531 | m_drsp.valid = true; |
---|
| 2532 | m_drsp.error = true; |
---|
| 2533 | m_drsp.rdata = 0; |
---|
| 2534 | break; |
---|
| 2535 | } // end switch xtn_opcode |
---|
| 2536 | } // end else |
---|
| 2537 | } // end if XTN_READ |
---|
| 2538 | |
---|
| 2539 | // Handling WRITE XTN requests from processor. |
---|
| 2540 | // They are not executed in this DCACHE_IDLE state |
---|
| 2541 | // if they require access to the caches or the TLBs |
---|
| 2542 | // that are already accessed. |
---|
| 2543 | // Caches can be invalidated or flushed in user mode, |
---|
| 2544 | // and the sync instruction can be executed in user mode |
---|
| 2545 | else if (m_dreq.type == iss_t::XTN_WRITE) |
---|
| 2546 | { |
---|
[789] | 2547 | int xtn_opcode = (int)m_dreq.addr / 4; |
---|
[331] | 2548 | r_dcache_xtn_opcode = xtn_opcode; |
---|
| 2549 | |
---|
| 2550 | // checking processor mode: |
---|
[789] | 2551 | if ((m_dreq.mode == iss_t::MODE_USER) && |
---|
[366] | 2552 | (xtn_opcode != iss_t::XTN_SYNC) && |
---|
[331] | 2553 | (xtn_opcode != iss_t::XTN_DCACHE_INVAL) && |
---|
| 2554 | (xtn_opcode != iss_t::XTN_DCACHE_FLUSH) && |
---|
| 2555 | (xtn_opcode != iss_t::XTN_ICACHE_INVAL) && |
---|
[789] | 2556 | (xtn_opcode != iss_t::XTN_ICACHE_FLUSH)) |
---|
[331] | 2557 | { |
---|
| 2558 | r_mmu_detr = MMU_WRITE_PRIVILEGE_VIOLATION; |
---|
| 2559 | r_mmu_dbvar = m_dreq.addr; |
---|
| 2560 | m_drsp.valid = true; |
---|
| 2561 | m_drsp.error = true; |
---|
| 2562 | m_drsp.rdata = 0; |
---|
| 2563 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 2564 | } |
---|
| 2565 | else |
---|
| 2566 | { |
---|
[789] | 2567 | switch (xtn_opcode) |
---|
[331] | 2568 | { |
---|
[789] | 2569 | case iss_t::XTN_PTPR: // itlb & dtlb must be flushed |
---|
[331] | 2570 | r_dcache_xtn_req = true; |
---|
| 2571 | r_dcache_fsm = DCACHE_XTN_SWITCH; |
---|
| 2572 | break; |
---|
| 2573 | |
---|
[789] | 2574 | case iss_t::XTN_TLB_MODE: // no cache or tlb access |
---|
| 2575 | r_mmu_mode = m_dreq.wdata; |
---|
| 2576 | m_drsp.valid = true; |
---|
| 2577 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 2578 | break; |
---|
| 2579 | |
---|
[789] | 2580 | case iss_t::XTN_DTLB_INVAL: // dtlb access |
---|
| 2581 | r_dcache_fsm = DCACHE_XTN_DT_INVAL; |
---|
[331] | 2582 | break; |
---|
| 2583 | |
---|
[789] | 2584 | case iss_t::XTN_ITLB_INVAL: // itlb access |
---|
[331] | 2585 | r_dcache_xtn_req = true; |
---|
| 2586 | r_dcache_fsm = DCACHE_XTN_IT_INVAL; |
---|
| 2587 | break; |
---|
| 2588 | |
---|
[789] | 2589 | case iss_t::XTN_DCACHE_INVAL: // dcache, dtlb & itlb access |
---|
| 2590 | r_dcache_fsm = DCACHE_XTN_DC_INVAL_VA; |
---|
[331] | 2591 | break; |
---|
| 2592 | |
---|
[789] | 2593 | case iss_t::XTN_MMU_DCACHE_PA_INV: // dcache, dtlb & itlb access |
---|
| 2594 | r_dcache_fsm = DCACHE_XTN_DC_INVAL_PA; |
---|
[331] | 2595 | if (sizeof(paddr_t) <= 32) |
---|
| 2596 | { |
---|
| 2597 | assert(r_mmu_word_hi.read() == 0 && |
---|
| 2598 | "high bits should be 0 for 32bit paddr"); |
---|
| 2599 | r_dcache_save_paddr = (paddr_t)r_mmu_word_lo.read(); |
---|
| 2600 | } |
---|
| 2601 | else |
---|
| 2602 | { |
---|
| 2603 | r_dcache_save_paddr = (paddr_t)r_mmu_word_hi.read() << 32 | |
---|
| 2604 | (paddr_t)r_mmu_word_lo.read(); |
---|
| 2605 | } |
---|
| 2606 | break; |
---|
| 2607 | |
---|
[789] | 2608 | case iss_t::XTN_DCACHE_FLUSH: // itlb and dtlb must be reset |
---|
[331] | 2609 | r_dcache_flush_count = 0; |
---|
[789] | 2610 | r_dcache_fsm = DCACHE_XTN_DC_FLUSH; |
---|
[331] | 2611 | break; |
---|
| 2612 | |
---|
[789] | 2613 | case iss_t::XTN_ICACHE_INVAL: // icache and itlb access |
---|
[331] | 2614 | r_dcache_xtn_req = true; |
---|
| 2615 | r_dcache_fsm = DCACHE_XTN_IC_INVAL_VA; |
---|
| 2616 | break; |
---|
| 2617 | |
---|
[789] | 2618 | case iss_t::XTN_MMU_ICACHE_PA_INV: // icache access |
---|
[331] | 2619 | r_dcache_xtn_req = true; |
---|
| 2620 | r_dcache_fsm = DCACHE_XTN_IC_INVAL_PA; |
---|
| 2621 | break; |
---|
| 2622 | |
---|
[789] | 2623 | case iss_t::XTN_ICACHE_FLUSH: // icache access |
---|
[331] | 2624 | r_dcache_xtn_req = true; |
---|
| 2625 | r_dcache_fsm = DCACHE_XTN_IC_FLUSH; |
---|
| 2626 | break; |
---|
| 2627 | |
---|
[789] | 2628 | case iss_t::XTN_SYNC: // wait until write buffer empty |
---|
| 2629 | r_dcache_fsm = DCACHE_XTN_SYNC; |
---|
[331] | 2630 | break; |
---|
| 2631 | |
---|
[789] | 2632 | case iss_t::XTN_MMU_WORD_LO: // no cache or tlb access |
---|
| 2633 | r_mmu_word_lo = m_dreq.wdata; |
---|
| 2634 | m_drsp.valid = true; |
---|
| 2635 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 2636 | break; |
---|
| 2637 | |
---|
[789] | 2638 | case iss_t::XTN_MMU_WORD_HI: // no cache or tlb access |
---|
| 2639 | r_mmu_word_hi = m_dreq.wdata; |
---|
| 2640 | m_drsp.valid = true; |
---|
| 2641 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 2642 | break; |
---|
| 2643 | |
---|
[789] | 2644 | case iss_t::XTN_MMU_LL_RESET: // no cache or tlb access |
---|
[331] | 2645 | r_dcache_llsc_valid = false; |
---|
[789] | 2646 | m_drsp.valid = true; |
---|
| 2647 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 2648 | break; |
---|
| 2649 | |
---|
[789] | 2650 | case iss_t::XTN_DATA_PADDR_EXT: // no cache or tlb access |
---|
[394] | 2651 | r_dcache_paddr_ext = m_dreq.wdata; |
---|
| 2652 | m_drsp.valid = true; |
---|
| 2653 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 2654 | break; |
---|
| 2655 | |
---|
[789] | 2656 | case iss_t::XTN_INST_PADDR_EXT: // no cache or tlb access |
---|
[721] | 2657 | r_dcache_xtn_req = true; |
---|
| 2658 | r_dcache_fsm = DCACHE_XTN_IC_PADDR_EXT; |
---|
| 2659 | break; |
---|
| 2660 | |
---|
[789] | 2661 | case iss_t::XTN_ICACHE_PREFETCH: // not implemented : no action |
---|
| 2662 | case iss_t::XTN_DCACHE_PREFETCH: // not implemented : no action |
---|
| 2663 | m_drsp.valid = true; |
---|
| 2664 | r_dcache_fsm = DCACHE_IDLE; |
---|
[721] | 2665 | break; |
---|
[331] | 2666 | |
---|
[668] | 2667 | case iss_t::XTN_DEBUG_MASK: // debug mask |
---|
| 2668 | m_debug_dcache_fsm = ((m_dreq.wdata & 0x1) != 0); |
---|
| 2669 | m_debug_icache_fsm = ((m_dreq.wdata & 0x2) != 0); |
---|
| 2670 | m_debug_cmd_fsm = ((m_dreq.wdata & 0x4) != 0); |
---|
| 2671 | m_drsp.valid = true; |
---|
| 2672 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 2673 | break; |
---|
| 2674 | |
---|
[331] | 2675 | default: |
---|
| 2676 | r_mmu_detr = MMU_WRITE_UNDEFINED_XTN; |
---|
| 2677 | r_mmu_dbvar = m_dreq.addr; |
---|
| 2678 | m_drsp.valid = true; |
---|
| 2679 | m_drsp.error = true; |
---|
| 2680 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 2681 | break; |
---|
| 2682 | } // end switch xtn_opcode |
---|
| 2683 | } // end else |
---|
| 2684 | } // end if XTN_WRITE |
---|
| 2685 | |
---|
| 2686 | // Handling processor requests to address space (READ/WRITE/LL/SC) |
---|
| 2687 | // The dtlb and dcache can be activated or not. |
---|
| 2688 | // We compute the cacheability, and check processor request validity: |
---|
| 2689 | // - If DTLB not activated : cacheability is defined by the segment table, |
---|
| 2690 | // and there is no access rights checking. |
---|
| 2691 | // - If DTLB activated : cacheability is defined by the C bit in the PTE, |
---|
| 2692 | // and the U & W bits of the PTE are checked, as well as the DTLB hit. |
---|
| 2693 | // Jumps to the TLB_MISS sub-fsm in case of dtlb miss. |
---|
| 2694 | else |
---|
| 2695 | { |
---|
[789] | 2696 | bool valid_req; |
---|
| 2697 | bool cacheable; |
---|
[331] | 2698 | |
---|
[789] | 2699 | if (not (r_mmu_mode.read() & DATA_TLB_MASK)) // dtlb not activated |
---|
[331] | 2700 | { |
---|
[789] | 2701 | valid_req = true; |
---|
[331] | 2702 | |
---|
[789] | 2703 | if (not (r_mmu_mode.read() & DATA_CACHE_MASK)) cacheable = false; |
---|
[549] | 2704 | else cacheable = m_cacheability_table[(uint64_t)m_dreq.addr]; |
---|
[331] | 2705 | } |
---|
[789] | 2706 | else // dtlb activated |
---|
[331] | 2707 | { |
---|
[789] | 2708 | if (tlb_hit) // tlb hit |
---|
[331] | 2709 | { |
---|
| 2710 | // cacheability |
---|
[789] | 2711 | if (not (r_mmu_mode.read() & DATA_CACHE_MASK)) cacheable = false; |
---|
[331] | 2712 | else cacheable = tlb_flags.c; |
---|
| 2713 | |
---|
| 2714 | // access rights checking |
---|
[789] | 2715 | if (not tlb_flags.u and (m_dreq.mode == iss_t::MODE_USER)) |
---|
[331] | 2716 | { |
---|
[789] | 2717 | if ((m_dreq.type == iss_t::DATA_READ) or |
---|
| 2718 | (m_dreq.type == iss_t::DATA_LL)) |
---|
[331] | 2719 | { |
---|
| 2720 | r_mmu_detr = MMU_READ_PRIVILEGE_VIOLATION; |
---|
| 2721 | } |
---|
| 2722 | else |
---|
| 2723 | { |
---|
| 2724 | r_mmu_detr = MMU_WRITE_PRIVILEGE_VIOLATION; |
---|
| 2725 | } |
---|
| 2726 | valid_req = false; |
---|
| 2727 | r_mmu_dbvar = m_dreq.addr; |
---|
| 2728 | m_drsp.valid = true; |
---|
| 2729 | m_drsp.error = true; |
---|
| 2730 | m_drsp.rdata = 0; |
---|
| 2731 | #if DEBUG_DCACHE |
---|
[789] | 2732 | if (m_debug_dcache_fsm) |
---|
| 2733 | std::cout << " <PROC " << name() << " DCACHE_IDLE>" |
---|
| 2734 | << " HIT in dtlb, but privilege violation" << std::endl; |
---|
[331] | 2735 | #endif |
---|
| 2736 | } |
---|
[789] | 2737 | else if (not tlb_flags.w and |
---|
[331] | 2738 | ((m_dreq.type == iss_t::DATA_WRITE) or |
---|
[789] | 2739 | (m_dreq.type == iss_t::DATA_SC))) |
---|
[331] | 2740 | { |
---|
| 2741 | r_mmu_detr = MMU_WRITE_ACCES_VIOLATION; |
---|
| 2742 | valid_req = false; |
---|
| 2743 | r_mmu_dbvar = m_dreq.addr; |
---|
| 2744 | m_drsp.valid = true; |
---|
| 2745 | m_drsp.error = true; |
---|
| 2746 | m_drsp.rdata = 0; |
---|
| 2747 | #if DEBUG_DCACHE |
---|
[789] | 2748 | if (m_debug_dcache_fsm) |
---|
| 2749 | std::cout << " <PROC " << name() << " DCACHE_IDLE>" |
---|
| 2750 | << " HIT in dtlb, but writable violation" << std::endl; |
---|
[331] | 2751 | #endif |
---|
| 2752 | } |
---|
| 2753 | else |
---|
| 2754 | { |
---|
[789] | 2755 | valid_req = true; |
---|
[331] | 2756 | } |
---|
| 2757 | } |
---|
[789] | 2758 | else // tlb miss |
---|
[331] | 2759 | { |
---|
[789] | 2760 | valid_req = false; |
---|
| 2761 | r_dcache_tlb_vaddr = m_dreq.addr; |
---|
| 2762 | r_dcache_tlb_ins = false; |
---|
| 2763 | r_dcache_fsm = DCACHE_TLB_MISS; |
---|
[331] | 2764 | } |
---|
| 2765 | } // end DTLB activated |
---|
| 2766 | |
---|
[789] | 2767 | if (valid_req) // processor request is valid (after MMU check) |
---|
[331] | 2768 | { |
---|
| 2769 | // READ request |
---|
| 2770 | // The read requests are taken only if there is no cache update. |
---|
| 2771 | // We request a VCI transaction to CMD FSM if miss or uncachable |
---|
[366] | 2772 | |
---|
[789] | 2773 | if (((m_dreq.type == iss_t::DATA_READ)) |
---|
| 2774 | and not r_dcache_updt_req.read()) |
---|
[331] | 2775 | { |
---|
[789] | 2776 | if (cacheable) // cacheable read |
---|
[331] | 2777 | { |
---|
[789] | 2778 | if (cache_state == CACHE_SLOT_STATE_EMPTY) // cache miss |
---|
[331] | 2779 | { |
---|
| 2780 | #ifdef INSTRUMENTATION |
---|
[789] | 2781 | m_cpt_dcache_miss++; |
---|
[331] | 2782 | #endif |
---|
| 2783 | // request a VCI DMISS transaction |
---|
| 2784 | r_dcache_vci_paddr = paddr; |
---|
| 2785 | r_dcache_vci_miss_req = true; |
---|
| 2786 | r_dcache_miss_type = PROC_MISS; |
---|
| 2787 | r_dcache_fsm = DCACHE_MISS_SELECT; |
---|
| 2788 | #if DEBUG_DCACHE |
---|
[789] | 2789 | if (m_debug_dcache_fsm) |
---|
| 2790 | std::cout << " <PROC " << name() << " DCACHE_IDLE>" |
---|
| 2791 | << " READ MISS in dcache" |
---|
| 2792 | << " / PADDR = " << std::hex << paddr << std::endl; |
---|
[331] | 2793 | #endif |
---|
| 2794 | } |
---|
[789] | 2795 | else if (cache_state == CACHE_SLOT_STATE_ZOMBI) // pending cleanup |
---|
[331] | 2796 | { |
---|
| 2797 | // stalled until cleanup is acknowledged |
---|
| 2798 | r_dcache_fsm = DCACHE_IDLE; |
---|
[394] | 2799 | #if DEBUG_DCACHE |
---|
[789] | 2800 | if (m_debug_dcache_fsm) |
---|
| 2801 | std::cout << " <PROC " << name() << " DCACHE_IDLE>" |
---|
| 2802 | << " Pending cleanup, stalled until cleanup acknowledge" |
---|
| 2803 | << " / PADDR = " << std::hex << paddr << std::endl; |
---|
[394] | 2804 | #endif |
---|
[331] | 2805 | } |
---|
| 2806 | else // cache hit |
---|
| 2807 | { |
---|
| 2808 | #ifdef INSTRUMENTATION |
---|
[789] | 2809 | m_cpt_data_read++; |
---|
[331] | 2810 | #endif |
---|
| 2811 | // returns data to processor |
---|
[789] | 2812 | m_drsp.valid = true; |
---|
| 2813 | m_drsp.error = false; |
---|
| 2814 | m_drsp.rdata = cache_rdata; |
---|
[331] | 2815 | #if DEBUG_DCACHE |
---|
[789] | 2816 | if (m_debug_dcache_fsm) |
---|
| 2817 | std::cout << " <PROC " << name() << " DCACHE_IDLE>" |
---|
| 2818 | << " READ HIT in dcache" |
---|
| 2819 | << " : PADDR = " << std::hex << paddr |
---|
| 2820 | << " / DATA = " << std::hex << cache_rdata << std::endl; |
---|
[331] | 2821 | #endif |
---|
| 2822 | } |
---|
| 2823 | } |
---|
[789] | 2824 | else // uncacheable read |
---|
[331] | 2825 | { |
---|
[789] | 2826 | r_dcache_vci_paddr = paddr; |
---|
| 2827 | r_dcache_vci_unc_be = m_dreq.be; |
---|
| 2828 | r_dcache_vci_unc_write = false; |
---|
| 2829 | r_dcache_vci_unc_req = true; |
---|
| 2830 | r_dcache_fsm = DCACHE_UNC_WAIT; |
---|
[331] | 2831 | #if DEBUG_DCACHE |
---|
[789] | 2832 | if (m_debug_dcache_fsm) |
---|
| 2833 | std::cout << " <PROC " << name() << " DCACHE_IDLE>" |
---|
| 2834 | << " READ UNCACHEABLE in dcache" |
---|
| 2835 | << " / PADDR = " << std::hex << paddr << std::endl; |
---|
[331] | 2836 | #endif |
---|
| 2837 | } |
---|
| 2838 | } // end READ |
---|
| 2839 | |
---|
| 2840 | // LL request (non cachable) |
---|
| 2841 | // We request a VCI LL transaction to CMD FSM and register |
---|
| 2842 | // the LL/SC operation in llsc buffer. |
---|
| 2843 | else if (m_dreq.type == iss_t::DATA_LL) |
---|
| 2844 | { |
---|
| 2845 | // register paddr in LLSC buffer |
---|
| 2846 | r_dcache_llsc_paddr = paddr; |
---|
| 2847 | r_dcache_llsc_count = LLSC_TIMEOUT; |
---|
| 2848 | r_dcache_llsc_valid = true; |
---|
| 2849 | |
---|
| 2850 | // request an LL VCI transaction and go to DCACHE_LL_WAIT state |
---|
| 2851 | r_dcache_vci_ll_req = true; |
---|
| 2852 | r_dcache_vci_paddr = paddr; |
---|
| 2853 | r_dcache_ll_rsp_count = 0; |
---|
| 2854 | r_dcache_fsm = DCACHE_LL_WAIT; |
---|
| 2855 | |
---|
| 2856 | }// end LL |
---|
| 2857 | |
---|
| 2858 | // WRITE request: |
---|
| 2859 | // If the TLB is activated and the PTE Dirty bit is not set, we stall |
---|
| 2860 | // the processor and set the Dirty bit before handling the write request, |
---|
| 2861 | // going to the DCACHE_DIRTY_GT_PTE state. |
---|
| 2862 | // If we don't need to set the Dirty bit, we can acknowledge |
---|
| 2863 | // the processor request, as the write arguments (including the |
---|
| 2864 | // physical address) are registered in r_dcache_save registers, |
---|
| 2865 | // and the write will be done in the P1 pipeline stage. |
---|
[789] | 2866 | else if (m_dreq.type == iss_t::DATA_WRITE) |
---|
[331] | 2867 | { |
---|
[789] | 2868 | if ((r_mmu_mode.read() & DATA_TLB_MASK) |
---|
| 2869 | and not tlb_flags.d) // Dirty bit must be set |
---|
[331] | 2870 | { |
---|
| 2871 | // The PTE physical address is obtained from the nline value (dtlb), |
---|
| 2872 | // and from the virtual address (word index) |
---|
[789] | 2873 | if (tlb_flags.b ) // PTE1 |
---|
[331] | 2874 | { |
---|
[789] | 2875 | r_dcache_dirty_paddr = (paddr_t)(tlb_nline * (m_dcache_words << 2)) | |
---|
| 2876 | (paddr_t)((m_dreq.addr >> 19) & 0x3c); |
---|
[331] | 2877 | } |
---|
[789] | 2878 | else // PTE2 |
---|
[331] | 2879 | { |
---|
[789] | 2880 | r_dcache_dirty_paddr = (paddr_t) (tlb_nline * (m_dcache_words << 2)) | |
---|
| 2881 | (paddr_t) ((m_dreq.addr >> 9) & 0x38); |
---|
[331] | 2882 | } |
---|
[789] | 2883 | r_dcache_fsm = DCACHE_DIRTY_GET_PTE; |
---|
[331] | 2884 | } |
---|
[789] | 2885 | else // Write request accepted |
---|
[331] | 2886 | { |
---|
| 2887 | #ifdef INSTRUMENTATION |
---|
[789] | 2888 | m_cpt_data_write++; |
---|
[331] | 2889 | #endif |
---|
| 2890 | // cleaning llsc buffer if address matching |
---|
[789] | 2891 | if (paddr == r_dcache_llsc_paddr.read()) |
---|
[331] | 2892 | r_dcache_llsc_valid = false; |
---|
| 2893 | |
---|
[616] | 2894 | if (not cacheable) |
---|
| 2895 | { |
---|
[789] | 2896 | r_dcache_vci_paddr = paddr; |
---|
| 2897 | r_dcache_vci_wdata = m_dreq.wdata; |
---|
| 2898 | r_dcache_vci_unc_write = true; |
---|
| 2899 | r_dcache_vci_unc_be = m_dreq.be; |
---|
| 2900 | r_dcache_vci_unc_req = true; |
---|
| 2901 | r_dcache_fsm = DCACHE_UNC_WAIT; |
---|
[616] | 2902 | } |
---|
| 2903 | else |
---|
| 2904 | { |
---|
| 2905 | // response to processor |
---|
[789] | 2906 | m_drsp.valid = true; |
---|
[616] | 2907 | // activating P1 stage |
---|
| 2908 | wbuf_request = true; |
---|
| 2909 | updt_request = (cache_state == CACHE_SLOT_STATE_VALID); |
---|
| 2910 | } |
---|
[331] | 2911 | } |
---|
| 2912 | } // end WRITE |
---|
| 2913 | |
---|
| 2914 | // SC request: |
---|
| 2915 | // If the TLB is activated and the PTE Dirty bit is not set, we stall |
---|
| 2916 | // the processor and set the Dirty bit before handling the write request, |
---|
| 2917 | // going to the DCACHE_DIRTY_GT_PTE state. |
---|
| 2918 | // If we don't need to set the Dirty bit, we test the llsc buffer: |
---|
| 2919 | // If failure, we send a negative response to processor. |
---|
| 2920 | // If success, we request a SC transaction to CMD FSM and go |
---|
| 2921 | // to DCACHE_SC_WAIT state. |
---|
| 2922 | // We don't check a possible write hit in dcache, as the cache update |
---|
| 2923 | // is done by the coherence transaction induced by the SC... |
---|
[789] | 2924 | else if (m_dreq.type == iss_t::DATA_SC) |
---|
[331] | 2925 | { |
---|
[789] | 2926 | if ((r_mmu_mode.read() & DATA_TLB_MASK) |
---|
| 2927 | and not tlb_flags.d) // Dirty bit must be set |
---|
[331] | 2928 | { |
---|
| 2929 | // The PTE physical address is obtained from the nline value (dtlb), |
---|
| 2930 | // and the word index (virtual address) |
---|
[789] | 2931 | if (tlb_flags.b) // PTE1 |
---|
[331] | 2932 | { |
---|
[789] | 2933 | r_dcache_dirty_paddr = (paddr_t) (tlb_nline * (m_dcache_words << 2)) | |
---|
| 2934 | (paddr_t) ((m_dreq.addr >> 19) & 0x3c); |
---|
[331] | 2935 | } |
---|
[789] | 2936 | else // PTE2 |
---|
[331] | 2937 | { |
---|
[789] | 2938 | r_dcache_dirty_paddr = (paddr_t) (tlb_nline * (m_dcache_words << 2)) | |
---|
| 2939 | (paddr_t) ((m_dreq.addr >> 9) & 0x38); |
---|
[331] | 2940 | } |
---|
[789] | 2941 | r_dcache_fsm = DCACHE_DIRTY_GET_PTE; |
---|
[331] | 2942 | m_drsp.valid = false; |
---|
| 2943 | m_drsp.error = false; |
---|
| 2944 | m_drsp.rdata = 0; |
---|
| 2945 | } |
---|
[789] | 2946 | else // SC request accepted |
---|
[331] | 2947 | { |
---|
| 2948 | #ifdef INSTRUMENTATION |
---|
[789] | 2949 | m_cpt_data_sc++; |
---|
[331] | 2950 | #endif |
---|
| 2951 | // checking local success |
---|
[789] | 2952 | if (r_dcache_llsc_valid.read() and |
---|
| 2953 | (r_dcache_llsc_paddr.read() == paddr)) // local success |
---|
[331] | 2954 | { |
---|
| 2955 | // request an SC CMD and go to DCACHE_SC_WAIT state |
---|
| 2956 | r_dcache_vci_paddr = paddr; |
---|
| 2957 | r_dcache_vci_sc_req = true; |
---|
| 2958 | r_dcache_vci_sc_data = m_dreq.wdata; |
---|
| 2959 | r_dcache_fsm = DCACHE_SC_WAIT; |
---|
| 2960 | } |
---|
[789] | 2961 | else // local fail |
---|
[331] | 2962 | { |
---|
[789] | 2963 | m_drsp.valid = true; |
---|
| 2964 | m_drsp.error = false; |
---|
| 2965 | m_drsp.rdata = 0x1; |
---|
[331] | 2966 | } |
---|
| 2967 | } |
---|
| 2968 | } // end SC |
---|
| 2969 | } // end valid_req |
---|
| 2970 | } // end if read/write/ll/sc request |
---|
| 2971 | } // end processor request |
---|
| 2972 | |
---|
| 2973 | // itlb miss request |
---|
[789] | 2974 | else if (r_icache_tlb_miss_req.read() and not wbuf_write_miss ) |
---|
[331] | 2975 | { |
---|
| 2976 | r_dcache_tlb_ins = true; |
---|
| 2977 | r_dcache_tlb_vaddr = r_icache_vaddr_save.read(); |
---|
| 2978 | r_dcache_fsm = DCACHE_TLB_MISS; |
---|
| 2979 | } |
---|
| 2980 | |
---|
| 2981 | // Computing requests for P1 stage : r_dcache_wbuf_req & r_dcache_updt_req |
---|
| 2982 | r_dcache_updt_req = updt_request; |
---|
| 2983 | r_dcache_wbuf_req = wbuf_request or |
---|
| 2984 | (r_dcache_wbuf_req.read() and wbuf_write_miss); |
---|
| 2985 | break; |
---|
| 2986 | } |
---|
| 2987 | ///////////////////// |
---|
| 2988 | case DCACHE_TLB_MISS: // This is the entry point for the sub-fsm handling all tlb miss. |
---|
| 2989 | // Input arguments are: |
---|
| 2990 | // - r_dcache_tlb_vaddr |
---|
| 2991 | // - r_dcache_tlb_ins (true when itlb miss) |
---|
| 2992 | // The sub-fsm access the dcache to find the missing TLB entry, |
---|
| 2993 | // and activates the cache miss procedure in case of miss. |
---|
| 2994 | // It bypass the first level page table access if possible. |
---|
| 2995 | // It uses atomic access to update the R/L access bits |
---|
| 2996 | // in the page table if required. |
---|
| 2997 | // It directly updates the itlb or dtlb, and writes into the |
---|
| 2998 | // r_mmu_ins_* or r_mmu_data* error reporting registers. |
---|
| 2999 | { |
---|
[789] | 3000 | uint32_t ptba = 0; |
---|
| 3001 | bool bypass; |
---|
| 3002 | paddr_t pte_paddr; |
---|
[331] | 3003 | |
---|
| 3004 | // evaluate bypass in order to skip first level page table access |
---|
[789] | 3005 | if (r_dcache_tlb_ins.read()) // itlb miss |
---|
[331] | 3006 | { |
---|
| 3007 | bypass = r_itlb.get_bypass(r_dcache_tlb_vaddr.read(), &ptba); |
---|
| 3008 | } |
---|
[789] | 3009 | else // dtlb miss |
---|
[331] | 3010 | { |
---|
| 3011 | bypass = r_dtlb.get_bypass(r_dcache_tlb_vaddr.read(), &ptba); |
---|
| 3012 | } |
---|
| 3013 | |
---|
[789] | 3014 | if (not bypass) // Try to read PTE1/PTD1 in dcache |
---|
[331] | 3015 | { |
---|
[789] | 3016 | pte_paddr = (((paddr_t) r_mmu_ptpr.read()) << (INDEX1_NBITS + 2)) | |
---|
| 3017 | ((((paddr_t) r_dcache_tlb_vaddr.read()) >> PAGE_M_NBITS) << 2); |
---|
[331] | 3018 | r_dcache_tlb_paddr = pte_paddr; |
---|
| 3019 | r_dcache_fsm = DCACHE_TLB_PTE1_GET; |
---|
| 3020 | } |
---|
[789] | 3021 | else // Try to read PTE2 in dcache |
---|
[331] | 3022 | { |
---|
[789] | 3023 | pte_paddr = (paddr_t) ptba << PAGE_K_NBITS | |
---|
| 3024 | (paddr_t) (r_dcache_tlb_vaddr.read() & PTD_ID2_MASK) >> (PAGE_K_NBITS - 3); |
---|
[331] | 3025 | r_dcache_tlb_paddr = pte_paddr; |
---|
| 3026 | r_dcache_fsm = DCACHE_TLB_PTE2_GET; |
---|
| 3027 | } |
---|
| 3028 | |
---|
| 3029 | #if DEBUG_DCACHE |
---|
[789] | 3030 | if (m_debug_dcache_fsm) |
---|
| 3031 | { |
---|
| 3032 | if (r_dcache_tlb_ins.read()) |
---|
| 3033 | std::cout << " <PROC " << name() << " DCACHE_TLB_MISS> ITLB miss"; |
---|
| 3034 | else |
---|
| 3035 | std::cout << " <PROC " << name() << " DCACHE_TLB_MISS> DTLB miss"; |
---|
| 3036 | std::cout << " / VADDR = " << std::hex << r_dcache_tlb_vaddr.read() |
---|
| 3037 | << " / ptpr = " << (((paddr_t)r_mmu_ptpr.read()) << (INDEX1_NBITS+2)) |
---|
| 3038 | << " / BYPASS = " << bypass |
---|
| 3039 | << " / PTE_ADR = " << pte_paddr << std::endl; |
---|
| 3040 | } |
---|
[331] | 3041 | #endif |
---|
| 3042 | |
---|
| 3043 | break; |
---|
| 3044 | } |
---|
| 3045 | ///////////////////////// |
---|
[789] | 3046 | case DCACHE_TLB_PTE1_GET: // try to read a PT1 entry in dcache |
---|
[331] | 3047 | { |
---|
[468] | 3048 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 3049 | if (r_dcache_clack_req.read()) |
---|
[468] | 3050 | { |
---|
| 3051 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3052 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3053 | break; |
---|
| 3054 | } |
---|
| 3055 | |
---|
[341] | 3056 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 3057 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[341] | 3058 | { |
---|
| 3059 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3060 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3061 | break; |
---|
| 3062 | } |
---|
| 3063 | |
---|
[789] | 3064 | uint32_t entry; |
---|
| 3065 | size_t way; |
---|
| 3066 | size_t set; |
---|
| 3067 | size_t word; |
---|
| 3068 | int cache_state; |
---|
| 3069 | r_dcache.read(r_dcache_tlb_paddr.read(), |
---|
| 3070 | &entry, |
---|
| 3071 | &way, |
---|
| 3072 | &set, |
---|
| 3073 | &word, |
---|
| 3074 | &cache_state); |
---|
[331] | 3075 | #ifdef INSTRUMENTATION |
---|
[789] | 3076 | m_cpt_dcache_data_read++; |
---|
| 3077 | m_cpt_dcache_dir_read++; |
---|
[331] | 3078 | #endif |
---|
[789] | 3079 | if (cache_state == CACHE_SLOT_STATE_VALID) // hit in dcache |
---|
[331] | 3080 | { |
---|
[789] | 3081 | if (not (entry & PTE_V_MASK)) // unmapped |
---|
[331] | 3082 | { |
---|
[789] | 3083 | if (r_dcache_tlb_ins.read()) |
---|
[331] | 3084 | { |
---|
| 3085 | r_mmu_ietr = MMU_READ_PT1_UNMAPPED; |
---|
| 3086 | r_mmu_ibvar = r_dcache_tlb_vaddr.read(); |
---|
| 3087 | r_icache_tlb_miss_req = false; |
---|
| 3088 | r_icache_tlb_rsp_error = true; |
---|
| 3089 | } |
---|
| 3090 | else |
---|
| 3091 | { |
---|
[789] | 3092 | r_mmu_detr = MMU_READ_PT1_UNMAPPED; |
---|
| 3093 | r_mmu_dbvar = r_dcache_tlb_vaddr.read(); |
---|
| 3094 | m_drsp.valid = true; |
---|
| 3095 | m_drsp.error = true; |
---|
[331] | 3096 | } |
---|
[789] | 3097 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 3098 | |
---|
| 3099 | #if DEBUG_DCACHE |
---|
[789] | 3100 | if (m_debug_dcache_fsm) |
---|
| 3101 | { |
---|
| 3102 | std::cout << " <PROC " << name() |
---|
| 3103 | << " DCACHE_TLB_PTE1_GET> HIT in dcache, but unmapped" |
---|
| 3104 | << std::hex << " / paddr = " << r_dcache_tlb_paddr.read() |
---|
| 3105 | << std::dec << " / way = " << way |
---|
| 3106 | << std::dec << " / set = " << set |
---|
| 3107 | << std::dec << " / word = " << word |
---|
| 3108 | << std::hex << " / PTE1 = " << entry << std::endl; |
---|
| 3109 | } |
---|
[331] | 3110 | #endif |
---|
| 3111 | |
---|
| 3112 | } |
---|
[789] | 3113 | else if (entry & PTE_T_MASK ) // PTD : me must access PT2 |
---|
[331] | 3114 | { |
---|
| 3115 | // mark the cache line ac containing a PTD |
---|
[789] | 3116 | r_dcache_contains_ptd[m_dcache_sets * way + set] = true; |
---|
[331] | 3117 | |
---|
| 3118 | // register bypass |
---|
[789] | 3119 | if (r_dcache_tlb_ins.read()) // itlb |
---|
[331] | 3120 | { |
---|
| 3121 | r_itlb.set_bypass(r_dcache_tlb_vaddr.read(), |
---|
| 3122 | entry & ((1 << (m_paddr_nbits-PAGE_K_NBITS)) - 1), |
---|
[789] | 3123 | r_dcache_tlb_paddr.read() / (m_icache_words << 2)); |
---|
[331] | 3124 | } |
---|
[789] | 3125 | else // dtlb |
---|
[331] | 3126 | { |
---|
| 3127 | r_dtlb.set_bypass(r_dcache_tlb_vaddr.read(), |
---|
| 3128 | entry & ((1 << (m_paddr_nbits-PAGE_K_NBITS)) - 1), |
---|
[789] | 3129 | r_dcache_tlb_paddr.read() / (m_dcache_words << 2)); |
---|
[331] | 3130 | } |
---|
| 3131 | r_dcache_tlb_paddr = |
---|
[789] | 3132 | (paddr_t)(entry & ((1 << (m_paddr_nbits - PAGE_K_NBITS)) - 1)) << PAGE_K_NBITS | |
---|
[331] | 3133 | (paddr_t)(((r_dcache_tlb_vaddr.read() & PTD_ID2_MASK) >> PAGE_K_NBITS) << 3); |
---|
[789] | 3134 | r_dcache_fsm = DCACHE_TLB_PTE2_GET; |
---|
[331] | 3135 | |
---|
| 3136 | #if DEBUG_DCACHE |
---|
[789] | 3137 | if (m_debug_dcache_fsm) |
---|
| 3138 | { |
---|
| 3139 | std::cout << " <PROC " << name() |
---|
| 3140 | << " DCACHE_TLB_PTE1_GET> HIT in dcache" |
---|
| 3141 | << std::hex << " / paddr = " << r_dcache_tlb_paddr.read() |
---|
| 3142 | << std::dec << " / way = " << way |
---|
| 3143 | << std::dec << " / set = " << set |
---|
| 3144 | << std::dec << " / word = " << word |
---|
| 3145 | << std::hex << " / PTD = " << entry << std::endl; |
---|
| 3146 | } |
---|
[331] | 3147 | #endif |
---|
| 3148 | } |
---|
[789] | 3149 | else // PTE1 : we must update the TLB |
---|
[331] | 3150 | { |
---|
[789] | 3151 | r_dcache_in_tlb[m_icache_sets * way + set] = true; |
---|
[331] | 3152 | r_dcache_tlb_pte_flags = entry; |
---|
| 3153 | r_dcache_tlb_cache_way = way; |
---|
| 3154 | r_dcache_tlb_cache_set = set; |
---|
| 3155 | r_dcache_tlb_cache_word = word; |
---|
| 3156 | r_dcache_fsm = DCACHE_TLB_PTE1_SELECT; |
---|
| 3157 | |
---|
| 3158 | #if DEBUG_DCACHE |
---|
[789] | 3159 | if (m_debug_dcache_fsm) |
---|
| 3160 | { |
---|
| 3161 | std::cout << " <PROC " << name() |
---|
| 3162 | << " DCACHE_TLB_PTE1_GET> HIT in dcache" |
---|
| 3163 | << std::hex << " / paddr = " << r_dcache_tlb_paddr.read() |
---|
| 3164 | << std::dec << " / way = " << way |
---|
| 3165 | << std::dec << " / set = " << set |
---|
| 3166 | << std::dec << " / word = " << word |
---|
| 3167 | << std::hex << " / PTE1 = " << entry << std::endl; |
---|
| 3168 | } |
---|
[331] | 3169 | #endif |
---|
| 3170 | } |
---|
| 3171 | } |
---|
[789] | 3172 | else if (cache_state == CACHE_SLOT_STATE_ZOMBI) // pending cleanup |
---|
[338] | 3173 | { |
---|
| 3174 | // stalled until cleanup is acknowledged |
---|
[789] | 3175 | r_dcache_fsm = DCACHE_TLB_PTE1_GET; |
---|
[338] | 3176 | } |
---|
[789] | 3177 | else // we must load the missing cache line in dcache |
---|
[331] | 3178 | { |
---|
[789] | 3179 | r_dcache_vci_miss_req = true; |
---|
| 3180 | r_dcache_vci_paddr = r_dcache_tlb_paddr.read(); |
---|
| 3181 | r_dcache_save_paddr = r_dcache_tlb_paddr.read(); |
---|
| 3182 | r_dcache_miss_type = PTE1_MISS; |
---|
| 3183 | r_dcache_fsm = DCACHE_MISS_SELECT; |
---|
[331] | 3184 | |
---|
| 3185 | #if DEBUG_DCACHE |
---|
[789] | 3186 | if (m_debug_dcache_fsm) |
---|
| 3187 | { |
---|
| 3188 | std::cout << " <PROC " << name() |
---|
| 3189 | << " DCACHE_TLB_PTE1_GET> MISS in dcache:" |
---|
| 3190 | << " PTE1 address = " << std::hex << r_dcache_tlb_paddr.read() << std::endl; |
---|
| 3191 | } |
---|
[331] | 3192 | #endif |
---|
| 3193 | } |
---|
| 3194 | break; |
---|
| 3195 | } |
---|
| 3196 | //////////////////////////// |
---|
[789] | 3197 | case DCACHE_TLB_PTE1_SELECT: // select a slot for PTE1 |
---|
[331] | 3198 | { |
---|
[789] | 3199 | size_t way; |
---|
| 3200 | size_t set; |
---|
[331] | 3201 | |
---|
[789] | 3202 | if (r_dcache_tlb_ins.read()) |
---|
[331] | 3203 | { |
---|
[789] | 3204 | r_itlb.select(r_dcache_tlb_vaddr.read(), |
---|
| 3205 | true, // PTE1 |
---|
| 3206 | &way, |
---|
| 3207 | &set); |
---|
[331] | 3208 | #ifdef INSTRUMENTATION |
---|
[789] | 3209 | m_cpt_itlb_read++; |
---|
[331] | 3210 | #endif |
---|
| 3211 | } |
---|
| 3212 | else |
---|
| 3213 | { |
---|
[789] | 3214 | r_dtlb.select(r_dcache_tlb_vaddr.read(), |
---|
| 3215 | true, // PTE1 |
---|
| 3216 | &way, |
---|
| 3217 | &set); |
---|
[331] | 3218 | #ifdef INSTRUMENTATION |
---|
[789] | 3219 | m_cpt_dtlb_read++; |
---|
[331] | 3220 | #endif |
---|
| 3221 | } |
---|
| 3222 | r_dcache_tlb_way = way; |
---|
| 3223 | r_dcache_tlb_set = set; |
---|
| 3224 | r_dcache_fsm = DCACHE_TLB_PTE1_UPDT; |
---|
| 3225 | |
---|
| 3226 | #if DEBUG_DCACHE |
---|
[789] | 3227 | if (m_debug_dcache_fsm) |
---|
| 3228 | { |
---|
| 3229 | if (r_dcache_tlb_ins.read()) |
---|
| 3230 | std::cout << " <PROC " << name() |
---|
| 3231 | << " DCACHE_TLB_PTE1_SELECT> Select a slot in ITLB:"; |
---|
| 3232 | else |
---|
| 3233 | std::cout << " <PROC " << name() |
---|
| 3234 | << ".DCACHE_TLB_PTE1_SELECT> Select a slot in DTLB:"; |
---|
| 3235 | std::cout << " way = " << std::dec << way |
---|
| 3236 | << " / set = " << set << std::endl; |
---|
| 3237 | } |
---|
[331] | 3238 | #endif |
---|
| 3239 | break; |
---|
| 3240 | } |
---|
| 3241 | ////////////////////////// |
---|
[789] | 3242 | case DCACHE_TLB_PTE1_UPDT: // write a new PTE1 in tlb after testing the L/R bit |
---|
[331] | 3243 | // - if L/R bit already set, exit the sub-fsm. |
---|
| 3244 | // - if not, we update the page table but we dont write |
---|
| 3245 | // neither in DCACHE, nor in TLB, as this will be done by |
---|
| 3246 | // the coherence mechanism. |
---|
| 3247 | { |
---|
[789] | 3248 | paddr_t nline = r_dcache_tlb_paddr.read() >> (uint32_log2(m_dcache_words) + 2); |
---|
| 3249 | uint32_t pte = r_dcache_tlb_pte_flags.read(); |
---|
| 3250 | bool pt_updt = false; |
---|
| 3251 | bool local = true; |
---|
[331] | 3252 | |
---|
| 3253 | // We should compute the access locality: |
---|
| 3254 | // The PPN MSB bits define the destination cluster index. |
---|
[346] | 3255 | // The m_srcid MSB bits define the source cluster index. |
---|
[331] | 3256 | // The number of bits to compare depends on the number of clusters, |
---|
| 3257 | // and can be obtained in the mapping table. |
---|
| 3258 | // As long as this computation is not done, all access are local. |
---|
| 3259 | |
---|
[789] | 3260 | if (local) // local access |
---|
[331] | 3261 | { |
---|
[789] | 3262 | if (not ((pte & PTE_L_MASK) == PTE_L_MASK)) // we must set the L bit |
---|
[331] | 3263 | { |
---|
| 3264 | pt_updt = true; |
---|
[789] | 3265 | r_dcache_vci_cas_old = pte; |
---|
| 3266 | r_dcache_vci_cas_new = pte | PTE_L_MASK; |
---|
[331] | 3267 | pte = pte | PTE_L_MASK; |
---|
| 3268 | r_dcache_tlb_pte_flags = pte; |
---|
| 3269 | } |
---|
| 3270 | } |
---|
[789] | 3271 | else // remote access |
---|
[331] | 3272 | { |
---|
[789] | 3273 | if (not ((pte & PTE_R_MASK) == PTE_R_MASK)) // we must set the R bit |
---|
[331] | 3274 | { |
---|
| 3275 | pt_updt = true; |
---|
[789] | 3276 | r_dcache_vci_cas_old = pte; |
---|
| 3277 | r_dcache_vci_cas_new = pte | PTE_R_MASK; |
---|
[331] | 3278 | pte = pte | PTE_R_MASK; |
---|
| 3279 | r_dcache_tlb_pte_flags = pte; |
---|
| 3280 | } |
---|
| 3281 | } |
---|
| 3282 | |
---|
[789] | 3283 | if (not pt_updt) // update TLB and return |
---|
[331] | 3284 | { |
---|
[789] | 3285 | if (r_dcache_tlb_ins.read()) |
---|
[331] | 3286 | { |
---|
[789] | 3287 | r_itlb.write(true, // 2M page |
---|
| 3288 | pte, |
---|
| 3289 | 0, // argument unused for a PTE1 |
---|
| 3290 | r_dcache_tlb_vaddr.read(), |
---|
| 3291 | r_dcache_tlb_way.read(), |
---|
| 3292 | r_dcache_tlb_set.read(), |
---|
| 3293 | nline); |
---|
[331] | 3294 | #ifdef INSTRUMENTATION |
---|
[789] | 3295 | m_cpt_itlb_write++; |
---|
[331] | 3296 | #endif |
---|
| 3297 | |
---|
| 3298 | #if DEBUG_DCACHE |
---|
[789] | 3299 | if (m_debug_dcache_fsm) |
---|
| 3300 | { |
---|
| 3301 | std::cout << " <PROC " << name() |
---|
| 3302 | << " DCACHE_TLB_PTE1_UPDT> write PTE1 in ITLB" |
---|
| 3303 | << " / set = " << std::dec << r_dcache_tlb_set.read() |
---|
| 3304 | << " / way = " << r_dcache_tlb_way.read() << std::endl; |
---|
| 3305 | r_itlb.printTrace(); |
---|
| 3306 | } |
---|
[331] | 3307 | #endif |
---|
| 3308 | } |
---|
| 3309 | else |
---|
| 3310 | { |
---|
[789] | 3311 | r_dtlb.write(true, // 2M page |
---|
| 3312 | pte, |
---|
| 3313 | 0, // argument unused for a PTE1 |
---|
| 3314 | r_dcache_tlb_vaddr.read(), |
---|
| 3315 | r_dcache_tlb_way.read(), |
---|
| 3316 | r_dcache_tlb_set.read(), |
---|
| 3317 | nline); |
---|
[331] | 3318 | #ifdef INSTRUMENTATION |
---|
[789] | 3319 | m_cpt_dtlb_write++; |
---|
[331] | 3320 | #endif |
---|
| 3321 | |
---|
| 3322 | #if DEBUG_DCACHE |
---|
[789] | 3323 | if (m_debug_dcache_fsm) |
---|
| 3324 | { |
---|
| 3325 | std::cout << " <PROC " << name() |
---|
| 3326 | << " DCACHE_TLB_PTE1_UPDT> write PTE1 in DTLB" |
---|
| 3327 | << " / set = " << std::dec << r_dcache_tlb_set.read() |
---|
| 3328 | << " / way = " << r_dcache_tlb_way.read() << std::endl; |
---|
| 3329 | r_dtlb.printTrace(); |
---|
| 3330 | } |
---|
[331] | 3331 | #endif |
---|
| 3332 | } |
---|
| 3333 | r_dcache_fsm = DCACHE_TLB_RETURN; |
---|
| 3334 | } |
---|
| 3335 | else // update page table but not TLB |
---|
| 3336 | { |
---|
| 3337 | r_dcache_fsm = DCACHE_TLB_LR_UPDT; |
---|
| 3338 | |
---|
| 3339 | #if DEBUG_DCACHE |
---|
[789] | 3340 | if (m_debug_dcache_fsm) |
---|
| 3341 | { |
---|
| 3342 | std::cout << " <PROC " << name() |
---|
| 3343 | << " DCACHE_TLB_PTE1_UPDT> L/R bit update required" |
---|
| 3344 | << std::endl; |
---|
| 3345 | } |
---|
[331] | 3346 | #endif |
---|
| 3347 | } |
---|
| 3348 | break; |
---|
| 3349 | } |
---|
| 3350 | ///////////////////////// |
---|
[789] | 3351 | case DCACHE_TLB_PTE2_GET: // Try to get a PTE2 (64 bits) in the dcache |
---|
[331] | 3352 | { |
---|
[468] | 3353 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 3354 | if (r_dcache_clack_req.read()) |
---|
[468] | 3355 | { |
---|
| 3356 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3357 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3358 | break; |
---|
| 3359 | } |
---|
| 3360 | |
---|
[341] | 3361 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 3362 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[341] | 3363 | { |
---|
| 3364 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3365 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3366 | break; |
---|
| 3367 | } |
---|
| 3368 | |
---|
[789] | 3369 | uint32_t pte_flags; |
---|
| 3370 | uint32_t pte_ppn; |
---|
| 3371 | size_t way; |
---|
| 3372 | size_t set; |
---|
| 3373 | size_t word; |
---|
| 3374 | int cache_state; |
---|
[331] | 3375 | |
---|
[789] | 3376 | r_dcache.read(r_dcache_tlb_paddr.read(), |
---|
| 3377 | &pte_flags, |
---|
| 3378 | &pte_ppn, |
---|
| 3379 | &way, |
---|
| 3380 | &set, |
---|
| 3381 | &word, |
---|
| 3382 | &cache_state); |
---|
[331] | 3383 | #ifdef INSTRUMENTATION |
---|
[789] | 3384 | m_cpt_dcache_data_read++; |
---|
| 3385 | m_cpt_dcache_dir_read++; |
---|
[331] | 3386 | #endif |
---|
[789] | 3387 | if (cache_state == CACHE_SLOT_STATE_VALID) // hit in dcache |
---|
[331] | 3388 | { |
---|
[789] | 3389 | if (not (pte_flags & PTE_V_MASK)) // unmapped |
---|
[331] | 3390 | { |
---|
[789] | 3391 | if (r_dcache_tlb_ins.read()) |
---|
[331] | 3392 | { |
---|
| 3393 | r_mmu_ietr = MMU_READ_PT2_UNMAPPED; |
---|
| 3394 | r_mmu_ibvar = r_dcache_tlb_vaddr.read(); |
---|
| 3395 | r_icache_tlb_miss_req = false; |
---|
| 3396 | r_icache_tlb_rsp_error = true; |
---|
| 3397 | } |
---|
| 3398 | else |
---|
| 3399 | { |
---|
[789] | 3400 | r_mmu_detr = MMU_READ_PT2_UNMAPPED; |
---|
| 3401 | r_mmu_dbvar = r_dcache_tlb_vaddr.read(); |
---|
| 3402 | m_drsp.valid = true; |
---|
| 3403 | m_drsp.error = true; |
---|
[331] | 3404 | } |
---|
[789] | 3405 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 3406 | |
---|
| 3407 | #if DEBUG_DCACHE |
---|
[789] | 3408 | if (m_debug_dcache_fsm) |
---|
| 3409 | { |
---|
| 3410 | std::cout << " <PROC " << name() |
---|
| 3411 | << " DCACHE_TLB_PTE2_GET> HIT in dcache, but PTE unmapped" |
---|
| 3412 | << " PTE_FLAGS = " << std::hex << pte_flags |
---|
| 3413 | << " PTE_PPN = " << std::hex << pte_ppn << std::endl; |
---|
| 3414 | } |
---|
[331] | 3415 | #endif |
---|
| 3416 | } |
---|
[789] | 3417 | else // mapped : we must update the TLB |
---|
[331] | 3418 | { |
---|
[789] | 3419 | r_dcache_in_tlb[m_dcache_sets * way + set] = true; |
---|
[331] | 3420 | r_dcache_tlb_pte_flags = pte_flags; |
---|
| 3421 | r_dcache_tlb_pte_ppn = pte_ppn; |
---|
| 3422 | r_dcache_tlb_cache_way = way; |
---|
| 3423 | r_dcache_tlb_cache_set = set; |
---|
| 3424 | r_dcache_tlb_cache_word = word; |
---|
| 3425 | r_dcache_fsm = DCACHE_TLB_PTE2_SELECT; |
---|
| 3426 | |
---|
| 3427 | #if DEBUG_DCACHE |
---|
[789] | 3428 | if (m_debug_dcache_fsm) |
---|
| 3429 | { |
---|
| 3430 | std::cout << " <PROC " << name() |
---|
| 3431 | << " DCACHE_TLB_PTE2_GET> HIT in dcache:" |
---|
| 3432 | << " PTE_FLAGS = " << std::hex << pte_flags |
---|
| 3433 | << " PTE_PPN = " << std::hex << pte_ppn << std::endl; |
---|
| 3434 | } |
---|
[331] | 3435 | #endif |
---|
| 3436 | } |
---|
| 3437 | } |
---|
[789] | 3438 | else if (cache_state == CACHE_SLOT_STATE_ZOMBI) // pending cleanup |
---|
[338] | 3439 | { |
---|
| 3440 | // stalled until cleanup is acknowledged |
---|
| 3441 | r_dcache_fsm = DCACHE_TLB_PTE2_GET; |
---|
[386] | 3442 | |
---|
| 3443 | #if DEBUG_DCACHE |
---|
[789] | 3444 | if (m_debug_dcache_fsm) |
---|
| 3445 | { |
---|
| 3446 | std::cout << " <PROC " << name() |
---|
| 3447 | << " DCACHE_TLB_PTE2_GET> ZOMBI in dcache: waiting cleanup ack" |
---|
| 3448 | << std::endl; |
---|
| 3449 | } |
---|
[386] | 3450 | #endif |
---|
[338] | 3451 | } |
---|
[331] | 3452 | else // we must load the missing cache line in dcache |
---|
| 3453 | { |
---|
| 3454 | r_dcache_fsm = DCACHE_MISS_SELECT; |
---|
| 3455 | r_dcache_vci_miss_req = true; |
---|
| 3456 | r_dcache_vci_paddr = r_dcache_tlb_paddr.read(); |
---|
| 3457 | r_dcache_save_paddr = r_dcache_tlb_paddr.read(); |
---|
| 3458 | r_dcache_miss_type = PTE2_MISS; |
---|
| 3459 | |
---|
| 3460 | #if DEBUG_DCACHE |
---|
[789] | 3461 | if (m_debug_dcache_fsm) |
---|
| 3462 | { |
---|
| 3463 | std::cout << " <PROC " << name() |
---|
| 3464 | << " DCACHE_TLB_PTE2_GET> MISS in dcache:" |
---|
| 3465 | << " PTE address = " << std::hex << r_dcache_tlb_paddr.read() << std::endl; |
---|
| 3466 | } |
---|
[331] | 3467 | #endif |
---|
| 3468 | } |
---|
| 3469 | break; |
---|
| 3470 | } |
---|
| 3471 | //////////////////////////// |
---|
| 3472 | case DCACHE_TLB_PTE2_SELECT: // select a slot for PTE2 |
---|
| 3473 | { |
---|
| 3474 | size_t way; |
---|
| 3475 | size_t set; |
---|
| 3476 | |
---|
[789] | 3477 | if (r_dcache_tlb_ins.read()) |
---|
[331] | 3478 | { |
---|
[789] | 3479 | r_itlb.select(r_dcache_tlb_vaddr.read(), |
---|
| 3480 | false, // PTE2 |
---|
| 3481 | &way, |
---|
| 3482 | &set); |
---|
[331] | 3483 | #ifdef INSTRUMENTATION |
---|
[789] | 3484 | m_cpt_itlb_read++; |
---|
[331] | 3485 | #endif |
---|
| 3486 | } |
---|
| 3487 | else |
---|
| 3488 | { |
---|
[789] | 3489 | r_dtlb.select(r_dcache_tlb_vaddr.read(), |
---|
| 3490 | false, // PTE2 |
---|
| 3491 | &way, |
---|
| 3492 | &set); |
---|
[331] | 3493 | #ifdef INSTRUMENTATION |
---|
[789] | 3494 | m_cpt_dtlb_read++; |
---|
[331] | 3495 | #endif |
---|
| 3496 | } |
---|
| 3497 | |
---|
| 3498 | #if DEBUG_DCACHE |
---|
[789] | 3499 | if (m_debug_dcache_fsm) |
---|
| 3500 | { |
---|
| 3501 | if (r_dcache_tlb_ins.read()) |
---|
| 3502 | std::cout << " <PROC " << name() |
---|
| 3503 | << " DCACHE_TLB_PTE2_SELECT> Select a slot in ITLB:"; |
---|
| 3504 | else |
---|
| 3505 | std::cout << " <PROC " << name() |
---|
| 3506 | << " DCACHE_TLB_PTE2_SELECT> Select a slot in DTLB:"; |
---|
| 3507 | std::cout << " way = " << std::dec << way |
---|
| 3508 | << " / set = " << set << std::endl; |
---|
| 3509 | } |
---|
[331] | 3510 | #endif |
---|
| 3511 | r_dcache_tlb_way = way; |
---|
| 3512 | r_dcache_tlb_set = set; |
---|
| 3513 | r_dcache_fsm = DCACHE_TLB_PTE2_UPDT; |
---|
| 3514 | break; |
---|
| 3515 | } |
---|
| 3516 | ////////////////////////// |
---|
[789] | 3517 | case DCACHE_TLB_PTE2_UPDT: // write a new PTE2 in tlb after testing the L/R bit |
---|
[331] | 3518 | // - if L/R bit already set, exit the sub-fsm. |
---|
| 3519 | // - if not, we update the page table but we dont write |
---|
| 3520 | // neither in DCACHE, nor in TLB, as this will be done by |
---|
| 3521 | // the coherence mechanism. |
---|
| 3522 | { |
---|
[789] | 3523 | paddr_t nline = r_dcache_tlb_paddr.read() >> (uint32_log2(m_dcache_words) + 2); |
---|
| 3524 | uint32_t pte_flags = r_dcache_tlb_pte_flags.read(); |
---|
| 3525 | uint32_t pte_ppn = r_dcache_tlb_pte_ppn.read(); |
---|
| 3526 | bool pt_updt = false; |
---|
| 3527 | bool local = true; |
---|
[331] | 3528 | |
---|
| 3529 | // We should compute the access locality: |
---|
| 3530 | // The PPN MSB bits define the destination cluster index. |
---|
[346] | 3531 | // The m_srcid MSB bits define the source cluster index. |
---|
[331] | 3532 | // The number of bits to compare depends on the number of clusters, |
---|
| 3533 | // and can be obtained in the mapping table. |
---|
| 3534 | // As long as this computation is not done, all access are local. |
---|
| 3535 | |
---|
[789] | 3536 | if (local) // local access |
---|
[331] | 3537 | { |
---|
[789] | 3538 | if (not ((pte_flags & PTE_L_MASK) == PTE_L_MASK)) // we must set the L bit |
---|
[331] | 3539 | { |
---|
| 3540 | pt_updt = true; |
---|
[355] | 3541 | r_dcache_vci_cas_old = pte_flags; |
---|
| 3542 | r_dcache_vci_cas_new = pte_flags | PTE_L_MASK; |
---|
[331] | 3543 | pte_flags = pte_flags | PTE_L_MASK; |
---|
[789] | 3544 | r_dcache_tlb_pte_flags = pte_flags; |
---|
[331] | 3545 | } |
---|
| 3546 | } |
---|
| 3547 | else // remote access |
---|
| 3548 | { |
---|
[789] | 3549 | if (not ((pte_flags & PTE_R_MASK) == PTE_R_MASK)) // we must set the R bit |
---|
[331] | 3550 | { |
---|
| 3551 | pt_updt = true; |
---|
[355] | 3552 | r_dcache_vci_cas_old = pte_flags; |
---|
| 3553 | r_dcache_vci_cas_new = pte_flags | PTE_R_MASK; |
---|
[331] | 3554 | pte_flags = pte_flags | PTE_R_MASK; |
---|
[789] | 3555 | r_dcache_tlb_pte_flags = pte_flags; |
---|
[331] | 3556 | } |
---|
| 3557 | } |
---|
| 3558 | |
---|
[789] | 3559 | if (not pt_updt) // update TLB |
---|
[331] | 3560 | { |
---|
[789] | 3561 | if (r_dcache_tlb_ins.read()) |
---|
[331] | 3562 | { |
---|
[789] | 3563 | r_itlb.write( false, // 4K page |
---|
[331] | 3564 | pte_flags, |
---|
| 3565 | pte_ppn, |
---|
| 3566 | r_dcache_tlb_vaddr.read(), |
---|
| 3567 | r_dcache_tlb_way.read(), |
---|
| 3568 | r_dcache_tlb_set.read(), |
---|
| 3569 | nline ); |
---|
| 3570 | #ifdef INSTRUMENTATION |
---|
[789] | 3571 | m_cpt_itlb_write++; |
---|
[331] | 3572 | #endif |
---|
| 3573 | |
---|
| 3574 | #if DEBUG_DCACHE |
---|
[789] | 3575 | if (m_debug_dcache_fsm) |
---|
| 3576 | { |
---|
| 3577 | std::cout << " <PROC " << name() |
---|
| 3578 | << " DCACHE_TLB_PTE2_UPDT> write PTE2 in ITLB" |
---|
| 3579 | << " / set = " << std::dec << r_dcache_tlb_set.read() |
---|
| 3580 | << " / way = " << r_dcache_tlb_way.read() << std::endl; |
---|
| 3581 | r_itlb.printTrace(); |
---|
| 3582 | } |
---|
[331] | 3583 | #endif |
---|
| 3584 | } |
---|
| 3585 | else |
---|
| 3586 | { |
---|
[789] | 3587 | r_dtlb.write(false, // 4K page |
---|
| 3588 | pte_flags, |
---|
| 3589 | pte_ppn, |
---|
| 3590 | r_dcache_tlb_vaddr.read(), |
---|
| 3591 | r_dcache_tlb_way.read(), |
---|
| 3592 | r_dcache_tlb_set.read(), |
---|
| 3593 | nline); |
---|
[331] | 3594 | #ifdef INSTRUMENTATION |
---|
[789] | 3595 | m_cpt_dtlb_write++; |
---|
[331] | 3596 | #endif |
---|
| 3597 | |
---|
| 3598 | #if DEBUG_DCACHE |
---|
[789] | 3599 | if (m_debug_dcache_fsm) |
---|
| 3600 | { |
---|
| 3601 | std::cout << " <PROC " << name() |
---|
| 3602 | << " DCACHE_TLB_PTE2_UPDT> write PTE2 in DTLB" |
---|
| 3603 | << " / set = " << std::dec << r_dcache_tlb_set.read() |
---|
| 3604 | << " / way = " << r_dcache_tlb_way.read() << std::endl; |
---|
| 3605 | r_dtlb.printTrace(); |
---|
| 3606 | } |
---|
[331] | 3607 | #endif |
---|
| 3608 | |
---|
| 3609 | } |
---|
| 3610 | r_dcache_fsm = DCACHE_TLB_RETURN; |
---|
| 3611 | } |
---|
| 3612 | else // update page table but not TLB |
---|
| 3613 | { |
---|
[789] | 3614 | r_dcache_fsm = DCACHE_TLB_LR_UPDT; // dcache and page table update |
---|
[331] | 3615 | |
---|
| 3616 | #if DEBUG_DCACHE |
---|
[789] | 3617 | if (m_debug_dcache_fsm) |
---|
| 3618 | { |
---|
| 3619 | std::cout << " <PROC " << name() |
---|
| 3620 | << " DCACHE_TLB_PTE2_UPDT> L/R bit update required" << std::endl; |
---|
| 3621 | } |
---|
[331] | 3622 | #endif |
---|
| 3623 | } |
---|
| 3624 | break; |
---|
| 3625 | } |
---|
| 3626 | //////////////////////// |
---|
| 3627 | case DCACHE_TLB_LR_UPDT: // request a CAS transaction to update L/R bit |
---|
| 3628 | { |
---|
| 3629 | #if DEBUG_DCACHE |
---|
[789] | 3630 | if (m_debug_dcache_fsm) |
---|
| 3631 | { |
---|
| 3632 | std::cout << " <PROC " << name() |
---|
| 3633 | << " DCACHE_TLB_LR_UPDT> Update dcache: (L/R) bit" << std::endl; |
---|
| 3634 | } |
---|
[331] | 3635 | #endif |
---|
| 3636 | // r_dcache_vci_cas_old & r_dcache_vci_cas_new registers are already set |
---|
| 3637 | r_dcache_vci_paddr = r_dcache_tlb_paddr.read(); |
---|
| 3638 | |
---|
| 3639 | // checking llsc reservation buffer |
---|
[789] | 3640 | if (r_dcache_llsc_paddr.read() == r_dcache_tlb_paddr.read()) |
---|
[331] | 3641 | r_dcache_llsc_valid = false; |
---|
| 3642 | |
---|
| 3643 | // request a CAS CMD and go to DCACHE_TLB_LR_WAIT state |
---|
| 3644 | r_dcache_vci_cas_req = true; |
---|
[789] | 3645 | r_dcache_fsm = DCACHE_TLB_LR_WAIT; |
---|
[331] | 3646 | break; |
---|
| 3647 | } |
---|
| 3648 | //////////////////////// |
---|
[789] | 3649 | case DCACHE_TLB_LR_WAIT: // Waiting the response to SC transaction for DIRTY bit. |
---|
[331] | 3650 | // We consume the response in rsp FIFO, |
---|
| 3651 | // and exit the sub-fsm, but we don't |
---|
| 3652 | // analyse the response, because we don't |
---|
| 3653 | // care if the L/R bit update is not done. |
---|
| 3654 | // We must take the coherence requests because |
---|
| 3655 | // there is a risk of dead-lock |
---|
| 3656 | |
---|
| 3657 | { |
---|
[468] | 3658 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 3659 | if (r_dcache_clack_req.read()) |
---|
[468] | 3660 | { |
---|
| 3661 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3662 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3663 | break; |
---|
| 3664 | } |
---|
| 3665 | |
---|
[331] | 3666 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 3667 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 3668 | { |
---|
| 3669 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3670 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3671 | break; |
---|
| 3672 | } |
---|
| 3673 | |
---|
[789] | 3674 | if (r_vci_rsp_data_error.read()) // bus error |
---|
[331] | 3675 | { |
---|
| 3676 | std::cout << "BUS ERROR in DCACHE_TLB_LR_WAIT state" << std::endl; |
---|
| 3677 | std::cout << "This should not happen in this state" << std::endl; |
---|
| 3678 | exit(0); |
---|
| 3679 | } |
---|
[789] | 3680 | else if (r_vci_rsp_fifo_dcache.rok()) // response available |
---|
[506] | 3681 | { |
---|
[331] | 3682 | #if DEBUG_DCACHE |
---|
[789] | 3683 | if (m_debug_dcache_fsm) |
---|
| 3684 | { |
---|
| 3685 | std::cout << " <PROC " << name() |
---|
| 3686 | << " DCACHE_TLB_LR_WAIT> SC response received" << std::endl; |
---|
| 3687 | } |
---|
[331] | 3688 | #endif |
---|
| 3689 | vci_rsp_fifo_dcache_get = true; |
---|
[789] | 3690 | r_dcache_fsm = DCACHE_TLB_RETURN; |
---|
[331] | 3691 | } |
---|
| 3692 | break; |
---|
| 3693 | } |
---|
| 3694 | /////////////////////// |
---|
[789] | 3695 | case DCACHE_TLB_RETURN: // return to caller depending on tlb miss type |
---|
[331] | 3696 | { |
---|
| 3697 | #if DEBUG_DCACHE |
---|
[789] | 3698 | if (m_debug_dcache_fsm) |
---|
| 3699 | { |
---|
| 3700 | std::cout << " <PROC " << name() |
---|
| 3701 | << " DCACHE_TLB_RETURN> TLB MISS completed" << std::endl; |
---|
| 3702 | } |
---|
[331] | 3703 | #endif |
---|
[789] | 3704 | if (r_dcache_tlb_ins.read()) r_icache_tlb_miss_req = false; |
---|
[331] | 3705 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 3706 | break; |
---|
| 3707 | } |
---|
| 3708 | /////////////////////// |
---|
[789] | 3709 | case DCACHE_XTN_SWITCH: // The r_ptpr registers must be written, |
---|
[331] | 3710 | // and both itlb and dtlb must be flushed. |
---|
| 3711 | // Caution : the itlb miss requests must be taken |
---|
| 3712 | // to avoid dead-lock in case of simultaneous ITLB miss |
---|
[521] | 3713 | // Caution : the clack and cc requests must be taken |
---|
| 3714 | // to avoid dead-lock |
---|
[331] | 3715 | { |
---|
[521] | 3716 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 3717 | if (r_dcache_clack_req.read()) |
---|
[521] | 3718 | { |
---|
| 3719 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3720 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3721 | break; |
---|
| 3722 | } |
---|
| 3723 | |
---|
| 3724 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 3725 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[521] | 3726 | { |
---|
| 3727 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3728 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3729 | break; |
---|
| 3730 | } |
---|
| 3731 | |
---|
[331] | 3732 | // itlb miss request |
---|
[789] | 3733 | if (r_icache_tlb_miss_req.read()) |
---|
[331] | 3734 | { |
---|
[789] | 3735 | r_dcache_tlb_ins = true; |
---|
| 3736 | r_dcache_tlb_vaddr = r_icache_vaddr_save.read(); |
---|
| 3737 | r_dcache_fsm = DCACHE_TLB_MISS; |
---|
[331] | 3738 | break; |
---|
| 3739 | } |
---|
| 3740 | |
---|
[789] | 3741 | if (not r_dcache_xtn_req.read()) |
---|
[331] | 3742 | { |
---|
| 3743 | r_dtlb.flush(); |
---|
| 3744 | r_mmu_ptpr = m_dreq.wdata; |
---|
| 3745 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 3746 | m_drsp.valid = true; |
---|
| 3747 | } |
---|
| 3748 | break; |
---|
| 3749 | } |
---|
| 3750 | ///////////////////// |
---|
[789] | 3751 | case DCACHE_XTN_SYNC: // waiting until write buffer empty |
---|
| 3752 | // The coherence request must be taken |
---|
| 3753 | // as there is a risk of dead-lock |
---|
[331] | 3754 | { |
---|
[468] | 3755 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 3756 | if (r_dcache_clack_req.read()) |
---|
[468] | 3757 | { |
---|
| 3758 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3759 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3760 | break; |
---|
| 3761 | } |
---|
| 3762 | |
---|
[331] | 3763 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 3764 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 3765 | { |
---|
| 3766 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3767 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
[468] | 3768 | break; |
---|
[331] | 3769 | } |
---|
| 3770 | |
---|
[789] | 3771 | if (r_wbuf.empty()) |
---|
[331] | 3772 | { |
---|
[789] | 3773 | m_drsp.valid = true; |
---|
[331] | 3774 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 3775 | } |
---|
| 3776 | break; |
---|
| 3777 | } |
---|
| 3778 | //////////////////////// |
---|
[721] | 3779 | case DCACHE_XTN_IC_FLUSH: // Waiting completion of an XTN request to the ICACHE FSM |
---|
| 3780 | case DCACHE_XTN_IC_INVAL_VA: // Caution : the itlb miss requests must be taken |
---|
| 3781 | case DCACHE_XTN_IC_INVAL_PA: // because the XTN_ICACHE_INVAL request to icache |
---|
| 3782 | case DCACHE_XTN_IC_PADDR_EXT: // can generate an itlb miss, |
---|
| 3783 | case DCACHE_XTN_IT_INVAL: // and because it can exist a simultaneous ITLB miss |
---|
| 3784 | |
---|
[331] | 3785 | { |
---|
[468] | 3786 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 3787 | if (r_dcache_clack_req.read()) |
---|
[468] | 3788 | { |
---|
| 3789 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3790 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3791 | break; |
---|
| 3792 | } |
---|
| 3793 | |
---|
[331] | 3794 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 3795 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 3796 | { |
---|
| 3797 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3798 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3799 | break; |
---|
| 3800 | } |
---|
| 3801 | |
---|
| 3802 | // itlb miss request |
---|
[789] | 3803 | if (r_icache_tlb_miss_req.read()) |
---|
[331] | 3804 | { |
---|
[789] | 3805 | r_dcache_tlb_ins = true; |
---|
| 3806 | r_dcache_tlb_vaddr = r_icache_vaddr_save.read(); |
---|
| 3807 | r_dcache_fsm = DCACHE_TLB_MISS; |
---|
[331] | 3808 | break; |
---|
| 3809 | } |
---|
| 3810 | |
---|
| 3811 | // test if XTN request to icache completed |
---|
[789] | 3812 | if (not r_dcache_xtn_req.read()) |
---|
[331] | 3813 | { |
---|
| 3814 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 3815 | m_drsp.valid = true; |
---|
| 3816 | } |
---|
| 3817 | break; |
---|
| 3818 | } |
---|
| 3819 | ///////////////////////// |
---|
[789] | 3820 | case DCACHE_XTN_DC_FLUSH: // Invalidate sequencially all cache lines, using |
---|
[331] | 3821 | // r_dcache_flush_count as a slot counter, |
---|
| 3822 | // looping in this state until all slots have been visited. |
---|
| 3823 | // It can require two cycles per slot: |
---|
| 3824 | // We test here the slot state, and make the actual inval |
---|
| 3825 | // (if line is valid) in DCACHE_XTN_DC_FLUSH_GO state. |
---|
| 3826 | // A cleanup request is generated for each valid line. |
---|
| 3827 | // returns to IDLE and flush TLBs when last slot |
---|
| 3828 | { |
---|
[468] | 3829 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 3830 | if (r_dcache_clack_req.read()) |
---|
[468] | 3831 | { |
---|
| 3832 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3833 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3834 | break; |
---|
| 3835 | } |
---|
| 3836 | |
---|
[384] | 3837 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 3838 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[384] | 3839 | { |
---|
| 3840 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 3841 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 3842 | break; |
---|
| 3843 | } |
---|
| 3844 | |
---|
[789] | 3845 | if (not r_dcache_cc_send_req.read()) // blocked until previous cc_send request is sent |
---|
[331] | 3846 | { |
---|
[789] | 3847 | int state; |
---|
| 3848 | paddr_t tag; |
---|
| 3849 | size_t way = r_dcache_flush_count.read()/m_dcache_sets; |
---|
| 3850 | size_t set = r_dcache_flush_count.read()%m_dcache_sets; |
---|
[331] | 3851 | |
---|
| 3852 | #ifdef INSTRUMENTATION |
---|
[789] | 3853 | m_cpt_dcache_dir_read++; |
---|
[331] | 3854 | #endif |
---|
[789] | 3855 | r_dcache.read_dir(way, |
---|
| 3856 | set, |
---|
| 3857 | &tag, |
---|
| 3858 | &state); |
---|
[331] | 3859 | |
---|
[789] | 3860 | if (state == CACHE_SLOT_STATE_VALID) // inval required |
---|
[331] | 3861 | { |
---|
| 3862 | // request cleanup |
---|
| 3863 | r_dcache_cc_send_req = true; |
---|
[384] | 3864 | r_dcache_cc_send_nline = tag * m_dcache_sets + set; |
---|
[331] | 3865 | r_dcache_cc_send_way = way; |
---|
| 3866 | r_dcache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 3867 | |
---|
| 3868 | // goes to DCACHE_XTN_DC_FLUSH_GO to inval directory |
---|
[789] | 3869 | r_dcache_miss_way = way; |
---|
| 3870 | r_dcache_miss_set = set; |
---|
| 3871 | r_dcache_fsm = DCACHE_XTN_DC_FLUSH_GO; |
---|
[331] | 3872 | } |
---|
[789] | 3873 | else if (r_dcache_flush_count.read() == |
---|
| 3874 | (m_dcache_sets*m_dcache_ways - 1)) // last slot |
---|
[331] | 3875 | { |
---|
| 3876 | r_dtlb.reset(); |
---|
| 3877 | r_itlb.reset(); |
---|
| 3878 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 3879 | m_drsp.valid = true; |
---|
| 3880 | } |
---|
| 3881 | |
---|
| 3882 | // saturation counter |
---|
[789] | 3883 | if (r_dcache_flush_count.read() < (m_dcache_sets * m_dcache_ways - 1)) |
---|
[331] | 3884 | r_dcache_flush_count = r_dcache_flush_count.read() + 1; |
---|
| 3885 | } |
---|
| 3886 | break; |
---|
| 3887 | } |
---|
| 3888 | //////////////////////////// |
---|
| 3889 | case DCACHE_XTN_DC_FLUSH_GO: // Switch the cache slot to ZOMBI state |
---|
| 3890 | // and reset directory extension. |
---|
| 3891 | // returns to IDLE and flush TLBs when last slot |
---|
| 3892 | { |
---|
| 3893 | size_t way = r_dcache_miss_way.read(); |
---|
| 3894 | size_t set = r_dcache_miss_set.read(); |
---|
| 3895 | |
---|
[789] | 3896 | r_dcache_in_tlb[m_dcache_sets * way + set] = false; |
---|
| 3897 | r_dcache_contains_ptd[m_dcache_sets * way + set] = false; |
---|
[331] | 3898 | |
---|
| 3899 | #ifdef INSTRUMENTATION |
---|
[789] | 3900 | m_cpt_dcache_dir_write++; |
---|
[331] | 3901 | #endif |
---|
[789] | 3902 | r_dcache.write_dir(way, |
---|
| 3903 | set, |
---|
| 3904 | CACHE_SLOT_STATE_ZOMBI); |
---|
[331] | 3905 | |
---|
[789] | 3906 | if (r_dcache_flush_count.read() == |
---|
| 3907 | (m_dcache_sets*m_dcache_ways - 1)) // last slot |
---|
[331] | 3908 | { |
---|
| 3909 | r_dtlb.reset(); |
---|
| 3910 | r_itlb.reset(); |
---|
| 3911 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 3912 | m_drsp.valid = true; |
---|
| 3913 | } |
---|
| 3914 | else |
---|
| 3915 | { |
---|
| 3916 | r_dcache_fsm = DCACHE_XTN_DC_FLUSH; |
---|
| 3917 | } |
---|
| 3918 | break; |
---|
| 3919 | } |
---|
| 3920 | ///////////////////////// |
---|
[789] | 3921 | case DCACHE_XTN_DT_INVAL: // handling processor XTN_DTLB_INVAL request |
---|
[331] | 3922 | { |
---|
| 3923 | r_dtlb.inval(r_dcache_save_wdata.read()); |
---|
[789] | 3924 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 3925 | m_drsp.valid = true; |
---|
[331] | 3926 | break; |
---|
| 3927 | } |
---|
| 3928 | //////////////////////////// |
---|
| 3929 | case DCACHE_XTN_DC_INVAL_VA: // selective cache line invalidate with virtual address |
---|
| 3930 | // requires 3 cycles: access tlb, read cache, inval cache |
---|
[789] | 3931 | // we compute the physical address in this state |
---|
[331] | 3932 | { |
---|
| 3933 | paddr_t paddr; |
---|
[789] | 3934 | bool hit; |
---|
[331] | 3935 | |
---|
[789] | 3936 | if (r_mmu_mode.read() & DATA_TLB_MASK) // dtlb activated |
---|
[331] | 3937 | { |
---|
| 3938 | |
---|
| 3939 | #ifdef INSTRUMENTATION |
---|
[789] | 3940 | m_cpt_dtlb_read++; |
---|
[331] | 3941 | #endif |
---|
[789] | 3942 | hit = r_dtlb.translate(r_dcache_save_wdata.read(), |
---|
| 3943 | &paddr); |
---|
[331] | 3944 | } |
---|
[789] | 3945 | else // dtlb not activated |
---|
[331] | 3946 | { |
---|
| 3947 | paddr = (paddr_t)r_dcache_save_wdata.read(); |
---|
[487] | 3948 | if (vci_param::N > 32) |
---|
| 3949 | paddr = paddr | ((paddr_t)(r_dcache_paddr_ext.read()) << 32); |
---|
[789] | 3950 | hit = true; |
---|
[331] | 3951 | } |
---|
| 3952 | |
---|
[789] | 3953 | if (hit) // tlb hit |
---|
[331] | 3954 | { |
---|
| 3955 | r_dcache_save_paddr = paddr; |
---|
[789] | 3956 | r_dcache_fsm = DCACHE_XTN_DC_INVAL_PA; |
---|
[331] | 3957 | } |
---|
[789] | 3958 | else // tlb miss |
---|
| 3959 | { |
---|
[331] | 3960 | |
---|
| 3961 | #ifdef INSTRUMENTATION |
---|
[789] | 3962 | m_cpt_dtlb_miss++; |
---|
[331] | 3963 | #endif |
---|
[789] | 3964 | r_dcache_tlb_ins = false; // dtlb |
---|
| 3965 | r_dcache_tlb_vaddr = r_dcache_save_wdata.read(); |
---|
| 3966 | r_dcache_fsm = DCACHE_TLB_MISS; |
---|
[331] | 3967 | } |
---|
| 3968 | |
---|
| 3969 | #if DEBUG_DCACHE |
---|
[789] | 3970 | if (m_debug_dcache_fsm) |
---|
| 3971 | { |
---|
| 3972 | std::cout << " <PROC " << name() |
---|
| 3973 | << " DCACHE_XTN_DC_INVAL_VA> Compute physical address" << std::hex |
---|
| 3974 | << " / VADDR = " << r_dcache_save_wdata.read() |
---|
| 3975 | << " / PADDR = " << paddr << std::endl; |
---|
| 3976 | } |
---|
[331] | 3977 | #endif |
---|
| 3978 | |
---|
| 3979 | break; |
---|
| 3980 | } |
---|
| 3981 | //////////////////////////// |
---|
| 3982 | case DCACHE_XTN_DC_INVAL_PA: // selective cache line invalidate with physical address |
---|
| 3983 | // requires 2 cycles: read cache / inval cache |
---|
| 3984 | // In this state we read dcache. |
---|
| 3985 | { |
---|
[789] | 3986 | size_t way; |
---|
| 3987 | size_t set; |
---|
| 3988 | size_t word; |
---|
| 3989 | int state; |
---|
[331] | 3990 | |
---|
| 3991 | #ifdef INSTRUMENTATION |
---|
[789] | 3992 | m_cpt_dcache_dir_read++; |
---|
[331] | 3993 | #endif |
---|
[789] | 3994 | r_dcache.read_dir(r_dcache_save_paddr.read(), |
---|
| 3995 | &state, |
---|
| 3996 | &way, |
---|
| 3997 | &set, |
---|
| 3998 | &word); |
---|
[331] | 3999 | |
---|
[789] | 4000 | if (state == CACHE_SLOT_STATE_VALID) // inval to be done |
---|
[331] | 4001 | { |
---|
| 4002 | r_dcache_xtn_way = way; |
---|
| 4003 | r_dcache_xtn_set = set; |
---|
[789] | 4004 | r_dcache_fsm = DCACHE_XTN_DC_INVAL_GO; |
---|
[331] | 4005 | } |
---|
[789] | 4006 | else // miss : nothing to do |
---|
[331] | 4007 | { |
---|
[789] | 4008 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4009 | m_drsp.valid = true; |
---|
[331] | 4010 | } |
---|
| 4011 | |
---|
| 4012 | #if DEBUG_DCACHE |
---|
[789] | 4013 | if (m_debug_dcache_fsm) |
---|
| 4014 | { |
---|
| 4015 | std::cout << " <PROC " << name() |
---|
| 4016 | << " DCACHE_XTN_DC_INVAL_PA> Test hit in dcache" << std::hex |
---|
| 4017 | << " / PADDR = " << r_dcache_save_paddr.read() << std::dec |
---|
| 4018 | << " / HIT = " << (state == CACHE_SLOT_STATE_VALID) |
---|
| 4019 | << " / SET = " << set |
---|
| 4020 | << " / WAY = " << way << std::endl; |
---|
| 4021 | } |
---|
[331] | 4022 | #endif |
---|
| 4023 | break; |
---|
| 4024 | } |
---|
| 4025 | //////////////////////////// |
---|
| 4026 | case DCACHE_XTN_DC_INVAL_GO: // In this state, we invalidate the cache line |
---|
[789] | 4027 | // Blocked if previous cleanup not completed |
---|
[331] | 4028 | // Test if itlb or dtlb inval is required |
---|
| 4029 | { |
---|
[789] | 4030 | if (not r_dcache_cc_send_req.read()) // blocked until previous cc_send request is sent |
---|
[331] | 4031 | { |
---|
[789] | 4032 | size_t way = r_dcache_xtn_way.read(); |
---|
| 4033 | size_t set = r_dcache_xtn_set.read(); |
---|
| 4034 | paddr_t nline = r_dcache_save_paddr.read() / (m_dcache_words << 2); |
---|
[331] | 4035 | |
---|
| 4036 | #ifdef INSTRUMENTATION |
---|
[789] | 4037 | m_cpt_dcache_dir_write++; |
---|
[331] | 4038 | #endif |
---|
[789] | 4039 | r_dcache.write_dir(way, |
---|
| 4040 | set, |
---|
| 4041 | CACHE_SLOT_STATE_ZOMBI); |
---|
[331] | 4042 | |
---|
| 4043 | // request cleanup |
---|
| 4044 | r_dcache_cc_send_req = true; |
---|
| 4045 | r_dcache_cc_send_nline = nline; |
---|
| 4046 | r_dcache_cc_send_way = way; |
---|
| 4047 | r_dcache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 4048 | |
---|
| 4049 | // possible itlb & dtlb invalidate |
---|
[789] | 4050 | if (r_dcache_in_tlb[way * m_dcache_sets + set]) |
---|
[331] | 4051 | { |
---|
| 4052 | r_dcache_tlb_inval_line = nline; |
---|
| 4053 | r_dcache_tlb_inval_set = 0; |
---|
| 4054 | r_dcache_fsm_scan_save = DCACHE_XTN_DC_INVAL_END; |
---|
| 4055 | r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; |
---|
[789] | 4056 | r_dcache_in_tlb[way * m_dcache_sets + set] = false; |
---|
[331] | 4057 | } |
---|
[789] | 4058 | else if (r_dcache_contains_ptd[way * m_dcache_sets + set]) |
---|
[331] | 4059 | { |
---|
| 4060 | r_itlb.reset(); |
---|
| 4061 | r_dtlb.reset(); |
---|
[789] | 4062 | r_dcache_contains_ptd[way * m_dcache_sets + set] = false; |
---|
[331] | 4063 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4064 | m_drsp.valid = true; |
---|
| 4065 | } |
---|
| 4066 | else |
---|
| 4067 | { |
---|
| 4068 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4069 | m_drsp.valid = true; |
---|
| 4070 | } |
---|
| 4071 | |
---|
| 4072 | #if DEBUG_DCACHE |
---|
[789] | 4073 | if (m_debug_dcache_fsm) |
---|
| 4074 | { |
---|
| 4075 | std::cout << " <PROC " << name() |
---|
| 4076 | << " DCACHE_XTN_DC_INVAL_GO> Actual dcache inval" << std::hex |
---|
| 4077 | << " / PADDR = " << r_dcache_save_paddr.read() << std::endl; |
---|
| 4078 | } |
---|
[331] | 4079 | #endif |
---|
[789] | 4080 | } |
---|
[331] | 4081 | break; |
---|
| 4082 | } |
---|
| 4083 | ////////////////////////////// |
---|
[789] | 4084 | case DCACHE_XTN_DC_INVAL_END: // send response to processor XTN request |
---|
[331] | 4085 | { |
---|
| 4086 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4087 | m_drsp.valid = true; |
---|
| 4088 | break; |
---|
| 4089 | } |
---|
| 4090 | //////////////////////// |
---|
[487] | 4091 | case DCACHE_MISS_SELECT: // Try to select a slot in associative set, |
---|
| 4092 | // Waiting in this state if no slot available. |
---|
| 4093 | // If a victim slot has been choosen and the r_icache_cc_send_req is false, |
---|
| 4094 | // we send the cleanup request in this state. |
---|
| 4095 | // If not, a r_icache_cleanup_victim_req flip-flop is |
---|
| 4096 | // utilized for saving this cleanup request, and it will be sent later |
---|
| 4097 | // in state ICACHE_MISS_WAIT or ICACHE_MISS_UPDT_DIR. |
---|
| 4098 | // The r_icache_miss_clack flip-flop is set |
---|
| 4099 | // when a cleanup is required |
---|
[331] | 4100 | { |
---|
[789] | 4101 | if (m_dreq.valid) m_cost_data_miss_frz++; |
---|
[331] | 4102 | |
---|
[468] | 4103 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 4104 | if (r_dcache_clack_req.read()) |
---|
[468] | 4105 | { |
---|
| 4106 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4107 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4108 | break; |
---|
| 4109 | } |
---|
| 4110 | |
---|
[331] | 4111 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 4112 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 4113 | { |
---|
| 4114 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4115 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4116 | break; |
---|
| 4117 | } |
---|
| 4118 | |
---|
[789] | 4119 | bool found = false; |
---|
| 4120 | bool cleanup = false; |
---|
| 4121 | size_t way = 0; |
---|
| 4122 | size_t set = 0; |
---|
| 4123 | paddr_t victim = 0; |
---|
[331] | 4124 | |
---|
| 4125 | #ifdef INSTRUMENTATION |
---|
[789] | 4126 | m_cpt_dcache_dir_read++; |
---|
[331] | 4127 | #endif |
---|
[789] | 4128 | r_dcache.read_select(r_dcache_save_paddr.read(), |
---|
| 4129 | &victim, |
---|
| 4130 | &way, |
---|
| 4131 | &set, |
---|
| 4132 | &found, |
---|
| 4133 | &cleanup); |
---|
[355] | 4134 | |
---|
[789] | 4135 | if (not found) |
---|
[487] | 4136 | { |
---|
| 4137 | break; |
---|
| 4138 | } |
---|
| 4139 | else |
---|
| 4140 | { |
---|
| 4141 | r_dcache_miss_way = way; |
---|
| 4142 | r_dcache_miss_set = set; |
---|
| 4143 | |
---|
[789] | 4144 | if (cleanup) |
---|
[331] | 4145 | { |
---|
[789] | 4146 | if (not r_dcache_cc_send_req.read()) |
---|
[487] | 4147 | { |
---|
[789] | 4148 | r_dcache_cc_send_req = true; |
---|
| 4149 | r_dcache_cc_send_nline = victim; |
---|
| 4150 | r_dcache_cc_send_way = way; |
---|
| 4151 | r_dcache_cc_send_type = CC_TYPE_CLEANUP; |
---|
[331] | 4152 | |
---|
| 4153 | } |
---|
| 4154 | else |
---|
| 4155 | { |
---|
[487] | 4156 | r_dcache_cleanup_victim_req = true; |
---|
| 4157 | r_dcache_cleanup_victim_nline = victim; |
---|
[331] | 4158 | } |
---|
| 4159 | |
---|
[789] | 4160 | r_dcache_miss_clack = true; |
---|
| 4161 | r_dcache_fsm = DCACHE_MISS_CLEAN; |
---|
[487] | 4162 | } |
---|
| 4163 | else |
---|
| 4164 | { |
---|
[789] | 4165 | r_dcache_fsm = DCACHE_MISS_WAIT; |
---|
[487] | 4166 | } |
---|
| 4167 | |
---|
[331] | 4168 | #if DEBUG_DCACHE |
---|
[789] | 4169 | if (m_debug_dcache_fsm) |
---|
| 4170 | { |
---|
| 4171 | std::cout << " <PROC " << name() |
---|
| 4172 | << " DCACHE_MISS_SELECT> Select a slot:" << std::dec |
---|
| 4173 | << " / WAY = " << way |
---|
| 4174 | << " / SET = " << set |
---|
| 4175 | << " / PADDR = " << std::hex << r_dcache_save_paddr.read(); |
---|
| 4176 | if (cleanup) std::cout << " / VICTIM = " << (victim*m_dcache_words*4) << std::endl; |
---|
| 4177 | else std::cout << std::endl; |
---|
| 4178 | } |
---|
[331] | 4179 | #endif |
---|
[487] | 4180 | } // end found |
---|
[331] | 4181 | break; |
---|
| 4182 | } |
---|
| 4183 | /////////////////////// |
---|
[789] | 4184 | case DCACHE_MISS_CLEAN: // switch the slot to ZOMBI state |
---|
[331] | 4185 | // and possibly request itlb or dtlb invalidate |
---|
| 4186 | { |
---|
[789] | 4187 | if (m_dreq.valid) m_cost_data_miss_frz++; |
---|
[331] | 4188 | |
---|
[789] | 4189 | size_t way = r_dcache_miss_way.read(); |
---|
| 4190 | size_t set = r_dcache_miss_set.read(); |
---|
[331] | 4191 | |
---|
| 4192 | #ifdef INSTRUMENTATION |
---|
[789] | 4193 | m_cpt_dcache_dir_read++; |
---|
[331] | 4194 | #endif |
---|
[789] | 4195 | r_dcache.write_dir(way, |
---|
| 4196 | set, |
---|
| 4197 | CACHE_SLOT_STATE_ZOMBI); |
---|
[331] | 4198 | #if DEBUG_DCACHE |
---|
[789] | 4199 | if (m_debug_dcache_fsm) |
---|
| 4200 | { |
---|
| 4201 | std::cout << " <PROC " << name() |
---|
| 4202 | << " DCACHE_MISS_CLEAN> Switch to ZOMBI state" << std::dec |
---|
| 4203 | << " / way = " << way |
---|
| 4204 | << " / set = " << set << std::endl; |
---|
| 4205 | } |
---|
[331] | 4206 | #endif |
---|
| 4207 | // if selective itlb & dtlb invalidate are required |
---|
| 4208 | // the miss response is not handled before invalidate completed |
---|
[789] | 4209 | if (r_dcache_in_tlb[way * m_dcache_sets + set]) |
---|
[331] | 4210 | { |
---|
[789] | 4211 | r_dcache_in_tlb[way * m_dcache_sets + set] = false; |
---|
[532] | 4212 | |
---|
[789] | 4213 | if (not r_dcache_cleanup_victim_req.read()) |
---|
| 4214 | r_dcache_tlb_inval_line = r_dcache_cc_send_nline.read(); |
---|
[532] | 4215 | else |
---|
| 4216 | r_dcache_tlb_inval_line = r_dcache_cleanup_victim_nline.read(); |
---|
| 4217 | |
---|
[789] | 4218 | r_dcache_tlb_inval_set = 0; |
---|
| 4219 | r_dcache_fsm_scan_save = DCACHE_MISS_WAIT; |
---|
| 4220 | r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; |
---|
[331] | 4221 | } |
---|
[789] | 4222 | else if (r_dcache_contains_ptd[way * m_dcache_sets + set]) |
---|
[331] | 4223 | { |
---|
| 4224 | r_itlb.reset(); |
---|
| 4225 | r_dtlb.reset(); |
---|
[789] | 4226 | r_dcache_contains_ptd[way * m_dcache_sets + set] = false; |
---|
[331] | 4227 | r_dcache_fsm = DCACHE_MISS_WAIT; |
---|
| 4228 | } |
---|
| 4229 | else |
---|
| 4230 | { |
---|
| 4231 | r_dcache_fsm = DCACHE_MISS_WAIT; |
---|
| 4232 | } |
---|
| 4233 | break; |
---|
| 4234 | } |
---|
| 4235 | ////////////////////// |
---|
[789] | 4236 | case DCACHE_MISS_WAIT: // waiting the response to a miss request from VCI_RSP FSM |
---|
[331] | 4237 | // This state is in charge of error signaling |
---|
| 4238 | // There is 5 types of error depending on the requester |
---|
| 4239 | { |
---|
[789] | 4240 | if (m_dreq.valid) m_cost_data_miss_frz++; |
---|
[331] | 4241 | |
---|
[487] | 4242 | // send cleanup victim request |
---|
[789] | 4243 | if (r_dcache_cleanup_victim_req.read() and not r_dcache_cc_send_req.read()) |
---|
[487] | 4244 | { |
---|
| 4245 | r_dcache_cc_send_req = true; |
---|
| 4246 | r_dcache_cc_send_nline = r_dcache_cleanup_victim_nline; |
---|
| 4247 | r_dcache_cc_send_way = r_dcache_miss_way; |
---|
| 4248 | r_dcache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 4249 | r_dcache_cleanup_victim_req = false; |
---|
| 4250 | } |
---|
| 4251 | |
---|
[488] | 4252 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 4253 | if (r_dcache_clack_req.read()) |
---|
[488] | 4254 | { |
---|
| 4255 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4256 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4257 | break; |
---|
| 4258 | } |
---|
| 4259 | |
---|
[331] | 4260 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 4261 | if (r_cc_receive_dcache_req.read() and |
---|
[711] | 4262 | not r_dcache_cc_send_req.read() and |
---|
| 4263 | not r_dcache_cleanup_victim_req.read()) |
---|
[331] | 4264 | { |
---|
| 4265 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4266 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4267 | break; |
---|
| 4268 | } |
---|
| 4269 | |
---|
[789] | 4270 | if (r_vci_rsp_data_error.read()) // bus error |
---|
[331] | 4271 | { |
---|
[789] | 4272 | switch (r_dcache_miss_type.read()) |
---|
[331] | 4273 | { |
---|
| 4274 | case PROC_MISS: |
---|
| 4275 | { |
---|
[789] | 4276 | r_mmu_detr = MMU_READ_DATA_ILLEGAL_ACCESS; |
---|
| 4277 | r_mmu_dbvar = r_dcache_save_vaddr.read(); |
---|
| 4278 | m_drsp.valid = true; |
---|
| 4279 | m_drsp.error = true; |
---|
| 4280 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 4281 | break; |
---|
| 4282 | } |
---|
| 4283 | case PTE1_MISS: |
---|
| 4284 | { |
---|
[789] | 4285 | if (r_dcache_tlb_ins.read()) |
---|
[331] | 4286 | { |
---|
[789] | 4287 | r_mmu_ietr = MMU_READ_PT1_ILLEGAL_ACCESS; |
---|
| 4288 | r_mmu_ibvar = r_dcache_tlb_vaddr.read(); |
---|
| 4289 | r_icache_tlb_miss_req = false; |
---|
| 4290 | r_icache_tlb_rsp_error = true; |
---|
[331] | 4291 | } |
---|
| 4292 | else |
---|
| 4293 | { |
---|
[789] | 4294 | r_mmu_detr = MMU_READ_PT1_ILLEGAL_ACCESS; |
---|
| 4295 | r_mmu_dbvar = r_dcache_tlb_vaddr.read(); |
---|
| 4296 | m_drsp.valid = true; |
---|
| 4297 | m_drsp.error = true; |
---|
[331] | 4298 | } |
---|
[789] | 4299 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 4300 | break; |
---|
| 4301 | } |
---|
| 4302 | case PTE2_MISS: |
---|
| 4303 | { |
---|
[789] | 4304 | if (r_dcache_tlb_ins.read()) |
---|
[331] | 4305 | { |
---|
[789] | 4306 | r_mmu_ietr = MMU_READ_PT2_ILLEGAL_ACCESS; |
---|
| 4307 | r_mmu_ibvar = r_dcache_tlb_vaddr.read(); |
---|
| 4308 | r_icache_tlb_miss_req = false; |
---|
| 4309 | r_icache_tlb_rsp_error = true; |
---|
[331] | 4310 | } |
---|
| 4311 | else |
---|
| 4312 | { |
---|
[789] | 4313 | r_mmu_detr = MMU_READ_PT2_ILLEGAL_ACCESS; |
---|
| 4314 | r_mmu_dbvar = r_dcache_tlb_vaddr.read(); |
---|
| 4315 | m_drsp.valid = true; |
---|
| 4316 | m_drsp.error = true; |
---|
[331] | 4317 | } |
---|
[789] | 4318 | r_dcache_fsm = DCACHE_IDLE; |
---|
[331] | 4319 | break; |
---|
| 4320 | } |
---|
| 4321 | } // end switch type |
---|
| 4322 | r_vci_rsp_data_error = false; |
---|
| 4323 | } |
---|
[789] | 4324 | else if (r_vci_rsp_fifo_dcache.rok()) // valid response available |
---|
[331] | 4325 | { |
---|
| 4326 | r_dcache_miss_word = 0; |
---|
[789] | 4327 | r_dcache_fsm = DCACHE_MISS_DATA_UPDT; |
---|
[331] | 4328 | } |
---|
| 4329 | break; |
---|
| 4330 | } |
---|
| 4331 | ////////////////////////// |
---|
[789] | 4332 | case DCACHE_MISS_DATA_UPDT: // update the dcache (one word per cycle) |
---|
[331] | 4333 | { |
---|
[789] | 4334 | if (m_dreq.valid) m_cost_data_miss_frz++; |
---|
[331] | 4335 | |
---|
[789] | 4336 | if (r_vci_rsp_fifo_dcache.rok()) // one word available |
---|
[331] | 4337 | { |
---|
| 4338 | #ifdef INSTRUMENTATION |
---|
[789] | 4339 | m_cpt_dcache_data_write++; |
---|
[331] | 4340 | #endif |
---|
[789] | 4341 | r_dcache.write(r_dcache_miss_way.read(), |
---|
| 4342 | r_dcache_miss_set.read(), |
---|
| 4343 | r_dcache_miss_word.read(), |
---|
| 4344 | r_vci_rsp_fifo_dcache.read()); |
---|
[331] | 4345 | #if DEBUG_DCACHE |
---|
[789] | 4346 | if (m_debug_dcache_fsm) |
---|
| 4347 | { |
---|
| 4348 | std::cout << " <PROC " << name() |
---|
| 4349 | << " DCACHE_MISS_DATA_UPDT> Write one word:" |
---|
| 4350 | << " / DATA = " << std::hex << r_vci_rsp_fifo_dcache.read() |
---|
| 4351 | << " / WAY = " << std::dec << r_dcache_miss_way.read() |
---|
| 4352 | << " / SET = " << r_dcache_miss_set.read() |
---|
| 4353 | << " / WORD = " << r_dcache_miss_word.read() << std::endl; |
---|
| 4354 | } |
---|
[331] | 4355 | #endif |
---|
| 4356 | vci_rsp_fifo_dcache_get = true; |
---|
| 4357 | r_dcache_miss_word = r_dcache_miss_word.read() + 1; |
---|
| 4358 | |
---|
[789] | 4359 | if (r_dcache_miss_word.read() == (m_dcache_words - 1)) // last word |
---|
[331] | 4360 | { |
---|
| 4361 | r_dcache_fsm = DCACHE_MISS_DIR_UPDT; |
---|
| 4362 | } |
---|
| 4363 | } |
---|
| 4364 | break; |
---|
| 4365 | } |
---|
| 4366 | ////////////////////////// |
---|
| 4367 | case DCACHE_MISS_DIR_UPDT: // Stalled if a victim line has been evicted |
---|
| 4368 | // and the cleanup ack has not been received, |
---|
| 4369 | // as indicated by the r_dcache_miss clack. |
---|
| 4370 | // - If no matching coherence request (r_dcache_inval_miss) |
---|
| 4371 | // switch directory slot to VALID state. |
---|
| 4372 | // - If matching coherence request, switch directory slot |
---|
| 4373 | // to ZOMBI state, and send a cleanup request. |
---|
| 4374 | { |
---|
[789] | 4375 | if (m_dreq.valid) m_cost_data_miss_frz++; |
---|
[331] | 4376 | |
---|
[487] | 4377 | // send cleanup victim request |
---|
[789] | 4378 | if (r_dcache_cleanup_victim_req.read() and not r_dcache_cc_send_req.read()) |
---|
[487] | 4379 | { |
---|
| 4380 | r_dcache_cc_send_req = true; |
---|
| 4381 | r_dcache_cc_send_nline = r_dcache_cleanup_victim_nline; |
---|
| 4382 | r_dcache_cc_send_way = r_dcache_miss_way; |
---|
| 4383 | r_dcache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 4384 | r_dcache_cleanup_victim_req = false; |
---|
| 4385 | } |
---|
| 4386 | |
---|
[488] | 4387 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 4388 | if (r_dcache_clack_req.read()) |
---|
[488] | 4389 | { |
---|
| 4390 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4391 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4392 | break; |
---|
| 4393 | } |
---|
| 4394 | |
---|
[331] | 4395 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 4396 | if (r_cc_receive_dcache_req.read() and |
---|
[711] | 4397 | not r_dcache_cc_send_req.read() and |
---|
[789] | 4398 | not r_dcache_cleanup_victim_req.read()) |
---|
[331] | 4399 | { |
---|
| 4400 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4401 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4402 | break; |
---|
| 4403 | } |
---|
| 4404 | |
---|
[789] | 4405 | if (not r_dcache_miss_clack.read()) // waiting cleanup acknowledge |
---|
[331] | 4406 | { |
---|
[789] | 4407 | if (r_dcache_miss_inval.read()) // switch slot to ZOMBI state, and new cleanup |
---|
[331] | 4408 | { |
---|
[789] | 4409 | if (not r_dcache_cc_send_req.read()) // blocked until previous request sent |
---|
[331] | 4410 | { |
---|
| 4411 | r_dcache_miss_inval = false; |
---|
| 4412 | // request cleanup |
---|
| 4413 | r_dcache_cc_send_req = true; |
---|
[789] | 4414 | r_dcache_cc_send_nline = r_dcache_save_paddr.read() / (m_dcache_words << 2); |
---|
[331] | 4415 | r_dcache_cc_send_way = r_dcache_miss_way.read(); |
---|
| 4416 | r_dcache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 4417 | |
---|
| 4418 | #ifdef INSTRUMENTATION |
---|
[789] | 4419 | m_cpt_dcache_dir_write++; |
---|
[331] | 4420 | #endif |
---|
| 4421 | r_dcache.write_dir( r_dcache_save_paddr.read(), |
---|
| 4422 | r_dcache_miss_way.read(), |
---|
| 4423 | r_dcache_miss_set.read(), |
---|
| 4424 | CACHE_SLOT_STATE_ZOMBI ); |
---|
| 4425 | #if DEBUG_DCACHE |
---|
[789] | 4426 | if (m_debug_dcache_fsm) |
---|
| 4427 | std::cout << " <PROC " << name() |
---|
| 4428 | << " DCACHE_MISS_DIR_UPDT> Switch slot to ZOMBI state" |
---|
| 4429 | << " PADDR = " << std::hex << r_dcache_save_paddr.read() |
---|
| 4430 | << " / WAY = " << std::dec << r_dcache_miss_way.read() |
---|
| 4431 | << " / SET = " << r_dcache_miss_set.read() << std::endl; |
---|
[331] | 4432 | #endif |
---|
| 4433 | } |
---|
| 4434 | else |
---|
| 4435 | break; |
---|
| 4436 | } |
---|
| 4437 | else // switch slot to VALID state |
---|
| 4438 | { |
---|
| 4439 | |
---|
| 4440 | #ifdef INSTRUMENTATION |
---|
[789] | 4441 | m_cpt_dcache_dir_write++; |
---|
[331] | 4442 | #endif |
---|
[789] | 4443 | r_dcache.write_dir(r_dcache_save_paddr.read(), |
---|
| 4444 | r_dcache_miss_way.read(), |
---|
| 4445 | r_dcache_miss_set.read(), |
---|
| 4446 | CACHE_SLOT_STATE_VALID); |
---|
[331] | 4447 | |
---|
| 4448 | #if DEBUG_DCACHE |
---|
[789] | 4449 | if (m_debug_dcache_fsm) |
---|
| 4450 | std::cout << " <PROC " << name() |
---|
| 4451 | << " DCACHE_MISS_DIR_UPDT> Switch slot to VALID state" |
---|
| 4452 | << " PADDR = " << std::hex << r_dcache_save_paddr.read() |
---|
| 4453 | << " / WAY = " << std::dec << r_dcache_miss_way.read() |
---|
| 4454 | << " / SET = " << r_dcache_miss_set.read() << std::endl; |
---|
[331] | 4455 | #endif |
---|
| 4456 | // reset directory extension |
---|
| 4457 | size_t way = r_dcache_miss_way.read(); |
---|
| 4458 | size_t set = r_dcache_miss_set.read(); |
---|
[789] | 4459 | r_dcache_in_tlb[way * m_dcache_sets + set] = false; |
---|
| 4460 | r_dcache_contains_ptd[way * m_dcache_sets + set] = false; |
---|
[331] | 4461 | } |
---|
| 4462 | if (r_dcache_miss_type.read()==PTE1_MISS) r_dcache_fsm = DCACHE_TLB_PTE1_GET; |
---|
| 4463 | else if (r_dcache_miss_type.read()==PTE2_MISS) r_dcache_fsm = DCACHE_TLB_PTE2_GET; |
---|
| 4464 | else r_dcache_fsm = DCACHE_IDLE; |
---|
| 4465 | } |
---|
| 4466 | break; |
---|
| 4467 | } |
---|
| 4468 | ///////////////////// |
---|
| 4469 | case DCACHE_UNC_WAIT: // waiting a response to an uncacheable read |
---|
| 4470 | { |
---|
[468] | 4471 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 4472 | if (r_dcache_clack_req.read()) |
---|
[468] | 4473 | { |
---|
| 4474 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4475 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4476 | break; |
---|
| 4477 | } |
---|
| 4478 | |
---|
[331] | 4479 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 4480 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 4481 | { |
---|
| 4482 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4483 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4484 | break; |
---|
| 4485 | } |
---|
| 4486 | |
---|
[789] | 4487 | if (r_vci_rsp_data_error.read()) // bus error |
---|
[331] | 4488 | { |
---|
[789] | 4489 | if (r_dcache_vci_unc_write.read()) |
---|
| 4490 | r_mmu_detr = MMU_WRITE_DATA_ILLEGAL_ACCESS; |
---|
[616] | 4491 | else |
---|
[789] | 4492 | r_mmu_detr = MMU_READ_DATA_ILLEGAL_ACCESS; |
---|
[616] | 4493 | |
---|
[331] | 4494 | r_mmu_dbvar = m_dreq.addr; |
---|
| 4495 | r_vci_rsp_data_error = false; |
---|
| 4496 | m_drsp.error = true; |
---|
| 4497 | m_drsp.valid = true; |
---|
| 4498 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4499 | break; |
---|
| 4500 | } |
---|
[789] | 4501 | else if (r_vci_rsp_fifo_dcache.rok()) // data available |
---|
| 4502 | { |
---|
[331] | 4503 | // consume data |
---|
| 4504 | vci_rsp_fifo_dcache_get = true; |
---|
| 4505 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4506 | |
---|
| 4507 | // acknowledge the processor request if it has not been modified |
---|
[789] | 4508 | if (m_dreq.valid and (m_dreq.addr == r_dcache_save_vaddr.read())) |
---|
[331] | 4509 | { |
---|
[789] | 4510 | m_drsp.valid = true; |
---|
| 4511 | m_drsp.error = false; |
---|
| 4512 | m_drsp.rdata = r_vci_rsp_fifo_dcache.read(); |
---|
[331] | 4513 | } |
---|
[789] | 4514 | } |
---|
[331] | 4515 | break; |
---|
| 4516 | } |
---|
| 4517 | ///////////////////// |
---|
| 4518 | case DCACHE_LL_WAIT: // waiting VCI response to a LL transaction |
---|
| 4519 | { |
---|
[468] | 4520 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 4521 | if (r_dcache_clack_req.read()) |
---|
[468] | 4522 | { |
---|
| 4523 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4524 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4525 | break; |
---|
| 4526 | } |
---|
| 4527 | |
---|
[331] | 4528 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 4529 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 4530 | { |
---|
| 4531 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4532 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4533 | break; |
---|
| 4534 | } |
---|
| 4535 | |
---|
[789] | 4536 | if (r_vci_rsp_data_error.read()) // bus error |
---|
[331] | 4537 | { |
---|
| 4538 | r_mmu_detr = MMU_READ_DATA_ILLEGAL_ACCESS; |
---|
| 4539 | r_mmu_dbvar = m_dreq.addr; |
---|
| 4540 | r_vci_rsp_data_error = false; |
---|
| 4541 | m_drsp.error = true; |
---|
| 4542 | m_drsp.valid = true; |
---|
| 4543 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4544 | break; |
---|
| 4545 | } |
---|
[789] | 4546 | else if (r_vci_rsp_fifo_dcache.rok()) // data available |
---|
| 4547 | { |
---|
[331] | 4548 | // consume data |
---|
| 4549 | vci_rsp_fifo_dcache_get = true; |
---|
| 4550 | |
---|
[789] | 4551 | if (r_dcache_ll_rsp_count.read() == 0) // first flit |
---|
[331] | 4552 | { |
---|
| 4553 | // set key value in llsc reservation buffer |
---|
| 4554 | r_dcache_llsc_key = r_vci_rsp_fifo_dcache.read(); |
---|
[789] | 4555 | r_dcache_ll_rsp_count = r_dcache_ll_rsp_count.read() + 1; |
---|
[331] | 4556 | } |
---|
| 4557 | else // last flit |
---|
| 4558 | { |
---|
| 4559 | // acknowledge the processor request if it has not been modified |
---|
[789] | 4560 | if (m_dreq.valid and (m_dreq.addr == r_dcache_save_vaddr.read())) |
---|
[331] | 4561 | { |
---|
[789] | 4562 | m_drsp.valid = true; |
---|
| 4563 | m_drsp.error = false; |
---|
| 4564 | m_drsp.rdata = r_vci_rsp_fifo_dcache.read(); |
---|
[331] | 4565 | } |
---|
| 4566 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4567 | } |
---|
[789] | 4568 | } |
---|
[331] | 4569 | break; |
---|
| 4570 | } |
---|
| 4571 | //////////////////// |
---|
[789] | 4572 | case DCACHE_SC_WAIT: // waiting VCI response to a SC transaction |
---|
[331] | 4573 | { |
---|
[468] | 4574 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 4575 | if (r_dcache_clack_req.read()) |
---|
[468] | 4576 | { |
---|
| 4577 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4578 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4579 | break; |
---|
| 4580 | } |
---|
| 4581 | |
---|
[331] | 4582 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 4583 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 4584 | { |
---|
| 4585 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4586 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4587 | break; |
---|
| 4588 | } |
---|
| 4589 | |
---|
[789] | 4590 | if (r_vci_rsp_data_error.read()) // bus error |
---|
[331] | 4591 | { |
---|
| 4592 | r_mmu_detr = MMU_READ_DATA_ILLEGAL_ACCESS; |
---|
| 4593 | r_mmu_dbvar = m_dreq.addr; |
---|
| 4594 | r_vci_rsp_data_error = false; |
---|
| 4595 | m_drsp.error = true; |
---|
| 4596 | m_drsp.valid = true; |
---|
| 4597 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4598 | break; |
---|
| 4599 | } |
---|
[789] | 4600 | else if (r_vci_rsp_fifo_dcache.rok()) // response available |
---|
| 4601 | { |
---|
[331] | 4602 | // consume response |
---|
| 4603 | vci_rsp_fifo_dcache_get = true; |
---|
| 4604 | m_drsp.valid = true; |
---|
| 4605 | m_drsp.rdata = r_vci_rsp_fifo_dcache.read(); |
---|
| 4606 | r_dcache_fsm = DCACHE_IDLE; |
---|
[789] | 4607 | } |
---|
[331] | 4608 | break; |
---|
| 4609 | } |
---|
| 4610 | ////////////////////////// |
---|
[789] | 4611 | case DCACHE_DIRTY_GET_PTE: // This sub_fsm set the PTE Dirty bit in memory |
---|
| 4612 | // before handling a processor WRITE or SC request |
---|
| 4613 | // Input argument is r_dcache_dirty_paddr |
---|
| 4614 | // In this first state, we get PTE value in dcache |
---|
| 4615 | // and post a CAS request to CMD FSM |
---|
[331] | 4616 | { |
---|
| 4617 | // get PTE in dcache |
---|
| 4618 | uint32_t pte; |
---|
| 4619 | size_t way; |
---|
| 4620 | size_t set; |
---|
[468] | 4621 | size_t word; // unused |
---|
[331] | 4622 | int state; |
---|
| 4623 | |
---|
| 4624 | #ifdef INSTRUMENTATION |
---|
[789] | 4625 | m_cpt_dcache_data_read++; |
---|
| 4626 | m_cpt_dcache_dir_read++; |
---|
[331] | 4627 | #endif |
---|
[789] | 4628 | r_dcache.read(r_dcache_dirty_paddr.read(), |
---|
| 4629 | &pte, |
---|
| 4630 | &way, |
---|
| 4631 | &set, |
---|
| 4632 | &word, |
---|
| 4633 | &state); |
---|
[331] | 4634 | |
---|
| 4635 | assert( (state == CACHE_SLOT_STATE_VALID) and |
---|
| 4636 | "error in DCACHE_DIRTY_TLB_SET: the PTE should be in dcache" ); |
---|
| 4637 | |
---|
| 4638 | // request CAS transaction to CMD_FSM |
---|
[789] | 4639 | r_dcache_dirty_way = way; |
---|
| 4640 | r_dcache_dirty_set = set; |
---|
[331] | 4641 | |
---|
| 4642 | // check llsc reservation buffer |
---|
[789] | 4643 | if (r_dcache_llsc_paddr.read() == r_dcache_dirty_paddr.read()) |
---|
[331] | 4644 | r_dcache_llsc_valid = false; |
---|
| 4645 | |
---|
| 4646 | // request a CAS CMD and go to DCACHE_DIRTY_WAIT state |
---|
| 4647 | r_dcache_vci_cas_req = true; |
---|
| 4648 | r_dcache_vci_paddr = r_dcache_dirty_paddr.read(); |
---|
| 4649 | r_dcache_vci_cas_old = pte; |
---|
| 4650 | r_dcache_vci_cas_new = pte | PTE_D_MASK; |
---|
| 4651 | r_dcache_fsm = DCACHE_DIRTY_WAIT; |
---|
| 4652 | |
---|
| 4653 | #if DEBUG_DCACHE |
---|
[789] | 4654 | if (m_debug_dcache_fsm) |
---|
| 4655 | { |
---|
| 4656 | std::cout << " <PROC " << name() |
---|
| 4657 | << " DCACHE_DIRTY_GET_PTE> CAS request" << std::hex |
---|
| 4658 | << " / PTE_PADDR = " << r_dcache_dirty_paddr.read() |
---|
| 4659 | << " / PTE_VALUE = " << pte << std::dec |
---|
| 4660 | << " / SET = " << set |
---|
| 4661 | << " / WAY = " << way << std::endl; |
---|
| 4662 | } |
---|
[331] | 4663 | #endif |
---|
| 4664 | break; |
---|
| 4665 | } |
---|
| 4666 | /////////////////////// |
---|
[789] | 4667 | case DCACHE_DIRTY_WAIT: // wait completion of CAS for PTE Dirty bit, |
---|
| 4668 | // and return to IDLE state when response is received. |
---|
| 4669 | // we don't care if the CAS is a failure: |
---|
| 4670 | // - if the CAS is a success, the coherence mechanism |
---|
| 4671 | // updates the local copy. |
---|
| 4672 | // - if the CAS is a failure, we just retry the write. |
---|
[331] | 4673 | { |
---|
[468] | 4674 | // coherence clack request (from DSPIN CLACK) |
---|
[789] | 4675 | if (r_dcache_clack_req.read()) |
---|
[468] | 4676 | { |
---|
| 4677 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4678 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4679 | break; |
---|
| 4680 | } |
---|
| 4681 | |
---|
[331] | 4682 | // coherence request (from CC_RECEIVE FSM) |
---|
[789] | 4683 | if (r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read()) |
---|
[331] | 4684 | { |
---|
| 4685 | r_dcache_fsm = DCACHE_CC_CHECK; |
---|
| 4686 | r_dcache_fsm_cc_save = r_dcache_fsm.read(); |
---|
| 4687 | break; |
---|
| 4688 | } |
---|
| 4689 | |
---|
[789] | 4690 | if (r_vci_rsp_data_error.read()) // bus error |
---|
[331] | 4691 | { |
---|
| 4692 | std::cout << "BUS ERROR in DCACHE_DIRTY_WAIT state" << std::endl; |
---|
| 4693 | std::cout << "This should not happen in this state" << std::endl; |
---|
| 4694 | exit(0); |
---|
| 4695 | } |
---|
[789] | 4696 | else if (r_vci_rsp_fifo_dcache.rok()) // response available |
---|
[331] | 4697 | { |
---|
| 4698 | vci_rsp_fifo_dcache_get = true; |
---|
| 4699 | r_dcache_fsm = DCACHE_IDLE; |
---|
| 4700 | |
---|
| 4701 | #if DEBUG_DCACHE |
---|
[789] | 4702 | if (m_debug_dcache_fsm) |
---|
| 4703 | { |
---|
| 4704 | std::cout << " <PROC " << name() |
---|
| 4705 | << " DCACHE_DIRTY_WAIT> CAS completed" << std::endl; |
---|
| 4706 | } |
---|
[331] | 4707 | #endif |
---|
| 4708 | } |
---|
| 4709 | break; |
---|
| 4710 | } |
---|
| 4711 | ///////////////////// |
---|
| 4712 | case DCACHE_CC_CHECK: // This state is the entry point for the sub-FSM |
---|
| 4713 | // handling coherence requests for DCACHE. |
---|
| 4714 | // If there is a matching pending miss on the modified cache |
---|
| 4715 | // line this is signaled in the r_dcache_miss inval flip-flop. |
---|
| 4716 | // If the updated (or invalidated) cache line has copies in TLBs |
---|
| 4717 | // these TLB copies are invalidated. |
---|
| 4718 | // The return state is defined in r_dcache_fsm_cc_save |
---|
| 4719 | { |
---|
[789] | 4720 | paddr_t paddr = r_cc_receive_dcache_nline.read() * m_dcache_words * 4; |
---|
| 4721 | paddr_t mask = ~((m_dcache_words << 2) - 1); |
---|
[331] | 4722 | |
---|
[484] | 4723 | // CLACK handler |
---|
| 4724 | // We switch the directory slot to EMPTY state and reset |
---|
| 4725 | // r_dcache_miss_clack if the cleanup ack is matching a pending miss. |
---|
[789] | 4726 | if (r_dcache_clack_req.read()) |
---|
[484] | 4727 | { |
---|
[789] | 4728 | if (m_dreq.valid ) m_cost_data_miss_frz++; |
---|
[331] | 4729 | |
---|
[484] | 4730 | #ifdef INSTRUMENTATION |
---|
[789] | 4731 | m_cpt_dcache_dir_write++; |
---|
[484] | 4732 | #endif |
---|
[789] | 4733 | r_dcache.write_dir(0, |
---|
| 4734 | r_dcache_clack_way.read(), |
---|
| 4735 | r_dcache_clack_set.read(), |
---|
| 4736 | CACHE_SLOT_STATE_EMPTY); |
---|
[484] | 4737 | |
---|
[789] | 4738 | if ((r_dcache_miss_set.read() == r_dcache_clack_set.read()) and |
---|
| 4739 | (r_dcache_miss_way.read() == r_dcache_clack_way.read())) |
---|
[484] | 4740 | { |
---|
| 4741 | r_dcache_miss_clack = false; |
---|
| 4742 | } |
---|
| 4743 | |
---|
| 4744 | r_dcache_clack_req = false; |
---|
| 4745 | |
---|
| 4746 | // return to cc_save state |
---|
| 4747 | r_dcache_fsm = r_dcache_fsm_cc_save.read() ; |
---|
| 4748 | |
---|
| 4749 | #if DEBUG_DCACHE |
---|
[789] | 4750 | if (m_debug_dcache_fsm) |
---|
| 4751 | { |
---|
| 4752 | std::cout << " <PROC " << name() |
---|
| 4753 | << " DCACHE_CC_CHECK> CLACK for PADDR " << paddr |
---|
| 4754 | << " Switch slot to EMPTY state : " |
---|
| 4755 | << " set = " << r_dcache_clack_set.read() |
---|
| 4756 | << " / way = " << r_dcache_clack_way.read() << std::endl; |
---|
| 4757 | } |
---|
[484] | 4758 | #endif |
---|
| 4759 | break; |
---|
| 4760 | } |
---|
| 4761 | |
---|
[583] | 4762 | assert ( not r_dcache_cc_send_req.read() and |
---|
| 4763 | "CC_SEND must be available in DCACHE_CC_CHECK" ); |
---|
[487] | 4764 | |
---|
[468] | 4765 | // Match between MISS address and CC address |
---|
| 4766 | if (r_cc_receive_dcache_req.read() and |
---|
[789] | 4767 | ((r_dcache_fsm_cc_save == DCACHE_MISS_SELECT) or |
---|
| 4768 | (r_dcache_fsm_cc_save == DCACHE_MISS_WAIT) or |
---|
[468] | 4769 | (r_dcache_fsm_cc_save == DCACHE_MISS_DIR_UPDT)) and |
---|
| 4770 | ((r_dcache_vci_paddr.read() & mask) == (paddr & mask))) // matching |
---|
[331] | 4771 | { |
---|
| 4772 | // signaling matching |
---|
| 4773 | r_dcache_miss_inval = true; |
---|
| 4774 | |
---|
| 4775 | // in case of update, go to CC_UPDT |
---|
| 4776 | // JUST TO POP THE FIFO |
---|
| 4777 | if (r_cc_receive_dcache_type.read() == CC_TYPE_UPDT) |
---|
| 4778 | { |
---|
[789] | 4779 | r_dcache_fsm = DCACHE_CC_UPDT; |
---|
| 4780 | r_dcache_cc_word = r_cc_receive_word_idx.read(); |
---|
[468] | 4781 | |
---|
[331] | 4782 | // just pop the fifo , don't write in icache |
---|
| 4783 | r_dcache_cc_need_write = false; |
---|
| 4784 | } |
---|
| 4785 | // the request is dealt with |
---|
| 4786 | else |
---|
| 4787 | { |
---|
| 4788 | r_cc_receive_dcache_req = false; |
---|
[468] | 4789 | r_dcache_fsm = r_dcache_fsm_cc_save.read(); |
---|
[331] | 4790 | } |
---|
| 4791 | |
---|
| 4792 | #if DEBUG_DCACHE |
---|
[789] | 4793 | if (m_debug_dcache_fsm) |
---|
| 4794 | { |
---|
| 4795 | std::cout << " <PROC " << name() |
---|
| 4796 | << " DCACHE_CC_CHECK> Coherence request matching a pending miss:" |
---|
| 4797 | << " PADDR = " << std::hex << paddr << std::endl; |
---|
| 4798 | } |
---|
[331] | 4799 | #endif |
---|
[468] | 4800 | } |
---|
[331] | 4801 | |
---|
[468] | 4802 | // CC request handler |
---|
| 4803 | |
---|
| 4804 | int state = 0; |
---|
| 4805 | size_t way = 0; |
---|
| 4806 | size_t set = 0; |
---|
| 4807 | size_t word = 0; |
---|
| 4808 | |
---|
[331] | 4809 | #ifdef INSTRUMENTATION |
---|
[789] | 4810 | m_cpt_dcache_dir_read++; |
---|
[331] | 4811 | #endif |
---|
[789] | 4812 | r_dcache.read_dir(paddr, |
---|
| 4813 | &state, |
---|
| 4814 | &way, |
---|
| 4815 | &set, |
---|
| 4816 | &word); // unused |
---|
[331] | 4817 | |
---|
[468] | 4818 | r_dcache_cc_way = way; |
---|
| 4819 | r_dcache_cc_set = set; |
---|
[331] | 4820 | |
---|
[789] | 4821 | if (state == CACHE_SLOT_STATE_VALID) // hit |
---|
[468] | 4822 | { |
---|
| 4823 | // need to update the cache state |
---|
| 4824 | if (r_cc_receive_dcache_type.read() == CC_TYPE_UPDT) // hit update |
---|
[331] | 4825 | { |
---|
| 4826 | r_dcache_cc_need_write = true; |
---|
[468] | 4827 | r_dcache_fsm = DCACHE_CC_UPDT; |
---|
| 4828 | r_dcache_cc_word = r_cc_receive_word_idx.read(); |
---|
[331] | 4829 | } |
---|
[789] | 4830 | else if (r_cc_receive_dcache_type.read() == CC_TYPE_INVAL) // hit inval |
---|
[331] | 4831 | { |
---|
[789] | 4832 | r_dcache_fsm = DCACHE_CC_INVAL; |
---|
[331] | 4833 | } |
---|
[468] | 4834 | } |
---|
| 4835 | else // miss |
---|
| 4836 | { |
---|
| 4837 | // multicast acknowledgement required in case of update |
---|
[789] | 4838 | if (r_cc_receive_dcache_type.read() == CC_TYPE_UPDT) |
---|
[468] | 4839 | { |
---|
[789] | 4840 | r_dcache_fsm = DCACHE_CC_UPDT; |
---|
| 4841 | r_dcache_cc_word = r_cc_receive_word_idx.read(); |
---|
[331] | 4842 | |
---|
[468] | 4843 | // just pop the fifo , don't write in icache |
---|
| 4844 | r_dcache_cc_need_write = false; |
---|
| 4845 | } |
---|
| 4846 | else // No response needed |
---|
| 4847 | { |
---|
| 4848 | r_cc_receive_dcache_req = false; |
---|
[789] | 4849 | r_dcache_fsm = r_dcache_fsm_cc_save.read(); |
---|
[468] | 4850 | } |
---|
| 4851 | } |
---|
| 4852 | |
---|
[331] | 4853 | #if DEBUG_DCACHE |
---|
[789] | 4854 | if (m_debug_dcache_fsm) |
---|
| 4855 | { |
---|
| 4856 | std::cout << " <PROC " << name() |
---|
| 4857 | << " DCACHE_CC_CHECK> Coherence request received:" |
---|
| 4858 | << " PADDR = " << std::hex << paddr |
---|
| 4859 | << " / TYPE = " << std::dec << r_cc_receive_dcache_type.read() |
---|
| 4860 | << " / HIT = " << (state == CACHE_SLOT_STATE_VALID) << std::endl; |
---|
| 4861 | } |
---|
[331] | 4862 | #endif |
---|
[468] | 4863 | |
---|
[331] | 4864 | break; |
---|
| 4865 | } |
---|
| 4866 | ///////////////////// |
---|
[468] | 4867 | case DCACHE_CC_INVAL: // hit inval: switch slot to ZOMBI state and send a |
---|
| 4868 | // CLEANUP after possible invalidation of copies in |
---|
| 4869 | // TLBs |
---|
[331] | 4870 | { |
---|
[789] | 4871 | size_t way = r_dcache_cc_way.read(); |
---|
| 4872 | size_t set = r_dcache_cc_set.read(); |
---|
[331] | 4873 | |
---|
[789] | 4874 | if (r_dcache_in_tlb[way * m_dcache_sets + set]) // selective TLB inval |
---|
[331] | 4875 | { |
---|
[789] | 4876 | r_dcache_in_tlb[way * m_dcache_sets + set] = false; |
---|
| 4877 | r_dcache_tlb_inval_line = r_cc_receive_dcache_nline.read(); |
---|
| 4878 | r_dcache_tlb_inval_set = 0; |
---|
| 4879 | r_dcache_fsm_scan_save = r_dcache_fsm.read(); |
---|
| 4880 | r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; |
---|
[468] | 4881 | break; |
---|
| 4882 | } |
---|
[331] | 4883 | |
---|
[789] | 4884 | if (r_dcache_contains_ptd[way * m_dcache_sets + set]) // TLB flush |
---|
[468] | 4885 | { |
---|
| 4886 | r_itlb.reset(); |
---|
| 4887 | r_dtlb.reset(); |
---|
[789] | 4888 | r_dcache_contains_ptd[way * m_dcache_sets + set] = false; |
---|
[468] | 4889 | |
---|
[331] | 4890 | #if DEBUG_DCACHE |
---|
[789] | 4891 | if (m_debug_dcache_fsm) |
---|
| 4892 | { |
---|
| 4893 | std::cout << " <PROC " << name() |
---|
| 4894 | << " DCACHE_CC_INVAL> Flush DTLB & ITLB" << std::endl; |
---|
| 4895 | } |
---|
[331] | 4896 | #endif |
---|
[468] | 4897 | } |
---|
[331] | 4898 | |
---|
[789] | 4899 | assert(not r_dcache_cc_send_req.read() && |
---|
[468] | 4900 | "ERROR in DCACHE_CC_INVAL: the r_dcache_cc_send_req " |
---|
| 4901 | "must not be set"); |
---|
[331] | 4902 | |
---|
[468] | 4903 | // Switch slot state to ZOMBI and send CLEANUP command |
---|
[789] | 4904 | r_dcache.write_dir(way, |
---|
| 4905 | set, |
---|
| 4906 | CACHE_SLOT_STATE_ZOMBI); |
---|
[331] | 4907 | |
---|
[468] | 4908 | // coherence request completed |
---|
| 4909 | r_cc_receive_dcache_req = false; |
---|
| 4910 | r_dcache_cc_send_req = true; |
---|
| 4911 | r_dcache_cc_send_nline = r_cc_receive_dcache_nline.read(); |
---|
| 4912 | r_dcache_cc_send_way = r_dcache_cc_way.read(); |
---|
| 4913 | r_dcache_cc_send_type = CC_TYPE_CLEANUP; |
---|
| 4914 | r_dcache_fsm = r_dcache_fsm_cc_save.read(); |
---|
| 4915 | |
---|
[331] | 4916 | #if DEBUG_DCACHE |
---|
[789] | 4917 | if (m_debug_dcache_fsm) |
---|
| 4918 | { |
---|
| 4919 | std::cout << " <PROC " << name() |
---|
| 4920 | << " DCACHE_CC_INVAL> Switch slot to EMPTY state:" << std::dec |
---|
| 4921 | << " / WAY = " << way |
---|
| 4922 | << " / SET = " << set << std::endl; |
---|
| 4923 | } |
---|
[331] | 4924 | #endif |
---|
| 4925 | break; |
---|
| 4926 | } |
---|
| 4927 | /////////////////// |
---|
[789] | 4928 | case DCACHE_CC_UPDT: // hit update: write one word per cycle, |
---|
| 4929 | // after possible invalidation of copies in TLBs |
---|
[331] | 4930 | { |
---|
[789] | 4931 | size_t word = r_dcache_cc_word.read(); |
---|
| 4932 | size_t way = r_dcache_cc_way.read(); |
---|
| 4933 | size_t set = r_dcache_cc_set.read(); |
---|
[331] | 4934 | |
---|
[789] | 4935 | if (r_dcache_in_tlb[way * m_dcache_sets + set]) // selective TLB inval |
---|
[331] | 4936 | { |
---|
[789] | 4937 | r_dcache_in_tlb[way * m_dcache_sets + set] = false; |
---|
[468] | 4938 | r_dcache_tlb_inval_line = r_cc_receive_dcache_nline.read(); |
---|
| 4939 | r_dcache_tlb_inval_set = 0; |
---|
| 4940 | r_dcache_fsm_scan_save = r_dcache_fsm.read(); |
---|
| 4941 | r_dcache_fsm = DCACHE_INVAL_TLB_SCAN; |
---|
[331] | 4942 | |
---|
[468] | 4943 | break; |
---|
| 4944 | } |
---|
[331] | 4945 | |
---|
[789] | 4946 | if (r_dcache_contains_ptd[way * m_dcache_sets + set]) // TLB flush |
---|
[468] | 4947 | { |
---|
| 4948 | r_itlb.reset(); |
---|
| 4949 | r_dtlb.reset(); |
---|
[789] | 4950 | r_dcache_contains_ptd[way * m_dcache_sets + set] = false; |
---|
[468] | 4951 | |
---|
[331] | 4952 | #if DEBUG_DCACHE |
---|
[789] | 4953 | if (m_debug_dcache_fsm) |
---|
| 4954 | { |
---|
| 4955 | std::cout << " <PROC " << name() |
---|
| 4956 | << " DCACHE_CC_UPDT> Flush DTLB & ITLB" << std::endl; |
---|
| 4957 | } |
---|
[331] | 4958 | #endif |
---|
[468] | 4959 | } |
---|
[331] | 4960 | |
---|
[468] | 4961 | assert (not r_dcache_cc_send_req.read() && |
---|
| 4962 | "ERROR in DCACHE_CC_INVAL: the r_dcache_cc_send_req " |
---|
| 4963 | "must not be set"); |
---|
| 4964 | |
---|
[789] | 4965 | if (not r_cc_receive_updt_fifo_be.rok()) break; |
---|
[468] | 4966 | |
---|
| 4967 | if (r_dcache_cc_need_write.read()) |
---|
| 4968 | { |
---|
| 4969 | |
---|
[331] | 4970 | #ifdef INSTRUMENTATION |
---|
[789] | 4971 | m_cpt_dcache_data_write++; |
---|
[331] | 4972 | #endif |
---|
[789] | 4973 | r_dcache.write(way, |
---|
| 4974 | set, |
---|
| 4975 | word, |
---|
| 4976 | r_cc_receive_updt_fifo_data.read(), |
---|
| 4977 | r_cc_receive_updt_fifo_be.read()); |
---|
[331] | 4978 | |
---|
[468] | 4979 | r_dcache_cc_word = word + 1; |
---|
[331] | 4980 | |
---|
| 4981 | #if DEBUG_DCACHE |
---|
[789] | 4982 | if (m_debug_dcache_fsm) |
---|
| 4983 | { |
---|
| 4984 | std::cout << " <PROC " << name() |
---|
| 4985 | << " DCACHE_CC_UPDT> Write one word" << std::dec |
---|
| 4986 | << " / WAY = " << way |
---|
| 4987 | << " / SET = " << set |
---|
| 4988 | << " / WORD = " << word |
---|
| 4989 | << " / VALUE = " << std::hex << r_cc_receive_updt_fifo_data.read() << std::endl; |
---|
| 4990 | } |
---|
[331] | 4991 | #endif |
---|
| 4992 | } |
---|
| 4993 | |
---|
[789] | 4994 | if (r_cc_receive_updt_fifo_eop.read()) // last word |
---|
[331] | 4995 | { |
---|
[468] | 4996 | // no need to write in the cache anymore |
---|
| 4997 | r_dcache_cc_need_write = false; |
---|
[331] | 4998 | |
---|
[468] | 4999 | // coherence request completed |
---|
| 5000 | r_cc_receive_dcache_req = false; |
---|
[331] | 5001 | |
---|
[468] | 5002 | // request multicast acknowledgement |
---|
| 5003 | r_dcache_cc_send_req = true; |
---|
| 5004 | r_dcache_cc_send_nline = r_cc_receive_dcache_nline.read(); |
---|
| 5005 | r_dcache_cc_send_updt_tab_idx = r_cc_receive_dcache_updt_tab_idx.read(); |
---|
| 5006 | r_dcache_cc_send_type = CC_TYPE_MULTI_ACK; |
---|
| 5007 | r_dcache_fsm = r_dcache_fsm_cc_save.read(); |
---|
[331] | 5008 | } |
---|
| 5009 | |
---|
[468] | 5010 | //consume fifo if not eop |
---|
| 5011 | cc_receive_updt_fifo_get = true; |
---|
| 5012 | |
---|
[331] | 5013 | break; |
---|
| 5014 | } |
---|
| 5015 | /////////////////////////// |
---|
[789] | 5016 | case DCACHE_INVAL_TLB_SCAN: // Scan sequencially all sets for both ITLB & DTLB |
---|
| 5017 | // It makes assumption: m_itlb_sets == m_dtlb_sets |
---|
| 5018 | // All ways are handled in parallel. |
---|
| 5019 | // We enter this state when a DCACHE line is modified, |
---|
| 5020 | // and there is a copy in itlb or dtlb. |
---|
| 5021 | // It can be caused by: |
---|
| 5022 | // - a coherence inval or updt transaction, |
---|
| 5023 | // - a line inval caused by a cache miss |
---|
| 5024 | // - a processor XTN inval request, |
---|
| 5025 | // - a WRITE hit, |
---|
| 5026 | // - a Dirty bit update |
---|
| 5027 | // Input arguments are: |
---|
| 5028 | // - r_dcache_tlb_inval_line |
---|
| 5029 | // - r_dcache_tlb_inval_set |
---|
| 5030 | // - r_dcache_fsm_scan_save |
---|
[331] | 5031 | { |
---|
[789] | 5032 | paddr_t line = r_dcache_tlb_inval_line.read(); |
---|
| 5033 | size_t set = r_dcache_tlb_inval_set.read(); |
---|
| 5034 | size_t way; |
---|
| 5035 | bool ok; |
---|
[331] | 5036 | |
---|
[789] | 5037 | for (way = 0; way < m_itlb_ways; way++) |
---|
[331] | 5038 | { |
---|
[789] | 5039 | ok = r_itlb.inval(line, way, set); |
---|
[331] | 5040 | |
---|
| 5041 | #if DEBUG_DCACHE |
---|
[789] | 5042 | if (m_debug_dcache_fsm and ok) |
---|
| 5043 | { |
---|
| 5044 | std::cout << " <PROC " << name() |
---|
| 5045 | << ".DCACHE_INVAL_TLB_SCAN> Invalidate ITLB entry:" << std::hex |
---|
| 5046 | << " line = " << line << std::dec |
---|
| 5047 | << " / set = " << set |
---|
| 5048 | << " / way = " << way << std::endl; |
---|
| 5049 | } |
---|
[331] | 5050 | #endif |
---|
| 5051 | } |
---|
| 5052 | |
---|
[789] | 5053 | for (way = 0; way < m_dtlb_ways; way++) |
---|
[331] | 5054 | { |
---|
[789] | 5055 | ok = r_dtlb.inval( line, way, set); |
---|
[331] | 5056 | |
---|
| 5057 | #if DEBUG_DCACHE |
---|
[789] | 5058 | if (m_debug_dcache_fsm and ok) |
---|
| 5059 | std::cout << " <PROC " << name() << " DCACHE_INVAL_TLB_SCAN>" |
---|
| 5060 | << " Invalidate DTLB entry" << std::hex |
---|
| 5061 | << " / line = " << line << std::dec |
---|
| 5062 | << " / set = " << set |
---|
| 5063 | << " / way = " << way << std::endl; |
---|
[331] | 5064 | #endif |
---|
| 5065 | } |
---|
| 5066 | |
---|
| 5067 | // return to the calling state when TLB inval completed |
---|
[789] | 5068 | if (r_dcache_tlb_inval_set.read() == (m_dtlb_sets - 1)) |
---|
[331] | 5069 | { |
---|
| 5070 | r_dcache_fsm = r_dcache_fsm_scan_save.read(); |
---|
| 5071 | } |
---|
| 5072 | r_dcache_tlb_inval_set = r_dcache_tlb_inval_set.read() + 1; |
---|
| 5073 | break; |
---|
| 5074 | } |
---|
| 5075 | } // end switch r_dcache_fsm |
---|
| 5076 | |
---|
| 5077 | ///////////////// wbuf update /////////////////////////////////////////////////////// |
---|
| 5078 | r_wbuf.update(); |
---|
| 5079 | |
---|
| 5080 | ///////////////// llsc update /////////////////////////////////////////////////////// |
---|
| 5081 | if (r_dcache_llsc_valid.read()) r_dcache_llsc_count = r_dcache_llsc_count.read() - 1; |
---|
| 5082 | if (r_dcache_llsc_count.read() == 1) r_dcache_llsc_valid = false; |
---|
| 5083 | |
---|
| 5084 | //////////////// test processor frozen ////////////////////////////////////////////// |
---|
| 5085 | // The simulation exit if the number of consecutive frozen cycles |
---|
| 5086 | // is larger than the m_max_frozen_cycles (constructor parameter) |
---|
[789] | 5087 | if ((m_ireq.valid and not m_irsp.valid) or (m_dreq.valid and not m_drsp.valid)) |
---|
[331] | 5088 | { |
---|
[789] | 5089 | m_cpt_frz_cycles++; // used for instrumentation |
---|
| 5090 | m_cpt_stop_simulation++; // used for debug |
---|
| 5091 | if (m_cpt_stop_simulation > m_max_frozen_cycles) |
---|
[331] | 5092 | { |
---|
| 5093 | std::cout << std::dec << "ERROR in CC_VCACHE_WRAPPER " << name() << std::endl |
---|
| 5094 | << " stop at cycle " << m_cpt_total_cycles << std::endl |
---|
| 5095 | << " frozen since cycle " << m_cpt_total_cycles - m_max_frozen_cycles |
---|
| 5096 | << std::endl; |
---|
| 5097 | r_iss.dump(); |
---|
| 5098 | exit(1); |
---|
| 5099 | } |
---|
| 5100 | } |
---|
| 5101 | else |
---|
| 5102 | { |
---|
| 5103 | m_cpt_stop_simulation = 0; |
---|
| 5104 | } |
---|
| 5105 | |
---|
| 5106 | /////////// execute one iss cycle ///////////////////////////////// |
---|
| 5107 | { |
---|
[789] | 5108 | uint32_t it = 0; |
---|
| 5109 | for (size_t i = 0; i < (size_t) iss_t::n_irq; i++) if (p_irq[i].read()) it |= (1 << i); |
---|
| 5110 | r_iss.executeNCycles(1, m_irsp, m_drsp, it); |
---|
[331] | 5111 | } |
---|
| 5112 | |
---|
| 5113 | //////////////////////////////////////////////////////////////////////////// |
---|
| 5114 | // The VCI_CMD FSM controls the following ressources: |
---|
| 5115 | // - r_vci_cmd_fsm |
---|
| 5116 | // - r_vci_cmd_min |
---|
| 5117 | // - r_vci_cmd_max |
---|
| 5118 | // - r_vci_cmd_cpt |
---|
| 5119 | // - r_vci_cmd_imiss_prio |
---|
| 5120 | // - wbuf (reset) |
---|
| 5121 | // - r_icache_miss_req (reset) |
---|
| 5122 | // - r_icache_unc_req (reset) |
---|
| 5123 | // - r_dcache_vci_miss_req (reset) |
---|
| 5124 | // - r_dcache_vci_unc_req (reset) |
---|
| 5125 | // - r_dcache_vci_ll_req (reset) |
---|
| 5126 | // - r_dcache_vci_sc_req (reset in case of local sc fail) |
---|
| 5127 | // - r_dcache_vci_cas_req (reset) |
---|
| 5128 | // |
---|
| 5129 | // This FSM handles requests from both the DCACHE FSM & the ICACHE FSM. |
---|
| 5130 | // There are 8 request types, with the following priorities : |
---|
| 5131 | // 1 - Data Read Miss : r_dcache_vci_miss_req and miss in the write buffer |
---|
| 5132 | // 2 - Data Read Uncachable : r_dcache_vci_unc_req |
---|
| 5133 | // 3 - Instruction Miss : r_icache_miss_req and miss in the write buffer |
---|
| 5134 | // 4 - Instruction Uncachable : r_icache_unc_req |
---|
| 5135 | // 5 - Data Write : r_wbuf.rok() |
---|
| 5136 | // 6 - Data Linked Load : r_dcache_vci_ll_req |
---|
| 5137 | // 7 - Data Store Conditionnal: r_dcache_vci_sc_req |
---|
| 5138 | // 8 - Compare And Swap : r_dcache_vci_cas_req |
---|
| 5139 | // |
---|
| 5140 | // As we want to support several simultaneous VCI transactions, the VCI_CMD_FSM |
---|
| 5141 | // and the VCI_RSP_FSM are fully desynchronized. |
---|
| 5142 | // |
---|
| 5143 | // VCI formats: |
---|
| 5144 | // According to the VCI advanced specification, all read requests packets |
---|
| 5145 | // (data Uncached, Miss data, instruction Uncached, Miss instruction) |
---|
| 5146 | // are one word packets. |
---|
| 5147 | // For write burst packets, all words are in the same cache line, |
---|
| 5148 | // and addresses must be contiguous (the BE field is 0 in case of "holes"). |
---|
| 5149 | // The sc command packet implements actually a compare-and-swap mechanism |
---|
| 5150 | // and the packet contains two flits. |
---|
| 5151 | //////////////////////////////////////////////////////////////////////////////////// |
---|
| 5152 | |
---|
[423] | 5153 | |
---|
[789] | 5154 | switch (r_vci_cmd_fsm.read()) |
---|
[331] | 5155 | { |
---|
| 5156 | ////////////// |
---|
| 5157 | case CMD_IDLE: |
---|
| 5158 | { |
---|
[394] | 5159 | // DCACHE read requests (r_dcache_vci_miss_req or r_dcache_vci_ll_req), and |
---|
[331] | 5160 | // ICACHE read requests (r_icache_miss_req) require both a write_buffer access |
---|
| 5161 | // to check a possible pending write on the same cache line. |
---|
| 5162 | // As there is only one possible access per cycle to write buffer, we implement |
---|
| 5163 | // a round-robin priority between DCACHE and ICACHE for this access, |
---|
| 5164 | // using the r_vci_cmd_imiss_prio flip-flop. |
---|
| 5165 | |
---|
[789] | 5166 | size_t wbuf_min; |
---|
| 5167 | size_t wbuf_max; |
---|
[331] | 5168 | |
---|
| 5169 | bool dcache_miss_req = r_dcache_vci_miss_req.read() and |
---|
[789] | 5170 | (not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read()); |
---|
[331] | 5171 | |
---|
[789] | 5172 | bool dcache_ll_req = r_dcache_vci_ll_req.read() and |
---|
| 5173 | (not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read()); |
---|
[331] | 5174 | |
---|
[789] | 5175 | bool dcache_sc_req = r_dcache_vci_sc_req.read() and |
---|
| 5176 | (not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read()); |
---|
[616] | 5177 | |
---|
[789] | 5178 | bool dcache_cas_req = r_dcache_vci_cas_req.read() and |
---|
| 5179 | (not r_icache_miss_req.read() or not r_vci_cmd_imiss_prio.read()); |
---|
[616] | 5180 | |
---|
[331] | 5181 | bool icache_miss_req = r_icache_miss_req.read() and |
---|
[789] | 5182 | (not (r_dcache_vci_miss_req.read() or |
---|
| 5183 | r_dcache_vci_ll_req.read() or |
---|
| 5184 | r_dcache_vci_cas_req.read() or |
---|
| 5185 | r_dcache_vci_sc_req.read()) or |
---|
| 5186 | r_vci_cmd_imiss_prio.read()); |
---|
[331] | 5187 | |
---|
[616] | 5188 | // 1 - Data unc write |
---|
[789] | 5189 | if (r_dcache_vci_unc_req.read() and r_dcache_vci_unc_write.read()) |
---|
[331] | 5190 | { |
---|
[616] | 5191 | r_vci_cmd_fsm = CMD_DATA_UNC_WRITE; |
---|
| 5192 | r_dcache_vci_unc_req = false; |
---|
| 5193 | } |
---|
| 5194 | // 2 data read miss |
---|
[789] | 5195 | else if (dcache_miss_req and r_wbuf.miss(r_dcache_vci_paddr.read())) |
---|
[616] | 5196 | { |
---|
[331] | 5197 | r_vci_cmd_fsm = CMD_DATA_MISS; |
---|
| 5198 | r_dcache_vci_miss_req = false; |
---|
| 5199 | r_vci_cmd_imiss_prio = true; |
---|
| 5200 | } |
---|
[616] | 5201 | // 3 - Data Read Uncachable |
---|
[789] | 5202 | else if (r_dcache_vci_unc_req.read() and not r_dcache_vci_unc_write.read()) |
---|
[331] | 5203 | { |
---|
[616] | 5204 | r_vci_cmd_fsm = CMD_DATA_UNC_READ; |
---|
[331] | 5205 | r_dcache_vci_unc_req = false; |
---|
| 5206 | } |
---|
[616] | 5207 | // 4 - Data Linked Load |
---|
[789] | 5208 | else if (dcache_ll_req and r_wbuf.miss(r_dcache_vci_paddr.read())) |
---|
[331] | 5209 | { |
---|
[616] | 5210 | r_vci_cmd_fsm = CMD_DATA_LL; |
---|
| 5211 | r_dcache_vci_ll_req = false; |
---|
| 5212 | r_vci_cmd_imiss_prio = true; |
---|
[331] | 5213 | } |
---|
[616] | 5214 | // 5 - Instruction Miss |
---|
[789] | 5215 | else if (icache_miss_req and r_wbuf.miss(r_icache_vci_paddr.read())) |
---|
[331] | 5216 | { |
---|
| 5217 | r_vci_cmd_fsm = CMD_INS_MISS; |
---|
| 5218 | r_icache_miss_req = false; |
---|
| 5219 | r_vci_cmd_imiss_prio = false; |
---|
| 5220 | } |
---|
[616] | 5221 | // 6 - Instruction Uncachable |
---|
[789] | 5222 | else if (r_icache_unc_req.read()) |
---|
[331] | 5223 | { |
---|
[789] | 5224 | r_vci_cmd_fsm = CMD_INS_UNC; |
---|
| 5225 | r_icache_unc_req = false; |
---|
[331] | 5226 | } |
---|
[616] | 5227 | // 7 - Data Write |
---|
[789] | 5228 | else if (r_wbuf.rok(&wbuf_min, &wbuf_max)) |
---|
[331] | 5229 | { |
---|
[789] | 5230 | r_vci_cmd_fsm = CMD_DATA_WRITE; |
---|
| 5231 | r_vci_cmd_cpt = wbuf_min; |
---|
| 5232 | r_vci_cmd_min = wbuf_min; |
---|
| 5233 | r_vci_cmd_max = wbuf_max; |
---|
[331] | 5234 | } |
---|
[616] | 5235 | // 8 - Data Store Conditionnal |
---|
[789] | 5236 | else if (dcache_sc_req and r_wbuf.miss(r_dcache_vci_paddr.read())) |
---|
[331] | 5237 | { |
---|
[789] | 5238 | r_vci_cmd_fsm = CMD_DATA_SC; |
---|
| 5239 | r_dcache_vci_sc_req = false; |
---|
| 5240 | r_vci_cmd_imiss_prio = true; |
---|
| 5241 | r_vci_cmd_cpt = 0; |
---|
[331] | 5242 | } |
---|
[616] | 5243 | // 9 - Compare And Swap |
---|
[789] | 5244 | else if (dcache_cas_req and r_wbuf.miss(r_dcache_vci_paddr.read())) |
---|
[331] | 5245 | { |
---|
[789] | 5246 | r_vci_cmd_fsm = CMD_DATA_CAS; |
---|
| 5247 | r_dcache_vci_cas_req = false; |
---|
| 5248 | r_vci_cmd_imiss_prio = true; |
---|
| 5249 | r_vci_cmd_cpt = 0; |
---|
[331] | 5250 | } |
---|
[394] | 5251 | |
---|
| 5252 | #if DEBUG_CMD |
---|
[789] | 5253 | if (m_debug_cmd_fsm ) |
---|
| 5254 | { |
---|
| 5255 | std::cout << " <PROC " << name() << " CMD_IDLE>" |
---|
| 5256 | << " / dmiss_req = " << dcache_miss_req |
---|
| 5257 | << " / imiss_req = " << icache_miss_req |
---|
| 5258 | << std::endl; |
---|
| 5259 | } |
---|
[394] | 5260 | #endif |
---|
[331] | 5261 | break; |
---|
| 5262 | } |
---|
| 5263 | //////////////////// |
---|
| 5264 | case CMD_DATA_WRITE: |
---|
| 5265 | { |
---|
[789] | 5266 | if (p_vci.cmdack.read()) |
---|
[331] | 5267 | { |
---|
| 5268 | r_vci_cmd_cpt = r_vci_cmd_cpt + 1; |
---|
| 5269 | if (r_vci_cmd_cpt == r_vci_cmd_max) // last flit sent |
---|
| 5270 | { |
---|
[789] | 5271 | r_vci_cmd_fsm = CMD_IDLE; |
---|
| 5272 | r_wbuf.sent(); |
---|
[331] | 5273 | } |
---|
| 5274 | } |
---|
| 5275 | break; |
---|
| 5276 | } |
---|
| 5277 | ///////////////// |
---|
| 5278 | case CMD_DATA_SC: |
---|
| 5279 | case CMD_DATA_CAS: |
---|
| 5280 | { |
---|
| 5281 | // The CAS and SC VCI commands contain two flits |
---|
[789] | 5282 | if (p_vci.cmdack.read()) |
---|
[331] | 5283 | { |
---|
| 5284 | r_vci_cmd_cpt = r_vci_cmd_cpt + 1; |
---|
| 5285 | if (r_vci_cmd_cpt == 1) r_vci_cmd_fsm = CMD_IDLE ; |
---|
| 5286 | } |
---|
| 5287 | break; |
---|
| 5288 | } |
---|
| 5289 | ////////////////// |
---|
| 5290 | case CMD_INS_MISS: |
---|
| 5291 | case CMD_INS_UNC: |
---|
| 5292 | case CMD_DATA_MISS: |
---|
[616] | 5293 | case CMD_DATA_UNC_READ: |
---|
| 5294 | case CMD_DATA_UNC_WRITE: |
---|
[331] | 5295 | case CMD_DATA_LL: |
---|
| 5296 | { |
---|
| 5297 | // all read VCI commands contain one single flit |
---|
[789] | 5298 | if (p_vci.cmdack.read()) { |
---|
[423] | 5299 | r_vci_cmd_fsm = CMD_IDLE; |
---|
| 5300 | } |
---|
[331] | 5301 | break; |
---|
| 5302 | } |
---|
| 5303 | |
---|
| 5304 | } // end switch r_vci_cmd_fsm |
---|
| 5305 | |
---|
| 5306 | ////////////////////////////////////////////////////////////////////////// |
---|
| 5307 | // The VCI_RSP FSM controls the following ressources: |
---|
| 5308 | // - r_vci_rsp_fsm: |
---|
| 5309 | // - r_vci_rsp_fifo_icache (push) |
---|
| 5310 | // - r_vci_rsp_fifo_dcache (push) |
---|
| 5311 | // - r_vci_rsp_data_error (set) |
---|
| 5312 | // - r_vci_rsp_ins_error (set) |
---|
| 5313 | // - r_vci_rsp_cpt |
---|
| 5314 | // - r_dcache_vci_sc_req (reset when SC response recieved) |
---|
| 5315 | // |
---|
| 5316 | // As the VCI_RSP and VCI_CMD are fully desynchronized to support several |
---|
| 5317 | // simultaneous VCI transactions, this FSM uses the VCI RPKTID field |
---|
| 5318 | // to identify the transactions. |
---|
| 5319 | // |
---|
| 5320 | // VCI vormat: |
---|
| 5321 | // This component checks the response packet length and accepts only |
---|
| 5322 | // single word packets for write response packets. |
---|
| 5323 | // |
---|
| 5324 | // Error handling: |
---|
| 5325 | // This FSM analyzes the VCI error code and signals directly the Write Bus Error. |
---|
| 5326 | // In case of Read Data Error, the VCI_RSP FSM sets the r_vci_rsp_data_error |
---|
| 5327 | // flip_flop and the error is signaled by the DCACHE FSM. |
---|
| 5328 | // In case of Instruction Error, the VCI_RSP FSM sets the r_vci_rsp_ins_error |
---|
| 5329 | // flip_flop and the error is signaled by the ICACHE FSM. |
---|
| 5330 | // In case of Cleanup Error, the simulation stops with an error message... |
---|
| 5331 | ////////////////////////////////////////////////////////////////////////// |
---|
| 5332 | |
---|
[789] | 5333 | switch (r_vci_rsp_fsm.read()) |
---|
[331] | 5334 | { |
---|
| 5335 | ////////////// |
---|
| 5336 | case RSP_IDLE: |
---|
| 5337 | { |
---|
[789] | 5338 | if (p_vci.rspval.read()) |
---|
[331] | 5339 | { |
---|
| 5340 | r_vci_rsp_cpt = 0; |
---|
| 5341 | |
---|
[789] | 5342 | if ((p_vci.rpktid.read() & 0x7) == TYPE_DATA_UNC) |
---|
[331] | 5343 | { |
---|
| 5344 | r_vci_rsp_fsm = RSP_DATA_UNC; |
---|
| 5345 | } |
---|
[789] | 5346 | else if ((p_vci.rpktid.read() & 0x7) == TYPE_READ_DATA_MISS) |
---|
[331] | 5347 | { |
---|
| 5348 | r_vci_rsp_fsm = RSP_DATA_MISS; |
---|
| 5349 | } |
---|
[789] | 5350 | else if ((p_vci.rpktid.read() & 0x7) == TYPE_READ_INS_UNC) |
---|
[331] | 5351 | { |
---|
| 5352 | r_vci_rsp_fsm = RSP_INS_UNC; |
---|
| 5353 | } |
---|
[789] | 5354 | else if ((p_vci.rpktid.read() & 0x7) == TYPE_READ_INS_MISS) |
---|
[331] | 5355 | { |
---|
| 5356 | r_vci_rsp_fsm = RSP_INS_MISS; |
---|
| 5357 | } |
---|
[789] | 5358 | else if ((p_vci.rpktid.read() & 0x7) == TYPE_WRITE) |
---|
[331] | 5359 | { |
---|
| 5360 | r_vci_rsp_fsm = RSP_DATA_WRITE; |
---|
| 5361 | } |
---|
[789] | 5362 | else if ((p_vci.rpktid.read() & 0x7) == TYPE_CAS) |
---|
[331] | 5363 | { |
---|
| 5364 | r_vci_rsp_fsm = RSP_DATA_UNC; |
---|
| 5365 | } |
---|
[789] | 5366 | else if ((p_vci.rpktid.read() & 0x7) == TYPE_LL) |
---|
[331] | 5367 | { |
---|
| 5368 | r_vci_rsp_fsm = RSP_DATA_LL; |
---|
| 5369 | } |
---|
[789] | 5370 | else if ((p_vci.rpktid.read() & 0x7) == TYPE_SC) |
---|
[331] | 5371 | { |
---|
| 5372 | r_vci_rsp_fsm = RSP_DATA_UNC; |
---|
| 5373 | } |
---|
| 5374 | else |
---|
| 5375 | { |
---|
| 5376 | assert(false and "Unexpected VCI response"); |
---|
| 5377 | } |
---|
| 5378 | } |
---|
| 5379 | break; |
---|
| 5380 | } |
---|
| 5381 | ////////////////// |
---|
| 5382 | case RSP_INS_MISS: |
---|
| 5383 | { |
---|
[789] | 5384 | if (p_vci.rspval.read()) |
---|
[331] | 5385 | { |
---|
[789] | 5386 | if ((p_vci.rerror.read() & 0x1) != 0) // error reported |
---|
[331] | 5387 | { |
---|
| 5388 | r_vci_rsp_ins_error = true; |
---|
[789] | 5389 | if (p_vci.reop.read()) r_vci_rsp_fsm = RSP_IDLE; |
---|
[331] | 5390 | } |
---|
| 5391 | else // no error reported |
---|
| 5392 | { |
---|
[789] | 5393 | if (r_vci_rsp_fifo_icache.wok()) |
---|
[331] | 5394 | { |
---|
[789] | 5395 | if (r_vci_rsp_cpt.read() >= m_icache_words) |
---|
[473] | 5396 | { |
---|
| 5397 | std::cout << "ERROR in VCI_CC_VCACHE " << name() |
---|
| 5398 | << " VCI response packet too long " |
---|
| 5399 | << " for instruction miss" << std::endl; |
---|
| 5400 | exit(0); |
---|
| 5401 | } |
---|
[789] | 5402 | r_vci_rsp_cpt = r_vci_rsp_cpt.read() + 1; |
---|
| 5403 | vci_rsp_fifo_icache_put = true, |
---|
| 5404 | vci_rsp_fifo_icache_data = p_vci.rdata.read(); |
---|
| 5405 | if (p_vci.reop.read()) |
---|
[331] | 5406 | { |
---|
[789] | 5407 | if (r_vci_rsp_cpt.read() != (m_icache_words - 1)) |
---|
[473] | 5408 | { |
---|
| 5409 | std::cout << "ERROR in VCI_CC_VCACHE " << name() |
---|
| 5410 | << " VCI response packet too short" |
---|
| 5411 | << " for instruction miss" << std::endl; |
---|
| 5412 | exit(0); |
---|
| 5413 | } |
---|
[789] | 5414 | r_vci_rsp_fsm = RSP_IDLE; |
---|
[331] | 5415 | } |
---|
| 5416 | } |
---|
| 5417 | } |
---|
| 5418 | } |
---|
| 5419 | break; |
---|
| 5420 | } |
---|
| 5421 | ///////////////// |
---|
| 5422 | case RSP_INS_UNC: |
---|
| 5423 | { |
---|
[789] | 5424 | if (p_vci.rspval.read()) |
---|
[331] | 5425 | { |
---|
[789] | 5426 | assert(p_vci.reop.read() and |
---|
[331] | 5427 | "illegal VCI response packet for uncachable instruction"); |
---|
| 5428 | |
---|
[789] | 5429 | if ((p_vci.rerror.read() & 0x1) != 0) // error reported |
---|
[331] | 5430 | { |
---|
| 5431 | r_vci_rsp_ins_error = true; |
---|
| 5432 | r_vci_rsp_fsm = RSP_IDLE; |
---|
| 5433 | } |
---|
| 5434 | else // no error reported |
---|
| 5435 | { |
---|
[789] | 5436 | if (r_vci_rsp_fifo_icache.wok()) |
---|
[331] | 5437 | { |
---|
[789] | 5438 | vci_rsp_fifo_icache_put = true; |
---|
| 5439 | vci_rsp_fifo_icache_data = p_vci.rdata.read(); |
---|
[331] | 5440 | r_vci_rsp_fsm = RSP_IDLE; |
---|
| 5441 | } |
---|
| 5442 | } |
---|
| 5443 | } |
---|
| 5444 | break; |
---|
| 5445 | } |
---|
| 5446 | /////////////////// |
---|
| 5447 | case RSP_DATA_MISS: |
---|
| 5448 | { |
---|
[789] | 5449 | if (p_vci.rspval.read()) |
---|
[331] | 5450 | { |
---|
[789] | 5451 | if ((p_vci.rerror.read() & 0x1) != 0) // error reported |
---|
[331] | 5452 | { |
---|
| 5453 | r_vci_rsp_data_error = true; |
---|
[789] | 5454 | if (p_vci.reop.read()) r_vci_rsp_fsm = RSP_IDLE; |
---|
[331] | 5455 | } |
---|
| 5456 | else // no error reported |
---|
| 5457 | { |
---|
[789] | 5458 | if (r_vci_rsp_fifo_dcache.wok()) |
---|
[331] | 5459 | { |
---|
[789] | 5460 | assert((r_vci_rsp_cpt.read() < m_dcache_words) and |
---|
[331] | 5461 | "The VCI response packet for data miss is too long"); |
---|
| 5462 | |
---|
[789] | 5463 | r_vci_rsp_cpt = r_vci_rsp_cpt.read() + 1; |
---|
| 5464 | vci_rsp_fifo_dcache_put = true, |
---|
| 5465 | vci_rsp_fifo_dcache_data = p_vci.rdata.read(); |
---|
| 5466 | if (p_vci.reop.read()) |
---|
[331] | 5467 | { |
---|
[789] | 5468 | assert((r_vci_rsp_cpt.read() == m_dcache_words - 1) and |
---|
[331] | 5469 | "The VCI response packet for data miss is too short"); |
---|
| 5470 | |
---|
[789] | 5471 | r_vci_rsp_fsm = RSP_IDLE; |
---|
[331] | 5472 | } |
---|
| 5473 | } |
---|
| 5474 | } |
---|
| 5475 | } |
---|
| 5476 | break; |
---|
| 5477 | } |
---|
| 5478 | ////////////////// |
---|
| 5479 | case RSP_DATA_UNC: |
---|
| 5480 | { |
---|
[789] | 5481 | if (p_vci.rspval.read()) |
---|
[331] | 5482 | { |
---|
[789] | 5483 | assert(p_vci.reop.read() and |
---|
[331] | 5484 | "illegal VCI response packet for uncachable read data"); |
---|
| 5485 | |
---|
[789] | 5486 | if ((p_vci.rerror.read() & 0x1) != 0) // error reported |
---|
[331] | 5487 | { |
---|
| 5488 | r_vci_rsp_data_error = true; |
---|
| 5489 | r_vci_rsp_fsm = RSP_IDLE; |
---|
| 5490 | } |
---|
[789] | 5491 | else // no error reported |
---|
[331] | 5492 | { |
---|
[789] | 5493 | if (r_vci_rsp_fifo_dcache.wok()) |
---|
[331] | 5494 | { |
---|
[789] | 5495 | vci_rsp_fifo_dcache_put = true; |
---|
| 5496 | vci_rsp_fifo_dcache_data = p_vci.rdata.read(); |
---|
[331] | 5497 | r_vci_rsp_fsm = RSP_IDLE; |
---|
| 5498 | } |
---|
| 5499 | } |
---|
| 5500 | } |
---|
| 5501 | break; |
---|
| 5502 | } |
---|
[434] | 5503 | ///////////////// |
---|
[331] | 5504 | case RSP_DATA_LL: |
---|
| 5505 | { |
---|
[789] | 5506 | if (p_vci.rspval.read()) |
---|
[331] | 5507 | { |
---|
[789] | 5508 | if ((p_vci.rerror.read() & 0x1) != 0) // error reported |
---|
[331] | 5509 | { |
---|
| 5510 | r_vci_rsp_data_error = true; |
---|
| 5511 | r_vci_rsp_fsm = RSP_IDLE; |
---|
[434] | 5512 | break; |
---|
[331] | 5513 | } |
---|
| 5514 | if (r_vci_rsp_cpt.read() == 0) //first flit |
---|
| 5515 | { |
---|
[789] | 5516 | if (r_vci_rsp_fifo_dcache.wok()) |
---|
[331] | 5517 | { |
---|
[346] | 5518 | assert(!p_vci.reop.read() && |
---|
[331] | 5519 | "illegal VCI response packet for LL"); |
---|
| 5520 | vci_rsp_fifo_dcache_put = true; |
---|
[346] | 5521 | vci_rsp_fifo_dcache_data = p_vci.rdata.read(); |
---|
[331] | 5522 | r_vci_rsp_cpt = r_vci_rsp_cpt.read() + 1; |
---|
| 5523 | } |
---|
| 5524 | break; |
---|
| 5525 | } |
---|
| 5526 | else // last flit |
---|
| 5527 | { |
---|
[789] | 5528 | if (r_vci_rsp_fifo_dcache.wok()) |
---|
[331] | 5529 | { |
---|
[346] | 5530 | assert(p_vci.reop.read() && |
---|
[331] | 5531 | "illegal VCI response packet for LL"); |
---|
| 5532 | vci_rsp_fifo_dcache_put = true; |
---|
[346] | 5533 | vci_rsp_fifo_dcache_data = p_vci.rdata.read(); |
---|
[331] | 5534 | r_vci_rsp_fsm = RSP_IDLE; |
---|
| 5535 | } |
---|
| 5536 | break; |
---|
| 5537 | } |
---|
| 5538 | } |
---|
| 5539 | break; |
---|
| 5540 | } |
---|
| 5541 | //////////////////// |
---|
| 5542 | case RSP_DATA_WRITE: |
---|
| 5543 | { |
---|
[346] | 5544 | if (p_vci.rspval.read()) |
---|
[331] | 5545 | { |
---|
[789] | 5546 | assert(p_vci.reop.read() and |
---|
[331] | 5547 | "a VCI response packet must contain one flit for a write transaction"); |
---|
| 5548 | |
---|
| 5549 | r_vci_rsp_fsm = RSP_IDLE; |
---|
[789] | 5550 | uint32_t wbuf_index = p_vci.rtrdid.read(); |
---|
[616] | 5551 | r_wbuf.completed(wbuf_index); |
---|
[789] | 5552 | if ((p_vci.rerror.read() & 0x1) != 0) r_iss.setWriteBerr(); |
---|
[331] | 5553 | } |
---|
| 5554 | break; |
---|
| 5555 | } |
---|
| 5556 | } // end switch r_vci_rsp_fsm |
---|
| 5557 | |
---|
| 5558 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
| 5559 | // The CC_SEND FSM is in charge of sending cleanups and the multicast |
---|
| 5560 | // acknowledgements on the coherence network. It has two clients (DCACHE FSM |
---|
| 5561 | // and ICACHE FSM) that are served with a round-robin priority. |
---|
| 5562 | // The CC_SEND FSM resets the r_*cache_cc_send_req request flip-flops as |
---|
| 5563 | // soon as the request has been sent. |
---|
| 5564 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
[789] | 5565 | switch (r_cc_send_fsm.read()) |
---|
[331] | 5566 | { |
---|
| 5567 | /////////////////////////// |
---|
| 5568 | case CC_SEND_IDLE: |
---|
| 5569 | { |
---|
| 5570 | /////////////////////////////////////////////////////// |
---|
| 5571 | // handling round robin between icache and dcache : // |
---|
| 5572 | // we first check for the last client and listen for // |
---|
| 5573 | // a request of the other, then update the client // |
---|
[386] | 5574 | // r_cc_send_last_client : 0 dcache / 1 icache |
---|
[331] | 5575 | /////////////////////////////////////////////////////// |
---|
[333] | 5576 | bool update_last_client = r_cc_send_last_client.read(); |
---|
[789] | 5577 | if (r_cc_send_last_client.read() == 0) // last client was dcache |
---|
[331] | 5578 | { |
---|
[333] | 5579 | if (r_icache_cc_send_req.read()) // request from icache |
---|
[331] | 5580 | update_last_client = 1; // update last client to icache |
---|
| 5581 | } |
---|
| 5582 | else // last client was icache |
---|
| 5583 | { |
---|
[333] | 5584 | if (r_dcache_cc_send_req.read()) // request from dcache |
---|
[331] | 5585 | update_last_client = 0; // update last client to dcache |
---|
| 5586 | } |
---|
| 5587 | r_cc_send_last_client = update_last_client; |
---|
| 5588 | |
---|
| 5589 | // if there is an actual request |
---|
| 5590 | if (r_dcache_cc_send_req.read() or r_icache_cc_send_req.read()) |
---|
| 5591 | { |
---|
[386] | 5592 | // the new client is dcache and has a cleanup request |
---|
[789] | 5593 | if ((update_last_client == 0) and |
---|
[386] | 5594 | (r_dcache_cc_send_type.read() == CC_TYPE_CLEANUP)) |
---|
[331] | 5595 | r_cc_send_fsm = CC_SEND_CLEANUP_1; |
---|
[386] | 5596 | // the new client is dcache and has a multi acknowledgement request |
---|
[789] | 5597 | else if ((update_last_client == 0) and |
---|
[386] | 5598 | (r_dcache_cc_send_type.read() == CC_TYPE_MULTI_ACK)) |
---|
[331] | 5599 | r_cc_send_fsm = CC_SEND_MULTI_ACK; |
---|
[386] | 5600 | // the new client is icache and has a cleanup request |
---|
[789] | 5601 | else if ((update_last_client == 1) and |
---|
[386] | 5602 | (r_icache_cc_send_type.read() == CC_TYPE_CLEANUP)) |
---|
[331] | 5603 | r_cc_send_fsm = CC_SEND_CLEANUP_1; |
---|
[386] | 5604 | // the new client is icache and has a multi acknowledgement request |
---|
[789] | 5605 | else if ((update_last_client == 1) and |
---|
[386] | 5606 | (r_icache_cc_send_type.read() == CC_TYPE_MULTI_ACK)) |
---|
[331] | 5607 | r_cc_send_fsm = CC_SEND_MULTI_ACK; |
---|
| 5608 | } |
---|
| 5609 | break; |
---|
| 5610 | } |
---|
| 5611 | /////////////////////////// |
---|
| 5612 | case CC_SEND_CLEANUP_1: |
---|
| 5613 | { |
---|
| 5614 | // wait for the first flit to be consumed |
---|
[468] | 5615 | if (p_dspin_p2m.read.read()) |
---|
[331] | 5616 | r_cc_send_fsm = CC_SEND_CLEANUP_2; |
---|
| 5617 | |
---|
| 5618 | break; |
---|
| 5619 | } |
---|
| 5620 | /////////////////////////// |
---|
| 5621 | case CC_SEND_CLEANUP_2: |
---|
| 5622 | { |
---|
| 5623 | // wait for the second flit to be consumed |
---|
[468] | 5624 | if (p_dspin_p2m.read.read()) |
---|
[331] | 5625 | { |
---|
[333] | 5626 | if (r_cc_send_last_client.read() == 0) // dcache active request |
---|
[331] | 5627 | r_dcache_cc_send_req = false; // reset dcache request |
---|
| 5628 | else // icache active request |
---|
| 5629 | r_icache_cc_send_req = false; // reset icache request |
---|
| 5630 | |
---|
| 5631 | // go back to idle state |
---|
| 5632 | r_cc_send_fsm = CC_SEND_IDLE; |
---|
| 5633 | } |
---|
| 5634 | break; |
---|
| 5635 | } |
---|
| 5636 | /////////////////////////// |
---|
| 5637 | case CC_SEND_MULTI_ACK: |
---|
| 5638 | { |
---|
| 5639 | // wait for the flit to be consumed |
---|
[789] | 5640 | if (p_dspin_p2m.read.read()) |
---|
[331] | 5641 | { |
---|
[789] | 5642 | if (r_cc_send_last_client.read() == 0) // dcache active request |
---|
[331] | 5643 | r_dcache_cc_send_req = false; // reset dcache request |
---|
| 5644 | else // icache active request |
---|
| 5645 | r_icache_cc_send_req = false; // reset icache request |
---|
| 5646 | // go back to idle state |
---|
| 5647 | r_cc_send_fsm = CC_SEND_IDLE; |
---|
| 5648 | } |
---|
| 5649 | break; |
---|
| 5650 | } |
---|
| 5651 | } // end switch CC_SEND FSM |
---|
| 5652 | |
---|
| 5653 | /////////////////////////////////////////////////////////////////////////////// |
---|
[468] | 5654 | // CC_RECEIVE FSM |
---|
[331] | 5655 | // This FSM receive all coherence packets on a DSPIN40 port. |
---|
[468] | 5656 | // There is 5 packet types: |
---|
[331] | 5657 | // - CC_DATA_INVAL : DCACHE invalidate request |
---|
| 5658 | // - CC_DATA_UPDT : DCACHE update request (multi-words) |
---|
| 5659 | // - CC_INST_INVAL : ICACHE invalidate request |
---|
| 5660 | // - CC_INST_UPDT : ICACHE update request (multi-words) |
---|
| 5661 | // - CC_BROADCAST : Broadcast invalidate request (both DCACHE & ICACHE) |
---|
| 5662 | ////////////////////////////////////////////////////////////////////////////// |
---|
[789] | 5663 | switch (r_cc_receive_fsm.read()) |
---|
[331] | 5664 | { |
---|
| 5665 | ///////////////////// |
---|
| 5666 | case CC_RECEIVE_IDLE: |
---|
| 5667 | { |
---|
| 5668 | // a coherence request has arrived |
---|
[468] | 5669 | if (p_dspin_m2p.write.read()) |
---|
[331] | 5670 | { |
---|
| 5671 | // initialize dspin received data |
---|
[468] | 5672 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
[331] | 5673 | // initialize coherence packet type |
---|
[386] | 5674 | uint64_t receive_type = DspinDhccpParam::dspin_get(receive_data, |
---|
[468] | 5675 | DspinDhccpParam::M2P_TYPE); |
---|
[331] | 5676 | // test for a broadcast |
---|
[468] | 5677 | if (DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::M2P_BC)) |
---|
[331] | 5678 | { |
---|
| 5679 | r_cc_receive_fsm = CC_RECEIVE_BRDCAST_HEADER; |
---|
| 5680 | } |
---|
[468] | 5681 | // test for a multi updt |
---|
| 5682 | else if (receive_type == DspinDhccpParam::TYPE_MULTI_UPDT_DATA) |
---|
[331] | 5683 | { |
---|
[468] | 5684 | r_cc_receive_fsm = CC_RECEIVE_DATA_UPDT_HEADER; |
---|
[331] | 5685 | } |
---|
[468] | 5686 | else if (receive_type == DspinDhccpParam::TYPE_MULTI_UPDT_INST) |
---|
[331] | 5687 | { |
---|
[468] | 5688 | r_cc_receive_fsm = CC_RECEIVE_INS_UPDT_HEADER; |
---|
[331] | 5689 | } |
---|
| 5690 | // test for a multi inval |
---|
[468] | 5691 | else if (receive_type == DspinDhccpParam::TYPE_MULTI_INVAL_DATA) |
---|
| 5692 | { |
---|
| 5693 | r_cc_receive_fsm = CC_RECEIVE_DATA_INVAL_HEADER; |
---|
| 5694 | } |
---|
[331] | 5695 | else |
---|
| 5696 | { |
---|
[468] | 5697 | r_cc_receive_fsm = CC_RECEIVE_INS_INVAL_HEADER; |
---|
[331] | 5698 | } |
---|
| 5699 | } |
---|
| 5700 | break; |
---|
| 5701 | } |
---|
| 5702 | /////////////////////////////// |
---|
| 5703 | case CC_RECEIVE_BRDCAST_HEADER: |
---|
| 5704 | { |
---|
| 5705 | // no actual data in the HEADER, just skip to second flit |
---|
| 5706 | r_cc_receive_fsm = CC_RECEIVE_BRDCAST_NLINE; |
---|
| 5707 | break; |
---|
| 5708 | } |
---|
| 5709 | ////////////////////////////// |
---|
| 5710 | case CC_RECEIVE_BRDCAST_NLINE: |
---|
| 5711 | { |
---|
| 5712 | // initialize dspin received data |
---|
[468] | 5713 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
[331] | 5714 | // wait for both dcache and icache to take the request |
---|
| 5715 | // TODO maybe we need to wait for both only to leave the state, but |
---|
| 5716 | // not to actually post a request to an available cache => need a |
---|
| 5717 | // flip_flop to check that ? |
---|
[386] | 5718 | if (not (r_cc_receive_icache_req.read()) and |
---|
[484] | 5719 | not (r_cc_receive_dcache_req.read()) and |
---|
[468] | 5720 | (p_dspin_m2p.write.read())) |
---|
[331] | 5721 | { |
---|
| 5722 | // request dcache to handle the BROADCAST |
---|
[468] | 5723 | r_cc_receive_dcache_req = true; |
---|
[789] | 5724 | r_cc_receive_dcache_nline = DspinDhccpParam::dspin_get(receive_data, |
---|
[386] | 5725 | DspinDhccpParam::BROADCAST_NLINE); |
---|
[468] | 5726 | r_cc_receive_dcache_type = CC_TYPE_INVAL; |
---|
[331] | 5727 | // request icache to handle the BROADCAST |
---|
[468] | 5728 | r_cc_receive_icache_req = true; |
---|
[789] | 5729 | r_cc_receive_icache_nline = DspinDhccpParam::dspin_get(receive_data, |
---|
[386] | 5730 | DspinDhccpParam::BROADCAST_NLINE); |
---|
[468] | 5731 | r_cc_receive_icache_type = CC_TYPE_INVAL; |
---|
[331] | 5732 | // get back to idle state |
---|
| 5733 | r_cc_receive_fsm = CC_RECEIVE_IDLE; |
---|
| 5734 | break; |
---|
| 5735 | } |
---|
| 5736 | // keep waiting for the caches to accept the request |
---|
| 5737 | break; |
---|
| 5738 | } |
---|
| 5739 | ///////////////////////////// |
---|
[468] | 5740 | case CC_RECEIVE_DATA_INVAL_HEADER: |
---|
[331] | 5741 | { |
---|
[346] | 5742 | // sample updt tab index in the HEADER, then skip to second flit |
---|
[468] | 5743 | r_cc_receive_fsm = CC_RECEIVE_DATA_INVAL_NLINE; |
---|
[331] | 5744 | break; |
---|
| 5745 | } |
---|
[468] | 5746 | ///////////////////////////// |
---|
| 5747 | case CC_RECEIVE_INS_INVAL_HEADER: |
---|
| 5748 | { |
---|
| 5749 | // sample updt tab index in the HEADER, then skip to second flit |
---|
| 5750 | r_cc_receive_fsm = CC_RECEIVE_INS_INVAL_NLINE; |
---|
| 5751 | break; |
---|
| 5752 | } |
---|
[331] | 5753 | //////////////////////////// |
---|
[468] | 5754 | case CC_RECEIVE_DATA_INVAL_NLINE: |
---|
[331] | 5755 | { |
---|
| 5756 | // sample nline in the second flit |
---|
[468] | 5757 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
[331] | 5758 | // for data INVAL, wait for dcache to take the request |
---|
[484] | 5759 | if (p_dspin_m2p.write.read() and |
---|
[789] | 5760 | not r_cc_receive_dcache_req.read()) |
---|
[331] | 5761 | { |
---|
| 5762 | // request dcache to handle the INVAL |
---|
[468] | 5763 | r_cc_receive_dcache_req = true; |
---|
| 5764 | r_cc_receive_dcache_nline = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_INVAL_NLINE); |
---|
[331] | 5765 | r_cc_receive_dcache_type = CC_TYPE_INVAL; |
---|
| 5766 | // get back to idle state |
---|
| 5767 | r_cc_receive_fsm = CC_RECEIVE_IDLE; |
---|
| 5768 | break; |
---|
| 5769 | } |
---|
[468] | 5770 | break; |
---|
| 5771 | } |
---|
| 5772 | ////////////////////////////// |
---|
| 5773 | case CC_RECEIVE_INS_INVAL_NLINE: |
---|
| 5774 | { |
---|
| 5775 | // sample nline in the second flit |
---|
| 5776 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
[331] | 5777 | // for ins INVAL, wait for icache to take the request |
---|
[484] | 5778 | if (p_dspin_m2p.write.read() and |
---|
[789] | 5779 | not r_cc_receive_icache_req.read()) |
---|
[331] | 5780 | { |
---|
| 5781 | // request icache to handle the INVAL |
---|
[468] | 5782 | r_cc_receive_icache_req = true; |
---|
| 5783 | r_cc_receive_icache_nline = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_INVAL_NLINE); |
---|
[331] | 5784 | r_cc_receive_icache_type = CC_TYPE_INVAL; |
---|
| 5785 | // get back to idle state |
---|
| 5786 | r_cc_receive_fsm = CC_RECEIVE_IDLE; |
---|
| 5787 | break; |
---|
| 5788 | } |
---|
[468] | 5789 | break; |
---|
[331] | 5790 | } |
---|
| 5791 | //////////////////////////// |
---|
[468] | 5792 | case CC_RECEIVE_DATA_UPDT_HEADER: |
---|
[331] | 5793 | { |
---|
| 5794 | // sample updt tab index in the HEADER, than skip to second flit |
---|
[468] | 5795 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
[331] | 5796 | // for data INVAL, wait for dcache to take the request and fifo to |
---|
| 5797 | // be empty |
---|
[468] | 5798 | if (not r_cc_receive_dcache_req.read()) |
---|
[331] | 5799 | { |
---|
[789] | 5800 | r_cc_receive_dcache_updt_tab_idx = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_UPDT_INDEX); |
---|
[468] | 5801 | r_cc_receive_fsm = CC_RECEIVE_DATA_UPDT_NLINE; |
---|
[331] | 5802 | break; |
---|
| 5803 | } |
---|
[468] | 5804 | break; |
---|
| 5805 | } |
---|
| 5806 | //////////////////////////// |
---|
| 5807 | case CC_RECEIVE_INS_UPDT_HEADER: |
---|
| 5808 | { |
---|
| 5809 | // sample updt tab index in the HEADER, than skip to second flit |
---|
| 5810 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
[331] | 5811 | // for ins INVAL, wait for icache to take the request and fifo to be |
---|
| 5812 | // empty |
---|
[468] | 5813 | if (not r_cc_receive_icache_req.read()) |
---|
[331] | 5814 | { |
---|
[789] | 5815 | r_cc_receive_icache_updt_tab_idx = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_UPDT_INDEX); |
---|
[468] | 5816 | r_cc_receive_fsm = CC_RECEIVE_INS_UPDT_NLINE; |
---|
[331] | 5817 | break; |
---|
| 5818 | } |
---|
| 5819 | // keep waiting for the correct cache to accept the request |
---|
| 5820 | break; |
---|
| 5821 | } |
---|
| 5822 | /////////////////////////// |
---|
[468] | 5823 | case CC_RECEIVE_DATA_UPDT_NLINE: |
---|
[331] | 5824 | { |
---|
| 5825 | // sample nline and word index in the second flit |
---|
[468] | 5826 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
[331] | 5827 | // for data INVAL, wait for dcache to take the request and fifo to |
---|
| 5828 | // be empty |
---|
[789] | 5829 | if (r_cc_receive_updt_fifo_be.empty() and |
---|
| 5830 | p_dspin_m2p.write.read()) |
---|
[331] | 5831 | { |
---|
[789] | 5832 | r_cc_receive_dcache_req = true; |
---|
| 5833 | r_cc_receive_dcache_nline = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_NLINE); |
---|
| 5834 | r_cc_receive_word_idx = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_WORD_INDEX); |
---|
| 5835 | r_cc_receive_dcache_type = CC_TYPE_UPDT; |
---|
[331] | 5836 | // get back to idle state |
---|
[468] | 5837 | r_cc_receive_fsm = CC_RECEIVE_DATA_UPDT_DATA; |
---|
[331] | 5838 | break; |
---|
| 5839 | } |
---|
[468] | 5840 | break; |
---|
| 5841 | } |
---|
| 5842 | //////////////////////////// |
---|
| 5843 | case CC_RECEIVE_INS_UPDT_NLINE: |
---|
| 5844 | { |
---|
| 5845 | // sample nline and word index in the second flit |
---|
| 5846 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
[331] | 5847 | // for ins INVAL, wait for icache to take the request and fifo to be |
---|
| 5848 | // empty |
---|
[789] | 5849 | if (r_cc_receive_updt_fifo_be.empty() and |
---|
| 5850 | p_dspin_m2p.write.read()) |
---|
[331] | 5851 | { |
---|
[789] | 5852 | r_cc_receive_icache_req = true; |
---|
| 5853 | r_cc_receive_icache_nline = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_NLINE); |
---|
| 5854 | r_cc_receive_word_idx = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_WORD_INDEX); |
---|
| 5855 | r_cc_receive_icache_type = CC_TYPE_UPDT; |
---|
[331] | 5856 | // get back to idle state |
---|
[468] | 5857 | r_cc_receive_fsm = CC_RECEIVE_INS_UPDT_DATA; |
---|
[331] | 5858 | break; |
---|
| 5859 | } |
---|
| 5860 | break; |
---|
| 5861 | } |
---|
| 5862 | ////////////////////////// |
---|
[468] | 5863 | case CC_RECEIVE_DATA_UPDT_DATA: |
---|
[331] | 5864 | { |
---|
| 5865 | // wait for the fifo |
---|
[468] | 5866 | if (r_cc_receive_updt_fifo_be.wok() and (p_dspin_m2p.write.read())) |
---|
[331] | 5867 | { |
---|
[468] | 5868 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
| 5869 | bool receive_eop = p_dspin_m2p.eop.read(); |
---|
[403] | 5870 | cc_receive_updt_fifo_be = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_BE); |
---|
[331] | 5871 | cc_receive_updt_fifo_data = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_DATA); |
---|
[403] | 5872 | cc_receive_updt_fifo_eop = receive_eop; |
---|
[331] | 5873 | cc_receive_updt_fifo_put = true; |
---|
[789] | 5874 | if (receive_eop ) r_cc_receive_fsm = CC_RECEIVE_IDLE; |
---|
[331] | 5875 | } |
---|
| 5876 | break; |
---|
| 5877 | } |
---|
[468] | 5878 | ////////////////////////// |
---|
| 5879 | case CC_RECEIVE_INS_UPDT_DATA: |
---|
| 5880 | { |
---|
| 5881 | // wait for the fifo |
---|
| 5882 | if (r_cc_receive_updt_fifo_be.wok() and (p_dspin_m2p.write.read())) |
---|
| 5883 | { |
---|
| 5884 | uint64_t receive_data = p_dspin_m2p.data.read(); |
---|
| 5885 | bool receive_eop = p_dspin_m2p.eop.read(); |
---|
| 5886 | cc_receive_updt_fifo_be = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_BE); |
---|
| 5887 | cc_receive_updt_fifo_data = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_DATA); |
---|
| 5888 | cc_receive_updt_fifo_eop = receive_eop; |
---|
| 5889 | cc_receive_updt_fifo_put = true; |
---|
[789] | 5890 | if (receive_eop ) r_cc_receive_fsm = CC_RECEIVE_IDLE; |
---|
[468] | 5891 | } |
---|
| 5892 | break; |
---|
| 5893 | } |
---|
| 5894 | |
---|
[331] | 5895 | } // end switch CC_RECEIVE FSM |
---|
| 5896 | |
---|
[468] | 5897 | ///////////////// DSPIN CLACK interface /////////////// |
---|
| 5898 | |
---|
| 5899 | uint64_t clack_type = DspinDhccpParam::dspin_get(r_dspin_clack_flit.read(), |
---|
| 5900 | DspinDhccpParam::CLACK_TYPE); |
---|
| 5901 | |
---|
[789] | 5902 | size_t clack_way = DspinDhccpParam::dspin_get(r_dspin_clack_flit.read(), |
---|
[468] | 5903 | DspinDhccpParam::CLACK_WAY); |
---|
| 5904 | |
---|
[789] | 5905 | size_t clack_set = DspinDhccpParam::dspin_get(r_dspin_clack_flit.read(), |
---|
[468] | 5906 | DspinDhccpParam::CLACK_SET); |
---|
| 5907 | |
---|
[789] | 5908 | bool dspin_clack_get = false; |
---|
[468] | 5909 | bool dcache_clack_request = (clack_type == DspinDhccpParam::TYPE_CLACK_DATA); |
---|
| 5910 | bool icache_clack_request = (clack_type == DspinDhccpParam::TYPE_CLACK_INST); |
---|
| 5911 | |
---|
| 5912 | if (r_dspin_clack_req.read()) |
---|
| 5913 | { |
---|
| 5914 | // CLACK DATA: Send request to DCACHE FSM |
---|
[789] | 5915 | if (dcache_clack_request and not r_dcache_clack_req.read()) |
---|
| 5916 | { |
---|
[468] | 5917 | r_dcache_clack_req = true; |
---|
[789] | 5918 | r_dcache_clack_way = clack_way & ((1ULL << (uint32_log2(m_dcache_ways))) - 1); |
---|
| 5919 | r_dcache_clack_set = clack_set & ((1ULL << (uint32_log2(m_dcache_sets))) - 1); |
---|
[468] | 5920 | dspin_clack_get = true; |
---|
| 5921 | } |
---|
| 5922 | |
---|
| 5923 | // CLACK INST: Send request to ICACHE FSM |
---|
[789] | 5924 | else if (icache_clack_request and not r_icache_clack_req.read()) |
---|
| 5925 | { |
---|
[468] | 5926 | r_icache_clack_req = true; |
---|
| 5927 | r_icache_clack_way = clack_way & ((1ULL<<(uint32_log2(m_dcache_ways)))-1); |
---|
| 5928 | r_icache_clack_set = clack_set & ((1ULL<<(uint32_log2(m_icache_sets)))-1); |
---|
| 5929 | dspin_clack_get = true; |
---|
| 5930 | } |
---|
| 5931 | } |
---|
| 5932 | else |
---|
| 5933 | { |
---|
| 5934 | dspin_clack_get = true; |
---|
| 5935 | } |
---|
| 5936 | |
---|
| 5937 | if (dspin_clack_get) |
---|
| 5938 | { |
---|
| 5939 | r_dspin_clack_req = p_dspin_clack.write.read(); |
---|
| 5940 | r_dspin_clack_flit = p_dspin_clack.data.read(); |
---|
| 5941 | } |
---|
| 5942 | |
---|
[331] | 5943 | ///////////////// Response FIFOs update ////////////////////// |
---|
| 5944 | r_vci_rsp_fifo_icache.update(vci_rsp_fifo_icache_get, |
---|
| 5945 | vci_rsp_fifo_icache_put, |
---|
| 5946 | vci_rsp_fifo_icache_data); |
---|
| 5947 | |
---|
| 5948 | r_vci_rsp_fifo_dcache.update(vci_rsp_fifo_dcache_get, |
---|
| 5949 | vci_rsp_fifo_dcache_put, |
---|
| 5950 | vci_rsp_fifo_dcache_data); |
---|
[346] | 5951 | |
---|
[331] | 5952 | ///////////////// updt FIFO update ////////////////////// |
---|
| 5953 | //TODO check this |
---|
| 5954 | r_cc_receive_updt_fifo_be.update(cc_receive_updt_fifo_get, |
---|
| 5955 | cc_receive_updt_fifo_put, |
---|
| 5956 | cc_receive_updt_fifo_be); |
---|
| 5957 | r_cc_receive_updt_fifo_data.update(cc_receive_updt_fifo_get, |
---|
| 5958 | cc_receive_updt_fifo_put, |
---|
| 5959 | cc_receive_updt_fifo_data); |
---|
| 5960 | r_cc_receive_updt_fifo_eop.update(cc_receive_updt_fifo_get, |
---|
| 5961 | cc_receive_updt_fifo_put, |
---|
| 5962 | cc_receive_updt_fifo_eop); |
---|
| 5963 | |
---|
| 5964 | } // end transition() |
---|
| 5965 | |
---|
| 5966 | /////////////////////// |
---|
| 5967 | tmpl(void)::genMoore() |
---|
| 5968 | /////////////////////// |
---|
| 5969 | { |
---|
| 5970 | |
---|
| 5971 | // VCI initiator command on the direct network |
---|
| 5972 | // it depends on the CMD FSM state |
---|
| 5973 | |
---|
[336] | 5974 | bool is_sc_or_cas = (r_vci_cmd_fsm.read() == CMD_DATA_CAS) or |
---|
[789] | 5975 | (r_vci_cmd_fsm.read() == CMD_DATA_SC); |
---|
[336] | 5976 | |
---|
[346] | 5977 | p_vci.pktid = 0; |
---|
| 5978 | p_vci.srcid = m_srcid; |
---|
| 5979 | p_vci.cons = is_sc_or_cas; |
---|
| 5980 | p_vci.contig = not is_sc_or_cas; |
---|
| 5981 | p_vci.wrap = false; |
---|
| 5982 | p_vci.clen = 0; |
---|
| 5983 | p_vci.cfixed = false; |
---|
[331] | 5984 | |
---|
[789] | 5985 | if (m_monitor_ok) { |
---|
| 5986 | if (p_vci.cmdack.read() == true and p_vci.cmdval == true) { |
---|
[423] | 5987 | if (((p_vci.address.read()) >= m_monitor_base) and |
---|
[789] | 5988 | ((p_vci.address.read()) < m_monitor_base + m_monitor_length)) { |
---|
[423] | 5989 | std::cout << "CC_VCACHE Monitor " << name() << std::hex |
---|
| 5990 | << " Access type = " << vci_cmd_type_str[p_vci.cmd.read()] |
---|
| 5991 | << " Pktid type = " << vci_pktid_type_str[p_vci.pktid.read()] |
---|
| 5992 | << " : address = " << p_vci.address.read() |
---|
| 5993 | << " / be = " << p_vci.be.read(); |
---|
[789] | 5994 | if (p_vci.cmd.read() == vci_param::CMD_WRITE ) { |
---|
[423] | 5995 | std::cout << " / data = " << p_vci.wdata.read(); |
---|
| 5996 | } |
---|
| 5997 | std::cout << std::dec << std::endl; |
---|
| 5998 | } |
---|
| 5999 | } |
---|
| 6000 | } |
---|
| 6001 | |
---|
[789] | 6002 | switch (r_vci_cmd_fsm.read()) { |
---|
[331] | 6003 | |
---|
| 6004 | case CMD_IDLE: |
---|
[346] | 6005 | p_vci.cmdval = false; |
---|
| 6006 | p_vci.address = 0; |
---|
| 6007 | p_vci.wdata = 0; |
---|
| 6008 | p_vci.be = 0; |
---|
| 6009 | p_vci.trdid = 0; |
---|
| 6010 | p_vci.pktid = 0; |
---|
| 6011 | p_vci.plen = 0; |
---|
| 6012 | p_vci.cmd = vci_param::CMD_NOP; |
---|
| 6013 | p_vci.eop = false; |
---|
[331] | 6014 | break; |
---|
| 6015 | |
---|
| 6016 | case CMD_INS_MISS: |
---|
[346] | 6017 | p_vci.cmdval = true; |
---|
| 6018 | p_vci.address = r_icache_vci_paddr.read() & m_icache_yzmask; |
---|
| 6019 | p_vci.wdata = 0; |
---|
| 6020 | p_vci.be = 0xF; |
---|
| 6021 | p_vci.trdid = 0; |
---|
| 6022 | p_vci.pktid = TYPE_READ_INS_MISS; |
---|
| 6023 | p_vci.plen = m_icache_words<<2; |
---|
| 6024 | p_vci.cmd = vci_param::CMD_READ; |
---|
| 6025 | p_vci.eop = true; |
---|
[331] | 6026 | break; |
---|
| 6027 | |
---|
| 6028 | case CMD_INS_UNC: |
---|
[346] | 6029 | p_vci.cmdval = true; |
---|
| 6030 | p_vci.address = r_icache_vci_paddr.read() & ~0x3; |
---|
| 6031 | p_vci.wdata = 0; |
---|
| 6032 | p_vci.be = 0xF; |
---|
| 6033 | p_vci.trdid = 0; |
---|
| 6034 | p_vci.pktid = TYPE_READ_INS_UNC; |
---|
| 6035 | p_vci.plen = 4; |
---|
| 6036 | p_vci.cmd = vci_param::CMD_READ; |
---|
| 6037 | p_vci.eop = true; |
---|
[331] | 6038 | break; |
---|
| 6039 | |
---|
| 6040 | case CMD_DATA_MISS: |
---|
[346] | 6041 | p_vci.cmdval = true; |
---|
| 6042 | p_vci.address = r_dcache_vci_paddr.read() & m_dcache_yzmask; |
---|
| 6043 | p_vci.wdata = 0; |
---|
| 6044 | p_vci.be = 0xF; |
---|
| 6045 | p_vci.trdid = 0; |
---|
| 6046 | p_vci.pktid = TYPE_READ_DATA_MISS; |
---|
| 6047 | p_vci.plen = m_dcache_words << 2; |
---|
| 6048 | p_vci.cmd = vci_param::CMD_READ; |
---|
| 6049 | p_vci.eop = true; |
---|
[331] | 6050 | break; |
---|
| 6051 | |
---|
[616] | 6052 | case CMD_DATA_UNC_READ: |
---|
[346] | 6053 | p_vci.cmdval = true; |
---|
| 6054 | p_vci.address = r_dcache_vci_paddr.read() & ~0x3; |
---|
| 6055 | p_vci.wdata = 0; |
---|
| 6056 | p_vci.be = r_dcache_vci_unc_be.read(); |
---|
| 6057 | p_vci.trdid = 0; |
---|
[616] | 6058 | p_vci.pktid = TYPE_DATA_UNC; |
---|
[346] | 6059 | p_vci.plen = 4; |
---|
| 6060 | p_vci.cmd = vci_param::CMD_READ; |
---|
| 6061 | p_vci.eop = true; |
---|
[331] | 6062 | break; |
---|
| 6063 | |
---|
[616] | 6064 | case CMD_DATA_UNC_WRITE: |
---|
| 6065 | p_vci.cmdval = true; |
---|
| 6066 | p_vci.address = r_dcache_vci_paddr.read() & ~0x3; |
---|
| 6067 | p_vci.wdata = r_dcache_vci_wdata.read(); |
---|
| 6068 | p_vci.be = r_dcache_vci_unc_be.read(); |
---|
| 6069 | p_vci.trdid = 0; |
---|
| 6070 | p_vci.pktid = TYPE_DATA_UNC; |
---|
| 6071 | p_vci.plen = 4; |
---|
| 6072 | p_vci.cmd = vci_param::CMD_WRITE; |
---|
| 6073 | p_vci.eop = true; |
---|
| 6074 | break; |
---|
| 6075 | |
---|
[331] | 6076 | case CMD_DATA_WRITE: |
---|
[346] | 6077 | p_vci.cmdval = true; |
---|
| 6078 | p_vci.address = r_wbuf.getAddress(r_vci_cmd_cpt.read()) & ~0x3; |
---|
| 6079 | p_vci.wdata = r_wbuf.getData(r_vci_cmd_cpt.read()); |
---|
| 6080 | p_vci.be = r_wbuf.getBe(r_vci_cmd_cpt.read()); |
---|
| 6081 | p_vci.trdid = r_wbuf.getIndex(); |
---|
| 6082 | p_vci.pktid = TYPE_WRITE; |
---|
| 6083 | p_vci.plen = (r_vci_cmd_max.read() - r_vci_cmd_min.read() + 1) << 2; |
---|
| 6084 | p_vci.cmd = vci_param::CMD_WRITE; |
---|
| 6085 | p_vci.eop = (r_vci_cmd_cpt.read() == r_vci_cmd_max.read()); |
---|
[331] | 6086 | break; |
---|
| 6087 | |
---|
| 6088 | case CMD_DATA_LL: |
---|
[346] | 6089 | p_vci.cmdval = true; |
---|
| 6090 | p_vci.address = r_dcache_vci_paddr.read() & ~0x3; |
---|
| 6091 | p_vci.wdata = 0; |
---|
| 6092 | p_vci.be = 0xF; |
---|
| 6093 | p_vci.trdid = 0; |
---|
| 6094 | p_vci.pktid = TYPE_LL; |
---|
| 6095 | p_vci.plen = 8; |
---|
| 6096 | p_vci.cmd = vci_param::CMD_LOCKED_READ; |
---|
| 6097 | p_vci.eop = true; |
---|
[331] | 6098 | break; |
---|
| 6099 | |
---|
| 6100 | case CMD_DATA_SC: |
---|
[346] | 6101 | p_vci.cmdval = true; |
---|
| 6102 | p_vci.address = r_dcache_vci_paddr.read() & ~0x3; |
---|
[789] | 6103 | if (r_vci_cmd_cpt.read() == 0) p_vci.wdata = r_dcache_llsc_key.read(); |
---|
| 6104 | else p_vci.wdata = r_dcache_vci_sc_data.read(); |
---|
[346] | 6105 | p_vci.be = 0xF; |
---|
| 6106 | p_vci.trdid = 0; |
---|
| 6107 | p_vci.pktid = TYPE_SC; |
---|
| 6108 | p_vci.plen = 8; |
---|
| 6109 | p_vci.cmd = vci_param::CMD_NOP; |
---|
| 6110 | p_vci.eop = (r_vci_cmd_cpt.read() == 1); |
---|
[331] | 6111 | break; |
---|
| 6112 | |
---|
| 6113 | case CMD_DATA_CAS: |
---|
[346] | 6114 | p_vci.cmdval = true; |
---|
| 6115 | p_vci.address = r_dcache_vci_paddr.read() & ~0x3; |
---|
[789] | 6116 | if (r_vci_cmd_cpt.read() == 0) p_vci.wdata = r_dcache_vci_cas_old.read(); |
---|
| 6117 | else p_vci.wdata = r_dcache_vci_cas_new.read(); |
---|
[346] | 6118 | p_vci.be = 0xF; |
---|
| 6119 | p_vci.trdid = 0; |
---|
| 6120 | p_vci.pktid = TYPE_CAS; |
---|
| 6121 | p_vci.plen = 8; |
---|
| 6122 | p_vci.cmd = vci_param::CMD_NOP; |
---|
| 6123 | p_vci.eop = (r_vci_cmd_cpt.read() == 1); |
---|
[331] | 6124 | break; |
---|
| 6125 | } // end switch r_vci_cmd_fsm |
---|
| 6126 | |
---|
| 6127 | // VCI initiator response on the direct network |
---|
[346] | 6128 | // it depends on the VCI_RSP FSM |
---|
[331] | 6129 | |
---|
[789] | 6130 | switch (r_vci_rsp_fsm.read()) |
---|
[331] | 6131 | { |
---|
[346] | 6132 | case RSP_DATA_WRITE : p_vci.rspack = true; break; |
---|
| 6133 | case RSP_INS_MISS : p_vci.rspack = r_vci_rsp_fifo_icache.wok(); break; |
---|
| 6134 | case RSP_INS_UNC : p_vci.rspack = r_vci_rsp_fifo_icache.wok(); break; |
---|
| 6135 | case RSP_DATA_MISS : p_vci.rspack = r_vci_rsp_fifo_dcache.wok(); break; |
---|
| 6136 | case RSP_DATA_UNC : p_vci.rspack = r_vci_rsp_fifo_dcache.wok(); break; |
---|
| 6137 | case RSP_DATA_LL : p_vci.rspack = r_vci_rsp_fifo_dcache.wok(); break; |
---|
| 6138 | case RSP_IDLE : p_vci.rspack = false; break; |
---|
[331] | 6139 | } // end switch r_vci_rsp_fsm |
---|
| 6140 | |
---|
[346] | 6141 | |
---|
[394] | 6142 | // Send coherence packets on DSPIN P2M |
---|
[346] | 6143 | // it depends on the CC_SEND FSM |
---|
| 6144 | |
---|
[331] | 6145 | uint64_t dspin_send_data = 0; |
---|
[789] | 6146 | switch (r_cc_send_fsm.read()) |
---|
[331] | 6147 | { |
---|
[346] | 6148 | ////////////////// |
---|
[331] | 6149 | case CC_SEND_IDLE: |
---|
| 6150 | { |
---|
[468] | 6151 | p_dspin_p2m.write = false; |
---|
[331] | 6152 | break; |
---|
| 6153 | } |
---|
[346] | 6154 | /////////////////////// |
---|
[331] | 6155 | case CC_SEND_CLEANUP_1: |
---|
| 6156 | { |
---|
| 6157 | // initialize dspin send data |
---|
[346] | 6158 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
| 6159 | m_cc_global_id, |
---|
| 6160 | DspinDhccpParam::CLEANUP_SRCID); |
---|
| 6161 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
| 6162 | 0, |
---|
[468] | 6163 | DspinDhccpParam::P2M_BC); |
---|
[346] | 6164 | |
---|
[789] | 6165 | if (r_cc_send_last_client.read() == 0) // dcache active request |
---|
[331] | 6166 | { |
---|
[369] | 6167 | uint64_t dest = (uint64_t) r_dcache_cc_send_nline.read() |
---|
[346] | 6168 | >> (m_nline_width - m_x_width - m_y_width) |
---|
| 6169 | << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width); |
---|
| 6170 | |
---|
[331] | 6171 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6172 | dest, |
---|
| 6173 | DspinDhccpParam::CLEANUP_DEST); |
---|
[331] | 6174 | |
---|
| 6175 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[394] | 6176 | (r_dcache_cc_send_nline.read() & 0x300000000ULL)>>32, |
---|
[346] | 6177 | DspinDhccpParam::CLEANUP_NLINE_MSB); |
---|
[331] | 6178 | |
---|
| 6179 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6180 | r_dcache_cc_send_way.read(), |
---|
| 6181 | DspinDhccpParam::CLEANUP_WAY_INDEX); |
---|
[331] | 6182 | |
---|
| 6183 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6184 | DspinDhccpParam::TYPE_CLEANUP_DATA, |
---|
[468] | 6185 | DspinDhccpParam::P2M_TYPE); |
---|
[331] | 6186 | } |
---|
[346] | 6187 | else // icache active request |
---|
[331] | 6188 | { |
---|
[369] | 6189 | uint64_t dest = (uint64_t) r_icache_cc_send_nline.read() |
---|
[346] | 6190 | >> (m_nline_width - m_x_width - m_y_width) |
---|
| 6191 | << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width); |
---|
[331] | 6192 | |
---|
| 6193 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6194 | dest, |
---|
| 6195 | DspinDhccpParam::CLEANUP_DEST); |
---|
[331] | 6196 | |
---|
| 6197 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[789] | 6198 | (r_icache_cc_send_nline.read() & 0x300000000ULL) >> 32, |
---|
[346] | 6199 | DspinDhccpParam::CLEANUP_NLINE_MSB); |
---|
[331] | 6200 | |
---|
| 6201 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6202 | r_icache_cc_send_way.read(), |
---|
| 6203 | DspinDhccpParam::CLEANUP_WAY_INDEX); |
---|
[331] | 6204 | |
---|
| 6205 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6206 | DspinDhccpParam::TYPE_CLEANUP_INST, |
---|
[468] | 6207 | DspinDhccpParam::P2M_TYPE); |
---|
[331] | 6208 | } |
---|
| 6209 | // send flit |
---|
[468] | 6210 | p_dspin_p2m.data = dspin_send_data; |
---|
| 6211 | p_dspin_p2m.write = true; |
---|
| 6212 | p_dspin_p2m.eop = false; |
---|
[331] | 6213 | break; |
---|
| 6214 | } |
---|
[346] | 6215 | /////////////////////// |
---|
[331] | 6216 | case CC_SEND_CLEANUP_2: |
---|
| 6217 | { |
---|
| 6218 | // initialize dspin send data |
---|
[346] | 6219 | |
---|
[789] | 6220 | if (r_cc_send_last_client.read() == 0) // dcache active request |
---|
[331] | 6221 | { |
---|
| 6222 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6223 | r_dcache_cc_send_nline.read() & 0xFFFFFFFFULL, |
---|
| 6224 | DspinDhccpParam::CLEANUP_NLINE_LSB); |
---|
[331] | 6225 | } |
---|
[346] | 6226 | else // icache active request |
---|
[331] | 6227 | { |
---|
| 6228 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6229 | r_icache_cc_send_nline.read() & 0xFFFFFFFFULL, |
---|
| 6230 | DspinDhccpParam::CLEANUP_NLINE_LSB); |
---|
[331] | 6231 | } |
---|
| 6232 | // send flit |
---|
[468] | 6233 | p_dspin_p2m.data = dspin_send_data; |
---|
| 6234 | p_dspin_p2m.write = true; |
---|
| 6235 | p_dspin_p2m.eop = true; |
---|
[331] | 6236 | break; |
---|
| 6237 | } |
---|
[346] | 6238 | /////////////////////// |
---|
[331] | 6239 | case CC_SEND_MULTI_ACK: |
---|
| 6240 | { |
---|
| 6241 | // initialize dspin send data |
---|
| 6242 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6243 | 0, |
---|
[468] | 6244 | DspinDhccpParam::P2M_BC); |
---|
[346] | 6245 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
| 6246 | DspinDhccpParam::TYPE_MULTI_ACK, |
---|
[468] | 6247 | DspinDhccpParam::P2M_TYPE); |
---|
[346] | 6248 | |
---|
[789] | 6249 | if (r_cc_send_last_client.read() == 0) // dcache active request |
---|
[331] | 6250 | { |
---|
[369] | 6251 | uint64_t dest = (uint64_t) r_dcache_cc_send_nline.read() |
---|
[346] | 6252 | >> (m_nline_width - m_x_width - m_y_width) |
---|
| 6253 | << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width); |
---|
| 6254 | |
---|
[331] | 6255 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6256 | dest, |
---|
| 6257 | DspinDhccpParam::MULTI_ACK_DEST); |
---|
[331] | 6258 | |
---|
| 6259 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6260 | r_dcache_cc_send_updt_tab_idx.read(), |
---|
| 6261 | DspinDhccpParam::MULTI_ACK_UPDT_INDEX); |
---|
[331] | 6262 | } |
---|
[346] | 6263 | else // icache active request |
---|
[331] | 6264 | { |
---|
[369] | 6265 | uint64_t dest = (uint64_t) r_icache_cc_send_nline.read() |
---|
[346] | 6266 | >> (m_nline_width - m_x_width - m_y_width) |
---|
| 6267 | << (DspinDhccpParam::GLOBALID_WIDTH - m_x_width - m_y_width); |
---|
| 6268 | |
---|
[331] | 6269 | |
---|
| 6270 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6271 | dest, |
---|
| 6272 | DspinDhccpParam::MULTI_ACK_DEST); |
---|
[331] | 6273 | |
---|
| 6274 | DspinDhccpParam::dspin_set(dspin_send_data, |
---|
[346] | 6275 | r_icache_cc_send_updt_tab_idx.read(), |
---|
| 6276 | DspinDhccpParam::MULTI_ACK_UPDT_INDEX); |
---|
[331] | 6277 | } |
---|
| 6278 | // send flit |
---|
[468] | 6279 | p_dspin_p2m.data = dspin_send_data; |
---|
| 6280 | p_dspin_p2m.write = true; |
---|
| 6281 | p_dspin_p2m.eop = true; |
---|
[355] | 6282 | |
---|
[331] | 6283 | break; |
---|
| 6284 | } |
---|
| 6285 | } // end switch CC_SEND FSM |
---|
| 6286 | |
---|
[346] | 6287 | // Receive coherence packets |
---|
| 6288 | // It depends on the CC_RECEIVE FSM |
---|
[789] | 6289 | switch (r_cc_receive_fsm.read()) |
---|
[331] | 6290 | { |
---|
| 6291 | ///////////////////// |
---|
| 6292 | case CC_RECEIVE_IDLE: |
---|
| 6293 | { |
---|
[468] | 6294 | p_dspin_m2p.read = false; |
---|
[331] | 6295 | break; |
---|
| 6296 | } |
---|
| 6297 | /////////////////////////////// |
---|
| 6298 | case CC_RECEIVE_BRDCAST_HEADER: |
---|
| 6299 | { |
---|
[468] | 6300 | p_dspin_m2p.read = true; |
---|
[331] | 6301 | break; |
---|
| 6302 | } |
---|
| 6303 | ////////////////////////////// |
---|
| 6304 | case CC_RECEIVE_BRDCAST_NLINE: |
---|
| 6305 | { |
---|
| 6306 | // TODO maybe we need to wait for both only to leave the state, but |
---|
| 6307 | // not to actually post a request to an available cache => need a |
---|
| 6308 | // flip_flop to check that ? |
---|
| 6309 | if (not (r_cc_receive_icache_req.read()) and not (r_cc_receive_dcache_req.read())) |
---|
[468] | 6310 | p_dspin_m2p.read = true; |
---|
[331] | 6311 | else |
---|
[468] | 6312 | p_dspin_m2p.read = false; |
---|
[331] | 6313 | break; |
---|
| 6314 | } |
---|
| 6315 | ///////////////////////////// |
---|
[468] | 6316 | case CC_RECEIVE_DATA_INVAL_HEADER: |
---|
| 6317 | case CC_RECEIVE_INS_INVAL_HEADER: |
---|
[331] | 6318 | { |
---|
[468] | 6319 | p_dspin_m2p.read = true; |
---|
[331] | 6320 | break; |
---|
| 6321 | } |
---|
| 6322 | //////////////////////////// |
---|
[468] | 6323 | case CC_RECEIVE_DATA_INVAL_NLINE: |
---|
[331] | 6324 | { |
---|
[468] | 6325 | p_dspin_m2p.read = not r_cc_receive_dcache_req.read(); |
---|
[331] | 6326 | break; |
---|
| 6327 | } |
---|
[468] | 6328 | case CC_RECEIVE_INS_INVAL_NLINE: |
---|
| 6329 | { |
---|
| 6330 | p_dspin_m2p.read = not r_cc_receive_icache_req.read(); |
---|
| 6331 | break; |
---|
| 6332 | } |
---|
| 6333 | /////////////////////////// |
---|
| 6334 | case CC_RECEIVE_DATA_UPDT_HEADER: |
---|
| 6335 | { |
---|
| 6336 | if (not r_cc_receive_dcache_req.read()) |
---|
| 6337 | p_dspin_m2p.read = true; |
---|
| 6338 | else |
---|
| 6339 | p_dspin_m2p.read = false; |
---|
| 6340 | break; |
---|
| 6341 | } |
---|
[331] | 6342 | //////////////////////////// |
---|
[468] | 6343 | case CC_RECEIVE_INS_UPDT_HEADER: |
---|
[331] | 6344 | { |
---|
[789] | 6345 | if (not r_cc_receive_icache_req.read()) |
---|
[468] | 6346 | p_dspin_m2p.read = true; |
---|
[331] | 6347 | else |
---|
[468] | 6348 | p_dspin_m2p.read = false; |
---|
[331] | 6349 | break; |
---|
| 6350 | } |
---|
| 6351 | /////////////////////////// |
---|
[468] | 6352 | case CC_RECEIVE_DATA_UPDT_NLINE: |
---|
| 6353 | case CC_RECEIVE_INS_UPDT_NLINE: |
---|
[331] | 6354 | { |
---|
[789] | 6355 | if (r_cc_receive_updt_fifo_be.empty()) |
---|
[468] | 6356 | p_dspin_m2p.read = true; |
---|
[331] | 6357 | else |
---|
[468] | 6358 | p_dspin_m2p.read = false; |
---|
[331] | 6359 | break; |
---|
| 6360 | } |
---|
[468] | 6361 | /////////////////////////// |
---|
| 6362 | case CC_RECEIVE_DATA_UPDT_DATA: |
---|
| 6363 | case CC_RECEIVE_INS_UPDT_DATA: |
---|
[331] | 6364 | { |
---|
| 6365 | if (r_cc_receive_updt_fifo_be.wok()) |
---|
[468] | 6366 | p_dspin_m2p.read = true; |
---|
[331] | 6367 | else |
---|
[468] | 6368 | p_dspin_m2p.read = false; |
---|
[331] | 6369 | break; |
---|
| 6370 | } |
---|
| 6371 | } // end switch CC_RECEIVE FSM |
---|
| 6372 | |
---|
[468] | 6373 | |
---|
| 6374 | int clack_type = DspinDhccpParam::dspin_get(r_dspin_clack_flit.read(), |
---|
| 6375 | DspinDhccpParam::CLACK_TYPE); |
---|
| 6376 | |
---|
[789] | 6377 | bool dspin_clack_get = false; |
---|
[468] | 6378 | bool dcache_clack_request = (clack_type == DspinDhccpParam::TYPE_CLACK_DATA); |
---|
| 6379 | bool icache_clack_request = (clack_type == DspinDhccpParam::TYPE_CLACK_INST); |
---|
| 6380 | |
---|
| 6381 | if (r_dspin_clack_req.read()) |
---|
| 6382 | { |
---|
| 6383 | // CLACK DATA: wait if pending request to DCACHE FSM |
---|
| 6384 | if (dcache_clack_request and not r_dcache_clack_req.read()) |
---|
| 6385 | { |
---|
| 6386 | dspin_clack_get = true; |
---|
| 6387 | } |
---|
| 6388 | |
---|
| 6389 | // CLACK INST: wait if pending request to ICACHE FSM |
---|
| 6390 | else if (icache_clack_request and not r_icache_clack_req.read()) |
---|
| 6391 | { |
---|
| 6392 | dspin_clack_get = true; |
---|
| 6393 | } |
---|
| 6394 | } |
---|
| 6395 | else |
---|
| 6396 | { |
---|
| 6397 | dspin_clack_get = true; |
---|
| 6398 | } |
---|
| 6399 | |
---|
| 6400 | p_dspin_clack.read = dspin_clack_get; |
---|
[331] | 6401 | } // end genMoore |
---|
| 6402 | |
---|
[423] | 6403 | tmpl(void)::start_monitor(paddr_t base, paddr_t length) |
---|
| 6404 | // This version of monitor print both Read and Write request |
---|
| 6405 | { |
---|
[789] | 6406 | m_monitor_ok = true; |
---|
| 6407 | m_monitor_base = base; |
---|
| 6408 | m_monitor_length = length; |
---|
[423] | 6409 | } |
---|
| 6410 | |
---|
| 6411 | tmpl(void)::stop_monitor() |
---|
| 6412 | { |
---|
[789] | 6413 | m_monitor_ok = false; |
---|
[423] | 6414 | } |
---|
| 6415 | |
---|
[331] | 6416 | }} |
---|
| 6417 | |
---|
| 6418 | // Local Variables: |
---|
| 6419 | // tab-width: 4 |
---|
| 6420 | // c-basic-offset: 4 |
---|
| 6421 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 6422 | // indent-tabs-mode: nil |
---|
| 6423 | // End: |
---|
| 6424 | |
---|
| 6425 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|