source: branches/MESI/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h @ 675

Last change on this file since 675 was 675, checked in by haoliu, 10 years ago

MESI bug fixed

File size: 55.8 KB
Line 
1/* -*- c++ -*-
2 * File         : vci_mem_cache.h
3 * Date         : 26/10/2008
4 * Copyright    : UPMC / LIP6
5 * Authors      : Alain Greiner / Eric Guthmuller
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 * Maintainers: alain.greiner@lip6.fr
28 *              eric.guthmuller@polytechnique.edu
29 *              cesar.fuguet-tortolero@lip6.fr
30 *              alexandre.joannou@lip6.fr
31 */
32
33#ifndef SOCLIB_CABA_MEM_CACHE_H
34#define SOCLIB_CABA_MEM_CACHE_H
35
36#include <inttypes.h>
37#include <systemc>
38#include <list>
39#include <cassert>
40#include "arithmetics.h"
41#include "alloc_elems.h"
42#include "caba_base_module.h"
43#include "vci_target.h"
44#include "vci_initiator.h"
45#include "generic_fifo.h"
46#include "mapping_table.h"
47#include "int_tab.h"
48#include "generic_llsc_global_table.h"
49#include "mem_cache_directory.h"
50#include "xram_transaction.h"
51#include "update_tab.h"
52#include "dspin_interface.h"
53#include "dspin_dhccp_param.h"
54
55#define TRT_ENTRIES      4      // Number of entries in TRT
56#define UPT_ENTRIES      4      // Number of entries in UPT
57#define IVT_ENTRIES      4      // Number of entries in IVT
58#define HEAP_ENTRIES     1024   // Number of entries in HEAP
59
60namespace soclib {  namespace caba {
61
62  using namespace sc_core;
63
64  template<typename vci_param_int, 
65           typename vci_param_ext,
66           size_t   dspin_in_width,
67           size_t   dspin_out_width>
68    class VciMemCache
69    : public soclib::caba::BaseModule
70    {
71      typedef typename vci_param_int::fast_addr_t  addr_t;
72      typedef typename sc_dt::sc_uint<64>          wide_data_t;
73      typedef uint32_t                             data_t;
74      typedef uint32_t                             tag_t;
75      typedef uint32_t                             be_t;
76      typedef uint32_t                             copy_t;
77
78      /* States of the TGT_CMD fsm */
79      enum tgt_cmd_fsm_state_e
80      {
81        TGT_CMD_IDLE,
82        TGT_CMD_READ,
83        TGT_CMD_WRITE,
84        TGT_CMD_CAS,
85        TGT_CMD_ERROR,
86        TGT_CMD_CONFIG
87      };
88
89      /* States of the TGT_RSP fsm */
90      enum tgt_rsp_fsm_state_e
91      {
92        TGT_RSP_CONFIG_IDLE,
93        TGT_RSP_TGT_CMD_IDLE,
94        TGT_RSP_READ_IDLE,
95        TGT_RSP_WRITE_IDLE,
96        TGT_RSP_CAS_IDLE,
97        TGT_RSP_XRAM_IDLE,
98        TGT_RSP_MULTI_ACK_IDLE,
99        TGT_RSP_CLEANUP_IDLE,
100        TGT_RSP_CONFIG,
101        TGT_RSP_TGT_CMD,
102        TGT_RSP_READ,
103        TGT_RSP_WRITE,
104        TGT_RSP_CLEANUP,
105        TGT_RSP_CAS,
106        TGT_RSP_XRAM,
107        TGT_RSP_MULTI_ACK
108      };
109
110      /* States of the DSPIN_TGT fsm */
111      enum cc_receive_fsm_state_e
112      {
113        CC_RECEIVE_IDLE,
114        CC_RECEIVE_CLEANUP,
115        CC_RECEIVE_CLEANUP_EOP,
116        CC_RECEIVE_MULTI_ACK
117      };
118
119      /* States of the CC_SEND fsm */
120      enum cc_send_fsm_state_e
121      {
122        CC_SEND_CONFIG_IDLE,
123        CC_SEND_WRITE_IDLE,
124        CC_SEND_XRAM_RSP_IDLE,
125        CC_SEND_CAS_IDLE,
126        CC_SEND_READ_IDLE,
127        CC_SEND_CONFIG_INVAL_HEADER,
128        CC_SEND_CONFIG_INVAL_NLINE,
129        CC_SEND_CONFIG_BRDCAST_HEADER,
130        CC_SEND_CONFIG_BRDCAST_NLINE,
131        CC_SEND_XRAM_RSP_INVAL_HEADER,
132        CC_SEND_XRAM_RSP_INVAL_NLINE,
133        CC_SEND_XRAM_RSP_BRDCAST_HEADER,
134        CC_SEND_XRAM_RSP_BRDCAST_NLINE,
135        CC_SEND_READ_BRDCAST_HEADER,
136        CC_SEND_READ_BRDCAST_NLINE,
137        CC_SEND_READ_MULTI_HEADER,
138        CC_SEND_READ_MULTI_NLINE,
139        CC_SEND_WRITE_BRDCAST_HEADER,
140        CC_SEND_WRITE_BRDCAST_NLINE,
141        CC_SEND_WRITE_INVAL_HEADER,
142        CC_SEND_WRITE_INVAL_NLINE,
143        CC_SEND_CAS_BRDCAST_HEADER,
144        CC_SEND_CAS_BRDCAST_NLINE,
145        CC_SEND_CAS_INVAL_HEADER,
146        CC_SEND_CAS_INVAL_NLINE
147      };
148
149      /* States of the MULTI_ACK fsm */
150      enum multi_ack_fsm_state_e
151      {
152        MULTI_ACK_IDLE,
153        MULTI_ACK_GET_DATA,
154        MULTI_ACK_IVT_LOCK,
155        MULTI_ACK_IVT_CLEAR,
156        MULTI_ACK_DIR_REQ,
157        MULTI_ACK_DIR_LOCK,
158        MULTI_ACK_DIR_UPDT,
159        MULTI_ACK_RSP,
160        MULTI_ACK_HEAP_REQ,
161        MULTI_ACK_HEAP_LOCK,
162        MULTI_ACK_HEAP_WRITE,
163        MULTI_ACK_WAIT
164      };
165
166      /* States of the CONFIG fsm */
167      enum config_fsm_state_e
168      {
169        CONFIG_IDLE,
170        CONFIG_LOOP,
171        CONFIG_WAIT,
172        CONFIG_RSP,
173        CONFIG_DIR_REQ,
174        CONFIG_DIR_ACCESS,
175        CONFIG_IVT_LOCK,
176        CONFIG_BC_SEND,
177        CONFIG_INVAL_SEND,
178        CONFIG_HEAP_REQ,
179        CONFIG_HEAP_SCAN,
180        CONFIG_HEAP_LAST,
181        CONFIG_TRT_LOCK,
182        CONFIG_TRT_SET,
183        CONFIG_PUT_REQ
184      };
185
186      /* States of the READ fsm */
187      enum read_fsm_state_e
188      {
189        READ_IDLE,
190        READ_DIR_REQ,
191        READ_DIR_LOCK,
192        READ_IVT_INVAL_LOCK,
193        READ_INVAL_HEAP_REQ,
194        READ_INVAL_HEAP_ERASE,
195        READ_INVAL_HEAP_LAST,
196        READ_IVT_UPDT_LOCK,
197        READ_WAIT,
198        READ_DIR_HIT, 
199        READ_HEAP_REQ,
200        READ_HEAP_LOCK,
201        READ_HEAP_WRITE,
202        READ_HEAP_ERASE,
203        READ_HEAP_LAST,
204        READ_RSP,
205        READ_TRT_LOCK,
206        READ_TRT_SET,
207        READ_TRT_REQ
208      };
209
210      /* States of the WRITE fsm */
211      enum write_fsm_state_e
212      {
213        WRITE_IDLE,
214        WRITE_NEXT,
215        WRITE_DIR_REQ,
216        WRITE_DIR_LOCK,
217        WRITE_DIR_HIT,
218        WRITE_HEAP_REQ,
219        WRITE_HEAP_ERASE,
220        WRITE_HEAP_LAST,
221        WRITE_RSP,
222        WRITE_MISS_TRT_LOCK,
223        WRITE_WAIT,
224        WRITE_MISS_TRT_SET,
225        WRITE_MISS_TRT_DATA,
226        WRITE_MISS_XRAM_REQ,
227        WRITE_INVAL_TRT_LOCK,
228        WRITE_INVAL_IVT_LOCK,
229        WRITE_DIR_INVAL,
230        WRITE_INVAL_CC_SEND,
231        WRITE_INVAL_XRAM_REQ
232      };
233
234      /* States of the IXR_RSP fsm */
235      enum ixr_rsp_fsm_state_e
236      {
237        IXR_RSP_IDLE,
238        IXR_RSP_ACK,
239        IXR_RSP_TRT_ERASE,
240        IXR_RSP_TRT_READ
241      };
242
243      /* States of the XRAM_RSP fsm */
244      enum xram_rsp_fsm_state_e
245      {
246        XRAM_RSP_IDLE,
247        XRAM_RSP_TRT_COPY,
248        XRAM_RSP_TRT_DIRTY,
249        XRAM_RSP_DIR_LOCK,
250        XRAM_RSP_DIR_UPDT,
251        XRAM_RSP_DIR_RSP,
252        XRAM_RSP_IVT_LOCK,
253        XRAM_RSP_INVAL_WAIT,
254        XRAM_RSP_INVAL,
255        XRAM_RSP_WRITE_DIRTY,
256        XRAM_RSP_HEAP_REQ,
257        XRAM_RSP_HEAP_ERASE,
258        XRAM_RSP_HEAP_LAST,
259        XRAM_RSP_ERROR_ERASE,
260        XRAM_RSP_ERROR_RSP
261      };
262
263      /* States of the IXR_CMD fsm */
264      enum ixr_cmd_fsm_state_e
265      {
266        IXR_CMD_READ_IDLE,
267        IXR_CMD_WRITE_IDLE,
268        IXR_CMD_CAS_IDLE,
269        IXR_CMD_XRAM_IDLE,
270        IXR_CMD_CLEANUP_IDLE,
271        IXR_CMD_CONFIG_IDLE,
272        IXR_CMD_READ_TRT,
273        IXR_CMD_WRITE_TRT,
274        IXR_CMD_CAS_TRT,
275        IXR_CMD_XRAM_TRT,
276        IXR_CMD_CLEANUP_TRT,
277        IXR_CMD_CONFIG_TRT,
278        IXR_CMD_READ_SEND,
279        IXR_CMD_WRITE_SEND,
280        IXR_CMD_CAS_SEND,
281        IXR_CMD_XRAM_SEND,
282        IXR_CMD_CLEANUP_DATA_SEND,
283        IXR_CMD_CONFIG_SEND
284      };
285
286      /* States of the CAS fsm */
287      enum cas_fsm_state_e
288      {
289        CAS_IDLE,
290        CAS_DIR_REQ,
291        CAS_DIR_LOCK,
292        CAS_DIR_HIT_READ,
293        CAS_DIR_HIT_COMPARE,
294        CAS_DIR_HIT_WRITE,
295        CAS_MULTI_INVAL_IVT_LOCK,
296        CAS_WAIT,
297        CAS_MULTI_INVAL_HEAP_LOCK,
298        CAS_MULTI_INVAL_REQ,
299        CAS_HEAP_NEXT,
300        CAS_HEAP_LAST,
301        CAS_BC_TRT_LOCK,
302        CAS_BC_IVT_LOCK,
303        CAS_BC_DIR_INVAL,
304        CAS_BC_CC_SEND,
305        CAS_BC_XRAM_REQ,
306        CAS_RSP_FAIL,
307        CAS_RSP_SUCCESS,
308        CAS_MISS_TRT_LOCK,
309        CAS_MISS_TRT_SET,
310        CAS_MISS_XRAM_REQ
311      };
312
313      /* States of the CLEANUP fsm */
314      enum cleanup_fsm_state_e
315      {
316        CLEANUP_IDLE,
317        CLEANUP_GET_NLINE,
318        CLEANUP_GET_DATA,
319        CLEANUP_DIR_REQ,
320        CLEANUP_DIR_LOCK,
321        CLEANUP_DIR_WRITE,
322        CLEANUP_LOCKED_IVT_LOCK,
323        CLEANUP_LOCKED_IVT_DECREMENT,
324        CLEANUP_LOCKED_IVT_CLEAR,   
325        CLEANUP_LOCKED_RSP,
326        CLEANUP_HEAP_REQ,
327        CLEANUP_HEAP_LOCK,
328        CLEANUP_HEAP_SEARCH,
329        CLEANUP_HEAP_CLEAN,
330        CLEANUP_HEAP_FREE,
331        CLEANUP_MISS_IVT_LOCK,
332        CLEANUP_MISS_IVT_DECREMENT,
333        CLEANUP_MISS_IVT_CLEAR,
334        CLEANUP_MISS_RSP,
335        CLEANUP_MISS_IXR_REQ,
336        CLEANUP_WAIT,
337        CLEANUP_SEND_CLACK
338      };
339
340      /* States of the ALLOC_DIR fsm */
341      enum alloc_dir_fsm_state_e
342      {
343        ALLOC_DIR_RESET,
344        ALLOC_DIR_READ,
345        ALLOC_DIR_WRITE,
346        ALLOC_DIR_CAS,
347        ALLOC_DIR_CLEANUP,
348        ALLOC_DIR_XRAM_RSP,
349        ALLOC_DIR_MULTI_ACK,
350        ALLOC_DIR_CONFIG
351      };
352
353      /* States of the ALLOC_TRT fsm */
354      enum alloc_trt_fsm_state_e
355      {
356        ALLOC_TRT_READ,
357        ALLOC_TRT_WRITE,
358        ALLOC_TRT_CAS,
359        ALLOC_TRT_XRAM_RSP,
360        ALLOC_TRT_IXR_RSP,
361        ALLOC_TRT_CLEANUP,
362        ALLOC_TRT_IXR_CMD,
363        ALLOC_TRT_CONFIG
364      };
365
366//      /* States of the ALLOC_UPT fsm */
367//      enum alloc_upt_fsm_state_e
368//      {
369//        ALLOC_UPT_WRITE,
370//        ALLOC_UPT_CAS,
371//        ALLOC_UPT_MULTI_ACK
372//      };
373//
374      /* States of the ALLOC_IVT fsm */
375      enum alloc_ivt_fsm_state_e
376      {
377        ALLOC_IVT_WRITE,
378        ALLOC_IVT_READ,
379        ALLOC_IVT_XRAM_RSP,
380        ALLOC_IVT_CLEANUP,
381        ALLOC_IVT_CAS,
382        ALLOC_IVT_CONFIG,
383        ALLOC_IVT_MULTI_ACK
384      };
385
386      /* States of the ALLOC_HEAP fsm */
387      enum alloc_heap_fsm_state_e
388      {
389        ALLOC_HEAP_RESET,
390        ALLOC_HEAP_READ,
391        ALLOC_HEAP_WRITE,
392        ALLOC_HEAP_CAS,
393        ALLOC_HEAP_CLEANUP,
394        ALLOC_HEAP_MULTI_ACK,
395        ALLOC_HEAP_XRAM_RSP,
396        ALLOC_HEAP_CONFIG
397      };
398
399      /* transaction type, pktid field */
400      enum transaction_type_e
401      {
402          // b3 unused
403          // b2 READ / NOT READ
404          // Si READ
405          //  b1 DATA / INS
406          //  b0 UNC / MISS
407          // Si NOT READ
408          //  b1 accÚs table llsc type SW / other
409          //  b2 WRITE/CAS/LL/SC
410          TYPE_DATA_UNC               = 0x0,
411          TYPE_READ_DATA_MISS         = 0x1,
412          TYPE_READ_INS_UNC           = 0x2,
413          TYPE_READ_INS_MISS          = 0x3,
414          TYPE_WRITE                  = 0x4,
415          TYPE_CAS                    = 0x5,
416          TYPE_LL                     = 0x6,
417          TYPE_SC                     = 0x7
418      };
419
420      /* SC return values */
421      enum sc_status_type_e
422      {
423          SC_SUCCESS  =   0x00000000,
424          SC_FAIL     =   0x00000001
425      };
426
427      // debug variables
428      bool                 m_debug;
429      size_t               m_debug_previous_valid;
430      size_t               m_debug_previous_count;
431      bool                 m_debug_previous_dirty;
432      data_t *             m_debug_previous_data;
433      data_t *             m_debug_data;
434
435      // instrumentation counters
436      uint32_t     m_cpt_cycles;        // Counter of cycles
437
438      // Counters accessible in software (not yet but eventually)
439      uint32_t     m_cpt_reset_count;    // Last cycle at which counters have been reset
440      uint32_t     m_cpt_read_local;     // Number of local READ transactions
441      uint32_t     m_cpt_read_remote;    // number of remote READ transactions
442      uint32_t     m_cpt_read_cost;      // Number of (flits * distance) for READs
443
444      uint32_t     m_cpt_write_local;    // Number of local WRITE transactions
445      uint32_t     m_cpt_write_remote;   // number of remote WRITE transactions
446      uint32_t     m_cpt_write_flits_local;  // number of flits for local WRITEs
447      uint32_t     m_cpt_write_flits_remote; // number of flits for remote WRITEs
448      uint32_t     m_cpt_write_cost;     // Number of (flits * distance) for WRITEs
449
450      uint32_t     m_cpt_ll_local;       // Number of local LL transactions
451      uint32_t     m_cpt_ll_remote;      // number of remote LL transactions
452      uint32_t     m_cpt_ll_cost;        // Number of (flits * distance) for LLs
453
454      uint32_t     m_cpt_sc_local;       // Number of local SC transactions
455      uint32_t     m_cpt_sc_remote;      // number of remote SC transactions
456      uint32_t     m_cpt_sc_cost;        // Number of (flits * distance) for SCs
457
458      uint32_t     m_cpt_cas_local;      // Number of local SC transactions
459      uint32_t     m_cpt_cas_remote;     // number of remote SC transactions
460      uint32_t     m_cpt_cas_cost;       // Number of (flits * distance) for SCs
461
462      uint32_t     m_cpt_update;         // Number of requests causing an UPDATE
463      uint32_t     m_cpt_update_local;   // Number of local UPDATE transactions
464      uint32_t     m_cpt_update_remote;  // Number of remote UPDATE transactions
465      uint32_t     m_cpt_update_cost;    // Number of (flits * distance) for UPDT
466
467      uint32_t     m_cpt_minval;         // Number of requests causing M_INV
468      uint32_t     m_cpt_minval_local;   // Number of local M_INV transactions
469      uint32_t     m_cpt_minval_remote;  // Number of remote M_INV transactions
470      uint32_t     m_cpt_minval_cost;    // Number of (flits * distance) for M_INV
471
472      uint32_t     m_cpt_binval;         // Number of BROADCAST INVAL
473
474      uint32_t     m_cpt_cleanup_local;  // Number of local CLEANUP transactions
475      uint32_t     m_cpt_cleanup_remote; // Number of remote CLEANUP transactions
476      uint32_t     m_cpt_cleanup_cost;   // Number of (flits * distance) for CLEANUPs
477
478      // Counters not accessible by software
479      uint32_t     m_cpt_read_miss;      // Number of MISS READ
480      uint32_t     m_cpt_write_miss;    // Number of MISS WRITE
481      uint32_t     m_cpt_write_dirty;   // Cumulated length for WRITE transactions
482      uint32_t     m_cpt_write_broadcast;// Number of BROADCAST INVAL because write
483
484      uint32_t     m_cpt_trt_rb;        // Read blocked by a hit in trt
485      uint32_t     m_cpt_trt_full;      // Transaction blocked due to a full trt
486     
487      uint32_t     m_cpt_read_fsm_dir_lock;        // wait DIR LOCK
488      uint32_t     m_cpt_read_fsm_n_dir_lock;      // NB DIR LOCK
489      uint32_t     m_cpt_write_fsm_dir_lock;       // wait DIR LOCK
490      uint32_t     m_cpt_write_fsm_n_dir_lock;     // NB DIR LOCK
491      uint32_t     m_cpt_xram_rsp_fsm_dir_lock;    // wait DIR LOCK
492      uint32_t     m_cpt_xram_rsp_fsm_n_dir_lock;  // NB DIR LOCK
493      uint32_t     m_cpt_cas_fsm_dir_lock;         // wait DIR LOCK
494      uint32_t     m_cpt_cas_fsm_n_dir_lock;       // NB DIR LOCK
495      uint32_t     m_cpt_cleanup_fsm_dir_lock;     // wait DIR LOCK
496      uint32_t     m_cpt_cleanup_fsm_n_dir_lock;   // NB DIR LOCK
497     
498      uint32_t     m_cpt_dir_unused;            // NB cycles DIR LOCK unused
499      uint32_t     m_cpt_read_fsm_dir_used;     // NB cycles DIR LOCK used
500      uint32_t     m_cpt_write_fsm_dir_used;    // NB cycles DIR LOCK used
501      uint32_t     m_cpt_cas_fsm_dir_used;      // NB cycles DIR LOCK used
502      uint32_t     m_cpt_xram_rsp_fsm_dir_used; // NB cycles DIR LOCK used
503      uint32_t     m_cpt_cleanup_fsm_dir_used;  // NB cycles DIR LOCK used
504
505      uint32_t     m_cpt_read_fsm_trt_lock;      // wait TRT LOCK
506      uint32_t     m_cpt_write_fsm_trt_lock;     // wait TRT LOCK
507      uint32_t     m_cpt_cas_fsm_trt_lock;       // wait TRT LOCK
508      uint32_t     m_cpt_xram_rsp_fsm_trt_lock;  // wait TRT LOCK
509      uint32_t     m_cpt_ixr_fsm_trt_lock;       // wait TRT LOCK
510     
511      uint32_t     m_cpt_read_fsm_n_trt_lock;      // NB TRT LOCK
512      uint32_t     m_cpt_write_fsm_n_trt_lock;     // NB TRT LOCK
513      uint32_t     m_cpt_cas_fsm_n_trt_lock;       // NB TRT LOCK
514      uint32_t     m_cpt_xram_rsp_fsm_n_trt_lock;  // NB TRT LOCK
515      uint32_t     m_cpt_ixr_fsm_n_trt_lock;       // NB TRT LOCK
516
517      uint32_t     m_cpt_read_fsm_trt_used;      // NB cycles TRT LOCK used
518      uint32_t     m_cpt_write_fsm_trt_used;     // NB cycles TRT LOCK used
519      uint32_t     m_cpt_cas_fsm_trt_used;       // NB cycles TRT LOCK used
520      uint32_t     m_cpt_xram_rsp_fsm_trt_used;  // NB cycles TRT LOCK used
521      uint32_t     m_cpt_ixr_fsm_trt_used;       // NB cycles TRT LOCK used
522     
523      uint32_t     m_cpt_trt_unused;            // NB cycles TRT LOCK unused
524
525      uint32_t     m_cpt_write_fsm_upt_lock;     // wait UPT LOCK
526      uint32_t     m_cpt_xram_rsp_fsm_upt_lock;  // wait UPT LOCK
527      uint32_t     m_cpt_multi_ack_fsm_upt_lock; // wait UPT LOCK
528      uint32_t     m_cpt_cleanup_fsm_ivt_lock;   // wait UPT LOCK
529      uint32_t     m_cpt_cas_fsm_upt_lock;       // wait UPT LOCK
530     
531      uint32_t     m_cpt_write_fsm_n_upt_lock;     // NB UPT LOCK
532      uint32_t     m_cpt_xram_rsp_fsm_n_upt_lock;  // NB UPT LOCK
533      uint32_t     m_cpt_multi_ack_fsm_n_upt_lock; // NB UPT LOCK
534      uint32_t     m_cpt_cleanup_fsm_n_upt_lock;   // NB UPT LOCK
535      uint32_t     m_cpt_cas_fsm_n_upt_lock;       // NB UPT LOCK
536     
537      uint32_t     m_cpt_write_fsm_upt_used;     // NB cycles UPT LOCK used
538      uint32_t     m_cpt_xram_rsp_fsm_upt_used;  // NB cycles UPT LOCK used
539      uint32_t     m_cpt_multi_ack_fsm_upt_used; // NB cycles UPT LOCK used
540      uint32_t     m_cpt_cleanup_fsm_ivt_used;   // NB cycles UPT LOCK used
541      uint32_t     m_cpt_cas_fsm_upt_used;       // NB cycles UPT LOCK used
542     
543      uint32_t     m_cpt_ivt_unused;            // NB cycles UPT LOCK unused
544      uint32_t     m_cpt_upt_unused;            // NB cycles UPT LOCK unused
545
546      uint32_t     m_cpt_read_fsm_heap_lock;     // wait HEAP LOCK
547      uint32_t     m_cpt_write_fsm_heap_lock;    // wait HEAP LOCK
548      uint32_t     m_cpt_cas_fsm_heap_lock;      // wait HEAP LOCK
549      uint32_t     m_cpt_cleanup_fsm_heap_lock;  // wait HEAP LOCK
550      uint32_t     m_cpt_xram_rsp_fsm_heap_lock; // wait HEAP LOCK
551     
552      uint32_t     m_cpt_read_fsm_n_heap_lock;     // NB HEAP LOCK
553      uint32_t     m_cpt_write_fsm_n_heap_lock;    // NB HEAP LOCK
554      uint32_t     m_cpt_cas_fsm_n_heap_lock;      // NB HEAP LOCK
555      uint32_t     m_cpt_cleanup_fsm_n_heap_lock;  // NB HEAP LOCK
556      uint32_t     m_cpt_xram_rsp_fsm_n_heap_lock; // NB HEAP LOCK
557     
558      uint32_t     m_cpt_read_fsm_heap_used;     // NB cycles HEAP LOCK used
559      uint32_t     m_cpt_write_fsm_heap_used;    // NB cycles HEAP LOCK used
560      uint32_t     m_cpt_cas_fsm_heap_used;      // NB cycles HEAP LOCK used
561      uint32_t     m_cpt_cleanup_fsm_heap_used;  // NB cycles HEAP LOCK used
562      uint32_t     m_cpt_xram_rsp_fsm_heap_used; // NB cycles HEAP LOCK used
563     
564      uint32_t     m_cpt_heap_unused;            // NB cycles HEAP LOCK unused
565
566      //RWT
567      uint32_t     m_cpt_cleanup_data;   
568      uint32_t     m_cpt_ncc_to_cc_read;         // NB change from NCC to CC caused by a READ
569      uint32_t     m_cpt_ncc_to_cc_write;        // NB change from NCC to CC caused by a WRITE
570      uint32_t     m_cpt_ncc_to_cc;              // NB change from NCC to CC
571
572      uint32_t     m_cpt_read_data_unc;
573      uint32_t     m_cpt_read_data_miss_CC;
574      uint32_t     m_cpt_read_ins_unc;
575      uint32_t     m_cpt_read_ins_miss;
576      uint32_t     m_cpt_read_ll_CC;
577      uint32_t     m_cpt_read_data_miss_NCC;
578      uint32_t     m_cpt_read_ll_NCC;
579      uint32_t     m_cpt_read_WTF;
580
581      uint32_t     m_cpt_update_flits;  // Number of flits for UPDATEs
582      uint32_t     m_cpt_inval_cost;    // Number of (flits * distance) for INVALs
583
584      uint32_t     m_cpt_get;
585      uint32_t     m_cpt_put;
586
587      size_t       m_prev_count;
588
589      protected:
590
591      SC_HAS_PROCESS(VciMemCache);
592
593      public:
594      sc_in<bool>                                 p_clk;
595      sc_in<bool>                                 p_resetn;
596      sc_in<bool>                                 p_irq;
597      soclib::caba::VciTarget<vci_param_int>      p_vci_tgt;
598      soclib::caba::VciInitiator<vci_param_ext>   p_vci_ixr;
599      soclib::caba::DspinInput<dspin_in_width>    p_dspin_p2m;
600      soclib::caba::DspinOutput<dspin_out_width>  p_dspin_m2p;
601      soclib::caba::DspinOutput<dspin_out_width>  p_dspin_clack;
602
603#if MONITOR_MEMCACHE_FSM == 1
604      sc_out<int> p_read_fsm; 
605      sc_out<int> p_write_fsm; 
606      sc_out<int> p_xram_rsp_fsm; 
607      sc_out<int> p_cas_fsm; 
608      sc_out<int> p_cleanup_fsm; 
609      sc_out<int> p_config_fsm; 
610      sc_out<int> p_alloc_heap_fsm; 
611      sc_out<int> p_alloc_dir_fsm; 
612      sc_out<int> p_alloc_trt_fsm; 
613      sc_out<int> p_alloc_upt_fsm; 
614      sc_out<int> p_alloc_ivt_fsm; 
615      sc_out<int> p_tgt_cmd_fsm; 
616      sc_out<int> p_tgt_rsp_fsm; 
617      sc_out<int> p_ixr_cmd_fsm; 
618      sc_out<int> p_ixr_rsp_fsm; 
619      sc_out<int> p_cc_send_fsm; 
620      sc_out<int> p_cc_receive_fsm; 
621      sc_out<int> p_multi_ack_fsm; 
622#endif
623
624      VciMemCache(
625          sc_module_name name,                                // Instance Name
626          const soclib::common::MappingTable &mtp,            // Mapping table INT network
627          const soclib::common::MappingTable &mtx,            // Mapping table RAM network
628          const soclib::common::IntTab       &srcid_x,        // global index RAM network
629          const soclib::common::IntTab       &tgtid_d,        // global index INT network
630          const size_t                       cc_global_id,    // global index CC network
631          const size_t                       x_width,         // X width in platform
632          const size_t                       y_width,         // Y width in platform
633          const size_t                       nways,           // Number of ways per set
634          const size_t                       nsets,           // Number of sets
635          const size_t                       nwords,          // Number of words per line
636          const size_t                       max_copies,      // max number of copies
637          const size_t                       heap_size=HEAP_ENTRIES,
638          const size_t                       trt_lines=TRT_ENTRIES, 
639          const size_t                       upt_lines=UPT_ENTRIES,     
640          const size_t                       ivt_lines=IVT_ENTRIES,     
641          const size_t                       debug_start_cycle=0,
642          const bool                         debug_ok=false );
643
644      ~VciMemCache();
645
646      void reset_counters();
647      void print_stats(bool activity_counters, bool stats);
648      void print_trace( size_t detailled = 0 );
649      void cache_monitor(addr_t addr);
650      void start_monitor(addr_t addr, addr_t length);
651      void stop_monitor();
652
653      private:
654
655      void transition();
656      void genMoore();
657      void check_monitor(addr_t addr, data_t data, bool read);
658      uint32_t req_distance(uint32_t req_srcid);
659      bool is_local_req(uint32_t req_srcid);
660      int  read_instrumentation(uint32_t regr, uint32_t & rdata);
661
662      // Component attributes
663      std::list<soclib::common::Segment> m_seglist;          // segments allocated
664      size_t                             m_nseg;             // number of segments
665      soclib::common::Segment            **m_seg;            // array of segments pointers
666      size_t                             m_seg_config;       // config segment index
667      const size_t                       m_srcid_x;          // global index on RAM network
668      const size_t                       m_initiators;       // Number of initiators
669      const size_t                       m_heap_size;        // Size of the heap
670      const size_t                       m_ways;             // Number of ways in a set
671      const size_t                       m_sets;             // Number of cache sets
672      const size_t                       m_words;            // Number of words in a line
673      const size_t                       m_cc_global_id;     // global_index on cc network
674      const size_t                       m_xwidth;           // number of x bits in platform
675      const size_t                       m_ywidth;           // number of y bits in platform
676      size_t                             m_debug_start_cycle;
677      bool                               m_debug_ok;
678      uint32_t                           m_trt_lines;
679      TransactionTab                     m_trt;              // xram transaction table
680      uint32_t                           m_upt_lines;
681      UpdateTab                          m_upt;              // pending update
682      UpdateTab                          m_ivt;              // pending invalidate
683      CacheDirectory                     m_cache_directory;  // data cache directory
684      CacheData                          m_cache_data;       // data array[set][way][word]
685      HeapDirectory                      m_heap;             // heap for copies
686      size_t                             m_max_copies;       // max number of copies in heap
687      GenericLLSCGlobalTable
688      < 32  ,    // number of slots
689        4096,    // number of processors in the system
690        8000,    // registration life (# of LL operations)
691        addr_t >                         m_llsc_table;       // ll/sc registration table
692
693      // adress masks
694      const soclib::common::AddressMaskingTable<addr_t>   m_x;
695      const soclib::common::AddressMaskingTable<addr_t>   m_y;
696      const soclib::common::AddressMaskingTable<addr_t>   m_z;
697      const soclib::common::AddressMaskingTable<addr_t>   m_nline;
698
699      // broadcast address
700      uint32_t                           m_broadcast_boundaries;
701
702      // configuration interface constants
703      const uint32_t m_config_addr_mask;
704      const uint32_t m_config_regr_width;
705      const uint32_t m_config_func_width;
706      const uint32_t m_config_regr_idx_mask;
707      const uint32_t m_config_func_idx_mask;
708
709      // Fifo between TGT_CMD fsm and READ fsm
710      GenericFifo<addr_t>    m_cmd_read_addr_fifo;
711      GenericFifo<size_t>    m_cmd_read_length_fifo;
712      GenericFifo<size_t>    m_cmd_read_srcid_fifo;
713      GenericFifo<size_t>    m_cmd_read_trdid_fifo;
714      GenericFifo<size_t>    m_cmd_read_pktid_fifo;
715
716      // Fifo between TGT_CMD fsm and WRITE fsm
717      GenericFifo<addr_t>    m_cmd_write_addr_fifo;
718      GenericFifo<bool>      m_cmd_write_eop_fifo;
719      GenericFifo<size_t>    m_cmd_write_srcid_fifo;
720      GenericFifo<size_t>    m_cmd_write_trdid_fifo;
721      GenericFifo<size_t>    m_cmd_write_pktid_fifo;
722      GenericFifo<data_t>    m_cmd_write_data_fifo;
723      GenericFifo<be_t>      m_cmd_write_be_fifo;
724
725      // Fifo between TGT_CMD fsm and CAS fsm
726      GenericFifo<addr_t>    m_cmd_cas_addr_fifo;
727      GenericFifo<bool>      m_cmd_cas_eop_fifo;
728      GenericFifo<size_t>    m_cmd_cas_srcid_fifo;
729      GenericFifo<size_t>    m_cmd_cas_trdid_fifo;
730      GenericFifo<size_t>    m_cmd_cas_pktid_fifo;
731      GenericFifo<data_t>    m_cmd_cas_wdata_fifo;
732
733      // Fifo between CC_RECEIVE fsm and CLEANUP fsm
734      GenericFifo<uint64_t>  m_cc_receive_to_cleanup_fifo;
735     
736      // Fifo between CC_RECEIVE fsm and MULTI_ACK fsm
737      GenericFifo<uint64_t>  m_cc_receive_to_multi_ack_fifo;
738
739      // Buffer between TGT_CMD fsm and TGT_RSP fsm
740      // (segmentation violation response request)
741      sc_signal<bool>     r_tgt_cmd_to_tgt_rsp_req;
742
743      sc_signal<uint32_t> r_tgt_cmd_to_tgt_rsp_rdata;
744      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_error;
745      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_srcid;
746      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_trdid;
747      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_pktid;
748
749      sc_signal<addr_t>   r_tgt_cmd_config_addr;
750      sc_signal<size_t>   r_tgt_cmd_config_cmd;
751
752      //////////////////////////////////////////////////
753      // Registers controlled by the TGT_CMD fsm
754      //////////////////////////////////////////////////
755
756      sc_signal<int>         r_tgt_cmd_fsm;
757
758      ///////////////////////////////////////////////////////
759      // Registers controlled by the CONFIG fsm
760      ///////////////////////////////////////////////////////
761
762      sc_signal<int>      r_config_fsm;               // FSM state
763      sc_signal<bool>     r_config_lock;              // lock protecting exclusive access
764      sc_signal<int>      r_config_cmd;               // config request type 
765      sc_signal<addr_t>   r_config_address;           // target buffer physical address
766      sc_signal<size_t>   r_config_srcid;             // config request srcid
767      sc_signal<size_t>   r_config_trdid;             // config request trdid
768      sc_signal<size_t>   r_config_pktid;             // config request pktid
769      sc_signal<size_t>   r_config_cmd_lines;         // number of lines to be handled
770      sc_signal<size_t>   r_config_rsp_lines;         // number of lines not completed
771      sc_signal<size_t>   r_config_dir_way;           // DIR: selected way
772      sc_signal<bool>     r_config_dir_lock;          // DIR: locked entry
773      sc_signal<size_t>   r_config_dir_count;         // DIR: number of copies
774      sc_signal<bool>     r_config_dir_is_cnt;        // DIR: counter mode (broadcast)
775      sc_signal<size_t>   r_config_dir_copy_srcid;    // DIR: first copy SRCID
776      sc_signal<bool>     r_config_dir_copy_inst;     // DIR: first copy L1 type
777      sc_signal<size_t>   r_config_dir_ptr;           // DIR: index of next copy in HEAP
778      sc_signal<size_t>   r_config_dir_state;         // DIR: dir state
779      sc_signal<size_t>   r_config_heap_next;         // current pointer to scan HEAP
780      sc_signal<size_t>   r_config_trt_index;         // selected entry in TRT
781      sc_signal<size_t>   r_config_ivt_index;         // selected entry in IVT
782
783      // Buffer between CONFIG fsm and IXR_CMD fsm
784      sc_signal<bool>     r_config_to_ixr_cmd_req;    // valid request
785      sc_signal<size_t>   r_config_to_ixr_cmd_index;  // TRT index
786
787      // Buffer between CONFIG fsm and TGT_RSP fsm (send a done response to L1 cache)
788      sc_signal<bool>     r_config_to_tgt_rsp_req;    // valid request
789      sc_signal<bool>     r_config_to_tgt_rsp_error;  // error response
790      sc_signal<size_t>   r_config_to_tgt_rsp_srcid;  // Transaction srcid
791      sc_signal<size_t>   r_config_to_tgt_rsp_trdid;  // Transaction trdid
792      sc_signal<size_t>   r_config_to_tgt_rsp_pktid;  // Transaction pktid
793
794      // Buffer between CONFIG fsm and CC_SEND fsm (multi-inval / broadcast-inval)
795      sc_signal<bool>     r_config_to_cc_send_multi_req;    // multi-inval request
796      sc_signal<bool>     r_config_to_cc_send_brdcast_req;  // broadcast-inval request
797      sc_signal<addr_t>   r_config_to_cc_send_nline;        // line index
798      sc_signal<size_t>   r_config_to_cc_send_trdid;        // UPT index
799      GenericFifo<bool>   m_config_to_cc_send_inst_fifo;    // fifo for the L1 type
800      GenericFifo<size_t> m_config_to_cc_send_srcid_fifo;   // fifo for owners srcid
801
802      ///////////////////////////////////////////////////////
803      // Registers controlled by the READ fsm
804      ///////////////////////////////////////////////////////
805
806      sc_signal<int>      r_read_fsm;                 // FSM state
807      sc_signal<size_t>   r_read_copy;                // Srcid of the first copy
808      sc_signal<size_t>   r_read_copy_cache;          // Srcid of the first copy
809      sc_signal<bool>     r_read_copy_inst;           // Type of the first copy
810      sc_signal<tag_t>    r_read_tag;                 // cache line tag (in directory)
811      sc_signal<bool>     r_read_is_cnt;              // is_cnt bit (in directory)
812      sc_signal<bool>     r_read_lock;                // lock bit (in directory)
813      sc_signal<bool>     r_read_dirty;               // dirty bit (in directory)
814      sc_signal<size_t>   r_read_count;               // number of copies
815      sc_signal<size_t>   r_read_ptr;                 // pointer to the heap
816      sc_signal<data_t> * r_read_data;                // data (one cache line)
817      sc_signal<size_t>   r_read_way;                 // associative way (in cache)
818      sc_signal<size_t>   r_read_trt_index;           // Transaction Table index
819      sc_signal<size_t>   r_read_next_ptr;            // Next entry to point to
820      sc_signal<bool>     r_read_last_free;           // Last free entry
821      sc_signal<addr_t>   r_read_ll_key;              // LL key from llsc_global_table
822
823
824   
825      sc_signal<bool>     r_read_ll_done; 
826      sc_signal<bool>     r_read_need_block; 
827      sc_signal<size_t>   r_read_state; 
828      // Buffer between READ fsm and IXR_CMD fsm
829      sc_signal<bool>     r_read_to_ixr_cmd_req;      // valid request
830      sc_signal<size_t>   r_read_to_ixr_cmd_index;    // TRT index
831
832      // Buffer between READ fsm and TGT_RSP fsm (send a hit read response to L1 cache)
833      sc_signal<bool>     r_read_to_tgt_rsp_req;      // valid request
834      sc_signal<size_t>   r_read_to_tgt_rsp_srcid;    // Transaction srcid
835      sc_signal<size_t>   r_read_to_tgt_rsp_trdid;    // Transaction trdid
836      sc_signal<size_t>   r_read_to_tgt_rsp_pktid;    // Transaction pktid
837      sc_signal<data_t> * r_read_to_tgt_rsp_data;     // data (one cache line)
838      sc_signal<size_t>   r_read_to_tgt_rsp_word;     // first word of the response
839      sc_signal<size_t>   r_read_to_tgt_rsp_length;   // length of the response
840      sc_signal<addr_t>   r_read_to_tgt_rsp_ll_key;   // LL key from llsc_global_table
841
842      //RWT: Buffer between READ fsm and CC_SEND fsm (send inval)
843      sc_signal<bool>     r_read_to_cc_send_req;
844      sc_signal<size_t>   r_read_to_cc_send_dest;
845      sc_signal<addr_t>   r_read_to_cc_send_nline;
846      sc_signal<bool>     r_read_to_cc_send_inst;
847      sc_signal<size_t>   r_read_to_cc_send_srcid;
848      sc_signal<size_t>   r_read_to_cc_send_ivt_index;
849      sc_signal<bool>     r_read_to_cc_send_multi_req; // multi inval
850      sc_signal<bool>     r_read_to_cc_send_brdcast_req;    // bd inval
851      sc_signal<bool>     r_read_to_cc_send_type;    //cc inval or cc updt     
852      sc_signal<bool>     r_read_to_cc_send_is_shared;    //line is or not shared     
853
854      //RWT: Buffer between READ fsm and CLEANUP fsm (wait for the data coming from L1 cache)
855      sc_signal<bool>     r_read_to_cleanup_req;    // valid request
856      sc_signal<addr_t>   r_read_to_cleanup_nline;  // cache line index
857      sc_signal<size_t>   r_read_to_cleanup_srcid;
858      sc_signal<size_t>   r_read_to_cleanup_length;
859      sc_signal<size_t>   r_read_to_cleanup_first_word;
860      sc_signal<bool>     r_read_to_cleanup_cached_read;   
861      sc_signal<bool>     r_read_to_cleanup_is_ll;
862      sc_signal<addr_t>   r_read_to_cleanup_addr;
863      sc_signal<addr_t>   r_read_to_cleanup_ll_key;
864
865      sc_signal<bool>     r_read_to_multi_ack_req;    // valid request
866      sc_signal<addr_t>   r_read_to_multi_ack_nline;  // cache line index
867      sc_signal<size_t>   r_read_to_multi_ack_first_word;
868      sc_signal<bool>     r_read_to_multi_ack_length;   
869      sc_signal<addr_t>   r_read_to_multi_ack_ll_key;
870 
871
872      GenericFifo<bool>   m_read_to_cc_send_inst_fifo;    // fifo for the L1 type
873      GenericFifo<size_t> m_read_to_cc_send_srcid_fifo;   // fifo for owners srcid
874
875
876
877      sc_signal<bool>     r_multi_ack_need_data;    // cc_updt rsp with data
878      sc_signal<size_t>   r_multi_ack_data_index;   
879      sc_signal<size_t>   r_multi_ack_ivt_index;   
880      sc_signal<size_t>   r_multi_ack_set;   
881      sc_signal<size_t>   r_multi_ack_way;   
882      sc_signal<size_t>   r_multi_ack_count;   
883      sc_signal<bool>     r_multi_ack_rsp;   
884      sc_signal<bool>     r_multi_ack_rsp_shared;   
885
886      sc_signal<size_t>   r_multi_ack_copy;                // Srcid of the first copy
887      sc_signal<bool>     r_multi_ack_copy_inst;           // Type of the first copy
888      sc_signal<tag_t>    r_multi_ack_tag;                 // cache line tag (in directory)
889      sc_signal<bool>     r_multi_ack_lock;                // lock bit (in directory)
890      sc_signal<bool>     r_multi_ack_dirty;               // dirty bit (in directory)
891      sc_signal<data_t> * r_multi_ack_data;                // data (one cache line)
892      sc_signal<size_t>   r_multi_ack_to_tgt_rsp_word;     
893      sc_signal<size_t>   r_multi_ack_to_tgt_rsp_length;   
894      sc_signal<size_t>   r_multi_ack_to_tgt_ll_key;       
895
896      sc_signal<bool>     r_multi_ack_last_free; 
897      sc_signal<bool>     r_multi_ack_miss_updt; 
898      sc_signal<size_t>   r_multi_ack_next_ptr; 
899
900      sc_signal<bool>     r_read_shared;          // State of the cache slot after transaction
901
902
903      sc_signal<data_t> * r_debug_data;            // data (one cache line)
904      ///////////////////////////////////////////////////////////////
905      // Registers controlled by the WRITE fsm
906      ///////////////////////////////////////////////////////////////
907
908      sc_signal<int>      r_write_fsm;                // FSM state
909      sc_signal<size_t>   r_write_state; 
910      sc_signal<addr_t>   r_write_address;            // first word address
911      sc_signal<size_t>   r_write_word_index;         // first word index in line
912      sc_signal<size_t>   r_write_word_count;         // number of words in line
913      sc_signal<size_t>   r_write_srcid;              // transaction srcid
914      sc_signal<size_t>   r_write_trdid;              // transaction trdid
915      sc_signal<size_t>   r_write_pktid;              // transaction pktid
916      sc_signal<data_t> * r_write_data;               // data (one cache line)
917      sc_signal<be_t>   * r_write_be;                 // one byte enable per word
918      sc_signal<bool>     r_write_byte;               // (BE != 0X0) and (BE != 0xF)
919      sc_signal<bool>     r_write_is_cnt;             // is_cnt bit (in directory)
920      sc_signal<bool>     r_write_lock;               // lock bit (in directory)
921      sc_signal<tag_t>    r_write_tag;                // cache line tag (in directory)
922      sc_signal<size_t>   r_write_copy;               // first owner of the line
923      sc_signal<size_t>   r_write_copy_cache;         // first owner of the line
924      sc_signal<bool>     r_write_copy_inst;          // is this owner a ICache ?
925      sc_signal<size_t>   r_write_count;              // number of copies
926      sc_signal<size_t>   r_write_ptr;                // pointer to the heap
927      sc_signal<size_t>   r_write_next_ptr;           // next pointer to the heap
928      sc_signal<bool>     r_write_to_dec;             // need to decrement update counter
929      sc_signal<size_t>   r_write_way;                // way of the line
930      sc_signal<size_t>   r_write_trt_index;          // index in Transaction Table
931      sc_signal<size_t>   r_write_upt_index;          // index in Update Table
932      sc_signal<bool>     r_write_sc_fail;            // sc command failed
933      sc_signal<data_t>   r_write_sc_key;             // sc command key
934      sc_signal<bool>     r_write_bc_data_we;         // Write enable for data buffer
935      sc_signal<bool>     r_write_inval_trt_send;
936      sc_signal<bool>     r_write_data_we;
937 
938      // Buffer between WRITE fsm and TGT_RSP fsm (acknowledge a write command from L1)
939      sc_signal<bool>     r_write_to_tgt_rsp_req;     // valid request
940      sc_signal<size_t>   r_write_to_tgt_rsp_srcid;   // transaction srcid
941      sc_signal<size_t>   r_write_to_tgt_rsp_trdid;   // transaction trdid
942      sc_signal<size_t>   r_write_to_tgt_rsp_pktid;   // transaction pktid
943      sc_signal<bool>     r_write_to_tgt_rsp_sc_fail; // sc command failed
944
945      // Buffer between WRITE fsm and IXR_CMD fsm
946      sc_signal<bool>     r_write_to_ixr_cmd_req;     // valid request
947      sc_signal<size_t>   r_write_to_ixr_cmd_index;   // TRT index
948
949      // Buffer between WRITE fsm and CC_SEND fsm (Update/Invalidate L1 caches)
950      sc_signal<bool>     r_write_to_cc_send_multi_req;     // valid multicast request
951      sc_signal<bool>     r_write_to_cc_send_brdcast_req;   // valid brdcast request
952      sc_signal<addr_t>   r_write_to_cc_send_nline;         // cache line index
953      sc_signal<size_t>   r_write_to_cc_send_trdid;         // index in Update Table
954      sc_signal<data_t> * r_write_to_cleanup_data;          // data (one cache line)
955      sc_signal<be_t>   * r_write_to_cleanup_be;            // word enable
956      sc_signal<size_t>   r_write_to_cc_send_count;         // number of words in line
957      sc_signal<size_t>   r_write_to_cc_send_index;         // index of first word in line
958      GenericFifo<bool>   m_write_to_cc_send_inst_fifo;     // fifo for the L1 type
959      GenericFifo<size_t> m_write_to_cc_send_srcid_fifo;    // fifo for srcids
960
961      // Buffer between WRITE fsm and MULTI_ACK fsm (Decrement UPT entry)
962      sc_signal<bool>     r_write_to_multi_ack_req;       // valid request
963      sc_signal<size_t>   r_write_to_multi_ack_upt_index; // index in update table
964
965      // RWT: Buffer between WRITE fsm and CLEANUP fsm (change slot state)
966      sc_signal<bool>     r_write_to_cleanup_req;         // valid request
967      sc_signal<addr_t>   r_write_to_cleanup_nline;       // cache line index
968
969      // RWT
970      sc_signal<bool>     r_write_coherent;               // cache slot state after transaction
971
972      //Buffer between WRITE fsm and CC_SEND fsm (INVAL for RWT)
973      sc_signal<bool>     r_write_to_cc_send_req;
974      sc_signal<size_t>   r_write_to_cc_send_dest;
975
976
977      /////////////////////////////////////////////////////////
978      // Registers controlled by MULTI_ACK fsm
979      //////////////////////////////////////////////////////////
980
981      sc_signal<int>      r_multi_ack_fsm;       // FSM state
982      sc_signal<size_t>   r_multi_ack_upt_index; // index in the Update Table
983      sc_signal<size_t>   r_multi_ack_srcid;     // pending write srcid
984      sc_signal<size_t>   r_multi_ack_trdid;     // pending write trdid
985      sc_signal<size_t>   r_multi_ack_pktid;     // pending write pktid
986      sc_signal<addr_t>   r_multi_ack_nline;     // pending write nline
987
988      // Buffer between MULTI_ACK fsm and TGT_RSP fsm (complete write/update transaction)
989      sc_signal<bool>     r_multi_ack_to_tgt_rsp_req;   // valid request
990      sc_signal<size_t>   r_multi_ack_to_tgt_rsp_srcid; // Transaction srcid
991      sc_signal<size_t>   r_multi_ack_to_tgt_rsp_trdid; // Transaction trdid
992      sc_signal<size_t>   r_multi_ack_to_tgt_rsp_pktid; // Transaction pktid
993
994      ///////////////////////////////////////////////////////
995      // Registers controlled by CLEANUP fsm
996      ///////////////////////////////////////////////////////
997
998      sc_signal<int>      r_cleanup_fsm;           // FSM state
999      sc_signal<size_t>   r_cleanup_srcid;         // transaction srcid
1000      sc_signal<bool>     r_cleanup_inst;          // Instruction or Data ?
1001      sc_signal<size_t>   r_cleanup_way_index;     // L1 Cache Way index
1002      sc_signal<addr_t>   r_cleanup_nline;         // cache line index
1003
1004
1005      sc_signal<copy_t>   r_cleanup_copy;          // first copy
1006      sc_signal<copy_t>   r_cleanup_copy_cache;    // first copy
1007      sc_signal<size_t>   r_cleanup_copy_inst;     // type of the first copy
1008      sc_signal<copy_t>   r_cleanup_count;         // number of copies
1009      sc_signal<size_t>   r_cleanup_ptr;           // pointer to the heap
1010      sc_signal<size_t>   r_cleanup_prev_ptr;      // previous pointer to the heap
1011      sc_signal<size_t>   r_cleanup_prev_srcid;    // srcid of previous heap entry
1012      sc_signal<size_t>   r_cleanup_prev_cache_id; // srcid of previous heap entry
1013      sc_signal<bool>     r_cleanup_prev_inst;     // inst bit of previous heap entry
1014      sc_signal<size_t>   r_cleanup_next_ptr;      // next pointer to the heap
1015      sc_signal<tag_t>    r_cleanup_tag;           // cache line tag (in directory)
1016      sc_signal<bool>     r_cleanup_is_cnt;        // inst bit (in directory)
1017      sc_signal<bool>     r_cleanup_lock;          // lock bit (in directory)
1018      sc_signal<bool>     r_cleanup_dirty;         // dirty bit (in directory)
1019      sc_signal<size_t>   r_cleanup_way;           // associative way (in cache)
1020
1021      sc_signal<size_t>   r_cleanup_locked_srcid;   // srcid of write rsp
1022      sc_signal<size_t>   r_cleanup_locked_trdid;   // trdid of write rsp
1023      sc_signal<size_t>   r_cleanup_locked_pktid;   // pktid of write rsp
1024      sc_signal<size_t>   r_cleanup_locked_index;   // ivt index
1025      sc_signal<bool>     r_cleanup_locked_is_updt; 
1026
1027      sc_signal<size_t>   r_cleanup_miss_srcid;   // srcid of write rsp
1028      sc_signal<size_t>   r_cleanup_miss_trdid;   // trdid of write rsp
1029      sc_signal<size_t>   r_cleanup_miss_pktid;   // pktid of write rsp
1030      sc_signal<size_t>   r_cleanup_miss_index;   // ivt index
1031      sc_signal<bool>     r_cleanup_miss_is_updt; 
1032      sc_signal<bool>     r_cleanup_miss_need_rsp;      // write response required
1033      sc_signal<bool>     r_cleanup_miss_need_ack;      // config acknowledge required
1034
1035
1036      // Buffer between CLEANUP fsm and TGT_RSP fsm (acknowledge a write command from L1)
1037      sc_signal<bool>     r_cleanup_to_tgt_rsp_req;   // valid request
1038      sc_signal<size_t>   r_cleanup_to_tgt_rsp_srcid; // transaction srcid
1039      sc_signal<size_t>   r_cleanup_to_tgt_rsp_trdid; // transaction trdid
1040      sc_signal<size_t>   r_cleanup_to_tgt_rsp_pktid; // transaction pktid
1041      sc_signal<addr_t>   r_cleanup_to_tgt_rsp_ll_key;
1042      sc_signal<addr_t>   r_cleanup_to_tgt_rsp_nline;
1043
1044      sc_signal<bool>     r_cleanup_to_tgt_rsp_type;
1045      sc_signal<data_t> * r_cleanup_to_tgt_rsp_data;
1046      sc_signal<size_t>   r_cleanup_to_tgt_rsp_length;
1047      sc_signal<size_t>   r_cleanup_to_tgt_rsp_first_word;
1048
1049      sc_signal<data_t> * r_multi_ack_to_tgt_rsp_data;
1050      ///////////////////////////////////////////////////////
1051      // Registers controlled by CAS fsm
1052      ///////////////////////////////////////////////////////
1053
1054      sc_signal<int>      r_cas_fsm;              // FSM state
1055      sc_signal<data_t>   r_cas_wdata;            // write data word
1056      sc_signal<data_t> * r_cas_rdata;            // read data word
1057      sc_signal<uint32_t> r_cas_lfsr;             // lfsr for random introducing
1058      sc_signal<size_t>   r_cas_cpt;              // size of command
1059      sc_signal<copy_t>   r_cas_copy;             // Srcid of the first copy
1060      sc_signal<copy_t>   r_cas_copy_cache;       // Srcid of the first copy
1061      sc_signal<bool>     r_cas_copy_inst;        // Type of the first copy
1062      sc_signal<size_t>   r_cas_count;            // number of copies
1063      sc_signal<size_t>   r_cas_ptr;              // pointer to the heap
1064      sc_signal<size_t>   r_cas_next_ptr;         // next pointer to the heap
1065      sc_signal<bool>     r_cas_is_cnt;           // is_cnt bit (in directory)
1066      sc_signal<bool>     r_cas_dirty;            // dirty bit (in directory)
1067      sc_signal<size_t>   r_cas_way;              // way in directory
1068      sc_signal<size_t>   r_cas_set;              // set in directory
1069      sc_signal<data_t>   r_cas_tag;              // cache line tag (in directory)
1070      sc_signal<size_t>   r_cas_trt_index;        // Transaction Table index
1071      sc_signal<size_t>   r_cas_ivt_index;        // Update Table index
1072      sc_signal<data_t> * r_cas_data;             // cache line data
1073
1074      sc_signal<bool>     r_cas_coherent;
1075      sc_signal<size_t>   r_cas_state;
1076
1077      // Buffer between CAS fsm and IXR_CMD fsm (XRAM write)
1078      sc_signal<bool>     r_cas_to_ixr_cmd_req;   // valid request
1079      sc_signal<size_t>   r_cas_to_ixr_cmd_index; // TRT index
1080
1081      // Buffer between CAS fsm and TGT_RSP fsm
1082      sc_signal<bool>     r_cas_to_tgt_rsp_req;   // valid request
1083      sc_signal<data_t>   r_cas_to_tgt_rsp_data;  // read data word
1084      sc_signal<size_t>   r_cas_to_tgt_rsp_srcid; // Transaction srcid
1085      sc_signal<size_t>   r_cas_to_tgt_rsp_trdid; // Transaction trdid
1086      sc_signal<size_t>   r_cas_to_tgt_rsp_pktid; // Transaction pktid
1087
1088      // Buffer between CAS fsm and CC_SEND fsm (Update/Invalidate L1 caches)
1089      sc_signal<bool>     r_cas_to_cc_send_multi_req;     // valid request
1090      sc_signal<bool>     r_cas_to_cc_send_brdcast_req;   // brdcast request
1091      sc_signal<addr_t>   r_cas_to_cc_send_nline;         // cache line index
1092      sc_signal<size_t>   r_cas_to_cc_send_trdid;         // index in Update Table
1093      sc_signal<data_t>   r_cas_to_cc_send_wdata;         // data (one word)
1094      sc_signal<bool>     r_cas_to_cc_send_is_long;       // it is a 64 bits CAS
1095      sc_signal<data_t>   r_cas_to_cc_send_wdata_high;    // data high (one word)
1096      sc_signal<size_t>   r_cas_to_cc_send_index;         // index of the word in line
1097      GenericFifo<bool>   m_cas_to_cc_send_inst_fifo;     // fifo for the L1 type
1098      GenericFifo<size_t> m_cas_to_cc_send_srcid_fifo;    // fifo for srcids
1099
1100      sc_signal<bool>     r_cas_to_cleanup_req;   
1101      sc_signal<addr_t>   r_cas_to_cleanup_nline;   
1102      ////////////////////////////////////////////////////
1103      // Registers controlled by the IXR_RSP fsm
1104      ////////////////////////////////////////////////////
1105
1106      sc_signal<int>      r_ixr_rsp_fsm;                // FSM state
1107      sc_signal<size_t>   r_ixr_rsp_trt_index;          // TRT entry index
1108      sc_signal<size_t>   r_ixr_rsp_cpt;                // word counter
1109
1110      // Buffer between IXR_RSP fsm and CONFIG fsm  (response from the XRAM)
1111      sc_signal<bool>     r_ixr_rsp_to_config_ack;      // one single bit   
1112
1113      // Buffer between IXR_RSP fsm and XRAM_RSP fsm  (response from the XRAM)
1114      sc_signal<bool>   * r_ixr_rsp_to_xram_rsp_rok;    // one bit per TRT entry
1115
1116      ////////////////////////////////////////////////////
1117      // Registers controlled by the XRAM_RSP fsm
1118      ////////////////////////////////////////////////////
1119
1120      sc_signal<int>      r_xram_rsp_fsm;               // FSM state
1121      sc_signal<size_t>   r_xram_rsp_trt_index;         // TRT entry index
1122      TransactionTabEntry r_xram_rsp_trt_buf;           // TRT entry local buffer
1123      sc_signal<bool>     r_xram_rsp_victim_inval;      // victim line invalidate
1124      sc_signal<bool>     r_xram_rsp_victim_is_cnt;     // victim line inst bit
1125      sc_signal<bool>     r_xram_rsp_victim_dirty;      // victim line dirty bit
1126      sc_signal<size_t>   r_xram_rsp_victim_way;        // victim line way
1127      sc_signal<size_t>   r_xram_rsp_victim_set;        // victim line set
1128      sc_signal<addr_t>   r_xram_rsp_victim_nline;      // victim line index
1129      sc_signal<copy_t>   r_xram_rsp_victim_copy;       // victim line first copy
1130      sc_signal<copy_t>   r_xram_rsp_victim_copy_cache; // victim line first copy
1131      sc_signal<bool>     r_xram_rsp_victim_copy_inst;  // victim line type of first copy
1132      sc_signal<size_t>   r_xram_rsp_victim_count;      // victim line number of copies
1133      sc_signal<size_t>   r_xram_rsp_victim_ptr;        // victim line pointer to the heap
1134      sc_signal<data_t> * r_xram_rsp_victim_data;       // victim line data
1135      sc_signal<size_t>   r_xram_rsp_ivt_index;         // IVT entry index
1136      sc_signal<size_t>   r_xram_rsp_next_ptr;          // Next pointer to the heap
1137      sc_signal<size_t>   r_xram_rsp_victim_state; 
1138
1139      // Buffer between XRAM_RSP fsm and TGT_RSP fsm  (response to L1 cache)
1140      sc_signal<bool>     r_xram_rsp_to_tgt_rsp_req;    // Valid request
1141      sc_signal<size_t>   r_xram_rsp_to_tgt_rsp_srcid;  // Transaction srcid
1142      sc_signal<size_t>   r_xram_rsp_to_tgt_rsp_trdid;  // Transaction trdid
1143      sc_signal<size_t>   r_xram_rsp_to_tgt_rsp_pktid;  // Transaction pktid
1144      sc_signal<data_t> * r_xram_rsp_to_tgt_rsp_data;   // data (one cache line)
1145      sc_signal<size_t>   r_xram_rsp_to_tgt_rsp_word;   // first word index
1146      sc_signal<size_t>   r_xram_rsp_to_tgt_rsp_length; // length of the response
1147      sc_signal<bool>     r_xram_rsp_to_tgt_rsp_rerror; // send error to requester
1148      sc_signal<addr_t>   r_xram_rsp_to_tgt_rsp_ll_key; // LL key from llsc_global_table
1149
1150      // Buffer between XRAM_RSP fsm and CC_SEND fsm (Inval L1 Caches)
1151      sc_signal<bool>     r_xram_rsp_to_cc_send_multi_req;     // Valid request
1152      sc_signal<bool>     r_xram_rsp_to_cc_send_brdcast_req;   // Broadcast request
1153      sc_signal<addr_t>   r_xram_rsp_to_cc_send_nline;         // cache line index;
1154      sc_signal<size_t>   r_xram_rsp_to_cc_send_trdid;         // index of UPT entry
1155      GenericFifo<bool>   m_xram_rsp_to_cc_send_inst_fifo;     // fifo for the L1 type
1156      GenericFifo<size_t> m_xram_rsp_to_cc_send_srcid_fifo;    // fifo for srcids
1157
1158      // Buffer between XRAM_RSP fsm and IXR_CMD fsm
1159      sc_signal<bool>     r_xram_rsp_to_ixr_cmd_req;   // Valid request
1160      sc_signal<size_t>   r_xram_rsp_to_ixr_cmd_index; // TRT index
1161
1162      //RWT
1163      sc_signal<bool>     r_xram_rsp_victim_coherent;      // victim's cache slot state
1164      sc_signal<bool>     r_xram_rsp_coherent;             // coherence of the read
1165      ////////////////////////////////////////////////////
1166      // Registers controlled by the IXR_CMD fsm
1167      ////////////////////////////////////////////////////
1168
1169      sc_signal<int>      r_ixr_cmd_fsm;
1170      sc_signal<size_t>   r_ixr_cmd_word;              // word index for a put
1171      sc_signal<size_t>   r_ixr_cmd_trdid;             // TRT index value     
1172      sc_signal<addr_t>   r_ixr_cmd_address;           // address to XRAM
1173      sc_signal<data_t> * r_ixr_cmd_wdata;             // cache line buffer
1174      sc_signal<bool>     r_ixr_cmd_get;               // transaction type (PUT/GET)
1175
1176      ////////////////////////////////////////////////////
1177      // Registers controlled by TGT_RSP fsm
1178      ////////////////////////////////////////////////////
1179
1180      sc_signal<int>      r_tgt_rsp_fsm;
1181      sc_signal<size_t>   r_tgt_rsp_cpt;
1182      sc_signal<bool>     r_tgt_rsp_key_sent;
1183
1184      ////////////////////////////////////////////////////
1185      // Registers controlled by CC_SEND fsm
1186      ////////////////////////////////////////////////////
1187
1188      sc_signal<int>      r_cc_send_fsm;
1189      sc_signal<size_t>   r_cc_send_cpt;
1190      sc_signal<bool>     r_cc_send_inst;
1191
1192      ////////////////////////////////////////////////////
1193      // Registers controlled by CC_RECEIVE fsm
1194      ////////////////////////////////////////////////////
1195
1196      sc_signal<int>      r_cc_receive_fsm;
1197
1198      ////////////////////////////////////////////////////
1199      // Registers controlled by ALLOC_DIR fsm
1200      ////////////////////////////////////////////////////
1201
1202      sc_signal<int>      r_alloc_dir_fsm;
1203      sc_signal<unsigned> r_alloc_dir_reset_cpt;
1204
1205      ////////////////////////////////////////////////////
1206      // Registers controlled by ALLOC_TRT fsm
1207      ////////////////////////////////////////////////////
1208
1209      sc_signal<int>      r_alloc_trt_fsm;
1210
1211      ////////////////////////////////////////////////////
1212      // Registers controlled by ALLOC_UPT fsm
1213      ////////////////////////////////////////////////////
1214
1215  //    sc_signal<int>      r_alloc_upt_fsm;
1216
1217      ////////////////////////////////////////////////////
1218      // Registers controlled by ALLOC_IVT fsm
1219      ////////////////////////////////////////////////////
1220
1221      sc_signal<int>      r_alloc_ivt_fsm;
1222
1223      ////////////////////////////////////////////////////
1224      // Registers controlled by ALLOC_HEAP fsm
1225      ////////////////////////////////////////////////////
1226
1227      sc_signal<int>      r_alloc_heap_fsm;
1228      sc_signal<unsigned> r_alloc_heap_reset_cpt;
1229
1230
1231      ////////////////////////////////////////////////////
1232      // REGISTERS FOR ODCCP
1233      ////////////////////////////////////////////////////
1234
1235      sc_signal<uint32_t>  r_cleanup_data_index;
1236      sc_signal<uint32_t>  r_cleanup_trdid;
1237      sc_signal<uint32_t>  r_cleanup_state;
1238      sc_signal<uint32_t>  r_cleanup_pktid;
1239      sc_signal<bool>      r_cleanup_coherent;
1240      sc_signal<data_t>    *r_cleanup_data;
1241      sc_signal<data_t>    *r_cleanup_old_data;
1242      sc_signal<bool>      r_cleanup_contains_data;
1243     
1244      sc_signal<bool>      r_cleanup_ncc;
1245      sc_signal<bool>      r_cleanup_to_ixr_cmd_ncc_l1_dirty;
1246      sc_signal<bool>      r_xram_rsp_to_ixr_cmd_inval_ncc_pending;
1247     
1248      sc_signal<bool>      r_cleanup_to_ixr_cmd_req;
1249      sc_signal<data_t>    *r_cleanup_to_ixr_cmd_data;
1250      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_srcid;
1251      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_index;
1252      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_pktid;
1253      sc_signal<addr_t>    r_cleanup_to_ixr_cmd_nline;
1254    }; // end class VciMemCache
1255
1256}}
1257
1258#endif
1259
1260// Local Variables:
1261// tab-width: 2
1262// c-basic-offset: 2
1263// c-file-offsets:((innamespace . 0)(inline-open . 0))
1264// indent-tabs-mode: nil
1265// End:
1266
1267// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=2:softtabstop=2
1268
Note: See TracBrowser for help on using the repository browser.