1 | /* -*- c++ -*- |
---|
2 | * File : vci_cc_vcache_wrapper_v1.h |
---|
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 | |
---|
27 | #ifndef SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_V1_H |
---|
28 | #define SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_V1_H |
---|
29 | |
---|
30 | #include <inttypes.h> |
---|
31 | #include <systemc> |
---|
32 | #include "caba_base_module.h" |
---|
33 | #include "write_buffer.h" |
---|
34 | #include "generic_cache.h" |
---|
35 | #include "vci_initiator.h" |
---|
36 | #include "vci_target.h" |
---|
37 | #include "mapping_table.h" |
---|
38 | #include "generic_tlb.h" |
---|
39 | #include "static_assert.h" |
---|
40 | |
---|
41 | namespace soclib { |
---|
42 | namespace caba { |
---|
43 | |
---|
44 | using namespace sc_core; |
---|
45 | |
---|
46 | //////////////////////////////////////////// |
---|
47 | template<typename vci_param, typename iss_t> |
---|
48 | class VciCcVCacheWrapperV1 |
---|
49 | //////////////////////////////////////////// |
---|
50 | : public soclib::caba::BaseModule |
---|
51 | { |
---|
52 | typedef uint32_t vaddr_t; |
---|
53 | typedef uint32_t data_t; |
---|
54 | typedef uint32_t tag_t; |
---|
55 | typedef uint32_t type_t; |
---|
56 | typedef typename iss_t::DataOperationType data_op_t; |
---|
57 | |
---|
58 | typedef typename vci_param::addr_t paddr_t; |
---|
59 | typedef typename vci_param::be_t vci_be_t; |
---|
60 | typedef typename vci_param::srcid_t vci_srcid_t; |
---|
61 | typedef typename vci_param::trdid_t vci_trdid_t; |
---|
62 | typedef typename vci_param::pktid_t vci_pktid_t; |
---|
63 | typedef typename vci_param::plen_t vci_plen_t; |
---|
64 | |
---|
65 | enum icache_fsm_state_e { |
---|
66 | ICACHE_IDLE, // 00 |
---|
67 | ICACHE_BIS, // 01 |
---|
68 | ICACHE_TLB1_READ, // 02 |
---|
69 | ICACHE_TLB1_LL_WAIT, // 03 |
---|
70 | ICACHE_TLB1_SC_WAIT, // 04 |
---|
71 | ICACHE_TLB1_UPDT, // 05 |
---|
72 | ICACHE_TLB2_READ, // 06 |
---|
73 | ICACHE_TLB2_LL_WAIT, // 07 |
---|
74 | ICACHE_TLB2_SC_WAIT, // 08 |
---|
75 | ICACHE_TLB2_UPDT, // 09 |
---|
76 | ICACHE_TLB_FLUSH, // 0a |
---|
77 | ICACHE_CACHE_FLUSH, // 0b |
---|
78 | ICACHE_TLB_INVAL, // 0c |
---|
79 | ICACHE_CACHE_INVAL, // 0d |
---|
80 | ICACHE_CACHE_INVAL_PA, // 0e |
---|
81 | ICACHE_MISS_WAIT, // 0f |
---|
82 | ICACHE_UNC_WAIT, // 10 |
---|
83 | ICACHE_MISS_UPDT, // 11 |
---|
84 | ICACHE_ERROR, // 12 |
---|
85 | ICACHE_CC_INVAL, // 13 |
---|
86 | ICACHE_TLB_CC_INVAL, // 14 |
---|
87 | }; |
---|
88 | |
---|
89 | enum dcache_fsm_state_e { |
---|
90 | DCACHE_IDLE, // 00 |
---|
91 | DCACHE_BIS, // 01 |
---|
92 | DCACHE_TLB1_READ, // 02 |
---|
93 | DCACHE_TLB1_LL_WAIT, // 03 |
---|
94 | DCACHE_TLB1_SC_WAIT, // 04 |
---|
95 | DCACHE_TLB1_UPDT, // 05 |
---|
96 | DCACHE_TLB2_READ, // 06 |
---|
97 | DCACHE_TLB2_LL_WAIT, // 07 |
---|
98 | DCACHE_TLB2_SC_WAIT, // 08 |
---|
99 | DCACHE_TLB2_UPDT, // 09 |
---|
100 | DCACHE_CTXT_SWITCH, // 0a |
---|
101 | DCACHE_ICACHE_FLUSH, // 0b |
---|
102 | DCACHE_DCACHE_FLUSH, // 0c |
---|
103 | DCACHE_ITLB_INVAL, // 0d |
---|
104 | DCACHE_DTLB_INVAL, // 0e |
---|
105 | DCACHE_ICACHE_INVAL, // 0f |
---|
106 | DCACHE_DCACHE_INVAL, // 10 |
---|
107 | DCACHE_ICACHE_INVAL_PA, // 0f |
---|
108 | DCACHE_DCACHE_INVAL_PA, // 10 |
---|
109 | DCACHE_DCACHE_SYNC, // 11 |
---|
110 | DCACHE_LL_DIRTY_WAIT, // 12 |
---|
111 | DCACHE_SC_DIRTY_WAIT, // 13 |
---|
112 | DCACHE_WRITE_UPDT, // 14 |
---|
113 | DCACHE_WRITE_DIRTY, // 15 |
---|
114 | DCACHE_WRITE_REQ, // 16 |
---|
115 | DCACHE_MISS_WAIT, // 17 |
---|
116 | DCACHE_MISS_UPDT, // 18 |
---|
117 | DCACHE_UNC_WAIT, // 19 |
---|
118 | DCACHE_ERROR, // 1a |
---|
119 | DCACHE_CC_CHECK, // 1b |
---|
120 | DCACHE_CC_INVAL, // 1c |
---|
121 | DCACHE_CC_UPDT, // 1d |
---|
122 | DCACHE_CC_NOP, // 1e |
---|
123 | DCACHE_TLB_CC_INVAL, // 1f |
---|
124 | }; |
---|
125 | |
---|
126 | enum cmd_fsm_state_e { |
---|
127 | CMD_IDLE, // 00 |
---|
128 | CMD_ITLB_READ, // 01 |
---|
129 | CMD_ITLB_ACC_LL, // 02 |
---|
130 | CMD_ITLB_ACC_SC, // 03 |
---|
131 | CMD_INS_MISS, // 04 |
---|
132 | CMD_INS_UNC, // 05 |
---|
133 | CMD_DTLB_READ, // 06 |
---|
134 | CMD_DTLB_ACC_LL, // 07 |
---|
135 | CMD_DTLB_ACC_SC, // 08 |
---|
136 | CMD_DTLB_DIRTY_LL, // 09 |
---|
137 | CMD_DTLB_DIRTY_SC, // 0a |
---|
138 | CMD_DATA_UNC, // 0b |
---|
139 | CMD_DATA_MISS, // 0c |
---|
140 | CMD_DATA_WRITE, // 0d |
---|
141 | CMD_INS_CLEANUP, // 0e |
---|
142 | CMD_DATA_CLEANUP, // 0f |
---|
143 | }; |
---|
144 | |
---|
145 | enum rsp_fsm_state_e { |
---|
146 | RSP_IDLE, // 00 |
---|
147 | RSP_ITLB_READ, // 01 |
---|
148 | RSP_ITLB_ACC_LL, // 02 |
---|
149 | RSP_ITLB_ACC_SC, // 03 |
---|
150 | RSP_INS_MISS, // 04 |
---|
151 | RSP_INS_UNC, // 05 |
---|
152 | RSP_DTLB_READ, // 06 |
---|
153 | RSP_DTLB_ACC_LL, // 07 |
---|
154 | RSP_DTLB_ACC_SC, // 08 |
---|
155 | RSP_DTLB_DIRTY_LL, // 09 |
---|
156 | RSP_DTLB_DIRTY_SC, // 0a |
---|
157 | RSP_DATA_MISS, // 0b |
---|
158 | RSP_DATA_UNC, // 0c |
---|
159 | RSP_DATA_WRITE, // 0d |
---|
160 | RSP_INS_CLEANUP, // 0e |
---|
161 | RSP_DATA_CLEANUP, // 0f |
---|
162 | }; |
---|
163 | |
---|
164 | enum tgt_fsm_state_e { |
---|
165 | TGT_IDLE, // 00 |
---|
166 | TGT_UPDT_WORD, // 01 |
---|
167 | TGT_UPDT_DATA, // 02 |
---|
168 | TGT_REQ_BROADCAST, // 03 |
---|
169 | TGT_REQ_ICACHE, // 04 |
---|
170 | TGT_REQ_DCACHE, // 05 |
---|
171 | TGT_RSP_BROADCAST, // 06 |
---|
172 | TGT_RSP_ICACHE, // 07 |
---|
173 | TGT_RSP_DCACHE, // 08 |
---|
174 | }; |
---|
175 | |
---|
176 | enum inval_itlb_fsm_state_e { |
---|
177 | INVAL_ITLB_IDLE, // 00 |
---|
178 | INVAL_ITLB_CHECK, // 01 |
---|
179 | INVAL_ITLB_INVAL, // 02 |
---|
180 | INVAL_ITLB_CLEAR, // 03 |
---|
181 | }; |
---|
182 | |
---|
183 | enum inval_dtlb_fsm_state_e { |
---|
184 | INVAL_DTLB_IDLE, // 00 |
---|
185 | INVAL_DTLB_CHECK, // 01 |
---|
186 | INVAL_DTLB_INVAL, // 02 |
---|
187 | INVAL_DTLB_CLEAR, // 03 |
---|
188 | }; |
---|
189 | |
---|
190 | // TLB Mode ITLB / DTLB / ICACHE / DCACHE |
---|
191 | enum { |
---|
192 | ALL_DEACTIVE = 0x0000, // TLBs disactive caches disactive |
---|
193 | INS_TLB_MASK = 0x8, |
---|
194 | DATA_TLB_MASK = 0x4, |
---|
195 | INS_CACHE_MASK = 0x2, |
---|
196 | DATA_CACHE_MASK = 0x1, |
---|
197 | }; |
---|
198 | |
---|
199 | // Error Type |
---|
200 | enum mmu_error_type_e { |
---|
201 | MMU_NONE = 0x0000, // None |
---|
202 | MMU_WRITE_PT1_UNMAPPED = 0x0001, // Write access of Page fault on Page Table 1 (non fatal error) |
---|
203 | MMU_WRITE_PT2_UNMAPPED = 0x0002, // Write access of Page fault on Page Table 2 (non fatal error) |
---|
204 | MMU_WRITE_PRIVILEGE_VIOLATION = 0x0004, // Write access of Protected access in user mode (user error) |
---|
205 | MMU_WRITE_ACCES_VIOLATION = 0x0008, // Write access of write access to a non writable page (user error) |
---|
206 | MMU_WRITE_UNDEFINED_XTN = 0x0020, // Write access of undefined external access address (user error) |
---|
207 | MMU_WRITE_PT1_ILLEGAL_ACCESS = 0x0040, // Write access of Bus Error accessing Table 1 (kernel error) |
---|
208 | MMU_WRITE_PT2_ILLEGAL_ACCESS = 0x0080, // Write access of Bus Error accessing Table 2 (kernel error) |
---|
209 | MMU_WRITE_DATA_ILLEGAL_ACCESS = 0x0100, // Write access of Bus Error in cache access (kernel error) |
---|
210 | MMU_READ_PT1_UNMAPPED = 0x1001, // Read access of Page fault on Page Table 1 (non fatal error) |
---|
211 | MMU_READ_PT2_UNMAPPED = 0x1002, // Read access of Page fault on Page Table 2 (non fatal error) |
---|
212 | MMU_READ_PRIVILEGE_VIOLATION = 0x1004, // Read access of Protected access in user mode (user error) |
---|
213 | MMU_READ_EXEC_VIOLATION = 0x1010, // Exec access to a non exec page (user error) |
---|
214 | MMU_READ_UNDEFINED_XTN = 0x1020, // Read access of Undefined external access address (user error) |
---|
215 | MMU_READ_PT1_ILLEGAL_ACCESS = 0x1040, // Read access of Bus Error in Table1 access (kernel error) |
---|
216 | MMU_READ_PT2_ILLEGAL_ACCESS = 0x1080, // Read access of Bus Error in Table2 access (kernel error) |
---|
217 | MMU_READ_DATA_ILLEGAL_ACCESS = 0x1100, // Read access of Bus Error in cache access (kernel error) |
---|
218 | }; |
---|
219 | |
---|
220 | // Cleanup Type |
---|
221 | enum { |
---|
222 | NONE, // reset |
---|
223 | CACHE_CLEANUP, // cache cleanup |
---|
224 | TLB_CLEANUP, // TLB cleanup |
---|
225 | }; |
---|
226 | |
---|
227 | public: |
---|
228 | sc_in<bool> p_clk; |
---|
229 | sc_in<bool> p_resetn; |
---|
230 | sc_in<bool> p_irq[iss_t::n_irq]; |
---|
231 | soclib::caba::VciInitiator<vci_param> p_vci_ini_rw; |
---|
232 | soclib::caba::VciInitiator<vci_param> p_vci_ini_c; |
---|
233 | soclib::caba::VciTarget<vci_param> p_vci_tgt; |
---|
234 | |
---|
235 | private: |
---|
236 | // STRUCTURAL PARAMETERS |
---|
237 | soclib::common::AddressDecodingTable<uint32_t, bool> m_cacheability_table; |
---|
238 | const soclib::common::Segment m_segment; |
---|
239 | iss_t m_iss; |
---|
240 | const vci_srcid_t m_srcid_rw; |
---|
241 | const vci_srcid_t m_srcid_c; |
---|
242 | |
---|
243 | const size_t m_itlb_ways; |
---|
244 | const size_t m_itlb_sets; |
---|
245 | |
---|
246 | const size_t m_dtlb_ways; |
---|
247 | const size_t m_dtlb_sets; |
---|
248 | |
---|
249 | const size_t m_icache_ways; |
---|
250 | const size_t m_icache_sets; |
---|
251 | const size_t m_icache_yzmask; |
---|
252 | const size_t m_icache_words; |
---|
253 | |
---|
254 | const size_t m_dcache_ways; |
---|
255 | const size_t m_dcache_sets; |
---|
256 | const size_t m_dcache_yzmask; |
---|
257 | const size_t m_dcache_words; |
---|
258 | |
---|
259 | const size_t m_write_buf_size; |
---|
260 | const size_t m_paddr_nbits; |
---|
261 | |
---|
262 | // instruction and data vcache tlb instances |
---|
263 | soclib::caba::GenericCcTlb<paddr_t> icache_tlb; |
---|
264 | soclib::caba::GenericCcTlb<paddr_t> dcache_tlb; |
---|
265 | |
---|
266 | sc_signal<vaddr_t> r_mmu_ptpr; // page table pointer register |
---|
267 | sc_signal<int> r_mmu_mode; // tlb mode register |
---|
268 | sc_signal<int> r_mmu_params; // mmu parameters register |
---|
269 | sc_signal<int> r_mmu_release; // mmu release register |
---|
270 | sc_signal<int> r_mmu_word_lo; // mmu misc data low |
---|
271 | sc_signal<int> r_mmu_word_hi; // mmu mmu misc data hight |
---|
272 | |
---|
273 | // DCACHE FSM REGISTERS |
---|
274 | sc_signal<int> r_dcache_fsm; // state register |
---|
275 | sc_signal<paddr_t> r_dcache_paddr_save; // physical address |
---|
276 | sc_signal<data_t> r_dcache_wdata_save; // write data |
---|
277 | sc_signal<data_t> r_dcache_rdata_save; // read data |
---|
278 | sc_signal<type_t> r_dcache_type_save; // access type |
---|
279 | sc_signal<vci_be_t> r_dcache_be_save; // byte enable |
---|
280 | sc_signal<bool> r_dcache_cached_save; // used by the write buffer |
---|
281 | sc_signal<paddr_t> r_dcache_tlb_paddr; // physical address of tlb miss |
---|
282 | sc_signal<bool> r_dcache_dirty_save; // used for TLB dirty bit update |
---|
283 | sc_signal<size_t> r_dcache_tlb_set_save; // used for TLB dirty bit update |
---|
284 | sc_signal<size_t> r_dcache_tlb_way_save; // used for TLB dirty bit update |
---|
285 | sc_signal<vaddr_t> r_dcache_id1_save; // used by the PT1 bypass |
---|
286 | sc_signal<paddr_t> r_dcache_ptba_save; // used by the PT1 bypass |
---|
287 | sc_signal<bool> r_dcache_ptba_ok; // used by the PT1 bypass |
---|
288 | sc_signal<data_t> r_dcache_pte_update; // used for page table update |
---|
289 | sc_signal<tag_t> r_dcache_ppn_save; // used for speculative cache access |
---|
290 | sc_signal<tag_t> r_dcache_vpn_save; // used for speculative cache access |
---|
291 | sc_signal<bool> r_dtlb_translation_valid; // used for speculative address |
---|
292 | sc_signal<bool> r_dcache_buf_unc_valid; // used for uncached read |
---|
293 | sc_signal<bool> r_dcache_hit_p_save; // used to save hit_p in case BIS |
---|
294 | |
---|
295 | sc_signal<data_t> r_dcache_error_type; // software visible register |
---|
296 | sc_signal<vaddr_t> r_dcache_bad_vaddr; // software visible register |
---|
297 | |
---|
298 | sc_signal<bool> r_dcache_miss_req; // used for cached read miss |
---|
299 | sc_signal<bool> r_dcache_unc_req; // used for uncached read miss |
---|
300 | sc_signal<bool> r_dcache_write_req; // used for write |
---|
301 | sc_signal<bool> r_dcache_tlb_read_req; // used for tlb ptba or pte read |
---|
302 | sc_signal<bool> r_dcache_tlb_first_req; // used for tlb ptba or pte read |
---|
303 | sc_signal<bool> r_dcache_tlb_ll_acc_req; // used for tlb entry type update |
---|
304 | sc_signal<bool> r_dcache_tlb_sc_acc_req; // used for tlb entry type update |
---|
305 | sc_signal<bool> r_dcache_tlb_ll_dirty_req; // used for tlb dirty bit update |
---|
306 | sc_signal<bool> r_dcache_tlb_sc_dirty_req; // used for tlb dirty bit update |
---|
307 | sc_signal<bool> r_dcache_tlb_sc_fail; // used for tlb entry sc failed |
---|
308 | sc_signal<bool> r_dcache_tlb_ptba_read; // used for tlb ptba read when write dirty bit |
---|
309 | sc_signal<bool> r_dcache_xtn_req; // used for xtn write for ICACHE |
---|
310 | |
---|
311 | // coherence registers |
---|
312 | sc_signal<int> r_dcache_fsm_save; // state save register |
---|
313 | sc_signal<size_t> r_dcache_way; |
---|
314 | sc_signal<size_t> r_dcache_set; |
---|
315 | sc_signal<bool> r_dcache_cleanup_req; |
---|
316 | sc_signal<data_t> r_dcache_cleanup_line; |
---|
317 | sc_signal<int> r_dcache_cleanup_type; |
---|
318 | sc_signal<bool> r_dcache_inval_rsp; |
---|
319 | |
---|
320 | // ICACHE FSM REGISTERS |
---|
321 | sc_signal<int> r_icache_fsm; // state register |
---|
322 | sc_signal<paddr_t> r_icache_paddr_save; // physical address |
---|
323 | sc_signal<vaddr_t> r_icache_id1_save; // used by the PT1 bypass |
---|
324 | sc_signal<paddr_t> r_icache_ptba_save; // used by the PT1 bypass |
---|
325 | sc_signal<bool> r_icache_ptba_ok; // used by the PT1 bypass |
---|
326 | sc_signal<data_t> r_icache_pte_update; // used for page table update |
---|
327 | sc_signal<tag_t> r_icache_ppn_save; // used for speculative cache access |
---|
328 | sc_signal<tag_t> r_icache_vpn_save; // used for speculative cache access |
---|
329 | sc_signal<bool> r_itlb_translation_valid; // used for speculative physical address |
---|
330 | sc_signal<bool> r_icache_buf_unc_valid; // used for uncached read |
---|
331 | sc_signal<vaddr_t> r_icache_vaddr_req; // used by the PT1 bypass |
---|
332 | |
---|
333 | sc_signal<data_t> r_icache_error_type; // software visible registers |
---|
334 | sc_signal<vaddr_t> r_icache_bad_vaddr; // software visible registers |
---|
335 | |
---|
336 | sc_signal<bool> r_icache_miss_req; // used for cached read miss |
---|
337 | sc_signal<bool> r_icache_unc_req; // used for uncached read miss |
---|
338 | sc_signal<bool> r_icache_tlb_read_req; // used for tlb ptba or pte read |
---|
339 | sc_signal<bool> r_icache_tlb_first_req; // used for tlb ptba or pte read |
---|
340 | sc_signal<bool> r_icache_tlb_ll_req; // used for tlb entry type update |
---|
341 | sc_signal<bool> r_icache_tlb_sc_req; // used for tlb entry type update |
---|
342 | sc_signal<bool> r_icache_tlb_sc_fail; // used for tlb entry sc failed |
---|
343 | |
---|
344 | // coherence registers |
---|
345 | sc_signal<int> r_icache_fsm_save; |
---|
346 | sc_signal<size_t> r_icache_way; |
---|
347 | sc_signal<size_t> r_icache_set; |
---|
348 | sc_signal<bool> r_icache_cleanup_req; |
---|
349 | sc_signal<data_t> r_icache_cleanup_line; |
---|
350 | sc_signal<int> r_icache_cleanup_type; |
---|
351 | sc_signal<bool> r_icache_inval_rsp; |
---|
352 | |
---|
353 | // VCI_CMD FSM REGISTERS |
---|
354 | sc_signal<int> r_vci_cmd_fsm; |
---|
355 | sc_signal<size_t> r_vci_cmd_min; |
---|
356 | sc_signal<size_t> r_vci_cmd_max; |
---|
357 | sc_signal<size_t> r_vci_cmd_cpt; |
---|
358 | |
---|
359 | // VCI_RSP FSM REGISTERS |
---|
360 | sc_signal<int> r_vci_rsp_fsm; |
---|
361 | sc_signal<size_t> r_vci_rsp_cpt; |
---|
362 | sc_signal<bool> r_vci_rsp_ins_error; |
---|
363 | sc_signal<bool> r_vci_rsp_data_error; |
---|
364 | |
---|
365 | data_t *r_icache_miss_buf; |
---|
366 | data_t *r_dcache_miss_buf; |
---|
367 | |
---|
368 | // VCI_TGT FSM REGISTERS |
---|
369 | data_t *r_tgt_buf; |
---|
370 | bool *r_tgt_val; |
---|
371 | |
---|
372 | sc_signal<int> r_vci_tgt_fsm; |
---|
373 | sc_signal<paddr_t> r_tgt_addr; |
---|
374 | sc_signal<size_t> r_tgt_word; |
---|
375 | sc_signal<bool> r_tgt_update; |
---|
376 | sc_signal<bool> r_tgt_broadcast; |
---|
377 | sc_signal<vci_srcid_t> r_tgt_srcid; |
---|
378 | sc_signal<vci_pktid_t> r_tgt_pktid; |
---|
379 | sc_signal<vci_trdid_t> r_tgt_trdid; |
---|
380 | sc_signal<vci_plen_t> r_tgt_plen; |
---|
381 | sc_signal<bool> r_tgt_icache_req; |
---|
382 | sc_signal<bool> r_tgt_dcache_req; |
---|
383 | sc_signal<bool> r_tgt_icache_rsp; |
---|
384 | sc_signal<bool> r_tgt_dcache_rsp; |
---|
385 | sc_signal<size_t> r_ccinval_itlb_cpt; |
---|
386 | sc_signal<size_t> r_ccinval_dtlb_cpt; |
---|
387 | |
---|
388 | // INVAL CHECK FSM |
---|
389 | sc_signal<int> r_inval_itlb_fsm; |
---|
390 | sc_signal<bool> r_icache_tlb_inval_req; |
---|
391 | sc_signal<bool> r_itlb_cc_check_end; |
---|
392 | sc_signal<size_t> r_ccinval_itlb_way; |
---|
393 | sc_signal<size_t> r_ccinval_itlb_set; |
---|
394 | sc_signal<bool> r_icache_inval_tlb_rsp; |
---|
395 | sc_signal<paddr_t> r_icache_tlb_nline; |
---|
396 | sc_signal<bool> r_icache_cc_hit_t; |
---|
397 | |
---|
398 | sc_signal<int> r_inval_dtlb_fsm; |
---|
399 | sc_signal<bool> r_dcache_tlb_inval_req; |
---|
400 | sc_signal<bool> r_dtlb_cc_check_end; |
---|
401 | sc_signal<size_t> r_ccinval_dtlb_way; |
---|
402 | sc_signal<size_t> r_ccinval_dtlb_set; |
---|
403 | sc_signal<bool> r_dcache_inval_tlb_rsp; |
---|
404 | sc_signal<paddr_t> r_dcache_tlb_nline; |
---|
405 | sc_signal<bool> r_dcache_cc_hit_t; |
---|
406 | |
---|
407 | WriteBuffer<paddr_t> r_wbuf; |
---|
408 | GenericCache<paddr_t> r_icache; |
---|
409 | GenericCache<paddr_t> r_dcache; |
---|
410 | |
---|
411 | // Activity counters |
---|
412 | uint32_t m_cpt_dcache_data_read; // DCACHE DATA READ |
---|
413 | uint32_t m_cpt_dcache_data_write; // DCACHE DATA WRITE |
---|
414 | uint32_t m_cpt_dcache_dir_read; // DCACHE DIR READ |
---|
415 | uint32_t m_cpt_dcache_dir_write; // DCACHE DIR WRITE |
---|
416 | |
---|
417 | uint32_t m_cpt_icache_data_read; // ICACHE DATA READ |
---|
418 | uint32_t m_cpt_icache_data_write; // ICACHE DATA WRITE |
---|
419 | uint32_t m_cpt_icache_dir_read; // ICACHE DIR READ |
---|
420 | uint32_t m_cpt_icache_dir_write; // ICACHE DIR WRITE |
---|
421 | |
---|
422 | uint32_t m_cpt_frz_cycles; // number of cycles where the cpu is frozen |
---|
423 | uint32_t m_cpt_total_cycles; // total number of cycles |
---|
424 | |
---|
425 | // Cache activity counters |
---|
426 | uint32_t m_cpt_read; // total number of read data |
---|
427 | uint32_t m_cpt_write; // total number of write data |
---|
428 | uint32_t m_cpt_data_miss; // number of read miss |
---|
429 | uint32_t m_cpt_ins_miss; // number of instruction miss |
---|
430 | uint32_t m_cpt_unc_read; // number of read uncached |
---|
431 | uint32_t m_cpt_write_cached; // number of cached write |
---|
432 | uint32_t m_cpt_ins_read; // number of instruction read |
---|
433 | |
---|
434 | uint32_t m_cost_write_frz; // number of frozen cycles related to write buffer of cache |
---|
435 | uint32_t m_cost_data_miss_frz; // number of frozen cycles related to data miss of cache |
---|
436 | uint32_t m_cost_unc_read_frz; // number of frozen cycles related to uncached read of cache |
---|
437 | uint32_t m_cost_ins_miss_frz; // number of frozen cycles related to ins miss of cache |
---|
438 | |
---|
439 | uint32_t m_cpt_imiss_transaction; // number of VCI instruction miss transactions |
---|
440 | uint32_t m_cpt_dmiss_transaction; // number of VCI data miss transactions |
---|
441 | uint32_t m_cpt_unc_transaction; // number of VCI uncached read transactions |
---|
442 | uint32_t m_cpt_write_transaction; // number of VCI write transactions |
---|
443 | uint32_t m_cpt_icache_unc_transaction; // number of VCI instruction uncached transactions |
---|
444 | |
---|
445 | uint32_t m_cost_imiss_transaction; // cumulated duration for VCI IMISS transactions |
---|
446 | uint32_t m_cost_dmiss_transaction; // cumulated duration for VCI DMISS transactions |
---|
447 | uint32_t m_cost_unc_transaction; // cumulated duration for VCI UNC transactions |
---|
448 | uint32_t m_cost_icache_unc_transaction; // cumulated duration for VCI IUNC transactions |
---|
449 | uint32_t m_cost_write_transaction; // cumulated duration for VCI WRITE transactions |
---|
450 | uint32_t m_length_write_transaction; // cumulated length for VCI WRITE transactions |
---|
451 | |
---|
452 | // TLB activity counters |
---|
453 | uint32_t m_cpt_ins_tlb_read; // number of instruction tlb read |
---|
454 | uint32_t m_cpt_ins_tlb_miss; // number of instruction tlb miss |
---|
455 | uint32_t m_cpt_ins_tlb_update_acc; // number of instruction tlb update acc |
---|
456 | uint32_t m_cpt_data_tlb_read; // number of data tlb read |
---|
457 | uint32_t m_cpt_data_tlb_miss; // number of data tlb miss |
---|
458 | uint32_t m_cpt_data_tlb_update_acc; // number of data tlb update acc |
---|
459 | uint32_t m_cpt_data_tlb_update_dirty; // number of data tlb update dirty |
---|
460 | |
---|
461 | uint32_t m_cost_ins_tlb_miss_frz; // number of frozen cycles related to instruction tlb miss |
---|
462 | uint32_t m_cost_data_tlb_miss_frz; // number of frozen cycles related to data tlb miss |
---|
463 | uint32_t m_cost_ins_tlb_update_acc_frz; // number of cycles for instruction tlb flush |
---|
464 | uint32_t m_cost_data_tlb_update_acc_frz; // number of cycles for data tlb flush |
---|
465 | uint32_t m_cost_data_tlb_update_dirty_frz; // number of cycles for instruction cache flush |
---|
466 | |
---|
467 | uint32_t m_cpt_itlbmiss_transaction; // number of itlb miss transactions |
---|
468 | uint32_t m_cpt_itlb_ll_transaction; // number of itlb ll acc transactions |
---|
469 | uint32_t m_cpt_itlb_sc_transaction; // number of itlb sc acc transactions |
---|
470 | uint32_t m_cpt_dtlbmiss_transaction; // number of dtlb miss transactions |
---|
471 | uint32_t m_cpt_dtlb_ll_transaction; // number of dtlb ll acc transactions |
---|
472 | uint32_t m_cpt_dtlb_sc_transaction; // number of dtlb sc acc transactions |
---|
473 | uint32_t m_cpt_dtlb_ll_dirty_transaction; // number of dtlb ll dirty transactions |
---|
474 | uint32_t m_cpt_dtlb_sc_dirty_transaction; // number of dtlb sc dirty transactions |
---|
475 | |
---|
476 | uint32_t m_cost_itlbmiss_transaction; // cumulated duration for VCI instruction TLB miss transactions |
---|
477 | uint32_t m_cost_itlb_ll_transaction; // cumulated duration for VCI instruction TLB ll acc transactions |
---|
478 | uint32_t m_cost_itlb_sc_transaction; // cumulated duration for VCI instruction TLB sc acc transactions |
---|
479 | uint32_t m_cost_dtlbmiss_transaction; // cumulated duration for VCI data TLB miss transactions |
---|
480 | uint32_t m_cost_dtlb_ll_transaction; // cumulated duration for VCI data TLB ll acc transactions |
---|
481 | uint32_t m_cost_dtlb_sc_transaction; // cumulated duration for VCI data TLB sc acc transactions |
---|
482 | uint32_t m_cost_dtlb_ll_dirty_transaction;// cumulated duration for VCI data TLB ll dirty transactions |
---|
483 | uint32_t m_cost_dtlb_sc_dirty_transaction;// cumulated duration for VCI data TLB sc dirty transactions |
---|
484 | |
---|
485 | uint32_t m_cpt_cc_cleanup_ins; |
---|
486 | uint32_t m_cpt_cc_cleanup_data; |
---|
487 | uint32_t m_cpt_icleanup_transaction; |
---|
488 | uint32_t m_cpt_dcleanup_transaction; |
---|
489 | uint32_t m_cost_icleanup_transaction; |
---|
490 | uint32_t m_cost_dcleanup_transaction; |
---|
491 | |
---|
492 | uint32_t m_cpt_cc_update_data; // number of coherence update data packets |
---|
493 | uint32_t m_cpt_cc_inval_ins; // number of coherence inval instruction packets |
---|
494 | uint32_t m_cpt_cc_inval_data; // number of coherence inval data packets |
---|
495 | uint32_t m_cpt_cc_broadcast; // number of coherence broadcast packets |
---|
496 | |
---|
497 | protected: |
---|
498 | SC_HAS_PROCESS(VciCcVCacheWrapperV1); |
---|
499 | |
---|
500 | public: |
---|
501 | VciCcVCacheWrapperV1( |
---|
502 | sc_module_name insname, |
---|
503 | int proc_id, |
---|
504 | const soclib::common::MappingTable &mtp, |
---|
505 | const soclib::common::MappingTable &mtc, |
---|
506 | const soclib::common::IntTab &initiator_index_rw, |
---|
507 | const soclib::common::IntTab &initiator_index_c, |
---|
508 | const soclib::common::IntTab &target_index, |
---|
509 | size_t itlb_ways, |
---|
510 | size_t itlb_sets, |
---|
511 | size_t dtlb_ways, |
---|
512 | size_t dtlb_sets, |
---|
513 | size_t icache_ways, |
---|
514 | size_t icache_sets, |
---|
515 | size_t icache_words, |
---|
516 | size_t dcache_ways, |
---|
517 | size_t dcache_sets, |
---|
518 | size_t dcache_words, |
---|
519 | size_t write_buf_size ); |
---|
520 | |
---|
521 | ~VciCcVCacheWrapperV1(); |
---|
522 | |
---|
523 | void print_cpi(); |
---|
524 | void print_stats(); |
---|
525 | |
---|
526 | private: |
---|
527 | void transition(); |
---|
528 | void genMoore(); |
---|
529 | |
---|
530 | soclib_static_assert((int)iss_t::SC_ATOMIC == (int)vci_param::STORE_COND_ATOMIC); |
---|
531 | soclib_static_assert((int)iss_t::SC_NOT_ATOMIC == (int)vci_param::STORE_COND_NOT_ATOMIC); |
---|
532 | }; |
---|
533 | |
---|
534 | }} |
---|
535 | |
---|
536 | #endif /* SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_V1_H */ |
---|
537 | |
---|
538 | // Local Variables: |
---|
539 | // tab-width: 4 |
---|
540 | // c-basic-offset: 4 |
---|
541 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
542 | // indent-tabs-mode: nil |
---|
543 | // End: |
---|
544 | |
---|
545 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
546 | |
---|