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

Last change on this file since 247 was 247, checked in by cfuguet, 12 years ago

Introducing new CLEANUP transaction address specification in the components:

  • vci_cc_vcache_wrapper_v4
  • vci_mem_cache_v4

The new specification uses the VCI WDATA and the VCI BE to send the cleanup
nline. The VCI ADDRESS is like follows:

  • NLINE MSb | Memory Cache local ID | 00....00

The platforms:

  • tsarv4_mono_mmu
  • tsarv4_generic_mmu

has been modified to use the modified components and the mapping table for the coherence
address space has been updated.

File size: 30.9 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_x_width;
257    const size_t                        m_y_width;
258
259    const size_t                        m_memory_cache_local_id;
260
261    const size_t                        m_proc_id;
262
263    const uint32_t                                              m_max_frozen_cycles;
264
265    const size_t                                                m_paddr_nbits; 
266
267    ////////////////////////////////////////
268    // Communication with processor ISS
269    ////////////////////////////////////////
270    typename iss_t::InstructionRequest  m_ireq;
271    typename iss_t::InstructionResponse m_irsp;
272    typename iss_t::DataRequest         m_dreq;
273    typename iss_t::DataResponse        m_drsp;
274
275    /////////////////////////////////////////////
276    // debug variables (for each FSM)
277    /////////////////////////////////////////////
278    uint32_t                            m_debug_start_cycle;
279    bool                                m_debug_ok;
280    bool                                m_debug_previous_hit;
281    bool                                m_idebug_previous_hit;
282    bool                                m_debug_dcache_fsm;
283    bool                                m_debug_icache_fsm;
284    bool                                m_debug_cleanup_fsm;
285    bool                                m_debug_inval_itlb_fsm;
286    bool                                m_debug_inval_dtlb_fsm;
287
288    ///////////////////////////////
289    // Software visible REGISTERS
290    ///////////////////////////////
291    sc_signal<uint32_t>     r_mmu_ptpr;                 // page table pointer register
292    sc_signal<uint32_t>     r_mmu_mode;                 // mmu mode register
293    sc_signal<uint32_t>     r_mmu_word_lo;              // mmu misc data low
294    sc_signal<uint32_t>     r_mmu_word_hi;              // mmu misc data hight
295    sc_signal<uint32_t>     r_mmu_ibvar;                // mmu bad instruction address
296    sc_signal<uint32_t>     r_mmu_dbvar;                // mmu bad data address
297    sc_signal<uint32_t>     r_mmu_ietr;                 // mmu instruction error type
298    sc_signal<uint32_t>     r_mmu_detr;                 // mmu data error type
299    uint32_t                r_mmu_params;                       // read-only
300    uint32_t                r_mmu_release;                      // read_only
301
302
303    //////////////////////////////
304    // ICACHE FSM REGISTERS
305    //////////////////////////////
306    sc_signal<int>          r_icache_fsm;               // state register
307    sc_signal<int>          r_icache_fsm_save;          // return state for coherence operation
308    sc_signal<paddr_t>      r_icache_vci_paddr;         // physical address
309    sc_signal<uint32_t>     r_icache_vaddr_save;        // virtual address requested by the processor
310
311    // icache miss handling
312    sc_signal<size_t>       r_icache_miss_way;              // selected way for cache update
313    sc_signal<size_t>       r_icache_miss_set;              // selected set for cache update         
314    sc_signal<size_t>       r_icache_miss_word;             // word index for sequencial cache update
315    sc_signal<bool>         r_icache_miss_inval;        // coherence request matching a pending miss
316
317    // coherence request handling
318    sc_signal<size_t>       r_icache_cc_way;                // selected way for cc update/inval
319    sc_signal<size_t>       r_icache_cc_set;                // selected set for cc update/inval
320    sc_signal<size_t>       r_icache_cc_word;               // word counter for cc update
321
322    // icache flush handling
323    sc_signal<size_t>       r_icache_flush_count;           // slot counter used for cache flush
324
325    // communication between ICACHE FSM and VCI_CMD FSM
326    sc_signal<bool>         r_icache_miss_req;           // cached read miss
327    sc_signal<bool>         r_icache_unc_req;            // uncached read miss
328
329    // communication between ICACHE FSM and DCACHE FSM
330    sc_signal<bool>             r_icache_tlb_miss_req;       // itlb miss request (set icache/reset dcache)
331    sc_signal<bool>         r_icache_tlb_rsp_error;      // itlb miss response error (written by dcache)
332
333    // communication between ICACHE FSM and CLEANUP FSMs
334    sc_signal<bool>         r_icache_cleanup_req;        // ins cleanup request
335    sc_signal<paddr_t>      r_icache_cleanup_line;       // ins cleanup NLINE
336
337    ///////////////////////////////
338    // DCACHE FSM REGISTERS
339    ///////////////////////////////
340    sc_signal<int>          r_dcache_fsm;               // state register
341    sc_signal<int>          r_dcache_fsm_cc_save;       // return state for coherence operation
342    sc_signal<int>          r_dcache_fsm_scan_save;     // return state for tlb scan operation
343    // registers written in P0 stage (used in P1 stage)
344    sc_signal<bool>         r_dcache_p0_valid;              // P1 pipeline stage must be executed
345    sc_signal<uint32_t>     r_dcache_p0_vaddr;          // virtual address (from proc)
346    sc_signal<uint32_t>     r_dcache_p0_wdata;          // write data (from proc)
347    sc_signal<vci_be_t>     r_dcache_p0_be;             // byte enable (from proc)
348    sc_signal<paddr_t>      r_dcache_p0_paddr;          // physical address
349    sc_signal<bool>         r_dcache_p0_cacheable;          // address cacheable
350    // registers written in P1 stage (used in P2 stage)
351    sc_signal<bool>         r_dcache_p1_valid;              // P2 pipeline stage must be executed
352    sc_signal<uint32_t>     r_dcache_p1_wdata;          // write data (from proc)
353    sc_signal<vci_be_t>     r_dcache_p1_be;             // byte enable (from proc)
354    sc_signal<paddr_t>      r_dcache_p1_paddr;          // physical address
355    sc_signal<size_t>       r_dcache_p1_cache_way;          // selected way (from dcache)
356    sc_signal<size_t>       r_dcache_p1_cache_set;          // selected set (from dcache)   
357    sc_signal<size_t>       r_dcache_p1_cache_word;         // selected word (from dcache)   
358    // registers used by the Dirty bit sub-fsm
359    sc_signal<paddr_t>      r_dcache_dirty_paddr;       // PTE physical address
360    sc_signal<size_t>       r_dcache_dirty_way;         // way to invalidate in dcache
361    sc_signal<size_t>       r_dcache_dirty_set;         // set to invalidate in dcache
362
363    // communication between DCACHE FSM and VCI_CMD FSM
364    sc_signal<paddr_t>      r_dcache_vci_paddr;             // physical address for VCI command
365    sc_signal<bool>         r_dcache_vci_miss_req;      // read miss request
366    sc_signal<bool>         r_dcache_vci_unc_req;       // uncacheable read request
367    sc_signal<bool>         r_dcache_vci_unc_be;        // uncacheable read byte enable
368    sc_signal<bool>         r_dcache_vci_sc_req;        // atomic write request (Compare & swap)
369    sc_signal<uint32_t>     r_dcache_vci_sc_old;        // previous data value for an atomic write
370    sc_signal<uint32_t>     r_dcache_vci_sc_new;        // new data value for an atomic write
371
372    // register used for XTN inval
373    sc_signal<size_t>       r_dcache_xtn_way;               // selected way (from dcache)
374    sc_signal<size_t>       r_dcache_xtn_set;               // selected set (from dcache)   
375
376    // write buffer state extension
377    sc_signal<bool>         r_dcache_pending_unc_write; // pending uncacheable write in WBUF
378
379    // handling dcache miss
380    sc_signal<int>              r_dcache_miss_type;                 // type of miss depending on the requester
381    sc_signal<size_t>       r_dcache_miss_word;             // word index for sequencial cache update
382    sc_signal<size_t>       r_dcache_miss_way;              // selected way for cache update
383    sc_signal<size_t>       r_dcache_miss_set;              // selected set for cache update
384    sc_signal<bool>         r_dcache_miss_inval;        // coherence request matching a pending miss
385
386    // handling coherence requests
387    sc_signal<size_t>       r_dcache_cc_way;                // selected way for cc update/inval
388    sc_signal<size_t>       r_dcache_cc_set;                // selected set for cc update/inval
389    sc_signal<size_t>       r_dcache_cc_word;               // word counter for cc update
390
391    // dcache flush handling
392    sc_signal<size_t>       r_dcache_flush_count;           // slot counter used for cache flush
393
394    // used by the TLB miss sub-fsm
395    sc_signal<uint32_t>     r_dcache_tlb_vaddr;             // virtual address for a tlb miss
396    sc_signal<bool>         r_dcache_tlb_ins;               // target tlb (itlb if true)
397    sc_signal<paddr_t>      r_dcache_tlb_paddr;             // physical address of pte
398    sc_signal<uint32_t>     r_dcache_tlb_pte_flags;         // pte1 or first word of pte2
399    sc_signal<uint32_t>     r_dcache_tlb_pte_ppn;           // second word of pte2
400    sc_signal<size_t>       r_dcache_tlb_cache_way;         // selected way in dcache
401    sc_signal<size_t>       r_dcache_tlb_cache_set;         // selected set in dcache
402    sc_signal<size_t>       r_dcache_tlb_cache_word;    // selected word in dcache
403    sc_signal<size_t>       r_dcache_tlb_way;               // selected way in tlb   
404    sc_signal<size_t>       r_dcache_tlb_set;               // selected set in tlb   
405
406    // LL reservation handling
407    sc_signal<bool>         r_dcache_ll_valid;              // valid LL reservation
408    sc_signal<uint32_t>     r_dcache_ll_data;               // LL reserved data
409    sc_signal<paddr_t>      r_dcache_ll_vaddr;              // LL reserved address
410                           
411    // ITLB and DTLB invalidation
412    sc_signal<paddr_t>      r_dcache_tlb_inval_line;    // line index
413    sc_signal<size_t>       r_dcache_tlb_inval_count;   // tlb entry counter
414
415    // communication between DCACHE FSM and ICACHE FSM
416    sc_signal<bool>         r_dcache_xtn_req;           // xtn request (caused by processor)
417    sc_signal<int>          r_dcache_xtn_opcode;        // xtn request type
418
419    // communication between DCACHE FSM and CLEANUP FSMs
420    sc_signal<bool>         r_dcache_cleanup_req;       // data cleanup request
421    sc_signal<paddr_t>      r_dcache_cleanup_line;      // data cleanup NLINE
422
423    // dcache directory extension
424    bool                    *r_dcache_in_tlb;           // copy exist in dtlb or itlb
425    bool                    *r_dcache_contains_ptd;     // cache line contains a PTD
426
427    ///////////////////////////////////
428    // VCI_CMD FSM REGISTERS
429    ///////////////////////////////////
430    sc_signal<int>          r_vci_cmd_fsm;
431    sc_signal<size_t>       r_vci_cmd_min;                  // used for write bursts
432    sc_signal<size_t>       r_vci_cmd_max;                  // used for write bursts
433    sc_signal<size_t>       r_vci_cmd_cpt;                  // used for write bursts
434    sc_signal<bool>         r_vci_cmd_imiss_prio;           // round-robin between imiss & dmiss
435
436    ///////////////////////////////////
437    // VCI_RSP FSM REGISTERS
438    ///////////////////////////////////
439    sc_signal<int>          r_vci_rsp_fsm;
440    sc_signal<size_t>       r_vci_rsp_cpt;
441    sc_signal<bool>         r_vci_rsp_ins_error;
442    sc_signal<bool>         r_vci_rsp_data_error;
443    GenericFifo<uint32_t>   r_vci_rsp_fifo_icache;          // response FIFO to ICACHE FSM
444    GenericFifo<uint32_t>   r_vci_rsp_fifo_dcache;          // response FIFO to DCACHE FSM
445
446    ///////////////////////////////////
447    //  CLEANUP FSM REGISTER
448    ///////////////////////////////////
449    sc_signal<int>          r_cleanup_fsm;              // state register
450    sc_signal<size_t>       r_cleanup_trdid;            // to clear the registration buffer
451    GenericCam<paddr_t>     r_cleanup_buffer;           // Registration buffer for cleanups
452
453    ///////////////////////////////////
454    //  TGT FSM REGISTERS
455    ///////////////////////////////////
456    sc_signal<int>          r_tgt_fsm;                          // state register
457    sc_signal<paddr_t>      r_tgt_paddr;                        // cache line physical address
458    sc_signal<size_t>       r_tgt_word_count;               // word index
459    sc_signal<size_t>       r_tgt_word_min;                     // index of the first word to be updated
460    sc_signal<size_t>       r_tgt_word_max;                     // index of the last word to be updated
461    sc_signal<bool>         r_tgt_update;                       // update request
462    sc_signal<bool>         r_tgt_update_data;              // update data request
463    sc_signal<vci_srcid_t>  r_tgt_srcid;
464    sc_signal<vci_pktid_t>  r_tgt_pktid;
465    sc_signal<vci_trdid_t>  r_tgt_trdid;
466
467    // communications between TGT FSM and DCACHE/ICACHE FSMs
468    sc_signal<bool>         r_tgt_icache_req;               // coherence request (set by tgt)
469    sc_signal<bool>         r_tgt_dcache_req;               // coherence request (set by tgt)
470    sc_signal<bool>         r_tgt_icache_rsp;               // coherence response (set by icache)
471    sc_signal<bool>         r_tgt_dcache_rsp;               // coherence response (set by dcache)
472
473    uint32_t                *r_tgt_buf;                         // cache line word buffer
474    vci_be_t                *r_tgt_be;                          // cache line be buffer
475
476    //////////////////////////////////////////////////////////////////
477    // processor, write buffer, caches , TLBs and CAM for cleanups
478    //////////////////////////////////////////////////////////////////
479    iss_t                       r_iss;   
480    MultiWriteBuffer<paddr_t>   r_wbuf;
481    GenericCache<paddr_t>       r_icache;
482    GenericCache<paddr_t>       r_dcache;
483    GenericTlb<paddr_t>         r_itlb;
484    GenericTlb<paddr_t>         r_dtlb;
485
486    ////////////////////////////////
487    // Activity counters
488    ////////////////////////////////
489    uint32_t m_cpt_dcache_data_read;        // DCACHE DATA READ
490    uint32_t m_cpt_dcache_data_write;       // DCACHE DATA WRITE
491    uint32_t m_cpt_dcache_dir_read;         // DCACHE DIR READ
492    uint32_t m_cpt_dcache_dir_write;        // DCACHE DIR WRITE
493
494    uint32_t m_cpt_icache_data_read;        // ICACHE DATA READ
495    uint32_t m_cpt_icache_data_write;       // ICACHE DATA WRITE
496    uint32_t m_cpt_icache_dir_read;         // ICACHE DIR READ
497    uint32_t m_cpt_icache_dir_write;        // ICACHE DIR WRITE
498
499    uint32_t m_cpt_frz_cycles;              // number of cycles where the cpu is frozen
500    uint32_t m_cpt_total_cycles;                // total number of cycles
501
502    // Cache activity counters
503    uint32_t m_cpt_data_read;               // total number of read data
504    uint32_t m_cpt_data_write;              // total number of write data
505    uint32_t m_cpt_data_miss;               // number of read miss
506    uint32_t m_cpt_ins_miss;                // number of instruction miss
507    uint32_t m_cpt_unc_read;                // number of read uncached
508    uint32_t m_cpt_write_cached;            // number of cached write
509    uint32_t m_cpt_ins_read;                // number of instruction read
510    uint32_t m_cpt_ins_spc_miss;            // number of speculative instruction miss
511
512    uint32_t m_cost_write_frz;              // number of frozen cycles related to write buffer         
513    uint32_t m_cost_data_miss_frz;          // number of frozen cycles related to data miss
514    uint32_t m_cost_unc_read_frz;           // number of frozen cycles related to uncached read
515    uint32_t m_cost_ins_miss_frz;           // number of frozen cycles related to ins miss
516
517    uint32_t m_cpt_imiss_transaction;       // number of VCI instruction miss transactions
518    uint32_t m_cpt_dmiss_transaction;       // number of VCI data miss transactions
519    uint32_t m_cpt_unc_transaction;         // number of VCI uncached read transactions
520    uint32_t m_cpt_write_transaction;       // number of VCI write transactions
521    uint32_t m_cpt_icache_unc_transaction;
522
523    uint32_t m_cost_imiss_transaction;      // cumulated duration for VCI IMISS transactions
524    uint32_t m_cost_dmiss_transaction;      // cumulated duration for VCI DMISS transactions
525    uint32_t m_cost_unc_transaction;        // cumulated duration for VCI UNC transactions
526    uint32_t m_cost_write_transaction;      // cumulated duration for VCI WRITE transactions
527    uint32_t m_cost_icache_unc_transaction; // cumulated duration for VCI IUNC transactions   
528    uint32_t m_length_write_transaction;    // cumulated length for VCI WRITE transactions
529
530    // TLB activity counters
531    uint32_t m_cpt_ins_tlb_read;            // number of instruction tlb read
532    uint32_t m_cpt_ins_tlb_miss;            // number of instruction tlb miss
533    uint32_t m_cpt_ins_tlb_update_acc;      // number of instruction tlb update
534    uint32_t m_cpt_ins_tlb_occup_cache;     // number of instruction tlb occupy data cache line
535    uint32_t m_cpt_ins_tlb_hit_dcache;      // number of instruction tlb hit in data cache
536
537    uint32_t m_cpt_data_tlb_read;           // number of data tlb read
538    uint32_t m_cpt_data_tlb_miss;           // number of data tlb miss
539    uint32_t m_cpt_data_tlb_update_acc;     // number of data tlb update
540    uint32_t m_cpt_data_tlb_update_dirty;   // number of data tlb update dirty
541    uint32_t m_cpt_data_tlb_hit_dcache;     // number of data tlb hit in data cache
542    uint32_t m_cpt_data_tlb_occup_cache;    // number of data tlb occupy data cache line
543    uint32_t m_cpt_tlb_occup_dcache;
544   
545    uint32_t m_cost_ins_tlb_miss_frz;       // number of frozen cycles related to instruction tlb miss
546    uint32_t m_cost_data_tlb_miss_frz;      // number of frozen cycles related to data tlb miss
547    uint32_t m_cost_ins_tlb_update_acc_frz;    // number of frozen cycles related to instruction tlb update acc
548    uint32_t m_cost_data_tlb_update_acc_frz;   // number of frozen cycles related to data tlb update acc
549    uint32_t m_cost_data_tlb_update_dirty_frz; // number of frozen cycles related to data tlb update dirty
550    uint32_t m_cost_ins_tlb_occup_cache_frz;   // number of frozen cycles related to instruction tlb miss operate in dcache
551    uint32_t m_cost_data_tlb_occup_cache_frz;  // number of frozen cycles related to data tlb miss operate in dcache
552
553    uint32_t m_cpt_itlbmiss_transaction;       // number of itlb miss transactions
554    uint32_t m_cpt_itlb_ll_transaction;        // number of itlb ll acc transactions
555    uint32_t m_cpt_itlb_sc_transaction;        // number of itlb sc acc transactions
556    uint32_t m_cpt_dtlbmiss_transaction;       // number of dtlb miss transactions
557    uint32_t m_cpt_dtlb_ll_transaction;        // number of dtlb ll acc transactions
558    uint32_t m_cpt_dtlb_sc_transaction;        // number of dtlb sc acc transactions
559    uint32_t m_cpt_dtlb_ll_dirty_transaction;  // number of dtlb ll dirty transactions
560    uint32_t m_cpt_dtlb_sc_dirty_transaction;  // number of dtlb sc dirty transactions
561
562    uint32_t m_cost_itlbmiss_transaction;       // cumulated duration for VCI instruction TLB miss transactions
563    uint32_t m_cost_itlb_ll_transaction;        // cumulated duration for VCI instruction TLB ll acc transactions
564    uint32_t m_cost_itlb_sc_transaction;        // cumulated duration for VCI instruction TLB sc acc transactions
565    uint32_t m_cost_dtlbmiss_transaction;       // cumulated duration for VCI data TLB miss transactions
566    uint32_t m_cost_dtlb_ll_transaction;        // cumulated duration for VCI data TLB ll acc transactions
567    uint32_t m_cost_dtlb_sc_transaction;        // cumulated duration for VCI data TLB sc acc transactions
568    uint32_t m_cost_dtlb_ll_dirty_transaction;  // cumulated duration for VCI data TLB ll dirty transactions
569    uint32_t m_cost_dtlb_sc_dirty_transaction;  // cumulated duration for VCI data TLB sc dirty transactions
570
571    // coherence activity counters
572    uint32_t m_cpt_cc_update_icache;            // number of coherence update instruction commands
573    uint32_t m_cpt_cc_update_dcache;            // number of coherence update data commands
574    uint32_t m_cpt_cc_inval_icache;             // number of coherence inval instruction commands
575    uint32_t m_cpt_cc_inval_dcache;             // number of coherence inval data commands
576    uint32_t m_cpt_cc_broadcast;                // number of coherence broadcast commands
577   
578    uint32_t m_cost_updt_data_frz;              // number of frozen cycles related to coherence update data packets
579    uint32_t m_cost_inval_ins_frz;              // number of frozen cycles related to coherence inval instruction packets
580    uint32_t m_cost_inval_data_frz;             // number of frozen cycles related to coherence inval data packets
581    uint32_t m_cost_broadcast_frz;              // number of frozen cycles related to coherence broadcast packets
582
583    uint32_t m_cpt_cc_cleanup_ins;              // number of coherence cleanup packets
584    uint32_t m_cpt_cc_cleanup_data;             // number of coherence cleanup packets
585
586    uint32_t m_cpt_icleanup_transaction;        // number of instruction cleanup transactions
587    uint32_t m_cpt_dcleanup_transaction;        // number of instructinumber of data cleanup transactions
588    uint32_t m_cost_icleanup_transaction;       // cumulated duration for VCI instruction cleanup transactions
589    uint32_t m_cost_dcleanup_transaction;       // cumulated duration for VCI data cleanup transactions
590
591    uint32_t m_cost_ins_tlb_inval_frz;      // number of frozen cycles related to checking ins tlb invalidate
592    uint32_t m_cpt_ins_tlb_inval;           // number of ins tlb invalidate
593
594    uint32_t m_cost_data_tlb_inval_frz;     // number of frozen cycles related to checking data tlb invalidate   
595    uint32_t m_cpt_data_tlb_inval;          // number of data tlb invalidate
596
597    // FSM activity counters
598    uint32_t m_cpt_fsm_icache     [64];
599    uint32_t m_cpt_fsm_dcache     [64];
600    uint32_t m_cpt_fsm_cmd        [64];
601    uint32_t m_cpt_fsm_rsp        [64];
602    uint32_t m_cpt_fsm_tgt        [64];
603    uint32_t m_cpt_fsm_cmd_cleanup[64];
604    uint32_t m_cpt_fsm_rsp_cleanup[64];
605
606    uint32_t m_cpt_stop_simulation;             // used to stop simulation if frozen
607
608protected:
609    SC_HAS_PROCESS(VciCcVCacheWrapperV4);
610
611public:
612    VciCcVCacheWrapperV4(
613        sc_module_name insname,
614        int proc_id,
615        const soclib::common::MappingTable &mtp,
616        const soclib::common::MappingTable &mtc,
617        const soclib::common::IntTab &initiator_index_d,
618        const soclib::common::IntTab &initiator_index_c,
619        const soclib::common::IntTab &target_index_d,
620        size_t   itlb_ways,
621        size_t   itlb_sets,
622        size_t   dtlb_ways,
623        size_t   dtlb_sets,
624        size_t   icache_ways,
625        size_t   icache_sets,
626        size_t   icache_words,
627        size_t   dcache_ways,
628        size_t   dcache_sets,
629        size_t   dcache_words,
630        size_t   wbuf_nlines, 
631        size_t   wbuf_nwords, 
632        size_t   x_width,
633        size_t   y_width,
634        uint32_t memory_cache_local_id,
635        uint32_t max_frozen_cycles,
636        uint32_t debug_start_cycle,
637        bool     debug_ok);
638
639    ~VciCcVCacheWrapperV4();
640
641    void print_cpi();
642    void print_stats();
643    void clear_stats();
644    void print_trace(size_t mode = 0);
645    void cache_monitor(paddr_t addr);
646    inline void iss_set_debug_mask(uint v) {
647        r_iss.set_debug_mask(v);
648    }
649
650private:
651    void transition();
652    void genMoore();
653
654    soclib_static_assert((int)iss_t::SC_ATOMIC == (int)vci_param::STORE_COND_ATOMIC);
655    soclib_static_assert((int)iss_t::SC_NOT_ATOMIC == (int)vci_param::STORE_COND_NOT_ATOMIC);
656};
657
658}}
659
660#endif /* SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_V4_H */
661
662// Local Variables:
663// tab-width: 4
664// c-basic-offset: 4
665// c-file-offsets:((innamespace . 0)(inline-open . 0))
666// indent-tabs-mode: nil
667// End:
668
669// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
670
671
672
673
Note: See TracBrowser for help on using the repository browser.