source: trunk/modules/vci_cc_vcache_wrapper_v4/caba/source/include/vci_cc_vcache_wrapper_v4.h @ 217

Last change on this file since 217 was 217, checked in by alain, 12 years ago

Fixing a bug in the DCACHE_INVALTLB_SCAN sub-FSM:
It requires a specific register to save the return state.

File size: 30.7 KB
Line 
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_cache.h"
38#include "generic_cam.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
45namespace soclib {
46namespace caba {
47
48using namespace sc_core;
49
50////////////////////////////////////////////
51template<typename vci_param, typename iss_t>
52class 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_LR_UPDT,           
103        DCACHE_TLB_LR_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_END,
116        DCACHE_XTN_DC_INVAL_GO,         
117        DCACHE_XTN_DT_INVAL,         
118        //handling dirty bit update
119        DCACHE_DIRTY_GET_PTE,
120        DCACHE_DIRTY_SC_WAIT,           
121            // handling processor miss requests
122        DCACHE_MISS_VICTIM,
123        DCACHE_MISS_INVAL,
124        DCACHE_MISS_WAIT,           
125        DCACHE_MISS_UPDT,           
126        // handling processor unc and sc requests
127        DCACHE_UNC_WAIT,           
128        DCACHE_SC_WAIT,           
129        // handling coherence requests
130        DCACHE_CC_CHECK,           
131        DCACHE_CC_INVAL,           
132        DCACHE_CC_UPDT,             
133        // handling TLB inval (after a coherence or XTN request)
134        DCACHE_INVAL_TLB_SCAN,             
135    };
136
137    enum cmd_fsm_state_e {     
138        CMD_IDLE,
139        CMD_INS_MISS,
140        CMD_INS_UNC,
141        CMD_DATA_MISS,
142        CMD_DATA_UNC,
143        CMD_DATA_WRITE,
144        CMD_DATA_SC, 
145    };
146
147    enum rsp_fsm_state_e {       
148        RSP_IDLE,
149        RSP_INS_MISS,
150        RSP_INS_UNC,
151        RSP_DATA_MISS,
152        RSP_DATA_UNC,
153        RSP_DATA_WRITE,
154        RSP_DATA_SC,
155    };
156
157    enum cleanup_cmd_fsm_state_e {
158        CLEANUP_DATA_IDLE,
159        CLEANUP_DATA_GO,
160        CLEANUP_INS_IDLE,
161        CLEANUP_INS_GO,
162    };
163
164    enum tgt_fsm_state_e { 
165        TGT_IDLE,
166        TGT_UPDT_WORD,
167        TGT_UPDT_DATA,
168        TGT_REQ_BROADCAST,
169        TGT_REQ_ICACHE,
170        TGT_REQ_DCACHE,
171        TGT_RSP_BROADCAST,
172        TGT_RSP_ICACHE, 
173        TGT_RSP_DCACHE,
174    };
175
176    // TLB Mode : ITLB / DTLB / ICACHE / DCACHE
177    enum {         
178        INS_TLB_MASK    = 0x8,
179        DATA_TLB_MASK   = 0x4,
180        INS_CACHE_MASK  = 0x2,
181        DATA_CACHE_MASK = 0x1,
182    };
183
184    // Error Type
185    enum mmu_error_type_e
186    {
187        MMU_NONE                      = 0x0000, // None
188        MMU_WRITE_PT1_UNMAPPED        = 0x0001, // Write access of Page fault on Page Table 1         
189        MMU_WRITE_PT2_UNMAPPED        = 0x0002, // Write access of Page fault on Page Table 2         
190        MMU_WRITE_PRIVILEGE_VIOLATION = 0x0004, // Write access of Protected access in user mode     
191        MMU_WRITE_ACCES_VIOLATION     = 0x0008, // Write access of write access to a non writable page
192        MMU_WRITE_UNDEFINED_XTN       = 0x0020, // Write access of undefined external access address 
193        MMU_WRITE_PT1_ILLEGAL_ACCESS  = 0x0040, // Write access of Bus Error accessing Table 1       
194        MMU_WRITE_PT2_ILLEGAL_ACCESS  = 0x0080, // Write access of Bus Error accessing Table 2     
195        MMU_WRITE_DATA_ILLEGAL_ACCESS = 0x0100, // Write access of Bus Error in cache access     
196        MMU_READ_PT1_UNMAPPED         = 0x1001, // Read access of Page fault on Page Table 1   
197        MMU_READ_PT2_UNMAPPED         = 0x1002, // Read access of Page fault on Page Table 2 
198        MMU_READ_PRIVILEGE_VIOLATION  = 0x1004, // Read access of Protected access in user mode
199        MMU_READ_EXEC_VIOLATION       = 0x1010, // Exec access to a non exec page             
200        MMU_READ_UNDEFINED_XTN        = 0x1020, // Read access of Undefined external access address
201        MMU_READ_PT1_ILLEGAL_ACCESS   = 0x1040, // Read access of Bus Error in Table1 access     
202        MMU_READ_PT2_ILLEGAL_ACCESS   = 0x1080, // Read access of Bus Error in Table2 access   
203        MMU_READ_DATA_ILLEGAL_ACCESS  = 0x1100, // Read access of Bus Error in cache access
204    };
205
206    // miss types for data cache
207    enum dcache_miss_type_e
208    {
209        PTE1_MISS, 
210        PTE2_MISS,
211        PROC_MISS, 
212    };
213
214    enum transaction_type_d_e
215    {
216        // b0 : 1 if cached
217        // b1 : 1 if instruction
218        TYPE_DATA_UNC     = 0x0,
219        TYPE_DATA_MISS    = 0x1,
220        TYPE_INS_UNC      = 0x2,
221        TYPE_INS_MISS     = 0x3,
222    };
223
224public:
225    sc_in<bool>                             p_clk;
226    sc_in<bool>                             p_resetn;
227    sc_in<bool>                             p_irq[iss_t::n_irq];
228    soclib::caba::VciInitiator<vci_param>   p_vci_ini_d;
229    soclib::caba::VciInitiator<vci_param>   p_vci_ini_c;
230    soclib::caba::VciTarget<vci_param>      p_vci_tgt_c;
231
232private:
233
234    // STRUCTURAL PARAMETERS
235    soclib::common::AddressDecodingTable<uint32_t, bool>        m_cacheability_table;
236    const soclib::common::Segment                               m_segment;
237    const vci_srcid_t                                           m_srcid_d;
238    const vci_srcid_t                                           m_srcid_c;
239
240    const size_t                                                m_itlb_ways;
241    const size_t                                                m_itlb_sets;
242
243    const size_t                                                m_dtlb_ways;
244    const size_t                                                m_dtlb_sets;
245
246    const size_t                                                m_icache_ways;
247    const size_t                                                m_icache_sets;
248    const paddr_t                                               m_icache_yzmask;
249    const size_t                                                m_icache_words;
250
251    const size_t                                                m_dcache_ways;
252    const size_t                                                m_dcache_sets;
253    const paddr_t                                               m_dcache_yzmask;
254    const size_t                                                m_dcache_words;
255
256    const size_t                        m_proc_id;
257
258    const uint32_t                                              m_max_frozen_cycles;
259
260    const size_t                                                m_paddr_nbits; 
261
262    ////////////////////////////////////////
263    // Communication with processor ISS
264    ////////////////////////////////////////
265    typename iss_t::InstructionRequest  m_ireq;
266    typename iss_t::InstructionResponse m_irsp;
267    typename iss_t::DataRequest         m_dreq;
268    typename iss_t::DataResponse        m_drsp;
269
270    /////////////////////////////////////////////
271    // debug variables (for each FSM)
272    /////////////////////////////////////////////
273    uint32_t                            m_debug_start_cycle;
274    bool                                m_debug_ok;
275    bool                                m_debug_previous_hit;
276    bool                                m_idebug_previous_hit;
277    bool                                m_debug_dcache_fsm;
278    bool                                m_debug_icache_fsm;
279    bool                                m_debug_cleanup_fsm;
280    bool                                m_debug_inval_itlb_fsm;
281    bool                                m_debug_inval_dtlb_fsm;
282
283    ///////////////////////////////
284    // Software visible REGISTERS
285    ///////////////////////////////
286    sc_signal<uint32_t>     r_mmu_ptpr;                 // page table pointer register
287    sc_signal<uint32_t>     r_mmu_mode;                 // mmu mode register
288    sc_signal<uint32_t>     r_mmu_word_lo;              // mmu misc data low
289    sc_signal<uint32_t>     r_mmu_word_hi;              // mmu misc data hight
290    sc_signal<uint32_t>     r_mmu_ibvar;                // mmu bad instruction address
291    sc_signal<uint32_t>     r_mmu_dbvar;                // mmu bad data address
292    sc_signal<uint32_t>     r_mmu_ietr;                 // mmu instruction error type
293    sc_signal<uint32_t>     r_mmu_detr;                 // mmu data error type
294    uint32_t                r_mmu_params;                       // read-only
295    uint32_t                r_mmu_release;                      // read_only
296
297
298    //////////////////////////////
299    // ICACHE FSM REGISTERS
300    //////////////////////////////
301    sc_signal<int>          r_icache_fsm;               // state register
302    sc_signal<int>          r_icache_fsm_save;          // return state for coherence operation
303    sc_signal<paddr_t>      r_icache_vci_paddr;         // physical address
304    sc_signal<uint32_t>     r_icache_vaddr_save;        // virtual address requested by the processor
305
306    // icache miss handling
307    sc_signal<size_t>       r_icache_miss_way;              // selected way for cache update
308    sc_signal<size_t>       r_icache_miss_set;              // selected set for cache update         
309    sc_signal<size_t>       r_icache_miss_word;             // word index for sequencial cache update
310    sc_signal<bool>         r_icache_miss_inval;        // coherence request matching a pending miss
311
312    // coherence request handling
313    sc_signal<size_t>       r_icache_cc_way;                // selected way for cc update/inval
314    sc_signal<size_t>       r_icache_cc_set;                // selected set for cc update/inval
315    sc_signal<size_t>       r_icache_cc_word;               // word counter for cc update
316
317    // icache flush handling
318    sc_signal<size_t>       r_icache_flush_count;           // slot counter used for cache flush
319
320    // communication between ICACHE FSM and VCI_CMD FSM
321    sc_signal<bool>         r_icache_miss_req;           // cached read miss
322    sc_signal<bool>         r_icache_unc_req;            // uncached read miss
323
324    // communication between ICACHE FSM and DCACHE FSM
325    sc_signal<bool>             r_icache_tlb_miss_req;       // itlb miss request (set icache/reset dcache)
326    sc_signal<bool>         r_icache_tlb_rsp_error;      // itlb miss response error (written by dcache)
327
328    // communication between ICACHE FSM and CLEANUP FSMs
329    sc_signal<bool>         r_icache_cleanup_req;        // ins cleanup request
330    sc_signal<paddr_t>      r_icache_cleanup_line;       // ins cleanup NLINE
331
332    ///////////////////////////////
333    // DCACHE FSM REGISTERS
334    ///////////////////////////////
335    sc_signal<int>          r_dcache_fsm;               // state register
336    sc_signal<int>          r_dcache_fsm_cc_save;       // return state for coherence operation
337    sc_signal<int>          r_dcache_fsm_scan_save;     // return state for tlb scan operation
338    // registers written in P0 stage (used in P1 stage)
339    sc_signal<bool>         r_dcache_p0_valid;              // P1 pipeline stage must be executed
340    sc_signal<uint32_t>     r_dcache_p0_vaddr;          // virtual address (from proc)
341    sc_signal<uint32_t>     r_dcache_p0_wdata;          // write data (from proc)
342    sc_signal<vci_be_t>     r_dcache_p0_be;             // byte enable (from proc)
343    sc_signal<paddr_t>      r_dcache_p0_paddr;          // physical address
344    sc_signal<bool>         r_dcache_p0_cacheable;          // address cacheable
345    // registers written in P1 stage (used in P2 stage)
346    sc_signal<bool>         r_dcache_p1_valid;              // P2 pipeline stage must be executed
347    sc_signal<uint32_t>     r_dcache_p1_wdata;          // write data (from proc)
348    sc_signal<vci_be_t>     r_dcache_p1_be;             // byte enable (from proc)
349    sc_signal<paddr_t>      r_dcache_p1_paddr;          // physical address
350    sc_signal<size_t>       r_dcache_p1_cache_way;          // selected way (from dcache)
351    sc_signal<size_t>       r_dcache_p1_cache_set;          // selected set (from dcache)   
352    sc_signal<size_t>       r_dcache_p1_cache_word;         // selected word (from dcache)   
353    // registers used by the Dirty bit sub-fsm
354    sc_signal<paddr_t>      r_dcache_dirty_paddr;       // PTE physical address
355    sc_signal<size_t>       r_dcache_dirty_way;         // way to invalidate in dcache
356    sc_signal<size_t>       r_dcache_dirty_set;         // set to invalidate in dcache
357
358    // communication between DCACHE FSM and VCI_CMD FSM
359    sc_signal<paddr_t>      r_dcache_vci_paddr;             // physical address for VCI command
360    sc_signal<bool>         r_dcache_vci_miss_req;      // read miss request
361    sc_signal<bool>         r_dcache_vci_unc_req;       // uncacheable read request
362    sc_signal<bool>         r_dcache_vci_unc_be;        // uncacheable read byte enable
363    sc_signal<bool>         r_dcache_vci_sc_req;        // atomic write request (Compare & swap)
364    sc_signal<uint32_t>     r_dcache_vci_sc_old;        // previous data value for an atomic write
365    sc_signal<uint32_t>     r_dcache_vci_sc_new;        // new data value for an atomic write
366
367    // register used for XTN inval
368    sc_signal<size_t>       r_dcache_xtn_way;               // selected way (from dcache)
369    sc_signal<size_t>       r_dcache_xtn_set;               // selected set (from dcache)   
370
371    // write buffer state extension
372    sc_signal<bool>         r_dcache_pending_unc_write; // pending uncacheable write in WBUF
373
374    // handling dcache miss
375    sc_signal<int>              r_dcache_miss_type;                 // type of miss depending on the requester
376    sc_signal<size_t>       r_dcache_miss_word;             // word index for sequencial cache update
377    sc_signal<size_t>       r_dcache_miss_way;              // selected way for cache update
378    sc_signal<size_t>       r_dcache_miss_set;              // selected set for cache update
379    sc_signal<bool>         r_dcache_miss_inval;        // coherence request matching a pending miss
380
381    // handling coherence requests
382    sc_signal<size_t>       r_dcache_cc_way;                // selected way for cc update/inval
383    sc_signal<size_t>       r_dcache_cc_set;                // selected set for cc update/inval
384    sc_signal<size_t>       r_dcache_cc_word;               // word counter for cc update
385
386    // dcache flush handling
387    sc_signal<size_t>       r_dcache_flush_count;           // slot counter used for cache flush
388
389    // used by the TLB miss sub-fsm
390    sc_signal<uint32_t>     r_dcache_tlb_vaddr;             // virtual address for a tlb miss
391    sc_signal<bool>         r_dcache_tlb_ins;               // target tlb (itlb if true)
392    sc_signal<paddr_t>      r_dcache_tlb_paddr;             // physical address of pte
393    sc_signal<uint32_t>     r_dcache_tlb_pte_flags;         // pte1 or first word of pte2
394    sc_signal<uint32_t>     r_dcache_tlb_pte_ppn;           // second word of pte2
395    sc_signal<size_t>       r_dcache_tlb_cache_way;         // selected way in dcache
396    sc_signal<size_t>       r_dcache_tlb_cache_set;         // selected set in dcache
397    sc_signal<size_t>       r_dcache_tlb_cache_word;    // selected word in dcache
398    sc_signal<size_t>       r_dcache_tlb_way;               // selected way in tlb   
399    sc_signal<size_t>       r_dcache_tlb_set;               // selected set in tlb   
400
401    // LL reservation handling
402    sc_signal<bool>         r_dcache_ll_valid;              // valid LL reservation
403    sc_signal<uint32_t>     r_dcache_ll_data;               // LL reserved data
404    sc_signal<paddr_t>      r_dcache_ll_vaddr;              // LL reserved address
405                           
406    // ITLB and DTLB invalidation
407    sc_signal<paddr_t>      r_dcache_tlb_inval_line;    // line index
408    sc_signal<size_t>       r_dcache_tlb_inval_count;   // tlb entry counter
409
410    // communication between DCACHE FSM and ICACHE FSM
411    sc_signal<bool>         r_dcache_xtn_req;           // xtn request (caused by processor)
412    sc_signal<int>          r_dcache_xtn_opcode;        // xtn request type
413
414    // communication between DCACHE FSM and CLEANUP FSMs
415    sc_signal<bool>         r_dcache_cleanup_req;       // data cleanup request
416    sc_signal<paddr_t>      r_dcache_cleanup_line;      // data cleanup NLINE
417
418    // dcache directory extension
419    bool                    *r_dcache_in_tlb;           // copy exist in dtlb or itlb
420    bool                    *r_dcache_contains_ptd;     // cache line contains a PTD
421
422    ///////////////////////////////////
423    // VCI_CMD FSM REGISTERS
424    ///////////////////////////////////
425    sc_signal<int>          r_vci_cmd_fsm;
426    sc_signal<size_t>       r_vci_cmd_min;                  // used for write bursts
427    sc_signal<size_t>       r_vci_cmd_max;                  // used for write bursts
428    sc_signal<size_t>       r_vci_cmd_cpt;                  // used for write bursts
429    sc_signal<bool>         r_vci_cmd_imiss_prio;           // round-robin between imiss & dmiss
430
431    ///////////////////////////////////
432    // VCI_RSP FSM REGISTERS
433    ///////////////////////////////////
434    sc_signal<int>          r_vci_rsp_fsm;
435    sc_signal<size_t>       r_vci_rsp_cpt;
436    sc_signal<bool>         r_vci_rsp_ins_error;
437    sc_signal<bool>         r_vci_rsp_data_error;
438    GenericFifo<uint32_t>   r_vci_rsp_fifo_icache;          // response FIFO to ICACHE FSM
439    GenericFifo<uint32_t>   r_vci_rsp_fifo_dcache;          // response FIFO to DCACHE FSM
440
441    ///////////////////////////////////
442    //  CLEANUP FSM REGISTER
443    ///////////////////////////////////
444    sc_signal<int>          r_cleanup_fsm;              // state register
445    sc_signal<size_t>       r_cleanup_trdid;            // to clear the registration buffer
446    GenericCam<paddr_t>     r_cleanup_buffer;           // Registration buffer for cleanups
447
448    ///////////////////////////////////
449    //  TGT FSM REGISTERS
450    ///////////////////////////////////
451    sc_signal<int>          r_tgt_fsm;                          // state register
452    sc_signal<paddr_t>      r_tgt_paddr;                        // cache line physical address
453    sc_signal<size_t>       r_tgt_word_count;               // word index
454    sc_signal<size_t>       r_tgt_word_min;                     // index of the first word to be updated
455    sc_signal<size_t>       r_tgt_word_max;                     // index of the last word to be updated
456    sc_signal<bool>         r_tgt_update;                       // update request
457    sc_signal<bool>         r_tgt_update_data;              // update data request
458    sc_signal<vci_srcid_t>  r_tgt_srcid;
459    sc_signal<vci_pktid_t>  r_tgt_pktid;
460    sc_signal<vci_trdid_t>  r_tgt_trdid;
461
462    // communications between TGT FSM and DCACHE/ICACHE FSMs
463    sc_signal<bool>         r_tgt_icache_req;               // coherence request (set by tgt)
464    sc_signal<bool>         r_tgt_dcache_req;               // coherence request (set by tgt)
465    sc_signal<bool>         r_tgt_icache_rsp;               // coherence response (set by icache)
466    sc_signal<bool>         r_tgt_dcache_rsp;               // coherence response (set by dcache)
467
468    uint32_t                *r_tgt_buf;                         // cache line word buffer
469    vci_be_t                *r_tgt_be;                          // cache line be buffer
470
471    //////////////////////////////////////////////////////////////////
472    // processor, write buffer, caches , TLBs and CAM for cleanups
473    //////////////////////////////////////////////////////////////////
474    iss_t                       r_iss;   
475    MultiWriteBuffer<paddr_t>   r_wbuf;
476    GenericCache<paddr_t>       r_icache;
477    GenericCache<paddr_t>       r_dcache;
478    GenericTlb<paddr_t>         r_itlb;
479    GenericTlb<paddr_t>         r_dtlb;
480
481    ////////////////////////////////
482    // Activity counters
483    ////////////////////////////////
484    uint32_t m_cpt_dcache_data_read;        // DCACHE DATA READ
485    uint32_t m_cpt_dcache_data_write;       // DCACHE DATA WRITE
486    uint32_t m_cpt_dcache_dir_read;         // DCACHE DIR READ
487    uint32_t m_cpt_dcache_dir_write;        // DCACHE DIR WRITE
488
489    uint32_t m_cpt_icache_data_read;        // ICACHE DATA READ
490    uint32_t m_cpt_icache_data_write;       // ICACHE DATA WRITE
491    uint32_t m_cpt_icache_dir_read;         // ICACHE DIR READ
492    uint32_t m_cpt_icache_dir_write;        // ICACHE DIR WRITE
493
494    uint32_t m_cpt_frz_cycles;              // number of cycles where the cpu is frozen
495    uint32_t m_cpt_total_cycles;                // total number of cycles
496
497    // Cache activity counters
498    uint32_t m_cpt_data_read;               // total number of read data
499    uint32_t m_cpt_data_write;              // total number of write data
500    uint32_t m_cpt_data_miss;               // number of read miss
501    uint32_t m_cpt_ins_miss;                // number of instruction miss
502    uint32_t m_cpt_unc_read;                // number of read uncached
503    uint32_t m_cpt_write_cached;            // number of cached write
504    uint32_t m_cpt_ins_read;                // number of instruction read
505    uint32_t m_cpt_ins_spc_miss;            // number of speculative instruction miss
506
507    uint32_t m_cost_write_frz;              // number of frozen cycles related to write buffer         
508    uint32_t m_cost_data_miss_frz;          // number of frozen cycles related to data miss
509    uint32_t m_cost_unc_read_frz;           // number of frozen cycles related to uncached read
510    uint32_t m_cost_ins_miss_frz;           // number of frozen cycles related to ins miss
511
512    uint32_t m_cpt_imiss_transaction;       // number of VCI instruction miss transactions
513    uint32_t m_cpt_dmiss_transaction;       // number of VCI data miss transactions
514    uint32_t m_cpt_unc_transaction;         // number of VCI uncached read transactions
515    uint32_t m_cpt_write_transaction;       // number of VCI write transactions
516    uint32_t m_cpt_icache_unc_transaction;
517
518    uint32_t m_cost_imiss_transaction;      // cumulated duration for VCI IMISS transactions
519    uint32_t m_cost_dmiss_transaction;      // cumulated duration for VCI DMISS transactions
520    uint32_t m_cost_unc_transaction;        // cumulated duration for VCI UNC transactions
521    uint32_t m_cost_write_transaction;      // cumulated duration for VCI WRITE transactions
522    uint32_t m_cost_icache_unc_transaction; // cumulated duration for VCI IUNC transactions   
523    uint32_t m_length_write_transaction;    // cumulated length for VCI WRITE transactions
524
525    // TLB activity counters
526    uint32_t m_cpt_ins_tlb_read;            // number of instruction tlb read
527    uint32_t m_cpt_ins_tlb_miss;            // number of instruction tlb miss
528    uint32_t m_cpt_ins_tlb_update_acc;      // number of instruction tlb update
529    uint32_t m_cpt_ins_tlb_occup_cache;     // number of instruction tlb occupy data cache line
530    uint32_t m_cpt_ins_tlb_hit_dcache;      // number of instruction tlb hit in data cache
531
532    uint32_t m_cpt_data_tlb_read;           // number of data tlb read
533    uint32_t m_cpt_data_tlb_miss;           // number of data tlb miss
534    uint32_t m_cpt_data_tlb_update_acc;     // number of data tlb update
535    uint32_t m_cpt_data_tlb_update_dirty;   // number of data tlb update dirty
536    uint32_t m_cpt_data_tlb_hit_dcache;     // number of data tlb hit in data cache
537    uint32_t m_cpt_data_tlb_occup_cache;    // number of data tlb occupy data cache line
538    uint32_t m_cpt_tlb_occup_dcache;
539   
540    uint32_t m_cost_ins_tlb_miss_frz;       // number of frozen cycles related to instruction tlb miss
541    uint32_t m_cost_data_tlb_miss_frz;      // number of frozen cycles related to data tlb miss
542    uint32_t m_cost_ins_tlb_update_acc_frz;    // number of frozen cycles related to instruction tlb update acc
543    uint32_t m_cost_data_tlb_update_acc_frz;   // number of frozen cycles related to data tlb update acc
544    uint32_t m_cost_data_tlb_update_dirty_frz; // number of frozen cycles related to data tlb update dirty
545    uint32_t m_cost_ins_tlb_occup_cache_frz;   // number of frozen cycles related to instruction tlb miss operate in dcache
546    uint32_t m_cost_data_tlb_occup_cache_frz;  // number of frozen cycles related to data tlb miss operate in dcache
547
548    uint32_t m_cpt_itlbmiss_transaction;       // number of itlb miss transactions
549    uint32_t m_cpt_itlb_ll_transaction;        // number of itlb ll acc transactions
550    uint32_t m_cpt_itlb_sc_transaction;        // number of itlb sc acc transactions
551    uint32_t m_cpt_dtlbmiss_transaction;       // number of dtlb miss transactions
552    uint32_t m_cpt_dtlb_ll_transaction;        // number of dtlb ll acc transactions
553    uint32_t m_cpt_dtlb_sc_transaction;        // number of dtlb sc acc transactions
554    uint32_t m_cpt_dtlb_ll_dirty_transaction;  // number of dtlb ll dirty transactions
555    uint32_t m_cpt_dtlb_sc_dirty_transaction;  // number of dtlb sc dirty transactions
556
557    uint32_t m_cost_itlbmiss_transaction;       // cumulated duration for VCI instruction TLB miss transactions
558    uint32_t m_cost_itlb_ll_transaction;        // cumulated duration for VCI instruction TLB ll acc transactions
559    uint32_t m_cost_itlb_sc_transaction;        // cumulated duration for VCI instruction TLB sc acc transactions
560    uint32_t m_cost_dtlbmiss_transaction;       // cumulated duration for VCI data TLB miss transactions
561    uint32_t m_cost_dtlb_ll_transaction;        // cumulated duration for VCI data TLB ll acc transactions
562    uint32_t m_cost_dtlb_sc_transaction;        // cumulated duration for VCI data TLB sc acc transactions
563    uint32_t m_cost_dtlb_ll_dirty_transaction;  // cumulated duration for VCI data TLB ll dirty transactions
564    uint32_t m_cost_dtlb_sc_dirty_transaction;  // cumulated duration for VCI data TLB sc dirty transactions
565
566    // coherence activity counters
567    uint32_t m_cpt_cc_update_icache;            // number of coherence update instruction commands
568    uint32_t m_cpt_cc_update_dcache;            // number of coherence update data commands
569    uint32_t m_cpt_cc_inval_icache;             // number of coherence inval instruction commands
570    uint32_t m_cpt_cc_inval_dcache;             // number of coherence inval data commands
571    uint32_t m_cpt_cc_broadcast;                // number of coherence broadcast commands
572   
573    uint32_t m_cost_updt_data_frz;              // number of frozen cycles related to coherence update data packets
574    uint32_t m_cost_inval_ins_frz;              // number of frozen cycles related to coherence inval instruction packets
575    uint32_t m_cost_inval_data_frz;             // number of frozen cycles related to coherence inval data packets
576    uint32_t m_cost_broadcast_frz;              // number of frozen cycles related to coherence broadcast packets
577
578    uint32_t m_cpt_cc_cleanup_ins;              // number of coherence cleanup packets
579    uint32_t m_cpt_cc_cleanup_data;             // number of coherence cleanup packets
580
581    uint32_t m_cpt_icleanup_transaction;        // number of instruction cleanup transactions
582    uint32_t m_cpt_dcleanup_transaction;        // number of instructinumber of data cleanup transactions
583    uint32_t m_cost_icleanup_transaction;       // cumulated duration for VCI instruction cleanup transactions
584    uint32_t m_cost_dcleanup_transaction;       // cumulated duration for VCI data cleanup transactions
585
586    uint32_t m_cost_ins_tlb_inval_frz;      // number of frozen cycles related to checking ins tlb invalidate
587    uint32_t m_cpt_ins_tlb_inval;           // number of ins tlb invalidate
588
589    uint32_t m_cost_data_tlb_inval_frz;     // number of frozen cycles related to checking data tlb invalidate   
590    uint32_t m_cpt_data_tlb_inval;          // number of data tlb invalidate
591
592    // FSM activity counters
593    uint32_t m_cpt_fsm_icache     [64];
594    uint32_t m_cpt_fsm_dcache     [64];
595    uint32_t m_cpt_fsm_cmd        [64];
596    uint32_t m_cpt_fsm_rsp        [64];
597    uint32_t m_cpt_fsm_tgt        [64];
598    uint32_t m_cpt_fsm_cmd_cleanup[64];
599    uint32_t m_cpt_fsm_rsp_cleanup[64];
600
601    uint32_t m_cpt_stop_simulation;             // used to stop simulation if frozen
602
603protected:
604    SC_HAS_PROCESS(VciCcVCacheWrapperV4);
605
606public:
607    VciCcVCacheWrapperV4(
608        sc_module_name insname,
609        int proc_id,
610        const soclib::common::MappingTable &mtp,
611        const soclib::common::MappingTable &mtc,
612        const soclib::common::IntTab &initiator_index_d,
613        const soclib::common::IntTab &initiator_index_c,
614        const soclib::common::IntTab &target_index_d,
615        size_t   itlb_ways,
616        size_t   itlb_sets,
617        size_t   dtlb_ways,
618        size_t   dtlb_sets,
619        size_t   icache_ways,
620        size_t   icache_sets,
621        size_t   icache_words,
622        size_t   dcache_ways,
623        size_t   dcache_sets,
624        size_t   dcache_words,
625        size_t   wbuf_nlines, 
626        size_t   wbuf_nwords, 
627        uint32_t max_frozen_cycles,
628        uint32_t debug_start_cycle,
629        bool     debug_ok);
630
631    ~VciCcVCacheWrapperV4();
632
633    void print_cpi();
634    void print_stats();
635    void clear_stats();
636    void print_trace(size_t mode = 0);
637    void cache_monitor(paddr_t addr);
638    inline void iss_set_debug_mask(uint v) {
639        r_iss.set_debug_mask(v);
640    }
641
642private:
643    void transition();
644    void genMoore();
645
646    soclib_static_assert((int)iss_t::SC_ATOMIC == (int)vci_param::STORE_COND_ATOMIC);
647    soclib_static_assert((int)iss_t::SC_NOT_ATOMIC == (int)vci_param::STORE_COND_NOT_ATOMIC);
648};
649
650}}
651
652#endif /* SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_V4_H */
653
654// Local Variables:
655// tab-width: 4
656// c-basic-offset: 4
657// c-file-offsets:((innamespace . 0)(inline-open . 0))
658// indent-tabs-mode: nil
659// End:
660
661// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
662
663
664
665
Note: See TracBrowser for help on using the repository browser.