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

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

Introducing vci_cc_vcache_v4

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