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

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

bug fixing

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