source: branches/v5/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h @ 296

Last change on this file since 296 was 296, checked in by alain, 11 years ago

introducing major modifications in vci_cc_vcache_wrappers

  • remove speculative access to ICACHE and DCACHE
  • reduce write pipe-line to 2 stages
  • introduce ZOMBI state for cleanup registration
  • remove the generic CAM
  • introduce scalable LL/SC
  • handling 3 stages broadcast: CC_BROADCAST -> CLEANUP -> CLACK
File size: 33.1 KB
Line 
1/* -*- c++ -*-
2 * File : vci_cc_vcache_wrapper.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_H
29#define SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_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 "vci_initiator.h"
39#include "vci_target.h"
40#include "mapping_table.h"
41#include "static_assert.h"
42#include "iss2.h"
43
44#define LLSC_TIMEOUT    10000
45
46namespace soclib {
47namespace caba {
48
49using namespace sc_core;
50
51////////////////////////////////////////////
52template<typename vci_param, typename iss_t>
53class VciCcVCacheWrapper
54////////////////////////////////////////////
55    : public soclib::caba::BaseModule
56{
57    typedef uint32_t vaddr_t;
58    typedef uint32_t tag_t;
59    typedef uint32_t type_t;
60    typedef typename iss_t::DataOperationType data_op_t;
61
62    typedef typename vci_param::addr_t  paddr_t;
63    typedef typename vci_param::data_t  vci_data_t;
64    typedef typename vci_param::be_t    vci_be_t;
65    typedef typename vci_param::srcid_t vci_srcid_t;
66    typedef typename vci_param::trdid_t vci_trdid_t;
67    typedef typename vci_param::pktid_t vci_pktid_t;
68    typedef typename vci_param::plen_t  vci_plen_t;
69
70    enum icache_fsm_state_e { 
71        ICACHE_IDLE,             
72        // handling XTN processor requests
73        ICACHE_XTN_TLB_FLUSH,
74        ICACHE_XTN_CACHE_FLUSH, 
75        ICACHE_XTN_CACHE_FLUSH_GO, 
76        ICACHE_XTN_TLB_INVAL, 
77        ICACHE_XTN_CACHE_INVAL_VA,
78        ICACHE_XTN_CACHE_INVAL_PA, 
79        ICACHE_XTN_CACHE_INVAL_GO,
80        // handling tlb miss
81        ICACHE_TLB_WAIT,
82        // handling cache miss
83        ICACHE_MISS_SELECT,   
84        ICACHE_MISS_CLEAN,   
85        ICACHE_MISS_WAIT,   
86        ICACHE_MISS_DATA_UPDT, 
87        ICACHE_MISS_DIR_UPDT, 
88        // handling unc read
89        ICACHE_UNC_WAIT, 
90        // handling coherence requests
91        ICACHE_CC_CLACK,
92        ICACHE_CC_CHECK, 
93        ICACHE_CC_INVAL, 
94        ICACHE_CC_UPDT,
95        ICACHE_CC_BROADCAST, 
96    };
97
98    enum dcache_fsm_state_e { 
99        DCACHE_IDLE,               
100        // handling itlb & dtlb miss
101        DCACHE_TLB_MISS,
102        DCACHE_TLB_PTE1_GET,           
103        DCACHE_TLB_PTE1_SELECT,     
104        DCACHE_TLB_PTE1_UPDT,       
105        DCACHE_TLB_PTE2_GET,   
106        DCACHE_TLB_PTE2_SELECT,       
107        DCACHE_TLB_PTE2_UPDT,           
108        DCACHE_TLB_LR_UPDT,           
109        DCACHE_TLB_LR_WAIT,           
110        DCACHE_TLB_RETURN,         
111            // handling processor XTN requests
112        DCACHE_XTN_SWITCH,
113        DCACHE_XTN_SYNC,
114        DCACHE_XTN_IC_INVAL_VA,       
115        DCACHE_XTN_IC_FLUSH,       
116        DCACHE_XTN_IC_INVAL_PA,     
117        DCACHE_XTN_IT_INVAL,         
118        DCACHE_XTN_DC_FLUSH,       
119        DCACHE_XTN_DC_FLUSH_GO,     
120        DCACHE_XTN_DC_INVAL_VA,       
121        DCACHE_XTN_DC_INVAL_PA,     
122        DCACHE_XTN_DC_INVAL_END,
123        DCACHE_XTN_DC_INVAL_GO,         
124        DCACHE_XTN_DT_INVAL,         
125        //handling dirty bit update
126        DCACHE_DIRTY_GET_PTE,
127        DCACHE_DIRTY_WAIT,           
128            // handling processor miss requests
129        DCACHE_MISS_SELECT,
130        DCACHE_MISS_CLEAN,
131        DCACHE_MISS_WAIT,           
132        DCACHE_MISS_DATA_UPDT,           
133        DCACHE_MISS_DIR_UPDT,           
134        // handling processor unc, ll and sc requests
135        DCACHE_UNC_WAIT,           
136        DCACHE_LL_WAIT,           
137        DCACHE_SC_WAIT,           
138        // handling coherence requests
139        DCACHE_CC_CLACK,           
140        DCACHE_CC_CHECK,           
141        DCACHE_CC_INVAL,           
142        DCACHE_CC_UPDT,             
143        DCACHE_CC_BROADCAST,       
144        // handling TLB inval (after a coherence or XTN request)
145        DCACHE_INVAL_TLB_SCAN,             
146    };
147
148    enum cmd_fsm_state_e {     
149        CMD_IDLE,
150        CMD_INS_MISS,
151        CMD_INS_UNC,
152        CMD_DATA_MISS,
153        CMD_DATA_UNC,
154        CMD_DATA_WRITE,
155        CMD_DATA_LL,
156        CMD_DATA_SC,
157        CMD_DATA_CAS, 
158    };
159
160    enum rsp_fsm_state_e {       
161        RSP_IDLE,
162        RSP_INS_MISS,
163        RSP_INS_UNC,
164        RSP_DATA_MISS,
165        RSP_DATA_UNC,
166        RSP_DATA_LL,
167        RSP_DATA_WRITE,
168    };
169
170    enum cleanup_cmd_fsm_state_e {
171        CLEANUP_CMD_DATA_IDLE,
172        CLEANUP_CMD_DATA_GO,
173        CLEANUP_CMD_INS_IDLE,
174        CLEANUP_CMD_INS_GO,
175    };
176
177    enum cleanup_rsp_fsm_state_e {
178        CLEANUP_RSP_IDLE,
179        CLEANUP_RSP_DATA,
180        CLEANUP_RSP_INS,
181    };
182
183    enum tgt_fsm_state_e { 
184        TGT_IDLE,
185        TGT_UPDT_WORD,
186        TGT_UPDT_DATA,
187        TGT_REQ_BROADCAST,
188        TGT_REQ_ICACHE,
189        TGT_REQ_DCACHE,
190        TGT_RSP_BROADCAST,
191        TGT_RSP_ICACHE, 
192        TGT_RSP_DCACHE,
193    };
194
195    /* transaction type, pktid field */
196    enum transaction_type_e
197    {
198        // b3 unused
199        // b2 READ / NOT READ
200        // if READ
201        //  b1 DATA / INS
202        //  b0 UNC / MISS
203        // else
204        //  b1 accÚs table llsc type SW / other
205        //  b2 WRITE/CAS/LL/SC
206        TYPE_READ_DATA_UNC          = 0x0,
207        TYPE_READ_DATA_MISS         = 0x1,
208        TYPE_READ_INS_UNC           = 0x2,
209        TYPE_READ_INS_MISS          = 0x3,
210        TYPE_WRITE                  = 0x4,
211        TYPE_CAS                    = 0x5,
212        TYPE_LL                     = 0x6,
213        TYPE_SC                     = 0x7
214    };
215   
216    /* SC return values */
217    enum sc_status_type_e
218    {
219        SC_SUCCESS  =   0x00000000,
220        SC_FAIL     =   0x00000001
221    };
222
223    // coherence request type
224    enum {
225        CC_TYPE_INVAL_DATA,
226        CC_TYPE_INVAL_INS,
227        CC_TYPE_UPDT_DATA,
228        CC_TYPE_UPDT_INS,
229        CC_TYPE_BROADCAST,
230    };
231
232    // TLB Mode : ITLB / DTLB / ICACHE / DCACHE
233    enum {         
234        INS_TLB_MASK    = 0x8,
235        DATA_TLB_MASK   = 0x4,
236        INS_CACHE_MASK  = 0x2,
237        DATA_CACHE_MASK = 0x1,
238    };
239
240    // Error Type
241    enum mmu_error_type_e
242    {
243        MMU_NONE                      = 0x0000, // None
244        MMU_WRITE_PT1_UNMAPPED        = 0x0001, // Write & Page fault on PT1         
245        MMU_WRITE_PT2_UNMAPPED        = 0x0002, // Write & Page fault on PT2         
246        MMU_WRITE_PRIVILEGE_VIOLATION = 0x0004, // Write & Protected access in user mode     
247        MMU_WRITE_ACCES_VIOLATION     = 0x0008, // Write to non writable page
248        MMU_WRITE_UNDEFINED_XTN       = 0x0020, // Write & undefined external access 
249        MMU_WRITE_PT1_ILLEGAL_ACCESS  = 0x0040, // Write & Bus Error accessing PT1       
250        MMU_WRITE_PT2_ILLEGAL_ACCESS  = 0x0080, // Write & Bus Error accessing PT2     
251        MMU_WRITE_DATA_ILLEGAL_ACCESS = 0x0100, // Write & Bus Error in cache access     
252        MMU_READ_PT1_UNMAPPED         = 0x1001, // Read & Page fault on PT1     
253        MMU_READ_PT2_UNMAPPED         = 0x1002, // Read & Page fault on PT2 
254        MMU_READ_PRIVILEGE_VIOLATION  = 0x1004, // Read & Protected access in user mode
255        MMU_READ_EXEC_VIOLATION       = 0x1010, // Read & Exec access to a non exec page
256        MMU_READ_UNDEFINED_XTN        = 0x1020, // Read & Undefined external access 
257        MMU_READ_PT1_ILLEGAL_ACCESS   = 0x1040, // Read & Bus Error accessing PT1     
258        MMU_READ_PT2_ILLEGAL_ACCESS   = 0x1080, // Read & Bus Error accessing PT2       
259        MMU_READ_DATA_ILLEGAL_ACCESS  = 0x1100, // Read & Bus Error in cache access
260    };
261
262    // miss types for data cache
263    enum dcache_miss_type_e
264    {
265        PTE1_MISS, 
266        PTE2_MISS,
267        PROC_MISS, 
268    };
269
270    enum transaction_type_d_e
271    {
272        // b0 : 1 if cached
273        // b1 : 1 if instruction
274        TYPE_DATA_UNC     = 0x0,
275        TYPE_DATA_MISS    = 0x1,
276        TYPE_INS_UNC      = 0x2,
277        TYPE_INS_MISS     = 0x3,
278    };
279
280public:
281    sc_in<bool>                             p_clk;
282    sc_in<bool>                             p_resetn;
283    sc_in<bool>                             p_irq[iss_t::n_irq];
284    soclib::caba::VciInitiator<vci_param>   p_vci_ini_d;
285    soclib::caba::VciInitiator<vci_param>   p_vci_ini_c;
286    soclib::caba::VciTarget<vci_param>      p_vci_tgt_c;
287
288private:
289
290    // STRUCTURAL PARAMETERS
291    soclib::common::AddressDecodingTable<uint32_t, bool>        m_cacheability_table;
292    const soclib::common::Segment                               m_segment;
293    const vci_srcid_t                                           m_srcid_d;
294    const vci_srcid_t                                           m_srcid_c;
295
296    const size_t                                                m_itlb_ways;
297    const size_t                                                m_itlb_sets;
298
299    const size_t                                                m_dtlb_ways;
300    const size_t                                                m_dtlb_sets;
301
302    const size_t                                                m_icache_ways;
303    const size_t                                                m_icache_sets;
304    const paddr_t                                               m_icache_yzmask;
305    const size_t                                                m_icache_words;
306
307    const size_t                                                m_dcache_ways;
308    const size_t                                                m_dcache_sets;
309    const paddr_t                                               m_dcache_yzmask;
310    const size_t                                                m_dcache_words;
311
312    const size_t                        m_x_width;
313    const size_t                        m_y_width;
314
315    const size_t                        m_memory_cache_local_id;
316    const size_t                        m_proc_id;
317    const uint32_t                                              m_max_frozen_cycles;
318    const size_t                                                m_paddr_nbits; 
319
320    ////////////////////////////////////////
321    // Communication with processor ISS
322    ////////////////////////////////////////
323    typename iss_t::InstructionRequest  m_ireq;
324    typename iss_t::InstructionResponse m_irsp;
325    typename iss_t::DataRequest         m_dreq;
326    typename iss_t::DataResponse        m_drsp;
327
328    /////////////////////////////////////////////
329    // debug variables (for each FSM)
330    /////////////////////////////////////////////
331    uint32_t                            m_debug_start_cycle;
332    bool                                m_debug_ok;
333    bool                                m_debug_previous_hit;
334    bool                                m_idebug_previous_hit;
335    bool                                m_debug_dcache_fsm;
336    bool                                m_debug_icache_fsm;
337    bool                                m_debug_cleanup_fsm;
338    bool                                m_debug_inval_itlb_fsm;
339    bool                                m_debug_inval_dtlb_fsm;
340
341    ///////////////////////////////
342    // Software visible REGISTERS
343    ///////////////////////////////
344    sc_signal<uint32_t>     r_mmu_ptpr;                 // page table pointer register
345    sc_signal<uint32_t>     r_mmu_mode;                 // mmu mode register
346    sc_signal<uint32_t>     r_mmu_word_lo;              // mmu misc data low
347    sc_signal<uint32_t>     r_mmu_word_hi;              // mmu misc data hight
348    sc_signal<uint32_t>     r_mmu_ibvar;                // mmu bad instruction address
349    sc_signal<uint32_t>     r_mmu_dbvar;                // mmu bad data address
350    sc_signal<uint32_t>     r_mmu_ietr;                 // mmu instruction error type
351    sc_signal<uint32_t>     r_mmu_detr;                 // mmu data error type
352    uint32_t                r_mmu_params;                       // read-only
353    uint32_t                r_mmu_release;                      // read_only
354
355
356    //////////////////////////////
357    // ICACHE FSM REGISTERS
358    //////////////////////////////
359    sc_signal<int>          r_icache_fsm;               // state register
360    sc_signal<int>          r_icache_fsm_save;          // return state for coherence op
361    sc_signal<paddr_t>      r_icache_vci_paddr;         // physical address
362    sc_signal<uint32_t>     r_icache_vaddr_save;        // virtual address from processor
363
364    // icache miss handling
365    sc_signal<size_t>       r_icache_miss_way;              // selected way for cache update
366    sc_signal<size_t>       r_icache_miss_set;              // selected set for cache update
367    sc_signal<size_t>       r_icache_miss_word;             // word index ( cache update)
368    sc_signal<bool>         r_icache_miss_inval;        // coherence request matching a miss
369    sc_signal<bool>         r_icache_miss_clack;        // waiting for a cleanup acknowledge
370
371    // coherence request handling
372    sc_signal<size_t>       r_icache_cc_way;                // selected way for cc update/inval
373    sc_signal<size_t>       r_icache_cc_set;                // selected set for cc update/inval
374    sc_signal<size_t>       r_icache_cc_word;               // word counter for cc update
375
376    // icache flush handling
377    sc_signal<size_t>       r_icache_flush_count;           // slot counter used for cache flush
378
379    // communication between ICACHE FSM and VCI_CMD FSM
380    sc_signal<bool>         r_icache_miss_req;           // cached read miss
381    sc_signal<bool>         r_icache_unc_req;            // uncached read miss
382
383    // communication between ICACHE FSM and DCACHE FSM
384    sc_signal<bool>             r_icache_tlb_miss_req;       // (set icache/reset dcache)
385    sc_signal<bool>         r_icache_tlb_rsp_error;      // tlb miss response error
386
387    // communication between ICACHE FSM and CLEANUP FSMs
388    sc_signal<bool>         r_icache_cleanup_req;        // ICACHE cleanup request
389    sc_signal<paddr_t>      r_icache_cleanup_line;       // ICACHE cleanup NLINE
390    sc_signal<size_t>       r_icache_cleanup_way;        // ICACHE cleanup way
391
392    ///////////////////////////////
393    // DCACHE FSM REGISTERS
394    ///////////////////////////////
395    sc_signal<int>          r_dcache_fsm;               // state register
396    sc_signal<int>          r_dcache_fsm_cc_save;       // return state for coherence op
397    sc_signal<int>          r_dcache_fsm_scan_save;     // return state for tlb scan op
398    // registers written in P0 stage (used in P1 stage)
399    sc_signal<bool>         r_dcache_wbuf_req;          // WBUF must be written in P1 stage
400    sc_signal<bool>         r_dcache_updt_req;          // DCACHE must be updated in P1 stage
401    sc_signal<uint32_t>     r_dcache_save_vaddr;        // virtual address (from proc)
402    sc_signal<uint32_t>     r_dcache_save_wdata;        // write data (from proc)
403    sc_signal<vci_be_t>     r_dcache_save_be;           // byte enable (from proc)
404    sc_signal<paddr_t>      r_dcache_save_paddr;        // physical address
405    sc_signal<bool>         r_dcache_save_cacheable;    // address cacheable
406    sc_signal<size_t>       r_dcache_save_cache_way;    // selected way (from dcache)
407    sc_signal<size_t>       r_dcache_save_cache_set;    // selected set (from dcache)   
408    sc_signal<size_t>       r_dcache_save_cache_word;   // selected word (from dcache)   
409    // registers used by the Dirty bit sub-fsm
410    sc_signal<paddr_t>      r_dcache_dirty_paddr;       // PTE physical address
411    sc_signal<size_t>       r_dcache_dirty_way;         // way to invalidate in dcache
412    sc_signal<size_t>       r_dcache_dirty_set;         // set to invalidate in dcache
413
414    // communication between DCACHE FSM and VCI_CMD FSM
415    sc_signal<paddr_t>      r_dcache_vci_paddr;             // physical address for VCI command
416    sc_signal<bool>         r_dcache_vci_miss_req;      // read miss request
417    sc_signal<bool>         r_dcache_vci_unc_req;       // uncacheable read request
418    sc_signal<bool>         r_dcache_vci_unc_be;        // uncacheable read byte enable
419    sc_signal<bool>         r_dcache_vci_cas_req;       // atomic write request CAS
420    sc_signal<uint32_t>     r_dcache_vci_cas_old;       // previous data value for a CAS
421    sc_signal<uint32_t>     r_dcache_vci_cas_new;       // new data value for a CAS
422    sc_signal<bool>         r_dcache_vci_ll_req;        // atomic read request LL
423    sc_signal<bool>         r_dcache_vci_sc_req;        // atomic write request SC
424    sc_signal<vci_data_t>   r_dcache_vci_sc_data;       // SC data (command)
425
426    // register used for XTN inval
427    sc_signal<size_t>       r_dcache_xtn_way;               // selected way (from dcache)
428    sc_signal<size_t>       r_dcache_xtn_set;               // selected set (from dcache)   
429
430    // write buffer state extension
431    sc_signal<bool>         r_dcache_pending_unc_write; // pending uncacheable write in WBUF
432
433    // handling dcache miss
434    sc_signal<int>              r_dcache_miss_type;                 // depending on the requester
435    sc_signal<size_t>       r_dcache_miss_word;             // word index for cache update
436    sc_signal<size_t>       r_dcache_miss_way;              // selected way for cache update
437    sc_signal<size_t>       r_dcache_miss_set;              // selected set for cache update
438    sc_signal<bool>         r_dcache_miss_inval;        // coherence request matching a miss
439    sc_signal<bool>         r_dcache_miss_clack;        // waiting for a cleanup acknowledge
440
441    // handling coherence requests
442    sc_signal<size_t>       r_dcache_cc_way;                // selected way for cc update/inval
443    sc_signal<size_t>       r_dcache_cc_set;                // selected set for cc update/inval
444    sc_signal<size_t>       r_dcache_cc_word;               // word counter for cc update
445
446    // dcache flush handling
447    sc_signal<size_t>       r_dcache_flush_count;           // slot counter used for cache flush
448
449    // ll response handling
450    sc_signal<size_t>       r_dcache_ll_rsp_count;          // flit counter used for ll rsp
451
452    // used by the TLB miss sub-fsm
453    sc_signal<uint32_t>     r_dcache_tlb_vaddr;             // virtual address for a tlb miss
454    sc_signal<bool>         r_dcache_tlb_ins;               // target tlb (itlb if true)
455    sc_signal<paddr_t>      r_dcache_tlb_paddr;             // physical address of pte
456    sc_signal<uint32_t>     r_dcache_tlb_pte_flags;         // pte1 or first word of pte2
457    sc_signal<uint32_t>     r_dcache_tlb_pte_ppn;           // second word of pte2
458    sc_signal<size_t>       r_dcache_tlb_cache_way;         // selected way in dcache
459    sc_signal<size_t>       r_dcache_tlb_cache_set;         // selected set in dcache
460    sc_signal<size_t>       r_dcache_tlb_cache_word;    // selected word in dcache
461    sc_signal<size_t>       r_dcache_tlb_way;               // selected way in tlb   
462    sc_signal<size_t>       r_dcache_tlb_set;               // selected set in tlb   
463
464    // ITLB and DTLB invalidation
465    sc_signal<paddr_t>      r_dcache_tlb_inval_line;    // line index
466    sc_signal<size_t>       r_dcache_tlb_inval_set;     // tlb set counter
467
468    // communication between DCACHE FSM and ICACHE FSM
469    sc_signal<bool>         r_dcache_xtn_req;           // xtn request (caused by processor)
470    sc_signal<int>          r_dcache_xtn_opcode;        // xtn request type
471
472    // communication between DCACHE FSM and CLEANUP FSMs
473    sc_signal<bool>         r_dcache_cleanup_req;       // DCACHE cleanup request
474    sc_signal<paddr_t>      r_dcache_cleanup_line;      // DCACHE cleanup nline
475    sc_signal<size_t>       r_dcache_cleanup_way;       // DCACHE cleanup way
476
477    // dcache directory extension
478    bool                    *r_dcache_in_tlb;           // copy exist in dtlb or itlb
479    bool                    *r_dcache_contains_ptd;     // cache line contains a PTD
480
481    ///////////////////////////////////
482    // VCI_CMD FSM REGISTERS
483    ///////////////////////////////////
484    sc_signal<int>          r_vci_cmd_fsm;
485    sc_signal<size_t>       r_vci_cmd_min;                  // used for write bursts
486    sc_signal<size_t>       r_vci_cmd_max;                  // used for write bursts
487    sc_signal<size_t>       r_vci_cmd_cpt;                  // used for write bursts
488    sc_signal<bool>         r_vci_cmd_imiss_prio;           // round-robin between imiss & dmiss
489
490    ///////////////////////////////////
491    // VCI_RSP FSM REGISTERS
492    ///////////////////////////////////
493    sc_signal<int>          r_vci_rsp_fsm;
494    sc_signal<size_t>       r_vci_rsp_cpt;
495    sc_signal<bool>         r_vci_rsp_ins_error;
496    sc_signal<bool>         r_vci_rsp_data_error;
497    GenericFifo<uint32_t>   r_vci_rsp_fifo_icache;          // response FIFO to ICACHE FSM
498    GenericFifo<uint32_t>   r_vci_rsp_fifo_dcache;          // response FIFO to DCACHE FSM
499
500    ///////////////////////////////////
501    //  CLEANUP_CMD FSM REGISTER
502    ///////////////////////////////////
503    sc_signal<int>          r_cleanup_cmd_fsm;          // state register
504    sc_signal<size_t>       r_cleanup_cmd_trdid;        // contains way & data/ins flag
505
506    ///////////////////////////////////
507    //  CLEANUP_RSP FSM REGISTER
508    ///////////////////////////////////
509    sc_signal<int>          r_cleanup_rsp_fsm;          // state register
510    sc_signal<bool>         r_cleanup_icache_req;       // cleanup_rsp to icache request 
511    sc_signal<size_t>       r_cleanup_icache_way;       // cleanup_rsp to icache way     
512    sc_signal<size_t>       r_cleanup_icache_set;       // cleanup_rsp to icache set
513    sc_signal<bool>         r_cleanup_dcache_req;       // cleanup_rsp to dcache request 
514    sc_signal<size_t>       r_cleanup_dcache_way;       // cleanup_rsp to dcache way     
515    sc_signal<size_t>       r_cleanup_dcache_set;       // cleanup_rsp to dcache set
516
517    ///////////////////////////////////
518    //  TGT FSM REGISTERS
519    ///////////////////////////////////
520    sc_signal<int>          r_tgt_fsm;                          // state register
521    sc_signal<paddr_t>      r_tgt_paddr;                        // cache line physical address
522    sc_signal<size_t>       r_tgt_word_count;               // word index
523    sc_signal<size_t>       r_tgt_word_min;                     // index of the first word
524    sc_signal<size_t>       r_tgt_word_max;                     // index of the last word
525    sc_signal<int>          r_tgt_cc_type;                  // type of coherence request
526    sc_signal<vci_srcid_t>  r_tgt_srcid;
527    sc_signal<vci_pktid_t>  r_tgt_pktid;
528    sc_signal<vci_trdid_t>  r_tgt_trdid;
529    uint32_t                *r_tgt_buf;                         // cache line word buffer
530    vci_be_t                *r_tgt_be;                          // cache line be buffer
531
532    // communications between TGT FSM and DCACHE/ICACHE FSMs
533    sc_signal<bool>         r_tgt_icache_req;               // coherence request (set by tgt)
534    sc_signal<bool>         r_tgt_dcache_req;               // coherence request (set by tgt)
535    sc_signal<bool>         r_icache_tgt_need_rsp;      // response required (set by icache)
536    sc_signal<bool>         r_dcache_tgt_need_rsp;      // response required (set by dcache)
537
538    //////////////////////////////////////////////////////////////////
539    // processor, write buffer, caches , TLBs and CAM for cleanups
540    //////////////////////////////////////////////////////////////////
541
542    iss_t                       r_iss;   
543    MultiWriteBuffer<paddr_t>   r_wbuf;
544    GenericCache<paddr_t>       r_icache;
545    GenericCache<paddr_t>       r_dcache;
546    GenericTlb<paddr_t>         r_itlb;
547    GenericTlb<paddr_t>         r_dtlb;
548
549    //////////////////////////////////////////////////////////////////
550    // llsc registration buffer
551    //////////////////////////////////////////////////////////////////
552
553    sc_signal<paddr_t>                     r_dcache_llsc_paddr;
554    sc_signal<uint32_t>                    r_dcache_llsc_key;
555    sc_signal<uint32_t>                    r_dcache_llsc_count;
556    sc_signal<bool>                        r_dcache_llsc_valid;
557
558    ////////////////////////////////
559    // Activity counters
560    ////////////////////////////////
561    uint32_t m_cpt_dcache_data_read;        // DCACHE DATA READ
562    uint32_t m_cpt_dcache_data_write;       // DCACHE DATA WRITE
563    uint32_t m_cpt_dcache_dir_read;         // DCACHE DIR READ
564    uint32_t m_cpt_dcache_dir_write;        // DCACHE DIR WRITE
565
566    uint32_t m_cpt_icache_data_read;        // ICACHE DATA READ
567    uint32_t m_cpt_icache_data_write;       // ICACHE DATA WRITE
568    uint32_t m_cpt_icache_dir_read;         // ICACHE DIR READ
569    uint32_t m_cpt_icache_dir_write;        // ICACHE DIR WRITE
570
571    uint32_t m_cpt_frz_cycles;              // number of cycles where the cpu is frozen
572    uint32_t m_cpt_total_cycles;                // total number of cycles
573
574    // Cache activity counters
575    uint32_t m_cpt_data_read;               // total number of read data
576    uint32_t m_cpt_data_write;              // total number of write data
577    uint32_t m_cpt_data_miss;               // number of read miss
578    uint32_t m_cpt_ins_miss;                // number of instruction miss
579    uint32_t m_cpt_unc_read;                // number of read uncached
580    uint32_t m_cpt_write_cached;            // number of cached write
581    uint32_t m_cpt_ins_read;                // number of instruction read
582    uint32_t m_cpt_ins_spc_miss;            // number of speculative instruction miss
583
584    uint32_t m_cost_write_frz;              // number of frozen cycles related to write buffer         
585    uint32_t m_cost_data_miss_frz;          // number of frozen cycles related to data miss
586    uint32_t m_cost_unc_read_frz;           // number of frozen cycles related to uncached read
587    uint32_t m_cost_ins_miss_frz;           // number of frozen cycles related to ins miss
588
589    uint32_t m_cpt_imiss_transaction;       // number of VCI instruction miss transactions
590    uint32_t m_cpt_dmiss_transaction;       // number of VCI data miss transactions
591    uint32_t m_cpt_unc_transaction;         // number of VCI uncached read transactions
592    uint32_t m_cpt_write_transaction;       // number of VCI write transactions
593    uint32_t m_cpt_icache_unc_transaction;
594
595    uint32_t m_cost_imiss_transaction;      // cumulated duration for VCI IMISS transactions
596    uint32_t m_cost_dmiss_transaction;      // cumulated duration for VCI DMISS transactions
597    uint32_t m_cost_unc_transaction;        // cumulated duration for VCI UNC transactions
598    uint32_t m_cost_write_transaction;      // cumulated duration for VCI WRITE transactions
599    uint32_t m_cost_icache_unc_transaction; // cumulated duration for VCI IUNC transactions   
600    uint32_t m_length_write_transaction;    // cumulated length for VCI WRITE transactions
601
602    // TLB activity counters
603    uint32_t m_cpt_ins_tlb_read;            // number of instruction tlb read
604    uint32_t m_cpt_ins_tlb_miss;            // number of instruction tlb miss
605    uint32_t m_cpt_ins_tlb_update_acc;      // number of instruction tlb update
606    uint32_t m_cpt_ins_tlb_occup_cache;     // number of instruction tlb occupy data cache line
607    uint32_t m_cpt_ins_tlb_hit_dcache;      // number of instruction tlb hit in data cache
608
609    uint32_t m_cpt_data_tlb_read;           // number of data tlb read
610    uint32_t m_cpt_data_tlb_miss;           // number of data tlb miss
611    uint32_t m_cpt_data_tlb_update_acc;     // number of data tlb update
612    uint32_t m_cpt_data_tlb_update_dirty;   // number of data tlb update dirty
613    uint32_t m_cpt_data_tlb_hit_dcache;     // number of data tlb hit in data cache
614    uint32_t m_cpt_data_tlb_occup_cache;    // number of data tlb occupy data cache line
615    uint32_t m_cpt_tlb_occup_dcache;
616   
617    uint32_t m_cost_ins_tlb_miss_frz;       // number of frozen cycles related to instruction tlb miss
618    uint32_t m_cost_data_tlb_miss_frz;      // number of frozen cycles related to data tlb miss
619    uint32_t m_cost_ins_tlb_update_acc_frz;    // number of frozen cycles related to instruction tlb update acc
620    uint32_t m_cost_data_tlb_update_acc_frz;   // number of frozen cycles related to data tlb update acc
621    uint32_t m_cost_data_tlb_update_dirty_frz; // number of frozen cycles related to data tlb update dirty
622    uint32_t m_cost_ins_tlb_occup_cache_frz;   // number of frozen cycles related to instruction tlb miss operate in dcache
623    uint32_t m_cost_data_tlb_occup_cache_frz;  // number of frozen cycles related to data tlb miss operate in dcache
624
625    uint32_t m_cpt_itlbmiss_transaction;       // number of itlb miss transactions
626    uint32_t m_cpt_itlb_ll_transaction;        // number of itlb ll acc transactions
627    uint32_t m_cpt_itlb_sc_transaction;        // number of itlb sc acc transactions
628    uint32_t m_cpt_dtlbmiss_transaction;       // number of dtlb miss transactions
629    uint32_t m_cpt_dtlb_ll_transaction;        // number of dtlb ll acc transactions
630    uint32_t m_cpt_dtlb_sc_transaction;        // number of dtlb sc acc transactions
631    uint32_t m_cpt_dtlb_ll_dirty_transaction;  // number of dtlb ll dirty transactions
632    uint32_t m_cpt_dtlb_sc_dirty_transaction;  // number of dtlb sc dirty transactions
633
634    uint32_t m_cost_itlbmiss_transaction;       // cumulated duration for VCI instruction TLB miss transactions
635    uint32_t m_cost_itlb_ll_transaction;        // cumulated duration for VCI instruction TLB ll acc transactions
636    uint32_t m_cost_itlb_sc_transaction;        // cumulated duration for VCI instruction TLB sc acc transactions
637    uint32_t m_cost_dtlbmiss_transaction;       // cumulated duration for VCI data TLB miss transactions
638    uint32_t m_cost_dtlb_ll_transaction;        // cumulated duration for VCI data TLB ll acc transactions
639    uint32_t m_cost_dtlb_sc_transaction;        // cumulated duration for VCI data TLB sc acc transactions
640    uint32_t m_cost_dtlb_ll_dirty_transaction;  // cumulated duration for VCI data TLB ll dirty transactions
641    uint32_t m_cost_dtlb_sc_dirty_transaction;  // cumulated duration for VCI data TLB sc dirty transactions
642
643    // coherence activity counters
644    uint32_t m_cpt_cc_update_icache;            // number of coherence update instruction commands
645    uint32_t m_cpt_cc_update_dcache;            // number of coherence update data commands
646    uint32_t m_cpt_cc_inval_icache;             // number of coherence inval instruction commands
647    uint32_t m_cpt_cc_inval_dcache;             // number of coherence inval data commands
648    uint32_t m_cpt_cc_broadcast;                // number of coherence broadcast commands
649   
650    uint32_t m_cost_updt_data_frz;              // number of frozen cycles related to coherence update data packets
651    uint32_t m_cost_inval_ins_frz;              // number of frozen cycles related to coherence inval instruction packets
652    uint32_t m_cost_inval_data_frz;             // number of frozen cycles related to coherence inval data packets
653    uint32_t m_cost_broadcast_frz;              // number of frozen cycles related to coherence broadcast packets
654
655    uint32_t m_cpt_cc_cleanup_ins;              // number of coherence cleanup packets
656    uint32_t m_cpt_cc_cleanup_data;             // number of coherence cleanup packets
657
658    uint32_t m_cpt_icleanup_transaction;        // number of instruction cleanup transactions
659    uint32_t m_cpt_dcleanup_transaction;        // number of instructinumber of data cleanup transactions
660    uint32_t m_cost_icleanup_transaction;       // cumulated duration for VCI instruction cleanup transactions
661    uint32_t m_cost_dcleanup_transaction;       // cumulated duration for VCI data cleanup transactions
662
663    uint32_t m_cost_ins_tlb_inval_frz;      // number of frozen cycles related to checking ins tlb invalidate
664    uint32_t m_cpt_ins_tlb_inval;           // number of ins tlb invalidate
665
666    uint32_t m_cost_data_tlb_inval_frz;     // number of frozen cycles related to checking data tlb invalidate   
667    uint32_t m_cpt_data_tlb_inval;          // number of data tlb invalidate
668
669    // FSM activity counters
670    uint32_t m_cpt_fsm_icache     [64];
671    uint32_t m_cpt_fsm_dcache     [64];
672    uint32_t m_cpt_fsm_cmd        [64];
673    uint32_t m_cpt_fsm_rsp        [64];
674    uint32_t m_cpt_fsm_tgt        [64];
675    uint32_t m_cpt_fsm_cmd_cleanup[64];
676    uint32_t m_cpt_fsm_rsp_cleanup[64];
677
678    uint32_t m_cpt_stop_simulation;             // used to stop simulation if frozen
679
680protected:
681    SC_HAS_PROCESS(VciCcVCacheWrapper);
682
683public:
684    VciCcVCacheWrapper(
685        sc_module_name insname,
686        int proc_id,
687        const soclib::common::MappingTable &mtp,
688        const soclib::common::MappingTable &mtc,
689        const soclib::common::IntTab &initiator_index_d,
690        const soclib::common::IntTab &initiator_index_c,
691        const soclib::common::IntTab &target_index_d,
692        size_t   itlb_ways,
693        size_t   itlb_sets,
694        size_t   dtlb_ways,
695        size_t   dtlb_sets,
696        size_t   icache_ways,
697        size_t   icache_sets,
698        size_t   icache_words,
699        size_t   dcache_ways,
700        size_t   dcache_sets,
701        size_t   dcache_words,
702        size_t   wbuf_nlines, 
703        size_t   wbuf_nwords, 
704        size_t   x_width,
705        size_t   y_width,
706        uint32_t memory_cache_local_id,
707        uint32_t max_frozen_cycles,
708        uint32_t debug_start_cycle,
709        bool     debug_ok);
710
711    ~VciCcVCacheWrapper();
712
713    void print_cpi();
714    void print_stats();
715    void clear_stats();
716    void print_trace(size_t mode = 0);
717    void cache_monitor(paddr_t addr);
718    inline void iss_set_debug_mask(uint v) {
719        r_iss.set_debug_mask(v);
720    }
721
722private:
723    void transition();
724    void genMoore();
725
726    soclib_static_assert((int)iss_t::SC_ATOMIC == (int)vci_param::STORE_COND_ATOMIC);
727    soclib_static_assert((int)iss_t::SC_NOT_ATOMIC == (int)vci_param::STORE_COND_NOT_ATOMIC);
728};
729
730}}
731
732#endif /* SOCLIB_CABA_VCI_CC_VCACHE_WRAPPER_H */
733
734// Local Variables:
735// tab-width: 4
736// c-basic-offset: 4
737// c-file-offsets:((innamespace . 0)(inline-open . 0))
738// indent-tabs-mode: nil
739// End:
740
741// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
742
743
744
745
Note: See TracBrowser for help on using the repository browser.