1 | /* -*- c++ -*- |
---|
2 | * File : vci_cc_vcache_wrapper_v4.h |
---|
3 | * Copyright (c) UPMC, Lip6, SoC |
---|
4 | * Authors : Alain GREINER, Yang GAO |
---|
5 | * Date : 27/11/2011 |
---|
6 | * |
---|
7 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
8 | * |
---|
9 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
10 | * |
---|
11 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
12 | * under the terms of the GNU Lesser General Public License as published |
---|
13 | * by the Free Software Foundation; version 2.1 of the License. |
---|
14 | * |
---|
15 | * SoCLib is distributed in the hope that it will be useful, but |
---|
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | * Lesser General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU Lesser General Public |
---|
21 | * License along with SoCLib; if not, write to the Free Software |
---|
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
23 | * 02110-1301 USA |
---|
24 | * |
---|
25 | * SOCLIB_LGPL_HEADER_END |
---|
26 | */ |
---|
27 | |
---|
28 | #ifndef SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_V4_H |
---|
29 | #define SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_V4_H |
---|
30 | |
---|
31 | #include <inttypes.h> |
---|
32 | #include <systemc> |
---|
33 | #include "caba_base_module.h" |
---|
34 | #include "multi_write_buffer.h" |
---|
35 | #include "generic_fifo.h" |
---|
36 | #include "generic_tlb.h" |
---|
37 | #include "generic_cam.h" |
---|
38 | #include "generic_cache.h" |
---|
39 | #include "vci_initiator.h" |
---|
40 | #include "vci_target.h" |
---|
41 | #include "mapping_table.h" |
---|
42 | #include "static_assert.h" |
---|
43 | #include "iss2.h" |
---|
44 | |
---|
45 | namespace soclib { |
---|
46 | namespace caba { |
---|
47 | |
---|
48 | using namespace sc_core; |
---|
49 | |
---|
50 | //////////////////////////////////////////// |
---|
51 | template<typename vci_param, typename iss_t> |
---|
52 | class VciCcVCacheWrapperV4 |
---|
53 | //////////////////////////////////////////// |
---|
54 | : public soclib::caba::BaseModule |
---|
55 | { |
---|
56 | typedef uint32_t vaddr_t; |
---|
57 | typedef uint32_t tag_t; |
---|
58 | typedef uint32_t type_t; |
---|
59 | typedef typename iss_t::DataOperationType data_op_t; |
---|
60 | |
---|
61 | typedef typename vci_param::addr_t paddr_t; |
---|
62 | typedef typename vci_param::be_t vci_be_t; |
---|
63 | typedef typename vci_param::srcid_t vci_srcid_t; |
---|
64 | typedef typename vci_param::trdid_t vci_trdid_t; |
---|
65 | typedef typename vci_param::pktid_t vci_pktid_t; |
---|
66 | typedef typename vci_param::plen_t vci_plen_t; |
---|
67 | |
---|
68 | enum icache_fsm_state_e { |
---|
69 | ICACHE_IDLE, |
---|
70 | // handling XTN processor requests |
---|
71 | ICACHE_XTN_TLB_FLUSH, |
---|
72 | ICACHE_XTN_CACHE_FLUSH, |
---|
73 | ICACHE_XTN_TLB_INVAL, |
---|
74 | ICACHE_XTN_CACHE_INVAL_VA, |
---|
75 | ICACHE_XTN_CACHE_INVAL_PA, |
---|
76 | ICACHE_XTN_CACHE_INVAL_GO, |
---|
77 | // handling tlb miss |
---|
78 | ICACHE_TLB_WAIT, |
---|
79 | // handling cache miss |
---|
80 | ICACHE_MISS_VICTIM, |
---|
81 | ICACHE_MISS_INVAL, |
---|
82 | ICACHE_MISS_WAIT, |
---|
83 | ICACHE_MISS_UPDT, |
---|
84 | // handling unc read |
---|
85 | ICACHE_UNC_WAIT, |
---|
86 | // handling coherence requests |
---|
87 | ICACHE_CC_CHECK, |
---|
88 | ICACHE_CC_INVAL, |
---|
89 | ICACHE_CC_UPDT, |
---|
90 | }; |
---|
91 | |
---|
92 | enum dcache_fsm_state_e { |
---|
93 | DCACHE_IDLE, |
---|
94 | // handling itlb & dtlb miss |
---|
95 | DCACHE_TLB_MISS, |
---|
96 | DCACHE_TLB_PTE1_GET, |
---|
97 | DCACHE_TLB_PTE1_SELECT, |
---|
98 | DCACHE_TLB_PTE1_UPDT, |
---|
99 | DCACHE_TLB_PTE2_GET, |
---|
100 | DCACHE_TLB_PTE2_SELECT, |
---|
101 | DCACHE_TLB_PTE2_UPDT, |
---|
102 | DCACHE_TLB_SC_UPDT, |
---|
103 | DCACHE_TLB_SC_WAIT, |
---|
104 | DCACHE_TLB_RETURN, |
---|
105 | // handling processor XTN requests |
---|
106 | DCACHE_XTN_SWITCH, |
---|
107 | DCACHE_XTN_SYNC, |
---|
108 | DCACHE_XTN_IC_INVAL_VA, |
---|
109 | DCACHE_XTN_IC_FLUSH, |
---|
110 | DCACHE_XTN_IC_INVAL_PA, |
---|
111 | DCACHE_XTN_IT_INVAL, |
---|
112 | DCACHE_XTN_DC_FLUSH, |
---|
113 | DCACHE_XTN_DC_INVAL_VA, |
---|
114 | DCACHE_XTN_DC_INVAL_PA, |
---|
115 | DCACHE_XTN_DC_INVAL_WAIT, |
---|
116 | DCACHE_XTN_DC_INVAL_GO, |
---|
117 | DCACHE_XTN_DT_INVAL, |
---|
118 | //handling fourth stage write |
---|
119 | DCACHE_WRITE_TLB_DIRTY, |
---|
120 | DCACHE_WRITE_CACHE_DIRTY, |
---|
121 | DCACHE_WRITE_SC_WAIT, |
---|
122 | DCACHE_WRITE_UNC_WAIT, |
---|
123 | // handling processor miss requests |
---|
124 | DCACHE_MISS_VICTIM, |
---|
125 | DCACHE_MISS_INVAL, |
---|
126 | DCACHE_MISS_INVAL_WAIT, |
---|
127 | DCACHE_MISS_WAIT, |
---|
128 | DCACHE_MISS_UPDT, |
---|
129 | // handling processor unc and sc requests |
---|
130 | DCACHE_UNC_WAIT, |
---|
131 | // handling coherence requests |
---|
132 | DCACHE_CC_CHECK, |
---|
133 | DCACHE_CC_INVAL, |
---|
134 | DCACHE_CC_UPDT, |
---|
135 | DCACHE_CC_WAIT, |
---|
136 | }; |
---|
137 | |
---|
138 | enum cmd_fsm_state_e { |
---|
139 | CMD_IDLE, |
---|
140 | CMD_INS_MISS, |
---|
141 | CMD_INS_UNC, |
---|
142 | CMD_DATA_MISS, |
---|
143 | CMD_DATA_UNC, |
---|
144 | CMD_DATA_WRITE, |
---|
145 | CMD_DATA_SC, |
---|
146 | }; |
---|
147 | |
---|
148 | enum rsp_fsm_state_e { |
---|
149 | RSP_IDLE, |
---|
150 | RSP_INS_MISS, |
---|
151 | RSP_INS_UNC, |
---|
152 | RSP_DATA_MISS, |
---|
153 | RSP_DATA_UNC, |
---|
154 | RSP_DATA_WRITE, |
---|
155 | RSP_DATA_SC, |
---|
156 | }; |
---|
157 | |
---|
158 | enum cleanup_cmd_fsm_state_e { |
---|
159 | CLEANUP_DATA_IDLE, |
---|
160 | CLEANUP_DATA_GO, |
---|
161 | CLEANUP_INS_IDLE, |
---|
162 | CLEANUP_INS_GO, |
---|
163 | }; |
---|
164 | |
---|
165 | enum tgt_fsm_state_e { |
---|
166 | TGT_IDLE, |
---|
167 | TGT_UPDT_WORD, |
---|
168 | TGT_UPDT_DATA, |
---|
169 | TGT_REQ_BROADCAST, |
---|
170 | TGT_REQ_ICACHE, |
---|
171 | TGT_REQ_DCACHE, |
---|
172 | TGT_RSP_BROADCAST, |
---|
173 | TGT_RSP_ICACHE, |
---|
174 | TGT_RSP_DCACHE, |
---|
175 | }; |
---|
176 | |
---|
177 | enum inval_itlb_fsm_state_e { |
---|
178 | INVAL_ITLB_IDLE, |
---|
179 | INVAL_ITLB_SCAN, |
---|
180 | }; |
---|
181 | |
---|
182 | enum inval_dtlb_fsm_state_e { |
---|
183 | INVAL_DTLB_IDLE, |
---|
184 | INVAL_DTLB_SCAN, |
---|
185 | }; |
---|
186 | |
---|
187 | // TLB Mode : ITLB / DTLB / ICACHE / DCACHE |
---|
188 | enum { |
---|
189 | INS_TLB_MASK = 0x8, |
---|
190 | DATA_TLB_MASK = 0x4, |
---|
191 | INS_CACHE_MASK = 0x2, |
---|
192 | DATA_CACHE_MASK = 0x1, |
---|
193 | }; |
---|
194 | |
---|
195 | // Error Type |
---|
196 | enum mmu_error_type_e |
---|
197 | { |
---|
198 | MMU_NONE = 0x0000, // None |
---|
199 | MMU_WRITE_PT1_UNMAPPED = 0x0001, // Write access of Page fault on Page Table 1 |
---|
200 | MMU_WRITE_PT2_UNMAPPED = 0x0002, // Write access of Page fault on Page Table 2 |
---|
201 | MMU_WRITE_PRIVILEGE_VIOLATION = 0x0004, // Write access of Protected access in user mode |
---|
202 | MMU_WRITE_ACCES_VIOLATION = 0x0008, // Write access of write access to a non writable page |
---|
203 | MMU_WRITE_UNDEFINED_XTN = 0x0020, // Write access of undefined external access address |
---|
204 | MMU_WRITE_PT1_ILLEGAL_ACCESS = 0x0040, // Write access of Bus Error accessing Table 1 |
---|
205 | MMU_WRITE_PT2_ILLEGAL_ACCESS = 0x0080, // Write access of Bus Error accessing Table 2 |
---|
206 | MMU_WRITE_DATA_ILLEGAL_ACCESS = 0x0100, // Write access of Bus Error in cache access |
---|
207 | MMU_READ_PT1_UNMAPPED = 0x1001, // Read access of Page fault on Page Table 1 |
---|
208 | MMU_READ_PT2_UNMAPPED = 0x1002, // Read access of Page fault on Page Table 2 |
---|
209 | MMU_READ_PRIVILEGE_VIOLATION = 0x1004, // Read access of Protected access in user mode |
---|
210 | MMU_READ_EXEC_VIOLATION = 0x1010, // Exec access to a non exec page |
---|
211 | MMU_READ_UNDEFINED_XTN = 0x1020, // Read access of Undefined external access address |
---|
212 | MMU_READ_PT1_ILLEGAL_ACCESS = 0x1040, // Read access of Bus Error in Table1 access |
---|
213 | MMU_READ_PT2_ILLEGAL_ACCESS = 0x1080, // Read access of Bus Error in Table2 access |
---|
214 | MMU_READ_DATA_ILLEGAL_ACCESS = 0x1100, // Read access of Bus Error in cache access |
---|
215 | }; |
---|
216 | |
---|
217 | // miss types for data cache |
---|
218 | enum dcache_miss_type_e |
---|
219 | { |
---|
220 | PTE1_MISS, |
---|
221 | PTE2_MISS, |
---|
222 | PROC_MISS, |
---|
223 | }; |
---|
224 | |
---|
225 | enum transaction_type_d_e |
---|
226 | { |
---|
227 | // b0 : 1 if cached |
---|
228 | // b1 : 1 if instruction |
---|
229 | TYPE_DATA_UNC = 0x0, |
---|
230 | TYPE_DATA_MISS = 0x1, |
---|
231 | TYPE_INS_UNC = 0x2, |
---|
232 | TYPE_INS_MISS = 0x3, |
---|
233 | }; |
---|
234 | |
---|
235 | public: |
---|
236 | sc_in<bool> p_clk; |
---|
237 | sc_in<bool> p_resetn; |
---|
238 | sc_in<bool> p_irq[iss_t::n_irq]; |
---|
239 | soclib::caba::VciInitiator<vci_param> p_vci_ini_d; |
---|
240 | soclib::caba::VciInitiator<vci_param> p_vci_ini_c; |
---|
241 | soclib::caba::VciTarget<vci_param> p_vci_tgt_c; |
---|
242 | |
---|
243 | private: |
---|
244 | |
---|
245 | // STRUCTURAL PARAMETERS |
---|
246 | soclib::common::AddressDecodingTable<uint32_t, bool> m_cacheability_table; |
---|
247 | const soclib::common::Segment m_segment; |
---|
248 | const vci_srcid_t m_srcid_d; |
---|
249 | const vci_srcid_t m_srcid_c; |
---|
250 | |
---|
251 | const size_t m_itlb_ways; |
---|
252 | const size_t m_itlb_sets; |
---|
253 | |
---|
254 | const size_t m_dtlb_ways; |
---|
255 | const size_t m_dtlb_sets; |
---|
256 | |
---|
257 | const size_t m_icache_ways; |
---|
258 | const size_t m_icache_sets; |
---|
259 | const paddr_t m_icache_yzmask; |
---|
260 | const size_t m_icache_words; |
---|
261 | |
---|
262 | const size_t m_dcache_ways; |
---|
263 | const size_t m_dcache_sets; |
---|
264 | const paddr_t m_dcache_yzmask; |
---|
265 | const size_t m_dcache_words; |
---|
266 | |
---|
267 | const size_t m_proc_id; |
---|
268 | |
---|
269 | const uint32_t m_max_frozen_cycles; |
---|
270 | |
---|
271 | const size_t m_paddr_nbits; |
---|
272 | |
---|
273 | //////////////////////////////////////// |
---|
274 | // Variables used by print_trace() |
---|
275 | //////////////////////////////////////// |
---|
276 | |
---|
277 | bool m_ireq_valid; |
---|
278 | uint32_t m_ireq_addr; |
---|
279 | soclib::common::Iss2::ExecMode m_ireq_mode; |
---|
280 | |
---|
281 | bool m_irsp_valid; |
---|
282 | uint32_t m_irsp_instruction; |
---|
283 | bool m_irsp_error; |
---|
284 | |
---|
285 | bool m_dreq_valid; |
---|
286 | uint32_t m_dreq_addr; |
---|
287 | soclib::common::Iss2::ExecMode m_dreq_mode; |
---|
288 | soclib::common::Iss2::DataOperationType m_dreq_type; |
---|
289 | uint32_t m_dreq_wdata; |
---|
290 | uint8_t m_dreq_be; |
---|
291 | |
---|
292 | bool m_drsp_valid; |
---|
293 | uint32_t m_drsp_rdata; |
---|
294 | bool m_drsp_error; |
---|
295 | |
---|
296 | ///////////////////////////////////////////// |
---|
297 | // debug variables (for each FSM) |
---|
298 | ///////////////////////////////////////////// |
---|
299 | uint32_t m_debug_start_cycle; |
---|
300 | bool m_debug_ok; |
---|
301 | bool m_debug_previous_hit; |
---|
302 | bool m_debug_dcache_fsm; |
---|
303 | bool m_debug_icache_fsm; |
---|
304 | bool m_debug_cleanup_fsm; |
---|
305 | bool m_debug_inval_itlb_fsm; |
---|
306 | bool m_debug_inval_dtlb_fsm; |
---|
307 | |
---|
308 | /////////////////////////////// |
---|
309 | // Software visible REGISTERS |
---|
310 | /////////////////////////////// |
---|
311 | sc_signal<uint32_t> r_mmu_ptpr; // page table pointer register |
---|
312 | sc_signal<uint32_t> r_mmu_mode; // mmu mode register |
---|
313 | sc_signal<uint32_t> r_mmu_word_lo; // mmu misc data low |
---|
314 | sc_signal<uint32_t> r_mmu_word_hi; // mmu misc data hight |
---|
315 | sc_signal<uint32_t> r_mmu_ibvar; // mmu bad instruction address |
---|
316 | sc_signal<uint32_t> r_mmu_dbvar; // mmu bad data address |
---|
317 | sc_signal<uint32_t> r_mmu_ietr; // mmu instruction error type |
---|
318 | sc_signal<uint32_t> r_mmu_detr; // mmu data error type |
---|
319 | sc_signal<uint32_t> r_mmu_params; // read-only |
---|
320 | sc_signal<uint32_t> r_mmu_release; // read_only |
---|
321 | |
---|
322 | |
---|
323 | ////////////////////////////// |
---|
324 | // ICACHE FSM REGISTERS |
---|
325 | ////////////////////////////// |
---|
326 | sc_signal<int> r_icache_fsm; // state register |
---|
327 | sc_signal<int> r_icache_fsm_save; // return state for coherence operation |
---|
328 | sc_signal<paddr_t> r_icache_vci_paddr; // physical address |
---|
329 | sc_signal<uint32_t> r_icache_vaddr_save; // virtual address requested by the processor |
---|
330 | |
---|
331 | // icache miss handling |
---|
332 | sc_signal<size_t> r_icache_miss_way; // selected way for cache update |
---|
333 | sc_signal<size_t> r_icache_miss_set; // selected set for cache update |
---|
334 | sc_signal<size_t> r_icache_miss_word; // word index for sequencial cache update |
---|
335 | sc_signal<bool> r_icache_miss_inval; // coherence request matching a pending miss |
---|
336 | |
---|
337 | // coherence request handling |
---|
338 | sc_signal<size_t> r_icache_cc_way; // selected way for cc update/inval |
---|
339 | sc_signal<size_t> r_icache_cc_set; // selected set for cc update/inval |
---|
340 | sc_signal<size_t> r_icache_cc_word; // word counter for cc update |
---|
341 | |
---|
342 | // icache flush handling |
---|
343 | sc_signal<size_t> r_icache_flush_count; // slot counter used for cache flush |
---|
344 | |
---|
345 | // communication between ICACHE FSM and VCI_CMD FSM |
---|
346 | sc_signal<bool> r_icache_miss_req; // cached read miss |
---|
347 | sc_signal<bool> r_icache_unc_req; // uncached read miss |
---|
348 | |
---|
349 | // communication between ICACHE FSM and DCACHE FSM |
---|
350 | sc_signal<bool> r_icache_tlb_miss_req; // itlb miss request (set icache/reset dcache) |
---|
351 | sc_signal<bool> r_icache_tlb_rsp_error; // itlb miss response error (written by dcache) |
---|
352 | |
---|
353 | // communication between ICACHE FSM and CLEANUP FSMs |
---|
354 | sc_signal<bool> r_icache_cleanup_req; // ins cleanup request |
---|
355 | sc_signal<paddr_t> r_icache_cleanup_line; // ins cleanup NLINE |
---|
356 | |
---|
357 | /////////////////////////////// |
---|
358 | // DCACHE FSM REGISTERS |
---|
359 | /////////////////////////////// |
---|
360 | sc_signal<int> r_dcache_fsm; // state register |
---|
361 | sc_signal<int> r_dcache_fsm_save; // return state for coherence operation |
---|
362 | // registers written in P0 stage (used in P1 stage) |
---|
363 | sc_signal<bool> r_dcache_p0_valid; // P1 pipeline stage must be executed |
---|
364 | sc_signal<uint32_t> r_dcache_p0_vaddr; // virtual address (from proc) |
---|
365 | sc_signal<uint32_t> r_dcache_p0_wdata; // write data (from proc) |
---|
366 | sc_signal<vci_be_t> r_dcache_p0_be; // byte enable (from proc) |
---|
367 | sc_signal<paddr_t> r_dcache_p0_paddr; // physical address |
---|
368 | sc_signal<bool> r_dcache_p0_cacheable; // address cacheable |
---|
369 | sc_signal<size_t> r_dcache_p0_tlb_way; // selected way (from dtlb) |
---|
370 | sc_signal<size_t> r_dcache_p0_tlb_set; // selected set (from dtlb) |
---|
371 | sc_signal<paddr_t> r_dcache_p0_tlb_nline; // nline value (from dtlb) |
---|
372 | sc_signal<bool> r_dcache_p0_tlb_dirty; // dirty bit (from dtlb) |
---|
373 | sc_signal<bool> r_dcache_p0_tlb_big; // big page bit (from dtlb) |
---|
374 | // registers written in P1 stage (used in P2 stage) |
---|
375 | sc_signal<bool> r_dcache_p1_valid; // P2 pipeline stage must be executed |
---|
376 | sc_signal<bool> r_dcache_p1_updt_cache; // dcache must be updated |
---|
377 | sc_signal<bool> r_dcache_p1_set_dirty; // PTE dirty bit must be set |
---|
378 | sc_signal<uint32_t> r_dcache_p1_vaddr; // virtual address (from proc) |
---|
379 | sc_signal<uint32_t> r_dcache_p1_wdata; // write data (from proc) |
---|
380 | sc_signal<vci_be_t> r_dcache_p1_be; // byte enable (from proc) |
---|
381 | sc_signal<paddr_t> r_dcache_p1_paddr; // physical address |
---|
382 | sc_signal<size_t> r_dcache_p1_cache_way; // selected way (from dcache) |
---|
383 | sc_signal<size_t> r_dcache_p1_cache_set; // selected set (from dcache) |
---|
384 | sc_signal<size_t> r_dcache_p1_cache_word; // selected word (from dcache) |
---|
385 | sc_signal<size_t> r_dcache_p1_tlb_way; // selected way (from dtlb) |
---|
386 | sc_signal<size_t> r_dcache_p1_tlb_set; // selected set (from dtlb) |
---|
387 | sc_signal<paddr_t> r_dcache_p1_tlb_nline; // nline value (from dtlb) |
---|
388 | // registers written in P2 stage (used in P3 stage) |
---|
389 | sc_signal<uint32_t> r_dcache_p2_vaddr; // virtual address (from proc) |
---|
390 | sc_signal<size_t> r_dcache_p2_tlb_way; // selected way in dtlb |
---|
391 | sc_signal<size_t> r_dcache_p2_tlb_set; // selected set in dtlb |
---|
392 | sc_signal<bool> r_dcache_p2_set_dirty; // PTE dirty bit must be set |
---|
393 | sc_signal<paddr_t> r_dcache_p2_pte_paddr; // PTE physical address |
---|
394 | sc_signal<size_t> r_dcache_p2_pte_way; // selected way in dcache |
---|
395 | sc_signal<size_t> r_dcache_p2_pte_set; // selected set in dcache |
---|
396 | sc_signal<size_t> r_dcache_p2_pte_word; // selected word in dcache |
---|
397 | sc_signal<size_t> r_dcache_p2_pte_flags; // pte value read in dcache |
---|
398 | |
---|
399 | // communication between DCACHE FSM and VCI_CMD FSM |
---|
400 | sc_signal<paddr_t> r_dcache_vci_paddr; // physical address for VCI command |
---|
401 | sc_signal<bool> r_dcache_vci_miss_req; // read miss request |
---|
402 | sc_signal<bool> r_dcache_vci_unc_req; // uncacheable read request |
---|
403 | sc_signal<bool> r_dcache_vci_unc_be; // uncacheable read byte enable |
---|
404 | sc_signal<bool> r_dcache_vci_sc_req; // atomic write request (Compare & swap) |
---|
405 | sc_signal<uint32_t> r_dcache_vci_sc_old; // previous data value for an atomic write |
---|
406 | sc_signal<uint32_t> r_dcache_vci_sc_new; // new data value for an atomic write |
---|
407 | |
---|
408 | // register used for XTN inval |
---|
409 | sc_signal<size_t> r_dcache_xtn_way; // selected way (from dcache) |
---|
410 | sc_signal<size_t> r_dcache_xtn_set; // selected set (from dcache) |
---|
411 | |
---|
412 | // write buffer state extension |
---|
413 | sc_signal<bool> r_dcache_pending_unc_write; // pending uncacheable write in WBUF |
---|
414 | |
---|
415 | // handling dcache miss |
---|
416 | sc_signal<int> r_dcache_miss_type; // type of miss depending on the requester |
---|
417 | sc_signal<size_t> r_dcache_miss_word; // word index for sequencial cache update |
---|
418 | sc_signal<size_t> r_dcache_miss_way; // selected way for cache update |
---|
419 | sc_signal<size_t> r_dcache_miss_set; // selected set for cache update |
---|
420 | sc_signal<bool> r_dcache_miss_inval; // coherence request matching a pending miss |
---|
421 | |
---|
422 | // handling coherence requests |
---|
423 | sc_signal<size_t> r_dcache_cc_way; // selected way for cc update/inval |
---|
424 | sc_signal<size_t> r_dcache_cc_set; // selected set for cc update/inval |
---|
425 | sc_signal<size_t> r_dcache_cc_word; // word counter for cc update |
---|
426 | |
---|
427 | // dcache flush handling |
---|
428 | sc_signal<size_t> r_dcache_flush_count; // slot counter used for cache flush |
---|
429 | |
---|
430 | // used by the TLB miss sub-fsm |
---|
431 | sc_signal<uint32_t> r_dcache_tlb_vaddr; // virtual address for a tlb miss |
---|
432 | sc_signal<bool> r_dcache_tlb_ins; // target tlb (itlb if true) |
---|
433 | sc_signal<paddr_t> r_dcache_tlb_paddr; // physical address of pte |
---|
434 | sc_signal<uint32_t> r_dcache_tlb_pte_flags; // pte1 or first word of pte2 |
---|
435 | sc_signal<uint32_t> r_dcache_tlb_pte_ppn; // second word of pte2 |
---|
436 | sc_signal<size_t> r_dcache_tlb_cache_way; // selected way in dcache |
---|
437 | sc_signal<size_t> r_dcache_tlb_cache_set; // selected set in dcache |
---|
438 | sc_signal<size_t> r_dcache_tlb_cache_word; // selected word in dcache |
---|
439 | sc_signal<size_t> r_dcache_tlb_way; // selected way in tlb |
---|
440 | sc_signal<size_t> r_dcache_tlb_set; // selected set in tlb |
---|
441 | |
---|
442 | // LL reservation handling |
---|
443 | sc_signal<bool> r_dcache_ll_valid; // valid LL reservation |
---|
444 | sc_signal<uint32_t> r_dcache_ll_data; // LL reserved data |
---|
445 | sc_signal<paddr_t> r_dcache_ll_vaddr; // LL reserved address |
---|
446 | |
---|
447 | // communication between DCACHE FSM and INVAL_ITLB/INVAL_DTLB FSMs |
---|
448 | sc_signal<bool> r_dcache_itlb_inval_req; // inval request of one or several TLB entries |
---|
449 | sc_signal<bool> r_dcache_dtlb_inval_req; // inval request of one or several TLB entries; |
---|
450 | sc_signal<paddr_t> r_dcache_tlb_inval_line; // line index |
---|
451 | |
---|
452 | // communication between DCACHE FSM and ICACHE FSM |
---|
453 | sc_signal<bool> r_dcache_xtn_req; // xtn request (caused by processor) |
---|
454 | sc_signal<int> r_dcache_xtn_opcode; // xtn request type |
---|
455 | |
---|
456 | // communication between DCACHE FSM and CLEANUP FSMs |
---|
457 | sc_signal<bool> r_dcache_cleanup_req; // data cleanup request |
---|
458 | sc_signal<paddr_t> r_dcache_cleanup_line; // data cleanup NLINE |
---|
459 | |
---|
460 | // dcache directory extension |
---|
461 | bool *r_dcache_in_itlb; // copy of dcache line in itlb |
---|
462 | bool *r_dcache_in_dtlb; // copy of dcache line in dtlb |
---|
463 | |
---|
464 | /////////////////////////////////// |
---|
465 | // VCI_CMD FSM REGISTERS |
---|
466 | /////////////////////////////////// |
---|
467 | sc_signal<int> r_vci_cmd_fsm; |
---|
468 | sc_signal<size_t> r_vci_cmd_min; // used for write bursts |
---|
469 | sc_signal<size_t> r_vci_cmd_max; // used for write bursts |
---|
470 | sc_signal<size_t> r_vci_cmd_cpt; // used for write bursts |
---|
471 | sc_signal<bool> r_vci_cmd_imiss_prio; // round-robin between imiss & dmiss |
---|
472 | |
---|
473 | /////////////////////////////////// |
---|
474 | // VCI_RSP FSM REGISTERS |
---|
475 | /////////////////////////////////// |
---|
476 | sc_signal<int> r_vci_rsp_fsm; |
---|
477 | sc_signal<size_t> r_vci_rsp_cpt; |
---|
478 | sc_signal<bool> r_vci_rsp_ins_error; |
---|
479 | sc_signal<bool> r_vci_rsp_data_error; |
---|
480 | GenericFifo<uint32_t> r_vci_rsp_fifo_icache; // response FIFO to ICACHE FSM |
---|
481 | GenericFifo<uint32_t> r_vci_rsp_fifo_dcache; // response FIFO to DCACHE FSM |
---|
482 | |
---|
483 | /////////////////////////////////// |
---|
484 | // CLEANUP FSM REGISTER |
---|
485 | /////////////////////////////////// |
---|
486 | sc_signal<int> r_cleanup_fsm; // state register |
---|
487 | sc_signal<size_t> r_cleanup_trdid; // to clear the registration buffer |
---|
488 | GenericCam<paddr_t> r_cleanup_buffer; // Registration buffer for cleanups |
---|
489 | |
---|
490 | /////////////////////////////////// |
---|
491 | // TGT FSM REGISTERS |
---|
492 | /////////////////////////////////// |
---|
493 | sc_signal<int> r_tgt_fsm; // state register |
---|
494 | sc_signal<paddr_t> r_tgt_paddr; // cache line physical address |
---|
495 | sc_signal<size_t> r_tgt_word_count; // word index |
---|
496 | sc_signal<size_t> r_tgt_word_min; // index of the first word to be updated |
---|
497 | sc_signal<size_t> r_tgt_word_max; // index of the last word to be updated |
---|
498 | sc_signal<bool> r_tgt_update; // update request |
---|
499 | sc_signal<bool> r_tgt_update_data; // update data request |
---|
500 | sc_signal<vci_srcid_t> r_tgt_srcid; |
---|
501 | sc_signal<vci_pktid_t> r_tgt_pktid; |
---|
502 | sc_signal<vci_trdid_t> r_tgt_trdid; |
---|
503 | |
---|
504 | // communications between TGT FSM and DCACHE/ICACHE FSMs |
---|
505 | sc_signal<bool> r_tgt_icache_req; // coherence request (set by tgt) |
---|
506 | sc_signal<bool> r_tgt_dcache_req; // coherence request (set by tgt) |
---|
507 | sc_signal<bool> r_tgt_icache_rsp; // coherence response (set by icache) |
---|
508 | sc_signal<bool> r_tgt_dcache_rsp; // coherence response (set by dcache) |
---|
509 | |
---|
510 | uint32_t *r_tgt_buf; // cache line word buffer |
---|
511 | vci_be_t *r_tgt_be; // cache line be buffer |
---|
512 | |
---|
513 | /////////////////////////////////// |
---|
514 | // INVAL_ITLB FSM REGISTERS |
---|
515 | /////////////////////////////////// |
---|
516 | sc_signal<int> r_inval_itlb_fsm; // state register |
---|
517 | sc_signal<size_t> r_inval_itlb_count; // counter to scan all itlb entries |
---|
518 | |
---|
519 | /////////////////////////////////// |
---|
520 | // INVAL_DTLB FSM REGISTERS |
---|
521 | /////////////////////////////////// |
---|
522 | sc_signal<int> r_inval_dtlb_fsm; //state register |
---|
523 | sc_signal<size_t> r_inval_dtlb_count; // counter to scan all dtlb entries |
---|
524 | |
---|
525 | ////////////////////////////////////////////////////////////////// |
---|
526 | // processor, write buffer, caches , TLBs and CAM for cleanups |
---|
527 | ////////////////////////////////////////////////////////////////// |
---|
528 | iss_t r_iss; |
---|
529 | MultiWriteBuffer<paddr_t> r_wbuf; |
---|
530 | GenericCache<paddr_t> r_icache; |
---|
531 | GenericCache<paddr_t> r_dcache; |
---|
532 | GenericTlb<paddr_t> r_itlb; |
---|
533 | GenericTlb<paddr_t> r_dtlb; |
---|
534 | |
---|
535 | //////////////////////////////// |
---|
536 | // Activity counters |
---|
537 | //////////////////////////////// |
---|
538 | uint32_t m_cpt_dcache_data_read; // DCACHE DATA READ |
---|
539 | uint32_t m_cpt_dcache_data_write; // DCACHE DATA WRITE |
---|
540 | uint32_t m_cpt_dcache_dir_read; // DCACHE DIR READ |
---|
541 | uint32_t m_cpt_dcache_dir_write; // DCACHE DIR WRITE |
---|
542 | |
---|
543 | uint32_t m_cpt_icache_data_read; // ICACHE DATA READ |
---|
544 | uint32_t m_cpt_icache_data_write; // ICACHE DATA WRITE |
---|
545 | uint32_t m_cpt_icache_dir_read; // ICACHE DIR READ |
---|
546 | uint32_t m_cpt_icache_dir_write; // ICACHE DIR WRITE |
---|
547 | |
---|
548 | uint32_t m_cpt_frz_cycles; // number of cycles where the cpu is frozen |
---|
549 | uint32_t m_cpt_total_cycles; // total number of cycles |
---|
550 | |
---|
551 | // Cache activity counters |
---|
552 | uint32_t m_cpt_data_read; // total number of read data |
---|
553 | uint32_t m_cpt_data_write; // total number of write data |
---|
554 | uint32_t m_cpt_data_miss; // number of read miss |
---|
555 | uint32_t m_cpt_ins_miss; // number of instruction miss |
---|
556 | uint32_t m_cpt_unc_read; // number of read uncached |
---|
557 | uint32_t m_cpt_write_cached; // number of cached write |
---|
558 | uint32_t m_cpt_ins_read; // number of instruction read |
---|
559 | uint32_t m_cpt_ins_spc_miss; // number of speculative instruction miss |
---|
560 | |
---|
561 | uint32_t m_cost_write_frz; // number of frozen cycles related to write buffer |
---|
562 | uint32_t m_cost_data_miss_frz; // number of frozen cycles related to data miss |
---|
563 | uint32_t m_cost_unc_read_frz; // number of frozen cycles related to uncached read |
---|
564 | uint32_t m_cost_ins_miss_frz; // number of frozen cycles related to ins miss |
---|
565 | |
---|
566 | uint32_t m_cpt_imiss_transaction; // number of VCI instruction miss transactions |
---|
567 | uint32_t m_cpt_dmiss_transaction; // number of VCI data miss transactions |
---|
568 | uint32_t m_cpt_unc_transaction; // number of VCI uncached read transactions |
---|
569 | uint32_t m_cpt_write_transaction; // number of VCI write transactions |
---|
570 | uint32_t m_cpt_icache_unc_transaction; |
---|
571 | |
---|
572 | uint32_t m_cost_imiss_transaction; // cumulated duration for VCI IMISS transactions |
---|
573 | uint32_t m_cost_dmiss_transaction; // cumulated duration for VCI DMISS transactions |
---|
574 | uint32_t m_cost_unc_transaction; // cumulated duration for VCI UNC transactions |
---|
575 | uint32_t m_cost_write_transaction; // cumulated duration for VCI WRITE transactions |
---|
576 | uint32_t m_cost_icache_unc_transaction; // cumulated duration for VCI IUNC transactions |
---|
577 | uint32_t m_length_write_transaction; // cumulated length for VCI WRITE transactions |
---|
578 | |
---|
579 | // TLB activity counters |
---|
580 | uint32_t m_cpt_ins_tlb_read; // number of instruction tlb read |
---|
581 | uint32_t m_cpt_ins_tlb_miss; // number of instruction tlb miss |
---|
582 | uint32_t m_cpt_ins_tlb_update_acc; // number of instruction tlb update |
---|
583 | uint32_t m_cpt_ins_tlb_occup_cache; // number of instruction tlb occupy data cache line |
---|
584 | uint32_t m_cpt_ins_tlb_hit_dcache; // number of instruction tlb hit in data cache |
---|
585 | |
---|
586 | uint32_t m_cpt_data_tlb_read; // number of data tlb read |
---|
587 | uint32_t m_cpt_data_tlb_miss; // number of data tlb miss |
---|
588 | uint32_t m_cpt_data_tlb_update_acc; // number of data tlb update |
---|
589 | uint32_t m_cpt_data_tlb_update_dirty; // number of data tlb update dirty |
---|
590 | uint32_t m_cpt_data_tlb_hit_dcache; // number of data tlb hit in data cache |
---|
591 | uint32_t m_cpt_data_tlb_occup_cache; // number of data tlb occupy data cache line |
---|
592 | uint32_t m_cpt_tlb_occup_dcache; |
---|
593 | |
---|
594 | uint32_t m_cost_ins_tlb_miss_frz; // number of frozen cycles related to instruction tlb miss |
---|
595 | uint32_t m_cost_data_tlb_miss_frz; // number of frozen cycles related to data tlb miss |
---|
596 | uint32_t m_cost_ins_tlb_update_acc_frz; // number of frozen cycles related to instruction tlb update acc |
---|
597 | uint32_t m_cost_data_tlb_update_acc_frz; // number of frozen cycles related to data tlb update acc |
---|
598 | uint32_t m_cost_data_tlb_update_dirty_frz; // number of frozen cycles related to data tlb update dirty |
---|
599 | uint32_t m_cost_ins_tlb_occup_cache_frz; // number of frozen cycles related to instruction tlb miss operate in dcache |
---|
600 | uint32_t m_cost_data_tlb_occup_cache_frz; // number of frozen cycles related to data tlb miss operate in dcache |
---|
601 | |
---|
602 | uint32_t m_cpt_itlbmiss_transaction; // number of itlb miss transactions |
---|
603 | uint32_t m_cpt_itlb_ll_transaction; // number of itlb ll acc transactions |
---|
604 | uint32_t m_cpt_itlb_sc_transaction; // number of itlb sc acc transactions |
---|
605 | uint32_t m_cpt_dtlbmiss_transaction; // number of dtlb miss transactions |
---|
606 | uint32_t m_cpt_dtlb_ll_transaction; // number of dtlb ll acc transactions |
---|
607 | uint32_t m_cpt_dtlb_sc_transaction; // number of dtlb sc acc transactions |
---|
608 | uint32_t m_cpt_dtlb_ll_dirty_transaction; // number of dtlb ll dirty transactions |
---|
609 | uint32_t m_cpt_dtlb_sc_dirty_transaction; // number of dtlb sc dirty transactions |
---|
610 | |
---|
611 | uint32_t m_cost_itlbmiss_transaction; // cumulated duration for VCI instruction TLB miss transactions |
---|
612 | uint32_t m_cost_itlb_ll_transaction; // cumulated duration for VCI instruction TLB ll acc transactions |
---|
613 | uint32_t m_cost_itlb_sc_transaction; // cumulated duration for VCI instruction TLB sc acc transactions |
---|
614 | uint32_t m_cost_dtlbmiss_transaction; // cumulated duration for VCI data TLB miss transactions |
---|
615 | uint32_t m_cost_dtlb_ll_transaction; // cumulated duration for VCI data TLB ll acc transactions |
---|
616 | uint32_t m_cost_dtlb_sc_transaction; // cumulated duration for VCI data TLB sc acc transactions |
---|
617 | uint32_t m_cost_dtlb_ll_dirty_transaction; // cumulated duration for VCI data TLB ll dirty transactions |
---|
618 | uint32_t m_cost_dtlb_sc_dirty_transaction; // cumulated duration for VCI data TLB sc dirty transactions |
---|
619 | |
---|
620 | // coherence activity counters |
---|
621 | uint32_t m_cpt_cc_update_icache; // number of coherence update instruction commands |
---|
622 | uint32_t m_cpt_cc_update_dcache; // number of coherence update data commands |
---|
623 | uint32_t m_cpt_cc_inval_icache; // number of coherence inval instruction commands |
---|
624 | uint32_t m_cpt_cc_inval_dcache; // number of coherence inval data commands |
---|
625 | uint32_t m_cpt_cc_broadcast; // number of coherence broadcast commands |
---|
626 | |
---|
627 | uint32_t m_cost_updt_data_frz; // number of frozen cycles related to coherence update data packets |
---|
628 | uint32_t m_cost_inval_ins_frz; // number of frozen cycles related to coherence inval instruction packets |
---|
629 | uint32_t m_cost_inval_data_frz; // number of frozen cycles related to coherence inval data packets |
---|
630 | uint32_t m_cost_broadcast_frz; // number of frozen cycles related to coherence broadcast packets |
---|
631 | |
---|
632 | uint32_t m_cpt_cc_cleanup_ins; // number of coherence cleanup packets |
---|
633 | uint32_t m_cpt_cc_cleanup_data; // number of coherence cleanup packets |
---|
634 | |
---|
635 | uint32_t m_cpt_icleanup_transaction; // number of instruction cleanup transactions |
---|
636 | uint32_t m_cpt_dcleanup_transaction; // number of instructinumber of data cleanup transactions |
---|
637 | uint32_t m_cost_icleanup_transaction; // cumulated duration for VCI instruction cleanup transactions |
---|
638 | uint32_t m_cost_dcleanup_transaction; // cumulated duration for VCI data cleanup transactions |
---|
639 | |
---|
640 | uint32_t m_cost_ins_tlb_inval_frz; // number of frozen cycles related to checking ins tlb invalidate |
---|
641 | uint32_t m_cpt_ins_tlb_inval; // number of ins tlb invalidate |
---|
642 | |
---|
643 | uint32_t m_cost_data_tlb_inval_frz; // number of frozen cycles related to checking data tlb invalidate |
---|
644 | uint32_t m_cpt_data_tlb_inval; // number of data tlb invalidate |
---|
645 | |
---|
646 | // FSM activity counters |
---|
647 | uint32_t m_cpt_fsm_icache [64]; |
---|
648 | uint32_t m_cpt_fsm_dcache [64]; |
---|
649 | uint32_t m_cpt_fsm_cmd [64]; |
---|
650 | uint32_t m_cpt_fsm_rsp [64]; |
---|
651 | uint32_t m_cpt_fsm_tgt [64]; |
---|
652 | uint32_t m_cpt_fsm_cmd_cleanup[64]; |
---|
653 | uint32_t m_cpt_fsm_rsp_cleanup[64]; |
---|
654 | |
---|
655 | uint32_t m_cpt_stop_simulation; // used to stop simulation if frozen |
---|
656 | |
---|
657 | protected: |
---|
658 | SC_HAS_PROCESS(VciCcVCacheWrapperV4); |
---|
659 | |
---|
660 | public: |
---|
661 | VciCcVCacheWrapperV4( |
---|
662 | sc_module_name insname, |
---|
663 | int proc_id, |
---|
664 | const soclib::common::MappingTable &mtp, |
---|
665 | const soclib::common::MappingTable &mtc, |
---|
666 | const soclib::common::IntTab &initiator_index_d, |
---|
667 | const soclib::common::IntTab &initiator_index_c, |
---|
668 | const soclib::common::IntTab &target_index_d, |
---|
669 | size_t itlb_ways, |
---|
670 | size_t itlb_sets, |
---|
671 | size_t dtlb_ways, |
---|
672 | size_t dtlb_sets, |
---|
673 | size_t icache_ways, |
---|
674 | size_t icache_sets, |
---|
675 | size_t icache_words, |
---|
676 | size_t dcache_ways, |
---|
677 | size_t dcache_sets, |
---|
678 | size_t dcache_words, |
---|
679 | size_t wbuf_nlines, |
---|
680 | size_t wbuf_nwords, |
---|
681 | uint32_t max_frozen_cycles, |
---|
682 | uint32_t debug_start_cycle, |
---|
683 | bool debug_ok); |
---|
684 | |
---|
685 | ~VciCcVCacheWrapperV4(); |
---|
686 | |
---|
687 | void print_cpi(); |
---|
688 | void print_stats(); |
---|
689 | void clear_stats(); |
---|
690 | void print_trace(size_t mode = 0); |
---|
691 | void cache_monitor(paddr_t addr); |
---|
692 | |
---|
693 | private: |
---|
694 | void transition(); |
---|
695 | void genMoore(); |
---|
696 | |
---|
697 | soclib_static_assert((int)iss_t::SC_ATOMIC == (int)vci_param::STORE_COND_ATOMIC); |
---|
698 | soclib_static_assert((int)iss_t::SC_NOT_ATOMIC == (int)vci_param::STORE_COND_NOT_ATOMIC); |
---|
699 | }; |
---|
700 | |
---|
701 | }} |
---|
702 | |
---|
703 | #endif /* SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_V4_H */ |
---|
704 | |
---|
705 | // Local Variables: |
---|
706 | // tab-width: 4 |
---|
707 | // c-basic-offset: 4 |
---|
708 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
709 | // indent-tabs-mode: nil |
---|
710 | // End: |
---|
711 | |
---|
712 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
713 | |
---|
714 | |
---|
715 | |
---|
716 | |
---|