Changeset 434 for trunk/modules


Ignore:
Timestamp:
Jul 12, 2013, 12:16:30 PM (11 years ago)
Author:
alain
Message:

Introducing a preliminary configuration interface in vci_mem_cache.

Location:
trunk/modules
Files:
6 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp

    r423 r434  
    52765276            break;
    52775277        }
    5278         ////////////////////
     5278        /////////////////
    52795279        case RSP_DATA_LL:
    52805280        {
     
    52855285                    r_vci_rsp_data_error = true;
    52865286                    r_vci_rsp_fsm = RSP_IDLE;
     5287                    break;
    52875288                }
    52885289                if (r_vci_rsp_cpt.read() == 0) //first flit
  • trunk/modules/vci_io_bridge/caba/metadata/vci_io_bridge.sd

    r240 r434  
    66Module('caba:vci_io_bridge',
    77        classname = 'soclib::caba::VciIoBridge',
    8         tmpl_parameters = [
    9         parameter.Module('vci_param_d', default = 'caba:vci_param',
    10                             cell_size   = parameter.Reference("cell_size_d"),
    11                             plen_size   = parameter.Reference("plen_size_d"),
    12                             addr_size   = parameter.Reference("addr_size_d"),
    13                             rerror_size = parameter.Reference("rerror_size_d"),
    14                             clen_size   = parameter.Reference("clen_size_d"), 
    15                             rflag_size  = parameter.Reference("rflag_size_d"),
    16                             srcid_size  = parameter.Reference("srcid_size_d"),
    17                             pktid_size  = parameter.Reference("pktid_size_d"),
    18                             trdid_size  = parameter.Reference("trdid_size_d"),
    19                             wrplen_size = parameter.Reference("wrplen_size_d")),
    20             parameter.Module('vci_param_x', default = 'caba:vci_param',
    21                             cell_size   = parameter.Reference("cell_size_x"),
    22                             plen_size   = parameter.Reference("plen_size_x"),
    23                             addr_size   = parameter.Reference("addr_size_x"),
    24                             rerror_size = parameter.Reference("rerror_size_x"),
    25                             clen_size   = parameter.Reference("clen_size_x"), 
    26                             rflag_size  = parameter.Reference("rflag_size_x"),
    27                             srcid_size  = parameter.Reference("srcid_size_x"),
    28                             pktid_size  = parameter.Reference("pktid_size_x"),
    29                             trdid_size  = parameter.Reference("trdid_size_x"),
    30                             wrplen_size = parameter.Reference("wrplen_size_x")),
    31         parameter.Module('vci_param_io', default = 'caba:vci_param',
    32                             cell_size   = parameter.Reference("cell_size_io"),
    33                             plen_size   = parameter.Reference("plen_size_io"),
    34                             addr_size   = parameter.Reference("addr_size_io"),
    35                             rerror_size = parameter.Reference("rerror_size_io"),
    36                             clen_size   = parameter.Reference("clen_size_io"), 
    37                             rflag_size  = parameter.Reference("rflag_size_io"),
    38                             srcid_size  = parameter.Reference("srcid_size_io"),
    39                             pktid_size  = parameter.Reference("pktid_size_io"),
    40                             trdid_size  = parameter.Reference("trdid_size_io"),
    41                             wrplen_size = parameter.Reference("wrplen_size_io")),
     8
     9        tmpl_parameters = [
     10        parameter.Module('vci_param_int',
     11                          default = 'caba:vci_param',
     12                          cell_size = parameter.Reference('iob_cell_size_int')),
     13            parameter.Module('vci_param_ext',
     14                          default = 'caba:vci_param',
     15                          cell_size = parameter.Reference('iob_cell_size_ext')),
    4216    ],
    43         header_files =         [ '../source/include/vci_io_bridge.h',
    44                                  '../source/include/transaction_tab_io.h'],
     17
     18        header_files =         [
     19        '../source/include/vci_io_bridge.h',
     20            '../source/include/transaction_tab_io.h'
     21    ],
     22
    4523        implementation_files = [ '../source/src/vci_io_bridge.cpp' ],
     24
    4625        uses = [ Uses('caba:base_module'),
    47                  Uses('common:mapping_table'),
    48                  Uses('caba:generic_fifo'),
    49                  Uses('caba:generic_tlb',
    50                        addr_t = parameter.StringExt('sc_dt::sc_uint<%d> ',
    51                        parameter.Reference('addr_size'))),
    52                  Uses('common:address_decoding_table',
    53                        input_t  = 'unsigned long',
    54                        output_t = 'bool'),
    55                  Uses('common:address_decoding_table',
    56                        input_t  = 'unsigned long',
    57                        output_t = 'int'),
    58 #                Uses('common:address_masking_table',
    59 #                       data_t = parameter.StringExt('sc_dt::sc_uint<%d> ',
    60 #                       parameter.Reference('addr_size'))),
    61            ],
    62         ports = [ Port('caba:vci_initiator', 'p_vci_ini_dma'),
    63                   Port('caba:vci_target', 'p_vci_tgt_dma'),
    64               Port('caba:vci_initiator', 'p_vci_ini_config'),
    65                   Port('caba:vci_target', 'p_vci_tgt_config'),
    66               Port('caba:vci_initiator', 'p_vci_ini_miss'),
    67                   Port('caba:bit_in','p_irq', parameter.Reference('nb_periph')),
     26            Uses('common:mapping_table'),
     27            Uses('caba:generic_fifo'),
     28            Uses('caba:generic_tlb',
     29              addr_t = parameter.StringExt('sc_dt::sc_uint<%d> ',
     30              parameter.Reference('addr_size'))),
     31            Uses('common:address_decoding_table',
     32              input_t  = 'unsigned long',
     33              output_t = 'bool'),
     34            Uses('common:address_decoding_table',
     35              input_t  = 'unsigned long',
     36              output_t = 'int'),
     37    ],
     38
     39        ports = [
     40              Port('caba:vci_initiator', 'p_vci_ini_ram'),
     41                  Port('caba:vci_target',    'p_vci_tgt_iox'),
     42              Port('caba:vci_initiator', 'p_vci_ini_iox'),
     43                  Port('caba:vci_target',    'p_vci_tgt_int'),
     44              Port('caba:vci_initiator', 'p_vci_ini_int'),
     45                  Port('caba:bit_in','p_irq', 32),
    6846                  Port('caba:bit_in', 'p_resetn', auto = 'resetn'),
    69                   Port('caba:clock_in', 'p_clk', auto = 'clock'), ],
    70         instance_parameters = [ parameter.Int('nd_periph'),
    71                                 parameter.Module('mtx', 'common:mapping_table'),
    72                                 parameter.Module('mtd', 'common:mapping_table'),
    73                                 parameter.Module('mtio', 'common:mapping_table'),
    74                                 parameter.Module('seg_config_iob', 'common:segment'),
    75                             parameter.IntTab('tgt_index_iocluster'),
    76 #                               parameter.IntTab('tgt_index_config'),
    77                                 parameter.IntTab('init_index_direct'),
    78                                 parameter.IntTab('tgt_index_iospace'),
    79                                 parameter.IntTab('init_index_iospace'),
    80                                 parameter.IntTab('init_index_dma'),
    81                                 parameter.Int('dcache_words'),
    82                                 parameter.Int('iotlb_ways'),
    83                                 parameter.Int('iotlb_sets'),
    84                                 parameter.Int('max_frozen_cycles'), ],
    85         extensions = [ 'dsx:get_ident='
    86                        'tgt_index_config:p_vci_tgt_config:mtd,'
    87                        'init_index_direct:p_vci_init_miss:mtd,'
    88                        'tgt_index_iospace:p_vci_tgt_dma:mtio,'
    89                        'init_index_iospace:p_vci_init_config:mtio,'
    90                        'init_index_dma:p_vci_ini_dma:mtx,'
    91                        'dsx:cpu=wrapper:iss_t',
    92                        'dsx:addressable=tgt_index_config,tgt_index_iospace',
    93 #                       'dsx:on_segment=mc:add_index:initiator_rw_index',
    94                        ],
     47                  Port('caba:clock_in', 'p_clk', auto = 'clock'),
     48    ],
    9549
    96 #       debug = True,
     50    instance_parameters = [
     51        parameter.Module('mt_ext', 'common:mapping_table'),
     52        parameter.Module('mt_int', 'common:mapping_table'),
     53        parameter.Module('mt_iox', 'common:mapping_table'),
     54        parameter.IntTab('int_tgtid'),
     55        parameter.IntTab('int_srcid'),
     56        parameter.IntTab('iox_tgtid'),
     57        parameter.IntTab('iox_srcid'),
     58        parameter.IntTab('ext_srcid'),
     59        parameter.Int('dcache_words'),
     60        parameter.Int('iotlb_ways'),
     61        parameter.Int('iotlb_sets'),
     62        parameter.Int('debug_start_cycle'),
     63        parameter.Bool('debug_ok'),
     64    ],
    9765)
    9866
  • trunk/modules/vci_io_bridge/caba/source/include/vci_io_bridge.h

    r405 r434  
    33 * Copyright (c) UPMC, Lip6, SoC
    44 * Date : 16/04/2012
     5 * Authors: Cassio Fraga, Alain Greiner
    56 *
    67 * SOCLIB_LGPL_HEADER_BEGIN
     
    2425 * SOCLIB_LGPL_HEADER_END
    2526 */
    26 
    27 //////Utilisation Considerations////////////////////////////////////////////////
     27/////////////////////////////////////////////////////////////////////////////////
     28// This TSAR component is a bridge to access external peripherals
     29// connected to an external I/O bus (such as Hypertransport or PCIe).
     30// AT the moment, the external I/O bus is modeled by a VCI VGMN component.
     31// It connects three VCI networks:
     32// - INT network : to receive both configuration requests from processors
     33//                 or software driven data access to peripherals.
     34// - RAM network : to send DMA transactions initiated by peripherals
     35//                 directly to the RAM (or L3 caches).
     36// - IOX network : to receive DMA transactions from peripherals, or to send
     37//                 configuration or data transactions to peripherals.
    2838//
    29 // - IOMMU PTPR pointer must fit in 32 bits (with a classical 2 level 4K page
    30 //   table in a 32 bit virtual space, it means a maximum of 45 bits in physical
    31 //   address)
     39// Regarding DMA transactions initiated by external peripherals, it provides
     40// an - optional - IOMMU service : the 32 bits virtual address is translated
     41// to a (up to) 40 bits physical address by a standard SoCLib generic TLB.
     42// In case of TLB MISS, the DMA is stalled until the TLB is updated.
     43// In case of page fault (illegal access), a VCI error is returned to the
     44// faulty peripheral.
     45/////////////////////////////////////////////////////////////////////////////////
     46//   General Constraints:
    3247//
    33 // - Physical address must fit in two 32 bit words
    34 //
    35 // - Maximal number of flits in a write transaction cannot be bigger than (n° of
    36 //   words in a chache line)/2
    37 //
    38 // - Page Tables must have the format used in TSAR (compatible with component
    39 //   generic_tlb)
    40 //
    41 // - IO's segment size must be the same in both networks
    42 //
     48// - All VCI fields have the same widths on the EXT and IOX networks.
     49// - Only the VCI DATA field can differ between INT and EXT networks,
     50//   and the width must be 32 or 64 bits.
     51// - The common VCI ADDRESS width cannot be larger than 64 bits.
     52// - All VCI transactions must be included in a single cache line.
     53// - Page Tables must have the format required by the SoCLib generic_tlb.
     54// - IO's segments must be the same in INT and IOX networks
    4355// - Write operations on IOMMU configuration registers (PTPR, ACTIVE) can only
    4456//   be done when DMA_TLB FSM is IDLE. It should, preferably, be done before
    4557//   starting any transfers. Pseudo register INVAL may be modified any time.
    46 //
    47 // - Similarly, write operations on the interruptions registers can only be done
    48 //   when the dedicated FSM is IDLE.               
    4958////////////////////////////////////////////////////////////////////////////////
    5059
    5160 
    5261///////TODO List///////////////////////////////////////////////////////////////
    53 //
    54 // Tableau de correspondance d'adresses physique - IO (pour CONFIG_CMD)
    55 //
    56 // Conversion 32 (entree) à 64 (sortie) bits (champ data). Dans les deux senses (CMD et RSP)
    57 //
    58 // Ne pas garder tous les champs WRITE CMD dans les FIFO a chaque flit
    59 // (seulement 'data' et 'be')
     62// - Ne pas garder tous les champs WRITE CMD dans les FIFO a chaque flit
     63//   (seulement 'data' et 'be')
     64// - Traiter complêtement les codes d'erreur en réponse à une transaction
     65//   WTI write
    6066///////////////////////////////////////////////////////////////////////////////
    6167
     
    7177#include "address_decoding_table.h"
    7278#include "static_assert.h"
    73 #include "transaction_tab_io.h"
    7479#include "vci_initiator.h"
    7580#include "vci_target.h"
     81#include "../../../include/soclib/io_bridge.h"
    7682
    7783namespace soclib {
     
    8086using namespace soclib::common;
    8187
    82 ////////////////////////////////////////////
    83 template<typename vci_param_d,typename vci_param_x, typename vci_param_io >
     88///////////////////////////////////////////////////////////////////////////////////
     89template<typename vci_param_int,
     90         typename vci_param_ext>
    8491class VciIoBridge
    85 ////////////////////////////////////////////
     92///////////////////////////////////////////////////////////////////////////////////
    8693    : public soclib::caba::BaseModule
    8794{
    88     typedef uint32_t tag_t;
    89     typedef uint32_t type_t;
    90    
    91     // Address field may change between direct, extenal and IO network
    92     typedef typename vci_param_d::addr_t        paddr_t;
    93     typedef typename vci_param_x::addr_t        paddr_t_x; // Just the cache line, for example
    94     typedef typename vci_param_io::addr_t       vaddr_t;
    95    
    96     // Data field may change for external network
    97     typedef typename vci_param_x::data_t      vci_data_t_x;
    98     typedef typename vci_param_x::be_t        vci_be_t_x;
    99     // Srcid field may change for external network
    100     typedef typename vci_param_x::srcid_t     vci_srcid_t_x;
    101    
    102     // Other fields must coincide   
    103     typedef typename vci_param_d::srcid_t     vci_srcid_t; 
    104     typedef typename vci_param_d::data_t      vci_data_t;   
    105     typedef typename vci_param_d::be_t        vci_be_t;
    106     typedef typename vci_param_d::trdid_t     vci_trdid_t;
    107     typedef typename vci_param_d::pktid_t     vci_pktid_t;
    108     typedef typename vci_param_d::plen_t      vci_plen_t;
    109     typedef typename vci_param_d::cmd_t       vci_cmd_t;
    110     typedef typename vci_param_d::contig_t    vci_contig_t;
    111     typedef typename vci_param_d::eop_t       vci_eop_t;
    112     typedef typename vci_param_d::const_t     vci_cons_t;
    113     typedef typename vci_param_d::wrap_t      vci_wrap_t;
    114     typedef typename vci_param_d::clen_t      vci_clen_t;
    115     typedef typename vci_param_d::cfixed_t    vci_cfixed_t;
    116 
    117     typedef typename vci_param_d::rerror_t    vci_rerror_t;
    118 
    119     enum {
    120         CACHE_LINE_MASK = 0xFFFFFFFFC0, 
    121         PPN1_MASK = 0x0007FFFF, 
    122         PPN2_MASK = 0x0FFFFFFF, 
     95    // Data field can have different widths on INT and EXT networks
     96    typedef typename vci_param_ext::fast_data_t     ext_data_t;
     97    typedef typename vci_param_int::fast_data_t     int_data_t;
     98
     99    // Other fields must be equal   
     100    typedef typename vci_param_int::fast_addr_t     vci_addr_t;
     101    typedef typename vci_param_int::srcid_t         vci_srcid_t; 
     102    typedef typename vci_param_int::be_t            vci_be_t;
     103    typedef typename vci_param_int::trdid_t         vci_trdid_t;
     104    typedef typename vci_param_int::pktid_t         vci_pktid_t;
     105    typedef typename vci_param_int::plen_t          vci_plen_t;
     106    typedef typename vci_param_int::cmd_t           vci_cmd_t;
     107    typedef typename vci_param_int::contig_t        vci_contig_t;
     108    typedef typename vci_param_int::eop_t           vci_eop_t;
     109    typedef typename vci_param_int::const_t         vci_cons_t;
     110    typedef typename vci_param_int::wrap_t          vci_wrap_t;
     111    typedef typename vci_param_int::clen_t          vci_clen_t;
     112    typedef typename vci_param_int::cfixed_t        vci_cfixed_t;
     113    typedef typename vci_param_int::rerror_t        vci_rerror_t;
     114
     115    enum
     116    {
     117        CACHE_LINE_MASK    = 0xFFFFFFFFC0LL, 
     118        PPN1_MASK          = 0x0007FFFF, 
     119        PPN2_MASK          = 0x0FFFFFFF, 
    123120        K_PAGE_OFFSET_MASK = 0x00000FFF, 
    124121        M_PAGE_OFFSET_MASK = 0x001FFFFF,
     
    127124    };
    128125 
    129     //DMA (from Peripherals to XRAM)
    130     enum dma_cmd_fsm_state { 
     126    // States for DMA_CMD FSM (from IOX to RAM)
     127    enum dma_cmd_fsm_state
     128    { 
    131129        DMA_CMD_IDLE,
    132         DMA_CMD_TRT_LOCK,
    133         DMA_CMD_TRT_WAIT,
    134         DMA_CMD_TRT_SET,
    135         DMA_CMD_FIFO_PUT,
    136         DMA_CMD_FIFO_MISS_PUT,
    137         DMA_CMD_TLB_MISS_WAIT,
    138         DMA_CMD_TLB_MISS_STORE,
    139         DMA_CMD_ERROR,
     130        DMA_CMD_FIFO_PUT_CMD,
     131        DMA_CMD_FIFO_PUT_RSP,
     132        DMA_CMD_MISS_WAIT,
     133        DMA_CMD_WAIT_EOP,
    140134    };
    141135   
    142     enum dma_rsp_fsm_state { 
     136    // States for DMA_RSP FSM (from RAM to IOX)
     137    enum dma_rsp_fsm_state
     138    { 
    143139        DMA_RSP_IDLE,
    144         DMA_RSP_TRT_LOCK,
    145140        DMA_RSP_FIFO_PUT,
    146         DMA_RSP_FIFO_ERROR_PUT,
    147141    };
    148142   
    149     // Allocates the transaction_tab_dma
    150     enum alloc_trt_dma_fsm_state {
    151         ALLOC_TRT_DMA_CMD,
    152         ALLOC_TRT_DMA_RSP
     143    // States for TLB_MISS FSM
     144    enum dma_tlb_fsm_state
     145    {   
     146        TLB_IDLE,
     147        TLB_MISS,
     148        TLB_PTE1_GET,
     149        TLB_PTE1_SELECT,
     150        TLB_PTE1_UPDT,
     151        TLB_PTE2_GET,                                                 
     152        TLB_PTE2_SELECT,
     153        TLB_PTE2_UPDT,
     154        TLB_WAIT,
     155        TLB_RETURN,
     156        TLB_INVAL_CHECK,
     157        };
     158   
     159    // States for CONFIG_CMD FSM (from INT to IOX)
     160    enum config_cmd_fsm_state
     161    { 
     162        CONFIG_CMD_IDLE,
     163        CONFIG_CMD_FIFO_PUT_CMD,
     164        CONFIG_CMD_FIFO_PUT_RSP,
     165        };
     166   
     167    // states for CONFIG_RSP FSM (from IOX to INT)
     168    enum config_rsp_fsm_state
     169    { 
     170        CONFIG_RSP_IDLE,
     171        CONFIG_RSP_FIFO_PUT,
    153172    };
    154      
    155 
    156     enum dma_tlb_fsm_state {   
    157         DMA_TLB_IDLE,
    158         DMA_TLB_MISS,
    159         DMA_TLB_PTE1_GET,
    160         DMA_TLB_PTE1_SELECT,
    161         DMA_TLB_PTE1_UPDT,
    162         DMA_TLB_PTE2_GET,                                                 
    163         DMA_TLB_PTE2_SELECT,
    164         DMA_TLB_PTE2_UPDT,
    165         DMA_TLB_WAIT_TRANSACTION,
    166         DMA_TLB_RETURN,
    167         // Treatment of CONFIG FSM request
    168         DMA_TLB_INVAL_CHECK,
    169         DMA_TLB_INVAL_SCAN
     173   
     174    // States for MISS_WTI_CMD FSM (to INT network)
     175    enum miss_wti_cmd_state
     176    { 
     177        MISS_WTI_CMD_IDLE,
     178        MISS_WTI_CMD_WTI,
     179        MISS_WTI_CMD_MISS,
    170180        };
    171181   
    172     //CONFIG (from Direct Network to Peripherals)
    173     enum config_cmd_fsm_state { 
    174         CONFIG_CMD_IDLE,
    175         CONFIG_CMD_TRT_LOCK,
    176         CONFIG_CMD_TRT_WAIT,
    177         CONFIG_CMD_TRT_SET,
    178         CONFIG_CMD_FIFO_PUT,
    179        
    180         // IOB private configuration segment
    181         CONFIG_CMD_PTPR_WRITE,
    182         CONFIG_CMD_PTPR_READ,
    183         CONFIG_CMD_ACTIVE_WRITE,
    184         CONFIG_CMD_ACTIVE_READ,
    185         CONFIG_CMD_BVAR_READ,
    186         CONFIG_CMD_ETR_READ,
    187         CONFIG_CMD_BAD_ID_READ,
    188         CONFIG_CMD_INVAL_REQ,
    189         CONFIG_CMD_INVAL,
    190         CONFIG_CMD_IT_ADDR_IOMMU_WRITE_1,
    191         CONFIG_CMD_IT_ADDR_IOMMU_WRITE_2,
    192         CONFIG_CMD_IT_ADDR_IOMMU_READ_1,
    193         CONFIG_CMD_IT_ADDR_IOMMU_READ_2,
    194         CONFIG_CMD_IT_ADDR_WRITE_1,
    195         CONFIG_CMD_IT_ADDR_WRITE_2,
    196         CONFIG_CMD_IT_ADDR_READ_1,
    197         CONFIG_CMD_IT_ADDR_READ_2,
    198         CONFIG_CMD_ERROR_WAIT,
    199         CONFIG_CMD_ERROR_RSP
     182    // States for MISS_WTI_RSP FSM (from INT network)
     183    enum miss_wti_rsp_state
     184    { 
     185        MISS_WTI_RSP_IDLE,
     186        MISS_WTI_RSP_WTI,
     187        MISS_WTI_RSP_MISS,
    200188        };
    201    
    202     enum config_rsp_fsm_state { 
    203         CONFIG_RSP_IDLE,
    204         CONFIG_RSP_TRT_LOCK,
    205         CONFIG_RSP_FIFO_PUT
     189
     190    // PKTID values for TLB MISS and WTI transactions
     191    enum pktid_values_e
     192    {
     193        PKTID_READ  = 0x0,  // TSAR code for read data uncached
     194        PKTID_WRITE = 0x4,  // TSAR code for write
    206195    };
    207    
    208     // Allocates the transaction_tab_dma
    209     enum alloc_trt_config_fsm_state {
    210         ALLOC_TRT_CONFIG_CMD,
    211         ALLOC_TRT_CONFIG_RSP
    212         };
    213    
    214     //MISS TRANSACTIONS (to Direct Network)
    215     enum miss_init_fsm_state { 
    216         MISS_INIT_IDLE_MISS,
    217         MISS_INIT_IDLE_IRQ,
    218         MISS_INIT_IRQ_CMD,
    219         MISS_INIT_IRQ_RSP,
    220         MISS_INIT_TLB_MISS_CMD,
    221         MISS_INIT_TLB_MISS_RSP
    222         };
    223    
    224     /////////////////////////////////////////////////////////////////
    225 
    226     // Configuration Error Type 
    227     enum config_error_type {
    228         READ_OK     = 0,
    229         READ_ERROR  = 1,
    230         WRITE_OK    = 2,
    231         WRITE_ERROR = 3
    232         };
    233  
     196   
    234197    // Miss types for iotlb
    235198    enum tlb_miss_type_e
    236199    {
    237200        PTE1_MISS,
    238         PTE2_MISS
     201        PTE2_MISS,
    239202        };
    240203   
    241     // IOB Configuration registers
    242     // Required segment size = (8 + 2*nb_periph) words
    243     enum {
    244         IOB_IOMMU_PTPR = 0,     // R/W  : Page Table Pointer Register
    245         IOB_IOMMU_ACTIVE = 1,   // R/W  : IOMMU activated if not 0
    246         IOB_IOMMU_BVAR = 2,     // R    : Bad Virtual Address
    247         IOB_IOMMU_ETR = 3,      // R    : Error type
    248         IOB_IOMMU_BAD_ID = 4,   // R    : Faulty peripheral Index
    249         IOB_INVAL_PTE = 5,      //   W  : Invalidate PTE. Virtual Address
    250         IOB_IT_ADDR_IOMMU_LO = 6,    // R/W
    251         IOB_IT_ADDR_IOMMU_HI = 7,    // R/W
    252         IOB_IT_ADDR_BEGIN = 8        // R/W : One register by IO
    253                                      // Addressed by two 32-bit words each
    254     };
    255 
    256    
    257     // Error Type
    258     enum mmu_error_type_e
    259     {
    260         MMU_NONE                      = 0x0000, // None
    261         MMU_WRITE_ACCES_VIOLATION     = 0x0008, // Write access of write access to a non writable page (bit W in flags)
    262         MMU_WRITE_PT1_ILLEGAL_ACCESS  = 0x0040, // Write access of Bus Error accessing Table 1       
    263         MMU_READ_PT1_UNMAPPED         = 0x1001, // Read access of Page fault on Page Table 1   
    264         MMU_READ_PT2_UNMAPPED         = 0x1002, // Read access of Page fault on Page Table 2 
    265         MMU_READ_PT1_ILLEGAL_ACCESS   = 0x1040, // Read access of Bus Error in Table1 access     
    266         MMU_READ_PT2_ILLEGAL_ACCESS   = 0x1080, // Read access of Bus Error in Table2 access   
    267         MMU_READ_DATA_ILLEGAL_ACCESS  = 0x1100, // Read access of Bus Error in cache access
    268     };
    269    
    270 
    271204public:
    272     sc_in<bool>                             p_clk;
    273     sc_in<bool>                             p_resetn;
    274     sc_in<bool>                             *p_irq_in;     
    275    
    276     soclib::caba::VciInitiator<vci_param_x>     p_vci_ini_dma; // XRAM Noc
    277     soclib::caba::VciTarget<vci_param_io>       p_vci_tgt_dma;
    278    
    279     soclib::caba::VciInitiator<vci_param_io>    p_vci_ini_config;
    280     soclib::caba::VciTarget<vci_param_d>        p_vci_tgt_config;
    281    
    282     soclib::caba::VciInitiator<vci_param_d>     p_vci_ini_miss;
     205    sc_in<bool>                               p_clk;
     206    sc_in<bool>                               p_resetn;
     207    sc_in<bool>*                              p_irq[32];     // not always constructed
     208   
     209    soclib::caba::VciInitiator<vci_param_ext> p_vci_ini_ram;
     210
     211    soclib::caba::VciTarget<vci_param_ext>    p_vci_tgt_iox;
     212    soclib::caba::VciInitiator<vci_param_ext> p_vci_ini_iox;
     213
     214    soclib::caba::VciTarget<vci_param_int>    p_vci_tgt_int;
     215    soclib::caba::VciInitiator<vci_param_int> p_vci_ini_int;
    283216
    284217private:
    285     const size_t        m_words;
    286     const size_t    m_nb_periph;
    287 
    288     // STRUCTURAL PARAMETERS
    289     // soclib::common::AddressDecodingTable<unsigned long, bool>   m_locality_table_config;
    290     // soclib::common::AddressDecodingTable<unsigned long, int>    m_routing_table_config;
    291     //const soclib::common::MappingTable&                   m_mtio;
    292    
    293     uint32_t                                    m_transaction_tab_dma_lines;
    294     TransactionTabIO                            m_transaction_tab_dma;  // dma transaction table
    295    
    296     uint32_t                                    m_transaction_tab_config_lines;
    297     TransactionTabIO                            m_transaction_tab_config;       // config transaction table
    298    
    299     // Direct Network
    300     const soclib::common::Segment                               m_segment_config;
    301     const vci_srcid_t                                           m_srcid_miss;
    302     // XRAM Network
    303     const vci_srcid_t_x                                         m_srcid_dma;
    304     // IO Network
    305     const soclib::common::Segment                               m_segment_io;
    306     const vci_srcid_t                                           m_srcid_config;
    307 
    308     const size_t                                                m_iotlb_ways;
    309     const size_t                                                m_iotlb_sets;
    310     const size_t                                                m_paddr_nbits; 
    311 
    312 
    313     /////////////////////////////////////////////
    314     // debug variables (for each FSM)
    315     /////////////////////////////////////////////
    316     uint32_t                            m_debug_start_cycle;
    317     bool                                m_debug_ok;
    318    
    319     bool                                m_debug_dma_cmd_fsm;
    320     bool                                m_debug_dma_rsp_fsm;
    321     bool                                m_debug_dma_tlb_fsm;
    322     bool                                m_debug_config_cmd_fsm;
    323     bool                                m_debug_config_rsp_fsm;
    324     bool                                m_debug_miss_init_fsm;
     218    const size_t                                  m_words;
     219    const bool                                m_has_irqs;
     220
     221    // INT & IOX Networks
     222    std::list<soclib::common::Segment>        m_int_seglist;
     223    const vci_srcid_t                             m_int_srcid;  // local SRCID on INT network
     224    std::list<soclib::common::Segment>        m_iox_seglist;
     225
     226    // TLB parameters
     227    const size_t                                                  m_iotlb_ways;
     228    const size_t                                                  m_iotlb_sets;
     229
     230    // debug variables
     231    uint32_t                                  m_debug_start_cycle;
     232    bool                                      m_debug_ok;
     233    bool                                      m_debug_activated;
    325234
    326235    ///////////////////////////////
    327236    // MEMORY MAPPED REGISTERS
    328237    ///////////////////////////////
    329     sc_signal<uint32_t>     r_iommu_ptpr;       // page table pointer register
    330     sc_signal<bool>         r_iommu_active;         // iotlb mode
    331     sc_signal<uint32_t>     r_iommu_bvar;       // iommu bad address
    332     sc_signal<uint32_t>     r_iommu_etr;        // iommu error type
    333     sc_signal<uint32_t>     r_iommu_bad_id;     // ID of the peripheral that tried bad operation
    334    
    335     sc_signal<paddr_t>     r_it_addr_iommu;        // iommu error type
    336     paddr_t                *r_it_addr;        // iommu error type
     238    sc_signal<uint32_t>         r_iommu_ptpr;           // page table pointer register
     239    sc_signal<bool>             r_iommu_active;         // iotlb mode
     240    sc_signal<uint32_t>         r_iommu_bvar;           // iommu bad virtual address
     241    sc_signal<uint32_t>         r_iommu_etr;            // iommu error type
     242    sc_signal<uint32_t>         r_iommu_bad_id;         // SRCID of faulty peripheral
     243    sc_signal<uint32_t>         r_iommu_wti_enable;     // enable WTI transactions when true
     244    sc_signal<vci_addr_t>       r_iommu_wti_paddr;      // address of IOMMU WTI
     245    sc_signal<vci_addr_t>*      r_iommu_peri_wti;       // array[32] WTI for peripherals
    337246 
    338247        ///////////////////////////////////
    339248    // DMA_CMD FSM REGISTERS
    340249    ///////////////////////////////////
    341     sc_signal<int>          r_dma_cmd_fsm;                              // state register
    342     sc_signal<int>          r_dma_cmd_fsm_save; //saves current state when miss interruption happens
    343     sc_signal<bool>         r_miss_interrupt;
    344    
    345     sc_signal<int>          r_dma_cmd_count;
    346     sc_signal<vci_trdid_t>  r_dma_cmd_trt_index;
    347     sc_signal<paddr_t>      r_dma_paddr;
    348    
    349     GenericFifo<paddr_t>        m_dma_cmd_addr_fifo;
    350     //GenericFifo<size_t>       m_dma_cmd_length_fifo;
     250    sc_signal<int>              r_dma_cmd_fsm;         
     251    sc_signal<uint32_t>         r_dma_cmd_vaddr;        // input virtual address
     252    sc_signal<vci_addr_t>       r_dma_cmd_paddr;        // output physical address
     253
     254    ///////////////////////////////////
     255    // DMA_RSP FSM REGISTERS
     256    ///////////////////////////////////
     257    sc_signal<int>              r_dma_rsp_fsm;
     258   
     259    ///////////////////////////////////
     260    // CONFIG_CMD FSM REGISTERS
     261    ///////////////////////////////////
     262    sc_signal<int>              r_config_cmd_fsm;
     263    sc_signal<uint32_t>         r_config_cmd_rdata;
     264    sc_signal<bool>             r_config_cmd_error;
     265    sc_signal<uint32_t>         r_config_cmd_inval_vaddr;
     266   
     267    ///////////////////////////////////
     268    // CONFIG_RSP FSM REGISTERS
     269    ///////////////////////////////////
     270    sc_signal<int>              r_config_rsp_fsm;
     271
     272    ///////////////////////////////////
     273    // TLB FSM REGISTERS
     274    ///////////////////////////////////
     275    sc_signal<int>              r_tlb_fsm;                      // state register
     276    sc_signal<bool>             r_waiting_transaction;  // Flag for returning from
     277    sc_signal<int>              r_tlb_miss_type;
     278        sc_signal<bool>             r_tlb_miss_error;
     279
     280    sc_signal<vci_addr_t>       r_tlb_paddr;                // physical address of pte
     281    sc_signal<uint32_t>         r_tlb_pte_flags;            // pte1 or first word of pte2
     282    sc_signal<uint32_t>         r_tlb_pte_ppn;          // second word of pte2
     283    sc_signal<size_t>           r_tlb_way;                      // selected way in tlb   
     284    sc_signal<size_t>           r_tlb_set;                      // selected set in tlb   
     285
     286    uint32_t*                   r_tlb_buf_data;         // prefetch buffer for PTEs
     287    sc_signal<bool>             r_tlb_buf_valid;        // one valit flag for all PTEs
     288    sc_signal<vci_addr_t>       r_tlb_buf_tag;          // cache line number 
     289    sc_signal<vci_addr_t>       r_tlb_buf_vaddr;        // virtual address first PTE 
     290    sc_signal<bool>             r_tlb_buf_big_page;     // ???
     291
     292    ///////////////////////////////////
     293    // MISS_WTI_CMD FSM REGISTERS
     294    ///////////////////////////////////
     295    sc_signal<int>              r_miss_wti_cmd_fsm;
     296    sc_signal<size_t>           r_miss_wti_cmd_index;
     297
     298    ///////////////////////////////////
     299    // MISS_WTI_RSP FSM REGISTERS
     300    ///////////////////////////////////
     301    sc_signal<int>              r_miss_wti_rsp_fsm;
     302    sc_signal<bool>             r_miss_wti_rsp_error;
     303    sc_signal<size_t>           r_miss_wti_rsp_count;
     304   
     305    /////////////////////////////////////////////////////
     306    //  ALLOCATORS for CONFIG_RSP fifo & DMA_RSP fifo
     307    /////////////////////////////////////////////////////
     308    sc_signal<bool>             r_alloc_fifo_config_rsp_local; 
     309    sc_signal<bool>             r_alloc_fifo_dma_rsp_local; 
     310
     311    //////////////////////////////////
     312    // IRQ FSM registers
     313    //////////////////////////////////
     314        sc_signal<bool>*            r_irq_pending;  // array[32]
     315        sc_signal<bool>*            r_irq_request;  // array[32]
     316   
     317    //////////////////////////////////////////////////////////////////
     318    // IOTLB 
     319    //////////////////////////////////////////////////////////////////
     320    GenericTlb<vci_addr_t>      r_iotlb;
     321       
     322    //////////////////////////////////////////////////////////////////
     323    // Inter-FSM communications
     324    //////////////////////////////////////////////////////////////////
     325   
     326    // between DMA_CMD and TLB FSM
     327    sc_signal<bool>             r_dma_tlb_req;
     328
     329    // between CONFIG_CMD FSM and TLB FSM
     330    sc_signal<bool>             r_config_tlb_req;
     331   
     332    // between TLB FSM and MISS_WTI FSM
     333    sc_signal<bool>             r_tlb_miss_req;
     334   
     335    /////////////////////////
     336    // FIFOs
     337    /////////////////////////
     338
     339    // ouput FIFO to VCI INI port on RAM network (VCI command)
     340    GenericFifo<vci_addr_t>     m_dma_cmd_addr_fifo;
    351341    GenericFifo<vci_srcid_t>    m_dma_cmd_srcid_fifo;
    352342    GenericFifo<vci_trdid_t>    m_dma_cmd_trdid_fifo;
     
    355345    GenericFifo<vci_cmd_t>      m_dma_cmd_cmd_fifo;
    356346    GenericFifo<vci_contig_t>   m_dma_cmd_contig_fifo;
    357     GenericFifo<vci_data_t>     m_dma_cmd_data_fifo;
     347    GenericFifo<ext_data_t>     m_dma_cmd_data_fifo;
    358348    GenericFifo<vci_eop_t>      m_dma_cmd_eop_fifo;
    359349    GenericFifo<vci_cons_t>     m_dma_cmd_cons_fifo;
     
    363353    GenericFifo<vci_clen_t>     m_dma_cmd_clen_fifo;
    364354
    365     // Command storage registers (in case of miss tlb)
    366     sc_signal<paddr_t>              r_miss_paddr;
    367     sc_signal<vci_cmd_t>            r_miss_cmd ;
    368     sc_signal<vci_contig_t>         r_miss_contig;
    369     sc_signal<vci_cons_t>           r_miss_cons ;
    370     sc_signal<vci_plen_t>           r_miss_plen ;
    371     sc_signal<vci_wrap_t>           r_miss_wrap ;
    372     sc_signal<vci_cfixed_t>         r_miss_cfixed;
    373     sc_signal<vci_clen_t>           r_miss_clen ;
    374     sc_signal<vci_srcid_t>          r_miss_srcid ;
    375     sc_signal<vci_trdid_t>          r_miss_trdid ;
    376     sc_signal<vci_pktid_t>          r_miss_pktid ;
    377     vci_data_t_x                    *r_miss_data ; 
    378     vci_be_t                        *r_miss_be;
    379    
    380     // Error registers
    381     sc_signal<int>          r_dma_error_type;   
    382     sc_signal<vci_trdid_t>  r_dma_error_trdid; 
    383     sc_signal<vci_pktid_t>  r_dma_error_pktid; 
    384    
    385     ///////////////////////////////////
    386     // DMA_TLB FSM REGISTERS
    387     ///////////////////////////////////
    388     sc_signal<int>          r_dma_tlb_fsm;                  // state register
    389     sc_signal<bool>         r_waiting_transaction;  // Flag for returning from
    390                                                     // invalidation interruptions
    391     sc_signal<int>          r_tlb_miss_type;
    392 
    393     sc_signal<vaddr_t>      r_iotlb_vaddr;              // virtual address for a tlb miss
    394     sc_signal<paddr_t>      r_iotlb_paddr;                  // physical address of pte
    395     sc_signal<uint32_t>     r_iotlb_pte_flags;      // pte1 or first word of pte2
    396     sc_signal<uint32_t>     r_iotlb_pte_ppn;        // second word of pte2
    397     sc_signal<size_t>       r_iotlb_way;                    // selected way in tlb   
    398     sc_signal<size_t>       r_iotlb_set;                    // selected set in tlb   
    399    
    400     //////////////////////////////////////////////////////////////////
    401     // IOTLB 
    402     //////////////////////////////////////////////////////////////////
    403     GenericTlb<paddr_t>         r_iotlb;
    404        
    405     ///////////////////////////////////
    406     // DMA_RSP FSM REGISTERS
    407     ///////////////////////////////////
    408     sc_signal<int>          r_dma_rsp_fsm;
    409 
    410         sc_signal<vci_trdid_t>  r_dma_rtrdid;
    411         sc_signal<vci_srcid_t>  r_dma_rsrcid;   
    412    
    413     GenericFifo<vci_data_t>     m_dma_rsp_data_fifo;
     355    // output FIFO to VCI TGT port on IOX network (VCI response)
     356    GenericFifo<ext_data_t>     m_dma_rsp_data_fifo;
    414357    GenericFifo<vci_srcid_t>    m_dma_rsp_rsrcid_fifo;
    415358    GenericFifo<vci_trdid_t>    m_dma_rsp_rtrdid_fifo;
     
    418361    GenericFifo<vci_rerror_t>   m_dma_rsp_rerror_fifo;
    419362       
    420     //Communication between DMA_CMD and DMA_RSP
    421     sc_signal<bool>     r_dma_cmd_rsp_erase_req;
    422         sc_signal<bool>     r_dma_cmd_error_req;
    423     //Communication between DMA_CMD and TLB
    424     sc_signal<bool>     r_dma_tlb_req;
    425     sc_signal<bool>     r_tlb_dma_untreated;
    426         sc_signal<bool>     r_dma_tlb_error_req;
    427     sc_signal<int>      r_tlb_error_type;   
    428     //Communication betweeen TLB and CONFIG_CMD
    429     sc_signal<bool>         r_config_tlb_req;
    430     sc_signal<vaddr_t>      r_config_tlb_inval_vaddr;
    431    
    432     ///////////////////////////////////
    433     // ALLOC_TRT_DMA FSM REGISTERS
    434     ///////////////////////////////////
    435     sc_signal<int>          r_alloc_trt_dma_fsm;                        // state register
    436 
    437 
    438     ///////////////////////////////////
    439     // CONFIG_CMD FSM REGISTERS
    440     ///////////////////////////////////
    441     sc_signal<int>          r_config_cmd_fsm;                   // state register
    442    
    443     sc_signal<vci_trdid_t>       r_config_cmd_trt_index;
    444    
    445     GenericFifo<paddr_t>        m_config_cmd_addr_fifo;
    446     //GenericFifo<size_t>       m_config_cmd_length_fifo;
     363    // output FIFO to VCI INI port on IOX network (VCI command)
     364    GenericFifo<vci_addr_t>     m_config_cmd_addr_fifo;
    447365    GenericFifo<vci_srcid_t>    m_config_cmd_srcid_fifo;
    448366    GenericFifo<vci_trdid_t>    m_config_cmd_trdid_fifo;
     
    451369    GenericFifo<vci_cmd_t>      m_config_cmd_cmd_fifo;
    452370    GenericFifo<vci_contig_t>   m_config_cmd_contig_fifo;
    453     GenericFifo<vci_data_t>     m_config_cmd_data_fifo;
     371    GenericFifo<ext_data_t>     m_config_cmd_data_fifo;
    454372    GenericFifo<vci_eop_t>      m_config_cmd_eop_fifo;
    455373    GenericFifo<vci_cons_t>     m_config_cmd_cons_fifo;
     
    459377    GenericFifo<vci_clen_t>     m_config_cmd_clen_fifo;
    460378   
    461    
    462     // Private configuration registers
    463     sc_signal<int>          r_config_error_type; // rerror field
    464     sc_signal<vci_data_t>   r_config_first_word;   
    465     sc_signal<int>          r_it_index;
    466    
    467     GenericFifo<vci_data_t>   m_config_local_data_fifo;
    468     GenericFifo<vci_srcid_t>  m_config_local_rsrcid_fifo;
    469     GenericFifo<vci_trdid_t>  m_config_local_rtrdid_fifo;
    470     GenericFifo<vci_pktid_t>  m_config_local_rpktid_fifo;
    471     GenericFifo<vci_eop_t>    m_config_local_reop_fifo;
    472     GenericFifo<vci_rerror_t> m_config_local_rerror_fifo;
    473     sc_signal<vaddr_t>      r_config_vaddr;
    474    
    475 
    476     ///////////////////////////////////
    477     // CONFIG_RSP FSM REGISTERS
    478     ///////////////////////////////////
    479     sc_signal<int>          r_config_rsp_fsm;
    480 
    481         sc_signal<vci_trdid_t>  r_config_rtrdid;
    482         sc_signal<vci_srcid_t>  r_config_rsrcid;
    483    
    484     GenericFifo<vci_data_t>   m_config_rsp_data_fifo;
    485     GenericFifo<vci_srcid_t>  m_config_rsp_rsrcid_fifo;
    486     GenericFifo<vci_trdid_t>  m_config_rsp_rtrdid_fifo;
    487     GenericFifo<vci_pktid_t>  m_config_rsp_rpktid_fifo;
    488     GenericFifo<vci_eop_t>    m_config_rsp_reop_fifo;
    489     GenericFifo<vci_rerror_t> m_config_rsp_rerror_fifo;
     379    // output FIFO to VCI TGT port on INT network (VCI response) 
     380    GenericFifo<int_data_t>     m_config_rsp_data_fifo;
     381    GenericFifo<vci_srcid_t>    m_config_rsp_rsrcid_fifo;
     382    GenericFifo<vci_trdid_t>    m_config_rsp_rtrdid_fifo;
     383    GenericFifo<vci_pktid_t>    m_config_rsp_rpktid_fifo;
     384    GenericFifo<vci_eop_t>      m_config_rsp_reop_fifo;
     385    GenericFifo<vci_rerror_t>   m_config_rsp_rerror_fifo;
    490386       
    491     // Defines priority between the two response FIFOs (local and remote)
    492     sc_signal<bool>         r_config_rsp_fifo_local_priority;
    493                                                            
    494     //Communication between CONFIG_CMD and CONFIG_RSP
    495     sc_signal<bool>     r_config_cmd_rsp_erase_req; // used to signal an erasing on TRT table
    496    
    497     ///////////////////////////////////
    498     // ALLOC_TRT_CONFIG FSM REGISTERS
    499     ///////////////////////////////////
    500     sc_signal<int>          r_alloc_trt_config_fsm;                             // state register
    501 
    502     ///////////////////////////////////
    503     // MISS_INIT FSM REGISTERS
    504     ///////////////////////////////////
    505     sc_signal<int>          r_miss_init_fsm;
    506 
    507         sc_signal<vci_data_t>   r_miss_rdata;
    508         sc_signal<vci_pktid_t>  r_miss_rpktid;
    509         sc_signal<vci_trdid_t>  r_miss_rtrdid;
    510         sc_signal<vci_rerror_t> r_miss_rerror;
    511         sc_signal<vci_eop_t>    r_miss_reop; 
    512         //sc_signal<vci_data_t> r_miss_rsrcid;
    513        
    514     sc_signal<size_t>   r_miss_rsp_cpt;
    515    
    516     //IRQ
    517         sc_signal<uint32_t>     r_irq_pending; 
    518         sc_signal<uint32_t>     r_irq_mask; 
    519         sc_signal<uint32_t>     r_irq_chosen; 
    520 
    521 
    522     //Communication between TLB and MISS_INIT
    523     sc_signal<bool>         r_tlb_miss_init_req;
    524     sc_signal<bool>         r_miss_init_error;
    525    
    526     ////////////////////////////////////
    527     // MISS PREFETCH BUFFER
    528     ///////////////////////////////////
    529     //DMA_TLB FSM is its owner.
    530     //CONFIG FSM must set a request in order to access the resource (invalidation)
    531 
    532     // Proposition : Buffer with some lines (4, for example). It could be
    533     // indexed from the bit 20.
    534  
    535     vci_data_t                *r_miss_buf_data;     // cache line data buffer
    536     bool                    r_miss_buf_valid;       // For individual invalidation,
    537                                                     // we could rather use the Valid bit at each PTE
    538     sc_signal<paddr_t>      r_miss_buf_tag;         // chache line number 
    539     sc_signal<paddr_t>      r_miss_buf_vaddr_begin; // Virtual address of the first PTE on the line
    540    
    541     bool                    r_miss_buf_first_level; // useful only if using both types of pages
    542    
     387   
    543388    ////////////////////////////////
    544389    // Activity counters
     
    550395    uint32_t m_cpt_iotlb_read;              // number of iotlb read
    551396    uint32_t m_cpt_iotlb_miss;              // number of iotlb miss
    552     uint32_t m_cost_iotlb_miss;             // number of blocking cycles (not the treatment cycles itself)
    553     uint32_t m_cpt_iotlbmiss_transaction;   // number of iotlb miss transactions to Mem Cache
    554     uint32_t m_cost_iotlbmiss_transaction;  // cumulated duration for iotlb miss transactions
     397    uint32_t m_cost_iotlb_miss;             // number of wait cycles (not treatment itself)
     398    uint32_t m_cpt_iotlbmiss_transaction;   // number of tlb miss transactions
     399    uint32_t m_cost_iotlbmiss_transaction;  // cumulated duration tlb miss transactions
    555400
    556401    //Transaction Tabs (TRTs) activity counters
     
    564409    uint32_t m_cpt_fsm_dma_cmd          [32];
    565410    uint32_t m_cpt_fsm_dma_rsp          [32];
    566     uint32_t m_cpt_fsm_dma_tlb          [32];
    567     uint32_t m_cpt_fsm_alloc_trt_dma    [32];
     411    uint32_t m_cpt_fsm_tlb              [32];
    568412    uint32_t m_cpt_fsm_config_cmd       [32];
    569413    uint32_t m_cpt_fsm_config_rsp       [32];
    570     uint32_t m_cpt_fsm_alloc_trt_config [32];
    571     uint32_t m_cpt_fsm_miss_init        [32];
     414    uint32_t m_cpt_fsm_miss_wti_cmd    [32];
     415    uint32_t m_cpt_fsm_miss_wti_rsp     [32];
    572416 
    573417protected:
     
    577421    VciIoBridge(
    578422        sc_module_name insname,
    579         size_t nb_periph,                               // maximun is 32
    580         const soclib::common::MappingTable  &mtx,       //external network
    581         const soclib::common::MappingTable  &mtd,       //direct network
    582         const soclib::common::MappingTable  &mtio,      //io network
    583         const soclib::common::Segment       &seg_config_iob,
    584         const soclib::common::IntTab &tgt_index_iocluster,
    585 //        const soclib::common::IntTab &tgt_index_config,     // Direct Noc
    586         const soclib::common::IntTab &init_index_direct,    // Direct Noc
    587         const soclib::common::IntTab &tgt_index_iospace,    // IO Noc
    588         const soclib::common::IntTab &init_index_iospace,   // IO Noc
    589         const soclib::common::IntTab &init_index_dma,       // XRAM Noc
    590         size_t dcache_words,
    591         size_t   iotlb_ways,
    592         size_t   iotlb_sets,
    593         uint32_t debug_start_cycle,
    594         bool     debug_ok);
     423        const    soclib::common::MappingTable  &mt_ext,      // external network
     424        const    soclib::common::MappingTable  &mt_int,      // internal network
     425        const    soclib::common::MappingTable  &mt_iox,      // iox network
     426        const    soclib::common::IntTab        &int_tgtid,   // INT network TGTID
     427        const    soclib::common::IntTab        &int_srcid,   // INT network SRCID
     428        const    soclib::common::IntTab        &iox_tgtid,   // IOX network TGTID
     429        const    bool                          has_irqs,     // component has irq ports
     430        const    size_t                        dcache_words,
     431        const    size_t                        iotlb_ways,
     432        const    size_t                        iotlb_sets,
     433        const    uint32_t                      debug_start_cycle,
     434        const    bool                          debug_ok );
    595435
    596436    ~VciIoBridge();
  • trunk/modules/vci_io_bridge/caba/source/src/vci_io_bridge.cpp

    r405 r434  
    1 /* i*- c++ -*-C
     1/* -*- c++ -*-
    22 * File : vci_io_bridge.cpp
    33 * Copyright (c) UPMC, Lip6, SoC
     4 * Authors: Cassio Fraga, Alain Greiner
    45 *
    56 * SOCLIB_LGPL_HEADER_BEGIN
     
    2930#include "../include/vci_io_bridge.h"
    3031
     32
    3133//////   debug services   ///////////////////////////////////////////////////////
    3234// All debug messages are conditionned by two variables:
    3335// - compile time : DEBUG_*** : defined below
    3436// - execution time : m_debug_***  : defined by constructor arguments
    35 //    m_debug_* = (m_debug_ok) and (m_cpt_cycle > m_debug_start_cycle)
     37//    m_debug_activated = (m_debug_ok) and (m_cpt_cycle > m_debug_start_cycle)
    3638/////////////////////////////////////////////////////////////////////////////////
    3739
    3840#define DEBUG_DMA_CMD           1
    3941#define DEBUG_DMA_RSP           1
    40 #define DEBUG_DMA_TLB           1
     42#define DEBUG_TLB_MISS          1
    4143#define DEBUG_CONFIG_CMD                1
    4244#define DEBUG_CONFIG_RSP                1
    43 #define DEBUG_MISS_INIT                 1
    44 
    45 #define NEW_XRAM_VCI            0
    46    
    47 #define IOMMU_ID                4097
     45#define DEBUG_MISS_WTI                  1
    4846
    4947namespace soclib {
     
    5250namespace {
    5351
    54 //DMA
    55 const char *dma_cmd_fsm_state_str[] = {
     52const char *dma_cmd_fsm_state_str[] =
     53    {
    5654        "DMA_CMD_IDLE",
    57         "DMA_CMD_TRT_LOCK",
    58         "DMA_CMD_TRT_WAIT",
    59         "DMA_CMD_TRT_SET",
    60         "DMA_CMD_FIFO_PUT",
    61         "DMA_CMD_FIFO_MISS_PUT",
    62         "DMA_CMD_TLB_MISS_WAIT",
    63         "DMA_CMD_TLB_MISS_STORE",
    64         "DMA_CMD_ERROR",
     55        "DMA_CMD_FIFO_PUT_CMD",
     56        "DMA_CMD_FIFO_PUT_RSP",
     57        "DMA_CMD_MISS_WAIT",
     58        "DMA_CMD_WAIT_EOP",
    6559    };
    6660
    67 const char *dma_rsp_fsm_state_str[] = {
     61const char *dma_rsp_fsm_state_str[] =
     62    {
    6863        "DMA_RSP_IDLE",
    69         "DMA_RSP_TRT_LOCK",
    7064        "DMA_RSP_FIFO_PUT",
    71         "DMA_RSP_FIFO_ERROR_PUT",
    72  };
    73 
    74 const char *alloc_trt_dma_fsm_state_str[] = {
    75         "ALLOC_TRT_DMA_CMD",
    76         "ALLOC_TRT_DMA_RSP",
    7765    };
    7866
    79 const char *dma_tlb_fsm_state_str[] = {
    80         "DMA_TLB_IDLE",
    81         "DMA_TLB_MISS",
    82         "DMA_TLB_PTE1_GET",
    83         "DMA_TLB_PTE1_SELECT",
    84         "DMA_TLB_PTE1_UPDT",
    85         "DMA_TLB_PTE2_GET",                                                 
    86         "DMA_TLB_PTE2_SELECT",
    87         "DMA_TLB_PTE2_UPDT",
    88         "DMA_TLB_WAIT_TRANSACTION",
    89         "DMA_TLB_RETURN",
    90         "DMA_TLB_INVAL_CHECK",
    91         "DMA_TLB_INVAL_SCAN",
     67const char *tlb_fsm_state_str[] =
     68    {
     69        "TLB_IDLE",
     70        "TLB_MISS",
     71        "TLB_PTE1_GET",
     72        "TLB_PTE1_SELECT",
     73        "TLB_PTE1_UPDT",
     74        "TLB_PTE2_GET",                                                 
     75        "TLB_PTE2_SELECT",
     76        "TLB_PTE2_UPDT",
     77        "TLB_WAIT",
     78        "TLB_RETURN",
     79        "TLB_INVAL_CHECK",
    9280    };
    9381
    94 //CONFIG
    95 const char *config_cmd_fsm_state_str[] = {
     82const char *config_cmd_fsm_state_str[] =
     83    {
    9684        "CONFIG_CMD_IDLE",
    97         "CONFIG_CMD_TRT_LOCK",
    98         "CONFIG_CMD_TRT_WAIT",
    99         "CONFIG_CMD_TRT_SET",
    100         "CONFIG_CMD_FIFO_PUT",
    101          
    102         // IOB private configuration segment
    103         "CONFIG_CMD_PTPR_WRITE",
    104         "CONFIG_CMD_PTPR_READ",
    105         "CONFIG_CMD_ACTIVE_WRITE",
    106         "CONFIG_CMD_ACTIVE_READ",
    107         "CONFIG_CMD_BVAR_READ",
    108         "CONFIG_CMD_ETR_READ",
    109         "CONFIG_CMD_BAD_ID_READ",
    110         "CONFIG_CMD_INVAL_REQ",
    111         "CONFIG_CMD_INVAL",
    112         "CONFIG_CMD_IT_ADDR_IOMMU_WRITE_1",
    113         "CONFIG_CMD_IT_ADDR_IOMMU_WRITE_2",
    114         "CONFIG_CMD_IT_ADDR_IOMMU_READ_1",
    115         "CONFIG_CMD_IT_ADDR_IOMMU_READ_2",
    116         "CONFIG_CMD_IT_ADDR_WRITE_1",
    117         "CONFIG_CMD_IT_ADDR_WRITE_2",
    118         "CONFIG_CMD_IT_ADDR_READ_1",
    119         "CONFIG_CMD_IT_ADDR_READ_2",
    120         "CONFIG_CMD_ERROR_WAIT",
    121         "CONFIG_CMD_ERROR_RSP",
     85        "CONFIG_CMD_FIFO_PUT_CMD",
     86        "CONFIG_CMD_FIFO_PUT_RSP",
    12287    };
    12388
    124 const char *config_rsp_fsm_state_str[] = {
     89const char *config_rsp_fsm_state_str[] =
     90    {
    12591        "CONFIG_RSP_IDLE",
    126         "CONFIG_RSP_TRT_LOCK",
    12792        "CONFIG_RSP_FIFO_PUT",
    12893    };
    12994
    130 const char *alloc_trt_config_fsm_state_str[] = {
    131         "ALLOC_TRT_CONFIG_CMD",
    132         "ALLOC_TRT_CONFIG_RSP",
    133     };
    134 
    135 //MISS TRANSACTIONS (to Direct Network)
    136 const char *miss_init_fsm_state_str[] = { 
    137         "MISS_INIT_IDLE_MISS",
    138         "MISS_INIT_IDLE_IRQ",
    139         "MISS_INIT_IRQ_CMD",
    140         "MISS_INIT_IRQ_RSP",
    141         "MISS_INIT_TLB_MISS_CMD",
    142         "MISS_INIT_TLB_MISS_RSP",
     95const char *miss_wti_fsm_state_str[] = { 
     96        "MISS_WTI_IDLE_MISS",
     97        "MISS_WTI_IDLE_WTI",
     98        "MISS_WTI_CMD_WTI",
     99        "MISS_WTI_RSP_WTI",
     100        "MISS_WTI_CMD_MISS",
     101        "MISS_WTI_RSP_MISS",
    143102    };
    144103}
    145104
    146 #define tmpl(...)  template<typename vci_param_d,typename vci_param_x, typename vci_param_io> __VA_ARGS__ VciIoBridge<vci_param_d,vci_param_x,vci_param_io>
    147 
    148 /////////////////////////////////
     105#define tmpl(...)  template<typename vci_param_int,typename vci_param_ext> __VA_ARGS__ VciIoBridge<vci_param_int,vci_param_ext>
     106
     107////////////////////////
    149108tmpl(/**/)::VciIoBridge(
    150109    sc_module_name                                  name,
    151     size_t                              nb_periph,
    152     const soclib::common::MappingTable  &mtx,
    153     const soclib::common::MappingTable  &mtd,
    154     const soclib::common::MappingTable  &mtio,
    155     const soclib::common::Segment       &seg_config_iob,
    156     const soclib::common::IntTab            &tgt_index_iocluster,
    157 //    const soclib::common::IntTab          &tgt_index_config,
    158     const soclib::common::IntTab            &init_index_direct,
    159     const soclib::common::IntTab            &tgt_index_iospace,
    160     const soclib::common::IntTab            &init_index_iospace,
    161     const soclib::common::IntTab            &init_index_dma,
    162     size_t                              dcache_words,
    163     size_t                                              iotlb_ways,
    164     size_t                                              iotlb_sets,
    165     uint32_t                                        debug_start_cycle,
    166     bool                                                debug_ok)
     110    const soclib::common::MappingTable  &mt_ext,
     111    const soclib::common::MappingTable  &mt_int,
     112    const soclib::common::MappingTable  &mt_iox,
     113    const soclib::common::IntTab            &int_tgtid,     // INT network TGTID
     114    const soclib::common::IntTab            &int_srcid,     // INT network SRCID
     115    const soclib::common::IntTab            &iox_tgtid,     // IOX network TGTID
     116    const bool                          has_irqs,
     117    const size_t                        dcache_words,
     118    const size_t                                        iotlb_ways,
     119    const size_t                                        iotlb_sets,
     120    const uint32_t                                      debug_start_cycle,
     121    const bool                                      debug_ok)
    167122    : soclib::caba::BaseModule(name),
    168123
    169       p_clk("clk"),
    170       p_resetn("resetn"),
    171       p_irq_in(soclib::common::alloc_elems<sc_core::sc_in<bool> >("irq_in", nb_periph)),
    172       p_vci_ini_dma("vci_ini_dma"),
    173       p_vci_tgt_dma("vci_tgt_dma"),
    174       p_vci_ini_config("vci_ini_config"),
    175       p_vci_tgt_config("vci_tgt_config"),
    176       p_vci_ini_miss("vci_ini_miss"),
    177 
    178       m_words(dcache_words),
    179       m_nb_periph(nb_periph),
    180      
    181       // m_locality_table_config(mtd.getLocalityTable<unsigned long>(tgt_index_iocluster)),
    182       // These structures simulate what in hardware will be a correspondence table
    183       // Between segments' base address on the direct space and on the IO space
    184       // m_routing_table_config(mtd.getRoutingTable<unsigned long>(tgt_index_iocluster)),
    185       //m_mtio(mtio),
    186      
    187       m_transaction_tab_dma(2),
    188       m_transaction_tab_config(1),
    189       //Direct Network
    190 //      m_segment_config(mtd.getSegment(tgt_index_config)),
    191       m_segment_config(seg_config_iob),
    192       m_srcid_miss(mtx.indexForId(init_index_direct)),
    193       //XRAM Network
    194       m_srcid_dma(mtx.indexForId(init_index_dma)),
    195       //IO Network
    196       m_segment_io(mtio.getSegment(tgt_index_iospace)),
    197       m_srcid_config(mtio.indexForId(init_index_iospace)),
     124      p_clk("p_clk"),
     125      p_resetn("p_resetn"),
     126      p_vci_ini_ram("p_vci_ini_ram"),
     127      p_vci_tgt_iox("p_vci_tgt_iox"),
     128      p_vci_ini_iox("p_vci_ini_iox"),
     129      p_vci_tgt_int("p_vci_tgt_int"),
     130      p_vci_ini_int("p_vci_ini_int"),
     131
     132      m_words( dcache_words ),
     133      m_has_irqs( has_irqs ),
     134
     135      // INT & IOX Network
     136      m_int_seglist( mt_int.getSegmentList( int_tgtid )),
     137      m_int_srcid( mt_int.indexForId( int_srcid )),
     138      m_iox_seglist( mt_iox.getSegmentList( iox_tgtid )),
    198139
    199140      m_iotlb_ways(iotlb_ways),
    200141      m_iotlb_sets(iotlb_sets),
    201       m_paddr_nbits(vci_param_d::N),
    202142
    203143      m_debug_start_cycle(debug_start_cycle),
    204144      m_debug_ok(debug_ok),
    205145
     146      // addressable registers
    206147      r_iommu_ptpr("r_iommu_ptpr"),
    207148      r_iommu_active("r_iommu_active"),
     
    209150      r_iommu_etr("r_iommu_etr"),
    210151      r_iommu_bad_id("r_iommu_bad_id"),
    211       r_it_addr_iommu("r_it_addr_iommu"),
    212 
    213       // DMA_CMD
     152      r_iommu_wti_paddr("r_iommu_wti_paddr"),
     153      r_iommu_peri_wti(alloc_elems<sc_signal<vci_addr_t> >("r_peri_wti_paddr", 32)),
     154
     155      // DMA_CMD FSM registers
    214156      r_dma_cmd_fsm("r_dma_cmd_fsm"),
    215       r_dma_cmd_fsm_save("r_dma_cmd_fsm_save"),     
    216       r_miss_interrupt("r_miss_interrupt"),
    217       r_dma_cmd_count("r_dma_cmd_count"),
    218       r_dma_cmd_trt_index("r_dma_cmd_trt_index"),
    219       r_dma_paddr("r_dma_paddr"),
    220       // FIFOs
    221       m_dma_cmd_addr_fifo("m_dma_cmd_addr_fifo",4),
    222       //m_dma_cmd_length_fifo("m_dma_cmd_length_fifo",4),
    223       m_dma_cmd_srcid_fifo("m_dma_cmd_srcid_fifo",4),
    224       m_dma_cmd_trdid_fifo("m_dma_cmd_trdid_fifo",4),
    225       m_dma_cmd_pktid_fifo("m_dma_cmd_pktid_fifo",4),
    226       m_dma_cmd_be_fifo("m_dma_cmd_be_fifo",4),
    227       m_dma_cmd_cmd_fifo("m_dma_cmd_cmd_fifo",4),
    228       m_dma_cmd_contig_fifo("m_dma_cmd_contig_fifo",4),
    229       m_dma_cmd_data_fifo("m_dma_cmd_data_fifo",4),
    230       m_dma_cmd_eop_fifo("m_dma_cmd_eop_fifo",4),
    231       m_dma_cmd_cons_fifo("m_dma_cmd_cons_fifo",4),
    232       m_dma_cmd_plen_fifo("m_dma_cmd_plen_fifo",4),
    233       m_dma_cmd_wrap_fifo("m_dma_cmd_wrap_fifo",4),
    234       m_dma_cmd_cfixed_fifo("m_dma_cmd_cfixed_fifo",4),
    235       m_dma_cmd_clen_fifo("m_dma_cmd_clen_fifo",4),
    236 
    237       r_miss_paddr       ("r_miss_paddr"),
    238       r_miss_cmd         ("r_miss_cmd"),
    239       r_miss_contig      ("r_miss_contig"),
    240       r_miss_cons        ("r_miss_cons"),
    241       r_miss_plen        ("r_miss_plen"),
    242       r_miss_wrap        ("r_miss_wrap"),
    243       r_miss_cfixed      ("r_miss_cfixed"),   
    244       r_miss_clen        ("r_miss_clen"),
    245       r_miss_srcid       ("r_miss_srcid"),
    246       r_miss_trdid       ("r_miss_trdid"),
    247       r_miss_pktid       ("r_miss_pktid"),
    248 
    249       r_dma_error_type("r_dma_error_type"),     
    250       r_dma_error_trdid("r_dma_error_trdid"),
    251       r_dma_error_pktid("r_dma_error_pktid"),
    252 
    253  
    254       r_dma_tlb_fsm("r_dma_tlb_fsm"),
     157      r_dma_cmd_vaddr("r_dma_cmd_vaddr"),
     158      r_dma_cmd_paddr("r_dma_cmd_paddr"),
     159
     160      //DMA_RSP FSM registers
     161      r_dma_rsp_fsm("r_dma_rsp_fsm"),
     162
     163      // CONFIG_CMD FSM registers
     164      r_config_cmd_fsm("r_config_cmd_fsm"),
     165      r_config_cmd_rdata("r_config_cmd_rdata"),
     166      r_config_cmd_error("r_config_cmd_error"),
     167      r_config_cmd_inval_vaddr("r_config_cmd_inval_vaddr"),
     168
     169      // CONFIG_RSP FSM registers 
     170      r_config_rsp_fsm("r_config_rsp_fsm"),
     171
     172      // TLB FSM registers
     173      r_tlb_fsm("r_tlb_fsm"),
    255174      r_waiting_transaction("r_waiting_transaction"),
    256175      r_tlb_miss_type("r_tlb_miss_type"),
    257 
    258                      
    259       r_iotlb_vaddr("r_iotlb_vaddr"),            // virtual address for a tlb miss
    260       r_iotlb_paddr("r_iotlb_paddr"),            // physical address of pte
    261       r_iotlb_pte_flags("r_iotlb_pte_flags"),// pte1 or first word of pte2
    262       r_iotlb_pte_ppn("r_iotlb_pte_ppn"),        // second word of pte2
    263       r_iotlb_way("r_iotlb_way"),                    // selected way in tlb   
    264       r_iotlb_set("r_iotlb_set"),                    // selected set in tlb   
    265 
    266       r_iotlb("iotlb", IOMMU_ID, iotlb_ways,iotlb_sets,vci_param_d::N),
     176      r_tlb_miss_error("r_tlb_miss_error"),
     177      r_tlb_paddr("r_tlb_paddr"),               
     178      r_tlb_pte_flags("r_tlb_pte_flags"),
     179      r_tlb_pte_ppn("r_tlb_pte_ppn"),
     180      r_tlb_way("r_tlb_way"),
     181      r_tlb_set("r_tlb_set"),   
     182      r_tlb_buf_valid("r_tlb_buf_valid"),
     183      r_tlb_buf_tag("r_tlb_buf_tag"),
     184      r_tlb_buf_vaddr("r_tlb_buf_vaddr"),
     185      r_tlb_buf_big_page("r_tlb_buf_big_page"),
     186
     187      // MISS_WTI_CMD FSM registers
     188      r_miss_wti_cmd_fsm("r_miss_wti_cmd_fsm"),
     189      r_miss_wti_cmd_index("r_miss_wti_cmd_index"),
     190
     191      // MISS_WTI_CMD FSM registers
     192      r_miss_wti_rsp_fsm("r_miss_wti_rsp_fsm"),
     193      r_miss_wti_rsp_error("r_miss_wti_rsp_error"),
     194
     195      // allocator for CONFIG_RSP & DMA_RSP fifos
     196      r_alloc_fifo_config_rsp_local("r_alloc_fifo_config_rsp_local"),
     197      r_alloc_fifo_dma_rsp_local("r_alloc_fifo_dma_rsp_local"),
     198
     199      // IRQs registers
     200      r_irq_pending(alloc_elems<sc_signal<bool> >("r_irq_pending", 32)),
     201      r_irq_request(alloc_elems<sc_signal<bool> >("r_irq_request", 32)),
    267202     
    268       //DMA_RSP
    269       r_dma_rsp_fsm("r_dma_rsp_fsm"),
    270       r_dma_rtrdid("r_dma_rtrdid"),
    271       r_dma_rsrcid("r_dma_rsrcid"),
    272       //Fifo's
    273       m_dma_rsp_data_fifo("m_dma_rsp_data_fifo",4),
    274       m_dma_rsp_rsrcid_fifo("m_dma_rsp_rsrcid_fifo",4),
    275       m_dma_rsp_rtrdid_fifo("m_dma_rsp_rtrdid_fifo",4),
    276       m_dma_rsp_rpktid_fifo("m_dma_rsp_rpktid_fifo",4),
    277       m_dma_rsp_reop_fifo("m_dma_rsp_reop_fifo",4),
    278       m_dma_rsp_rerror_fifo("m_dma_rsp_rerror_fifo",4),
     203      // TLB for IOMMU
     204      r_iotlb("iotlb", 0, iotlb_ways, iotlb_sets, vci_param_int::N),
     205     
     206      // Inter-FSM communications
     207      r_dma_tlb_req("r_dma_tlb_req"),
     208      r_config_tlb_req("r_config_tlb_req"),
     209      r_tlb_miss_req("r_tlb_miss_req"),
    279210     
    280       r_dma_cmd_rsp_erase_req("r_dma_cmd_rsp_erase_req"),
    281       r_dma_cmd_error_req("r_dma_cmd_error_req"),
    282       r_dma_tlb_req("r_dma_tlb_req"),
    283       r_tlb_dma_untreated("r_tlb_dma_untreated"),
    284       r_dma_tlb_error_req("r_dma_tlb_error_req"),
    285       r_config_tlb_req("r_config_tlb_req"),
    286       r_config_tlb_inval_vaddr("r_config_tlb_inval_vaddr"),
    287      
    288       // ALLOC TRT DMA
    289       r_alloc_trt_dma_fsm("r_alloc_trt_dma_fsm"),
    290      
    291       // CONFIG CMD
    292       r_config_cmd_fsm("r_config_cmd_fsm"),
    293       r_config_cmd_trt_index("r_config_cmd_trt_index"),
    294      
    295       m_config_cmd_addr_fifo("m_config_cmd_addr_fifo",4),
    296       //m_config_cmd_length_fifo("m_config_cmd_length_fifo",4),
    297       m_config_cmd_srcid_fifo("m_config_cmd_srcid_fifo",4),
    298       m_config_cmd_trdid_fifo("m_config_cmd_trdid_fifo",4),
    299       m_config_cmd_pktid_fifo("m_config_cmd_pktid_fifo",4),
    300       m_config_cmd_be_fifo("m_config_cmd_be_fifo",4),
    301       m_config_cmd_cmd_fifo("m_config_cmd_cmd_fifo",4),
    302       m_config_cmd_contig_fifo("m_config_cmd_contig_fifo",4),
    303       m_config_cmd_data_fifo("m_config_cmd_data_fifo",4),
    304       m_config_cmd_eop_fifo("m_config_cmd_eop_fifo",4),
    305       m_config_cmd_cons_fifo("m_config_cmd_cons_fifo",4),
    306       m_config_cmd_plen_fifo("m_config_cmd_plen_fifo",4),
    307       m_config_cmd_wrap_fifo("m_config_cmd_wrap_fifo",4),
    308       m_config_cmd_cfixed_fifo("m_config_cmd_cfixed_fifo",4),
    309       m_config_cmd_clen_fifo("m_config_cmd_clen_fifo",4),
    310       // Private configuration registers
    311       r_config_error_type("r_config_error_type"),
    312       r_config_first_word("r_config_first_word"),
    313       r_it_index("r_it_index"),
    314       //Fifo's
    315       m_config_local_data_fifo("m_config_local_data_fifo",4),     
    316       m_config_local_rsrcid_fifo("m_config_local_rsrcid_fifo",4),
    317       m_config_local_rtrdid_fifo("m_config_local_rtrdid_fifo",4),
    318       m_config_local_rpktid_fifo("m_config_local_rpktid_fifo",4),
    319       m_config_local_reop_fifo("m_config_local_reop_fifo",4),
    320       m_config_local_rerror_fifo("m_config_local_rerror_fifo",4),   
    321       r_config_vaddr("r_config_vaddr"),
     211      // DMA_CMD FIFOs
     212      m_dma_cmd_addr_fifo("m_dma_cmd_addr_fifo",2),
     213      m_dma_cmd_srcid_fifo("m_dma_cmd_srcid_fifo",2),
     214      m_dma_cmd_trdid_fifo("m_dma_cmd_trdid_fifo",2),
     215      m_dma_cmd_pktid_fifo("m_dma_cmd_pktid_fifo",2),
     216      m_dma_cmd_be_fifo("m_dma_cmd_be_fifo",2),
     217      m_dma_cmd_cmd_fifo("m_dma_cmd_cmd_fifo",2),
     218      m_dma_cmd_contig_fifo("m_dma_cmd_contig_fifo",2),
     219      m_dma_cmd_data_fifo("m_dma_cmd_data_fifo",2),
     220      m_dma_cmd_eop_fifo("m_dma_cmd_eop_fifo",2),
     221      m_dma_cmd_cons_fifo("m_dma_cmd_cons_fifo",2),
     222      m_dma_cmd_plen_fifo("m_dma_cmd_plen_fifo",2),
     223      m_dma_cmd_wrap_fifo("m_dma_cmd_wrap_fifo",2),
     224      m_dma_cmd_cfixed_fifo("m_dma_cmd_cfixed_fifo",2),
     225      m_dma_cmd_clen_fifo("m_dma_cmd_clen_fifo",2),
     226
     227      // DMA_RSP FIFOs
     228      m_dma_rsp_data_fifo("m_dma_rsp_data_fifo",2),
     229      m_dma_rsp_rsrcid_fifo("m_dma_rsp_rsrcid_fifo",2),
     230      m_dma_rsp_rtrdid_fifo("m_dma_rsp_rtrdid_fifo",2),
     231      m_dma_rsp_rpktid_fifo("m_dma_rsp_rpktid_fifo",2),
     232      m_dma_rsp_reop_fifo("m_dma_rsp_reop_fifo",2),
     233      m_dma_rsp_rerror_fifo("m_dma_rsp_rerror_fifo",2),
     234 
     235      // CONFIG_CMD FIFOs
     236      m_config_cmd_addr_fifo("m_config_cmd_addr_fifo",2),
     237      m_config_cmd_srcid_fifo("m_config_cmd_srcid_fifo",2),
     238      m_config_cmd_trdid_fifo("m_config_cmd_trdid_fifo",2),
     239      m_config_cmd_pktid_fifo("m_config_cmd_pktid_fifo",2),
     240      m_config_cmd_be_fifo("m_config_cmd_be_fifo",2),
     241      m_config_cmd_cmd_fifo("m_config_cmd_cmd_fifo",2),
     242      m_config_cmd_contig_fifo("m_config_cmd_contig_fifo",2),
     243      m_config_cmd_data_fifo("m_config_cmd_data_fifo",2),
     244      m_config_cmd_eop_fifo("m_config_cmd_eop_fifo",2),
     245      m_config_cmd_cons_fifo("m_config_cmd_cons_fifo",2),
     246      m_config_cmd_plen_fifo("m_config_cmd_plen_fifo",2),
     247      m_config_cmd_wrap_fifo("m_config_cmd_wrap_fifo",2),
     248      m_config_cmd_cfixed_fifo("m_config_cmd_cfixed_fifo",2),
     249      m_config_cmd_clen_fifo("m_config_cmd_clen_fifo",2),
     250
     251      // CONFIG_RSP FIFOs
     252      m_config_rsp_data_fifo("m_config_rsp_data_fifo",2),     
     253      m_config_rsp_rsrcid_fifo("m_config_rsp_rsrcid_fifo",2),
     254      m_config_rsp_rtrdid_fifo("m_config_rsp_rtrdid_fifo",2),
     255      m_config_rsp_rpktid_fifo("m_config_rsp_rpktid_fifo",2),
     256      m_config_rsp_reop_fifo("m_config_rsp_reop_fifo",2),
     257      m_config_rsp_rerror_fifo("m_config_rsp_rerror_fifo",2)
     258{
     259    std::cout << "  - Building VciIoBridge : " << name << std::endl;
     260
     261    // checking segments on INT network
     262    assert ( ( not m_int_seglist.empty() ) and
     263    "VCI_IO_BRIDGE ERROR : no segment allocated on INT network");
     264
     265    std::list<soclib::common::Segment>::iterator int_seg;
     266    for ( int_seg = m_int_seglist.begin() ; int_seg != m_int_seglist.end() ; int_seg++ )
     267    {
     268        std::cout << "    => segment " << int_seg->name()
     269                  << " / base = " << std::hex << int_seg->baseAddress()
     270                  << " / size = " << int_seg->size() << std::endl;
     271    }
     272
     273    // checking segments on IOX network
     274    assert ( ( not m_iox_seglist.empty() ) and
     275    "VCI_IO_BRIDGE ERROR : no segment allocated on IOX network");
     276
     277    std::list<soclib::common::Segment>::iterator iox_seg;
     278    for ( iox_seg = m_iox_seglist.begin() ; iox_seg != m_iox_seglist.end() ; iox_seg++ )
     279    {
     280        std::cout << "    => segment " << iox_seg->name()
     281                  << " / base = " << std::hex << iox_seg->baseAddress()
     282                  << " / size = " << iox_seg->size() << std::endl;
     283    }
     284
     285    assert( (vci_param_int::N == vci_param_ext::N) and
     286    "VCI_IO_BRIDGE ERROR: VCI ADDRESS widths must be equal on the 3 networks");
     287
     288    assert( (vci_param_int::N <=  64) and
     289    "VCI_IO_BRIDGE ERROR: VCI ADDRESS width cannot be bigger than 64 bits");
     290
     291    assert( ((vci_param_int::B == 4) or (vci_param_int::B == 8)) and
     292    "VCI_IO_BRIDGE ERROR: VCI DATA width must be 32 or 64 bits on internal network");   
     293
     294    assert( ((vci_param_ext::B == 4) or (vci_param_ext::B == 8)) and
     295    "VCI_IO_BRIDGE ERROR: VCI DATA width must be 32 or 64 bits on external network");   
     296
     297    assert( (vci_param_int::S == vci_param_ext::S) and
     298            "VCI_IO_BRIDGE ERROR: SRCID widths must be equal on the 3 networks");
     299
     300    // contruct 32 IRQ ports if required
     301    if ( has_irqs )
     302    {
     303        for ( size_t n=0 ; n<32 ; n++ ) p_irq[n] = new sc_core::sc_in<bool>;
     304    }
    322305   
    323       // CONFIG RSP 
    324       r_config_rsp_fsm("r_config_rsp_fsm"),
    325       r_config_rtrdid("r_config_rtrdid"),
    326       r_config_rsrcid("r_config_rsrcid"),
    327       //Fifo's
    328       m_config_rsp_data_fifo("m_config_rsp_data_fifo",4),     
    329       m_config_rsp_rsrcid_fifo("m_config_rsp_rsrcid_fifo",4),
    330       m_config_rsp_rtrdid_fifo("m_config_rsp_rtrdid_fifo",4),
    331       m_config_rsp_rpktid_fifo("m_config_rsp_rpktid_fifo",4),
    332       m_config_rsp_reop_fifo("m_config_rsp_reop_fifo",4),
    333       m_config_rsp_rerror_fifo("m_config_rsp_rerror_fifo",4),   
    334 
    335       // Communication between CONFIG CMD and CONFIG RSP
    336       r_config_cmd_rsp_erase_req("r_config_cmd_rsp_erase_req"),     
    337    
    338       // ALLOC TRT CONFIG
    339       r_alloc_trt_config_fsm("r_alloc_trt_config_fsm"),
    340       // MISS INIT
    341       r_miss_init_fsm("r_miss_init_fsm"),
    342       r_miss_rdata("r_miss_rdata"),
    343       r_miss_rpktid("r_miss_rpktid"),
    344       r_miss_rtrdid("r_miss_rtrdid"),
    345       r_miss_rerror("r_miss_rerror"),
    346       r_miss_reop("r_miss_reop"),
    347       //r_miss_rsrcid("r_miss_rsrcid"),
    348       r_miss_rsp_cpt("r_miss_rsp_cpt"),
    349       //IRQ
    350       r_irq_pending("r_irq_pending"),
    351       r_irq_mask("r_irq_mask"),
    352       r_irq_chosen("r_irq_chosen"),
    353      
    354       r_tlb_miss_init_req("r_tlb_miss_init_req"),
    355       r_miss_init_error("r_miss_init_error"),
    356      
    357       r_miss_buf_valid("r_miss_buf_valid"),
    358       r_miss_buf_tag("r_miss_buf_tag")
    359 {
    360     assert( (vci_param_d::N <=  64) and
    361             "ADDRESS cannot be bigger than 64 bits");
    362     assert( (vci_param_x::B)*8 == 64 and (vci_param_io::B)*8 == 64 and
    363             "DATA field must be 64 bits in Extern and IO Network");
    364     assert ( (vci_param_d::B)*8 == 32
    365         and "Error: data field in Direct Noc must be 32 bits" );
    366                    
    367    
    368     // Interruption Address vector, one entry for each IO
    369     r_it_addr           = new paddr_t[nb_periph];
    370     // One cache line buffer
    371     r_miss_buf_data     = new vci_data_t[dcache_words];
    372     // Command storage in case of miss TLB
    373     // (dcache_words/2) => Maximal size of a write command
    374     r_miss_data     = new vci_data_t[dcache_words];
    375     r_miss_be     = new vci_be_t[dcache_words];
    376    
     306    // Cache line buffer
     307    r_tlb_buf_data = new uint32_t[dcache_words];
     308
    377309    SC_METHOD(transition);
    378310    dont_initialize();
     
    389321/////////////////////////////////////
    390322{
    391     delete [] r_it_addr;
    392     delete [] r_miss_buf_data;
    393     delete [] r_miss_data;
    394     delete [] r_miss_be;
    395     soclib::common::dealloc_elems(p_irq_in, m_nb_periph);
     323    delete [] r_iommu_peri_wti;
     324    delete [] r_tlb_buf_data;
     325    soclib::common::dealloc_elems(p_irq, 32);
     326    soclib::common::dealloc_elems(r_irq_request, 32);
     327    soclib::common::dealloc_elems(r_irq_pending, 32);
    396328}
    397329
     
    404336    std::cout << std::dec << "IO_BRIDGE " << name() << std::endl;
    405337
    406     std::cout << "  " << dma_cmd_fsm_state_str[r_dma_cmd_fsm.read()]
     338    std::cout << "  "  << dma_cmd_fsm_state_str[r_dma_cmd_fsm.read()]
    407339              << " | " << dma_rsp_fsm_state_str[r_dma_rsp_fsm.read()]
    408               << " | " << dma_tlb_fsm_state_str[r_dma_tlb_fsm.read()]
    409               << " | " << alloc_trt_dma_fsm_state_str[r_alloc_trt_dma_fsm.read()]
     340              << " | " << tlb_fsm_state_str[r_tlb_fsm.read()]
    410341              << " | " << config_cmd_fsm_state_str[r_config_cmd_fsm.read()]
    411342              << " | " << config_rsp_fsm_state_str[r_config_rsp_fsm.read()]
    412               << " | " << alloc_trt_config_fsm_state_str[r_alloc_trt_config_fsm.read()]
    413               << " | " << miss_init_fsm_state_str[r_miss_init_fsm.read()];
    414     std::cout << std::endl;
     343              << " | " << miss_wti_fsm_state_str[r_miss_wti_cmd_fsm.read()]
     344              << std::endl;
    415345
    416346    if(mode & 0x01)
     
    424354    }
    425355}
    426 
    427 
    428356
    429357////////////////////////
     
    447375    m_cpt_iotlbmiss_transaction     = 0;   
    448376    m_cost_iotlbmiss_transaction    = 0;   
    449        
    450     m_cpt_trt_dma_full          = 0;
    451     m_cpt_trt_dma_full_cost     = 0;
    452     m_cpt_trt_config_full          = 0;
    453     m_cpt_trt_config_full_cost     = 0;
    454377}
    455378
     
    460383    if ( not p_resetn.read() )
    461384    {
    462 
    463         r_dma_cmd_fsm               = DMA_CMD_IDLE;
    464         r_dma_rsp_fsm               = DMA_RSP_IDLE;
    465         r_alloc_trt_dma_fsm     = ALLOC_TRT_DMA_CMD;
    466         r_dma_tlb_fsm           = DMA_TLB_IDLE;
    467         r_config_cmd_fsm            = CONFIG_CMD_IDLE;
    468         r_config_rsp_fsm            = CONFIG_RSP_IDLE;
    469         r_alloc_trt_config_fsm  = ALLOC_TRT_CONFIG_CMD;
    470         r_miss_init_fsm             = MISS_INIT_IDLE_MISS;
    471 
    472         //miss buffer invalidation
    473         r_miss_buf_valid = false;
    474        
    475                 r_iommu_active = false;
    476 
    477         r_dma_cmd_count = 0;
     385        r_dma_cmd_fsm      = DMA_CMD_IDLE;
     386        r_dma_rsp_fsm      = DMA_RSP_IDLE;
     387        r_tlb_fsm              = TLB_IDLE;
     388        r_config_cmd_fsm   = CONFIG_CMD_IDLE;
     389        r_config_rsp_fsm   = CONFIG_RSP_IDLE;
     390        r_miss_wti_cmd_fsm = MISS_WTI_CMD_IDLE;
     391        r_miss_wti_rsp_fsm = MISS_WTI_RSP_IDLE;
     392
     393        r_alloc_fifo_config_rsp_local = true;
     394        r_alloc_fifo_dma_rsp_local    = true;
     395
     396        r_tlb_buf_valid    = false;
     397                r_iommu_active     = false;
     398                r_iommu_wti_enable = false;
    478399       
    479400        // initializing FIFOs
     
    522443        m_config_rsp_reop_fifo.init();
    523444       
    524         m_config_local_rsrcid_fifo.init();
    525         m_config_local_rtrdid_fifo.init();
    526         m_config_local_rpktid_fifo.init();
    527         m_config_local_data_fifo.init();
    528         m_config_local_rerror_fifo.init();
    529         m_config_local_reop_fifo.init();
    530 
    531         //Communication between DMA_CMD and DMA_RSP
    532         r_dma_cmd_rsp_erase_req         =false;
    533         r_dma_cmd_error_req         =false;
    534         //Communication between DMA_CMD and TLB
    535         r_dma_tlb_req                   =false;
    536         r_tlb_dma_untreated                 =false;
    537         //Communication betweeen TLB and CONFIG_CMD
    538         r_config_tlb_req                    =false;
    539         r_config_tlb_inval_vaddr        =false;
    540             r_dma_tlb_error_req         =false;
    541         r_tlb_error_type            =false;   
    542         //Communication between CONFIG_CMD and CONFIG_RSP
    543         r_config_cmd_rsp_erase_req  =false;
    544         //Communication between TLB_MISS and MISS_INIT
    545         r_tlb_miss_init_req         =false;
    546         r_miss_init_error           =false;
    547         // Debug variables
    548                 m_debug_dma_rsp_fsm             = false;
    549                 m_debug_dma_cmd_fsm         = false;
    550         m_debug_dma_tlb_fsm         = false;
    551         m_debug_config_cmd_fsm      = false;
    552         m_debug_config_rsp_fsm      = false;
    553         m_debug_miss_init_fsm       = false;
     445        // SET/RESET Communication flip-flops
     446        r_dma_tlb_req                   = false;
     447        r_config_tlb_req                    = false;
     448        r_tlb_miss_req              = false;
     449
     450        // Debug variable
     451                m_debug_activated               = false;
    554452       
    555         r_irq_mask              = 0xFFFFFFFF;
    556         r_irq_chosen            = 0;
     453        for ( size_t n=0 ; n<32 ; n++ )
     454        {
     455            r_irq_pending[n]        = false;
     456            r_irq_request[n]        = false;
     457        }
    557458         
    558459            // activity counters
    559             m_cpt_total_cycles      = 0;
    560         m_cpt_iotlb_read       = 0;             
    561         m_cpt_iotlb_miss       = 0;             
    562         m_cpt_iotlbmiss_transaction      = 0;   
    563         m_cost_iotlbmiss_transaction      = 0;   
     460            m_cpt_total_cycles            = 0;
     461        m_cpt_iotlb_read              = 0;             
     462        m_cpt_iotlb_miss              = 0;             
     463        m_cpt_iotlbmiss_transaction   = 0;   
     464        m_cost_iotlbmiss_transaction  = 0;   
    564465       
    565         m_cpt_trt_dma_full          = 0;
    566         m_cpt_trt_dma_full_cost     = 0;
    567         m_cpt_trt_config_full          = 0;
    568         m_cpt_trt_config_full_cost     = 0;
     466        m_cpt_trt_dma_full            = 0;
     467        m_cpt_trt_dma_full_cost       = 0;
     468        m_cpt_trt_config_full         = 0;
     469        m_cpt_trt_config_full_cost    = 0;
    569470
    570471        for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_dma_cmd            [i]   = 0;
    571472        for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_dma_rsp            [i]   = 0;
    572         for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_dma_tlb            [i]   = 0;
    573         for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_alloc_trt_dma      [i]   = 0;
     473        for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_tlb                [i]   = 0;
    574474        for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_config_cmd         [i]   = 0;
    575475        for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_config_rsp         [i]   = 0;
    576         for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_alloc_trt_config   [i]   = 0;
    577         for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_miss_init          [i]   = 0;
     476        for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_miss_wti_cmd       [i]   = 0;
     477        for (uint32_t i=0; i<32 ; ++i) m_cpt_fsm_miss_wti_rsp       [i]   = 0;
     478
    578479        return;
    579480    }
    580481
     482    // default values for FIFOs
     483    bool        dma_cmd_fifo_put      = false;
     484    bool        dma_cmd_fifo_get      = false;
     485
     486    bool        dma_rsp_fifo_put      = false;
     487    bool        dma_rsp_fifo_get      = false;
    581488   
    582     //bool        miss_unposted      = false;
    583     bool        dma_cmd_fifo_put    = false;
    584     bool        dma_cmd_fifo_get    = false;
    585     bool        dma_rsp_fifo_put    = false;
    586     bool        dma_rsp_fifo_get    = false;
    587    
    588     bool        config_cmd_fifo_put = false;
    589     bool        config_cmd_fifo_get = false;
    590     bool        config_rsp_fifo_put = false;
    591     bool        config_rsp_fifo_get = false;
    592     bool        config_local_fifo_put = false;
    593     bool        config_local_fifo_get = false;
     489    bool        config_cmd_fifo_put   = false;
     490    bool        config_cmd_fifo_get   = false;
     491
     492    bool        config_rsp_fifo_put   = false;
     493    bool        config_rsp_fifo_get   = false;
    594494
    595495#ifdef INSTRUMENTATION
    596496    m_cpt_fsm_dma_cmd           [r_dma_cmd_fsm.read()] ++;
    597497    m_cpt_fsm_dma_rsp           [r_dma_rsp_fsm.read() ] ++;
    598     m_cpt_fsm_dma_tlb               [r_dma_tlb_fsm.read() ] ++;
    599     m_cpt_fsm_alloc_trt_dma     [r_alloc_trt_dma_fsm.read() ] ++;
     498    m_cpt_fsm_tlb                   [r_tlb_fsm.read() ] ++;
    600499    m_cpt_fsm_config_cmd            [r_config_cmd_fsm.read() ] ++;
    601500    m_cpt_fsm_config_rsp            [r_config_rsp_fsm.read() ] ++;
    602     m_cpt_fsm_alloc_trt_config  [r_alloc_trt_config_fsm.read() ] ++;
    603     m_cpt_fsm_miss_init         [r_miss_init_fsm.read() ] ++;
     501    m_cpt_fsm_miss_wti_cmd      [r_miss_wti_cmd_fsm.read() ] ++;
     502    m_cpt_fsm_miss_wti_rsp      [r_miss_wti_rsp_fsm.read() ] ++;
    604503#endif
    605504
    606505    m_cpt_total_cycles++;
    607506
    608     m_debug_dma_cmd_fsm        = (m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok;
    609     m_debug_dma_rsp_fsm         = (m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok;
    610     m_debug_dma_tlb_fsm    = (m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok;
    611     m_debug_config_cmd_fsm      = (m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok;
    612     m_debug_config_rsp_fsm     = (m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok;
    613     m_debug_miss_init_fsm       = (m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok;
    614 
    615     /////////////////////////////////////////////////////////////////////
    616     // The DMA_CMD_FSM controls the following ressources:
    617     // - r_dma_cmd_fsm
    618     // - r_dma_srcid
    619     // - r_dma_tlb_req (set)
    620     // - r_tlb_dma_untreated (reset)
    621     // - r_dma_cmd_rsp_erase_req (set)
     507    m_debug_activated  = (m_cpt_total_cycles > m_debug_start_cycle) and m_debug_ok;
     508
     509    //////////////////////////////////////////////////////////////////////////////
     510    // The DMA_CMD_FSM handles DMA transactions requested by peripherals
     511    // It makes the address translation if IOMMU is activated.
    622512    ///////////////////////////////////////////////////////////////////////////////
    623513
    624514    switch( r_dma_cmd_fsm.read() )
    625515    {
    626     //////////////
    627     case DMA_CMD_IDLE:
    628     {
    629         // Treats an eventual request from TLB_MISS fsm
    630         // to send a command whose miss treatment is now finished
    631         if ( r_tlb_dma_untreated.read() )
    632         {
    633             r_dma_cmd_fsm    = DMA_CMD_TRT_LOCK;//before posting we must update TRT
    634             r_dma_cmd_fsm_save = DMA_CMD_IDLE;
    635             r_miss_interrupt = true;
    636             break;
    637         }
    638         // Error during miss treatment
    639         else if (r_dma_tlb_error_req.read())
    640         {
    641             r_iommu_etr     = r_tlb_error_type.read();
    642             r_iommu_bvar    = r_iotlb_vaddr.read();
    643             r_iommu_bad_id  = r_miss_srcid.read();
    644             // For DMA_RSP FSM
    645             if(r_miss_cmd.read() == vci_param_io::CMD_WRITE) r_dma_error_type = WRITE_ERROR;
    646             else r_dma_error_type = READ_ERROR;
    647             r_dma_error_trdid   = r_miss_trdid.read();
    648             r_dma_error_pktid   = r_miss_pktid.read();
    649  
    650             r_dma_tlb_error_req = false;
    651             r_dma_cmd_fsm   = DMA_CMD_ERROR;
    652         }
    653 
    654         if ( p_vci_tgt_dma.cmdval.read() )
     516    //////////////////
     517    case DMA_CMD_IDLE:  // waiting DMA VCI transaction
     518    {
     519        if ( p_vci_tgt_iox.cmdval.read() ) // compute physical address
    655520        {
    656             if ( not r_iommu_active.read())     // iotlb not activated
     521            if ( not r_iommu_active.read() )    // tlb not activated
    657522            {
    658                 // physical address
    659                 r_dma_paddr = (paddr_t)p_vci_tgt_dma.address.read();
    660                 r_dma_cmd_fsm   = DMA_CMD_TRT_LOCK;
     523#if DEBUG_DMA_CMD
     524if( m_debug_activated )
     525std::cout << "  <IOB DMA_CMD_IDLE> IOMMU not activated" << std::endl;
     526#endif
     527                // put DMA transaction into DMA_CMD fifo
     528                r_dma_cmd_paddr = p_vci_tgt_iox.address.read();
     529                r_dma_cmd_fsm   = DMA_CMD_FIFO_PUT_CMD;
    661530            }
    662             else if (r_dma_tlb_fsm.read() == DMA_TLB_IDLE ||
    663                      r_dma_tlb_fsm.read() == DMA_TLB_WAIT_TRANSACTION )   // iotlb activated
     531            else if (r_tlb_fsm.read() == TLB_IDLE ||
     532                     r_tlb_fsm.read() == TLB_WAIT )       // tlb access possible
    664533            {
    665                 paddr_t paddr;
    666 
    667                
    668                 // We compute physical address and check access rights :
    669                 // - If MMU not activated :the physical address is equal to the virtual
    670                 //address (identity mapping) and there is no access rights checking
    671                 // - If MMU activated : cacheability is defined by the C bit in the PTE,
    672                 //   the physical address is obtained from the TLB, and the access rights are
    673                 //   defined by the W bit in the PTE.
    674 
    675                 paddr_t         iotlb_paddr;
     534                vci_addr_t      iotlb_paddr;
    676535                pte_info_t  iotlb_flags;
    677536                size_t      iotlb_way; 
    678537                size_t      iotlb_set;
    679                 paddr_t     iotlb_nline;
    680                 bool            iotlb_hit   = false;; 
    681 
     538                vci_addr_t  iotlb_nline;
     539                bool            iotlb_hit; 
    682540
    683541#ifdef INSTRUMENTATION
    684542m_cpt_iotlb_read++;
    685543#endif
    686 
    687                 iotlb_hit = r_iotlb.translate(p_vci_tgt_dma.address.read(),
    688                                             &iotlb_paddr,
    689                                             &iotlb_flags,
    690                                             &iotlb_nline,// unused
    691                                             &iotlb_way,  // unused
    692                                             &iotlb_set );// unused
     544                iotlb_hit = r_iotlb.translate(p_vci_tgt_iox.address.read(),
     545                                              &iotlb_paddr,
     546                                              &iotlb_flags,
     547                                              &iotlb_nline,  // unused
     548                                              &iotlb_way,        // unused
     549                                              &iotlb_set );  // unused
    693550           
    694            
    695                 if ( iotlb_hit )        // tlb hit
     551                if ( iotlb_hit )                                     // tlb hit
    696552                {
    697                     paddr       = iotlb_paddr;
    698                                        
    699                     // access rights checking
    700                     if ( not iotlb_flags.w and
    701                         (p_vci_tgt_dma.cmd.read() == vci_param_io::CMD_WRITE) )
     553                    if ( not iotlb_flags.w and    // access right violation
     554                        (p_vci_tgt_iox.cmd.read() == vci_param_ext::CMD_WRITE) )
    702555                    {
    703                         r_iommu_etr     = MMU_WRITE_ACCES_VIOLATION; 
    704                         r_iommu_bvar    = p_vci_tgt_dma.address.read();
    705                         r_iommu_bad_id  = p_vci_tgt_dma.srcid.read();
    706                         r_dma_cmd_fsm   = DMA_CMD_ERROR;
    707                         // For DMA_RSP
    708                         r_dma_error_type    = WRITE_ERROR;
    709                         r_dma_error_trdid   = p_vci_tgt_dma.trdid.read();
    710                         r_dma_error_pktid   = p_vci_tgt_dma.pktid.read();
     556                        // put DMA response error into DMA_RSP fifo
     557                        r_iommu_etr      = MMU_WRITE_ACCES_VIOLATION; 
     558                        r_iommu_bvar     = p_vci_tgt_iox.address.read();
     559                        r_iommu_bad_id   = p_vci_tgt_iox.srcid.read();
     560                        r_dma_cmd_fsm    = DMA_CMD_FIFO_PUT_RSP;
    711561#if DEBUG_DMA_CMD
    712 if( m_debug_dma_cmd_fsm )
    713 {
    714     std::cout << "  <IOB.DMA_CMD_IDLE> HIT in iotlb, but writable violation" << std::endl;
    715 }
    716 #endif
    717                     break;
     562if( m_debug_activated )
     563std::cout << "  <IOB DMA_CMD_IDLE> TLB HIT but writable violation" << std::endl;
     564#endif
    718565                    }
    719 
    720                     // Physical address registration
    721                     r_dma_paddr   = paddr;                     
    722                     r_dma_cmd_fsm       = DMA_CMD_TRT_LOCK;
    723                 }
    724                 // TLB miss: we enter TLB_MISS treatment sub-fsm
    725                 else
     566                    else                         // no access rights violation
     567                    {
     568#if DEBUG_DMA_CMD
     569if( m_debug_activated )
     570std::cout << "  <IOB DMA_CMD_IDLE> TLB HIT" << std::endl;
     571#endif
     572                    // put DMA transaction into DMA_CMD fifo
     573                    r_dma_cmd_paddr   = iotlb_paddr;                   
     574                    r_dma_cmd_fsm     = DMA_CMD_FIFO_PUT_CMD;
     575                    }
     576                }
     577                else                                             // TLB miss
    726578                {
    727579
     
    729581m_cpt_iotlb_miss++;
    730582#endif
    731                     if( r_dma_tlb_req.read() || r_tlb_dma_untreated.read() || r_dma_tlb_error_req.read() )
    732                     {
    733                         // There's already a ongoing request
    734                         // or a completed request but not yet put on FIFO.
    735                         // We stay blocked
    736                         r_dma_cmd_fsm = DMA_CMD_TLB_MISS_WAIT;
     583                        // register virtual address, and send request to TLB FSM
     584                                r_dma_cmd_vaddr = p_vci_tgt_iox.address.read();
     585                        r_dma_tlb_req   = true;
     586                        r_dma_cmd_fsm   = DMA_CMD_MISS_WAIT;
    737587#if DEBUG_DMA_CMD
    738 if( m_debug_dma_cmd_fsm )
    739 {
    740     std::cout << "  <IOB.DMA_CMD_IDLE> MISS in iotlb. There is a pending request." << std::endl;
    741 }
    742 #endif
    743                     }
    744                     else
    745                     {
    746                         // We register request virtual address, to be used by DMA_TLB_MISS FSM
    747                                 r_iotlb_vaddr = p_vci_tgt_dma.address.read();
    748                         assert((r_dma_cmd_count.read() == 0)
    749                                 and "ERROR: TRT counter should be 0");
    750                         r_dma_tlb_req   = true;
    751                         r_dma_cmd_fsm   = DMA_CMD_TLB_MISS_STORE;
    752 #if DEBUG_DMA_CMD
    753 if( m_debug_dma_cmd_fsm )
    754 {
    755     std::cout << "  <IOB.DMA_CMD_IDLE> MISS in iotlb. No pending request." << std::endl;
    756 }
    757 #endif
    758                     }
     588if( m_debug_activated )
     589std::cout << "  <IOB DMA_CMD_IDLE> TLB MISS" << std::endl;
     590#endif
    759591                } // end !hit
    760592            } // end if tlb_activated
     
    762594        break;
    763595    }
    764     /////////////////////////
    765     case DMA_CMD_TRT_LOCK:      // Waiting for the lock to modify Transaction Table
    766     {
    767         if ( r_alloc_trt_dma_fsm.read() == ALLOC_TRT_DMA_CMD )
    768         {
    769 
    770 #if DEBUG_DMA_CMD
    771 if( m_debug_dma_cmd_fsm )
    772 {
    773     std::cout << "  <IOB.DMA_CMD_TRT_LOCK> Check the TRT" << std::endl;
    774 }
    775 #endif
    776             size_t              wok_index = 0;
    777             bool                wok       = !m_transaction_tab_dma.full(wok_index);
    778 
    779             if ( wok )  // TRT isn't full. Write the new transaction.
    780             {
    781                 r_dma_cmd_trt_index = (vci_trdid_t)wok_index;
    782                 r_dma_cmd_fsm       = DMA_CMD_TRT_SET;
    783             }
    784             else                // wait an empty entry in TRT
    785             {
    786                 r_dma_cmd_rsp_erase_req = true;
    787                 r_dma_cmd_fsm       = DMA_CMD_TRT_WAIT;
    788 #if DEBUG_DMA_CMD
    789 if( m_debug_dma_cmd_fsm )
    790 {
    791     std::cout << "  <IOB.DMA_CMD_TRT_LOCK> TRT is full. Going to TRT_WAIT state" << std::endl;
    792 }
    793 #endif
     596    //////////////////////////
     597    case DMA_CMD_FIFO_PUT_CMD:    // put a DMA transaction in DMA_CMD fifo       
     598                                  // if contig, VCI address must be incremented
     599    {
     600        if ( p_vci_tgt_iox.cmdval && m_dma_cmd_addr_fifo.wok() )
     601        {
     602            dma_cmd_fifo_put = true;
    794603           
    795 #ifdef INSTRUMENTATION       
    796 m_cpt_trt_dma_full++;
    797 #endif
    798             }
    799         }
    800         break;
    801     }
    802     ////////////////
    803     case DMA_CMD_TRT_WAIT:      // release the lock protecting the transaction tab
    804                             // waits that RSP erases an entry
    805     {
    806 #ifdef INSTRUMENTATION       
    807 m_cpt_trt_dma_full_cost++;
    808 #endif
    809         // DMA_RSP will notify an erase action by reseting this register
    810         if(!r_dma_cmd_rsp_erase_req.read())
    811         {
    812             r_dma_cmd_fsm = DMA_CMD_TRT_LOCK; // take the lock again
    813         }
    814         break;
    815     }
    816     ////////////////////////
    817     case DMA_CMD_TRT_SET:       // register a new transaction in TRT
    818     { 
    819         if ( r_alloc_trt_dma_fsm.read() == ALLOC_TRT_DMA_CMD )
    820         {
    821             if(r_miss_interrupt.read())
    822             {
    823                 m_transaction_tab_dma.set(r_dma_cmd_trt_index.read(),
    824                                       r_miss_srcid.read(),
    825                                       r_miss_trdid.read() );
    826                 r_dma_cmd_fsm = DMA_CMD_FIFO_MISS_PUT;
    827             }
    828             else
    829             {
    830                 m_transaction_tab_dma.set(r_dma_cmd_trt_index.read(),
    831                                           p_vci_tgt_dma.srcid.read(),
    832                                           p_vci_tgt_dma.trdid.read() );
    833                 r_dma_cmd_fsm = DMA_CMD_FIFO_PUT;
    834             }
    835 #if DEBUG_DMA_CMD
    836 if( m_debug_dma_cmd_fsm )
    837 {
    838     std::cout << "  <IOB.DMA_CMD_TRT_SET> Set a new entry in TRT" << std::endl;
    839     if(r_miss_interrupt.read()) std::cout << " From the Network " << std::endl;
    840     else std::cout << " From miss interruption" << std::endl;
    841 }
    842 #endif
    843         }
    844         break;
    845     } 
    846     ///////////////////////
    847     case DMA_CMD_FIFO_PUT:       
    848     {
    849         if ( p_vci_tgt_dma.cmdval && m_dma_cmd_addr_fifo.wok() )
    850         {
    851             dma_cmd_fifo_put = true;
    852             //miss_unposted = false;
    853             if(  p_vci_tgt_dma.contig )    r_dma_paddr = r_dma_paddr.read() + 4;
    854             if(  p_vci_tgt_dma.eop )    r_dma_cmd_fsm = DMA_CMD_IDLE;
     604            if ( p_vci_tgt_iox.contig.read() ) r_dma_cmd_paddr = r_dma_cmd_paddr.read() +
     605                                                          vci_param_ext::B;
     606
     607            if ( p_vci_tgt_iox.eop.read() )    r_dma_cmd_fsm   = DMA_CMD_IDLE;
    855608           
    856609#if DEBUG_DMA_CMD
    857 if( m_debug_dma_cmd_fsm )
    858 {
    859     std::cout << "  <IOB.DMA_CMD_FIFO_PUT> Push into cmd_fifo:"
    860               << " address = " << std::hex << r_dma_paddr.read()
    861               << " srcid = " << std::dec << m_srcid_dma
    862               << " trdid = " << r_dma_cmd_trt_index.read()
    863               << " wdata = " << std::hex << p_vci_tgt_dma.wdata.read()
    864               << " be = " << p_vci_tgt_dma.be.read()
    865               << " contig = " << p_vci_tgt_dma.contig.read()
    866               << " eop = " << std::dec << p_vci_tgt_dma.eop.read()
    867               << " plen = " << std::dec << p_vci_tgt_dma.plen.read() << std::endl;
    868 }
    869 #endif
     610if( m_debug_activated )
     611std::cout << "  <IOB DMA_CMD_FIFO_PUT_CMD> Push into DMA_CMD fifo:"
     612          << " address = " << std::hex << r_dma_cmd_paddr.read()
     613          << " srcid = " << p_vci_tgt_iox.srcid.read()
     614          << " trdid = " << p_vci_tgt_iox.trdid.read()
     615          << " wdata = " << p_vci_tgt_iox.wdata.read()
     616          << " be = " << p_vci_tgt_iox.be.read()
     617          << " contig = " << p_vci_tgt_iox.contig.read()
     618          << " eop = " << std::dec << p_vci_tgt_iox.eop.read()
     619          << " plen = " << std::dec << p_vci_tgt_iox.plen.read() << std::endl;
     620#endif
     621        }
     622        break;
     623    }
     624    //////////////////////
     625    case DMA_CMD_WAIT_EOP:       // An error has been detected on the VCI DMA command
     626                             // consume the VCI packet before sending the error response
     627    {
     628        if ( p_vci_tgt_iox.eop.read() )    r_dma_cmd_fsm   = DMA_CMD_FIFO_PUT_RSP;
     629        break;
     630    }
     631    //////////////////////////
     632    case DMA_CMD_FIFO_PUT_RSP:   // try to put a response error in DMA_RSP fifo
     633                                 // The FIFO is shared with DMA_RSP FSM
     634                                 // and we must we wait for allocation...
     635    {
     636        if ( r_alloc_fifo_dma_rsp_local.read() )
     637        {
     638            dma_rsp_fifo_put = true;
     639
     640            if( m_dma_rsp_data_fifo.wok() )
     641            {
     642
     643#if DEBUG_DMA_CMD
     644if( m_debug_activated )
     645std::cout << "  <IOB DMA_CMD_FIFO_PUT_RSP> Put a response error to a DMA transaction."
     646          << std::endl;
     647#endif
     648                r_dma_cmd_fsm = DMA_CMD_IDLE;
     649            }
    870650        }
    871651        break;
    872652    }
    873653    ///////////////////////
    874     case DMA_CMD_FIFO_MISS_PUT: 
    875     {
    876         if ( m_dma_cmd_addr_fifo.wok() )
    877         {
    878             dma_cmd_fifo_put    = true;
    879             //miss_unposted       = true;
    880             if( r_miss_contig.read() )    r_miss_paddr = r_miss_paddr.read() + 4;
    881            
    882             if( r_dma_cmd_count.read() == 1 )
     654    case DMA_CMD_MISS_WAIT:  // waiting completion of a TLB miss
     655                             // we must test a possible page fault error...   
     656    {
     657        if ( not r_dma_tlb_req.read() ) // TLB miss completed
     658        {
     659            if ( r_tlb_miss_error.read() )   // Error reported by TLB FSM
    883660            {
    884                 r_tlb_dma_untreated = false;
    885                 r_miss_interrupt = false;
    886                 r_dma_cmd_fsm = r_dma_cmd_fsm_save.read();
     661                r_iommu_etr     = MMU_READ_PT2_UNMAPPED;
     662                r_iommu_bvar    = r_dma_cmd_vaddr.read();
     663                r_iommu_bad_id  = p_vci_tgt_iox.srcid.read();
     664                r_dma_cmd_fsm   = DMA_CMD_FIFO_PUT_RSP;
    887665            }
    888             r_dma_cmd_count = r_dma_cmd_count.read() - 1;
    889 
    890 #if DEBUG_DMA_CMD
    891 if( m_debug_dma_cmd_fsm )
    892 {
    893     std::cout << "  <IOB.DMA_CMD_FIFO_MISS_PUT> Push into cmd_fifo:"
    894               << " counter = " << std::hex << r_dma_cmd_count.read()
    895               << " address = " << std::hex << r_miss_paddr.read()
    896               << " srcid = " << std::dec << r_miss_srcid.read()
    897               << " trdid = " << r_miss_trdid.read()
    898               << " wdata = " << std::hex << r_miss_data
    899               << " be = " << r_miss_be
    900               << " plen = " << std::dec << r_miss_plen.read() << std::endl;
    901 }
    902 #endif
    903         }
    904         break;
    905     }
    906     ///////////////////
    907     case DMA_CMD_TLB_MISS_WAIT: // to store the miss request there must be
    908                                 // neither an ongoing request, nor a unposted finished request
    909     {
    910         // Treats an eventual request from TLB_MISS fsm
    911         // to send a command whose miss treatment is now finished
    912         if ( r_tlb_dma_untreated.read() )
    913         {
    914             r_dma_cmd_fsm    = DMA_CMD_TRT_LOCK; //before posting we must update TRT
    915             r_dma_cmd_fsm_save = DMA_CMD_TLB_MISS_WAIT;
    916             r_miss_interrupt = true;
    917             break;
    918         }
    919         // Error during miss treatment
    920         else if (r_dma_tlb_error_req.read())
    921         {
    922             r_iommu_etr     = r_tlb_error_type.read();
    923             r_iommu_bvar    = r_iotlb_vaddr.read();
    924             r_iommu_bad_id  = r_miss_srcid.read();
    925             // For DMA_RSP FSM
    926             if(r_miss_cmd.read() == vci_param_io::CMD_WRITE) r_dma_error_type = WRITE_ERROR;
    927             else r_dma_error_type = READ_ERROR;
    928             r_dma_error_trdid   = r_miss_trdid.read();
    929             r_dma_error_pktid   = r_miss_pktid.read();
    930  
    931             r_dma_tlb_error_req = false;
    932             r_dma_cmd_fsm   = DMA_CMD_ERROR;
    933         }
    934 
    935 #ifdef INSTRUMENTATION       
    936 m_cost_iotlb_miss++;  // Now it represents misses' total blocking cost (not the treatment cost itself)
    937 #endif
    938         else if (not r_dma_tlb_req.read())
    939         {
    940             r_dma_cmd_fsm   = DMA_CMD_TLB_MISS_STORE;
    941             assert((r_dma_cmd_count.read() == 0) and "ERROR: TRT counter should be 0");
    942         }
    943         break;
    944     }
    945     ///////////////////
    946     case DMA_CMD_TLB_MISS_STORE:
    947     {
    948         if ( p_vci_tgt_dma.cmdval.read())
    949         {
    950             if(r_dma_cmd_count.read() == 0)
     666            else                            // No error
    951667            {
    952                 r_miss_cmd = p_vci_tgt_dma.cmd.read();
    953                 r_miss_contig = p_vci_tgt_dma.contig.read();
    954                 r_miss_cons = p_vci_tgt_dma.cons.read();
    955                 r_miss_plen = p_vci_tgt_dma.plen.read();
    956                 r_miss_wrap = p_vci_tgt_dma.wrap.read();
    957                 r_miss_cfixed = p_vci_tgt_dma.cfixed.read();
    958                 r_miss_clen = p_vci_tgt_dma.clen.read();
    959                 r_miss_srcid = p_vci_tgt_dma.srcid.read();
    960                 r_miss_trdid = p_vci_tgt_dma.trdid.read();
    961                 r_miss_pktid = p_vci_tgt_dma.pktid.read();
    962                
    963 //                r_dma_tlb_req   = true;
     668                r_dma_cmd_fsm   = DMA_CMD_IDLE;
    964669            }
    965            
    966             r_miss_data[r_dma_cmd_count.read()] = p_vci_tgt_dma.wdata.read();
    967             r_miss_be[r_dma_cmd_count.read()] = p_vci_tgt_dma.be.read();
    968            
    969             r_dma_cmd_count = r_dma_cmd_count.read() + 1;
    970            
    971             if(  p_vci_tgt_dma.eop )  r_dma_cmd_fsm = DMA_CMD_IDLE;
    972            
    973 #if DEBUG_DMA_CMD
    974 if( m_debug_dma_cmd_fsm )
    975 {
    976     std::cout << "  <IOB.DMA_CMD_TLB_MISS_STORE> Storing VCI fields of command that originate the Miss:"
    977               << " counter = " << std::hex << r_dma_cmd_count.read()
    978               << " address = " << std::hex << p_vci_tgt_dma.address.read()
    979               << " srcid = " << std::dec << p_vci_tgt_dma.srcid.read()
    980               << " trdid = " << p_vci_tgt_dma.trdid.read()
    981               << " wdata = " << std::hex << p_vci_tgt_dma.wdata.read()
    982               << " be = " << p_vci_tgt_dma.be.read()
    983               << " plen = " << std::dec << p_vci_tgt_dma.plen.read() << std::endl;
    984 }
    985 #endif
    986         }
    987         break;
    988     }
    989     ///////////////////
    990     case DMA_CMD_ERROR:
    991     {
    992         // Wait in case of pending request
    993         // it isn't the case, generally
    994         if(!r_dma_cmd_error_req.read())
    995         {
    996             r_dma_cmd_error_req = true;
    997             r_dma_cmd_fsm       = DMA_CMD_IDLE;
    998         }
    999         break;
    1000     }
    1001     } // end switch DMA_CMD_FSM
    1002 
    1003     /////////////////////////////////////////////////////////////////////
    1004     // The DMA_RSP_FSM controls the following ressources:
    1005     // - r_dma_rsp_fsm
    1006     // - r_dma_cmd_rsp_erase_req (reset)
    1007     // - r_fma_error_req (reset)
    1008     // -
     670        }
     671        break;
     672    }
     673    } // end switch DMA_CMD FSM
     674
    1009675    //////////////////////////////////////////////////////////////////////////////
     676    // The DMA_RSP_FSM handles the RAM responses to peripherals DMA transactions.
     677    //////////////////////////////////////////////////////////////////////////////
     678
    1010679    switch( r_dma_rsp_fsm.read() )
    1011680    {
    1012     /////////////////////
    1013     case DMA_RSP_IDLE:
     681    //////////////////
     682    case DMA_RSP_IDLE:  // waiting a response from RAM betwork
    1014683    {           
    1015         // Interruption from DMA_CMD following an error
    1016         if(r_dma_cmd_error_req.read()) r_dma_rsp_fsm = DMA_RSP_FIFO_ERROR_PUT;
    1017        
    1018         if(p_vci_ini_dma.rspval.read())
     684        if ( p_vci_ini_ram.rspval.read() )
    1019685                {
    1020                         r_dma_rsp_fsm = DMA_RSP_TRT_LOCK;
     686                        r_dma_rsp_fsm = DMA_RSP_FIFO_PUT;
    1021687                }
    1022688                break;
    1023689    }
    1024     /////////////////////
    1025     case DMA_RSP_TRT_LOCK:
    1026     {           
    1027         if ( r_alloc_trt_dma_fsm.read() == ALLOC_TRT_DMA_RSP )
    1028         {
    1029            
    1030 #if DEBUG_DMA_RSP
    1031 if( m_debug_dma_rsp_fsm )
    1032 {
    1033     std::cout << "  <IOB.DMA_RSP_TRT_LOCK> Erase entry" << std::endl;
    1034 }
    1035 #endif
    1036             uint32_t trdid_xram = p_vci_ini_dma.rtrdid.read();
    1037            
    1038             r_dma_rsrcid = (vci_srcid_t)m_transaction_tab_dma.readSrcid(trdid_xram);
    1039             r_dma_rtrdid = (vci_trdid_t)m_transaction_tab_dma.readTrdid(trdid_xram);
    1040             m_transaction_tab_dma.erase(trdid_xram);
    1041             if (r_dma_cmd_rsp_erase_req.read()) r_dma_cmd_rsp_erase_req = false;
    1042             r_dma_rsp_fsm       = DMA_RSP_FIFO_PUT;
    1043         }       
    1044                 break;
    1045     }
    1046     //////////////////
     690    //////////////////////
    1047691    case DMA_RSP_FIFO_PUT:
    1048692    {
    1049         if(p_vci_ini_dma.rspval.read() && m_dma_rsp_data_fifo.wok())
     693        if(p_vci_ini_ram.rspval.read() and not r_alloc_fifo_dma_rsp_local.read() )
    1050694        {
    1051695            dma_rsp_fifo_put = true;
    1052             if(p_vci_ini_dma.reop.read())   r_dma_rsp_fsm = DMA_RSP_IDLE;       
     696
     697            if(p_vci_ini_ram.reop.read())   r_dma_rsp_fsm = DMA_RSP_IDLE;       
    1053698
    1054699#if DEBUG_DMA_RSP
    1055 if( m_debug_dma_rsp_fsm )
    1056 {
    1057     std::cout << "  <IOB.DMA_RSP_FIFO_PUT> Push into rsp_fifo:"
    1058               << " rsrcid = " << std::dec << r_dma_rsrcid.read()
    1059               << " rtrdid = " << r_dma_rtrdid.read()
    1060               << " rdata = " << std::hex << p_vci_ini_dma.rdata.read()
    1061     << std::endl;
    1062 }
    1063 #endif
    1064                        
     700if( m_debug_activated )
     701std::cout << "  <IOB DMA_RSP_FIFO_PUT> Push response into DMA_RSP fifo:"
     702          << " / rsrcid = " << std::hex << p_vci_ini_ram.rsrcid.read()
     703          << " / rtrdid = " << p_vci_ini_ram.rtrdid.read()
     704          << " / rdata = " << std::hex << p_vci_ini_ram.rdata.read()
     705          << " / rerror = " << p_vci_ini_ram.rerror.read()
     706          << " / reop = " << p_vci_ini_ram.reop.read() << std::endl;
     707#endif
    1065708        }
    1066709        break;
    1067710    }
    1068     //////////////////
    1069     case DMA_RSP_FIFO_ERROR_PUT:
    1070     {
    1071         if(m_dma_rsp_data_fifo.wok())
    1072         {
    1073             dma_rsp_fifo_put = true;
    1074             r_dma_rsp_fsm = DMA_RSP_IDLE;       
    1075 
    1076 #if DEBUG_DMA_RSP
    1077 if( m_debug_dma_rsp_fsm )
    1078 {
    1079     std::cout << "  <IOB.DMA_RSP_FIFO_ERROR_PUT> Push into rsp_fifo:"
    1080               << " rsrcid = " << std::dec << r_iommu_bad_id.read()
    1081               << " rtrdid = " << r_dma_error_trdid.read()
    1082               << " rerror = " << r_dma_error_type.read()
    1083               << " rdata = " << std::hex << 0
    1084     << std::endl;
    1085 }
    1086 #endif
    1087                        
    1088         }
    1089         break;
    1090     }
    1091711    } // end switch DMA_RSP_FSM
    1092712
    1093     ////////////////////////////////////////////////////////////////////////////
    1094     // The ALLOC_TRT_DMA fsm allocates the access to the Transaction Table (m_transaction_tab_dma)
    1095     // with a round robin priority between 2 user FSMs :
    1096     // - DMA_CMD : to set a new entry
    1097     // - DMA_RSP : to read and erase an entry
    1098     // The ressource is always allocated.
    1099     ////////////////////////////////////////////////////////////////////////////
    1100    
    1101     switch ( r_alloc_trt_dma_fsm.read() )
    1102     {
    1103     ///////////////////
    1104     case ALLOC_TRT_DMA_CMD:
    1105     {
    1106         if ( r_dma_cmd_fsm.read() != DMA_CMD_TRT_LOCK )
    1107         {
    1108           if (r_dma_rsp_fsm.read() == DMA_RSP_TRT_LOCK) r_alloc_trt_dma_fsm = ALLOC_TRT_DMA_RSP;
    1109         }
    1110         break;
    1111     }
    1112     ///////////////////
    1113     case ALLOC_TRT_DMA_RSP:
    1114     {
    1115         if (r_dma_rsp_fsm.read() != DMA_RSP_TRT_LOCK)
    1116         {
    1117             if (r_dma_cmd_fsm.read() == DMA_CMD_TRT_LOCK) r_alloc_trt_dma_fsm = ALLOC_TRT_DMA_CMD;
    1118         }
    1119         break;
    1120     }
    1121     } // end switch r_alloc_trt_dma_fsm
    1122    
    1123 
    1124     ////////////////////////////////////////////////////////////////////////////
    1125     // The DMA_TLB_MISS FSM handles an IOTLB miss. It blocks the TGT_FSM.
    1126     // Input argument is:
    1127     // - r_iotlb_vaddr
    1128     // - r_dma_tlb_req (reset)
    1129     // - r_tlb_miss_init_req (set)
    1130     // - r_config_tlb_req (reset)
    1131     // - r_tlb_dma_untreated (set)
    1132     //
    1133     // This fsm searchs the requested PTE on the  prefetch buffer.
    1134     // In case of miss,  it accesses the XRAM to find the missing TLB entry,
     713    //////////////////////////////////////////////////////////////////////////////////
     714    // The TLB FSM handles TLB miss request (from DMA_CMD FSM),
     715    // and the PTE inval request (from CONFIG_CMD FSM).
     716    // PTE inval request have highest priority. In case of TLB miss,
     717    // this fsm searchs the requested PTE on the prefetch buffer.
     718    // In case of buffer miss,  it request the MISS_WTI FSM to access the memory.
    1135719    // It bypass the first level page table access if possible.
    1136     // It directly updates the iotlb, and writes into the
    1137     // r_mmu_ins_* or r_mmu_data* error reporting registers.
     720    // It reset the r_dma_tlb_req flip-flop to signal TLB miss completion.
     721    // An unexpected, but possible page fault is signaled in r_tlb_miss_error flip_flop.
    1138722    ////////////////////////////////////////////////////////////////////////////////////
    1139     switch (r_dma_tlb_fsm.read())
    1140     {
    1141     case DMA_TLB_IDLE:
    1142     {
    1143         if(r_config_tlb_req)
    1144         {
    1145             r_config_tlb_req = false;
     723
     724    switch (r_tlb_fsm.read())
     725    {
     726    //////////////
     727    case TLB_IDLE:   // In case of TLB miss request, chek the prefetch buffer first
     728                     // PTE inval request are handled as unmaskable interrupts
     729    {
     730        if ( r_config_tlb_req ) // Request from CONFIG FSM for a PTE invalidation
     731        {
     732            r_config_tlb_req      = false;
    1146733            r_waiting_transaction = false;
    1147             r_dma_tlb_fsm = DMA_TLB_INVAL_CHECK;
    1148         // Request from CONFIG FSM following an PTE invalidation signal by OS
    1149         }
    1150         // Miss in IOTLB
    1151         else if(r_dma_tlb_req.read())   
    1152         {
    1153         // Checking prefetch buffer, by the virtual address
    1154         if(!r_miss_buf_first_level)
    1155         {
    1156             if( r_miss_buf_valid &&
    1157                 (r_miss_buf_vaddr_begin.read() ==
    1158                 (r_iotlb_vaddr.read()& ~PTE2_LINE_OFFSET & ~K_PAGE_OFFSET_MASK)))
     734            r_tlb_fsm = TLB_INVAL_CHECK;
     735        }
     736
     737        else if ( r_dma_tlb_req.read() )   // request from DMA_CMD for a TLB Miss
     738        {
     739            // Checking prefetch buffer
     740            if( not r_tlb_buf_big_page )     // small page => PTE2
    1159741            {
    1160               // Hit
    1161                 size_t pte_offset = (r_iotlb_vaddr.read()& PTE2_LINE_OFFSET)>>12;
    1162              
    1163 
    1164                 uint32_t pte_flags = r_miss_buf_data[2*pte_offset];
    1165                 uint32_t pte_ppn = r_miss_buf_data[2*pte_offset+1]; //because PTE2 is 2 words long
     742                if( r_tlb_buf_valid &&         // Hit on prefetch buffer
     743                    (r_tlb_buf_vaddr.read() ==
     744                    (r_dma_cmd_vaddr.read()& ~PTE2_LINE_OFFSET & ~K_PAGE_OFFSET_MASK)))
     745                {
     746                    size_t   pte_offset = (r_dma_cmd_vaddr.read()& PTE2_LINE_OFFSET)>>12;
     747                    uint32_t pte_flags  = r_tlb_buf_data[2*pte_offset];
     748                    uint32_t pte_ppn    = r_tlb_buf_data[2*pte_offset+1];
    1166749               
    1167                 // Bit valid checking
    1168                 if ( not ( pte_flags & PTE_V_MASK) )    // unmapped
    1169                 {
    1170                     //must not occur!
    1171                     std::cout << "IOMMU ERROR : " << name() << " DMA_TLB_IDLE state" << std::endl
    1172                                   << "The Page Table entry ins't valid (unmapped)" << std::endl;
     750                    // Bit valid checking
     751                    if ( not ( pte_flags & PTE_V_MASK) )        // unmapped
     752                    {
     753                        std::cout << "VCI_IO_BRIDGE ERROR : " << name()
     754                                  << " Page Table entry unmapped" << std::endl;
    1173755                       
    1174                     r_tlb_error_type          = MMU_READ_PT2_UNMAPPED;
    1175                     r_dma_tlb_error_req       = true;
    1176                     r_dma_tlb_req             = false;
    1177                        
    1178 #if DEBUG_DMA_TLB
    1179 if ( m_debug_dma_tlb_fsm )
    1180 {
    1181     std::cout << "  <IOB.DMA_TLB_IDLE> PTE2 Unmapped"
    1182               << std::hex << " / paddr = " << r_iotlb_paddr.read()
    1183               << std::hex << " / PTE (first word) = " << pte_flags << std::endl;
    1184 }
    1185 #endif
    1186                     break;
    1187                 }
    1188 
    1189                 r_iotlb_pte_flags       = pte_flags;
    1190                 r_iotlb_pte_ppn         = pte_ppn;
    1191                 r_dma_tlb_fsm           = DMA_TLB_PTE2_SELECT;
    1192                
    1193 #if DEBUG_DMA_TLB
    1194 if ( m_debug_dma_tlb_fsm )
    1195 {
    1196     std::cout << "  <IOB.DMA_TLB_IDLE> Hit on the prefetch buffer for PTE2:"
    1197               << " PTE_FLAGS = " << std::hex << pte_flags
    1198               << " PTE_PPN = " << std::hex << pte_ppn << std::endl;
    1199 }
    1200 #endif
    1201                 break;   
     756                        r_tlb_miss_error = true;
     757                        r_dma_tlb_req    = false;
     758#if DEBUG_TLB_MISS
     759if ( m_debug_activated )
     760std::cout << "  <IOB TLB_IDLE> PTE2 Unmapped" << std::hex
     761          << " / paddr = " << r_tlb_paddr.read()
     762          << " / PTE_FLAGS = " << pte_flags
     763          << " / PTE_PPN = " << pte_ppn << std::endl;
     764#endif
     765                        break;
     766                    }
     767
     768                    // valid PTE2 : we must update the TLB
     769                    r_tlb_pte_flags = pte_flags;
     770                    r_tlb_pte_ppn   = pte_ppn;
     771                    r_tlb_fsm       = TLB_PTE2_SELECT;
     772#if DEBUG_TLB_MISS
     773if ( m_debug_activated )
     774std::cout << "  <IOB TLB_IDLE> Hit on prefetch buffer: PTE2" << std::hex
     775          << " / PTE_FLAGS = " << pte_flags
     776          << " / PTE_PPN = " << pte_ppn << std::endl;
     777#endif
     778                    break;   
     779                }
    1202780            }
    1203         }
    1204         else    // First level entries on buffer. Unused if only small pages
    1205         {
    1206            if( r_miss_buf_valid &&
    1207               (r_miss_buf_vaddr_begin.read() ==
    1208                (r_iotlb_vaddr.read()& ~PTE1_LINE_OFFSET & ~M_PAGE_OFFSET_MASK )))
    1209             // The virtual address corresponds to one entry on the buffer line
     781            else                             // big page => PTE1
    1210782            {
    1211               // Hit
    1212                 size_t pte_offset = (r_iotlb_vaddr.read()& PTE1_LINE_OFFSET)>>21;
    1213              
    1214                 uint32_t pte_flags = r_miss_buf_data[pte_offset];
     783                if( r_tlb_buf_valid &&         // Hit on prefetch buffer
     784                    (r_tlb_buf_vaddr.read() ==
     785                    (r_dma_cmd_vaddr.read()& ~PTE1_LINE_OFFSET & ~M_PAGE_OFFSET_MASK )))
     786                {
     787                    size_t   pte_offset = (r_dma_cmd_vaddr.read()& PTE1_LINE_OFFSET)>>21;
     788                    uint32_t pte_flags  = r_tlb_buf_data[pte_offset];
    1215789                           
    1216                 // Bit valid checking
    1217                 if ( not ( pte_flags & PTE_V_MASK) )    // unmapped
    1218                 {
    1219                     //must not occur!
    1220                     std::cout << "IOMMU ERROR " << name() << "DMA_TLB_IDLE state" << std::endl
    1221                                   << "The Page Table entry ins't valid (unmapped)" << std::endl;
     790                    // Bit valid checking
     791                    if ( not ( pte_flags & PTE_V_MASK) )        // unmapped
     792                    {
     793                        std::cout << "VCI_IO_BRIDGE ERROR : " << name()
     794                                  << " Page Table entry unmapped" << std::endl;
    1222795                       
    1223                     r_tlb_error_type          = MMU_READ_PT1_UNMAPPED;
    1224                     r_dma_tlb_error_req       = true;
    1225                     r_dma_tlb_req             = false;
    1226                        
    1227 #if DEBUG_DMA_TLB
    1228 if ( m_debug_dma_tlb_fsm )
    1229 {
    1230     std::cout << "  <IOB.DMA_TLB_IDLE> First level entry Unmapped"
    1231               << std::hex << " / paddr = " << r_iotlb_paddr.read()
    1232               << std::hex << " / PTE = " << pte_flags << std::endl;
    1233 }
    1234 #endif
    1235                     break;
    1236                 }
    1237                
    1238                 if( pte_flags & PTE_T_MASK )    //  PTD : me must access PT2
    1239                 {
    1240                     // register bypass
    1241                     r_iotlb.set_bypass( r_iotlb_vaddr.read(),
    1242                                       pte_flags & ((1 << (m_paddr_nbits-PAGE_K_NBITS)) - 1),
    1243                                      0); //nline, unused
    1244 
    1245                     //&PTE2 = PTBA + IX2 * 8
    1246                     // ps: PAGE_K_NBITS corresponds also to the size of a second level page table
    1247                     r_iotlb_paddr = (paddr_t)(pte_flags & ((1<<(m_paddr_nbits-PAGE_K_NBITS))-1)) << PAGE_K_NBITS |
    1248                                   (paddr_t)(((r_iotlb_vaddr.read() & PTD_ID2_MASK) >> PAGE_K_NBITS) << 3);
    1249                     r_tlb_miss_init_req     = true;
    1250                     r_tlb_miss_type         = PTE2_MISS;
    1251                     r_dma_tlb_fsm           = DMA_TLB_WAIT_TRANSACTION;
     796                        r_tlb_miss_error = true;
     797                        r_dma_tlb_req    = false;
     798#if DEBUG_TLB_MISS
     799if ( m_debug_activated )
     800std::cout << "  <IOB TLB_IDLE> PTE1 Unmapped" << std::hex
     801          << " / paddr = " << r_tlb_paddr.read()
     802          << " / PTE = " << pte_flags << std::endl;
     803#endif
     804                        break;
     805                    }
     806
     807                    // valid PTE1 : we must update the TLB
     808                    r_tlb_pte_flags = pte_flags;
     809                    r_tlb_fsm       = TLB_PTE1_SELECT;
     810#if DEBUG_TLB_MISS
     811if ( m_debug_activated )
     812std::cout << "  <IOB TLB_PTE1_GET> Hit on prefetch buffer: PTE1" << std::hex
     813          << " / paddr = " << r_tlb_paddr.read()
     814          << std::hex << " / PTE1 = " << pte_flags << std::endl;
     815#endif
     816                    break;
     817                }
     818            }
     819       
     820            // prefetch buffer miss
     821            r_tlb_fsm = TLB_MISS;
     822
     823#if DEBUG_TLB_MISS
     824if ( m_debug_activated )
     825std::cout << "  <IOB TLB_IDLE> Miss on prefetch buffer"
     826          << std::hex << " / vaddr = " << r_dma_cmd_vaddr.read() << std::endl;
     827#endif
     828        }
     829        break;
     830    }
     831    //////////////
     832    case TLB_MISS: // handling tlb miss
     833    {
     834        uint32_t        ptba = 0;
     835        bool            bypass;
     836        vci_addr_t      pte_paddr;
     837
    1252838#ifdef INSTRUMENTATION
    1253839m_cpt_iotlbmiss_transaction++;
    1254840#endif
    1255 
    1256 #if DEBUG_DMA_TLB
    1257 if ( m_debug_dma_tlb_fsm )
    1258 {
    1259     std::cout << "  <IOB.DMA_TLB_IDLE> Hit on prefetch, but it is a PTD.Search PTE2"
    1260               << std::hex << " / paddr = " << r_iotlb_paddr.read()
    1261               << std::hex << " / PTD = " << pte_flags << std::endl;
    1262 }
    1263 #endif
    1264                 }
    1265                 else                    //  PTE1 :  we must update the TLB
    1266                             //  Should not occur if working only with small pages
    1267                 {
    1268                     r_iotlb_pte_flags   = pte_flags;
    1269                     r_dma_tlb_fsm  = DMA_TLB_PTE1_SELECT;
    1270 
    1271 #if DEBUG_DMA_TLB
    1272 if ( m_debug_dma_tlb_fsm )
    1273 {
    1274     std::cout << "  <IOB.DMA_TLB_PTE1_GET> Success. Big page"
    1275               << std::hex << " / paddr = " << r_iotlb_paddr.read()
    1276               << std::hex << " / PTE1 = " << pte_flags << std::endl;
    1277 }
    1278 #endif
    1279                 }
    1280                 break;
    1281             }
    1282         }
    1283        
    1284         r_dma_tlb_fsm = DMA_TLB_MISS;
    1285 
    1286 #if DEBUG_DMA_TLB
    1287 if ( m_debug_dma_tlb_fsm )
    1288 {
    1289     std::cout << "  <IOB.DMA_TLB_IDLE> Miss on prefetch."
    1290               << std::hex << " / vaddr = " << r_iotlb_vaddr.read() << std::endl;
    1291 }
    1292 #endif
    1293         }
    1294         break;
    1295     }
    1296     /////////////////////
    1297     case DMA_TLB_MISS: // handling all tlb miss
    1298     {
    1299         uint32_t        ptba = 0; //28 bits en TSAR
    1300         bool            bypass;
    1301         paddr_t         pte_paddr;
    1302 
    1303841        // evaluate bypass in order to skip first level page table access
    1304         bypass = r_iotlb.get_bypass(r_iotlb_vaddr.read(), &ptba);
     842        bypass = r_iotlb.get_bypass(r_dma_cmd_vaddr.read(), &ptba);
    1305843       
    1306         //Request to MISS_INIT_FSM to start transaction on Direct Network     
     844        // Request MISS_WTI_FSM a transaction on INT Network
    1307845        if ( not bypass )     // Read PTE1/PTD1 in XRAM
    1308846        {
    1309         // VOIR CONVENTION >> 13
    1310             pte_paddr = (paddr_t)((r_iommu_ptpr.read()) << (INDEX1_NBITS+2)) |
    1311                         (paddr_t)((r_iotlb_vaddr.read() >> PAGE_M_NBITS) << 2);
    1312             r_iotlb_paddr = pte_paddr;
     847
     848#if DEBUG_TLB_MISS
     849if ( m_debug_activated )
     850std::cout << "  <IOB TLB_MISS> Read PTE1/PTD1 in memory" << std::endl;
     851#endif
     852            pte_paddr = (vci_addr_t)((r_iommu_ptpr.read()) << (INDEX1_NBITS+2)) |
     853                        (vci_addr_t)((r_dma_cmd_vaddr.read() >> PAGE_M_NBITS) << 2);
     854            r_tlb_paddr = pte_paddr;
    1313855           
    1314             r_tlb_miss_init_req     = true;
    1315             r_tlb_miss_type         = PTE1_MISS;
    1316             r_dma_tlb_fsm           = DMA_TLB_WAIT_TRANSACTION;
    1317 #ifdef INSTRUMENTATION
    1318 m_cpt_iotlbmiss_transaction++;
    1319 #endif
     856            r_tlb_miss_req     = true;
     857            r_tlb_miss_type    = PTE1_MISS;
     858            r_tlb_fsm          = TLB_WAIT;
    1320859        }
    1321860        else                  // Read PTE2 in XRAM
    1322861        {
     862
     863#if DEBUG_TLB_MISS
     864if ( m_debug_activated )
     865std::cout << "  <IOB TLB_MISS> Read PTE2 in memory" << std::endl;
     866#endif
    1323867            //&PTE2 = PTBA + IX2 * 8
    1324             pte_paddr = (paddr_t)ptba << PAGE_K_NBITS |
    1325                         (paddr_t)(r_iotlb_vaddr.read()&PTD_ID2_MASK)>>(PAGE_K_NBITS-3);
     868            pte_paddr = (vci_addr_t)ptba << PAGE_K_NBITS |
     869                        (vci_addr_t)(r_dma_cmd_vaddr.read()&PTD_ID2_MASK)>>(PAGE_K_NBITS-3);
    1326870           
    1327             r_iotlb_paddr = pte_paddr;
     871            r_tlb_paddr = pte_paddr;
    1328872           
    1329             r_tlb_miss_init_req     = true;
    1330             r_tlb_miss_type         = PTE2_MISS;
    1331             r_dma_tlb_fsm           = DMA_TLB_WAIT_TRANSACTION;
    1332 #ifdef INSTRUMENTATION
    1333 m_cpt_iotlbmiss_transaction++;
    1334 #endif
    1335         }
    1336 
    1337 #if DEBUG_DMA_TLB
    1338 if ( m_debug_dma_tlb_fsm )
    1339 {
    1340     std::cout << "  <IOB.DMA_TLB_MISS> IOTLB miss";
    1341     std::cout << " / VADDR = " << std::hex << r_iotlb_vaddr.read()
    1342               << " / BYPASS = " << bypass
    1343               << " / PTE_ADR = " << pte_paddr << std::endl;
    1344 }
    1345 #endif
    1346  
    1347         break;
    1348     }
    1349     ///////////////////////// 
    1350     case DMA_TLB_PTE1_GET:      // Try to read a PT1 entry in the miss buffer
     873            r_tlb_miss_req     = true;
     874            r_tlb_miss_type    = PTE2_MISS;
     875            r_tlb_fsm          = TLB_WAIT;
     876        }
     877
     878        break;
     879    }
     880    ////////////////// 
     881    case TLB_PTE1_GET:  // Try to read a PT1 entry in the miss buffer
    1351882    {
    1352883       
    1353884        uint32_t  entry;
    1354885       
    1355         paddr_t line_number  = (paddr_t)((r_iotlb_paddr.read())&(CACHE_LINE_MASK));
    1356         size_t word_position = (size_t)( ((r_iotlb_paddr.read())&(~CACHE_LINE_MASK))>>2 );
     886        vci_addr_t line_number  = (vci_addr_t)((r_tlb_paddr.read())&(CACHE_LINE_MASK));
     887        size_t word_position = (size_t)( ((r_tlb_paddr.read())&(~CACHE_LINE_MASK))>>2 );
    1357888
    1358889        // Hit test. Just to verify.
    1359890        // Hit must happen, since we've just finished its' miss transaction
    1360         bool hit = (r_miss_buf_valid && (r_miss_buf_tag.read()== line_number) );
     891        bool hit = (r_tlb_buf_valid && (r_tlb_buf_tag.read()== line_number) );
    1361892        assert(hit and "Error: No hit on prefetch buffer after Miss Transaction");
    1362893       
    1363         entry = r_miss_buf_data[word_position];
     894        entry = r_tlb_buf_data[word_position];
    1364895           
    1365896        // Bit valid checking
     
    1367898        {
    1368899            //must not occur!
    1369             std::cout << "IOMMU ERROR " << name() << "DMA_TLB_IDLE state" << std::endl
     900            std::cout << "IOMMU ERROR " << name() << "TLB_IDLE state" << std::endl
    1370901                      << "The Page Table entry ins't valid (unmapped)" << std::endl;
    1371902                       
    1372             r_tlb_error_type          = MMU_READ_PT1_UNMAPPED;
    1373             r_dma_tlb_error_req       = true;
    1374             r_dma_tlb_req             = false;
    1375             r_dma_tlb_fsm             = DMA_TLB_IDLE;           
    1376 #if DEBUG_DMA_TLB
    1377 if ( m_debug_dma_tlb_fsm )
     903            r_tlb_miss_error       = true;
     904            r_dma_tlb_req         = false;
     905            r_tlb_fsm             = TLB_IDLE;           
     906
     907#if DEBUG_TLB_MISS
     908if ( m_debug_activated )
    1378909{
    1379     std::cout << "  <IOB.DMA_PTE1_GET> First level entry Unmapped"
    1380               << std::hex << " / paddr = " << r_iotlb_paddr.read()
     910    std::cout << "  <IOB DMA_PTE1_GET> First level entry Unmapped"
     911              << std::hex << " / paddr = " << r_tlb_paddr.read()
    1381912              << std::hex << " / PTE = " << entry << std::endl;
    1382913}
     
    1388919        {
    1389920            // register bypass
    1390             r_iotlb.set_bypass( r_iotlb_vaddr.read(),
    1391                                 entry & ((1 << (m_paddr_nbits-PAGE_K_NBITS)) - 1),
     921            r_iotlb.set_bypass( r_dma_cmd_vaddr.read(),
     922                                entry & ((1 << (vci_param_int::N-PAGE_K_NBITS)) - 1),
    1392923                                0); //nline, unused
    1393924
    1394925            //&PTE2 = PTBA + IX2 * 8
    1395926            // ps: PAGE_K_NBITS corresponds also to the size of a second level page table
    1396             r_iotlb_paddr = (paddr_t)(entry & ((1<<(m_paddr_nbits-PAGE_K_NBITS))-1)) << PAGE_K_NBITS |
    1397                                 (paddr_t)(((r_iotlb_vaddr.read() & PTD_ID2_MASK) >> PAGE_K_NBITS) << 3);
    1398             r_tlb_miss_init_req     = true;
    1399             r_tlb_miss_type         = PTE2_MISS;
    1400             r_dma_tlb_fsm           = DMA_TLB_WAIT_TRANSACTION;
     927            r_tlb_paddr = (vci_addr_t)(entry & ((1<<(vci_param_int::N-PAGE_K_NBITS))-1)) << PAGE_K_NBITS |
     928                                (vci_addr_t)(((r_dma_cmd_vaddr.read() & PTD_ID2_MASK) >> PAGE_K_NBITS) << 3);
     929            r_tlb_miss_req     = true;
     930            r_tlb_miss_type    = PTE2_MISS;
     931            r_tlb_fsm          = TLB_WAIT;
     932
    1401933#ifdef INSTRUMENTATION
    1402934m_cpt_iotlbmiss_transaction++;
    1403935#endif
    1404936
    1405 #if DEBUG_DMA_TLB
    1406 if ( m_debug_dma_tlb_fsm )
    1407 {
    1408     std::cout << "  <IOB.DMA_TLB_PTE1_GET> Success. Search PTE2"
    1409               << std::hex << " / paddr = " << r_iotlb_paddr.read()
    1410               << std::hex << " / PTD = " << entry << std::endl;
    1411 }
     937#if DEBUG_TLB_MISS
     938if ( m_debug_activated )
     939std::cout << "  <IOB TLB_PTE1_GET> Success. Search PTE2" << std::hex
     940          << " / PADDR = " << r_tlb_paddr.read()
     941          << " / PTD = " << entry << std::endl;
    1412942#endif
    1413943        }
     
    1415945                        //  Should not occur if working only with small pages
    1416946        {
    1417             r_iotlb_pte_flags   = entry;
    1418             r_dma_tlb_fsm  = DMA_TLB_PTE1_SELECT;
    1419 
    1420 #if DEBUG_DMA_TLB
    1421 if ( m_debug_dma_tlb_fsm )
    1422 {
    1423     std::cout << "  <IOB.DMA_TLB_PTE1_GET> Success. Big page"
    1424               << std::hex << " / paddr = " << r_iotlb_paddr.read()
    1425               << std::hex << " / PTE1 = " << entry << std::endl;
    1426 }
    1427 #endif
    1428         }
    1429        
    1430         break;
    1431     }
    1432     ////////////////////////////
    1433     case DMA_TLB_PTE1_SELECT:   // select a slot for PTE1
     947            r_tlb_pte_flags   = entry;
     948            r_tlb_fsm  = TLB_PTE1_SELECT;
     949
     950#if DEBUG_TLB_MISS
     951if ( m_debug_activated )
     952std::cout << "  <IOB TLB_PTE1_GET> Success. Big page"
     953          << std::hex << " / paddr = " << r_tlb_paddr.read()
     954          << std::hex << " / PTE1 = " << entry << std::endl;
     955#endif
     956        }
     957        break;
     958    }
     959    /////////////////////
     960    case TLB_PTE1_SELECT:       // select a slot for PTE1
    1434961    {
    1435962        size_t  way;
    1436963        size_t  set;
    1437964       
    1438         r_iotlb.select(  r_iotlb_vaddr.read(),
     965        r_iotlb.select(  r_dma_cmd_vaddr.read(),
    1439966                        true,  // PTE1
    1440967                        &way,
     
    1444971#endif
    1445972
    1446 #if DEBUG_DMA_TLB
    1447 if ( m_debug_dma_tlb_fsm )
    1448 {
    1449     std::cout << "  <IOB.DMA_TLB_PTE1_SELECT> Select a slot in IOTLB:";
    1450     std::cout << " way = " << std::dec << way
    1451                   << " / set = " << set << std::endl;
    1452 }
    1453 #endif
    1454         r_iotlb_way = way;
    1455         r_iotlb_set = set;
    1456         r_dma_tlb_fsm     = DMA_TLB_PTE1_UPDT;
    1457         break;
    1458     }
    1459     //////////////////////////
    1460     case DMA_TLB_PTE1_UPDT:     // write a new PTE1 in tlb
    1461                                 // not necessary to treat the L/R bit
    1462     {
    1463         //(OLD) paddr_t   nline = r_dcache_tlb_paddr.read() >> (uint32_log2(m_dcache_words)+2);   
    1464         uint32_t  pte   = r_iotlb_pte_flags.read();
     973#if DEBUG_TLB_MISS
     974if ( m_debug_activated )
     975std::cout << "  <IOB TLB_PTE1_SELECT> Select a slot in TLB"
     976          << " / way = " << std::dec << way
     977          << " / set = " << set << std::endl;
     978#endif
     979        r_tlb_way = way;
     980        r_tlb_set = set;
     981        r_tlb_fsm     = TLB_PTE1_UPDT;
     982        break;
     983    }
     984    ///////////////////
     985    case TLB_PTE1_UPDT:     // write a new PTE1 in tlb
     986                            // not necessary to treat the L/R bit
     987    {
     988        uint32_t  pte   = r_tlb_pte_flags.read();
    1465989       
    1466         r_miss_paddr = (paddr_t)( ((r_iotlb_pte_flags.read() & PPN1_MASK) << 21)
    1467                         | (r_iotlb_vaddr.read()& M_PAGE_OFFSET_MASK) );
     990        r_tlb_paddr = (vci_addr_t)( ((r_tlb_pte_flags.read() & PPN1_MASK) << 21)
     991                        | (r_dma_cmd_vaddr.read()& M_PAGE_OFFSET_MASK) );
    1468992       
    1469993        // update TLB
     
    1471995                      pte,
    1472996                      0,                // argument unused for a PTE1
    1473                       r_iotlb_vaddr.read(),   
    1474                       r_iotlb_way.read(),
    1475                       r_iotlb_set.read(),
     997                      r_dma_cmd_vaddr.read(),   
     998                      r_tlb_way.read(),
     999                      r_tlb_set.read(),
    14761000                      0 );      //we set nline = 0
    14771001#ifdef INSTRUMENTATION
     
    14791003#endif
    14801004
    1481 #if DEBUG_DMA_TLB
    1482 if ( m_debug_dma_tlb_fsm )
     1005#if DEBUG_TLB_MISS
     1006if ( m_debug_activated )
    14831007{
    1484     std::cout   << "  <IOB.DMA_TLB_PTE1_UPDT> write PTE1 in IOTLB";
    1485     std::cout   << " / set = " << std::dec << r_iotlb_set.read()
    1486                 << " / way = " << r_iotlb_way.read() << std::endl;
    1487     r_iotlb.printTrace();
     1008std::cout << "  <IOB TLB_PTE1_UPDT> write PTE1 in TLB"
     1009          << " / set = " << std::dec << r_tlb_set.read()
     1010          << " / way = " << r_tlb_way.read() << std::endl;
     1011r_iotlb.printTrace();
    14881012}
    14891013#endif
    14901014        // next state
    1491         r_dma_tlb_fsm = DMA_TLB_RETURN; // exit sub-fsm
    1492         break;
    1493     }
    1494     /////////////////////////
    1495     case DMA_TLB_PTE2_GET:      // Try to read a PTE2 (64 bits) in the miss buffer
     1015        r_tlb_fsm = TLB_RETURN; // exit sub-fsm
     1016        break;
     1017    }
     1018    //////////////////
     1019    case TLB_PTE2_GET:  // Try to read a PTE2 (64 bits) in the miss buffer
    14961020    {   
    14971021        uint32_t        pte_flags;
    14981022        uint32_t        pte_ppn;
    14991023       
    1500         paddr_t line_number  = (paddr_t)((r_iotlb_paddr.read())&(CACHE_LINE_MASK));
    1501         size_t word_position = (size_t)( ((r_iotlb_paddr.read())&(~CACHE_LINE_MASK))>>2 );
     1024        vci_addr_t line_number  = (vci_addr_t)((r_tlb_paddr.read())&(CACHE_LINE_MASK));
     1025        size_t word_position = (size_t)( ((r_tlb_paddr.read())&(~CACHE_LINE_MASK))>>2 );
    15021026       
    15031027       
    15041028        // Hit test. Just to verify.
    1505         bool hit = (r_miss_buf_valid && (r_miss_buf_tag.read()== line_number) );
     1029        bool hit = (r_tlb_buf_valid && (r_tlb_buf_tag.read()== line_number) );
    15061030        assert(hit and "Error: No hit on prefetch buffer after Miss Transaction");
    1507         pte_flags= r_miss_buf_data[word_position];
    1508         pte_ppn= r_miss_buf_data[word_position+1]; //because PTE2 is 2 words long
     1031        pte_flags= r_tlb_buf_data[word_position];
     1032        pte_ppn= r_tlb_buf_data[word_position+1]; //because PTE2 is 2 words long
    15091033        // Bit valid checking
    15101034        if ( not ( pte_flags & PTE_V_MASK) )    // unmapped
    15111035        {
    15121036            //must not occur!
    1513             std::cout << "IOMMU ERROR " << name() << "DMA_TLB_IDLE state" << std::endl
     1037            std::cout << "IOMMU ERROR " << name() << "TLB_IDLE state" << std::endl
    15141038                      << "The Page Table entry ins't valid (unmapped)" << std::endl;
    15151039                       
    1516             r_tlb_error_type          = MMU_READ_PT2_UNMAPPED;
    1517             r_dma_tlb_error_req       = true;
    1518             r_dma_tlb_req             = false;
    1519             r_dma_tlb_fsm             = DMA_TLB_IDLE;           
    1520 #if DEBUG_DMA_TLB
    1521 if ( m_debug_dma_tlb_fsm )
    1522 {
    1523     std::cout << "  <IOB.DMA_TLB_PTE2_GET> PTE2 Unmapped"
    1524               << std::hex << " / paddr = " << r_iotlb_paddr.read()
    1525               << std::hex << " / PTE = " << pte_flags << std::endl;
    1526 }
    1527 #endif
    1528                     break;
     1040            r_tlb_miss_error       = true;
     1041            r_dma_tlb_req         = false;
     1042            r_tlb_fsm             = TLB_IDLE;           
     1043
     1044#if DEBUG_TLB_MISS
     1045if ( m_debug_activated )
     1046std::cout << "  <IOB TLB_PTE2_GET> PTE2 Unmapped" << std::hex
     1047          << " / PADDR = " << r_tlb_paddr.read()
     1048          << " / PTE = " << pte_flags << std::endl;
     1049#endif
     1050            break;
    15291051        }
    15301052           
    1531         r_iotlb_pte_flags       = pte_flags;
    1532         r_iotlb_pte_ppn         = pte_ppn;
    1533         r_dma_tlb_fsm           = DMA_TLB_PTE2_SELECT;
     1053        r_tlb_pte_flags       = pte_flags;
     1054        r_tlb_pte_ppn         = pte_ppn;
     1055        r_tlb_fsm           = TLB_PTE2_SELECT;
    15341056               
    1535 #if DEBUG_DMA_TLB
    1536 if ( m_debug_dma_tlb_fsm )
    1537 {
    1538     std::cout << "  <IOB.DMA_TLB_PTE2_GET> Mapped:"
    1539               << " PTE_FLAGS = " << std::hex << pte_flags
    1540               << " PTE_PPN = " << std::hex << pte_ppn << std::endl;
    1541 }
     1057#if DEBUG_TLB_MISS
     1058if ( m_debug_activated )
     1059std::cout << "  <IOB TLB_PTE2_GET> Mapped" << std::hex
     1060          << " / PTE_FLAGS = " << pte_flags
     1061          << " / PTE_PPN = " << pte_ppn << std::endl;
    15421062#endif
    15431063        break;
    15441064    }
    15451065    ////////////////////////////
    1546     case DMA_TLB_PTE2_SELECT:    // select a slot for PTE2
     1066    case TLB_PTE2_SELECT:    // select a slot for PTE2
    15471067    {
    15481068        size_t way;
    15491069        size_t set;
    15501070
    1551         r_iotlb.select( r_iotlb_vaddr.read(),
     1071        r_iotlb.select( r_dma_cmd_vaddr.read(),
    15521072                        false,  // PTE2
    15531073                        &way,
     
    15571077#endif
    15581078
    1559 #if DEBUG_DMA_TLB
    1560 if ( m_debug_dma_tlb_fsm )
     1079#if DEBUG_TLB_MISS
     1080if ( m_debug_activated )
    15611081{
    1562         std::cout << "  <IOB.DMA_TLB_PTE2_SELECT> Select a slot in IOTLB:";
     1082        std::cout << "  <IOB TLB_PTE2_SELECT> Select a slot in IOTLB:";
    15631083        std::cout << " way = " << std::dec << way
    15641084                  << " / set = " << set << std::endl;
    15651085}
    15661086#endif
    1567         r_iotlb_way = way;
    1568         r_iotlb_set = set;
    1569         r_dma_tlb_fsm     = DMA_TLB_PTE2_UPDT;
    1570         break;
    1571     }
    1572     //////////////////////////
    1573     case DMA_TLB_PTE2_UPDT:             // write a new PTE2 in tlb
    1574                                     // not necessary to treat the L/R bit
    1575     {
    1576         //(OLD) paddr_t         nline     = r_dcache_tlb_paddr.read() >> (uint32_log2(m_dcache_words)+2);   
    1577         uint32_t        pte_flags = r_iotlb_pte_flags.read();
    1578         uint32_t        pte_ppn   = r_iotlb_pte_ppn.read();
     1087        r_tlb_way = way;
     1088        r_tlb_set = set;
     1089        r_tlb_fsm     = TLB_PTE2_UPDT;
     1090        break;
     1091    }
     1092    ///////////////////
     1093    case TLB_PTE2_UPDT:         // write a new PTE2 in tlb
     1094                                // not necessary to treat the L/R bit
     1095    {
     1096        uint32_t        pte_flags = r_tlb_pte_flags.read();
     1097        uint32_t        pte_ppn   = r_tlb_pte_ppn.read();
    15791098       
    1580         r_miss_paddr = (paddr_t)( ((r_iotlb_pte_ppn.read() & PPN2_MASK) << 12)
    1581                         | (r_iotlb_vaddr.read()& K_PAGE_OFFSET_MASK) );
     1099        r_tlb_paddr = (vci_addr_t)( ((r_tlb_pte_ppn.read() & PPN2_MASK) << 12)
     1100                        | (r_dma_cmd_vaddr.read()& K_PAGE_OFFSET_MASK) );
    15821101       
    15831102        // update TLB for a PTE2
     
    15851104                       pte_flags,
    15861105                       pte_ppn,
    1587                        r_iotlb_vaddr.read(),   
    1588                        r_iotlb_way.read(),
    1589                        r_iotlb_set.read(),
     1106                       r_dma_cmd_vaddr.read(),   
     1107                       r_tlb_way.read(),
     1108                       r_tlb_set.read(),
    15901109                       0 );     // nline = 0
    15911110#ifdef INSTRUMENTATION
     
    15931112#endif
    15941113
    1595 #if DEBUG_DMA_TLB
    1596 if ( m_debug_dma_tlb_fsm )
     1114#if DEBUG_TLB_MISS
     1115if ( m_debug_activated )
    15971116{
    1598         std::cout << "  <IOB.DMA_TLB_PTE2_UPDT> write PTE2 in IOTLB";
    1599         std::cout << " / set = " << std::dec << r_iotlb_set.read()
    1600                   << " / way = " << r_iotlb_way.read() << std::endl;
     1117        std::cout << "  <IOB TLB_PTE2_UPDT> write PTE2 in IOTLB";
     1118        std::cout << " / set = " << std::dec << r_tlb_set.read()
     1119                  << " / way = " << r_tlb_way.read() << std::endl;
    16011120        r_iotlb.printTrace();
    16021121}
    16031122#endif
    16041123        // next state
    1605         r_dma_tlb_fsm = DMA_TLB_RETURN; // exit sub-fsm
    1606         break;
    1607     }
    1608     ///////////////////////
    1609     case DMA_TLB_WAIT_TRANSACTION:
    1610     {
    1611         // CONFIG FSM request following a invalidation signal sent by OS.
    1612         if(r_config_tlb_req)
     1124        r_tlb_fsm = TLB_RETURN;
     1125        break;
     1126    }
     1127    //////////////
     1128    case TLB_WAIT:   // waiting completion of a miss transaction from MISS_WTI FSM
     1129                     // PTE inval request are handled as unmaskable interrupts
     1130    {
     1131        if ( r_config_tlb_req ) // Request from CONFIG FSM for a PTE invalidation
    16131132        {
    16141133            r_config_tlb_req = false;
    16151134            r_waiting_transaction = true;
    1616             r_dma_tlb_fsm = DMA_TLB_INVAL_CHECK;
     1135            r_tlb_fsm = TLB_INVAL_CHECK;
    16171136        }
    16181137
     
    16201139m_cost_iotlbmiss_transaction++;
    16211140#endif
    1622         if ( not r_tlb_miss_init_req )  //  Miss transaction is done
     1141        if ( not r_tlb_miss_req )       //  Miss transaction is done
    16231142        {
    1624                 if ( r_miss_init_error.read() ) // bus error
     1143                if ( r_miss_wti_rsp_error.read() ) // bus error
    16251144                {
    1626                 r_miss_init_error  = false;
    1627                 r_tlb_error_type    = MMU_READ_DATA_ILLEGAL_ACCESS;
    1628                 r_dma_tlb_error_req     = true;
    1629                 r_dma_tlb_req           = false;
    1630                 r_dma_tlb_fsm = DMA_TLB_IDLE;
     1145                r_miss_wti_rsp_error = false;
     1146                r_tlb_miss_error     = true;
     1147                r_dma_tlb_req        = false;
     1148                r_tlb_fsm            = TLB_IDLE;
    16311149            }
    16321150            else if(r_tlb_miss_type == PTE1_MISS)
    16331151            {
    1634                 r_dma_tlb_fsm = DMA_TLB_PTE1_GET;
    1635        
     1152                r_tlb_fsm = TLB_PTE1_GET;
    16361153            }
    16371154            else
    16381155            {
    1639                 r_dma_tlb_fsm = DMA_TLB_PTE2_GET;
     1156                r_tlb_fsm = TLB_PTE2_GET;
    16401157            }
    16411158        }
    16421159        break;
    16431160    }
    1644     ///////////////////////
    1645     case DMA_TLB_RETURN:                // return to caller depending on tlb miss type
    1646     {
    1647 #if DEBUG_DMA_TLB
    1648 if ( m_debug_dma_tlb_fsm )
    1649 {
    1650     std::cout << "  <IOB.DMA_TLB_RETURN> IOTLB MISS completed" << std::endl;
    1651 }
    1652 #endif
    1653         r_dma_tlb_req = false;
    1654         r_tlb_dma_untreated = true;
    1655         r_dma_tlb_fsm = DMA_TLB_IDLE;
    1656         break;
    1657     }
    1658     //////////////////////
    1659     case DMA_TLB_INVAL_CHECK:   // request from CONFIG FSM to invalidate all PTE on a given line
    1660                                 // This state checks the necessity to invalidate prefetch buffer
     1161    ////////////////
     1162    case TLB_RETURN:            // reset r_dma_tlb_req flip-flop to signal TLB miss completion
     1163                            // possible errors are signaled through r_tlb_miss_error
     1164    {
     1165#if DEBUG_TLB_MISS
     1166if ( m_debug_activated )
     1167std::cout << "  <IOB TLB_RETURN> IOTLB MISS completed" << std::endl;
     1168#endif
     1169        r_dma_tlb_req  = false;
     1170        r_tlb_fsm = TLB_IDLE;
     1171        break;
     1172    }
     1173    /////////////////////
     1174    case TLB_INVAL_CHECK:   // request from CONFIG_FSM to invalidate all PTE in a given line
     1175                            // checks the necessity to invalidate prefetch buffer
    16611176    {
    16621177        // If a transaction is pending, no need to invalidate the prefetch
    16631178        // We can ignore it, since we'll replace the line.
    16641179        // The new line is necessarily up-to-date
    1665         if(!r_waiting_transaction.read() && r_miss_buf_valid)
    1666         {
    1667             if(!r_miss_buf_first_level)
     1180        if(!r_waiting_transaction.read() && r_tlb_buf_valid)
     1181        {
     1182            if(!r_tlb_buf_big_page)
    16681183            {
    1669                if( r_miss_buf_vaddr_begin.read() ==
    1670                    (r_config_tlb_inval_vaddr.read()& ~PTE2_LINE_OFFSET) )
     1184               if( r_tlb_buf_vaddr.read() ==
     1185                   (r_config_cmd_inval_vaddr.read()& ~PTE2_LINE_OFFSET) )
    16711186                // The virtual address corresponds to one entry on the buffer line
    16721187                {
    1673                     r_miss_buf_valid = false;   //change here for individual invalidation
     1188                    r_tlb_buf_valid = false;   //change here for individual invalidation
    16741189                }
    16751190            }
    16761191            else    // First level entries on buffer. Unused if only small pages
    16771192            {
    1678                if( r_miss_buf_vaddr_begin.read() ==
    1679                    (r_config_tlb_inval_vaddr.read()& ~PTE1_LINE_OFFSET) )
     1193               if( r_tlb_buf_vaddr.read() ==
     1194                   (r_config_cmd_inval_vaddr.read()& ~PTE1_LINE_OFFSET) )
    16801195                // The virtual address corresponds to one entry on the buffer line
    16811196                {
    1682                     r_miss_buf_valid = false;   //change here for individual invalidation
     1197                    r_tlb_buf_valid = false;   //change here for individual invalidation
    16831198                }
    16841199            }
     
    16871202        // Invalidation on IOTLB
    16881203        bool    ok;
    1689         ok = r_iotlb.inval(r_config_tlb_inval_vaddr.read());
     1204        ok = r_iotlb.inval(r_config_cmd_inval_vaddr.read());
    16901205         
    1691         if(r_waiting_transaction.read()) r_dma_tlb_fsm =DMA_TLB_WAIT_TRANSACTION;
    1692         else r_dma_tlb_fsm = DMA_TLB_IDLE;
     1206        if(r_waiting_transaction.read()) r_tlb_fsm =TLB_WAIT;
     1207        else r_tlb_fsm = TLB_IDLE;
    16931208        break;
    16941209    }
    1695     } //end switch r_dma_tlb_fsm
     1210    } //end switch r_tlb_fsm
    16961211   
    1697    
    1698     /////////////////////////////////////////////////////////////////////
    1699     // The CONFIG_CMD_FSM is similar to the DMA_CMD_FSM, but without miss TLB treatment.
    1700     // It controls the following ressources:
    1701     // - r_config_cmd_fsm
    1702     //
    1703     // - r_config_cmd_rsp_erase_req (set)
    1704     // - r_config_tlb_req (set)
    1705     /////////////////////////////////////////////////////////////////////
     1212    ////////////////////////////////////////////////////////////////////////////////
     1213    // The CONFIG_CMD_FSM handles the VCI commands from the INT network.
     1214    // This FSM is mainly intended to handle single flit config transactions,
     1215    // but it can also handle software driven, multi-flits data transactions.
     1216    // - The configuration requests can be local (IO_BRIDGE config registers)
     1217    //   or remote (config registers of peripherals on IOX network).
     1218    // - The data requests are always remote.
     1219    // In case of local config, this FSM put a VCI response in CONFIG_RSP fifo.
     1220    // In case of remote transaction, it put the VCI command in CONFIG_CMD fifo.
     1221    ///////////////////////////////////////////////////////////////////////////////
    17061222
    17071223    switch( r_config_cmd_fsm.read() )
    17081224    {
    1709     //////////////
    1710     case CONFIG_CMD_IDLE:
    1711     {
    1712         if ( p_vci_tgt_config.cmdval.read() )
    1713         {
     1225    /////////////////////
     1226    case CONFIG_CMD_IDLE:   // waiting VCI command
     1227    {
     1228        if ( p_vci_tgt_int.cmdval.read() )
     1229        {
     1230
    17141231#if DEBUG_CONFIG_CMD
    1715 if( m_debug_config_cmd_fsm )
    1716 {
    1717     std::cout << "  <IOB.CONFIG_CMD_IDLE> Configuration command received!" <<std::endl;
    1718     std::cout << " address = " << std::hex << p_vci_tgt_config.address.read()
    1719               << " srcid = " << std::dec << p_vci_tgt_config.srcid.read()
    1720               << " trdid = " << p_vci_tgt_config.trdid.read()
    1721               << " wdata = " << std::hex << p_vci_tgt_config.wdata.read()
    1722               << " be = " << p_vci_tgt_config.be.read()
    1723               << " plen = " << std::dec << p_vci_tgt_config.plen.read() << std::endl;
    1724 }
    1725 #endif
    1726             paddr_t config_paddr = p_vci_tgt_config.address.read();
    1727    
    1728 //           // Just to verify
    1729 //           if(! m_locality_table_config[config_paddr] ) //cannot receive remote packets
    1730 //           {
    1731 //           std::cout << "IOB ERROR " << name() << " CONFIG_CMD_IDLE state" << std::endl
    1732 //                         << "Received a remote packet" << std::endl;
    1733 //               exit(0);
    1734 //           }
    1735 
    1736             bool read = (p_vci_tgt_config.cmd.read() == vci_param_d::CMD_READ);
    1737            
    1738             uint32_t              cell    = (uint32_t)((config_paddr & 0x1FF)>>2);
    1739            
    1740             // Treatement of received command
    1741             // Verifies error, tests if the the command is for IOB itself
     1232if( m_debug_activated )
     1233std::cout << "  <IOB CONFIG_CMD_IDLE> Command received"
     1234          << " / address = " << std::hex << p_vci_tgt_int.address.read()
     1235          << " / srcid = " << std::dec << p_vci_tgt_int.srcid.read()
     1236          << " / trdid = " << p_vci_tgt_int.trdid.read()
     1237          << " / wdata = " << std::hex << p_vci_tgt_int.wdata.read()
     1238          << " / be = " << p_vci_tgt_int.be.read()
     1239          << " / plen = " << std::dec << p_vci_tgt_int.plen.read()
     1240          << " / eop = " << p_vci_tgt_int.eop.read() << std::endl;
     1241#endif
     1242            vci_addr_t paddr = p_vci_tgt_int.address.read();
     1243            bool       read  = (p_vci_tgt_int.cmd.read() == vci_param_int::CMD_READ);
     1244            uint32_t   cell  = (uint32_t)((paddr & 0x1FF)>>2);
    17421245 
    1743             // To IOB itself
    1744             if(m_segment_config.contains(config_paddr))
     1246            // The "local" segment must be the first in the seglist
     1247            soclib::common::Segment seg = m_int_seglist.front();
     1248           
     1249            if ( seg.contains(paddr) )  // IO_BRIDGE itself
    17451250            {
    1746                 if(!read && (cell == IOB_IOMMU_PTPR))
    1747                     r_config_cmd_fsm = CONFIG_CMD_PTPR_WRITE;
    1748                 else if(read && (cell == IOB_IOMMU_PTPR))
    1749                     r_config_cmd_fsm = CONFIG_CMD_PTPR_READ;
    1750                 else if(!read && (cell == IOB_IOMMU_ACTIVE))
    1751                     r_config_cmd_fsm = CONFIG_CMD_ACTIVE_WRITE;
    1752                 else if(read && (cell == IOB_IOMMU_ACTIVE))
    1753                     r_config_cmd_fsm = CONFIG_CMD_ACTIVE_READ;
    1754                 else if(read && (cell == IOB_IOMMU_BVAR))
    1755                     r_config_cmd_fsm = CONFIG_CMD_BVAR_READ;
    1756                 else if(read && (cell == IOB_IOMMU_ETR))
    1757                     r_config_cmd_fsm = CONFIG_CMD_ETR_READ;
    1758                 else if(read && (cell == IOB_IOMMU_BAD_ID))
    1759                     r_config_cmd_fsm = CONFIG_CMD_BAD_ID_READ;
    1760                 // PTE invalidation signaled by the OS
    1761                 else if(!read && (cell == IOB_INVAL_PTE))
    1762                     r_config_cmd_fsm = CONFIG_CMD_INVAL_REQ;
    1763                 else if(!read && (cell == IOB_IT_ADDR_IOMMU_LO))
    1764                     r_config_cmd_fsm = CONFIG_CMD_IT_ADDR_IOMMU_WRITE_1;
    1765                 else if(read && (cell == IOB_IT_ADDR_IOMMU_LO))
    1766                     r_config_cmd_fsm = CONFIG_CMD_IT_ADDR_IOMMU_READ_1;
    1767                 else if( !read && ((cell >= IOB_IT_ADDR_BEGIN)&&
    1768                         ( cell< (IOB_IT_ADDR_BEGIN +2*m_nb_periph-1) ) ) )
    1769                 {
    1770                     // a factor two shows up because the registres come in couples
    1771                     r_it_index = (cell - IOB_IT_ADDR_BEGIN)/2;
    1772                     r_config_cmd_fsm = CONFIG_CMD_IT_ADDR_WRITE_1;
     1251                uint32_t      rdata  = 0;
     1252                bool          rerror = false;
     1253
     1254                if ( not read && (cell == IOB_IOMMU_PTPR) )       // WRITE PTPR
     1255                {
     1256                    r_iommu_ptpr = (uint32_t)p_vci_tgt_int.wdata.read();
     1257                }
     1258                else if ( read && (cell == IOB_IOMMU_PTPR) )      // READ PTPR
     1259                {
     1260                    rdata = r_iommu_ptpr.read();
     1261                }
     1262                else if( not read && (cell == IOB_WTI_ENABLE))  // WRITE WTI_ENABLE
     1263                {
     1264                    r_iommu_wti_enable = p_vci_tgt_int.wdata.read();
     1265                }
     1266                else if( read && (cell == IOB_WTI_ENABLE))       // READ WTI ENABLE
     1267                {
     1268                    rdata = r_iommu_wti_enable.read();
     1269                }
     1270                else if( read && (cell == IOB_IOMMU_BVAR))        // READ BVAR
     1271                {
     1272                    rdata = r_iommu_bvar.read();
     1273                }
     1274                else if( read && (cell == IOB_IOMMU_ETR))          // READ ETR
     1275                {
     1276                    rdata = r_iommu_etr.read();
     1277                }
     1278                else if( read && (cell == IOB_IOMMU_BAD_ID))      // READ BAD_ID
     1279                {
     1280                    rdata = r_iommu_bad_id.read();
     1281                }
     1282                else if( not read && (cell == IOB_INVAL_PTE))     // WRITE INVAL_PTE
     1283                {
     1284                    r_config_tlb_req         = true;
     1285                    r_config_cmd_inval_vaddr = (uint32_t)p_vci_tgt_int.wdata.read();
     1286                }
     1287                else if( not read && (cell == IOB_WTI_ADDR_LO)) // WRITE WTI_PADDR_LO
     1288                {
     1289                    r_iommu_wti_paddr = (vci_addr_t)p_vci_tgt_int.wdata.read();
     1290                }
     1291                else if( read && (cell == IOB_WTI_ADDR_LO))    // READ WTI_PADDR_LO
     1292                {
     1293                    rdata = (uint32_t)r_iommu_wti_paddr.read();
     1294                }
     1295                else if( not read && (cell == IOB_WTI_ADDR_HI)) // WRITE WTI_PADDR_HI
     1296                {
     1297                    r_iommu_wti_paddr = (r_iommu_wti_paddr.read() & 0x00000000FFFFFFFFLL) |
     1298                                        ((vci_addr_t)p_vci_tgt_int.wdata.read())<<32;
     1299                }
     1300                else if( read && (cell == IOB_WTI_ADDR_HI))    // READ WTI_PADDR_HI
     1301                {
     1302                    rdata = (uint32_t)(r_iommu_wti_paddr.read()>>32);
     1303                }
     1304                else if( not read && ((cell >= IOB_PERI_WTI_BEGIN)  // WRITE PERI WTI
     1305                          && (cell< (IOB_PERI_WTI_BEGIN + 64))) )
     1306                {
     1307                    size_t  index = (cell - IOB_PERI_WTI_BEGIN)/2;
     1308                    bool    high  = (cell - IOB_PERI_WTI_BEGIN)%2;
     1309                    if ( high ) r_iommu_peri_wti[index] =          // set 32 MSB bits
     1310                        (r_iommu_peri_wti[index].read() & 0x00000000FFFFFFFFLL) |
     1311                        ((vci_addr_t)p_vci_tgt_int.wdata.read())<<32;
     1312                    else        r_iommu_peri_wti[index] =          // set 32 LSB bits
     1313                         (vci_addr_t)p_vci_tgt_int.wdata.read();
    17731314                }
    1774                 else if( read && ((cell >= IOB_IT_ADDR_BEGIN)&&
    1775                         (cell< (IOB_IT_ADDR_BEGIN +2*m_nb_periph-1))) )
    1776                 {
    1777                     r_it_index = (cell - IOB_IT_ADDR_BEGIN)/2;
    1778                     r_config_cmd_fsm = CONFIG_CMD_IT_ADDR_READ_1;
    1779                 }
    1780                 else
    1781                 //Error. Wrong address, or invalid operation.
    1782                 {
    1783                     if(read)    r_config_error_type = READ_ERROR;
    1784                     else        r_config_error_type = WRITE_ERROR;
    1785                     r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    1786                 }
     1315                else if( read && ((cell >= IOB_PERI_WTI_BEGIN)      // READ PERI WTI   
     1316                         && (cell< (IOB_PERI_WTI_BEGIN + 64))) )
     1317                {
     1318                    size_t  index = (cell - IOB_PERI_WTI_BEGIN)/2;
     1319                    bool    high  = (cell - IOB_PERI_WTI_BEGIN)%2;
     1320                    if ( high ) rdata = (uint32_t)(r_iommu_peri_wti[index].read()>>32);
     1321                    else        rdata = (uint32_t)(r_iommu_peri_wti[index].read());
     1322                }
     1323                else   // Error: Wrong address, or invalid operation.
     1324                {
     1325                    rerror = true;
     1326                }
     1327                r_config_cmd_rdata  = rdata;
     1328                r_config_cmd_error = rerror;
     1329                r_config_cmd_fsm    = CONFIG_CMD_FIFO_PUT_RSP;
    17871330            }
    1788             // Must route the command to the correct IO
    1789             else
     1331            else                                        // remote peripheral
    17901332            {
    1791                 if(!p_vci_tgt_config.eop.read())
    1792                 {
    1793                     //Error
    1794                     if(read)    r_config_error_type = READ_ERROR;
    1795                     else        r_config_error_type = WRITE_ERROR;
    1796                     r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    1797                 }
    1798                
    1799                 // Find the corresponding address on IO Space
    1800 //                int tgt_index = m_routing_table_config[config_paddr];
    1801 //#if DEBUG_CONFIG_CMD
    1802 //if( m_debug_config_cmd_fsm )
    1803 //{
    1804 //    std::cout << "  <IOB.CONFIG_CMD_IDLE> Routing a configuration packet" <<std::endl
    1805 //            << "Target Index on Direct NoC: " << tgt_index << std::endl;
    1806 //}
    1807 //#endif
    1808 //                soclib::common::Segment io_segment = m_mtio.getSegment(IntTab(tgt_index));
    1809 //               #define L2 soclib::common::uint32_log2
    1810 //               paddr_t offset_mask = ( (1 << L2(io_segment.size())) - 1);
    1811 //               #undef L2
    1812 //               r_config_vaddr = (vaddr_t)( io_segment.baseAddress() |
    1813 //                               (vaddr_t)(config_paddr & offset_mask) );
    1814                
    1815                 // TODO So far, it is in identity mapping
    1816                 r_config_vaddr = (vaddr_t) config_paddr ;
    1817                 r_config_cmd_fsm        = CONFIG_CMD_TRT_LOCK;
    1818 
     1333                r_config_cmd_fsm  = CONFIG_CMD_FIFO_PUT_CMD;
    18191334            }
    1820 
    1821 
    18221335        } // end if cmdval
    18231336        break;
    18241337    }
    1825     /////////////////////////
    1826     case CONFIG_CMD_TRT_LOCK: // Waiting for the lock to modify Transaction Table
    1827     {
    1828         if ( r_alloc_trt_config_fsm.read() == ALLOC_TRT_CONFIG_CMD )
     1338    /////////////////////////////
     1339    case CONFIG_CMD_FIFO_PUT_CMD:       // transmit VCI command from the INT network
     1340                                    // to the CONFIG_CMD fifo to IOX network
     1341    {
     1342        config_cmd_fifo_put = true;
     1343
     1344        if ( p_vci_tgt_int.cmdval.read()  and m_config_cmd_addr_fifo.wok() )
    18291345        {
    18301346
    18311347#if DEBUG_CONFIG_CMD
    1832 if( m_debug_config_cmd_fsm )
    1833 {
    1834     std::cout << "  <IOB.CONFIG_CMD_TRT_LOCK> Check the TRT" << std::endl;
    1835 }
    1836 #endif
    1837             size_t              wok_index = 0;
    1838             bool                wok       = !m_transaction_tab_config.full(wok_index);
    1839 
    1840             if ( wok )  // TRT isn't full. Write the new transaction.
     1348if( m_debug_activated )
     1349std::cout << "  <IOB CONFIG_CMD_FIFO_PUT_CMD> Transmit VCI command to IOX network"
     1350          << " : address = " << std::hex << p_vci_tgt_int.address.read()
     1351          << " / srcid = " << p_vci_tgt_int.srcid.read()
     1352          << std::endl;
     1353#endif
     1354            if(  p_vci_tgt_int.eop.read() ) r_config_cmd_fsm = CONFIG_CMD_IDLE;
     1355        }
     1356        break;
     1357    }
     1358    /////////////////////////////
     1359    case CONFIG_CMD_FIFO_PUT_RSP:   // Try to put a response in CONFIG_RSP fifo,
     1360                                    // for a local configuration transaction.
     1361                                    // The FIFO is shared with CONFIG_RSP FSM
     1362                                    // and must we wait for allocation...
     1363    {
     1364        if ( p_vci_tgt_int.cmdval.read() and r_alloc_fifo_config_rsp_local.read() )
     1365        {
     1366            config_rsp_fifo_put = true;
     1367
     1368            if ( m_config_rsp_data_fifo.wok() ) 
    18411369            {
    1842                 r_config_cmd_trt_index = (vci_trdid_t)wok_index;
    1843                 r_config_cmd_fsm       = CONFIG_CMD_TRT_SET;
    1844             }
    1845             else                // wait an empty entry in TRT
    1846             {
    1847                 r_config_cmd_fsm       = CONFIG_CMD_TRT_WAIT;
    1848                 r_config_cmd_rsp_erase_req = true;
     1370
    18491371#if DEBUG_CONFIG_CMD
    1850 if( m_debug_config_cmd_fsm )
    1851 {
    1852     std::cout << "  <IOB.CONFIG_CMD_TRT_LOCK> TRT is full. Going to TRT_WAIT state" << std::endl;
    1853 }
    1854 #endif
    1855            
    1856 #ifdef INSTRUMENTATION       
    1857 m_cpt_trt_config_full++;
    1858 #endif
     1372if( m_debug_activated )
     1373std::cout << "  <IOB CONFIG_CMD_FIFO_PUT_RSP> Response to a local configuration request"
     1374          << std::endl;
     1375#endif
     1376                if(  p_vci_tgt_int.eop.read() ) r_config_cmd_fsm = CONFIG_CMD_IDLE;
    18591377            }
    18601378        }
    18611379        break;
    18621380    }
    1863     ////////////////
    1864     case CONFIG_CMD_TRT_WAIT:   // release the lock protecting the transaction tab
    1865                                 // waits that RSP erases an entry
    1866     {
    1867 #ifdef INSTRUMENTATION       
    1868 m_cpt_trt_config_full_cost++;
    1869 #endif
    1870         // CONFIG_RSP will notify an erase action by reseting this register
    1871         if(!r_config_cmd_rsp_erase_req.read())
    1872         {
    1873             r_config_cmd_fsm = CONFIG_CMD_TRT_LOCK; // take the lock again
    1874         }
    1875         break;
    1876     }
    1877     ////////////////////////
    1878     case CONFIG_CMD_TRT_SET:    // register a new transaction in TRT
    1879     { 
    1880         if ( r_alloc_trt_config_fsm.read() == ALLOC_TRT_CONFIG_CMD )
    1881         {
    1882             m_transaction_tab_config.set(   r_config_cmd_trt_index.read(),
    1883                                             p_vci_tgt_config.srcid.read(),
    1884                                             p_vci_tgt_config.trdid.read() );
    1885            
    1886             r_config_cmd_fsm = CONFIG_CMD_FIFO_PUT;
    1887 #if DEBUG_CONFIG_CMD
    1888 if( m_debug_config_cmd_fsm )
    1889 {
    1890     std::cout << "  <IOB.CONFIG_CMD_TRT_SET> Set a new entry in TRT" << std::endl;
    1891 }
    1892 #endif
    1893         }
    1894         break;
    1895     } 
    1896     ///////////////////////
    1897     case CONFIG_CMD_FIFO_PUT:   
    1898     {
    1899         if ( p_vci_tgt_config.cmdval && m_config_cmd_addr_fifo.wok() )
    1900         {
    1901             config_cmd_fifo_put = true;
    1902             if(  p_vci_tgt_config.eop )    r_config_cmd_fsm = CONFIG_CMD_IDLE;
    1903            
    1904 #if DEBUG_CONFIG_CMD
    1905 if( m_debug_config_cmd_fsm )
    1906 {
    1907     std::cout << "  <IOB.CONFIG_CMD_FIFO_PUT> Push into config_cmd_fifo:"
    1908               << " address = " << std::hex << r_config_vaddr.read()
    1909               << " srcid = " << std::dec << m_srcid_config
    1910               << " trdid = " << r_config_cmd_trt_index.read()
    1911               << " wdata = " << std::hex << p_vci_tgt_config.wdata.read()
    1912               << " be = " << p_vci_tgt_config.be.read()
    1913               << " plen = " << std::dec << p_vci_tgt_config.plen.read() << std::endl;
    1914 }
    1915 #endif
    1916         }
    1917         break;
    1918     }
    1919    
    1920     ///////////////////////////////
    1921     // Private Configuration States
    1922     ///////////////////////////////
    1923 
    1924     //////////////////
    1925     case CONFIG_CMD_PTPR_WRITE: // Convention- The word received is in the format:
    1926                                 // 00000 BASE_ADDRESS[39:13]
    1927                                 // Same pattern as in iommu_ptpr register
    1928     {
    1929         if ( p_vci_tgt_config.cmdval.read() && m_config_local_data_fifo.wok()
    1930             && r_dma_tlb_fsm == DMA_TLB_IDLE )
    1931         {
    1932             // This verification could have been done on IDLE state
    1933             // It would save us one cycle
    1934             if ( !p_vci_tgt_config.eop.read() )
    1935             {
    1936                 std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_PTPR_WRITE state" << std::endl;
    1937                 std::cout << " PTPR write command must contain one single flit" << std::endl;
    1938                 r_config_error_type = WRITE_ERROR;
    1939                 r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    1940                 break;
    1941             }
    1942            
    1943             // Depends on the convention
    1944             r_iommu_ptpr = (uint32_t)(p_vci_tgt_config.wdata.read());
    1945            
    1946             config_local_fifo_put = true;
    1947             r_config_cmd_fsm = CONFIG_CMD_IDLE;
    1948 
    1949 #if DEBUG_CONFIG_CMD
    1950 if( m_debug_config_cmd_fsm )
    1951 {
    1952     std::cout << "  <IOB.CONFIG_CMD_PTPR_WRITE> PTPR received:"
    1953               << "r_iommu_ptpr = " << std::hex << (p_vci_tgt_config.wdata.read())
    1954               <<std::endl;
    1955 }
    1956 #endif
    1957         }
    1958         break;
    1959     }
     1381    } // end switch CONFIG_CMD FSM
     1382
     1383    //////////////////////////////////////////////////////////////////////////////
     1384    // The CONFIG_RSP_FSM handles the VCI responses from the periherals
     1385    // on the IOX network and  writes the responses in the CONFIG_RSP fifo.
     1386    // The VCI response flit is only consumed in the FIFO_PUT state.
     1387    // This FSM is mainly intended to handle single flit config transactions,
     1388    // but it can also handle software driven, multi-flits data transactions.
     1389    //////////////////////////////////////////////////////////////////////////////
     1390
     1391    switch( r_config_rsp_fsm.read() )
     1392    {
    19601393    /////////////////////
    1961     case CONFIG_CMD_ACTIVE_WRITE:
    1962     {
    1963         if ( p_vci_tgt_config.cmdval.read() && m_config_local_data_fifo.wok()
    1964             && r_dma_tlb_fsm == DMA_TLB_IDLE )
    1965         {
    1966             // This verification could have been done on IDLE state
    1967             // It would save us one cycle
    1968             if ( !p_vci_tgt_config.eop.read() )
    1969             {
    1970                 std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_ACTIVE_WRITE state" << std::endl;
    1971                 std::cout << " ACTIVE write command must contain one single flit" << std::endl;
    1972                 r_config_error_type = WRITE_ERROR;
    1973                 r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    1974                 break;
    1975             }
    1976            
    1977             r_iommu_active = (p_vci_tgt_config.wdata.read() != 0);
    1978            
    1979             config_local_fifo_put = true;
    1980             r_config_cmd_fsm = CONFIG_CMD_IDLE;
    1981         }
    1982         break;
    1983     }
    1984     ///////////////////
    1985     case CONFIG_CMD_INVAL_REQ: // Blocks in case of untreated request
    1986     {   
    1987         if ( !r_config_tlb_req.read() )
    1988         {
    1989             r_config_tlb_req = true;     
    1990             r_config_cmd_fsm = CONFIG_CMD_INVAL;
    1991         }
    1992         break;
    1993     }
    1994     ///////////////////
    1995     case CONFIG_CMD_INVAL: // Consuming the 32bit Virtual Address of the invalidated page
    1996     {
    1997         if ( p_vci_tgt_config.cmdval.read() &&
    1998                 m_config_local_data_fifo.wok() )
    1999         {
    2000            
    2001             if ( !p_vci_tgt_config.eop.read() )
    2002             {
    2003                 std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_INVAL state" << std::endl;
    2004                 std::cout << " PTE invalidation commands must contain one single flit" << std::endl;
    2005                 r_config_error_type = WRITE_ERROR;
    2006                 r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    2007                 break;
    2008             }
    2009            
    2010             assert( (p_vci_tgt_config.wdata.read()& K_PAGE_OFFSET_MASK) == 0
    2011                     and " Error : Invalid format for Page Virtual Address. At least the 12 LSB bits must be zero");
    2012 
    2013             r_config_tlb_inval_vaddr = (vaddr_t)(p_vci_tgt_config.wdata.read());
    2014              
    2015             config_local_fifo_put = true;
    2016             r_config_cmd_fsm = CONFIG_CMD_IDLE;
    2017         }
    2018         break;
    2019     }
    2020     //////////////////
    2021     case CONFIG_CMD_IT_ADDR_IOMMU_WRITE_1:
    2022     {
    2023         if ( p_vci_tgt_config.cmdval.read() && m_config_local_data_fifo.wok())
    2024         {
    2025             if(vci_param_d::N <= 32)
    2026             {
    2027             // address holds in one single flit
    2028                 if (!p_vci_tgt_config.eop.read() )
    2029                 {
    2030                    
    2031                     std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_IT_ADDR_IOMMU_WRITE_1 state" << std::endl;
    2032                     std::cout << " PTE invalidation command should contain just one flit" << std::endl;
    2033                     r_config_error_type = WRITE_ERROR;
    2034                     r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    2035                 }
    2036                 else
    2037                 {
    2038                     // If physical address holds on a single word
    2039                     r_it_addr[r_it_index.read()] = (paddr_t)(p_vci_tgt_config.wdata.read());
    2040                  
    2041                     config_local_fifo_put = true;
    2042                     r_config_cmd_fsm = CONFIG_CMD_IDLE;
    2043                 }
    2044        
    2045             }
    2046             else
    2047             {
    2048             // two flits are required to send address
    2049                 if ( p_vci_tgt_config.eop.read() )
    2050                 {
    2051                    
    2052                     std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_IT_ADDR_IOMMU_WRITE_1 state" << std::endl;
    2053                     std::cout << " PTE invalidation commands should contain two flits" << std::endl;
    2054                     r_config_error_type = WRITE_ERROR;
    2055                     r_config_cmd_fsm = CONFIG_CMD_ERROR_RSP;
    2056                 }
    2057                 else
    2058                 {
    2059                     r_config_first_word = p_vci_tgt_config.wdata.read();
    2060                     r_config_cmd_fsm = CONFIG_CMD_IT_ADDR_IOMMU_WRITE_2;
    2061                 }
    2062             }
    2063         }
    2064         break;
    2065     }
    2066     /////////////////
    2067     case CONFIG_CMD_IT_ADDR_IOMMU_WRITE_2:
    2068     {
    2069         if ( p_vci_tgt_config.cmdval.read() && m_config_local_data_fifo.wok() )
    2070         {
    2071             if ( !p_vci_tgt_config.eop.read() )
    2072             {
    2073                 std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_IT_IOMMU_WRITE_2 state" << std::endl;
    2074                 std::cout << " PTE invalidation commands must contain two flits" << std::endl;
    2075                 r_config_error_type = WRITE_ERROR;
    2076                 r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    2077                 break;
    2078             }
    2079            
    2080             // Depends on the convention
    2081             size_t mask_msb = (1 << (vci_param_d::N - 32)) - 1 ;
    2082             r_it_addr_iommu = (paddr_t)(r_config_first_word.read() |
    2083                                    ((p_vci_tgt_config.wdata.read()& mask_msb)<<32));
    2084              
    2085             config_local_fifo_put = true;
    2086             r_config_cmd_fsm = CONFIG_CMD_IDLE;
    2087         }
    2088     }
    2089     //////////////////
    2090     case CONFIG_CMD_IT_ADDR_WRITE_1:
    2091     {
    2092         if ( p_vci_tgt_config.cmdval.read() && m_config_local_data_fifo.wok())
    2093         {
    2094             if(vci_param_d::N <= 32)
    2095             {
    2096             // address holds in one single flit
    2097                 if (!p_vci_tgt_config.eop.read() )
    2098                 {
    2099                    
    2100                     std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_IT_ADDR_WRITE_1 state" << std::endl;
    2101                     std::cout << " PTE invalidation command should contain just one flit" << std::endl;
    2102                     r_config_error_type = WRITE_ERROR;
    2103                     r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    2104                    
    2105                    
    2106                 }
    2107                 else
    2108                 {
    2109                     // If physical address holds on a single word
    2110                     r_it_addr[r_it_index.read()] = (paddr_t)(p_vci_tgt_config.wdata.read());
    2111                  
    2112                     config_local_fifo_put = true;
    2113                     r_config_cmd_fsm = CONFIG_CMD_IDLE;
    2114                 }
    2115        
    2116             }
    2117             else
    2118             {
    2119             // two flits are required to send address
    2120                 if ( p_vci_tgt_config.eop.read() )
    2121                 {
    2122                    
    2123                     std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_IT_ADDR_WRITE_1 state" << std::endl;
    2124                     std::cout << " PTE invalidation commands should contain two flits" << std::endl;
    2125                     r_config_error_type = WRITE_ERROR;
    2126                     r_config_cmd_fsm = CONFIG_CMD_ERROR_RSP;
    2127                 }
    2128                 else
    2129                 {
    2130                     r_config_first_word = p_vci_tgt_config.wdata.read();
    2131                     r_config_cmd_fsm = CONFIG_CMD_IT_ADDR_WRITE_2;
    2132                 }
    2133             }
    2134         }
    2135         break;
    2136     }
    2137     /////////////////
    2138     case CONFIG_CMD_IT_ADDR_WRITE_2:
    2139     {
    2140         if ( p_vci_tgt_config.cmdval.read() && m_config_local_data_fifo.wok() )
    2141         {
    2142             if ( !p_vci_tgt_config.eop.read() )
    2143             {
    2144                 std::cout << "CONFIG_CMD ERROR " << name() << " CONFIG_CMD_IT_ADDR_WRITE_2 state" << std::endl;
    2145                 std::cout << " PTE invalidation commands must contain two flits" << std::endl;
    2146                 r_config_error_type = WRITE_ERROR;
    2147                 r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    2148                 break;
    2149             }
    2150            
    2151             // Depends on the convention
    2152             size_t mask_msb = (1 << (vci_param_d::N - 32)) - 1 ;
    2153             r_it_addr[r_it_index.read()] = (paddr_t)(r_config_first_word.read() |
    2154                                 ((p_vci_tgt_config.wdata.read()& mask_msb)<<32));
    2155              
    2156             config_local_fifo_put = true;
    2157             r_config_cmd_fsm = CONFIG_CMD_IDLE;
    2158         }
    2159     }
    2160     //////////////////
    2161     case CONFIG_CMD_PTPR_READ:
    2162     case CONFIG_CMD_ACTIVE_READ:
    2163     case CONFIG_CMD_BVAR_READ:
    2164     case CONFIG_CMD_ETR_READ:
    2165     case CONFIG_CMD_BAD_ID_READ:
    2166     case CONFIG_CMD_IT_ADDR_IOMMU_READ_1:
    2167     case CONFIG_CMD_IT_ADDR_READ_1:
    2168     {
    2169         if ( p_vci_tgt_config.cmdval.read() && m_config_local_data_fifo.wok() )
    2170         {
    2171             // This verification could have been done on IDLE state
    2172             // It would save us one cycle
    2173             if ( !p_vci_tgt_config.eop.read() )
    2174             {
    2175                 std::cout << "CONFIG_CMD ERROR " << name() << config_cmd_fsm_state_str[r_config_cmd_fsm.read()] << std::endl;
    2176                 std::cout << " Read commands must contain one single flit" << std::endl;
    2177                 r_config_error_type = READ_ERROR;
    2178                 r_config_cmd_fsm = CONFIG_CMD_ERROR_WAIT;
    2179                 break;
    2180             }
    2181            
    2182             // fifo data receives the content of the corresponding register
    2183             // (depending on the current state)
    2184             config_local_fifo_put = true;
    2185             if(r_config_cmd_fsm.read()== CONFIG_CMD_IT_ADDR_READ_1)
    2186             r_config_cmd_fsm = CONFIG_CMD_IT_ADDR_READ_2;
    2187             else if(r_config_cmd_fsm.read()== CONFIG_CMD_IT_ADDR_IOMMU_READ_1)
    2188             r_config_cmd_fsm = CONFIG_CMD_IT_ADDR_IOMMU_READ_2;
    2189             else
    2190             r_config_cmd_fsm = CONFIG_CMD_IDLE;
    2191         }
    2192         break;
    2193     }
    2194     //////////////////
    2195     case CONFIG_CMD_IT_ADDR_READ_2:
    2196     case CONFIG_CMD_IT_ADDR_IOMMU_READ_2:
    2197     {
    2198         if ( p_vci_tgt_config.cmdval.read() && m_config_local_data_fifo.wok() )
    2199         {
    2200             config_local_fifo_put = true;
    2201             r_config_cmd_fsm = CONFIG_CMD_IDLE;
    2202         }
    2203     }
    2204     //////////////////
    2205     case CONFIG_CMD_ERROR_WAIT: //receives the other flits of the same transaction
    2206     {
    2207         if ( p_vci_tgt_config.cmdval.read() && p_vci_tgt_config.eop.read() )
    2208         r_config_cmd_fsm = CONFIG_CMD_ERROR_RSP;
    2209     }
    2210     ///////////////////
    2211     case CONFIG_CMD_ERROR_RSP:
    2212     {
    2213         if ( m_config_local_data_fifo.wok() )
    2214         {
    2215             config_local_fifo_put = true;
    2216             r_config_cmd_fsm = CONFIG_CMD_IDLE;
    2217         }
    2218         break;
    2219     }
    2220 
    2221     } // end switch CONFIG_CMD FSM
    2222 
    2223     /////////////////////////////////////////////////////////////////////
    2224     // The CONFIG_RSP_FSM controls the following ressources:
    2225     // - r_config_rsp_fsm
    2226     // - r_config_cmd_rsp_erase_req (reset)
    2227     // -
    2228     // -
    2229     //////////////////////////////////////////////////////////////////////////////
    2230     switch( r_config_rsp_fsm.read() )
    2231     {
    2232     /////////////////////
    2233     case CONFIG_RSP_IDLE:
     1394    case CONFIG_RSP_IDLE:  // waiting a VCI response from IOX network
    22341395    {           
    2235         if(p_vci_ini_config.rspval.read())
     1396        if ( p_vci_ini_iox.rspval.read() )
    22361397                {
    2237             r_config_rsp_fsm = CONFIG_RSP_TRT_LOCK;
     1398            r_config_rsp_fsm = CONFIG_RSP_FIFO_PUT;
    22381399                }
    22391400                break;
    22401401    }
    2241     /////////////////////
    2242     case CONFIG_RSP_TRT_LOCK:
    2243     {           
    2244         if ( r_alloc_trt_config_fsm.read() == ALLOC_TRT_CONFIG_RSP )
    2245         {
    2246            
    2247 #if DEBUG_CONFIG_RSP
    2248 if( m_debug_config_rsp_fsm )
    2249 {
    2250     std::cout << "  <IOB.CONFIG_RSP_TRT_LOCK> Read and erase entry" << std::endl;
    2251 }
    2252 #endif
    2253             uint32_t trdid_iospace = p_vci_ini_config.rtrdid.read();
    2254            
    2255             r_config_rsrcid = (vci_srcid_t)m_transaction_tab_config.readSrcid(trdid_iospace);
    2256             r_config_rtrdid = (vci_trdid_t)m_transaction_tab_config.readTrdid(trdid_iospace);
    2257             m_transaction_tab_config.erase(trdid_iospace);
    2258             if (r_config_cmd_rsp_erase_req.read()) r_config_cmd_rsp_erase_req = false;
    2259             r_config_rsp_fsm       = CONFIG_RSP_FIFO_PUT;
    2260         }       
    2261                 break;
    2262     }
    2263     //////////////////
    2264     case CONFIG_RSP_FIFO_PUT:
    2265     {
    2266         if(p_vci_ini_config.rspval.read() && m_config_rsp_data_fifo.wok())
     1402    /////////////////////////
     1403    case CONFIG_RSP_FIFO_PUT:  // try to write into CONFIG_RSP fifo
     1404                               // as soon as it is allocated
     1405    {
     1406        if ( p_vci_ini_iox.rspval.read() and not r_alloc_fifo_config_rsp_local.read() )
    22671407        {
    22681408            config_rsp_fifo_put = true;
    2269             if(p_vci_ini_config.reop.read())   r_config_rsp_fsm = CONFIG_RSP_IDLE;     
     1409
     1410            if ( m_config_rsp_data_fifo.wok() )
     1411            {
     1412                if ( p_vci_ini_iox.reop.read() ) r_config_rsp_fsm = CONFIG_RSP_IDLE;   
    22701413
    22711414#if DEBUG_CONFIG_RSP
    2272 if( m_debug_config_rsp_fsm )
    2273 {
    2274     std::cout << "  <IOB.CONFIG_RSP_FIFO_PUT> Push into rsp_fifo:"
    2275               << " rsrcid = " << std::dec << r_config_rsrcid.read()
    2276               << " rtrdid = " << r_config_rtrdid.read()
    2277               << " rdata = " << std::hex << p_vci_ini_config.rdata.read()
    2278     << std::endl;
    2279 }
    2280 #endif
     1415if( m_debug_activated )
     1416std::cout << "  <IOB CONFIG_RSP_FIFO_PUT> Push response into CONFIG_RSP fifo:"
     1417          << " / rsrcid = " << std::hex << p_vci_ini_iox.rsrcid.read()
     1418          << " / rtrdid = " << p_vci_ini_iox.rtrdid.read()
     1419          << " / rdata = " << p_vci_ini_iox.rdata.read()
     1420          << " / reop  = " << p_vci_ini_iox.reop.read()
     1421          << " / rerror = " << p_vci_ini_iox.rerror.read() << std::endl;
     1422#endif
     1423            }
    22811424                       
    22821425        }
     
    22851428    } // end switch CONFIG_RSP FSM
    22861429
    2287 
    2288     ////////////////////////////////////////////////////////////////////////////
    2289     // The ALLOC_TRT_CONFIG fsm allocates the access to the Transaction Table (m_transaction_tab_config)
    2290     // with a round robin priority between 2 user FSMs :
    2291     // - CONFIG_CMD : to set a new entry
    2292     // - CONFIG_RSP : to read and erase an entry
    2293     // The ressource is always allocated.
     1430    /////////////////////////////////////////////////////////////////////////////////
     1431    // If the IOB component has IRQ ports, the IRQ FSM detects all changes
     1432    // on the 32 p_irq[i] ports and request a VCI write transaction to the
     1433    // MISS_INIT FSM, using the 64 r_irq_request[i] and r_irq_pending[i] flip-flops.
     1434    /////////////////////////////////////////////////////////////////////////////////
     1435
     1436    if ( m_has_irqs )
     1437    {
     1438        for ( size_t i = 0; i<32; ++i )
     1439        {
     1440            r_irq_request[i] = ( p_irq[i]->read() == not r_irq_pending[i].read() );
     1441            r_irq_pending[i] = p_irq[i]->read();
     1442        }
     1443    }
     1444       
     1445    ///////////////////////////////////////////////////////////////////////////////////
     1446    // The MISS_WTI_CMD FSM send VCI commands on the Internal Network.
     1447    // It handles PTE MISS requests from TLB_MISS FSM and software IRQs.
     1448    // It supports several simultaneous VCI transactions.
    22941449    ////////////////////////////////////////////////////////////////////////////////////
    2295    
    2296     switch ( r_alloc_trt_config_fsm.read() )
    2297     {
    2298     ///////////////////
    2299     case ALLOC_TRT_CONFIG_CMD:
    2300     {
    2301         if ( r_config_cmd_fsm.read() != CONFIG_CMD_TRT_LOCK )
    2302         {
    2303           if (r_config_rsp_fsm.read() == CONFIG_RSP_TRT_LOCK) r_alloc_trt_config_fsm = ALLOC_TRT_CONFIG_RSP;
    2304         }
    2305     }
    2306     ///////////////////
    2307     case ALLOC_TRT_CONFIG_RSP:
    2308     {
    2309         if (r_config_rsp_fsm.read() != CONFIG_RSP_TRT_LOCK)
    2310         {
    2311             if (r_config_cmd_fsm.read() == CONFIG_CMD_TRT_LOCK) r_alloc_trt_config_fsm = ALLOC_TRT_CONFIG_CMD;
    2312         }
    2313     }
    2314     } // end switch r_alloc_trt_config_fsm
    2315 
    2316     ////////////////////////////////////////////////////////////////////////////
    2317     // The MISS_INIT FSM sends a page table entry miss request into Direct Noc
    2318     // It controls the following ressources:
    2319     // - r_miss_init_fsm
    2320     // - r_tlb_miss_init_req (reset)
    2321     // - r_miss_buf_data
    2322     // - r_miss_buf_valid
    2323     // - r_miss_buf_tag
    2324     ////////////////////////////////////////////////////////////////////////////////////
    2325 
    2326     // Building the interruption vector (systematically)
    2327     uint32_t irq_demands = 0;
    2328     for ( size_t i = 0; i<m_nb_periph; ++i )
    2329         irq_demands |= (p_irq_in[i].read() ? 1 : 0) << i;
    2330    
    2331     // For next cycle:
    2332         // Afectation of the new pending vector.
    2333         // Not useful, unless Irq choice is postponed to next cycle
    2334     r_irq_pending = irq_demands & r_irq_mask.read();
    2335         // Updating Mask
    2336     r_irq_mask = r_irq_mask.read()| ~irq_demands; 
    2337    
    23381450 
    2339     switch ( r_miss_init_fsm.read() )
    2340     {
    2341         //////////////
    2342         case MISS_INIT_IDLE_MISS:
    2343         {
    2344             if(r_tlb_miss_init_req.read())
     1451    switch ( r_miss_wti_cmd_fsm.read() )
     1452    {
     1453        ///////////////////////
     1454        case MISS_WTI_CMD_IDLE:   // TLB MISS have highest priority
     1455        {
     1456            if ( r_tlb_miss_req.read() )
    23451457            {
    2346                 r_miss_init_fsm = MISS_INIT_TLB_MISS_CMD;
     1458                r_miss_wti_cmd_fsm = MISS_WTI_CMD_MISS;
    23471459            }
    2348             else if (irq_demands & r_irq_mask.read()){
    2349                 // Choosing one interruption to send           
    2350                 // Find the first bit 1
    2351                 // starting by the bit just after the last chosen
    2352                 size_t i = (r_irq_chosen.read() + 1)% m_nb_periph;
     1460            else if ( r_iommu_wti_enable.read() )
     1461            {
     1462                // checking if there is a new pending interrupt
    23531463                bool found = false;
    2354                 do
    2355                 {
    2356                     if(irq_demands & r_irq_mask.read() & (1<<i))
    2357                     {
    2358                         r_irq_chosen = i;
    2359                         found = true;
    2360                     }
    2361                     i = (i+1) % m_nb_periph;
    2362                 }
    2363                 while(i != r_irq_chosen.read()+1 && !found);
    2364 
    2365                 r_miss_init_fsm = MISS_INIT_IRQ_CMD;
     1464                size_t n;
     1465                for ( n = 0 ; (n < 32) and not found ; n++ )
     1466                {
     1467                    if ( r_irq_request[n] ) found = true;
     1468                }
     1469                if ( found )
     1470                {
     1471                    r_miss_wti_cmd_index = n;
     1472                    r_miss_wti_cmd_fsm   = MISS_WTI_CMD_WTI;
     1473                }
    23661474            }
    23671475                        break;
    23681476        }
    2369         //////////////
    2370         case MISS_INIT_IDLE_IRQ:
    2371         {
    2372             if (irq_demands & r_irq_mask.read()){
    2373                 // Choosing one interruption to send           
    2374                 // Find the first bit 1
    2375                 // starting by the bit just after the last chosen
    2376                 size_t i = (r_irq_chosen.read() + 1)% m_nb_periph;
    2377                 bool found = false;
    2378                 do
    2379                 {
    2380                     if(irq_demands & r_irq_mask.read() & (1<<i))
    2381                     {
    2382                         r_irq_chosen = i;
    2383                         found = true;
    2384                     }
    2385                     i = (i+1) % m_nb_periph;
    2386                 }
    2387                 while(i != r_irq_chosen.read()+1 && !found);
    2388 
    2389                 r_miss_init_fsm = MISS_INIT_IRQ_CMD;
    2390             }
    2391             else if(r_tlb_miss_init_req.read())
     1477        //////////////////////     
     1478        case MISS_WTI_CMD_WTI:   // send a single flit IRQ WRITE on INT Network
     1479                                 // address is defined by IRQ_VECTOR[r_miss_wti_index]
     1480                                 // data is defined by r_irq_pending[r_miss_wti_index]
     1481        {
     1482            if ( p_vci_ini_int.cmdack )
    23921483            {
    2393                 r_miss_init_fsm = MISS_INIT_TLB_MISS_CMD;
    2394             }
    2395                         break;
    2396         }
    2397         /////////////////////////       // send a read request to Direct Network
    2398         case MISS_INIT_IRQ_CMD:
    2399         {
    2400         if ( p_vci_ini_miss.cmdack )
    2401         {
    2402             // Masking chosen interruption, until it is resolved
    2403             r_irq_mask = r_irq_mask.read() & ~(1<<r_irq_chosen.read());
    2404             r_miss_init_fsm = MISS_INIT_IRQ_RSP;               
    2405 
    2406 #if DEBUG_MISS_INIT
    2407 if( m_debug_miss_init_fsm )
    2408 {
    2409     std::cout << "  <IOB.MISS_INIT_IRQ_CMD> Send write (irq) command to XICU"
    2410               << " irq ID = " << std::dec << r_irq_chosen.read()
    2411               << " new mask = " << std::hex << (r_irq_mask.read() & ~(1<<r_irq_chosen.read()))
    2412      << std::endl;
    2413 }
    2414 #endif
    2415         }
    2416             break;
    2417         }
    2418         //////////////////
    2419         case MISS_INIT_IRQ_RSP:
    2420         {
    2421             if ( p_vci_ini_miss.rspval.read() )
    2422             {
    2423                 // It is a WRITE command, response in one single flit long
    2424                 assert( p_vci_ini_miss.reop.read() and "Write answer should have one single flit" );
    2425                 bool error;
    2426                
    2427                 if ( (p_vci_ini_miss.rerror.read()&0x1) != 0 )  // error reported
    2428                 {
    2429                     // TODO traiter error
    2430                     error = true;
    2431                 }
    2432                 r_miss_init_fsm = MISS_INIT_IDLE_MISS;
     1484                // reset the request
     1485                r_irq_request[r_miss_wti_cmd_index.read()] = false;
     1486                r_miss_wti_cmd_fsm = MISS_WTI_RSP_WTI;         
     1487
     1488#if DEBUG_MISS_WTI
     1489if( m_debug_activated )
     1490std::cout << "  <IOB MISS_WTI_CMD_WTI> Send WTI write command on Internal Network"
     1491          << " / IRQID = " << std::dec << r_miss_wti_cmd_index.read() << std::endl;
     1492#endif
    24331493            }
    24341494            break;
    24351495        }
    2436         /////////////////////////       // send a read request to Direct Network
    2437         case MISS_INIT_TLB_MISS_CMD:
    2438         {
    2439         if ( p_vci_ini_miss.cmdack )
    2440         {
    2441             r_miss_rsp_cpt  = 0;    //counter for the response flits
    2442             r_miss_buf_tag  = ( (r_iotlb_paddr.read()) & CACHE_LINE_MASK );
    2443             r_miss_buf_valid = true;
     1496        ///////////////////////
     1497        case MISS_WTI_CMD_MISS:   // send a TLB MISS request on INT Network
     1498        {
     1499            if ( p_vci_ini_int.cmdack )
     1500            {
     1501                r_tlb_buf_tag     = ( (r_tlb_paddr.read()) & CACHE_LINE_MASK );
     1502                r_tlb_buf_valid   = true;
    24441503           
    2445             if(r_tlb_miss_type.read()== PTE1_MISS)
    2446                 r_miss_buf_vaddr_begin =(r_iotlb_vaddr.read() & ~M_PAGE_OFFSET_MASK & ~PTE1_LINE_OFFSET);
    2447             else
    2448                 r_miss_buf_vaddr_begin =(r_iotlb_vaddr.read() & ~K_PAGE_OFFSET_MASK & ~PTE2_LINE_OFFSET);
     1504                if( r_tlb_miss_type.read() == PTE1_MISS )
     1505                    r_tlb_buf_vaddr = (r_dma_cmd_vaddr.read() &
     1506                                        ~M_PAGE_OFFSET_MASK & ~PTE1_LINE_OFFSET);
     1507                else
     1508                    r_tlb_buf_vaddr = (r_dma_cmd_vaddr.read() &
     1509                                        ~K_PAGE_OFFSET_MASK & ~PTE2_LINE_OFFSET);
    24491510               
    2450             r_miss_init_fsm = MISS_INIT_TLB_MISS_RSP;           
    2451 
    2452 #if DEBUG_MISS_INIT
    2453 if( m_debug_miss_init_fsm )
    2454 {
    2455     std::cout << "  <IOB.MISS_INIT_TLB_MISS_CMD> Send read (tlb entry) request to MEM CACHE: "
    2456     << " | address :  "<< std::hex <<(paddr_t)((r_iotlb_paddr.read())& CACHE_LINE_MASK)
    2457     << std::endl;
    2458 }
    2459 #endif
    2460         }
     1511                r_miss_wti_cmd_fsm = MISS_WTI_RSP_MISS;         
     1512
     1513#if DEBUG_MISS_WTI
     1514if( m_debug_activated )
     1515std::cout << "  <IOB MISS_WTI_CMD_MISS> Send TLB MISS command on Internal Network" << std::hex
     1516          << " / address = " <<(vci_addr_t)((r_tlb_paddr.read())& CACHE_LINE_MASK) << std::endl;
     1517#endif
     1518            }
    24611519            break;
    24621520        }
    2463         //////////////////
    2464         case MISS_INIT_TLB_MISS_RSP:   
    2465         {
    2466             if ( p_vci_ini_miss.rspval.read() )
     1521    } // end switch r_miss_wti_cmd_fsm
     1522
     1523    ///////////////////////////////////////////////////////////////////////////////////
     1524    // The MISS_WTI_RSP FSM handles VCI responses on the Internal Network.
     1525    // it can be response to TLB MISS (read transaction) or WTI (write transaction).
     1526    // It supports several simultaneous VCI transactions.
     1527    ////////////////////////////////////////////////////////////////////////////////////
     1528 
     1529    switch ( r_miss_wti_rsp_fsm.read() )
     1530    {
     1531        case MISS_WTI_RSP_IDLE:   // waiting a VCI response
     1532        {
     1533            if ( p_vci_ini_int.rspval.read() )
    24671534            {
    2468                 if ( (p_vci_ini_miss.rerror.read()&0x1) != 0 )  // error reported
    2469                 {
    2470                     r_miss_init_error = true;
    2471                     if ( p_vci_ini_miss.reop.read() )
     1535                if ( p_vci_ini_int.rpktid.read() == PKTID_READ )  // it's a TLB MISS response
     1536                {
     1537                    r_miss_wti_rsp_fsm   = MISS_WTI_RSP_MISS;
     1538                    r_miss_wti_rsp_count = 0;
     1539                }
     1540                else                                       // it's a WTI WRITE response
     1541                {
     1542                    r_miss_wti_rsp_fsm   = MISS_WTI_RSP_WTI;
     1543
     1544                }
     1545            }
     1546            break;
     1547        }
     1548        //////////////////////
     1549        case MISS_WTI_RSP_WTI:   // Handling response to a WTI transaction
     1550        {
     1551            assert( p_vci_ini_int.reop.read() and
     1552            "VCI_IO_BRIDGE ERROR: IRQ Write response should have one single flit" );
     1553
     1554            assert( ( (p_vci_ini_int.rerror.read()&0x1) == 0 ) and
     1555            "VCI_IO_BRIDGE ERROR: IRQ Write response error !!!" );
     1556             // TODO traiter error using the IOMMU IRQ
     1557
     1558#if DEBUG_MISS_WTI
     1559if( m_debug_activated )
     1560std::cout << "  <IOB MISS_WTI_RSP_WTI> Response to WTI write" << std::endl;
     1561#endif
     1562            r_miss_wti_rsp_fsm = MISS_WTI_RSP_IDLE;
     1563            break;
     1564        }
     1565        ///////////////////////
     1566        case MISS_WTI_RSP_MISS:   // Handling response to a TLB MISS transaction
     1567        {
     1568            if ( p_vci_ini_int.rspval.read() )
     1569            {
     1570                if ( (p_vci_ini_int.rerror.read()&0x1) != 0 )  // error reported
     1571                {
     1572                    r_miss_wti_rsp_error = true;
     1573                    if ( p_vci_ini_int.reop.read() )
    24721574                    {   
    2473                         r_miss_init_fsm = MISS_INIT_IDLE_IRQ;
    2474                         r_tlb_miss_init_req = false;
     1575                        r_miss_wti_cmd_fsm = MISS_WTI_RSP_IDLE;
     1576                        r_tlb_miss_req = false;
    24751577                    }
    2476 #if DEBUG_MISS_INIT
    2477 if( m_debug_miss_init_fsm )
    2478 {
    2479     std::cout << " <IOB.MISS_INIT_TLB_MISS_RSP> ERROR " << std::endl;
    2480 }
    2481 #endif
    2482                 }
    2483                 else
     1578#if DEBUG_MISS_WTI
     1579if( m_debug_activated )
     1580std::cout << " <IOB MISS_WTI_RSP_MISS> ERROR " << std::endl;
     1581#endif
     1582                }
     1583                else                                           // no error
    24841584                {
    2485                     bool   eop          = p_vci_ini_miss.reop.read();
    2486 
    2487 
    2488 #if DEBUG_MISS_INIT
    2489 if( m_debug_miss_init_fsm )
    2490 {
    2491     std::cout << "  <IOB.MISS_INIT_TLB_MISS_RSP> Response from Mem Cache to a read (tlb entry) transaction. Count = " << r_miss_rsp_cpt.read()
    2492     <<" | Data = " << std::hex << p_vci_ini_miss.rdata.read() << std::endl;
    2493 }
    2494 #endif
    2495 
    2496                     assert(((eop == (r_miss_rsp_cpt.read() == (m_words-1))) )
    2497                         and "Error : invalid length for a response from MEM CACHE");
    2498                     r_miss_buf_data[r_miss_rsp_cpt] =  (uint32_t)p_vci_ini_miss.rdata.read();
    2499                    
    2500                     r_miss_rsp_cpt = r_miss_rsp_cpt.read() + 1;
     1585                    bool   eop          = p_vci_ini_int.reop.read();
     1586
     1587#if DEBUG_MISS_WTI
     1588if( m_debug_activated )
     1589std::cout << "  <IOB MISS_WTI_RSP_MISS> Response to a tlb miss transaction"
     1590          << " / Count = " << r_miss_wti_rsp_count.read()
     1591          << " / Data = " << std::hex << p_vci_ini_int.rdata.read() << std::endl;
     1592#endif
     1593                    assert(((eop == (r_miss_wti_rsp_count.read() == (m_words-1)))) and
     1594                    "VCI_IO_BRIDGE ERROR: invalid length for a TLB MISS response");
     1595
     1596                    r_tlb_buf_data[r_miss_wti_rsp_count.read()] = p_vci_ini_int.rdata.read();
     1597                    r_miss_wti_rsp_count = r_miss_wti_rsp_count.read() + 1;
    25011598                   
    25021599                    if ( eop )
    25031600                    {
    2504                         r_tlb_miss_init_req = false;     //reset the request flip-flop
    2505                         r_miss_init_fsm = MISS_INIT_IDLE_IRQ;           
     1601                        r_tlb_miss_req = false;     //reset the request flip-flop
     1602                        r_miss_wti_cmd_fsm = MISS_WTI_RSP_IDLE;         
    25061603                    }
    2507 
    25081604                }
    25091605            }
    25101606            break;
    25111607        }
    2512 
    2513     } // end  switch r_miss_init_fsm
     1608    } // end  switch r_miss_wti_rsp_fsm
     1609
     1610    /////////////////////////////////////////////////////////////////////////
     1611    // This flip-flop allocates the access to the CONFIG_RSP fifo
     1612    // with a round robin priority between 2 clients FSMs :
     1613    // - CONFIG_CMD : to put a response to a local config command.
     1614    // - CONFIG_RSP : to put a response to a peripheral config command.
     1615    // The ressource is always allocated.
     1616    // A new allocation occurs when the owner FSM is not using it,
     1617    // and the other FSM is requiring it.
     1618    /////////////////////////////////////////////////////////////////////////
    25141619   
    2515     //////////////////////////////////
    2516     // Fifo consumption arbitration //
    2517     //////////////////////////////////
     1620    if ( r_alloc_fifo_config_rsp_local.read() )
     1621    {
     1622        if ( (r_config_rsp_fsm.read() == CONFIG_RSP_FIFO_PUT) and
     1623             (r_config_cmd_fsm.read() != CONFIG_CMD_FIFO_PUT_RSP) )
     1624        r_alloc_fifo_config_rsp_local = false;
     1625    }
     1626    else
     1627    {
     1628        if ( (r_config_cmd_fsm.read() == CONFIG_CMD_FIFO_PUT_RSP) and
     1629             (r_config_rsp_fsm.read() != CONFIG_RSP_FIFO_PUT) )
     1630        r_alloc_fifo_config_rsp_local = true;
     1631    }
     1632
     1633    /////////////////////////////////////////////////////////////////////////
     1634    // This flip-flop allocates the access to the DMA_RSP fifo
     1635    // with a round robin priority between 2 clients FSMs :
     1636    // - DMA_CMD : to put a error response in case of bad address translation
     1637    // - DMA_RSP : to put a normal response to a DMA transaction.
     1638    // The ressource is always allocated.
     1639    // A new allocation occurs when the owner FSM is not using it,
     1640    // and the other FSM is requiring it.
     1641    /////////////////////////////////////////////////////////////////////////
    25181642   
    2519     // Round Robin priority for CONFIG_RSP FIFO consumption
    2520     r_config_rsp_fifo_local_priority = ! r_config_rsp_fifo_local_priority.read();
    2521    
    2522     //DMA CMD
    2523     dma_cmd_fifo_get = (p_vci_ini_dma.cmdack.read() && m_dma_cmd_addr_fifo.rok());
    2524     // DMA RSP
    2525     dma_rsp_fifo_get = (p_vci_tgt_dma.rspack.read() && m_dma_rsp_data_fifo.rok());
    2526     // CONFIG CMD
    2527     config_cmd_fifo_get = (p_vci_ini_config.cmdack.read() && m_config_cmd_addr_fifo.rok() );
    2528     // CONFIG RSP, detemines wich fifo to consume
    2529     if(r_config_rsp_fifo_local_priority)
    2530     {
    2531         if(m_config_local_data_fifo.rok()) config_local_fifo_get = p_vci_tgt_config.rspack.read();
    2532         else if (m_config_rsp_data_fifo.rok()) config_rsp_fifo_get = p_vci_tgt_config.rspack.read();
    2533            
    2534     }
    2535     else
    2536     {
    2537         if (m_config_rsp_data_fifo.rok()) config_rsp_fifo_get = p_vci_tgt_config.rspack.read();
    2538         else if(m_config_local_data_fifo.rok()) config_local_fifo_get = p_vci_tgt_config.rspack.read();
    2539     }
    2540     ///////////////
    2541     //DMA_CMD Fifo
    2542     ///////////////
    2543     if(r_miss_interrupt)
    2544     {
    2545         m_dma_cmd_addr_fifo.update( dma_cmd_fifo_get,
    2546                                     dma_cmd_fifo_put,
    2547                                     r_miss_paddr.read() );
    2548         m_dma_cmd_cmd_fifo.update( dma_cmd_fifo_get,
    2549                                     dma_cmd_fifo_put,
    2550                                     r_miss_cmd.read() );
    2551         m_dma_cmd_contig_fifo.update( dma_cmd_fifo_get,
    2552                                     dma_cmd_fifo_put,
    2553                                     r_miss_contig.read() );
    2554         m_dma_cmd_cons_fifo.update( dma_cmd_fifo_get,
    2555                                     dma_cmd_fifo_put,
    2556                                     r_miss_cons.read() );
    2557         m_dma_cmd_plen_fifo.update( dma_cmd_fifo_get,
    2558                                     dma_cmd_fifo_put,
    2559                                     r_miss_plen.read() );
    2560         m_dma_cmd_wrap_fifo.update( dma_cmd_fifo_get,
    2561                                     dma_cmd_fifo_put,
    2562                                     r_miss_wrap.read() );
    2563         m_dma_cmd_cfixed_fifo.update( dma_cmd_fifo_get,
    2564                                     dma_cmd_fifo_put,
    2565                                     r_miss_cfixed.read() );
    2566         m_dma_cmd_clen_fifo.update( dma_cmd_fifo_get,
    2567                                     dma_cmd_fifo_put,
    2568                                     r_miss_clen.read() );
    2569         m_dma_cmd_srcid_fifo.update( dma_cmd_fifo_get,
    2570                                     dma_cmd_fifo_put,
    2571                                     m_srcid_dma ); //r_miss_srcid.read()
    2572         m_dma_cmd_trdid_fifo.update( dma_cmd_fifo_get,
    2573                                     dma_cmd_fifo_put,
    2574                                     r_miss_trdid.read() );
    2575         m_dma_cmd_pktid_fifo.update( dma_cmd_fifo_get,
    2576                                     dma_cmd_fifo_put,
    2577                                     r_miss_pktid.read() );
    2578         m_dma_cmd_data_fifo.update( dma_cmd_fifo_get,
    2579                                     dma_cmd_fifo_put,
    2580                                     r_miss_data[r_dma_cmd_count.read()-1] );
    2581         m_dma_cmd_be_fifo.update( dma_cmd_fifo_get,
    2582                                     dma_cmd_fifo_put,
    2583                                     r_miss_be[r_dma_cmd_count.read()-1] );
    2584         m_dma_cmd_eop_fifo.update( dma_cmd_fifo_get,
    2585                                     dma_cmd_fifo_put,
    2586                                     (r_dma_cmd_count.read() == 1) );
     1643    if ( r_alloc_fifo_dma_rsp_local.read() )
     1644    {
     1645        if ( (r_dma_rsp_fsm.read() == DMA_RSP_FIFO_PUT) and
     1646             (r_dma_cmd_fsm.read() != DMA_CMD_FIFO_PUT_RSP) )
     1647        r_alloc_fifo_dma_rsp_local = false;
    25871648    }
    25881649    else
    25891650    {
    2590         m_dma_cmd_addr_fifo.update( dma_cmd_fifo_get,
    2591                                     dma_cmd_fifo_put,
    2592                                     r_dma_paddr.read() );
    2593         m_dma_cmd_cmd_fifo.update( dma_cmd_fifo_get,
    2594                                     dma_cmd_fifo_put,
    2595                                     p_vci_tgt_dma.cmd.read() );
    2596         m_dma_cmd_contig_fifo.update( dma_cmd_fifo_get,
    2597                                     dma_cmd_fifo_put,
    2598                                     p_vci_tgt_dma.contig.read() );
    2599         m_dma_cmd_cons_fifo.update( dma_cmd_fifo_get,
    2600                                     dma_cmd_fifo_put,
    2601                                     p_vci_tgt_dma.cons.read() );
    2602         m_dma_cmd_plen_fifo.update( dma_cmd_fifo_get,
    2603                                     dma_cmd_fifo_put,
    2604                                     p_vci_tgt_dma.plen.read() );
    2605         m_dma_cmd_wrap_fifo.update( dma_cmd_fifo_get,
    2606                                     dma_cmd_fifo_put,
    2607                                     p_vci_tgt_dma.wrap.read() );
    2608         m_dma_cmd_cfixed_fifo.update( dma_cmd_fifo_get,
    2609                                     dma_cmd_fifo_put,
    2610                                     p_vci_tgt_dma.cfixed.read() );
    2611         m_dma_cmd_clen_fifo.update( dma_cmd_fifo_get,
    2612                                     dma_cmd_fifo_put,
    2613                                     p_vci_tgt_dma.clen.read() );
    2614         m_dma_cmd_srcid_fifo.update( dma_cmd_fifo_get,
    2615                                     dma_cmd_fifo_put,
    2616                                     m_srcid_dma );
    2617         m_dma_cmd_trdid_fifo.update( dma_cmd_fifo_get,
    2618                                     dma_cmd_fifo_put,
    2619                                     r_dma_cmd_trt_index.read() );
    2620         m_dma_cmd_pktid_fifo.update( dma_cmd_fifo_get,
    2621                                     dma_cmd_fifo_put,
    2622                                     p_vci_tgt_dma.pktid.read() );
    2623         m_dma_cmd_data_fifo.update( dma_cmd_fifo_get,
    2624                                     dma_cmd_fifo_put,
    2625                                     p_vci_tgt_dma.wdata.read() ); // TODO change
    2626                                                             // For 64bits XRAM
    2627         m_dma_cmd_be_fifo.update( dma_cmd_fifo_get,
    2628                                     dma_cmd_fifo_put,
    2629                                     p_vci_tgt_dma.be.read() );
    2630         m_dma_cmd_eop_fifo.update( dma_cmd_fifo_get,
    2631                                     dma_cmd_fifo_put,
    2632                                      p_vci_tgt_dma.eop.read() );
    2633     }
    2634 
    2635     ///////////////
    2636     //DMA_RSP Fifo
    2637     ///////////////
    2638     if(r_dma_rsp_fsm.read() == DMA_RSP_FIFO_ERROR_PUT)
    2639     {
    2640         m_dma_rsp_data_fifo.update( dma_rsp_fifo_get,
    2641                                     dma_rsp_fifo_put,
    2642                                     0 );
     1651        if ( (r_dma_cmd_fsm.read() == DMA_CMD_FIFO_PUT_RSP) and
     1652             (r_dma_rsp_fsm.read() != DMA_RSP_FIFO_PUT) )
     1653        r_alloc_fifo_dma_rsp_local = true;
     1654    }
     1655
     1656    // Define GET signals for all output FIFOs
     1657    dma_cmd_fifo_get    = p_vci_ini_ram.cmdack.read();
     1658    dma_rsp_fifo_get    = p_vci_tgt_iox.rspack.read();
     1659    config_cmd_fifo_get = p_vci_ini_iox.cmdack.read();
     1660    config_rsp_fifo_get = p_vci_tgt_int.rspack.read();
     1661
     1662    ///////////////////////////////////////////////////////////
     1663    // DMA_CMD fifo update
     1664    // One writer : DMA_CMD FSM
     1665    ///////////////////////////////////////////////////////////
     1666
     1667    m_dma_cmd_addr_fifo.update(   dma_cmd_fifo_get,
     1668                                  dma_cmd_fifo_put,
     1669                                  r_dma_cmd_paddr.read() );   // address translation
     1670    m_dma_cmd_cmd_fifo.update(    dma_cmd_fifo_get,
     1671                                  dma_cmd_fifo_put,
     1672                                  p_vci_tgt_iox.cmd.read() );
     1673    m_dma_cmd_contig_fifo.update( dma_cmd_fifo_get,
     1674                                  dma_cmd_fifo_put,
     1675                                  p_vci_tgt_iox.contig.read() );
     1676    m_dma_cmd_cons_fifo.update(   dma_cmd_fifo_get,
     1677                                  dma_cmd_fifo_put,
     1678                                  p_vci_tgt_iox.cons.read() );
     1679    m_dma_cmd_plen_fifo.update(   dma_cmd_fifo_get,
     1680                                  dma_cmd_fifo_put,
     1681                                  p_vci_tgt_iox.plen.read() );
     1682    m_dma_cmd_wrap_fifo.update(   dma_cmd_fifo_get,
     1683                                  dma_cmd_fifo_put,
     1684                                  p_vci_tgt_iox.wrap.read() );
     1685    m_dma_cmd_cfixed_fifo.update( dma_cmd_fifo_get,
     1686                                  dma_cmd_fifo_put,
     1687                                  p_vci_tgt_iox.cfixed.read() );
     1688    m_dma_cmd_clen_fifo.update(   dma_cmd_fifo_get,
     1689                                  dma_cmd_fifo_put,
     1690                                  p_vci_tgt_iox.clen.read() );
     1691    m_dma_cmd_srcid_fifo.update(  dma_cmd_fifo_get,
     1692                                  dma_cmd_fifo_put,
     1693                                  p_vci_tgt_iox.srcid.read() );
     1694    m_dma_cmd_trdid_fifo.update(  dma_cmd_fifo_get,
     1695                                  dma_cmd_fifo_put,
     1696                                  p_vci_tgt_iox.trdid.read() );
     1697    m_dma_cmd_pktid_fifo.update(  dma_cmd_fifo_get,
     1698                                  dma_cmd_fifo_put,
     1699                                  p_vci_tgt_iox.pktid.read() );
     1700    m_dma_cmd_data_fifo.update(   dma_cmd_fifo_get,
     1701                                  dma_cmd_fifo_put,
     1702                                  p_vci_tgt_iox.wdata.read() );
     1703    m_dma_cmd_be_fifo.update(     dma_cmd_fifo_get,
     1704                                  dma_cmd_fifo_put,
     1705                                  p_vci_tgt_iox.be.read() );
     1706    m_dma_cmd_eop_fifo.update(    dma_cmd_fifo_get,
     1707                                  dma_cmd_fifo_put,
     1708                                  p_vci_tgt_iox.eop.read() );
     1709
     1710    //////////////////////////////////////////////////////////////
     1711    // DMA_RSP fifo update
     1712    // Two writers : DMA_CMD FSM & DMA_RSP FSM
     1713    //////////////////////////////////////////////////////////////
     1714
     1715    if (r_alloc_fifo_dma_rsp_local.read() )  // owner is DMA_CMD FSM
     1716                                             // local response for a translation error
     1717    {
     1718        m_dma_rsp_data_fifo.update(   dma_rsp_fifo_get,
     1719                                      dma_rsp_fifo_put,
     1720                                      0 );                      // no data if error
    26431721        m_dma_rsp_rsrcid_fifo.update( dma_rsp_fifo_get,
    2644                                     dma_rsp_fifo_put,
    2645                                     r_iommu_bad_id.read() );
     1722                                      dma_rsp_fifo_put,
     1723                                      p_vci_tgt_iox.rsrcid.read() );
    26461724        m_dma_rsp_rtrdid_fifo.update( dma_rsp_fifo_get,
    2647                                     dma_rsp_fifo_put,
    2648                                     r_dma_error_trdid.read() );
     1725                                      dma_rsp_fifo_put,
     1726                                      p_vci_tgt_iox.rtrdid.read() );
    26491727        m_dma_rsp_rpktid_fifo.update( dma_rsp_fifo_get,
    2650                                     dma_rsp_fifo_put,
    2651                                     r_dma_error_pktid.read() );
    2652         m_dma_rsp_reop_fifo.update( dma_rsp_fifo_get,
    2653                                    dma_rsp_fifo_put,
    2654                                    true );
     1728                                      dma_rsp_fifo_put,
     1729                                      p_vci_tgt_iox.rpktid.read() );
     1730        m_dma_rsp_reop_fifo.update(   dma_rsp_fifo_get,
     1731                                      dma_rsp_fifo_put,
     1732                                      true );                    // single flit response
    26551733        m_dma_rsp_rerror_fifo.update( dma_rsp_fifo_get,
    26561734                                      dma_rsp_fifo_put,
    2657                                       r_dma_error_type.read() );
    2658     }
    2659     else
    2660     {
    2661         m_dma_rsp_data_fifo.update( dma_rsp_fifo_get,
    2662                                     dma_rsp_fifo_put,
    2663                                     p_vci_ini_dma.rdata.read() );
     1735                                      1 );                        // error
     1736    }
     1737    else                                   // owner is DMA_RSP FSM
     1738                                           // normal response to a DMA transaction
     1739    {
     1740        m_dma_rsp_data_fifo.update(   dma_rsp_fifo_get,
     1741                                      dma_rsp_fifo_put,
     1742                                      p_vci_ini_ram.rdata.read() );
    26641743        m_dma_rsp_rsrcid_fifo.update( dma_rsp_fifo_get,
    2665                                     dma_rsp_fifo_put,
    2666                                     r_dma_rsrcid.read() );
     1744                                      dma_rsp_fifo_put,
     1745                                      p_vci_ini_ram.rsrcid.read() );
    26671746        m_dma_rsp_rtrdid_fifo.update( dma_rsp_fifo_get,
    2668                                     dma_rsp_fifo_put,
    2669                                     r_dma_rtrdid.read() );
     1747                                      dma_rsp_fifo_put,
     1748                                      p_vci_ini_ram.rtrdid.read() );
    26701749        m_dma_rsp_rpktid_fifo.update( dma_rsp_fifo_get,
    2671                                     dma_rsp_fifo_put,
    2672                                     p_vci_ini_dma.rpktid.read() );
    2673         m_dma_rsp_reop_fifo.update( dma_rsp_fifo_get,
    2674                                    dma_rsp_fifo_put,
    2675                                    p_vci_ini_dma.reop.read() );
     1750                                      dma_rsp_fifo_put,
     1751                                      p_vci_ini_ram.rpktid.read() );
     1752        m_dma_rsp_reop_fifo.update(   dma_rsp_fifo_get,
     1753                                      dma_rsp_fifo_put,
     1754                                      p_vci_ini_ram.reop.read() );
    26761755        m_dma_rsp_rerror_fifo.update( dma_rsp_fifo_get,
    26771756                                      dma_rsp_fifo_put,
    2678                                       p_vci_ini_dma.rerror.read() );
    2679     }
    2680 
    2681     //////////////////
    2682     //CONFIG_CMD Fifo
    2683     //////////////////
    2684     m_config_cmd_addr_fifo.update( config_cmd_fifo_get,
    2685                                 config_cmd_fifo_put,
    2686                                 r_config_vaddr.read() );
    2687     m_config_cmd_cmd_fifo.update( config_cmd_fifo_get,
    2688                                 config_cmd_fifo_put,
    2689                                 p_vci_tgt_config.cmd.read() );
     1757                                      p_vci_ini_ram.rerror.read() );
     1758    }
     1759
     1760    ////////////////////////////////////////////////////////////////
     1761    // CONFIG_CMD fifo update
     1762    // One writer : CONFIG_CMD FSM
     1763    ////////////////////////////////////////////////////////////////
     1764
     1765    m_config_cmd_addr_fifo.update(   config_cmd_fifo_get,
     1766                                     config_cmd_fifo_put,
     1767                                     p_vci_tgt_int.address.read() );
     1768    m_config_cmd_cmd_fifo.update(    config_cmd_fifo_get,
     1769                                     config_cmd_fifo_put,
     1770                                     p_vci_tgt_int.cmd.read() );
    26901771    m_config_cmd_contig_fifo.update( config_cmd_fifo_get,
    2691                                 config_cmd_fifo_put,
    2692                                 p_vci_tgt_config.contig.read() );
    2693     m_config_cmd_cons_fifo.update( config_cmd_fifo_get,
    2694                                 config_cmd_fifo_put,
    2695                                 p_vci_tgt_config.cons.read() );
    2696     m_config_cmd_plen_fifo.update( config_cmd_fifo_get,
    2697                                 config_cmd_fifo_put,
    2698                                 p_vci_tgt_config.plen.read() );
    2699     m_config_cmd_wrap_fifo.update( config_cmd_fifo_get,
    2700                                 config_cmd_fifo_put,
    2701                                 p_vci_tgt_config.wrap.read() );
     1772                                     config_cmd_fifo_put,
     1773                                     p_vci_tgt_int.contig.read() );
     1774    m_config_cmd_cons_fifo.update(   config_cmd_fifo_get,
     1775                                     config_cmd_fifo_put,
     1776                                     p_vci_tgt_int.cons.read() );
     1777    m_config_cmd_plen_fifo.update(   config_cmd_fifo_get,
     1778                                     config_cmd_fifo_put,
     1779                                     p_vci_tgt_int.plen.read() );
     1780    m_config_cmd_wrap_fifo.update(   config_cmd_fifo_get,
     1781                                     config_cmd_fifo_put,
     1782                                     p_vci_tgt_int.wrap.read() );
    27021783    m_config_cmd_cfixed_fifo.update( config_cmd_fifo_get,
    2703                                 config_cmd_fifo_put,
    2704                                 p_vci_tgt_config.cfixed.read() );
    2705     m_config_cmd_clen_fifo.update( config_cmd_fifo_get,
    2706                                 config_cmd_fifo_put,
    2707                                 p_vci_tgt_config.clen.read() );
    2708     m_config_cmd_srcid_fifo.update( config_cmd_fifo_get,
    2709                                 config_cmd_fifo_put,
    2710                                 m_srcid_config );
    2711     m_config_cmd_trdid_fifo.update( config_cmd_fifo_get,
    2712                                 config_cmd_fifo_put,
    2713                                 r_config_cmd_trt_index.read() );
    2714     m_config_cmd_pktid_fifo.update( config_cmd_fifo_get,
    2715                                 config_cmd_fifo_put,
    2716                                 p_vci_tgt_config.pktid.read() );
    2717     m_config_cmd_data_fifo.update( config_cmd_fifo_get,
    2718                                 config_cmd_fifo_put,
    2719                                 p_vci_tgt_config.wdata.read() );
    2720     m_config_cmd_be_fifo.update( config_cmd_fifo_get,
    2721                                 config_cmd_fifo_put,
    2722                                 p_vci_tgt_config.be.read() );
    2723     m_config_cmd_eop_fifo.update( config_cmd_fifo_get,
    2724                                     config_cmd_fifo_put,
    2725                                      p_vci_tgt_config.eop.read() );
     1784                                     config_cmd_fifo_put,
     1785                                     p_vci_tgt_int.cfixed.read() );
     1786    m_config_cmd_clen_fifo.update(   config_cmd_fifo_get,
     1787                                     config_cmd_fifo_put,
     1788                                     p_vci_tgt_int.clen.read() );
     1789    m_config_cmd_srcid_fifo.update(  config_cmd_fifo_get,
     1790                                     config_cmd_fifo_put,
     1791                                     p_vci_tgt_int.srcid.read() );
     1792    m_config_cmd_trdid_fifo.update(  config_cmd_fifo_get,
     1793                                     config_cmd_fifo_put,
     1794                                     p_vci_tgt_int.trdid.read() );
     1795    m_config_cmd_pktid_fifo.update(  config_cmd_fifo_get,
     1796                                     config_cmd_fifo_put,
     1797                                     p_vci_tgt_int.pktid.read() );
     1798    m_config_cmd_data_fifo.update(   config_cmd_fifo_get,
     1799                                     config_cmd_fifo_put,
     1800                                     (ext_data_t)p_vci_tgt_int.wdata.read() );
     1801    m_config_cmd_be_fifo.update(     config_cmd_fifo_get,
     1802                                     config_cmd_fifo_put,
     1803                                     p_vci_tgt_int.be.read() );
     1804    m_config_cmd_eop_fifo.update(    config_cmd_fifo_get,
     1805                                     config_cmd_fifo_put,
     1806                                     p_vci_tgt_int.eop.read() );
    27261807   
    2727     //////////////////
    2728     //CONFIG_RSP Fifo
    2729     //////////////////
    2730     m_config_rsp_data_fifo.update( config_rsp_fifo_get,
    2731                                 config_rsp_fifo_put,
    2732                                 p_vci_ini_config.rdata.read() );
    2733     m_config_rsp_rsrcid_fifo.update( config_rsp_fifo_get,
    2734                                 config_rsp_fifo_put,
    2735                                 r_config_rsrcid.read() );
    2736     m_config_rsp_rtrdid_fifo.update( config_rsp_fifo_get,
    2737                                 config_rsp_fifo_put,
    2738                                 r_config_rtrdid.read() );
    2739     m_config_rsp_rpktid_fifo.update( config_rsp_fifo_get,
    2740                                 config_rsp_fifo_put,
    2741                                 p_vci_ini_config.rpktid.read() );
    2742     m_config_rsp_reop_fifo.update( config_rsp_fifo_get,
    2743                                config_rsp_fifo_put,
    2744                                p_vci_ini_config.reop.read() );
    2745     m_config_rsp_rerror_fifo.update( config_rsp_fifo_get,
    2746                                   config_rsp_fifo_put,
    2747                                   p_vci_ini_config.rerror.read() );
     1808    //////////////////////////////////////////////////////////////////////////
     1809    // CONFIG_RSP fifo update
     1810    // There is two writers : CONFIG_CMD FSM & CONFIG_RSP FSM
     1811    //////////////////////////////////////////////////////////////////////////
     1812
     1813    if ( r_alloc_fifo_config_rsp_local.read() )  // owner is CONFIG_CMD FSM
     1814                                                 // response for a local config transaction
     1815    {
     1816        m_config_rsp_data_fifo.update(   config_rsp_fifo_get,
     1817                                         config_rsp_fifo_put,
     1818                                         (int_data_t)r_config_cmd_rdata.read() );
     1819        m_config_rsp_rsrcid_fifo.update( config_rsp_fifo_get,
     1820                                         config_rsp_fifo_put,
     1821                                         p_vci_tgt_int.srcid.read() );
     1822        m_config_rsp_rtrdid_fifo.update( config_rsp_fifo_get,
     1823                                         config_rsp_fifo_put,
     1824                                         p_vci_tgt_int.trdid.read() );
     1825        m_config_rsp_rpktid_fifo.update( config_rsp_fifo_get,
     1826                                         config_rsp_fifo_put,
     1827                                         p_vci_tgt_int.pktid.read() );
     1828        m_config_rsp_reop_fifo.update(   config_rsp_fifo_get,
     1829                                         config_rsp_fifo_put,
     1830                                         true );                // local config are one flit
     1831        m_config_rsp_rerror_fifo.update( config_rsp_fifo_get,
     1832                                         config_rsp_fifo_put,
     1833                                         r_config_cmd_error.read() );
     1834    }
     1835    else                                         // owner is CONFIG_RSP FSM
     1836                                                 // response for a remote transaction
     1837    {
     1838        m_config_rsp_data_fifo.update(   config_rsp_fifo_get,
     1839                                         config_rsp_fifo_put,
     1840                                         (int_data_t)p_vci_ini_iox.rdata.read() );
     1841        m_config_rsp_rsrcid_fifo.update( config_rsp_fifo_get,
     1842                                         config_rsp_fifo_put,
     1843                                         p_vci_ini_iox.rsrcid.read() );
     1844        m_config_rsp_rtrdid_fifo.update( config_rsp_fifo_get,
     1845                                         config_rsp_fifo_put,
     1846                                         p_vci_ini_iox.rtrdid.read() );
     1847        m_config_rsp_rpktid_fifo.update( config_rsp_fifo_get,
     1848                                         config_rsp_fifo_put,
     1849                                         p_vci_ini_iox.rpktid.read() );
     1850        m_config_rsp_reop_fifo.update(   config_rsp_fifo_get,
     1851                                         config_rsp_fifo_put,
     1852                                         p_vci_ini_iox.reop.read() );
     1853        m_config_rsp_rerror_fifo.update( config_rsp_fifo_get,
     1854                                         config_rsp_fifo_put,
     1855                                         p_vci_ini_iox.rerror.read() );
     1856    }
    27481857   
    2749     ///////////////////////
    2750     //CONFIG Local RSP Fifo
    2751     ///////////////////////
    2752     m_config_local_rsrcid_fifo.update( config_local_fifo_get,
    2753                                 config_local_fifo_put,
    2754                                 p_vci_tgt_config.srcid.read() );
    2755     m_config_local_rtrdid_fifo.update( config_local_fifo_get,
    2756                                 config_local_fifo_put,
    2757                                 p_vci_tgt_config.trdid.read() );
    2758     m_config_local_rpktid_fifo.update( config_local_fifo_get,
    2759                                 config_local_fifo_put,
    2760                                 p_vci_tgt_config.pktid.read() );
    2761    
    2762     switch( r_config_cmd_fsm.read() )
    2763     {
    2764     case CONFIG_CMD_PTPR_WRITE:
    2765     case CONFIG_CMD_ACTIVE_WRITE:
    2766     case CONFIG_CMD_IT_ADDR_IOMMU_WRITE_2:
    2767     case CONFIG_CMD_IT_ADDR_WRITE_2:
    2768     case CONFIG_CMD_INVAL:
    2769         m_config_local_data_fifo.update( config_local_fifo_get,
    2770                                 config_local_fifo_put,
    2771                                 0);
    2772         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2773                                         config_local_fifo_put,
    2774                                         WRITE_OK );
    2775         m_config_local_reop_fifo.update( config_local_fifo_get,
    2776                                         config_local_fifo_put,
    2777                                         true );
    2778         break;
    2779     case CONFIG_CMD_PTPR_READ:
    2780         m_config_local_data_fifo.update( config_local_fifo_get,
    2781                                 config_local_fifo_put,
    2782                                 r_iommu_ptpr.read());
    2783         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2784                                         config_local_fifo_put,
    2785                                         READ_OK );
    2786         m_config_local_reop_fifo.update( config_local_fifo_get,
    2787                                         config_local_fifo_put,
    2788                                         true );
    2789         break;
    2790     case CONFIG_CMD_ACTIVE_READ:
    2791         m_config_local_data_fifo.update( config_local_fifo_get,
    2792                                 config_local_fifo_put,
    2793                                 r_iommu_active.read());
    2794         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2795                                         config_local_fifo_put,
    2796                                         READ_OK );
    2797         m_config_local_reop_fifo.update( config_local_fifo_get,
    2798                                         config_local_fifo_put,
    2799                                         true );
    2800         break;
    2801     case CONFIG_CMD_BVAR_READ:
    2802         m_config_local_data_fifo.update( config_local_fifo_get,
    2803                                 config_local_fifo_put,
    2804                                 r_iommu_bvar.read());
    2805         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2806                                         config_local_fifo_put,
    2807                                         READ_OK );
    2808         m_config_local_reop_fifo.update( config_local_fifo_get,
    2809                                         config_local_fifo_put,
    2810                                         true );
    2811         break;
    2812     case CONFIG_CMD_ETR_READ:
    2813         m_config_local_data_fifo.update( config_local_fifo_get,
    2814                                 config_local_fifo_put,
    2815                                 r_iommu_etr.read());
    2816         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2817                                         config_local_fifo_put,
    2818                                         READ_OK );
    2819         m_config_local_reop_fifo.update( config_local_fifo_get,
    2820                                         config_local_fifo_put,
    2821                                         true );
    2822         break;
    2823     case CONFIG_CMD_BAD_ID_READ:
    2824         m_config_local_data_fifo.update( config_local_fifo_get,
    2825                                 config_local_fifo_put,
    2826                                 r_iommu_bad_id.read());
    2827         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2828                                         config_local_fifo_put,
    2829                                         READ_OK );
    2830         m_config_local_reop_fifo.update( config_local_fifo_get,
    2831                                         config_local_fifo_put,
    2832                                         true );
    2833         break;
    2834     case CONFIG_CMD_IT_ADDR_IOMMU_READ_1:
    2835         m_config_local_data_fifo.update( config_local_fifo_get,
    2836                                 config_local_fifo_put,
    2837                                 (uint32_t)(r_it_addr_iommu.read() & 0xFFFFFFFF) );
    2838         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2839                                         config_local_fifo_put,
    2840                                         READ_OK );
    2841         m_config_local_reop_fifo.update( config_local_fifo_get,
    2842                                         config_local_fifo_put,
    2843                                         false );
    2844         break;
    2845     case CONFIG_CMD_IT_ADDR_IOMMU_READ_2:
    2846         m_config_local_data_fifo.update( config_local_fifo_get,
    2847                                 config_local_fifo_put,
    2848                                (uint32_t)((r_it_addr_iommu.read()>>32)&0xFF) );
    2849         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2850                                         config_local_fifo_put,
    2851                                         READ_OK );
    2852         m_config_local_reop_fifo.update( config_local_fifo_get,
    2853                                         config_local_fifo_put,
    2854                                         true );
    2855         break;
    2856     case CONFIG_CMD_IT_ADDR_READ_1:
    2857         m_config_local_data_fifo.update( config_local_fifo_get,
    2858                                 config_local_fifo_put,
    2859                                (uint32_t)(r_it_addr[r_it_index.read()] & 0xFFFFFFFF) );
    2860         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2861                                         config_local_fifo_put,
    2862                                         READ_OK );
    2863         m_config_local_reop_fifo.update( config_local_fifo_get,
    2864                                         config_local_fifo_put,
    2865                                         false );
    2866         break;
    2867     case CONFIG_CMD_IT_ADDR_READ_2:
    2868         m_config_local_data_fifo.update( config_local_fifo_get,
    2869                                 config_local_fifo_put,
    2870                                 (uint32_t)((r_it_addr[r_it_index.read()]>>32)&0xFF) );
    2871         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2872                                         config_local_fifo_put,
    2873                                         READ_OK );
    2874         m_config_local_reop_fifo.update( config_local_fifo_get,
    2875                                         config_local_fifo_put,
    2876                                         true );
    2877         break;
    2878     case CONFIG_CMD_ERROR_RSP:
    2879         m_config_local_data_fifo.update( config_local_fifo_get,
    2880                                         config_local_fifo_put,
    2881                                         0);
    2882         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2883                                         config_local_fifo_put,
    2884                                         r_config_error_type.read() );
    2885         m_config_local_reop_fifo.update( config_local_fifo_get,
    2886                                         config_local_fifo_put,
    2887                                         true );
    2888         break;
    2889     default:
    2890         m_config_local_data_fifo.update( config_local_fifo_get,
    2891                                 config_local_fifo_put,
    2892                                 0);
    2893         m_config_local_rerror_fifo.update( config_local_fifo_get,
    2894                                         config_local_fifo_put,
    2895                                         0 );
    2896         m_config_local_reop_fifo.update( config_local_fifo_get,
    2897                                config_local_fifo_put,
    2898                                false );
    2899         break;
    2900     }
    2901 
    29021858} // end transition()
    29031859
     
    29061862///////////////////////
    29071863{
    2908     //////////////////
    2909     // DMA Commands //
    2910     //////////////////
     1864    // VCI initiator command on RAM network
     1865    // directly the content of the dma_cmd FIFO
     1866
     1867    p_vci_ini_ram.cmdval  = m_dma_cmd_addr_fifo.rok();
     1868    p_vci_ini_ram.address = m_dma_cmd_addr_fifo.read();
     1869    p_vci_ini_ram.be      = m_dma_cmd_be_fifo.read();
     1870    p_vci_ini_ram.cmd     = m_dma_cmd_cmd_fifo.read();
     1871    p_vci_ini_ram.contig  = m_dma_cmd_contig_fifo.read();
     1872    p_vci_ini_ram.wdata   = m_dma_cmd_data_fifo.read();
     1873    p_vci_ini_ram.eop     = m_dma_cmd_eop_fifo.read();
     1874    p_vci_ini_ram.cons    = m_dma_cmd_cons_fifo.read();
     1875    p_vci_ini_ram.plen    = m_dma_cmd_plen_fifo.read();
     1876    p_vci_ini_ram.wrap    = m_dma_cmd_wrap_fifo.read();
     1877    p_vci_ini_ram.cfixed  = m_dma_cmd_cfixed_fifo.read();
     1878    p_vci_ini_ram.clen    = m_dma_cmd_clen_fifo.read();
     1879    p_vci_ini_ram.trdid   = m_dma_cmd_trdid_fifo.read();
     1880    p_vci_ini_ram.pktid   = m_dma_cmd_pktid_fifo.read();
     1881    p_vci_ini_ram.srcid   = m_dma_cmd_srcid_fifo.read();
    29111882   
    2912     // VCI initiator command on the xram network
    2913     if(m_dma_cmd_addr_fifo.rok())
    2914     //&& p_vci_ini_dma.cmdack.read())
    2915     {
    2916         p_vci_ini_dma.cmdval  = true;
    2917         #if NEW_XRAM_VCI
    2918         p_vci_ini_dma.address = (paddr_t_x)(m_dma_cmd_addr_fifo.read() >> 6 )
    2919         #else
    2920         p_vci_ini_dma.address = m_dma_cmd_addr_fifo.read();
    2921         #endif
    2922        
    2923         p_vci_ini_dma.be      = m_dma_cmd_be_fifo.read();
    2924         p_vci_ini_dma.cmd     = m_dma_cmd_cmd_fifo.read();
    2925         p_vci_ini_dma.contig  = m_dma_cmd_contig_fifo.read();
    2926         #if NEW_XRAM_VCI
    2927         //TODO for 64 bits field
    2928         #else
    2929         p_vci_ini_dma.wdata   = m_dma_cmd_data_fifo.read(); // The first is in param_x
    2930                                                     // the second in param_io
    2931         #endif
    2932         p_vci_ini_dma.eop     = m_dma_cmd_eop_fifo.read();
    2933         p_vci_ini_dma.cons    = m_dma_cmd_cons_fifo.read();
    2934         p_vci_ini_dma.plen    = m_dma_cmd_plen_fifo.read();
    2935         p_vci_ini_dma.wrap    = m_dma_cmd_wrap_fifo.read();
    2936         p_vci_ini_dma.cfixed  = m_dma_cmd_cfixed_fifo.read();
    2937         p_vci_ini_dma.clen    = m_dma_cmd_clen_fifo.read();
    2938         p_vci_ini_dma.trdid   = m_dma_cmd_trdid_fifo.read();
    2939         p_vci_ini_dma.pktid   = m_dma_cmd_pktid_fifo.read();
    2940         p_vci_ini_dma.srcid   = m_dma_cmd_srcid_fifo.read();
    2941     }
    2942     else
    2943     {
    2944         p_vci_ini_dma.cmdval  = false;
    2945         p_vci_ini_dma.address = 0;
    2946         p_vci_ini_dma.be      = 0;
    2947         p_vci_ini_dma.cmd     = vci_param_x::CMD_NOP;
    2948         p_vci_ini_dma.contig  = false;
    2949         p_vci_ini_dma.wdata   = 0;
    2950         p_vci_ini_dma.eop     = false;
    2951         p_vci_ini_dma.cons    = true;
    2952         p_vci_ini_dma.plen    = 0;
    2953         p_vci_ini_dma.wrap    = false;
    2954         p_vci_ini_dma.cfixed  = false;
    2955         p_vci_ini_dma.clen    = 0;
    2956         p_vci_ini_dma.trdid   = 0;
    2957         p_vci_ini_dma.pktid   = 0;
    2958     }
    2959    
    2960     // VCI target command on the IO network
    2961     // it depends on the DMA_CMD FSM state
     1883    // VCI target command ack on IOX network
     1884    // depends on the DMA_CMD FSM state
    29621885
    29631886    switch ( r_dma_cmd_fsm.read() )
    29641887    {
    29651888    case DMA_CMD_IDLE:
    2966     case DMA_CMD_TRT_LOCK:     
    2967     case DMA_CMD_TRT_WAIT:     
    2968     case DMA_CMD_TRT_SET:       
    2969         p_vci_tgt_dma.cmdack  = false;
    2970         break;
    2971     case DMA_CMD_FIFO_PUT:
    2972     case DMA_CMD_FIFO_MISS_PUT:
    2973         p_vci_tgt_dma.cmdack  = m_dma_cmd_addr_fifo.wok();
    2974         break;
    2975     case DMA_CMD_TLB_MISS_WAIT:
    2976         p_vci_tgt_dma.cmdack  = false;
    2977         break;
    2978     case DMA_CMD_TLB_MISS_STORE:
    2979         p_vci_tgt_dma.cmdack  = true;
    2980         break;
    2981     case DMA_CMD_ERROR:
    2982         p_vci_tgt_dma.cmdack  = !r_dma_cmd_error_req.read();
     1889    case DMA_CMD_MISS_WAIT:
     1890        p_vci_tgt_iox.cmdack  = false;
     1891        break;
     1892    case DMA_CMD_WAIT_EOP:
     1893        p_vci_tgt_iox.cmdack  = true;
     1894        break;
     1895    case DMA_CMD_FIFO_PUT_CMD:
     1896        p_vci_tgt_iox.cmdack  = m_dma_cmd_addr_fifo.wok();
     1897        break;
     1898    case DMA_CMD_FIFO_PUT_RSP:
     1899        p_vci_tgt_iox.cmdack  = m_dma_rsp_data_fifo.wok();
    29831900        break;
    29841901    }// end switch r_dma_cmd_fsm
    29851902
    2986     //////////////////
    2987     // DMA Responses//
    2988     //////////////////
     1903    // VCI target response on IOX network
     1904    // directly the content of the DMA_RSP FIFO
     1905
     1906    p_vci_tgt_iox.rspval  = m_dma_rsp_data_fifo.rok();
     1907    p_vci_tgt_iox.rsrcid  = m_dma_rsp_rsrcid_fifo.read();
     1908    p_vci_tgt_iox.rtrdid  = m_dma_rsp_rtrdid_fifo.read();
     1909    p_vci_tgt_iox.rpktid  = m_dma_rsp_rpktid_fifo.read();
     1910    p_vci_tgt_iox.rdata   = m_dma_rsp_data_fifo.read();
     1911    p_vci_tgt_iox.rerror  = m_dma_rsp_rerror_fifo.read();
     1912    p_vci_tgt_iox.reop    = m_dma_rsp_reop_fifo.read();
     1913
     1914    // VCI initiator response on the RAM Network
     1915    // depends on the DMA_RSP FSM state
     1916
     1917        p_vci_ini_ram.rspack = m_dma_rsp_data_fifo.wok() and
     1918                           (r_dma_rsp_fsm.read() == DMA_RSP_FIFO_PUT) and
     1919                           not r_alloc_fifo_dma_rsp_local.read();
     1920
     1921    // VCI initiator command on IOX network
     1922    // directly the content of the CONFIG_CMD FIFO
     1923
     1924    p_vci_ini_iox.cmdval  = m_config_cmd_addr_fifo.rok();
     1925    p_vci_ini_iox.address = m_config_cmd_addr_fifo.read();
     1926    p_vci_ini_iox.be      = m_config_cmd_be_fifo.read();
     1927    p_vci_ini_iox.cmd     = m_config_cmd_cmd_fifo.read();
     1928    p_vci_ini_iox.contig  = m_config_cmd_contig_fifo.read();
     1929    p_vci_ini_iox.wdata   = (ext_data_t)m_config_cmd_data_fifo.read();
     1930    p_vci_ini_iox.eop     = m_config_cmd_eop_fifo.read();
     1931    p_vci_ini_iox.cons    = m_config_cmd_cons_fifo.read();
     1932    p_vci_ini_iox.plen    = m_config_cmd_plen_fifo.read();
     1933    p_vci_ini_iox.wrap    = m_config_cmd_wrap_fifo.read();
     1934    p_vci_ini_iox.cfixed  = m_config_cmd_cfixed_fifo.read();
     1935    p_vci_ini_iox.clen    = m_config_cmd_clen_fifo.read();
     1936    p_vci_ini_iox.trdid   = m_config_cmd_trdid_fifo.read();
     1937    p_vci_ini_iox.pktid   = m_config_cmd_pktid_fifo.read();
     1938    p_vci_ini_iox.srcid   = m_config_cmd_srcid_fifo.read();
    29891939   
    2990     // VCI target response on the IO network
    2991     if(m_dma_rsp_data_fifo.rok())
    2992     {
    2993         p_vci_tgt_dma.rspval  = true;
    2994                 p_vci_tgt_dma.rsrcid  = m_dma_rsp_rsrcid_fifo.read();
    2995         p_vci_tgt_dma.rtrdid  = m_dma_rsp_rtrdid_fifo.read();
    2996        
    2997         p_vci_tgt_dma.rpktid  = m_dma_rsp_rpktid_fifo.read();
     1940    // VCI target command ack on INT network
     1941    // it depends on the CONFIG_CMD FSM state
     1942
     1943    switch ( r_config_cmd_fsm.read() )
     1944    {
     1945    case CONFIG_CMD_IDLE:
     1946        p_vci_tgt_int.cmdack  = false;
     1947        break;
     1948    case CONFIG_CMD_FIFO_PUT_CMD:         
     1949        p_vci_tgt_int.cmdack  = m_config_cmd_addr_fifo.wok();
     1950        break;
     1951    case CONFIG_CMD_FIFO_PUT_RSP:         
     1952        p_vci_tgt_int.cmdack  = m_config_rsp_data_fifo.wok() and
     1953                                r_alloc_fifo_config_rsp_local.read();
     1954        break;
     1955    }// end switch r_config_cmd_fsm
     1956
     1957    // VCI target response on INT network
     1958    // directly the content of the CONFIG_RSP FIFO
     1959
     1960    p_vci_tgt_int.rspval  = m_config_rsp_data_fifo.rok();
     1961        p_vci_tgt_int.rsrcid  = m_config_rsp_rsrcid_fifo.read();
     1962    p_vci_tgt_int.rtrdid  = m_config_rsp_rtrdid_fifo.read();
     1963    p_vci_tgt_int.rpktid  = m_config_rsp_rpktid_fifo.read();
     1964    p_vci_tgt_int.rdata   = m_config_rsp_data_fifo.read();
     1965    p_vci_tgt_int.rerror  = m_config_rsp_rerror_fifo.read();
     1966    p_vci_tgt_int.reop    = m_config_rsp_reop_fifo.read();
    29981967   
    2999         #if NEW_XRAM_VCI
    3000         //TODO for 64 bit data field
    3001         #else
    3002         p_vci_tgt_dma.rdata   = m_dma_rsp_data_fifo.read(); // The first is in param_io
    3003                                                     // the second in param_x
    3004         #endif
    3005        
    3006         p_vci_tgt_dma.rerror  = m_dma_rsp_rerror_fifo.read();
    3007         p_vci_tgt_dma.reop    = m_dma_rsp_reop_fifo.read();
    3008     }
    3009     else
    3010     {
    3011         p_vci_tgt_dma.rspval  = false;
    3012        
    3013                 p_vci_tgt_dma.rsrcid  = 0;
    3014                 p_vci_tgt_dma.rdata   = 0;
    3015                 p_vci_tgt_dma.rpktid  = 0;
    3016                 p_vci_tgt_dma.rtrdid  = 0;
    3017                 p_vci_tgt_dma.rerror  = 0;
    3018                 p_vci_tgt_dma.reop    = false;
    3019 
    3020     }
    3021 
    3022     // VCI initiator response on the Xram Network
    3023     // it depends on the DMA_RSP FSM state
    3024     switch ( r_dma_rsp_fsm.read() )
    3025     {
    3026     case DMA_RSP_IDLE:
    3027     case DMA_RSP_TRT_LOCK:
    3028     case DMA_RSP_FIFO_ERROR_PUT:
    3029     {
    3030                 p_vci_ini_dma.rspack = false;
    3031         break;
    3032     }
    3033     case DMA_RSP_FIFO_PUT:
    3034         {
    3035         p_vci_ini_dma.rspack = m_dma_rsp_data_fifo.wok();
    3036         break;
    3037     }
    3038     }// end switch r_dma_rsp_fsm
    3039 
    3040     /////////////////////
    3041     // CONFIG Commands //
    3042     /////////////////////
    3043 
    3044     // VCI initiator command on the IO network
    3045     if(m_config_cmd_addr_fifo.rok())
    3046     {
    3047         p_vci_ini_config.cmdval  = true;
    3048         #if NEW_XRAM_VCI
    3049         p_vci_ini_config.address = (paddr_t_x)(m_config_cmd_addr_fifo.read() >> 6 )
    3050         #else
    3051         p_vci_ini_config.address = m_config_cmd_addr_fifo.read();
    3052         #endif
    3053        
    3054         p_vci_ini_config.be      = (vci_be_t_x)m_config_cmd_be_fifo.read();
    3055         p_vci_ini_config.cmd     = m_config_cmd_cmd_fifo.read();
    3056         p_vci_ini_config.contig  = m_config_cmd_contig_fifo.read();
    3057         #if NEW_XRAM_VCI
    3058         //TODO
    3059         #else
    3060         p_vci_ini_config.wdata   = (vci_data_t_x)m_config_cmd_data_fifo.read(); // The first is in param_io
    3061                                                     // the second in param_d
    3062         #endif
    3063         p_vci_ini_config.eop     = m_config_cmd_eop_fifo.read();
    3064         p_vci_ini_config.cons    = m_config_cmd_cons_fifo.read();
    3065         p_vci_ini_config.plen    = m_config_cmd_plen_fifo.read();
    3066         p_vci_ini_config.wrap    = m_config_cmd_wrap_fifo.read();
    3067         p_vci_ini_config.cfixed  = m_config_cmd_cfixed_fifo.read();
    3068         p_vci_ini_config.clen    = m_config_cmd_clen_fifo.read();
    3069         p_vci_ini_config.trdid   = m_config_cmd_trdid_fifo.read();
    3070         p_vci_ini_config.pktid   = m_config_cmd_pktid_fifo.read();
    3071     }
    3072     else
    3073     {
    3074         p_vci_ini_config.cmdval  = false;
    3075         p_vci_ini_config.address = 0;
    3076         p_vci_ini_config.be      = 0;
    3077         p_vci_ini_config.cmd     = vci_param_io::CMD_NOP;
    3078         p_vci_ini_config.contig  = false;
    3079         p_vci_ini_config.wdata   = 0;
    3080         p_vci_ini_config.eop     = false;
    3081         p_vci_ini_config.cons    = true;
    3082         p_vci_ini_config.plen    = 0;
    3083         p_vci_ini_config.wrap    = false;
    3084         p_vci_ini_config.cfixed  = false;
    3085         p_vci_ini_config.clen    = 0;
    3086         p_vci_ini_config.trdid   = 0;
    3087         p_vci_ini_config.pktid   = 0;
    3088     }
     1968    // VCI initiator response on IOX Network
     1969    // it depends on the CONFIG_RSP FSM state
     1970
     1971        p_vci_ini_iox.rspack = m_config_rsp_data_fifo.wok() and
     1972                           (r_config_rsp_fsm.read() == CONFIG_RSP_FIFO_PUT) and
     1973                           not r_alloc_fifo_config_rsp_local.read();
     1974
     1975    // VCI initiator command  on INT network
     1976    // it depends on the MISS_WTI_CMD FSM state
     1977
     1978    // default values
     1979    p_vci_ini_int.srcid   = m_int_srcid;
     1980    p_vci_ini_int.trdid   = 0;
     1981    p_vci_ini_int.cfixed  = false;
     1982    p_vci_ini_int.eop     = true;
     1983    p_vci_ini_int.wrap    = false;
     1984    p_vci_ini_int.clen    = 0;
     1985    p_vci_ini_int.contig  = false;
     1986    p_vci_ini_int.cons    = true;
     1987    p_vci_ini_int.be      = 0xFF;
    30891988   
    3090     // VCI target command on the Direct network
    3091     // it depends on the CONFIG_CMD FSM state
    3092 
    3093     switch ( r_config_cmd_fsm.read() )
    3094     {
    3095     case CONFIG_CMD_IDLE:
    3096     case CONFIG_CMD_TRT_LOCK:   
    3097     case CONFIG_CMD_TRT_WAIT:
    3098     case CONFIG_CMD_TRT_SET:
    3099     case CONFIG_CMD_IT_ADDR_IOMMU_READ_1:
    3100     case CONFIG_CMD_IT_ADDR_READ_1:
    3101     case CONFIG_CMD_ERROR_RSP: 
    3102     case CONFIG_CMD_INVAL_REQ:
    3103         p_vci_tgt_config.cmdack  = false;
    3104         break;
    3105     case CONFIG_CMD_FIFO_PUT:     
    3106     case CONFIG_CMD_PTPR_WRITE:
    3107     case CONFIG_CMD_PTPR_READ:
    3108     case CONFIG_CMD_ACTIVE_WRITE:
    3109     case CONFIG_CMD_ACTIVE_READ:
    3110     case CONFIG_CMD_BVAR_READ:
    3111     case CONFIG_CMD_ETR_READ:
    3112     case CONFIG_CMD_BAD_ID_READ:
    3113     case CONFIG_CMD_IT_ADDR_IOMMU_WRITE_2:
    3114     case CONFIG_CMD_IT_ADDR_IOMMU_READ_2:
    3115     case CONFIG_CMD_IT_ADDR_WRITE_2:
    3116     case CONFIG_CMD_IT_ADDR_READ_2:
    3117     case CONFIG_CMD_INVAL:
    3118         p_vci_tgt_config.cmdack  = m_config_cmd_addr_fifo.wok();
    3119         break;
    3120     case CONFIG_CMD_IT_ADDR_IOMMU_WRITE_1:
    3121     case CONFIG_CMD_IT_ADDR_WRITE_1:
    3122     case CONFIG_CMD_ERROR_WAIT:
    3123         p_vci_tgt_config.cmdack = true;
    3124         break;
    3125     default:
    3126         p_vci_tgt_config.cmdack  = false;
    3127         break;
    3128     }// end switch r_config_cmd_fsm
    3129 
    3130     /////////////////////
    3131     // CONFIG Responses//
    3132     /////////////////////
     1989    switch ( r_miss_wti_cmd_fsm.read() )
     1990    {   
     1991    case MISS_WTI_CMD_IDLE:
     1992                p_vci_ini_int.cmdval  = false;
     1993        p_vci_ini_int.address = 0;
     1994        p_vci_ini_int.cmd     = vci_param_int::CMD_NOP;
     1995        p_vci_ini_int.pktid   = PKTID_READ;
     1996        p_vci_ini_int.wdata   = 0;
     1997        p_vci_ini_int.plen    = 0;
     1998        break;
    31331999   
    3134     // VCI target response on the Direct network
    3135     if(r_config_rsp_fifo_local_priority)
    3136     {
    3137     if( m_config_local_data_fifo.rok() )
    3138     {
    3139         p_vci_tgt_config.rspval  = true;
    3140                 p_vci_tgt_config.rsrcid  = m_config_local_rsrcid_fifo.read();
    3141         p_vci_tgt_config.rtrdid  = m_config_local_rtrdid_fifo.read();
    3142         p_vci_tgt_config.rpktid  = m_config_local_rpktid_fifo.read();
    3143         p_vci_tgt_config.rdata   = (vci_data_t)m_config_local_data_fifo.read();
    3144         p_vci_tgt_config.rerror  = m_config_local_rerror_fifo.read();
    3145         p_vci_tgt_config.reop    = m_config_local_reop_fifo.read();
    3146     }
    3147     else if(m_config_rsp_data_fifo.rok() )
    3148     {
    3149         p_vci_tgt_config.rspval  = true;
    3150                 p_vci_tgt_config.rsrcid  = m_config_rsp_rsrcid_fifo.read();
    3151         p_vci_tgt_config.rtrdid  = m_config_rsp_rtrdid_fifo.read();
    3152        
    3153         p_vci_tgt_config.rpktid  = m_config_rsp_rpktid_fifo.read();
     2000    case MISS_WTI_CMD_WTI:
     2001        p_vci_ini_int.cmdval  = true;
     2002        p_vci_ini_int.address = r_iommu_peri_wti[r_miss_wti_cmd_index.read()].read();
     2003        p_vci_ini_int.cmd     = vci_param_int::CMD_WRITE;
     2004        p_vci_ini_int.pktid   = PKTID_WRITE;
     2005        p_vci_ini_int.wdata   = (int_data_t)r_irq_pending[r_miss_wti_cmd_index.read()].read();
     2006        p_vci_ini_int.plen    = vci_param_int::B;
     2007        break;
    31542008   
    3155         p_vci_tgt_config.rdata   = (vci_data_t)m_config_rsp_data_fifo.read(); // The first is in param_d
    3156                                                     // the second in param_io
    3157         p_vci_tgt_config.rerror  = m_config_rsp_rerror_fifo.read();
    3158         p_vci_tgt_config.reop    = m_config_rsp_reop_fifo.read();
    3159     }
    3160     else
    3161     {
    3162         p_vci_tgt_config.rspval  = false;
    3163        
    3164                 p_vci_tgt_config.rsrcid  = 0;
    3165                 p_vci_tgt_config.rdata   = 0;
    3166                 p_vci_tgt_config.rpktid  = 0;
    3167                 p_vci_tgt_config.rtrdid  = 0;
    3168                 p_vci_tgt_config.rerror  = 0;
    3169                 p_vci_tgt_config.reop    = false;
    3170 
    3171     }
    3172     }
    3173     else
    3174     {
    3175     if(m_config_rsp_data_fifo.rok() )
    3176     {
    3177         p_vci_tgt_config.rspval  = true;
    3178                 p_vci_tgt_config.rsrcid  = m_config_rsp_rsrcid_fifo.read();
    3179         p_vci_tgt_config.rtrdid  = m_config_rsp_rtrdid_fifo.read();
    3180        
    3181         p_vci_tgt_config.rpktid  = m_config_rsp_rpktid_fifo.read();
    3182    
    3183         p_vci_tgt_config.rdata   = (vci_data_t)m_config_rsp_data_fifo.read(); // The first is in param_d
    3184                                                     // the second in param_io
    3185         p_vci_tgt_config.rerror  = m_config_rsp_rerror_fifo.read();
    3186         p_vci_tgt_config.reop    = m_config_rsp_reop_fifo.read();
    3187     }
    3188     else if( m_config_local_data_fifo.rok() )
    3189     {
    3190         p_vci_tgt_config.rspval  = true;
    3191                 p_vci_tgt_config.rsrcid  = m_config_local_rsrcid_fifo.read();
    3192         p_vci_tgt_config.rtrdid  = m_config_local_rtrdid_fifo.read();
    3193         p_vci_tgt_config.rpktid  = m_config_local_rpktid_fifo.read();
    3194         p_vci_tgt_config.rdata   = (vci_data_t)m_config_local_data_fifo.read();
    3195         p_vci_tgt_config.rerror  = m_config_local_rerror_fifo.read();
    3196         p_vci_tgt_config.reop    = m_config_local_reop_fifo.read();
    3197     }
    3198     else
    3199     {
    3200         p_vci_tgt_config.rspval  = false;
    3201        
    3202                 p_vci_tgt_config.rsrcid  = 0;
    3203                 p_vci_tgt_config.rdata   = 0;
    3204                 p_vci_tgt_config.rpktid  = 0;
    3205                 p_vci_tgt_config.rtrdid  = 0;
    3206                 p_vci_tgt_config.rerror  = 0;
    3207                 p_vci_tgt_config.reop    = false;
    3208 
    3209     }
    3210     }
    3211    
    3212     // VCI initiator response on the IO Network
    3213     // it depends on the CONFIG_RSP FSM state
    3214     switch ( r_config_rsp_fsm.read() )
    3215     {
    3216     case CONFIG_RSP_IDLE:
    3217     case CONFIG_RSP_TRT_LOCK:
    3218         p_vci_ini_config.rspack = false;
    3219         break;
    3220     case CONFIG_RSP_FIFO_PUT:
    3221                 p_vci_ini_config.rspack = m_config_rsp_data_fifo.wok();
    3222         break;
    3223     }// end switch r_config_rsp_fsm
    3224 
    3225     ////////////////////////////////////////////////////////////////
    3226     // VCI initiator command and response on from the Direct network
    3227     // for Miss Transactions
    3228     p_vci_ini_miss.srcid   = m_srcid_miss;
    3229    
    3230     switch ( r_miss_init_fsm.read() )
    3231     {   
    3232     case MISS_INIT_IDLE_MISS:
    3233     case MISS_INIT_IDLE_IRQ:
    3234                 p_vci_ini_miss.cmdval  = false;
    3235         p_vci_ini_miss.address = 0;
    3236         p_vci_ini_miss.be      = 0;
    3237         p_vci_ini_miss.cmd     = vci_param_d::CMD_NOP;
    3238         p_vci_ini_miss.contig  = false;
    3239         p_vci_ini_miss.wdata   = 0;
    3240         p_vci_ini_miss.eop     = false;
    3241         p_vci_ini_miss.cons    = true;
    3242         p_vci_ini_miss.plen    = 0;
    3243         p_vci_ini_miss.wrap    = false;
    3244         p_vci_ini_miss.cfixed  = false;
    3245         p_vci_ini_miss.clen    = 0;
    3246         p_vci_ini_miss.trdid   = 0;
    3247         p_vci_ini_miss.pktid   = 0;
    3248 
    3249                 p_vci_ini_miss.rspack = false;
    3250         break;
    3251    
    3252     case MISS_INIT_IRQ_CMD:
    3253         p_vci_ini_miss.cmdval  = true;
    3254         p_vci_ini_miss.address = (paddr_t)r_it_addr[r_irq_chosen.read()];
    3255         p_vci_ini_miss.wdata   = 0;
    3256         p_vci_ini_miss.plen    = vci_param_d::B;
    3257         p_vci_ini_miss.trdid   = 0; 
    3258         p_vci_ini_miss.cmd     = vci_param_d::CMD_READ;
    3259         p_vci_ini_miss.eop     = true;
    3260        
    3261         p_vci_ini_miss.be      = 0xF;
    3262         p_vci_ini_miss.pktid   = 0;
    3263         p_vci_ini_miss.cons    = false;
    3264         p_vci_ini_miss.wrap    = false;
    3265         p_vci_ini_miss.contig  = true;
    3266         p_vci_ini_miss.clen    = 0;
    3267         p_vci_ini_miss.cfixed  = false;
    3268         break;
    3269    
    3270     case MISS_INIT_IRQ_RSP:
    3271     case MISS_INIT_TLB_MISS_RSP:
    3272         p_vci_ini_miss.cmdval  = false;
    3273         p_vci_ini_miss.address = 0;
    3274         p_vci_ini_miss.be      = 0;
    3275         p_vci_ini_miss.cmd     = vci_param_d::CMD_NOP;
    3276         p_vci_ini_miss.contig  = false;
    3277         p_vci_ini_miss.wdata   = 0;
    3278         p_vci_ini_miss.eop     = false;
    3279         p_vci_ini_miss.cons    = true;
    3280         p_vci_ini_miss.plen    = 0;
    3281         p_vci_ini_miss.wrap    = false;
    3282         p_vci_ini_miss.cfixed  = false;
    3283         p_vci_ini_miss.clen    = 0;
    3284         p_vci_ini_miss.trdid   = 0;
    3285         p_vci_ini_miss.pktid   = 0;
    3286        
    3287         p_vci_ini_miss.rspack = true;
    3288  
    3289         break;
    3290    
    3291     case MISS_INIT_TLB_MISS_CMD:
    3292         p_vci_ini_miss.cmdval  = true;
    3293         p_vci_ini_miss.address = (paddr_t)((r_iotlb_paddr.read())& CACHE_LINE_MASK);
    3294         p_vci_ini_miss.wdata   = 0x00000000;
    3295         p_vci_ini_miss.plen    = m_words*(vci_param_d::B);
    3296         p_vci_ini_miss.trdid   = 0;  //could be used as the index on a miss transaction table
    3297         p_vci_ini_miss.cmd     = vci_param_d::CMD_READ;
    3298         p_vci_ini_miss.eop     = true;
    3299        
    3300         p_vci_ini_miss.be      = 0xF;
    3301         p_vci_ini_miss.pktid   = 0;
    3302         p_vci_ini_miss.cons    = false;
    3303         p_vci_ini_miss.wrap    = false;
    3304         p_vci_ini_miss.contig  = true;
    3305         p_vci_ini_miss.clen    = 0;
    3306         p_vci_ini_miss.cfixed  = false;
    3307         break;
    3308 
    3309     } // end switch r_miss_init_fsm
     2009    case MISS_WTI_CMD_MISS:
     2010        p_vci_ini_int.cmdval  = true;
     2011        p_vci_ini_int.address = r_tlb_paddr.read() & CACHE_LINE_MASK;
     2012        p_vci_ini_int.cmd     = vci_param_int::CMD_READ;
     2013        p_vci_ini_int.pktid   = PKTID_READ;
     2014        p_vci_ini_int.wdata   = 0;
     2015        p_vci_ini_int.plen    = m_words*(vci_param_int::B);
     2016        break;
     2017    }
     2018
     2019    // VCI initiator response on INT network
     2020    // It depends on the MISS_WTI_RSP FSM state
     2021
     2022    if ( r_miss_wti_rsp_fsm.read() == MISS_WTI_RSP_IDLE ) p_vci_ini_int.rspack  = false;
     2023    else                                                  p_vci_ini_int.rspack  = true;
     2024
    33102025} // end genMoore
    33112026
  • trunk/modules/vci_mem_cache/caba/metadata/vci_mem_cache.sd

    r426 r434  
    2424            '../source/include/mem_cache_directory.h',
    2525            '../source/include/update_tab.h'
     26        ],
     27
     28        interface_files = [
     29            '../../include/soclib/mem_cache.h',
    2630        ],
    2731
  • trunk/modules/vci_mem_cache/caba/source/include/mem_cache_directory.h

    r385 r434  
    274274
    275275    /////////////////////////////////////////////////////////////////////
     276    // The inval function invalidate an entry defined by the set and
     277    // way arguments.
     278    /////////////////////////////////////////////////////////////////////
     279    void inval( const size_t &set, const size_t &way )
     280    {
     281        m_dir_tab[set][way].init();
     282    }
     283
     284    /////////////////////////////////////////////////////////////////////
    276285    // The read_neutral() function reads a directory entry, without
    277286    // changing the LRU
     
    320329      // update LRU bits
    321330      bool all_recent = true;
    322       for ( size_t i=0 ; i<m_ways ; i++ ) {
    323         if ( i != way ) all_recent = m_lru_tab[set][i].recent && all_recent;
    324       }
    325       if ( all_recent ) {
    326         for( size_t i=0 ; i<m_ways ; i++ ) m_lru_tab[set][i].recent = false;
    327       } else {
    328         m_lru_tab[set][way].recent = true;
     331      for ( size_t i=0 ; i<m_ways ; i++ )
     332      {
     333          if ( i != way ) all_recent = m_lru_tab[set][i].recent && all_recent;
     334      }
     335      if ( all_recent )
     336      {
     337          for( size_t i=0 ; i<m_ways ; i++ ) m_lru_tab[set][i].recent = false;
     338      }
     339      else
     340      {
     341          m_lru_tab[set][way].recent = true;
    329342      }
    330343    } // end write()
  • trunk/modules/vci_mem_cache/caba/source/include/update_tab.h

    r385 r434  
    1111////////////////////////////////////////////////////////////////////////
    1212class UpdateTabEntry {
     13
    1314  typedef uint32_t size_t;
    1415  typedef sc_dt::sc_uint<40> addr_t;
    1516
    1617  public:
     18
    1719  bool      valid;      // It is a valid pending transaction
    1820  bool      update;     // It is an update transaction
    1921  bool      brdcast;    // It is a broadcast invalidate
    20   bool      rsp;        // It needs a response to the initiator
     22  bool      rsp;        // Response to the initiator required
     23  bool      ack;        // Acknowledge to the CONFIG FSM required
    2124  size_t        srcid;      // The srcid of the initiator which wrote the data
    2225  size_t        trdid;      // The trdid of the initiator which wrote the data
     
    2528  size_t        count;      // The number of acknowledge responses to receive
    2629
    27   UpdateTabEntry(){
     30  UpdateTabEntry()
     31  {
    2832    valid       = false;
    2933    update  = false;
    3034    brdcast = false;
    3135    rsp     = false;
     36    ack     = false;
    3237    srcid       = 0;
    3338    trdid       = 0;
     
    3843
    3944  UpdateTabEntry(bool   i_valid,
    40       bool   i_update,
    41       bool   i_brdcast,
    42       bool   i_rsp,
    43       size_t i_srcid,
    44       size_t i_trdid,
    45       size_t i_pktid,
    46       addr_t i_nline,
    47       size_t i_count)
     45                 bool   i_update,
     46                 bool   i_brdcast,
     47                 bool   i_rsp,
     48                 bool   i_ack,
     49                 size_t i_srcid,
     50                 size_t i_trdid,
     51                 size_t i_pktid,
     52                 addr_t i_nline,
     53                 size_t i_count)
    4854  {
    4955    valid       = i_valid;
     
    5157    brdcast = i_brdcast;
    5258    rsp     = i_rsp;
     59    ack     = i_ack;
    5360    srcid       = i_srcid;
    5461    trdid       = i_trdid;
     
    6471    brdcast = source.brdcast;
    6572    rsp     = source.rsp;
     73    ack     = source.ack;
    6674    srcid   = source.srcid;
    6775    trdid   = source.trdid;
     
    8088    brdcast= false;
    8189    rsp    = false;
     90    ack    = false;
    8291    srcid  = 0;
    8392    trdid  = 0;
     
    98107    brdcast= source.brdcast;
    99108    rsp    = source.rsp;
     109    ack    = source.ack  ;
    100110    srcid  = source.srcid;
    101111    trdid  = source.trdid;
     
    108118  // The print() function prints the entry 
    109119  ////////////////////////////////////////////////////////////////////
    110   void print(){
    111     std::cout << std::dec << "valid  = " << valid  << std::endl;
    112     std::cout << "update = " << update << std::endl;
    113     std::cout << "brdcast= " << brdcast<< std::endl;
    114     std::cout << "rsp    = " << rsp    << std::endl;
    115     std::cout << "srcid  = " << srcid  << std::endl;
    116     std::cout << "trdid  = " << trdid  << std::endl;
    117     std::cout << "pktid  = " << pktid  << std::endl;
    118     std::cout << std::hex << "nline  = " << nline  << std::endl;
    119     std::cout << std::dec << "count  = " << count  << std::endl;
     120  void print()
     121  {
     122    std::cout << " val = " << std::dec << valid
     123              << " / updt = " << update
     124              << " / bc = " << brdcast
     125              << " / rsp = " << rsp
     126              << " / ack = " << ack   
     127              << " / count = " << count
     128              << " / srcid = " << std::hex << srcid
     129              << " / trdid = " << trdid   
     130              << " / pktid = " << pktid
     131              << " / nline = " << nline  << std::endl;
    120132  }
    121133};
     
    126138class UpdateTab{
    127139
    128   typedef sc_dt::sc_uint<40> addr_t;
     140  typedef uint64_t addr_t;
    129141
    130142  private:
    131   size_t size_tab;
     143  size_t                      size_tab;
    132144  std::vector<UpdateTabEntry> tab;
    133145
     
    149161  // The size() function returns the size of the tab 
    150162  ////////////////////////////////////////////////////////////////////
    151   const size_t size(){
     163  const size_t size()
     164  {
    152165    return size_tab;
    153166  }
    154167
    155 
    156168  ////////////////////////////////////////////////////////////////////
    157169  // The print() function diplays the tab content
    158170  ////////////////////////////////////////////////////////////////////
    159   void print(){
    160     for(size_t i=0; i<size_tab; i++) {
    161       std::cout << "UPDATE TAB ENTRY " << std::dec << i << "--------" << std::endl;
     171  void print()
     172  {
     173    std::cout << "UPDATE TABLE Content" << std::endl;
     174    for(size_t i=0; i<size_tab; i++)
     175    {
     176      std::cout << "[" << std::dec << i << "] ";
    162177      tab[i].print();
    163178    }
     
    165180  }
    166181
    167 
    168182  /////////////////////////////////////////////////////////////////////
    169183  // The init() function initializes the tab
    170184  /////////////////////////////////////////////////////////////////////
    171   void init(){
    172     for ( size_t i=0; i<size_tab; i++) {
    173       tab[i].init();
    174     }
    175   }
    176 
     185  void init()
     186  {
     187    for ( size_t i=0; i<size_tab; i++) tab[i].init();
     188  }
    177189
    178190  /////////////////////////////////////////////////////////////////////
     
    200212  ///////////////////////////////////////////////////////////////////////////
    201213  bool set(const bool   update,
    202       const bool   brdcast,
    203       const bool   rsp,
    204       const size_t srcid,
    205       const size_t trdid,
    206       const size_t pktid,
    207       const addr_t nline,
    208       const size_t count,
    209       size_t &index)
    210   {
    211     for ( size_t i=0 ; i<size_tab ; i++ ) {
    212       if( !tab[i].valid ) {
     214           const bool   brdcast,
     215           const bool   rsp,
     216           const bool   ack,
     217           const size_t srcid,
     218           const size_t trdid,
     219           const size_t pktid,
     220           const addr_t nline,
     221           const size_t count,
     222           size_t       &index)
     223  {
     224    for ( size_t i=0 ; i<size_tab ; i++ )
     225    {
     226      if( !tab[i].valid )
     227      {
    213228        tab[i].valid            = true;
    214229        tab[i].update           = update;
    215230        tab[i].brdcast      = brdcast;
    216231        tab[i].rsp          = rsp;
     232        tab[i].ack          = ack;
    217233        tab[i].srcid            = (size_t) srcid;
    218234        tab[i].trdid            = (size_t) trdid;
     
    235251  /////////////////////////////////////////////////////////////////////
    236252  bool decrement( const size_t index,
    237       size_t &counter )
     253                  size_t &counter )
    238254  {
    239255    assert((index<size_tab) && "Bad Update Tab Entry");
    240     if ( tab[index].valid ) {
     256    if ( tab[index].valid )
     257    {
    241258      tab[index].count--;
    242259      counter = tab[index].count;
    243260      return true;
    244     } else {
     261    }
     262    else
     263    {
    245264      return false;
    246265    }
     
    252271  bool is_full()
    253272  {
    254     for(size_t i = 0 ; i < size_tab ; i++){
    255       if(!tab[i].valid){
    256         return false;
    257       }
     273    for(size_t i = 0 ; i < size_tab ; i++)
     274    {
     275      if(!tab[i].valid) return false;
    258276    }
    259277    return true;
     
    265283  bool is_not_empty()
    266284  {
    267     for(size_t i = 0 ; i < size_tab ; i++){
    268       if(tab[i].valid){
     285    for(size_t i = 0 ; i < size_tab ; i++)
     286    {
     287      if(tab[i].valid) return true;
     288    }
     289    return false;
     290  }
     291
     292  /////////////////////////////////////////////////////////////////////
     293  // The need_rsp() function returns the need of a response
     294  // Arguments :
     295  // - index : the index of the entry
     296  /////////////////////////////////////////////////////////////////////
     297  bool need_rsp(const size_t index)
     298  {
     299    assert(index<size_tab && "Bad Update Tab Entry");
     300    return tab[index].rsp;     
     301  }
     302
     303  /////////////////////////////////////////////////////////////////////
     304  // The need_ack() function returns the need of an acknowledge
     305  // Arguments :
     306  // - index : the index of the entry
     307  /////////////////////////////////////////////////////////////////////
     308  bool need_ack(const size_t index)
     309  {
     310    assert(index<size_tab && "Bad Update Tab Entry");
     311    return tab[index].ack;     
     312  }
     313
     314  /////////////////////////////////////////////////////////////////////
     315  // The is_brdcast() function returns the transaction type
     316  // Arguments :
     317  // - index : the index of the entry
     318  /////////////////////////////////////////////////////////////////////
     319  bool is_brdcast(const size_t index)
     320  {
     321    assert(index<size_tab && "Bad Update Tab Entry");
     322    return tab[index].brdcast; 
     323  }
     324
     325  /////////////////////////////////////////////////////////////////////
     326  // The is_update() function returns the transaction type
     327  // Arguments :
     328  // - index : the index of the entry
     329  /////////////////////////////////////////////////////////////////////
     330  bool is_update(const size_t index)
     331  {
     332    assert(index<size_tab && "Bad Update Tab Entry");
     333    return tab[index].update;   
     334  }
     335
     336  /////////////////////////////////////////////////////////////////////
     337  // The srcid() function returns the srcid value
     338  // Arguments :
     339  // - index : the index of the entry
     340  /////////////////////////////////////////////////////////////////////
     341  size_t srcid(const size_t index)
     342  {
     343    assert(index<size_tab && "Bad Update Tab Entry");
     344    return tab[index].srcid;   
     345  }
     346
     347  /////////////////////////////////////////////////////////////////////
     348  // The trdid() function returns the trdid value
     349  // Arguments :
     350  // - index : the index of the entry
     351  /////////////////////////////////////////////////////////////////////
     352  size_t trdid(const size_t index)
     353  {
     354    assert(index<size_tab && "Bad Update Tab Entry");
     355    return tab[index].trdid;   
     356  }
     357
     358  /////////////////////////////////////////////////////////////////////
     359  // The pktid() function returns the pktid value
     360  // Arguments :
     361  // - index : the index of the entry
     362  /////////////////////////////////////////////////////////////////////
     363  size_t pktid(const size_t index)
     364  {
     365    assert(index<size_tab && "Bad Update Tab Entry");
     366    return tab[index].pktid;   
     367  }
     368
     369  /////////////////////////////////////////////////////////////////////
     370  // The nline() function returns the nline value
     371  // Arguments :
     372  // - index : the index of the entry
     373  /////////////////////////////////////////////////////////////////////
     374  addr_t nline(const size_t index)
     375  {
     376    assert(index<size_tab && "Bad Update Tab Entry");
     377    return tab[index].nline;
     378  }
     379
     380  /////////////////////////////////////////////////////////////////////
     381  // The search_inval() function returns the index of the entry in UPT
     382  // Arguments :
     383  // - nline : the line number of the entry in the directory
     384  /////////////////////////////////////////////////////////////////////
     385  bool search_inval(const addr_t nline,size_t &index)
     386  {
     387    size_t i ;
     388
     389    for (i = 0 ; i < size_tab ; i++)
     390    {
     391      if ( (tab[i].nline == nline) and tab[i].valid and not tab[i].update )
     392      {
     393        index = i ;
    269394        return true;
    270395      }
     
    274399
    275400  /////////////////////////////////////////////////////////////////////
    276   // The need_rsp() function returns the need of a response
    277   // Arguments :
    278   // - index : the index of the entry
    279   /////////////////////////////////////////////////////////////////////
    280   bool need_rsp(const size_t index)
    281   {
    282     assert(index<size_tab && "Bad Update Tab Entry");
    283     return tab[index].rsp;     
    284   }
    285 
    286   /////////////////////////////////////////////////////////////////////
    287   // The is_update() function returns the transaction type
    288   // Arguments :
    289   // - index : the index of the entry
    290   /////////////////////////////////////////////////////////////////////
    291   bool is_brdcast(const size_t index)
    292   {
    293     assert(index<size_tab && "Bad Update Tab Entry");
    294     return tab[index].brdcast; 
    295   }
    296 
    297   /////////////////////////////////////////////////////////////////////
    298   // The is_update() function returns the transaction type
    299   // Arguments :
    300   // - index : the index of the entry
    301   /////////////////////////////////////////////////////////////////////
    302   bool is_update(const size_t index)
    303   {
    304     assert(index<size_tab && "Bad Update Tab Entry");
    305     return tab[index].update;   
    306   }
    307 
    308   /////////////////////////////////////////////////////////////////////
    309   // The srcid() function returns the srcid value
    310   // Arguments :
    311   // - index : the index of the entry
    312   /////////////////////////////////////////////////////////////////////
    313   size_t srcid(const size_t index)
    314   {
    315     assert(index<size_tab && "Bad Update Tab Entry");
    316     return tab[index].srcid;   
    317   }
    318 
    319   /////////////////////////////////////////////////////////////////////
    320   // The trdid() function returns the trdid value
    321   // Arguments :
    322   // - index : the index of the entry
    323   /////////////////////////////////////////////////////////////////////
    324   size_t trdid(const size_t index)
    325   {
    326     assert(index<size_tab && "Bad Update Tab Entry");
    327     return tab[index].trdid;   
    328   }
    329 
    330   /////////////////////////////////////////////////////////////////////
    331   // The pktid() function returns the pktid value
    332   // Arguments :
    333   // - index : the index of the entry
    334   /////////////////////////////////////////////////////////////////////
    335   size_t pktid(const size_t index)
    336   {
    337     assert(index<size_tab && "Bad Update Tab Entry");
    338     return tab[index].pktid;   
    339   }
    340 
    341   /////////////////////////////////////////////////////////////////////
    342   // The nline() function returns the nline value
    343   // Arguments :
    344   // - index : the index of the entry
    345   /////////////////////////////////////////////////////////////////////
    346   addr_t nline(const size_t index)
    347   {
    348     assert(index<size_tab && "Bad Update Tab Entry");
    349     return tab[index].nline;
    350   }
    351 
    352   /////////////////////////////////////////////////////////////////////
    353   // The search_inval() function returns the index of the entry in UPT
     401  // The read_nline() function returns the index of the entry in UPT
    354402  // Arguments :
    355403  // - nline : the line number of the entry in the directory
    356404  /////////////////////////////////////////////////////////////////////
    357   bool search_inval(const addr_t nline,size_t &index)
     405  bool read_nline(const addr_t nline,size_t &index)
    358406  {
    359407    size_t i ;
    360408
    361     for (i = 0 ; i < size_tab ; i++){
    362       if((tab[i].nline == nline) && tab[i].valid){
    363         if(!tab[i].update){
    364           index = i ;
    365           return true;
    366         }
    367       }
    368     }
    369     return false;
    370   }
    371 
    372   /////////////////////////////////////////////////////////////////////
    373   // The read_nline() function returns the index of the entry in UPT
    374   // Arguments :
    375   // - nline : the line number of the entry in the directory
    376   /////////////////////////////////////////////////////////////////////
    377   bool read_nline(const addr_t nline,size_t &index)
    378   {
    379     size_t i ;
    380 
    381     for (i = 0 ; i < size_tab ; i++){
    382       if((tab[i].nline == nline) && tab[i].valid){
     409    for (i = 0 ; i < size_tab ; i++)
     410    {
     411      if ( (tab[i].nline == nline) and tab[i].valid )
     412      {
    383413        index = i ;
    384414        return true;
  • trunk/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h

    r430 r434  
    7777
    7878      /* States of the TGT_CMD fsm */
    79       enum tgt_cmd_fsm_state_e{
     79      enum tgt_cmd_fsm_state_e
     80      {
    8081        TGT_CMD_IDLE,
    8182        TGT_CMD_ERROR,
    8283        TGT_CMD_READ,
    8384        TGT_CMD_WRITE,
    84         TGT_CMD_CAS
     85        TGT_CMD_CAS,
     86        TGT_CMD_CONFIG
    8587      };
    8688
     
    144146        MULTI_ACK_UPT_LOCK,
    145147        MULTI_ACK_UPT_CLEAR,
    146         MULTI_ACK_WRITE_RSP
     148        MULTI_ACK_WRITE_RSP,
     149        MULTI_ACK_CONFIG_ACK
     150      };
     151
     152      /* States of the CONFIG fsm */
     153      enum config_fsm_state_e
     154      {
     155        CONFIG_IDLE,
     156        CONFIG_LOOP,
     157        CONFIG_RSP,
     158        CONFIG_DIR_REQ,
     159        CONFIG_DIR_ACCESS,
     160        CONFIG_DIR_INVAL,
     161        CONFIG_BC_UPT_LOCK,
     162        CONFIG_BC_SEND,
     163        CONFIG_BC_WAIT,
     164       
     165        CONFIG_UPT_WAIT,
     166
     167        CONFIG_UPT_LOCK,
     168
     169        CONFIG_HEAP_REQ
    147170      };
    148171
     
    277300        CLEANUP_UPT_CLEAR,
    278301        CLEANUP_WRITE_RSP,
    279         CLEANUP_SEND_ACK
     302        CLEANUP_CONFIG_ACK,
     303        CLEANUP_SEND_CLACK
    280304      };
    281305
     
    284308      {
    285309        ALLOC_DIR_RESET,
     310        ALLOC_DIR_CONFIG,
    286311        ALLOC_DIR_READ,
    287312        ALLOC_DIR_WRITE,
     
    304329      enum alloc_upt_fsm_state_e
    305330      {
     331        ALLOC_UPT_CONFIG,
    306332        ALLOC_UPT_WRITE,
    307333        ALLOC_UPT_XRAM_RSP,
     
    350376      };
    351377
     378      /* Configuration commands */
     379      enum cmd_config_type_e
     380      {
     381          CMD_CONFIG_INVAL = 0,
     382          CMD_CONFIG_SYNC  = 1
     383      };
     384
    352385      // debug variables (for each FSM)
    353       bool         m_debug_global;
    354       bool         m_debug_tgt_cmd_fsm;
    355       bool         m_debug_tgt_rsp_fsm;
    356       bool         m_debug_cc_send_fsm;
    357       bool         m_debug_cc_receive_fsm;
    358       bool         m_debug_multi_ack_fsm;
    359       bool         m_debug_read_fsm;
    360       bool         m_debug_write_fsm;
    361       bool         m_debug_cas_fsm;
    362       bool         m_debug_cleanup_fsm;
    363       bool         m_debug_ixr_cmd_fsm;
    364       bool         m_debug_ixr_rsp_fsm;
    365       bool         m_debug_xram_rsp_fsm;
     386      bool         m_debug;
    366387      bool         m_debug_previous_hit;
    367388      size_t       m_debug_previous_count;
     
    373394      // instrumentation counters
    374395      uint32_t     m_cpt_cycles;        // Counter of cycles
     396
    375397      uint32_t     m_cpt_read;          // Number of READ transactions
     398      uint32_t     m_cpt_read_remote;   // number of remote READ transactions
     399      uint32_t     m_cpt_read_flits;    // number of flits for READs
     400      uint32_t     m_cpt_read_cost;     // Number of (flits * distance) for READs
     401
    376402      uint32_t     m_cpt_read_miss;     // Number of MISS READ
     403
    377404      uint32_t     m_cpt_write;         // Number of WRITE transactions
     405      uint32_t     m_cpt_write_remote;  // number of remote WRITE transactions
     406      uint32_t     m_cpt_write_flits;   // number of flits for WRITEs
     407      uint32_t     m_cpt_write_cost;    // Number of (flits * distance) for WRITEs
     408
    378409      uint32_t     m_cpt_write_miss;    // Number of MISS WRITE
    379410      uint32_t     m_cpt_write_cells;   // Cumulated length for WRITE transactions
     
    391422      uint32_t     m_cpt_cas;           // Number of CAS transactions
    392423
     424      uint32_t     m_cpt_cleanup_cost;  // Number of (flits * distance) for CLEANUPs
     425
     426      uint32_t     m_cpt_update_flits;  // Number of flits for UPDATEs
     427      uint32_t     m_cpt_update_cost;   // Number of (flits * distance) for UPDATEs
     428
     429      uint32_t     m_cpt_inval_cost;    // Number of (flits * distance) for INVALs
     430
     431      uint32_t     m_cpt_get;
     432
     433      uint32_t     m_cpt_put;
     434
    393435      size_t       m_prev_count;
    394436
     
    407449      VciMemCache(
    408450          sc_module_name name,                                // Instance Name
    409           const soclib::common::MappingTable &mtp,            // Mapping table direct network
    410           const soclib::common::MappingTable &mtx,            // Mapping table external network
    411           const soclib::common::IntTab       &srcid_x,        // global index on external network
    412           const soclib::common::IntTab       &tgtid_d,        // global index on direct network
    413           const size_t                       cc_global_id,    // global index on cc network
     451          const soclib::common::MappingTable &mtp,            // Mapping table INT network
     452          const soclib::common::MappingTable &mtx,            // Mapping table RAM network
     453          const soclib::common::IntTab       &srcid_x,        // global index RAM network
     454          const soclib::common::IntTab       &tgtid_d,        // global index INT network
     455          const size_t                       cc_global_id,    // global index CC network
    414456          const size_t                       nways,           // Number of ways per set
    415457          const size_t                       nsets,           // Number of sets
    416458          const size_t                       nwords,          // Number of words per line
    417           const size_t                       max_copies,      // max number of copies in heap
     459          const size_t                       max_copies,      // max number of copies
    418460          const size_t                       heap_size=HEAP_ENTRIES,
    419461          const size_t                       trt_lines=TRT_ENTRIES,
     
    437479
    438480      // Component attributes
    439       std::list<soclib::common::Segment> m_seglist;          // segments allocated to memcache
     481      std::list<soclib::common::Segment> m_seglist;          // segments allocated
    440482      size_t                             m_nseg;             // number of segments
    441483      soclib::common::Segment            **m_seg;            // array of segments pointers
    442       const size_t                       m_srcid_x;          // global index on external network
     484      size_t                             m_seg_config;       // config segment index
     485      const size_t                       m_srcid_x;          // global index on RAM network
    443486      const size_t                       m_initiators;       // Number of initiators
    444487      const size_t                       m_heap_size;        // Size of the heap
     
    458501      size_t                             m_max_copies;       // max number of copies in heap
    459502      GenericLLSCGlobalTable
    460       < 32  ,                              // number of slots
    461         4096,                              // number of processors in the system
    462         8000,                              // registration life (# of LL operations)
    463         addr_t >  m_llsc_table;            // ll/sc global registration table
     503      < 32  ,    // number of slots
     504        4096,    // number of processors in the system
     505        8000,    // registration life (# of LL operations)
     506        addr_t >                         m_llsc_table;       // ll/sc registration table
    464507
    465508      // adress masks
     
    511554      // (segmentation violation response request)
    512555      sc_signal<bool>     r_tgt_cmd_to_tgt_rsp_req;
     556
     557      sc_signal<uint32_t> r_tgt_cmd_to_tgt_rsp_rdata;
     558      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_error;
    513559      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_srcid;
    514560      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_trdid;
    515561      sc_signal<size_t>   r_tgt_cmd_to_tgt_rsp_pktid;
    516562
     563      sc_signal<addr_t>   r_tgt_cmd_config_addr;
     564      sc_signal<size_t>   r_tgt_cmd_config_cmd;
     565
     566      ///////////////////////////////////////////////////////
     567      // Registers controlled by the CONFIG fsm
     568      ///////////////////////////////////////////////////////
     569
     570      sc_signal<int>      r_config_fsm;        // FSM state
     571      sc_signal<bool>     r_config_lock;       // lock protecting exclusive access
     572      sc_signal<int>      r_config_cmd;        // config request status
     573      sc_signal<addr_t>   r_config_address;    // target buffer physical address
     574      sc_signal<size_t>   r_config_srcid;      // config request srcid
     575      sc_signal<size_t>   r_config_trdid;      // config request trdid
     576      sc_signal<size_t>   r_config_pktid;      // config request pktid
     577      sc_signal<size_t>   r_config_nlines;     // number of lines covering the buffer
     578      sc_signal<size_t>   r_config_way;        // selected way
     579      sc_signal<size_t>   r_config_count;      // number of copies
     580      sc_signal<size_t>   r_config_upt_index;  // UPT index
     581      sc_signal<bool>     r_config_is_cnt;     // counter mode (broadcast required)
     582
     583      // Buffer between CONFIG fsm and TGT_RSP fsm (send a done response to L1 cache)
     584      sc_signal<bool>     r_config_to_tgt_rsp_req;    // valid request
     585      sc_signal<bool>     r_config_to_tgt_rsp_error;  // error response
     586      sc_signal<size_t>   r_config_to_tgt_rsp_srcid;  // Transaction srcid
     587      sc_signal<size_t>   r_config_to_tgt_rsp_trdid;  // Transaction trdid
     588      sc_signal<size_t>   r_config_to_tgt_rsp_pktid;  // Transaction pktid
     589
     590      // Buffer between CONFIG fsm and CC_SEND fsm (multi-inval / broadcast-inval)
     591      sc_signal<bool>     r_config_to_cc_send_multi_req;    // multi-inval request
     592      sc_signal<bool>     r_config_to_cc_send_brdcast_req;  // broadcast-inval request
     593      sc_signal<size_t>   r_config_to_cc_send_nline;        // line index
     594      sc_signal<size_t>   r_config_to_cc_send_trdid;        // UPT index
     595
    517596      ///////////////////////////////////////////////////////
    518597      // Registers controlled by the READ fsm
    519598      ///////////////////////////////////////////////////////
    520599
    521       sc_signal<int>      r_read_fsm;        // FSM state
    522       sc_signal<size_t>   r_read_copy;       // Srcid of the first copy
    523       sc_signal<size_t>   r_read_copy_cache; // Srcid of the first copy
    524       sc_signal<bool>     r_read_copy_inst;  // Type of the first copy
    525       sc_signal<tag_t>    r_read_tag;        // cache line tag (in directory)
    526       sc_signal<bool>     r_read_is_cnt;     // is_cnt bit (in directory)
    527       sc_signal<bool>     r_read_lock;       // lock bit (in directory)
    528       sc_signal<bool>     r_read_dirty;      // dirty bit (in directory)
    529       sc_signal<size_t>   r_read_count;      // number of copies
    530       sc_signal<size_t>   r_read_ptr;        // pointer to the heap
    531       sc_signal<data_t> * r_read_data;       // data (one cache line)
    532       sc_signal<size_t>   r_read_way;        // associative way (in cache)
    533       sc_signal<size_t>   r_read_trt_index;  // Transaction Table index
    534       sc_signal<size_t>   r_read_next_ptr;   // Next entry to point to
    535       sc_signal<bool>     r_read_last_free;  // Last free entry
    536       sc_signal<addr_t>   r_read_ll_key;     // LL key from the llsc_global_table
     600      sc_signal<int>      r_read_fsm;          // FSM state
     601      sc_signal<size_t>   r_read_copy;         // Srcid of the first copy
     602      sc_signal<size_t>   r_read_copy_cache;   // Srcid of the first copy
     603      sc_signal<bool>     r_read_copy_inst;    // Type of the first copy
     604      sc_signal<tag_t>    r_read_tag;          // cache line tag (in directory)
     605      sc_signal<bool>     r_read_is_cnt;       // is_cnt bit (in directory)
     606      sc_signal<bool>     r_read_lock;         // lock bit (in directory)
     607      sc_signal<bool>     r_read_dirty;        // dirty bit (in directory)
     608      sc_signal<size_t>   r_read_count;        // number of copies
     609      sc_signal<size_t>   r_read_ptr;          // pointer to the heap
     610      sc_signal<data_t> * r_read_data;         // data (one cache line)
     611      sc_signal<size_t>   r_read_way;          // associative way (in cache)
     612      sc_signal<size_t>   r_read_trt_index;    // Transaction Table index
     613      sc_signal<size_t>   r_read_next_ptr;     // Next entry to point to
     614      sc_signal<bool>     r_read_last_free;    // Last free entry
     615      sc_signal<addr_t>   r_read_ll_key;       // LL key from the llsc_global_table
    537616
    538617      // Buffer between READ fsm and IXR_CMD fsm (ask a missing cache line to XRAM)
     
    626705      sc_signal<addr_t>   r_multi_ack_nline;     // pending write nline
    627706
     707      // signaling completion of multi-inval to CONFIG fsm
     708      sc_signal<bool>     r_multi_ack_to_config_ack;
     709
    628710      // Buffer between MULTI_ACK fsm and TGT_RSP fsm (complete write/update transaction)
    629711      sc_signal<bool>     r_multi_ack_to_tgt_rsp_req;   // valid request
     
    662744      sc_signal<size_t>   r_cleanup_way;           // associative way (in cache)
    663745
    664       sc_signal<size_t>   r_cleanup_write_srcid;   // srcid of write response
     746      sc_signal<size_t>   r_cleanup_write_srcid;   // srcid of write rsp
    665747      sc_signal<size_t>   r_cleanup_write_trdid;   // trdid of write rsp
    666748      sc_signal<size_t>   r_cleanup_write_pktid;   // pktid of write rsp
    667       sc_signal<bool>     r_cleanup_write_need_rsp;// needs a write rsp
     749
     750      sc_signal<bool>     r_cleanup_need_rsp;      // write response required
     751      sc_signal<bool>     r_cleanup_need_ack;      // config acknowledge required
    668752
    669753      sc_signal<size_t>   r_cleanup_index;         // index of the INVAL line (in the UPT)
    670754
     755      // signaling completion of broadcast-inval to CONFIG fsm
     756      sc_signal<bool>     r_cleanup_to_config_ack; 
     757       
    671758      // Buffer between CLEANUP fsm and TGT_RSP fsm (acknowledge a write command from L1)
    672759      sc_signal<bool>     r_cleanup_to_tgt_rsp_req;   // valid request
  • trunk/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r431 r434  
    3434#include "../include/vci_mem_cache.h"
    3535
    36 //////   debug services   ///////////////////////////////////////////////////////
     36//////   debug services   /////////////////////////////////////////////////////////////
    3737// All debug messages are conditionned by two variables:
    3838// - compile time   : DEBUG_MEMC_*** : defined below
    39 // - execution time : m_debug_***    : defined by constructor arguments
    40 //    m_debug_* = (m_debug_ok) and (m_cpt_cycle > m_debug_start_cycle)
    41 /////////////////////////////////////////////////////////////////////////////////
     39// - execution time : m_debug  = (m_debug_ok) and (m_cpt_cycle > m_debug_start_cycle)
     40///////////////////////////////////////////////////////////////////////////////////////
    4241
    4342#define DEBUG_MEMC_GLOBAL    0 // synthetic trace of all FSMs
     43#define DEBUG_MEMC_CONFIG    1 // detailed trace of CONFIG FSM
    4444#define DEBUG_MEMC_READ      1 // detailed trace of READ FSM
    4545#define DEBUG_MEMC_WRITE     1 // detailed trace of WRITE FSM
     
    6464  "TGT_CMD_READ",
    6565  "TGT_CMD_WRITE",
    66   "TGT_CMD_CAS"
     66  "TGT_CMD_CAS",
     67  "TGT_CMD_CONFIG"
    6768};
    6869const char *tgt_rsp_fsm_str[] =
     
    118119  "MULTI_ACK_UPT_LOCK",
    119120  "MULTI_ACK_UPT_CLEAR",
    120   "MULTI_ACK_WRITE_RSP"
     121  "MULTI_ACK_WRITE_RSP",
     122  "MULTI_ACK_CONFIG_ACK"
    121123};
    122124const char *read_fsm_str[] =
     
    237239  "CLEANUP_UPT_CLEAR",
    238240  "CLEANUP_WRITE_RSP",
    239   "CLEANUP_SEND_ACK"
     241  "CLEANUP_CONFIG_ACK",
     242  "CLEANUP_SEND_CLACK"
    240243};
    241244const char *alloc_dir_fsm_str[] =
     
    457460    for(seg = m_seglist.begin() ; seg != m_seglist.end() ; seg++)
    458461    {
     462        if ( seg->special() ) m_seg_config = i;
    459463        m_seg[i] = & (*seg);
    460464        i++;
     
    631635    // Initializing FSMs
    632636    r_tgt_cmd_fsm    = TGT_CMD_IDLE;
     637    r_config_fsm     = CONFIG_IDLE;
    633638    r_tgt_rsp_fsm    = TGT_RSP_TGT_CMD_IDLE;
    634639    r_cc_send_fsm    = CC_SEND_XRAM_RSP_IDLE;
     
    647652    r_ixr_cmd_fsm    = IXR_CMD_READ_IDLE;
    648653
    649     m_debug_global         = false;
    650     m_debug_tgt_cmd_fsm    = false;
    651     m_debug_tgt_rsp_fsm    = false;
    652     m_debug_cc_send_fsm    = false;
    653     m_debug_cc_receive_fsm = false;
    654     m_debug_multi_ack_fsm  = false;
    655     m_debug_read_fsm       = false;
    656     m_debug_write_fsm      = false;
    657     m_debug_cas_fsm        = false;
    658     m_debug_cleanup_fsm    = false;
    659     m_debug_ixr_cmd_fsm    = false;
    660     m_debug_ixr_rsp_fsm    = false;
    661     m_debug_xram_rsp_fsm   = false;
     654    m_debug                = false;
    662655    m_debug_previous_hit   = false;
    663656    m_debug_previous_count = 0;
     
    690683    m_cmd_cas_eop_fifo.init()   ;
    691684
     685    r_config_cmd  = MEMC_CMD_NOP;
     686    r_config_lock = false;
     687
    692688    r_tgt_cmd_to_tgt_rsp_req = false;
    693689
     
    697693    r_write_to_tgt_rsp_req          = false;
    698694    r_write_to_ixr_cmd_req          = false;
    699     r_write_to_cc_send_multi_req   = false;
    700     r_write_to_cc_send_brdcast_req = false;
     695    r_write_to_cc_send_multi_req    = false;
     696    r_write_to_cc_send_brdcast_req  = false;
    701697    r_write_to_multi_ack_req        = false;
    702698
     
    816812#endif
    817813
    818   m_debug_global         = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    819   m_debug_tgt_cmd_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    820   m_debug_tgt_rsp_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    821   m_debug_cc_send_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    822   m_debug_cc_receive_fsm = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    823   m_debug_multi_ack_fsm  = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    824   m_debug_read_fsm       = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    825   m_debug_write_fsm      = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    826   m_debug_cas_fsm        = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    827   m_debug_cleanup_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    828   m_debug_ixr_cmd_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    829   m_debug_ixr_rsp_fsm    = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    830   m_debug_xram_rsp_fsm   = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
     814  m_debug = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
    831815
    832816#if DEBUG_MEMC_GLOBAL
    833   if(m_debug_global)
    834   {
     817if(m_debug)
     818{
    835819    std::cout
    836820        << "---------------------------------------------"           << std::dec << std::endl
     
    853837        << " - ALLOC_UPT FSM  = "  << alloc_upt_fsm_str[r_alloc_upt_fsm.read()]   << std::endl
    854838        << " - ALLOC_HEAP FSM = "  << alloc_heap_fsm_str[r_alloc_heap_fsm.read()] << std::endl;
    855   }
     839}
    856840#endif
    857841
     
    859843  //    TGT_CMD FSM
    860844  ////////////////////////////////////////////////////////////////////////////////////
    861   // The TGT_CMD_FSM controls the incoming VCI command pakets from the processors
     845  // The TGT_CMD_FSM controls the incoming VCI command pakets from the processors,
     846  // and dispatch these commands to the proper FSM through dedicated FIFOs.
    862847  //
    863   // There are 5 types of accepted commands :
    864   // - READ   : A READ request has a length of 1 VCI cell. It can be a single word
    865   //            or an entire cache line, depending on the PLEN value.
    866   // - WRITE  : A WRITE request has a maximum length of 16 cells, and can only
    867   //            concern words in a same line.
    868   // - CAS    : A CAS request has a length of 2 cells or 4 cells.
    869   // - LL     : An LL request has a length of 1 cell.
    870   // - SC     : An SC request has a length of 2 cells. First cell contains the
    871   //            acces key, second cell the data to write in case of success.
     848  // There are 5 types of commands accepted in the XRAM segment:
     849  // - READ   : A READ request has a length of 1 VCI flit. It can be a single word
     850  //            or an entire cache line, depending on the PLEN value => READ FSM
     851  // - WRITE  : A WRITE request has a maximum length of 16 flits, and can only
     852  //            concern words in a same line => WRITE FSM
     853  // - CAS    : A CAS request has a length of 2 flits or 4 flits => CAS FSM
     854  // - LL     : An LL request has a length of 1 flit => READ FSM
     855  // - SC     : An SC request has a length of 2 flits. First flit contains the
     856  //            acces key, second flit the data to write => WRITE FSM.
     857  //
     858  // The READ/WRITE commands accepted in the configuration segment are targeting,
     859  // configuration or status registers. They must contain one single flit.
     860  // - For almost all addressable registers, the response is returned immediately.
     861  // - For MEMC_CMD_TYPE, the response is delayed until the operation is completed.
    872862  ////////////////////////////////////////////////////////////////////////////////////
    873863
    874864  switch(r_tgt_cmd_fsm.read())
    875865  {
    876       //////////////////
    877     case TGT_CMD_IDLE:
    878       if(p_vci_tgt.cmdval)
    879       {
     866    //////////////////
     867    case TGT_CMD_IDLE:     // waiting a VCI command (RAM or CONFIG)
     868    if(p_vci_tgt.cmdval)
     869    {
    880870
    881871#if DEBUG_MEMC_TGT_CMD
    882         if(m_debug_tgt_cmd_fsm)
    883         {
    884           std::cout
    885               << "  <MEMC " << name()
    886               << " TGT_CMD_IDLE> Receive command from srcid "
    887               << std::dec << p_vci_tgt.srcid.read()
    888               << " / for address "
    889               << std::hex << p_vci_tgt.address.read()
    890               << std::endl;
    891         }
     872if(m_debug)
     873std::cout << "  <MEMC " << name()
     874          << " TGT_CMD_IDLE> Receive command from srcid "
     875          << std::dec << p_vci_tgt.srcid.read()
     876          << " / address " << std::hex << p_vci_tgt.address.read() << std::endl;
    892877#endif
    893878        // checking segmentation violation
    894         addr_t  address = p_vci_tgt.address.read();
    895         uint32_t    plen    = p_vci_tgt.plen.read();
    896         bool found = false;
    897         for(size_t seg_id = 0 ; seg_id < m_nseg ; seg_id++)
    898         {
    899           if(m_seg[seg_id]->contains(address) &&
    900               m_seg[seg_id]->contains(address + plen - vci_param_int::B))
    901           {
    902             found = true;
    903           }
    904         }
    905 
    906         if(not found)
    907         {
    908           r_tgt_cmd_fsm = TGT_CMD_ERROR;
    909         }
    910         else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_READ)
    911         {
    912           // check that the pktid is either :
    913           // TYPE_READ_DATA_UNC
    914           // TYPE_READ_DATA_MISS
    915           // TYPE_READ_INS_UNC
    916           // TYPE_READ_INS_MISS
    917           // ==> bit2 must be zero with the TSAR encoding
    918           // ==> mask = 0b0100 = 0x4
    919           assert(((p_vci_tgt.pktid.read() & 0x4) == 0x0) &&
    920                  "The type specified in the pktid field is incompatible with the READ CMD");
    921           r_tgt_cmd_fsm = TGT_CMD_READ;
    922         }
    923         else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)
    924         {
    925           // check that the pktid is TYPE_WRITE
    926           // ==> TYPE_WRITE = X100 with the TSAR encoding
    927           // ==> mask = 0b0111 = 0x7
    928           assert(((p_vci_tgt.pktid.read() & 0x7) == 0x4) &&
    929                  "The type specified in the pktid field is incompatible with the WRITE CMD");
    930           r_tgt_cmd_fsm = TGT_CMD_WRITE;
    931         }
    932         else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ)
    933         {
    934           // check that the pktid is TYPE_LL
    935           // ==> TYPE_LL = X110 with the TSAR encoding
    936           // ==> mask = 0b0111 = 0x7
    937           assert(((p_vci_tgt.pktid.read() & 0x7) == 0x6) &&
    938                  "The type specified in the pktid field is incompatible with the LL CMD");
    939           r_tgt_cmd_fsm = TGT_CMD_READ;
    940         }
    941         else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_NOP)
    942         {
    943           // check that the pktid is either :
    944           // TYPE_CAS
    945           // TYPE_SC
    946           // ==> TYPE_CAS = X101 with the TSAR encoding
    947           // ==> TYPE_SC  = X111 with the TSAR encoding
    948           // ==> mask = 0b0101 = 0x5
    949           assert(((p_vci_tgt.pktid.read() & 0x5) == 0x5) &&
    950                  "The type specified in the pktid field is incompatible with the NOP CMD");
    951 
    952           if((p_vci_tgt.pktid.read() & 0x7) == TYPE_CAS)
    953             r_tgt_cmd_fsm = TGT_CMD_CAS;
    954           else // TYPE_SC
    955             r_tgt_cmd_fsm = TGT_CMD_WRITE;
    956         }
    957         else
    958         {
    959           std::cout << "VCI_MEM_CACHE ERROR " << name()
    960                     << " TGT_CMD_IDLE state" << std::endl;
    961           std::cout << " illegal VCI command type" << std::endl;
    962           exit(0);
    963         }
    964       }
    965       break;
    966 
    967     case TGT_CMD_ERROR:
    968       // A segmentation violation has been detected, thus a response with error
    969       // must be sent
    970 
    971       // wait if pending TGT_CMD request to TGT_RSP FSM
    972       if(r_tgt_cmd_to_tgt_rsp_req.read()) break;
    973 
    974       // consume all the command packet flits and set new request to the
    975       // TGT_RSP FSM
    976       if(p_vci_tgt.cmdval and p_vci_tgt.eop)
    977       {
    978         r_tgt_cmd_to_tgt_rsp_req   = true;
     879        addr_t      address  = p_vci_tgt.address.read();
     880        uint32_t    plen     = p_vci_tgt.plen.read();
     881        bool        found    = false;
     882        bool        config   = false;
     883
     884        // register arguments for response (segmentation violation or config)
    979885        r_tgt_cmd_to_tgt_rsp_srcid = p_vci_tgt.srcid.read();
    980886        r_tgt_cmd_to_tgt_rsp_trdid = p_vci_tgt.trdid.read();
    981887        r_tgt_cmd_to_tgt_rsp_pktid = p_vci_tgt.pktid.read();
    982888
    983         r_tgt_cmd_fsm = TGT_CMD_IDLE;
     889        for(size_t seg_id = 0 ; (seg_id < m_nseg) and not found ; seg_id++)
     890        {
     891            if( m_seg[seg_id]->contains(address) and
     892                m_seg[seg_id]->contains(address + plen - vci_param_int::B) )
     893            {
     894                found = true;
     895                if ( m_seg[seg_id]->special() ) config = true;
     896            }
     897        }
     898
     899        if ( not found )                /////////// out of segment error
     900        {
     901            r_tgt_cmd_fsm   = TGT_CMD_ERROR;
     902        }
     903        else if ( config )              /////////// configuration command
     904        {
     905            if ( not p_vci_tgt.eop.read() ) r_tgt_cmd_fsm = TGT_CMD_ERROR;
     906            else                            r_tgt_cmd_fsm = TGT_CMD_CONFIG;
     907        }
     908        else                            //////////// memory access
     909        {
     910            if ( p_vci_tgt.cmd.read() == vci_param_int::CMD_READ )
     911            {
     912                // check that the pktid is either :
     913                // TYPE_READ_DATA_UNC
     914                // TYPE_READ_DATA_MISS
     915                // TYPE_READ_INS_UNC
     916                // TYPE_READ_INS_MISS
     917                // ==> bit2 must be zero with the TSAR encoding
     918                // ==> mask = 0b0100 = 0x4
     919                assert( ((p_vci_tgt.pktid.read() & 0x4) == 0x0) and
     920                "The type specified in the pktid field is incompatible with the READ CMD");
     921                r_tgt_cmd_fsm = TGT_CMD_READ;
     922            }
     923            else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)
     924            {
     925                // check that the pktid is TYPE_WRITE
     926                // ==> TYPE_WRITE = X100 with the TSAR encoding
     927                // ==> mask = 0b0111 = 0x7
     928                assert(((p_vci_tgt.pktid.read() & 0x7) == 0x4) and
     929                "The type specified in the pktid field is incompatible with the WRITE CMD");
     930                r_tgt_cmd_fsm = TGT_CMD_WRITE;
     931            }
     932            else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ)
     933            {
     934                // check that the pktid is TYPE_LL
     935                // ==> TYPE_LL = X110 with the TSAR encoding
     936                // ==> mask = 0b0111 = 0x7
     937                assert(((p_vci_tgt.pktid.read() & 0x7) == 0x6) and
     938                "The type specified in the pktid field is incompatible with the LL CMD");
     939                r_tgt_cmd_fsm = TGT_CMD_READ;
     940            }
     941            else if(p_vci_tgt.cmd.read() == vci_param_int::CMD_NOP)
     942            {
     943                // check that the pktid is either :
     944                // TYPE_CAS
     945                // TYPE_SC
     946                // ==> TYPE_CAS = X101 with the TSAR encoding
     947                // ==> TYPE_SC  = X111 with the TSAR encoding
     948                // ==> mask = 0b0101 = 0x5
     949                assert(((p_vci_tgt.pktid.read() & 0x5) == 0x5) and
     950                "The type specified in the pktid field is incompatible with the NOP CMD");
     951
     952                if((p_vci_tgt.pktid.read() & 0x7) == TYPE_CAS) r_tgt_cmd_fsm = TGT_CMD_CAS;
     953                else                                           r_tgt_cmd_fsm = TGT_CMD_WRITE;
     954            }
     955            else
     956            {
     957                r_tgt_cmd_fsm = TGT_CMD_ERROR;
     958            }
     959        }
     960    }
     961    break;
     962
     963    ///////////////////
     964    case TGT_CMD_ERROR:  // response error must be sent
     965
     966    // wait if pending TGT_CMD request to TGT_RSP FSM
     967    if(r_tgt_cmd_to_tgt_rsp_req.read()) break;
     968
     969    // consume all the command packet flits before sending response error
     970    if ( p_vci_tgt.cmdval and p_vci_tgt.eop )
     971    {
     972        r_tgt_cmd_to_tgt_rsp_req   = true;
     973        r_tgt_cmd_to_tgt_rsp_error = 1;
     974        r_tgt_cmd_fsm              = TGT_CMD_IDLE;
    984975
    985976#if DEBUG_MEMC_TGT_CMD
    986 if(m_debug_tgt_cmd_fsm)
     977if(m_debug)
    987978  std::cout << "  <MEMC " << name()
    988979    << " TGT_CMD_ERROR> Segmentation violation:"
     
    993984    << " / plen = " << std::dec << p_vci_tgt.plen.read() << std::endl;
    994985#endif
    995       }
    996 
    997       break;
    998 
    999       //////////////////
    1000     case TGT_CMD_READ:
    1001       // This test checks that the read does not cross a cache line limit.
    1002       // It must not be taken into account when dealing with an LL CMD.
    1003       if(((m_x[(addr_t) p_vci_tgt.address.read()]+ (p_vci_tgt.plen.read() >>2)) > 16) &&
     986
     987    }
     988    break;
     989
     990    ////////////////////
     991    case TGT_CMD_CONFIG:    // execute config request and return response
     992    {
     993        if ( r_tgt_cmd_to_tgt_rsp_req.read() ) break;
     994
     995        addr_t   seg_base = m_seg[m_seg_config]->baseAddress();
     996        addr_t   address  = p_vci_tgt.address.read();
     997        size_t   cell     = (address - seg_base)/vci_param_int::B;
     998        bool     need_rsp = true;  // default value
     999        size_t   error    = 0;     // default value
     1000        uint32_t rdata    = 0;     // default value
     1001
     1002        if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_READ)         // get lock
     1003             and (cell == MEMC_LOCK) )
     1004        {
     1005            rdata         = (uint32_t)r_config_lock.read();
     1006            r_config_lock = true;
     1007        }
     1008        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)  // release lock
     1009                   and (cell == MEMC_LOCK) )
     1010        {
     1011            r_config_lock = false;
     1012        }
     1013        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set cmd type
     1014                   and (cell == MEMC_CMD_TYPE) )
     1015        {
     1016            r_config_cmd = p_vci_tgt.wdata.read();
     1017            need_rsp     = false;
     1018        }
     1019        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_lo
     1020                   and (cell == MEMC_ADDR_LO) )
     1021        {
     1022            r_config_address = (r_config_address.read() & 0xFFFFFFFF00000000LL) |
     1023                               (addr_t)p_vci_tgt.wdata.read();
     1024        }
     1025        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_hi
     1026                   and (cell == MEMC_ADDR_HI) )
     1027        {
     1028            r_config_address = (r_config_address.read() & 0x00000000FFFFFFFFLL) |
     1029                               ((addr_t)p_vci_tgt.wdata.read())<<32;
     1030        }
     1031        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set buf_lines
     1032                   and (cell == MEMC_BUF_LENGTH) )
     1033        {
     1034            size_t lines = (size_t)(p_vci_tgt.wdata.read()/(m_words*vci_param_int::B));
     1035            if ( r_config_address.read()/(m_words*vci_param_int::B) ) lines++;
     1036            r_config_nlines = lines;
     1037        }
     1038        else
     1039        {
     1040            error = 1;
     1041        }
     1042
     1043        if ( need_rsp )
     1044        {
     1045            // blocked if previous pending request to TGT_RSP FSM
     1046            if ( r_tgt_cmd_to_tgt_rsp_req.read() ) break;
     1047
     1048            r_tgt_cmd_to_tgt_rsp_req   = true;
     1049            r_tgt_cmd_to_tgt_rsp_error = error;
     1050            r_tgt_cmd_to_tgt_rsp_rdata = rdata;
     1051            r_tgt_cmd_fsm              = TGT_CMD_IDLE;
     1052        }
     1053        else
     1054        {
     1055            r_tgt_cmd_fsm              = TGT_CMD_IDLE;
     1056        }
     1057
     1058#if DEBUG_MEMC_TGT_CMD
     1059if(m_debug)
     1060std::cout << "  <MEMC " << name() << " TGT_CMD_CONFIG> Configuration request:"
     1061          << " address = " << std::hex << p_vci_tgt.address.read()
     1062          << " / wdata = " << p_vci_tgt.wdata.read()
     1063          << " / error = " << error << std::endl;
     1064#endif
     1065        break;
     1066    }
     1067    //////////////////
     1068    case TGT_CMD_READ:    // Push a read request into read fifo
     1069
     1070    // check that the read does not cross a cache line limit.
     1071    if ( ((m_x[(addr_t) p_vci_tgt.address.read()]+ (p_vci_tgt.plen.read() >>2)) > 16) and
    10041072          (p_vci_tgt.cmd.read() != vci_param_int::CMD_LOCKED_READ))
    1005       {
    1006         std::cout
    1007             << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
    1008             << std::endl;
    1009         std::cout
    1010             << " illegal address/plen combination for VCI read command" << std::endl;
     1073    {
     1074        std::cout << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
     1075                  << " illegal address/plen for VCI read command" << std::endl;
    10111076        exit(0);
    1012       }
    1013       if(!p_vci_tgt.eop.read())
    1014       {
    1015         std::cout
    1016             << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
    1017             << std::endl;
    1018         std::cout
    1019             << " read or ll command packets must contain one single flit"
    1020             << std::endl;
     1077    }
     1078    // check single flit
     1079    if(!p_vci_tgt.eop.read())
     1080    {
     1081        std::cout << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
     1082                  << " read command packet must contain one single flit" << std::endl;
    10211083        exit(0);
    1022       }
    1023       if((p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ) && (p_vci_tgt.plen.read() != 8))
    1024       {
    1025         std::cout
    1026             << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
    1027             << std::endl;
    1028         std::cout
    1029             << " ll command packets must have a plen of 8"
    1030             << std::endl;
     1084    }
     1085    // check plen for LL
     1086    if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ) and
     1087         (p_vci_tgt.plen.read() != 8) )
     1088    {
     1089        std::cout << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_READ state"
     1090                  << " ll command packets must have a plen of 8" << std::endl;
    10311091        exit(0);
    1032       }
    1033 
    1034       if(p_vci_tgt.cmdval && m_cmd_read_addr_fifo.wok())
    1035       {
     1092    }
     1093
     1094    if ( p_vci_tgt.cmdval and m_cmd_read_addr_fifo.wok() )
     1095    {
    10361096
    10371097#if DEBUG_MEMC_TGT_CMD
    1038 if(m_debug_tgt_cmd_fsm)
     1098if(m_debug)
    10391099std::cout << "  <MEMC " << name() << " TGT_CMD_READ> Push into read_fifo:"
    10401100          << " address = " << std::hex << p_vci_tgt.address.read()
     
    10451105#endif
    10461106        cmd_read_fifo_put = true;
    1047         if(p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ)
    1048           m_cpt_ll++;
    1049         else
    1050           m_cpt_read++;
     1107        if(p_vci_tgt.cmd.read() == vci_param_int::CMD_LOCKED_READ) m_cpt_ll++;
     1108        else                                                       m_cpt_read++;
    10511109        r_tgt_cmd_fsm = TGT_CMD_IDLE;
    1052       }
    1053       break;
    1054 
    1055       ///////////////////
     1110    }
     1111    break;
     1112
     1113    ///////////////////
    10561114    case TGT_CMD_WRITE:
    1057       if(p_vci_tgt.cmdval && m_cmd_write_addr_fifo.wok())
    1058       {
     1115    if(p_vci_tgt.cmdval and m_cmd_write_addr_fifo.wok())
     1116    {
    10591117
    10601118#if DEBUG_MEMC_TGT_CMD
    1061 if(m_debug_tgt_cmd_fsm)
     1119if(m_debug)
    10621120std::cout << "  <MEMC " << name() << " TGT_CMD_WRITE> Push into write_fifo:"
    10631121          << " address = " << std::hex << p_vci_tgt.address.read()
     
    10711129        cmd_write_fifo_put = true;
    10721130        if(p_vci_tgt.eop)  r_tgt_cmd_fsm = TGT_CMD_IDLE;
    1073       }
    1074       break;
    1075 
    1076       ////////////////////
     1131    }
     1132    break;
     1133
     1134    /////////////////
    10771135    case TGT_CMD_CAS:
    1078       if((p_vci_tgt.plen.read() != 8) && (p_vci_tgt.plen.read() != 16))
    1079       {
    1080         std::cout
    1081             << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_CAS state"
    1082             << std::endl
    1083             << "illegal format for CAS command " << std::endl;
    1084 
     1136    if((p_vci_tgt.plen.read() != 8) and (p_vci_tgt.plen.read() != 16))
     1137    {
     1138        std::cout << "VCI_MEM_CACHE ERROR " << name() << " TGT_CMD_CAS state"
     1139                  << "illegal format for CAS command " << std::endl;
    10851140        exit(0);
    1086       }
    1087 
    1088       if(p_vci_tgt.cmdval && m_cmd_cas_addr_fifo.wok())
    1089       {
     1141    }
     1142
     1143    if(p_vci_tgt.cmdval and m_cmd_cas_addr_fifo.wok())
     1144    {
    10901145
    10911146#if DEBUG_MEMC_TGT_CMD
    1092 if(m_debug_tgt_cmd_fsm)
     1147if(m_debug)
    10931148std::cout << "  <MEMC " << name() << " TGT_CMD_CAS> Pushing command into cmd_cas_fifo:"
    10941149          << " address = " << std::hex << p_vci_tgt.address.read()
     
    11021157        cmd_cas_fifo_put = true;
    11031158        if(p_vci_tgt.eop) r_tgt_cmd_fsm = TGT_CMD_IDLE;
    1104       }
    1105       break;
     1159    }
     1160    break;
    11061161  } // end switch tgt_cmd_fsm
    11071162
     
    11151170  // It can be update or inval requests initiated by the WRITE or CAS FSM,
    11161171  // or inval requests initiated by the XRAM_RSP FSM.
    1117   // It can also be a direct request from the WRITE FSM.
    11181172  //
    11191173  // The FSM decrements the proper entry in UPT.
     
    11291183  switch(r_multi_ack_fsm.read())
    11301184  {
    1131     ///////////////////
     1185    ////////////////////
    11321186    case MULTI_ACK_IDLE:
    1133       {
     1187    {
    11341188        bool multi_ack_fifo_rok = m_cc_receive_to_multi_ack_fifo.rok();
    11351189
     
    11651219
    11661220#if DEBUG_MEMC_MULTI_ACK
    1167         if(m_debug_multi_ack_fsm)
    1168         {
    1169           if (multi_ack_fifo_rok)
    1170           {
    1171             std::cout
    1172               << "  <MEMC " << name()
    1173               << " MULTI_ACK_IDLE> Response for UPT entry "
    1174               << updt_index
    1175               << std::endl;
    1176           }
    1177           else
    1178           {
    1179             std::cout
    1180               << "  <MEMC " << name()
    1181               << " MULTI_ACK_IDLE> Write FSM request to decrement UPT entry "
    1182               << updt_index
    1183               << std::endl;
    1184           }
    1185         }
     1221if(m_debug)
     1222{
     1223    if (multi_ack_fifo_rok)
     1224    {
     1225        std::cout << "  <MEMC " << name()
     1226                  << " MULTI_ACK_IDLE> Response for UPT entry "
     1227                  << updt_index << std::endl;
     1228    }
     1229    else
     1230    {
     1231        std::cout << "  <MEMC " << name()
     1232                  << " MULTI_ACK_IDLE> Write FSM request to decrement UPT entry "
     1233                  << updt_index << std::endl;
     1234    }
     1235}
    11861236#endif
    11871237        break;
     
    11901240    ////////////////////////
    11911241    case MULTI_ACK_UPT_LOCK:
    1192       {
     1242    {
    11931243        // get lock to the UPDATE table
    11941244        if(r_alloc_upt_fsm.read() != ALLOC_UPT_MULTI_ACK) break;
     
    12001250        if(not valid)
    12011251        {
    1202           std::cout
    1203             << "VCI_MEM_CACHE ERROR " << name()
    1204             << " MULTI_ACK_UPT_LOCK state" << std::endl
    1205             << "unsuccessful access to decrement the UPT"
    1206             << std::endl;
    1207 
    1208           exit(0);
     1252            std::cout << "VCI_MEM_CACHE ERROR " << name()
     1253                      << " MULTI_ACK_UPT_LOCK state" << std::endl
     1254                      << "unsuccessful access to decrement the UPT" << std::endl;
     1255            exit(0);
    12091256        }
    12101257
     
    12191266
    12201267#if DEBUG_MEMC_MULTI_ACK
    1221         if(m_debug_multi_ack_fsm)
    1222         {
    1223           std::cout
    1224             << "  <MEMC " << name()
    1225             << " MULTI_ACK_UPT_LOCK> Decrement the responses counter for UPT:"
    1226             << " entry = "       << r_multi_ack_upt_index.read()
    1227             << " / rsp_count = " << std::dec << count
    1228             << std::endl;
    1229         }
     1268if(m_debug)
     1269std::cout << "  <MEMC " << name()
     1270          << " MULTI_ACK_UPT_LOCK> Decrement the responses counter for UPT:"
     1271          << " entry = "       << r_multi_ack_upt_index.read()
     1272          << " / rsp_count = " << std::dec << count << std::endl;
    12301273#endif
    12311274        break;
    1232       }
     1275    }
    12331276
    12341277    /////////////////////////
    1235     case MULTI_ACK_UPT_CLEAR:
    1236       {
     1278    case MULTI_ACK_UPT_CLEAR:   // Clear UPT entry / Test if rsp or ack required
     1279    {
    12371280        if(r_alloc_upt_fsm.read() != ALLOC_UPT_MULTI_ACK)
    12381281        {
    1239           std::cout
    1240             << "VCI_MEM_CACHE ERROR " << name()
    1241             << " MULTI_ACK_UPT_CLEAR state"
    1242             << " bad UPT allocation"
    1243             << std::endl;
    1244 
    1245           exit(0);
     1282            std::cout << "VCI_MEM_CACHE ERROR " << name()
     1283                      << " MULTI_ACK_UPT_CLEAR state"
     1284                      << " bad UPT allocation" << std::endl;
     1285            exit(0);
    12461286        }
    12471287
     
    12511291        r_multi_ack_nline = m_upt.nline(r_multi_ack_upt_index.read());
    12521292        bool need_rsp     = m_upt.need_rsp(r_multi_ack_upt_index.read());
     1293        bool need_ack     = m_upt.need_ack(r_multi_ack_upt_index.read());
    12531294
    12541295        // clear the UPT entry
    12551296        m_upt.clear(r_multi_ack_upt_index.read());
    12561297
    1257         if(need_rsp)
    1258         {
    1259           r_multi_ack_fsm = MULTI_ACK_WRITE_RSP;
    1260         }
    1261         else
    1262         {
    1263           r_multi_ack_fsm = MULTI_ACK_IDLE;
    1264         }
     1298        if      ( need_rsp ) r_multi_ack_fsm = MULTI_ACK_WRITE_RSP;
     1299        else if ( need_ack ) r_multi_ack_fsm = MULTI_ACK_CONFIG_ACK;
     1300        else                 r_multi_ack_fsm = MULTI_ACK_IDLE;
    12651301
    12661302#if DEBUG_MEMC_MULTI_ACK
    1267         if(m_debug_multi_ack_fsm)
    1268         {
    1269           std::cout
    1270             <<  "  <MEMC " << name()
    1271             << " MULTI_ACK_UPT_CLEAR> Clear UPT entry "
    1272             << r_multi_ack_upt_index.read()
    1273             << std::endl;
    1274         }
     1303if(m_debug)
     1304std::cout <<  "  <MEMC " << name()
     1305          << " MULTI_ACK_UPT_CLEAR> Clear UPT entry "
     1306          << std::dec << r_multi_ack_upt_index.read() << std::endl;
    12751307#endif
    12761308        break;
    1277       }
    1278 
     1309    }
    12791310    /////////////////////////
    1280     case MULTI_ACK_WRITE_RSP:
    1281       {
    1282         // Post a request to TGT_RSP FSM
    1283         // Wait if pending request to the TGT_RSP FSM
    1284         if(r_multi_ack_to_tgt_rsp_req.read()) break;
     1311    case MULTI_ACK_WRITE_RSP:     // Post a response request to TGT_RSP FSM
     1312                                  // Wait if pending request
     1313    {
     1314        if ( r_multi_ack_to_tgt_rsp_req.read() ) break;
    12851315
    12861316        r_multi_ack_to_tgt_rsp_req   = true;
     
    12911321
    12921322#if DEBUG_MEMC_MULTI_ACK
    1293         if(m_debug_multi_ack_fsm)
    1294         {
    1295           std::cout
    1296             << "  <MEMC " << name()
    1297             << " MULTI_ACK_WRITE_RSP> Request TGT_RSP FSM to send a response to srcid "
    1298             << r_multi_ack_srcid.read()
    1299             << std::endl;
    1300         }
     1323if(m_debug)
     1324std::cout << "  <MEMC " << name() << " MULTI_ACK_WRITE_RSP>"
     1325          << " Request TGT_RSP FSM to send a response to srcid "
     1326          << std::hex << r_multi_ack_srcid.read() << std::endl;
    13011327#endif
    13021328        break;
    1303       }
     1329    }
     1330    //////////////////////////
     1331    case MULTI_ACK_CONFIG_ACK:    // Signals multi-inval completion to CONFIG FSM
     1332                                  // Wait if pending request
     1333    {
     1334        if ( r_multi_ack_to_config_ack.read() ) break;
     1335
     1336        r_multi_ack_to_config_ack   = true;
     1337        r_multi_ack_fsm              = MULTI_ACK_IDLE;
     1338
     1339#if DEBUG_MEMC_MULTI_ACK
     1340if(m_debug)
     1341std::cout << "  <MEMC " << name() << " MULTI_ACK_CONFIG_ACK>"
     1342          << " Signals inval completion to CONFIG FSM" << std::endl;
     1343#endif
     1344        break;
     1345    }
    13041346  } // end switch r_multi_ack_fsm
     1347
     1348  ////////////////////////////////////////////////////////////////////////////////////
     1349  //    CONFIG FSM
     1350  ////////////////////////////////////////////////////////////////////////////////////
     1351  // The CONFIG FSM handles the VCI configuration requests (INVAL & SYNC).
     1352  // The target buffer can have any size, and there is one single command for
     1353  // all cache lines covered by the target buffer.
     1354  // An INVAL or SYNC configuration request is defined by the followinf registers:
     1355  // - bool      r_config_cmd        : INVAL / SYNC / NOP)
     1356  // - uint64_t  r_config_address    : buffer base address
     1357  // - uint32_t  r_config_nlines     : number of lines covering buffer
     1358  //
     1359  // For both INVAL and SYNC commands, the CONFIG FSM contains the loop handling
     1360  // all cache lines covered by the target buffer.
     1361  //
     1362  // - INVAL request:
     1363  //   For each line, it access to the DIR array.
     1364  //   In case of miss, it does nothing, and a response is requested to TGT_RSP FSM.
     1365  //   In case of hit, with no copies in L1 caches, the line is invalidated and
     1366  //   a response is requested to TGT_RSP FSM.
     1367  //   If there is copies, a multi-inval, or a broadcast-inval coherence transaction
     1368  //   is launched and registered in UPT. The multi-inval transaction is signaled
     1369  //   by the r_multi_ack_to config_ack or r_cleanup_to_config_ack flip-flops.
     1370  //   The config inval response is sent only when the last line has been invalidated.
     1371  //
     1372  // - SYNC request: Not implemented yet
     1373  //
     1374  // From the software point of view, a configuration request is a sequence
     1375  // of 6 atomic accesses:
     1376  // - Read  MEMC_LOCK       : Get the lock
     1377  // - Write MEMC_ADDR_LO    : Set the buffer address LSB
     1378  // - Write MEMC_ADDR_HI    : Set the buffer address MSB
     1379  // - Write MEMC_BUF_LENGTH : set buffer length (bytes)
     1380  // - Write MEMC_CMD_TYPE   : launch the actual operation
     1381  // - WRITE MEMC_LOCK       : release the lock
     1382  ////////////////////////////////////////////////////////////////////////////////////
     1383
     1384  switch( r_config_fsm.read() )
     1385  {
     1386      /////////////////
     1387      case CONFIG_IDLE:  // waiting a config request
     1388      {
     1389          if ( r_config_cmd.read() != MEMC_CMD_NOP ) 
     1390          {
     1391              r_config_fsm    = CONFIG_LOOP;
     1392          }
     1393
     1394#if DEBUG_MEMC_CONFIG
     1395if(m_debug)
     1396std::cout << "  <MEMC " << name() << " CONFIG_IDLE> Config Request received"
     1397          << " address = " << std::hex << r_config_address.read()
     1398          << " / nlines = " << std::dec << r_config_nlines.read()
     1399          << " / type = " << r_config_cmd.read() << std::endl;
     1400#endif
     1401          break;
     1402      }
     1403      /////////////////
     1404      case CONFIG_LOOP:   // test last line
     1405      {
     1406          if ( r_config_nlines.read() == 0 )
     1407          {
     1408              r_config_cmd = MEMC_CMD_NOP;
     1409              r_config_fsm = CONFIG_RSP;
     1410          }
     1411          else
     1412          {
     1413              r_config_fsm = CONFIG_DIR_REQ;
     1414          }
     1415
     1416#if DEBUG_MEMC_CONFIG
     1417if(m_debug)
     1418std::cout << "  <MEMC " << name() << " CONFIG_SYNC_LOOP>"
     1419          << " address = " << std::hex << r_config_address.read()   
     1420          << " / nlines = " << std::dec << r_config_nlines.read()
     1421          << " / type = " << r_config_cmd.read() << std::endl;
     1422#endif
     1423          break;
     1424      }
     1425      ////////////////////
     1426      case CONFIG_DIR_REQ:  // Request directory lock
     1427      {
     1428          if ( r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG )
     1429          {
     1430              r_config_fsm = CONFIG_DIR_ACCESS;
     1431          }
     1432
     1433#if DEBUG_MEMC_CONFIG
     1434if(m_debug)
     1435std::cout << "  <MEMC " << name() << " CONFIG_INVAL_DIR_REQ>"
     1436          << " Request DIR access" << std::endl;
     1437#endif
     1438          break;
     1439      }
     1440      ///////////////////////
     1441      case CONFIG_DIR_ACCESS:   // Access directory and decode cmd
     1442      {
     1443          size_t way = 0;
     1444          DirectoryEntry entry = m_cache_directory.read(r_config_address.read(), way);
     1445
     1446          if ( entry.valid and                            // hit & inval command
     1447               (r_config_cmd.read() == MEMC_CMD_INVAL) )
     1448          {
     1449              r_config_way    = way;
     1450              r_config_is_cnt = entry.is_cnt;
     1451              r_config_count  = entry.count;
     1452              r_config_fsm    = CONFIG_DIR_INVAL;
     1453          }
     1454          else if ( entry.valid and                       // hit & sync command
     1455                    entry.dirty and
     1456                    (r_config_cmd.read() == MEMC_CMD_SYNC) )
     1457          {
     1458              std::cout << "VCI_MEM_CACHE ERROR: "
     1459                        << "SYNC config request not implemented yet" << std::endl;
     1460              exit(0);
     1461          }
     1462          else                                            // nothing to do : return to LOOP
     1463          {
     1464              r_config_nlines  = r_config_nlines.read() - 1;
     1465              r_config_address = r_config_address.read() + (m_words*vci_param_int::B);
     1466              r_config_fsm     = CONFIG_LOOP;
     1467          }
     1468
     1469#if DEBUG_MEMC_CONFIG
     1470if(m_debug)
     1471std::cout << "  <MEMC " << name() << " CONFIG_DIR_ACCESS> Accessing directory: "
     1472          << " address = " << std::hex << m_cmd_read_addr_fifo.read()
     1473          << " / hit = " << std::dec << entry.valid
     1474          << " / dirty = " <<std::dec << entry.dirty
     1475          << " / count = " <<std::dec << entry.count
     1476          << " / is_cnt = " << entry.is_cnt << std::endl;
     1477#endif
     1478          break;
     1479      }
     1480      //////////////////////
     1481      case CONFIG_DIR_INVAL:  // Invalidate the directory entry
     1482      {
     1483          size_t set        = m_y[(addr_t)(r_config_address.read())];
     1484          size_t way        = r_config_way.read();
     1485
     1486          m_cache_directory.inval( way, set );
     1487
     1488          if ( r_config_count.read() == 0 )     // return to LOOP
     1489          {
     1490              r_config_nlines  = r_config_nlines.read() - 1;
     1491              r_config_address = r_config_address.read() + (m_words*vci_param_int::B);
     1492              r_config_fsm     = CONFIG_LOOP;
     1493          }
     1494          else if ( r_config_is_cnt.read() )    // broacast required
     1495          {
     1496              r_config_fsm = CONFIG_BC_UPT_LOCK;
     1497          }
     1498          else
     1499          {
     1500              r_config_fsm = CONFIG_UPT_LOCK;
     1501          }
     1502
     1503#if DEBUG_MEMC_CONFIG
     1504if(m_debug)
     1505std::cout << "  <MEMC " << name() << " CONFIG_DIR_INVAL> Inval directory entry" << std::endl;
     1506#endif
     1507          break;
     1508      }
     1509      ////////////////////////
     1510      case CONFIG_BC_UPT_LOCK:  // try to register BC transaction in UPT
     1511      {
     1512          if ( r_alloc_upt_fsm.read() == ALLOC_UPT_CONFIG )
     1513          {
     1514              bool        wok       = false;
     1515              size_t      index     = 0;
     1516              size_t      srcid     = r_config_srcid.read();
     1517              size_t      trdid     = r_config_trdid.read();
     1518              size_t      pktid     = r_config_pktid.read();
     1519              addr_t      nline     = m_nline[(addr_t)(r_config_address.read())];
     1520              size_t      nb_copies = r_config_count.read();
     1521
     1522              wok = m_upt.set(false,    // it's an inval transaction
     1523                              true,     // it's a broadcast
     1524                              false,    // no response required
     1525                              true,     // acknowledge required
     1526                              srcid,
     1527                              trdid,
     1528                              pktid,
     1529                              nline,
     1530                              nb_copies,
     1531                              index);
     1532              if ( wok )
     1533              {
     1534                  r_config_fsm       = CONFIG_BC_SEND;
     1535                  r_config_upt_index = index;
     1536
     1537#if DEBUG_MEMC_CONFIG
     1538if( m_debug )
     1539std::cout << "  <MEMC " << name()
     1540          << " CONFIG_BC_UPT_LOCK> Register broadcast inval in UPT" << std::endl;
     1541#endif
     1542              }
     1543              else
     1544              {
     1545                  r_config_fsm       = CONFIG_UPT_WAIT;
     1546         
     1547#if DEBUG_MEMC_CONFIG
     1548if( m_debug )
     1549std::cout << "  <MEMC " << name() << " CONFIG_BC_UPT_LOCK>"
     1550          << " UPT full" << std::endl;
     1551#endif
     1552              }
     1553          }
     1554          break;
     1555      }
     1556      ////////////////////
     1557      case CONFIG_BC_SEND:    // Post a broadcast inval request to CC_SEND FSM
     1558      {
     1559          if( not r_config_to_cc_send_multi_req.read() and
     1560              not r_config_to_cc_send_brdcast_req.read() )
     1561          {
     1562              r_config_to_cc_send_multi_req   = false;
     1563              r_config_to_cc_send_brdcast_req = true;
     1564              r_config_to_cc_send_trdid       = r_config_upt_index.read();
     1565              r_config_to_cc_send_nline       = m_nline[(addr_t)(r_config_address.read())];
     1566
     1567              r_cleanup_to_config_ack         = false;
     1568
     1569              r_config_fsm                    = CONFIG_BC_WAIT;
     1570
     1571#if DEBUG_MEMC_CONFIG
     1572if(m_debug)
     1573std::cout << "  <MEMC " << name() << " CONFIG_BC_SEND>"
     1574          << " Post a broadcast inval request to CC_SEND FSM"
     1575          << " / address = " << r_config_address.read() <<std::endl;
     1576#endif
     1577          }
     1578          break;
     1579      }
     1580      ////////////////////
     1581      case CONFIG_BC_WAIT:      // wait broadcast completion to return to LOOP
     1582      {
     1583          if ( r_cleanup_to_config_ack.read() ) r_config_fsm = CONFIG_LOOP;
     1584
     1585#if DEBUG_MEMC_CONFIG
     1586if(m_debug)
     1587std::cout << "  <MEMC " << name() << " CONFIG_BC_WAIT>"
     1588          << " Waiting broadcast inval completion" << std::endl;
     1589#endif
     1590          break;
     1591      }
     1592      /////////////////////
     1593      case CONFIG_UPT_LOCK:  // Try to register multi-update in UPT
     1594      {
     1595          if ( r_alloc_upt_fsm.read() == ALLOC_UPT_CONFIG )
     1596          {
     1597              bool        wok       = false;
     1598              size_t      index     = 0;
     1599              size_t      srcid     = r_config_srcid.read();
     1600              size_t      trdid     = r_config_trdid.read();
     1601              size_t      pktid     = r_config_pktid.read();
     1602              addr_t      nline     = m_nline[(addr_t)(r_config_address.read())];
     1603              size_t      nb_copies = r_config_count.read();
     1604
     1605              wok = m_upt.set(false,    // it's an inval transaction
     1606                              false,    // not a broadcast
     1607                              false,    // no response required
     1608                              true,     // acknowledge required
     1609                              srcid,
     1610                              trdid,
     1611                              pktid,
     1612                              nline,
     1613                              nb_copies,
     1614                              index);
     1615              if ( wok )
     1616              {
     1617                  r_config_fsm       = CONFIG_BC_SEND;
     1618                  r_config_upt_index = index;
     1619
     1620#if DEBUG_MEMC_CONFIG
     1621if( m_debug )
     1622std::cout << "  <MEMC " << name()
     1623          << " CONFIG_BC_UPT_LOCK> Register broadcast inval in UPT" << std::endl;
     1624#endif
     1625              }
     1626              else
     1627              {
     1628                  r_config_fsm       = CONFIG_UPT_WAIT;
     1629         
     1630#if DEBUG_MEMC_CONFIG
     1631if( m_debug )
     1632std::cout << "  <MEMC " << name() << " CONFIG_BC_UPT_LOCK>"
     1633          << " UPT full" << std::endl;
     1634#endif
     1635              }
     1636
     1637#if DEBUG_MEMC_CONFIG
     1638if(m_debug)
     1639std::cout << "  <MEMC " << name() << " CONFIG_UPT_LOCK> Request access to UPT" << std::endl;
     1640#endif
     1641          }
     1642          break;
     1643      }
     1644      /////////////////////
     1645      case CONFIG_HEAP_REQ:  // request access to the heap
     1646      {
     1647          break;
     1648      }
     1649
     1650      ////////////////
     1651      case CONFIG_RSP:  // request TGT_RSP FSM to return response
     1652      {
     1653          if ( not r_config_to_tgt_rsp_req )
     1654          {
     1655              r_config_to_tgt_rsp_srcid  = r_config_srcid.read();
     1656              r_config_to_tgt_rsp_trdid  = r_config_trdid.read();
     1657              r_config_to_tgt_rsp_pktid  = r_config_pktid.read();
     1658              r_config_to_tgt_rsp_error  = false;
     1659              r_config_to_tgt_rsp_req    = true;
     1660              r_config_fsm               = CONFIG_IDLE;
     1661
     1662#if DEBUG_MEMC_CONFIG
     1663if(m_debug)
     1664std::cout << "  <MEMC " << name() << " CONFIG_RSP> Request TGT_RSP FSM to return response:"
     1665          << " error = " << r_config_to_tgt_rsp_error.read()
     1666          << " / rsrcid = " << std::hex << m_cmd_read_srcid_fifo.read() << std::endl;
     1667#endif
     1668          }
     1669          break;
     1670
     1671      }
     1672      /////////////////////
     1673      case CONFIG_UPT_WAIT:    // release the lock on UPT for one cycle, and retry
     1674      {
     1675          if ( r_config_is_cnt.read() ) r_config_fsm = CONFIG_BC_UPT_LOCK;
     1676          else                          r_config_fsm = CONFIG_UPT_LOCK;
     1677
     1678#if DEBUG_MEMC_CONFIG
     1679if(m_debug)
     1680std::cout << "  <MEMC " << name() << " CONFIG_UPT_WAIT>"
     1681          << " Release UPT lock" << std::endl;
     1682#endif
     1683          break;
     1684      }
     1685  }  // end switch r_config_fsm
    13051686
    13061687  ////////////////////////////////////////////////////////////////////////////////////
     
    13291710  switch(r_read_fsm.read())
    13301711  {
    1331     ///////////////
    1332     case READ_IDLE:
    1333       // waiting a read request
    1334     {
     1712      ///////////////
     1713      case READ_IDLE:  // waiting a read request
     1714      {
    13351715      if(m_cmd_read_addr_fifo.rok())
    13361716      {
    13371717
    13381718#if DEBUG_MEMC_READ
    1339 if(m_debug_read_fsm)
     1719if(m_debug)
    13401720std::cout << "  <MEMC " << name() << " READ_IDLE> Read request"
    13411721          << " : address = " << std::hex << m_cmd_read_addr_fifo.read()
     
    13501730    }
    13511731
     1732    //////////////////
     1733    case READ_DIR_REQ:  // Get the lock to the directory
     1734    {
     1735      if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
     1736      {
     1737        r_read_fsm = READ_DIR_LOCK;
     1738      }
     1739
     1740#if DEBUG_MEMC_READ
     1741if(m_debug)
     1742std::cout << "  <MEMC " << name() << " READ_DIR_REQ> Requesting DIR lock " << std::endl;
     1743#endif
     1744      break;
     1745    }
     1746
    13521747    ///////////////////
    1353     case READ_DIR_REQ:
    1354       // Get the lock to the directory
    1355     {
    1356       if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
    1357       {
    1358         r_read_fsm = READ_DIR_LOCK;
    1359       }
    1360 
    1361 #if DEBUG_MEMC_READ
    1362 if(m_debug_read_fsm)
    1363 std::cout << "  <MEMC " << name() << " READ_DIR_REQ> Requesting DIR lock " << std::endl;
    1364 #endif
    1365       break;
    1366     }
    1367 
    1368     ///////////////////
    1369     case READ_DIR_LOCK:
    1370       // check directory for hit / miss
     1748    case READ_DIR_LOCK:  // check directory for hit / miss
    13711749    {
    13721750      if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
     
    14001778        {
    14011779          // test if we need to register a new copy in the heap
    1402           if(entry.is_cnt || (entry.count == 0) || !cached_read)
     1780          if(entry.is_cnt or (entry.count == 0) or !cached_read)
    14031781          {
    14041782            r_read_fsm = READ_DIR_HIT;
     
    14151793
    14161794#if DEBUG_MEMC_READ
    1417 if(m_debug_read_fsm)
     1795if(m_debug)
    14181796{
    14191797std::cout << "  <MEMC " << name() << " READ_DIR_LOCK> Accessing directory: "
     
    15031881
    15041882#if DEBUG_MEMC_READ
    1505 if(m_debug_read_fsm)
     1883if(m_debug)
    15061884std::cout << "  <MEMC " << name() << " READ_DIR_HIT> Update directory entry:"
    15071885          << " addr = " << std::hex << m_cmd_read_addr_fifo.read()
     
    15391917
    15401918#if DEBUG_MEMC_READ
    1541 if(m_debug_read_fsm)
     1919if(m_debug)
    15421920std::cout << "  <MEMC " << name() << " READ_HEAP_REQ>"
    15431921          << " Requesting HEAP lock " << std::endl;
     
    15531931      {
    15541932        // enter counter mode when we reach the limit of copies or the heap is full
    1555         bool go_cnt = (r_read_count.read() >= m_max_copies) || m_heap.is_full();
     1933        bool go_cnt = (r_read_count.read() >= m_max_copies) or m_heap.is_full();
    15561934
    15571935        // read data in the cache
     
    16262004
    16272005#if DEBUG_MEMC_READ
    1628 if(m_debug_read_fsm)
     2006if(m_debug)
    16292007std::cout << "  <MEMC " << name() << " READ_HEAP_LOCK> Update directory:"
    16302008          << " tag = " << std::hex << entry.tag
     
    16702048
    16712049#if DEBUG_MEMC_READ
    1672 if(m_debug_read_fsm)
     2050if(m_debug)
    16732051std::cout << "  <MEMC " << name() << " READ_HEAP_WRITE> Add an entry in the heap:"
    16742052          << " owner_id = " << std::hex << heap_entry.owner.srcid
     
    17582136
    17592137#if DEBUG_MEMC_READ
    1760 if(m_debug_read_fsm)
     2138if(m_debug)
    17612139std::cout << "  <MEMC " << name() << " READ_RSP> Request TGT_RSP FSM to return data:"
    17622140          << " rsrcid = " << std::hex << m_cmd_read_srcid_fifo.read()
     
    17782156        bool        wok       = !m_trt.full(index);
    17792157
    1780         if(hit_read || !wok || hit_write)    // missing line already requested or no space
     2158        if(hit_read or !wok or hit_write)    // missing line already requested or no space
    17812159        {
    17822160          if(!wok)      m_cpt_trt_full++;
    1783           if(hit_read || hit_write)   m_cpt_trt_rb++;
     2161          if(hit_read or hit_write)   m_cpt_trt_rb++;
    17842162          r_read_fsm = READ_IDLE;
    17852163        }
     
    17922170
    17932171#if DEBUG_MEMC_READ
    1794 if(m_debug_read_fsm)
     2172if(m_debug)
    17952173std::cout << "  <MEMC " << name() << " READ_TRT_LOCK> Check TRT:"
    17962174          << " hit_read = " << hit_read
     
    18202198                              r_read_ll_key.read());
    18212199#if DEBUG_MEMC_READ
    1822 if(m_debug_read_fsm)
     2200if(m_debug)
    18232201std::cout << "  <MEMC " << name() << " READ_TRT_SET> Write in Transaction Table:"
    18242202          << " address = " << std::hex << m_cmd_read_addr_fifo.read()
    1825           << " / srcid = " << std::dec << m_cmd_read_srcid_fifo.read() << std::endl;
     2203          << " / srcid = " << std::hex << m_cmd_read_srcid_fifo.read() << std::endl;
    18262204#endif
    18272205        r_read_fsm = READ_TRT_REQ;
     
    18422220
    18432221#if DEBUG_MEMC_READ
    1844 if(m_debug_read_fsm)
     2222if(m_debug)
    18452223std::cout << "  <MEMC " << name() << " READ_TRT_REQ> Request GET transaction for address "
    18462224          << std::hex << m_cmd_read_addr_fifo.read() << std::endl;
     
    18842262  switch(r_write_fsm.read())
    18852263  {
    1886       ////////////////
     2264    ////////////////
    18872265    case WRITE_IDLE:  // copy first word of a write burst in local buffer
    18882266    {
     
    19172295        }
    19182296
    1919         if (m_cmd_write_eop_fifo.read() || ((m_cmd_write_pktid_fifo.read() & 0x7) == TYPE_SC))
     2297        if (m_cmd_write_eop_fifo.read() or ((m_cmd_write_pktid_fifo.read() & 0x7) == TYPE_SC))
    19202298        {
    19212299          r_write_fsm = WRITE_DIR_REQ;
     
    19272305
    19282306#if DEBUG_MEMC_WRITE
    1929         if(m_debug_write_fsm)
     2307        if(m_debug)
    19302308        {
    19312309          std::cout << "  <MEMC " << name() << " WRITE_IDLE> Write request "
     
    19462324
    19472325#if DEBUG_MEMC_WRITE
    1948         if(m_debug_write_fsm)
     2326        if(m_debug)
    19492327        {
    19502328          std::cout << "  <MEMC " << name()
     
    19992377          if(not m_cmd_write_addr_fifo.rok()) break;
    20002378
    2001           assert(m_cmd_write_eop_fifo.read() &&
     2379          assert(m_cmd_write_eop_fifo.read() and
    20022380                 "Error in VCI_MEM_CACHE : "
    20032381                 "invalid packet format for SC command");
     
    20302408
    20312409#if DEBUG_MEMC_WRITE
    2032       if(m_debug_write_fsm)
     2410      if(m_debug)
    20332411      {
    20342412        std::cout
     
    20652443          r_write_way        = way;
    20662444
    2067           if(entry.is_cnt && entry.count)
     2445          if(entry.is_cnt and entry.count)
    20682446          {
    20692447            r_write_fsm = WRITE_DIR_READ;
     
    20802458
    20812459#if DEBUG_MEMC_WRITE
    2082         if(m_debug_write_fsm)
     2460        if(m_debug)
    20832461        {
    20842462          std::cout << "  <MEMC " << name() << " WRITE_DIR_LOCK> Check the directory: "
     
    21302508
    21312509#if DEBUG_MEMC_WRITE
    2132       if(m_debug_write_fsm)
     2510      if(m_debug)
    21332511      {
    21342512        std::cout << "  <MEMC " << name() << " WRITE_DIR_READ> Read the cache to complete local buffer" << std::endl;
     
    21722550      // no_update is true when there is no need for coherence transaction
    21732551      // (tests for sc requests)
    2174       bool no_update = ((r_write_count.read() ==0) || (owner && (r_write_count.read() ==1) && (r_write_pktid.read() != TYPE_SC)));
     2552      bool no_update = ( (r_write_count.read() == 0) or
     2553                         (owner and (r_write_count.read() ==1) and (r_write_pktid.read() != TYPE_SC)));
    21752554
    21762555      // write data in the cache if no coherence transaction
     
    22052584      // coherence update required
    22062585      {
    2207         if(!r_write_to_cc_send_multi_req.read() &&
     2586        if(!r_write_to_cc_send_multi_req.read() and
    22082587           !r_write_to_cc_send_brdcast_req.read())
    22092588        {
     
    22172596
    22182597#if DEBUG_MEMC_WRITE
    2219       if(m_debug_write_fsm)
    2220       {
    2221         if(no_update)
    2222         {
    2223           std::cout << "  <MEMC " << name() << " WRITE_DIR_HIT> Write into cache / No coherence transaction"
    2224                     << std::endl;
    2225         }
    2226         else
    2227         {
    2228           std::cout << "  <MEMC " << name() << " WRITE_DIR_HIT> Coherence update required:"
    2229                     << " is_cnt = " << r_write_is_cnt.read()
    2230                     << " nb_copies = " << std::dec << r_write_count.read() << std::endl;
    2231           if(owner)
    2232             std::cout << "       ... but the first copy is the writer" << std::endl;
    2233         }
    2234       }
     2598if(m_debug)
     2599{
     2600    if(no_update)
     2601    {
     2602        std::cout << "  <MEMC " << name()
     2603                  << " WRITE_DIR_HIT> Write into cache / No coherence transaction"
     2604                  << std::endl;
     2605    }
     2606    else
     2607    {
     2608        std::cout << "  <MEMC " << name() << " WRITE_DIR_HIT> Coherence update required:"
     2609                  << " is_cnt = " << r_write_is_cnt.read()
     2610                  << " nb_copies = " << std::dec << r_write_count.read() << std::endl;
     2611        if(owner) std::cout << "       ... but the first copy is the writer" << std::endl;
     2612    }
     2613}
    22352614#endif
    22362615      break;
     
    22532632
    22542633        wok = m_upt.set(true,  // it's an update transaction
    2255                                false,    // it's not a broadcast
    2256                                true,     // it needs a response
    2257                                srcid,
    2258                                trdid,
    2259                                pktid,
    2260                                nline,
    2261                                nb_copies,
    2262                                index);
     2634                        false,    // it's not a broadcast
     2635                        true,     // response required
     2636                        false,    // no acknowledge required
     2637                        srcid,   
     2638                        trdid,
     2639                        pktid,
     2640                        nline,
     2641                        nb_copies,
     2642                        index);
    22632643        if(wok)       // write data in cache
    22642644        {
     
    22822662
    22832663#if DEBUG_MEMC_WRITE
    2284         if(m_debug_write_fsm)
    2285         {
    2286           if(wok)
    2287           {
    2288             std::cout << "  <MEMC " << name() << " WRITE_UPT_LOCK> Register the multicast update in UPT / "
    2289                       << " nb_copies = " << r_write_count.read() << std::endl;
    2290           }
    2291         }
     2664if(m_debug)
     2665{
     2666    if(wok)
     2667    {
     2668        std::cout << "  <MEMC " << name()
     2669                  << " WRITE_UPT_LOCK> Register the multicast update in UPT / "
     2670                  << " nb_copies = " << r_write_count.read() << std::endl;
     2671    }
     2672}
    22922673#endif
    22932674        r_write_upt_index = index;
     
    23062687
    23072688#if DEBUG_MEMC_WRITE
    2308         if(m_debug_write_fsm)
    2309         {
    2310           std::cout << "  <MEMC " << name() << " WRITE_UPT_HEAP_LOCK> Get acces to the HEAP" << std::endl;
    2311         }
     2689if(m_debug)
     2690std::cout << "  <MEMC " << name()
     2691          << " WRITE_UPT_HEAP_LOCK> Get acces to the HEAP" << std::endl;
    23122692#endif
    23132693        r_write_fsm = WRITE_UPT_REQ;
     
    23172697
    23182698    //////////////////
    2319     case WRITE_UPT_REQ:
    2320     {
    2321       // prepare the coherence transaction for the CC_SEND FSM
    2322       // and write the first copy in the FIFO
    2323       // send the request if only one copy
    2324 
     2699    case WRITE_UPT_REQ:    // prepare the coherence transaction for the CC_SEND FSM
     2700                           // and write the first copy in the FIFO
     2701                           // send the request if only one copy
     2702    {
    23252703      assert(not r_write_to_cc_send_multi_req.read()   and
    23262704             not r_write_to_cc_send_brdcast_req.read() and
     
    23732751
    23742752#if DEBUG_MEMC_WRITE
    2375       if(m_debug_write_fsm)
     2753      if(m_debug)
    23762754      {
    23772755        std::cout
     
    24042782      bool dec_upt_counter;
    24052783
    2406       if(((entry.owner.srcid != r_write_srcid.read()) || (r_write_pktid.read() == TYPE_SC)) or
     2784      if(((entry.owner.srcid != r_write_srcid.read()) or (r_write_pktid.read() == TYPE_SC)) or
    24072785#if L1_MULTI_CACHE
    24082786          (entry.owner.cache_id != r_write_pktid.read()) or
     
    24192797
    24202798#if DEBUG_MEMC_WRITE
    2421         if(m_debug_write_fsm)
     2799        if(m_debug)
    24222800        {
    24232801          std::cout << "  <MEMC " << name() << " WRITE_UPT_NEXT> Post another request to CC_SEND FSM"
     
    24352813
    24362814#if DEBUG_MEMC_WRITE
    2437         if(m_debug_write_fsm)
     2815        if(m_debug)
    24382816        {
    24392817          std::cout << "  <MEMC " << name() << " WRITE_UPT_NEXT> Skip one entry in heap matching the writer"
     
    25332911          }
    25342912
    2535           if(m_cmd_write_eop_fifo.read() || ((m_cmd_write_pktid_fifo.read() & 0x7)  == TYPE_SC))
     2913          if(m_cmd_write_eop_fifo.read() or ((m_cmd_write_pktid_fifo.read() & 0x7)  == TYPE_SC))
    25362914          {
    25372915            r_write_fsm = WRITE_DIR_REQ;
     
    25482926
    25492927#if DEBUG_MEMC_WRITE
    2550 if(m_debug_write_fsm)
     2928if(m_debug)
    25512929{
    25522930    std::cout << "  <MEMC " << name() << " WRITE_RSP> Post a request to TGT_RSP FSM"
     
    25722950
    25732951#if DEBUG_MEMC_WRITE
    2574 if(m_debug_write_fsm)
     2952if(m_debug)
    25752953std::cout << "  <MEMC " << name() << " WRITE_MISS_TRT_LOCK> Check the TRT" << std::endl;
    25762954#endif
     
    25882966          m_cpt_write_miss++;
    25892967        }
    2590         else if(wok && !hit_write)      // set a new entry in TRT
     2968        else if(wok and !hit_write)      // set a new entry in TRT
    25912969        {
    25922970          r_write_trt_index = wok_index;
     
    26082986
    26092987#if DEBUG_MEMC_WRITE
    2610 if(m_debug_write_fsm)
     2988if(m_debug)
    26112989std::cout << "  <MEMC " << name() << " WRITE_WAIT> Releases the locks before retry" << std::endl;
    26122990#endif
     
    26433021
    26443022#if DEBUG_MEMC_WRITE
    2645 if(m_debug_write_fsm)
     3023if(m_debug)
    26463024std::cout << "  <MEMC " << name() << " WRITE_MISS_TRT_SET> Set a new entry in TRT" << std::endl;
    26473025#endif
     
    26703048
    26713049#if DEBUG_MEMC_WRITE
    2672 if(m_debug_write_fsm)
     3050if(m_debug)
    26733051std::cout << "  <MEMC " << name() << " WRITE_MISS_TRT_DATA> Modify an existing entry in TRT" << std::endl;
    26743052#endif
     
    26893067
    26903068#if DEBUG_MEMC_WRITE
    2691 if(m_debug_write_fsm)
     3069if(m_debug)
    26923070std::cout << "  <MEMC " << name() << " WRITE_MISS_XRAM_REQ> Post a GET request to the IXR_CMD FSM" << std::endl;
    26933071#endif
     
    27143092
    27153093#if DEBUG_MEMC_WRITE
    2716 if(m_debug_write_fsm)
     3094if(m_debug)
    27173095std::cout << "  <MEMC " << name() << " WRITE_BC_TRT_LOCK> Check TRT"
    27183096          << " : wok = " << wok << " / index = " << wok_index << std::endl;
     
    27353113        size_t      nb_copies = r_write_count.read();
    27363114
    2737         wok =m_upt.set(false,  // it's an inval transaction
    2738                               true,     // it's a broadcast
    2739                               true,     // it needs a response
    2740                               srcid,
    2741                               trdid,
    2742                               pktid,
    2743                               nline,
    2744                               nb_copies,
    2745                               index);
     3115        wok = m_upt.set(false,  // it's an inval transaction
     3116                        true,     // it's a broadcast
     3117                        true,     // response required
     3118                        false,    // no acknowledge required
     3119                        srcid,
     3120                        trdid,
     3121                        pktid,
     3122                        nline,
     3123                        nb_copies,
     3124                        index);
    27463125
    27473126#if DEBUG_MEMC_WRITE
    2748 if( m_debug_write_fsm and wok )
     3127if( m_debug and wok )
    27493128std::cout << "  <MEMC " << name() << " WRITE_BC_UPT_LOCK> Register broadcast inval in UPT"
    27503129          << " / nb_copies = " << r_write_count.read() << std::endl;
     
    27633142      // Register a put transaction to XRAM in TRT
    27643143      // and invalidate the line in directory
    2765       if((r_alloc_trt_fsm.read() != ALLOC_TRT_WRITE) ||
    2766           (r_alloc_upt_fsm.read() != ALLOC_UPT_WRITE) ||
     3144      if((r_alloc_trt_fsm.read() != ALLOC_TRT_WRITE) or
     3145          (r_alloc_upt_fsm.read() != ALLOC_UPT_WRITE) or
    27673146          (r_alloc_dir_fsm.read() != ALLOC_DIR_WRITE))
    27683147      {
     
    28053184
    28063185#if DEBUG_MEMC_WRITE
    2807 if(m_debug_write_fsm)
     3186if(m_debug)
    28083187std::cout << "  <MEMC " << name() << " WRITE_BC_DIR_INVAL> Invalidate the directory entry: @ = "
    28093188          << r_write_address.read() << " / register the put transaction in TRT:" << std::endl;
     
    28163195    case WRITE_BC_CC_SEND:    // Post a coherence broadcast request to CC_SEND FSM
    28173196    {
    2818       if(!r_write_to_cc_send_multi_req.read() && !r_write_to_cc_send_brdcast_req.read())
     3197      if(!r_write_to_cc_send_multi_req.read() and !r_write_to_cc_send_brdcast_req.read())
    28193198      {
    28203199        r_write_to_cc_send_multi_req   = false;
     
    28333212
    28343213#if DEBUG_MEMC_WRITE
    2835 if(m_debug_write_fsm)
    2836 {
    2837     std::cout << "  <MEMC " << name()
    2838               << " WRITE_BC_CC_SEND> Post a broadcast request to CC_SEND FSM" << std::endl;
    2839 }
     3214if(m_debug)
     3215std::cout << "  <MEMC " << name()
     3216          << " WRITE_BC_CC_SEND> Post a broadcast request to CC_SEND FSM" << std::endl;
    28403217#endif
    28413218      }
     
    28583235
    28593236#if DEBUG_MEMC_WRITE
    2860 if(m_debug_write_fsm)
    2861 {
    2862      std::cout << "  <MEMC " << name()
    2863                << " WRITE_BC_XRAM_REQ> Post a put request to IXR_CMD FSM" << std::endl;
    2864 }
     3237if(m_debug)
     3238std::cout << "  <MEMC " << name()
     3239          << " WRITE_BC_XRAM_REQ> Post a put request to IXR_CMD FSM" << std::endl;
    28653240#endif
    28663241      }
     
    29343309
    29353310#if DEBUG_MEMC_IXR_CMD
    2936 if(m_debug_ixr_cmd_fsm)
     3311if(m_debug)
    29373312std::cout << "  <MEMC " << name() << " IXR_CMD_READ>"
    29383313          << " Send a get request to xram / address = " << std::hex
     
    29613336
    29623337#if DEBUG_MEMC_IXR_CMD
    2963 if(m_debug_ixr_cmd_fsm)
     3338if(m_debug)
    29643339std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE>"
    29653340          << " Send a put request to xram / address = " << std::hex
     
    29743349
    29753350#if DEBUG_MEMC_IXR_CMD
    2976 if(m_debug_ixr_cmd_fsm)
     3351if(m_debug)
    29773352std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE>"
    29783353          << " Send a get request to xram / address = " << std::hex
     
    30023377
    30033378#if DEBUG_MEMC_IXR_CMD
    3004 if(m_debug_ixr_cmd_fsm)
     3379if(m_debug)
    30053380std::cout << "  <MEMC " << name() << " IXR_CMD_CAS>"
    30063381          << " Send a put request to xram / address = " << std::hex
     
    30153390
    30163391#if DEBUG_MEMC_IXR_CMD
    3017 if(m_debug_ixr_cmd_fsm)
     3392if(m_debug)
    30183393std::cout << "  <MEMC " << name() << " IXR_CMD_CAS>"
    30193394          << " Send a get request to xram / address = " << std::hex
     
    30413416
    30423417#if DEBUG_MEMC_IXR_CMD
    3043 if(m_debug_ixr_cmd_fsm)
     3418if(m_debug)
    30443419std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM>"
    30453420          << " Send a put request to xram / address = " << std::hex
     
    30813456        r_ixr_rsp_cpt   = 0;
    30823457        r_ixr_rsp_trt_index = p_vci_ixr.rtrdid.read();
    3083         if(p_vci_ixr.reop.read() && !(p_vci_ixr.rerror.read() &0x1))   // PUT transaction
     3458        if(p_vci_ixr.reop.read() and !(p_vci_ixr.rerror.read() &0x1))   // PUT transaction
    30843459        {
    30853460          r_ixr_rsp_fsm = IXR_RSP_ACK;
    30863461
    30873462#if DEBUG_MEMC_IXR_RSP
    3088 if(m_debug_ixr_rsp_fsm)
    3089 {
    3090     std::cout << "  <MEMC " << name()
    3091               << " IXR_RSP_IDLE> Response from XRAM to a put transaction" << std::endl;
    3092 }
     3463if(m_debug)
     3464std::cout << "  <MEMC " << name()
     3465          << " IXR_RSP_IDLE> Response from XRAM to a put transaction" << std::endl;
    30933466#endif
    30943467        }
     
    30983471
    30993472#if DEBUG_MEMC_IXR_RSP
    3100 if(m_debug_ixr_rsp_fsm)
    3101 {
    3102     std::cout << "  <MEMC " << name()
    3103               << " IXR_RSP_IDLE> Response from XRAM to a get transaction" << std::endl;
    3104 }
     3473if(m_debug)
     3474std::cout << "  <MEMC " << name()
     3475          << " IXR_RSP_IDLE> Response from XRAM to a get transaction" << std::endl;
    31053476#endif
    31063477        }
     
    31143485
    31153486#if DEBUG_MEMC_IXR_RSP
    3116 if(m_debug_ixr_rsp_fsm)
    3117 {
    3118     std::cout << "  <MEMC " << name() << " IXR_RSP_ACK>" << std::endl;
    3119 }
     3487if(m_debug)
     3488std::cout << "  <MEMC " << name() << " IXR_RSP_ACK>" << std::endl;
    31203489#endif
    31213490      break;
     
    31303499
    31313500#if DEBUG_MEMC_IXR_RSP
    3132 if(m_debug_ixr_rsp_fsm)
    3133 {
    3134           std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_ERASE> Erase TRT entry "
    3135                     << r_ixr_rsp_trt_index.read() << std::endl;
    3136         }
     3501if(m_debug)
     3502std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_ERASE> Erase TRT entry "
     3503          << r_ixr_rsp_trt_index.read() << std::endl;
    31373504#endif
    31383505      }
     
    31423509    case IXR_RSP_TRT_READ:    // write a 64 bits data in the TRT
    31433510    {
    3144       if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) &&  p_vci_ixr.rspval)
     3511      if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and  p_vci_ixr.rspval)
    31453512      {
    31463513        size_t      index    = r_ixr_rsp_trt_index.read();
     
    31493516        bool        error    = ((p_vci_ixr.rerror.read() & 0x1) == 1);
    31503517
    3151         assert(((eop == (r_ixr_rsp_cpt.read() == (m_words-2))) || p_vci_ixr.rerror.read())
     3518        assert(((eop == (r_ixr_rsp_cpt.read() == (m_words-2))) or p_vci_ixr.rerror.read())
    31523519               and "Error in VCI_MEM_CACHE : invalid length for a response from XRAM");
    31533520
     
    31663533
    31673534#if DEBUG_MEMC_IXR_RSP
    3168 if(m_debug_ixr_rsp_fsm)
    3169 {
    3170     std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_READ> Writing a word in TRT : "
    3171               << " index = " << std::dec << index
    3172               << " / word = " << r_ixr_rsp_cpt.read()
    3173               << " / data = " << std::hex << data << std::endl;
    3174 }
     3535if(m_debug)
     3536std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_READ> Writing a word in TRT : "
     3537          << " index = " << std::dec << index
     3538          << " / word = " << r_ixr_rsp_cpt.read()
     3539          << " / data = " << std::hex << data << std::endl;
    31753540#endif
    31763541      }
     
    32193584
    32203585#if DEBUG_MEMC_XRAM_RSP
    3221 if(m_debug_xram_rsp_fsm)
     3586if(m_debug)
    32223587std::cout << "  <MEMC " << name() << " XRAM_RSP_IDLE>"
    32233588          << " Available cache line in TRT:"
     
    32333598                            // Copy the TRT entry in a local buffer
    32343599    {
    3235       if((r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) &&
     3600      if((r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
    32363601          (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP))
    32373602      {
     
    32423607        r_xram_rsp_fsm = XRAM_RSP_TRT_COPY;
    32433608
    3244 //        TransactionTabEntry trt_entry(m_trt.read(index));
    3245 //        r_xram_rsp_trt_buf.copy(trt_entry);           // TRT entry local buffer
    3246 
    32473609#if DEBUG_MEMC_XRAM_RSP
    3248 if(m_debug_xram_rsp_fsm)
     3610if(m_debug)
    32493611std::cout << "  <MEMC " << name() << " XRAM_RSP_DIR_LOCK>"
    32503612          << " Get access to DIR and TRT" << std::endl;
     
    32663628        DirectoryEntry victim(m_cache_directory.select(set, way));
    32673629
    3268         bool inval = (victim.count && victim.valid) ;
     3630        bool inval = (victim.count and victim.valid) ;
    32693631
    32703632        // copy the victim line in a local buffer
     
    32963658
    32973659#if DEBUG_MEMC_XRAM_RSP
    3298 if(m_debug_xram_rsp_fsm)
     3660if(m_debug)
    32993661std::cout << "  <MEMC " << name() << " XRAM_RSP_TRT_COPY>"
    33003662          << " Select a slot: "
     
    33233685
    33243686#if DEBUG_MEMC_XRAM_RSP
    3325 if(m_debug_xram_rsp_fsm)
     3687if(m_debug)
    33263688std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
    33273689          << " Get acces to UPT, but line invalidation registered"
     
    33313693
    33323694        }
    3333         else if(m_upt.is_full() && r_xram_rsp_victim_inval.read()) // UPT full
     3695        else if(m_upt.is_full() and r_xram_rsp_victim_inval.read()) // UPT full
    33343696        {
    33353697          r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    33363698
    33373699#if DEBUG_MEMC_XRAM_RSP
    3338 if(m_debug_xram_rsp_fsm)
     3700if(m_debug)
    33393701std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
    33403702          << " Get acces to UPT, but inval required and UPT full" << std::endl;
     
    33463708
    33473709#if DEBUG_MEMC_XRAM_RSP
    3348 if(m_debug_xram_rsp_fsm)
     3710if(m_debug)
    33493711std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
    33503712          << " Get acces to UPT" << std::endl;
     
    33593721
    33603722#if DEBUG_MEMC_XRAM_RSP
    3361 if(m_debug_xram_rsp_fsm)
     3723if(m_debug)
    33623724std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_WAIT>"
    33633725          << " Release all locks and retry" << std::endl;
     
    33733735      // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
    33743736      // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
    3375       bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) && r_xram_rsp_trt_buf.proc_read;
     3737      bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) and r_xram_rsp_trt_buf.proc_read;
    33763738
    33773739      // check if this is a cached read, this means pktid is either
    33783740      // TYPE_READ_DATA_MISS 0bX001 with TSAR encoding
    33793741      // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
    3380       bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) && r_xram_rsp_trt_buf.proc_read;
     3742      bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) and r_xram_rsp_trt_buf.proc_read;
    33813743
    33823744      bool dirty = false;
     
    33893751        m_cache_data.write(way, set, word, r_xram_rsp_trt_buf.wdata[word]);
    33903752
    3391         dirty = dirty || (r_xram_rsp_trt_buf.wdata_be[word] != 0);
     3753        dirty = dirty or (r_xram_rsp_trt_buf.wdata_be[word] != 0);
    33923754
    33933755        if(m_monitor_ok)
     
    34353797        bool   wok = m_upt.set(false,      // it's an inval transaction
    34363798                               broadcast,  // set broadcast bit
    3437                                false,      // it does not need a response
     3799                               false,      // no response required
     3800                               false,      // no acknowledge required
    34383801                               0,          // srcid
    34393802                               0,          // trdid
     
    34543817
    34553818#if DEBUG_MEMC_XRAM_RSP
    3456 if(m_debug_xram_rsp_fsm)
     3819if(m_debug)
    34573820{
    34583821std::cout << "  <MEMC " << name() << " XRAM_RSP_DIR_UPDT>"
     
    35003863
    35013864#if DEBUG_MEMC_XRAM_RSP
    3502 if(m_debug_xram_rsp_fsm)
     3865if(m_debug)
    35033866std::cout << "  <MEMC " << name() << " XRAM_RSP_TRT_DIRTY>"
    35043867          << " Set TRT entry for the put transaction"
     
    35343897
    35353898#if DEBUG_MEMC_XRAM_RSP
    3536 if(m_debug_xram_rsp_fsm)
     3899if(m_debug)
    35373900std::cout << "  <MEMC " << name() << " XRAM_RSP_DIR_RSP>"
    35383901          << " Request the TGT_RSP FSM to return data:"
     
    35473910    case XRAM_RSP_INVAL:  // send invalidate request to CC_SEND FSM
    35483911    {
    3549       if(!r_xram_rsp_to_cc_send_multi_req.read() &&
     3912      if(!r_xram_rsp_to_cc_send_multi_req.read() and
    35503913          !r_xram_rsp_to_cc_send_brdcast_req.read())
    35513914      {
    35523915        bool multi_req = !r_xram_rsp_victim_is_cnt.read();
    3553         bool last_multi_req  = multi_req && (r_xram_rsp_victim_count.read() == 1);
    3554         bool not_last_multi_req = multi_req && (r_xram_rsp_victim_count.read() != 1);
     3916        bool last_multi_req  = multi_req and (r_xram_rsp_victim_count.read() == 1);
     3917        bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1);
    35553918
    35563919        r_xram_rsp_to_cc_send_multi_req    = last_multi_req;
     
    35713934
    35723935#if DEBUG_MEMC_XRAM_RSP
    3573 if(m_debug_xram_rsp_fsm)
     3936if(m_debug)
    35743937std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL>"
    35753938          << " Send an inval request to CC_SEND FSM"
     
    35933956        m_cpt_write_dirty++;
    35943957
    3595         bool multi_req = !r_xram_rsp_victim_is_cnt.read() && r_xram_rsp_victim_inval.read();
    3596         bool not_last_multi_req = multi_req && (r_xram_rsp_victim_count.read() != 1);
     3958        bool multi_req = !r_xram_rsp_victim_is_cnt.read() and r_xram_rsp_victim_inval.read();
     3959        bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1);
    35973960
    35983961        if(not_last_multi_req)   r_xram_rsp_fsm = XRAM_RSP_HEAP_REQ;
     
    36003963
    36013964#if DEBUG_MEMC_XRAM_RSP
    3602 if(m_debug_xram_rsp_fsm)
     3965if(m_debug)
    36033966std::cout << "  <MEMC " << name() << " XRAM_RSP_WRITE_DIRTY>"
    36043967          << " Send the put request to IXR_CMD FSM"
     
    36173980
    36183981#if DEBUG_MEMC_XRAM_RSP
    3619 if(m_debug_xram_rsp_fsm)
     3982if(m_debug)
    36203983std::cout << "  <MEMC " << name() << " XRAM_RSP_HEAP_REQ>"
    36213984          << " Requesting HEAP lock" << std::endl;
     
    36554018
    36564019#if DEBUG_MEMC_XRAM_RSP
    3657 if(m_debug_xram_rsp_fsm)
     4020if(m_debug)
    36584021std::cout << "  <MEMC " << name() << " XRAM_RSP_HEAP_ERASE>"
    36594022          << " Erase copy:"
    3660           << " srcid = " << std::dec << entry.owner.srcid
     4023          << " srcid = " << std::hex << entry.owner.srcid
    36614024          << " / inst = " << std::dec << entry.owner.inst << std::endl;
    36624025#endif
     
    36974060
    36984061#if DEBUG_MEMC_XRAM_RSP
    3699 if(m_debug_xram_rsp_fsm)
     4062if(m_debug)
    37004063std::cout << "  <MEMC " << name() << " XRAM_RSP_HEAP_LAST>"
    37014064          << " Heap housekeeping" << std::endl;
     
    37134076
    37144077#if DEBUG_MEMC_XRAM_RSP
    3715 if(m_debug_xram_rsp_fsm)
     4078if(m_debug)
    37164079std::cout << "  <MEMC " << name() << " XRAM_RSP_ERROR_ERASE>"
    37174080          << " Error reported by XRAM / erase the TRT entry" << std::endl;
     
    37394102
    37404103#if DEBUG_MEMC_XRAM_RSP
    3741 if(m_debug_xram_rsp_fsm)
    3742     std::cout << "  <MEMC " << name()
    3743               << " XRAM_RSP_ERROR_RSP> Request a response error to TGT_RSP FSM:"
    3744               << " srcid = " << std::dec << r_xram_rsp_trt_buf.srcid << std::endl;
     4104if(m_debug)
     4105std::cout << "  <MEMC " << name()
     4106          << " XRAM_RSP_ERROR_RSP> Request a response error to TGT_RSP FSM:"
     4107          << " srcid = " << std::dec << r_xram_rsp_trt_buf.srcid << std::endl;
    37454108#endif
    37464109      }
     
    38034166
    38044167#if DEBUG_MEMC_CLEANUP
    3805       if(m_debug_cleanup_fsm)
    3806       {
    3807         std::cout
    3808             << "  <MEMC "         << name()
    3809             << " CLEANUP_IDLE> Cleanup request:" << std::hex
    3810             << " / owner_id = "   << srcid
    3811             << " / owner_ins = "  << (type == DspinDhccpParam::TYPE_CLEANUP_INST)
    3812             << std::endl;
    3813       }
     4168if(m_debug)
     4169std::cout << "  <MEMC "         << name()
     4170          << " CLEANUP_IDLE> Cleanup request:" << std::hex
     4171          << " / owner_id = "   << srcid
     4172          << " / owner_ins = "  << (type == DspinDhccpParam::TYPE_CLEANUP_INST) << std::endl;
    38144173#endif
    38154174      break;
     
    38314190
    38324191#if DEBUG_MEMC_CLEANUP
    3833       if(m_debug_cleanup_fsm)
    3834       {
    3835         std::cout
    3836             << "  <MEMC "         << name()
    3837             << " CLEANUP_GET_NLINE> Cleanup request:"
    3838             << std::hex
    3839             << " / address = "    << nline * m_words * 4
    3840             << std::endl;
    3841       }
     4192if(m_debug)
     4193std::cout << "  <MEMC "         << name()
     4194          << " CLEANUP_GET_NLINE> Cleanup request:"
     4195          << " / address = " << std::hex << nline * m_words * 4 << std::endl;
    38424196#endif
    38434197      break;
     
    38454199
    38464200    /////////////////////
    3847     case CLEANUP_DIR_REQ:
    3848     {
    3849       // Get the lock to the directory
     4201    case CLEANUP_DIR_REQ:   // Get the lock to the directory
     4202    {
    38504203      if(r_alloc_dir_fsm.read() != ALLOC_DIR_CLEANUP) break;
    38514204
     
    38534206
    38544207#if DEBUG_MEMC_CLEANUP
    3855       if(m_debug_cleanup_fsm)
    3856       {
    3857         std::cout
    3858             << "  <MEMC " << name() << " CLEANUP_DIR_REQ> Requesting DIR lock "
    3859             << std::endl;
    3860       }
     4208if(m_debug)
     4209std::cout << "  <MEMC " << name() << " CLEANUP_DIR_REQ> Requesting DIR lock" << std::endl;
    38614210#endif
    38624211      break;
     
    38954244#endif
    38964245
    3897       // hit :
    3898       // the copy must be cleared
    3899       if(entry.valid)
     4246      if(entry.valid)      // hit : the copy must be cleared
    39004247      {
    39014248        assert(
    3902             (entry.count > 0) &&
     4249            (entry.count > 0) and
    39034250            "VCI MEM CACHE ERROR: "
    39044251            "In CLEANUP_DIR_LOCK, CLEANUP command on a valid entry "
     
    39064253
    39074254        // no access to the heap
    3908         if((entry.count == 1) || (entry.is_cnt))
     4255        if((entry.count == 1) or (entry.is_cnt))
    39094256        {
    39104257          r_cleanup_fsm = CLEANUP_DIR_WRITE;
     
    39164263        }
    39174264      }
    3918       // miss :
    3919       // we must check the update table for a pending
    3920       // invalidation transaction
    3921       else
     4265      else                // miss : check UPT for a pending invalidation transaction
    39224266      {
    39234267        r_cleanup_fsm = CLEANUP_UPT_LOCK;
     
    39254269
    39264270#if DEBUG_MEMC_CLEANUP
    3927       if(m_debug_cleanup_fsm)
     4271      if(m_debug)
    39284272      {
    39294273        std::cout
     
    39684312
    39694313      bool   match_inst  = (r_cleanup_copy_inst.read() == r_cleanup_inst.read());
    3970       bool   match       = match_srcid && match_inst;
     4314      bool   match       = match_srcid and match_inst;
    39714315
    39724316      if(not r_cleanup_is_cnt.read() and not match)
     
    39994343      m_cache_directory.write(set, way, entry);
    40004344
    4001       r_cleanup_fsm = CLEANUP_SEND_ACK;
     4345      r_cleanup_fsm = CLEANUP_SEND_CLACK;
    40024346
    40034347#if DEBUG_MEMC_CLEANUP
    4004       if(m_debug_cleanup_fsm)
     4348      if(m_debug)
    40054349      {
    40064350        std::cout
     
    40294373
    40304374#if DEBUG_MEMC_CLEANUP
    4031       if(m_debug_cleanup_fsm)
     4375      if(m_debug)
    40324376      {
    40334377        std::cout
     
    41824526
    41834527#if DEBUG_MEMC_CLEANUP
    4184       if(m_debug_cleanup_fsm)
     4528      if(m_debug)
    41854529      {
    41864530        std::cout
     
    42204564      bool match_heap_srcid = (heap_entry.owner.srcid == r_cleanup_srcid.read());
    42214565      bool match_heap_inst  = (heap_entry.owner.inst  == r_cleanup_inst.read());
    4222       bool match_heap       = match_heap_srcid && match_heap_inst;
     4566      bool match_heap       = match_heap_srcid and match_heap_inst;
    42234567
    42244568#if L1_MULTI_CACHE
     
    42604604
    42614605#if DEBUG_MEMC_CLEANUP
    4262       if(m_debug_cleanup_fsm)
     4606      if(m_debug)
    42634607      {
    42644608        if(not match_heap)
     
    42894633      break;
    42904634    }
    4291 
    4292     case CLEANUP_HEAP_CLEAN:
    4293     {
    4294       // remove a copy in the linked list
     4635    ////////////////////////
     4636    case CLEANUP_HEAP_CLEAN:    // remove a copy in the linked list
     4637    {
    42954638      if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    42964639      {
     
    43294672
    43304673#if DEBUG_MEMC_CLEANUP
    4331       if(m_debug_cleanup_fsm)
    4332       {
    4333         std::cout
    4334             << "  <MEMC " << name()
    4335             << " CLEANUP_HEAP_SEARCH> Remove the copy in the linked list"
    4336             << std::endl;
    4337       }
    4338 #endif
    4339       break;
    4340     }
    4341 
    4342     case CLEANUP_HEAP_FREE:
    4343     {
    4344       // The heap entry pointed by r_cleanup_next_ptr is freed
    4345       // and becomes the head of the list of free entries
     4674if(m_debug)
     4675std::cout << "  <MEMC " << name() << " CLEANUP_HEAP_SEARCH>"
     4676          << " Remove the copy in the linked list" << std::endl;
     4677#endif
     4678      break;
     4679    }
     4680    ///////////////////////
     4681    case CLEANUP_HEAP_FREE:   // The heap entry pointed by r_cleanup_next_ptr is freed
     4682                              // and becomes the head of the list of free entries
     4683    {
    43464684      if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    43474685      {
     
    43754713      m_heap.unset_full();
    43764714
    4377       r_cleanup_fsm = CLEANUP_SEND_ACK;
     4715      r_cleanup_fsm = CLEANUP_SEND_CLACK;
    43784716
    43794717#if DEBUG_MEMC_CLEANUP
    4380       if(m_debug_cleanup_fsm)
    4381       {
    4382         std::cout
    4383             << "  <MEMC " << name()
    4384             << " CLEANUP_HEAP_SEARCH> Update the list of free entries"
    4385             << std::endl;
    4386       }
    4387 #endif
    4388       break;
    4389     }
    4390 
    4391     case CLEANUP_UPT_LOCK:
    4392     {
    4393       // search pending invalidate transaction matching the Cleanup NLINE in the UPDATE TABLE
    4394       // get the lock in the UPDATE_TABLE
     4718if(m_debug)
     4719std::cout << "  <MEMC " << name() << " CLEANUP_HEAP_FREE>"
     4720          << " Update the list of free entries" << std::endl;
     4721#endif
     4722      break;
     4723    }
     4724    //////////////////////
     4725    case CLEANUP_UPT_LOCK:   // get the lock protecting the UPT to search a pending
     4726                             // invalidate transaction matching the cleanup
     4727    {
    43954728      if(r_alloc_upt_fsm.read() != ALLOC_UPT_CLEANUP) break;
    43964729
     
    44004733      match_inval = m_upt.search_inval(r_cleanup_nline.read(), index);
    44014734
    4402       // no pending inval
    4403       if(not match_inval)
    4404       {
    4405         r_cleanup_fsm = CLEANUP_SEND_ACK;
     4735      if ( not match_inval )     // no pending inval
     4736      {
     4737          r_cleanup_fsm = CLEANUP_SEND_CLACK;
    44064738
    44074739#if DEBUG_MEMC_CLEANUP
    4408         if(m_debug_cleanup_fsm)
    4409         {
    4410           std::cout
    4411               << "  <MEMC " << name()
    4412               << " CLEANUP_UPT_LOCK> Unexpected cleanup"
    4413               << " with no corresponding UPT entry:"
    4414               << " address = " << std::hex
    4415               << (r_cleanup_nline.read() *4*m_words)
    4416               << std::endl;
    4417         }
    4418 #endif
    4419         break;
     4740if(m_debug)
     4741std::cout << "  <MEMC " << name()
     4742          << " CLEANUP_UPT_LOCK> Unexpected cleanup"
     4743          << " with no corresponding UPT entry:"
     4744          << " address = " << std::hex
     4745          << (r_cleanup_nline.read() *4*m_words)
     4746          << std::endl;
     4747#endif
     4748          break;
    44204749      }
    44214750
    44224751      // pending inval
    4423       r_cleanup_write_srcid    = m_upt.srcid(index);
    4424       r_cleanup_write_trdid    = m_upt.trdid(index);
    4425       r_cleanup_write_pktid    = m_upt.pktid(index);
    4426       r_cleanup_write_need_rsp = m_upt.need_rsp(index);
    4427       r_cleanup_index          = index;
     4752      r_cleanup_write_srcid = m_upt.srcid(index);
     4753      r_cleanup_write_trdid = m_upt.trdid(index);
     4754      r_cleanup_write_pktid = m_upt.pktid(index);
     4755      r_cleanup_need_rsp    = m_upt.need_rsp(index);
     4756      r_cleanup_need_ack    = m_upt.need_ack(index);
     4757      r_cleanup_index       = index;
    44284758
    44294759      r_cleanup_fsm         = CLEANUP_UPT_DECREMENT;
    44304760
    44314761#if DEBUG_MEMC_CLEANUP
    4432       if(m_debug_cleanup_fsm)
    4433       {
    4434         std::cout
    4435             << "  <MEMC " << name()
    4436             << " CLEANUP_UPT_LOCK> Cleanup matching pending"
    4437             << " invalidate transaction on UPT:"
    4438             << std::hex
    4439             << " address = "   << r_cleanup_nline.read() * m_words * 4
    4440             << " upt_entry = " << index
    4441             << std::endl;
    4442       }
    4443 #endif
    4444       break;
    4445     }
    4446 
    4447     case CLEANUP_UPT_DECREMENT:
    4448     {
    4449       // decrement response counter in UPT matching entry
     4762if(m_debug)
     4763std::cout << "  <MEMC " << name()
     4764          << " CLEANUP_UPT_LOCK> Cleanup matching pending"
     4765          << " invalidate transaction on UPT:"
     4766          << " address = " << std::hex << r_cleanup_nline.read() * m_words * 4
     4767          << " / upt_entry = " << index << std::endl;
     4768#endif
     4769      break;
     4770    }
     4771    ///////////////////////////
     4772    case CLEANUP_UPT_DECREMENT:   // decrement response counter in UPT matching entry
     4773    {
    44504774      if(r_alloc_upt_fsm.read() != ALLOC_UPT_CLEANUP)
    44514775      {
     
    44624786      m_upt.decrement(r_cleanup_index.read(), count);
    44634787
    4464       // invalidation transaction finished
    4465       // (all acknowledgements received)
    4466       if(count == 0)
     4788      if(count == 0)   // multi inval transaction completed
    44674789      {
    44684790        r_cleanup_fsm = CLEANUP_UPT_CLEAR;
    44694791      }
    4470       // invalidation transaction not finished
    4471       else
    4472       {
    4473         r_cleanup_fsm = CLEANUP_SEND_ACK ;
     4792      else             // multi inval transaction not completed
     4793      {
     4794        r_cleanup_fsm = CLEANUP_SEND_CLACK ;
    44744795      }
    44754796
    44764797#if DEBUG_MEMC_CLEANUP
    4477       if(m_debug_cleanup_fsm)
    4478       {
    4479         std::cout
    4480             << "  <MEMC "      << name()
    4481             << " CLEANUP_UPT_DECREMENT> Decrement response counter in UPT:"
     4798if(m_debug)
     4799std::cout << "  <MEMC " << name() << " CLEANUP_UPT_DECREMENT>"
     4800          << " Decrement response counter in UPT:"
    44824801            << " UPT_index = " << r_cleanup_index.read()
    4483             << " rsp_count = " << count
    4484             << std::endl;
    4485       }
    4486 #endif
    4487       break;
    4488     }
    4489 
    4490     case CLEANUP_UPT_CLEAR:
    4491     {
    4492       // Clear UPT entry of finished invalidation transaction
     4802            << " / rsp_count = " << count << std::endl;
     4803#endif
     4804      break;
     4805    }
     4806    ///////////////////////
     4807    case CLEANUP_UPT_CLEAR:    // Clear UPT entry
     4808    {
    44934809      if(r_alloc_upt_fsm.read() != ALLOC_UPT_CLEANUP)
    44944810      {
     
    45044820      m_upt.clear(r_cleanup_index.read());
    45054821
    4506       if(r_cleanup_write_need_rsp.read())
    4507       {
    4508         r_cleanup_fsm = CLEANUP_WRITE_RSP;
    4509       }
    4510       else
    4511       {
    4512         r_cleanup_fsm = CLEANUP_SEND_ACK;
    4513       }
     4822      if      ( r_cleanup_need_rsp.read() ) r_cleanup_fsm = CLEANUP_WRITE_RSP;
     4823      else if ( r_cleanup_need_ack.read() ) r_cleanup_fsm = CLEANUP_CONFIG_ACK;
     4824      else                                  r_cleanup_fsm = CLEANUP_SEND_CLACK;
    45144825
    45154826#if DEBUG_MEMC_CLEANUP
    4516       if(m_debug_cleanup_fsm)
    4517       {
    4518         std::cout
    4519             << "  <MEMC "      << name()
    4520             << " CLEANUP_UPT_CLEAR> Clear entry in UPT:"
    4521             << " UPT_index = " << r_cleanup_index.read()
    4522             << std::endl;
    4523       }
    4524 #endif
    4525       break;
    4526     }
    4527 
    4528     case CLEANUP_WRITE_RSP:
    4529     {
    4530       // response to a previous write on the direct network
    4531       // wait if pending request to the TGT_RSP FSM
     4827if(m_debug)
     4828std::cout << "  <MEMC "      << name()
     4829          << " CLEANUP_UPT_CLEAR> Clear entry in UPT:"
     4830          << " UPT_index = " << r_cleanup_index.read() << std::endl;
     4831#endif
     4832      break;
     4833    }
     4834    ///////////////////////
     4835    case CLEANUP_WRITE_RSP:    // response to a previous write on the direct network
     4836                               // wait if pending request to the TGT_RSP FSM
     4837    {
    45324838      if(r_cleanup_to_tgt_rsp_req.read()) break;
    45334839
     
    45384844      r_cleanup_to_tgt_rsp_pktid   = r_cleanup_write_pktid.read();
    45394845
    4540       r_cleanup_fsm                = CLEANUP_SEND_ACK;
     4846      r_cleanup_fsm                = CLEANUP_SEND_CLACK;
    45414847
    45424848#if DEBUG_MEMC_CLEANUP
    4543       if(m_debug_cleanup_fsm)
    4544       {
    4545         std::cout
    4546             << "  <MEMC " << name()
    4547             << " CLEANUP_WRITE_RSP> Send a response to a previous"
    4548             << " write request waiting for coherence transaction completion: "
    4549             << " rsrcid = "   << std::hex << r_cleanup_write_srcid.read()
    4550             << " / rtrdid = " << std::hex << r_cleanup_write_trdid.read()
    4551             << std::endl;
    4552       }
    4553 #endif
    4554       break;
    4555     }
    4556 
    4557     case CLEANUP_SEND_ACK:
    4558     {
    4559       // acknowledgement to a cleanup command
    4560       // on the coherence network (request to the CC_SEND FSM).
    4561       // wait if pending request to the CC_SEND FSM
     4849if(m_debug)
     4850std::cout << "  <MEMC " << name() << " CLEANUP_WRITE_RSP>"
     4851          << " Send a response to a previous write request: "
     4852          << " rsrcid = "   << std::hex << r_cleanup_write_srcid.read()
     4853          << " / rtrdid = " << r_cleanup_write_trdid.read()
     4854          << " / rpktid = " << r_cleanup_write_pktid.read() << std::endl;
     4855#endif
     4856      break;
     4857    }
     4858    ////////////////////////
     4859    case CLEANUP_CONFIG_ACK:   // signals inval completion to CONFIG FSM
     4860                               // wait if pending request
     4861    {
     4862      if ( r_cleanup_to_config_ack.read() ) break;
     4863
     4864      r_cleanup_to_config_ack      = true;
     4865      r_cleanup_fsm                = CLEANUP_SEND_CLACK;
     4866
     4867#if DEBUG_MEMC_CLEANUP
     4868if(m_debug)
     4869std::cout << "  <MEMC " << name() << " CLEANUP_CONFIG_ACK>"
     4870          << " Acknowledge broacast inval completion" << std::endl;
     4871#endif
     4872      break;
     4873    }
     4874    ////////////////////////
     4875    case CLEANUP_SEND_CLACK:    // acknowledgement to a cleanup command
     4876                              // on the coherence network (request to the CC_SEND FSM).
     4877                              // wait if pending request to the CC_SEND FSM
     4878    {
    45624879      if(r_cleanup_to_cc_send_req.read()) break;
    45634880
     
    45714888
    45724889#if DEBUG_MEMC_CLEANUP
    4573       if(m_debug_cleanup_fsm)
    4574       {
    4575         std::cout
    4576             << "  <MEMC " << name()
    4577             << " CLEANUP_SEND_ACK> Send the response to a cleanup request:"
    4578             << " srcid = " << std::dec << r_cleanup_srcid.read()
    4579             << std::endl;
    4580       }
     4890if(m_debug)
     4891std::cout << "  <MEMC " << name()
     4892          << " CLEANUP_SEND_CLACK> Send the response to a cleanup request:"
     4893          << " srcid = " << std::dec << r_cleanup_srcid.read() << std::endl;
    45814894#endif
    45824895      break;
     
    46184931
    46194932#if DEBUG_MEMC_CAS
    4620         if(m_debug_cas_fsm)
     4933        if(m_debug)
    46214934        {
    46224935          std::cout << "  <MEMC " << name() << " CAS_IDLE> CAS command: " << std::hex
     
    46414954          r_cas_rdata[r_cas_cpt.read()] = m_cmd_cas_wdata_fifo.read();
    46424955
    4643         if((r_cas_cpt.read() == 1) && m_cmd_cas_eop_fifo.read())
     4956        if((r_cas_cpt.read() == 1) and m_cmd_cas_eop_fifo.read())
    46444957          r_cas_wdata = m_cmd_cas_wdata_fifo.read();
    46454958
     
    46684981
    46694982#if DEBUG_MEMC_CAS
    4670       if(m_debug_cas_fsm)
     4983      if(m_debug)
    46714984      {
    46724985        std::cout
     
    47025015
    47035016#if DEBUG_MEMC_CAS
    4704         if(m_debug_cas_fsm)
     5017        if(m_debug)
    47055018        {
    47065019          std::cout << "  <MEMC " << name() << " CAS_DIR_LOCK> Directory acces"
     
    47545067
    47555068#if DEBUG_MEMC_CAS
    4756 if(m_debug_cas_fsm)
     5069if(m_debug)
    47575070std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_READ> Read data from "
    47585071          << " cache and store it in buffer" << std::endl;
     
    47725085
    47735086      // to avoid livelock, force the atomic access to fail pseudo-randomly
    4774       bool forced_fail = ((r_cas_lfsr % (64) == 0) && RANDOMIZE_CAS);
     5087      bool forced_fail = ((r_cas_lfsr % (64) == 0) and RANDOMIZE_CAS);
    47755088      r_cas_lfsr = (r_cas_lfsr >> 1) ^ ((- (r_cas_lfsr & 1)) & 0xd0000001);
    47765089
     
    47875100
    47885101#if DEBUG_MEMC_CAS
    4789 if(m_debug_cas_fsm)
     5102if(m_debug)
    47905103std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_COMPARE> Compare the old"
    47915104          << " and the new data"
     
    48105123          r_cas_fsm = CAS_BC_TRT_LOCK;    // broadcast invalidate required
    48115124        }
    4812         else if(!r_cas_to_cc_send_multi_req.read() &&
     5125        else if(!r_cas_to_cc_send_multi_req.read() and
    48135126                !r_cas_to_cc_send_brdcast_req.read())
    48145127        {
     
    48475160
    48485161#if DEBUG_MEMC_CAS
    4849 if(m_debug_cas_fsm)
     5162if(m_debug)
    48505163std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE> Update cache:"
    48515164          << " way = " << std::dec << way
     
    48745187        size_t      nb_copies  = r_cas_count.read();
    48755188
    4876         wok = m_upt.set(true,  // it's an update transaction
    4877                                false,   // it's not a broadcast
    4878                                true,    // it needs a response
    4879                                srcid,
    4880                                trdid,
    4881                                pktid,
    4882                                nline,
    4883                                nb_copies,
    4884                                index);
     5189        wok = m_upt.set(true,    // it's an update transaction
     5190                        false,   // it's not a broadcast
     5191                        true,    // response required 
     5192                        false,   // no acknowledge required
     5193                        srcid,
     5194                        trdid,
     5195                        pktid,
     5196                        nline,
     5197                        nb_copies,
     5198                        index);
    48855199        if(wok)   // coherence transaction registered in UPT
    48865200        {
     
    49165230
    49175231#if DEBUG_MEMC_CAS
    4918 if(m_debug_cas_fsm)
     5232if(m_debug)
    49195233std::cout << "  <MEMC " << name()
    49205234          << " CAS_UPT_LOCK> Register multi-update transaction in UPT"
     
    49315245
    49325246#if DEBUG_MEMC_CAS
    4933       if(m_debug_cas_fsm)
     5247      if(m_debug)
    49345248      {
    49355249        std::cout << "  <MEMC " << name()
     
    49475261
    49485262#if DEBUG_MEMC_CAS
    4949         if(m_debug_cas_fsm)
     5263        if(m_debug)
    49505264        {
    49515265          std::cout << "  <MEMC " << name()
     
    49635277             "VCI_MEM_CACHE ERROR : bad HEAP allocation");
    49645278
    4965       if(!r_cas_to_cc_send_multi_req.read() && !r_cas_to_cc_send_brdcast_req.read())
     5279      if(!r_cas_to_cc_send_multi_req.read() and !r_cas_to_cc_send_brdcast_req.read())
    49665280      {
    49675281        r_cas_to_cc_send_brdcast_req  = false;
     
    50035317
    50045318#if DEBUG_MEMC_CAS
    5005         if(m_debug_cas_fsm)
     5319        if(m_debug)
    50065320        {
    50075321          std::cout << "  <MEMC " << name() << " CAS_UPT_REQ> Send the first update request to CC_SEND FSM "
     
    50435357
    50445358#if DEBUG_MEMC_CAS
    5045       if(m_debug_cas_fsm)
     5359      if(m_debug)
    50465360      {
    50475361        std::cout << "  <MEMC " << name() << " CAS_UPT_NEXT> Send the next update request to CC_SEND FSM "
     
    50695383              r_cas_to_ixr_cmd_data[i] = r_cas_wdata.read();
    50705384            }
    5071             else if((i == word+1) && (r_cas_cpt.read() == 4))   // 64 bit CAS
     5385            else if((i == word+1) and (r_cas_cpt.read() == 4))   // 64 bit CAS
    50725386            {
    50735387              r_cas_to_ixr_cmd_data[i] = m_cmd_cas_wdata_fifo.read();
     
    51135427        // register a broadcast inval transaction in UPT
    51145428        wok = m_upt.set(false,  // it's an inval transaction
    5115                                true,    // it's a broadcast
    5116                                true,    // it needs a response
    5117                                srcid,
    5118                                trdid,
    5119                                pktid,
    5120                                nline,
    5121                                nb_copies,
    5122                                index);
     5429                        true,    // it's a broadcast
     5430                        true,    // response required
     5431                        false,   // no acknowledge required
     5432                        srcid,
     5433                        trdid,
     5434                        pktid,
     5435                        nline,
     5436                        nb_copies,
     5437                        index);
    51235438
    51245439        if(wok)     // UPT not full
     
    51485463
    51495464#if DEBUG_MEMC_CAS
    5150 if(m_debug_cas_fsm)
     5465if(m_debug)
    51515466std::cout << "  <MEMC " << name()
    51525467          << " CAS_BC_UPT_LOCK> Register a broadcast inval transaction in UPT"
     
    51665481    case CAS_BC_DIR_INVAL:  // Register the PUT transaction in TRT, and inval the DIR entry
    51675482    {
    5168       if((r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) &&
    5169           (r_alloc_upt_fsm.read() == ALLOC_UPT_CAS) &&
     5483      if((r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
     5484          (r_alloc_upt_fsm.read() == ALLOC_UPT_CAS) and
    51705485          (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS))
    51715486      {
     
    52045519
    52055520#if DEBUG_MEMC_CAS
    5206 if(m_debug_cas_fsm)
     5521if(m_debug)
    52075522std::cout << "  <MEMC " << name()
    52085523          << " CAS_BC_DIR_INVAL> Register the PUT in TRT and invalidate DIR entry"
     
    52205535    case CAS_BC_CC_SEND:  // Request the broadcast inval to CC_SEND FSM
    52215536    {
    5222       if(!r_cas_to_cc_send_multi_req.read() &&
     5537      if(!r_cas_to_cc_send_multi_req.read() and
    52235538          !r_cas_to_cc_send_brdcast_req.read())
    52245539      {
     
    52485563
    52495564#if DEBUG_MEMC_CAS
    5250 if(m_debug_cas_fsm)
     5565if(m_debug)
    52515566std::cout << "  <MEMC " << name()
    52525567          << " CAS_BC_XRAM_REQ> Request a PUT transaction to IXR_CMD FSM" << std::hex
     
    52775592
    52785593#if DEBUG_MEMC_CAS
    5279 if(m_debug_cas_fsm)
     5594if(m_debug)
    52805595std::cout << "  <MEMC " << name()
    52815596          << " CAS_RSP_FAIL> Request TGT_RSP to send a failure response" << std::endl;
     
    52995614
    53005615#if DEBUG_MEMC_CAS
    5301 if(m_debug_cas_fsm)
     5616if(m_debug)
    53025617std::cout << "  <MEMC " << name()
    53035618          << " CAS_RSP_SUCCESS> Request TGT_RSP to send a success response" << std::endl;
     
    53195634
    53205635#if DEBUG_MEMC_CAS
    5321         if(m_debug_cas_fsm)
     5636        if(m_debug)
    53225637        {
    53235638          std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_LOCK> Check TRT state"
     
    53295644#endif
    53305645
    5331         if(hit_read || !wok || hit_write)    // missing line already requested or no space in TRT
     5646        if(hit_read or !wok or hit_write)    // missing line already requested or no space in TRT
    53325647        {
    53335648          r_cas_fsm = CAS_WAIT;
     
    53705685
    53715686#if DEBUG_MEMC_CAS
    5372         if(m_debug_cas_fsm)
     5687        if(m_debug)
    53735688        {
    53745689          std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_SET> Register a GET transaction in TRT" << std::hex
     
    53925707
    53935708#if DEBUG_MEMC_CAS
    5394         if(m_debug_cas_fsm)
     5709        if(m_debug)
    53955710        {
    53965711          std::cout << "  <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction to IXR_CMD FSM" << std::hex
     
    54385753      {
    54395754        // XRAM_RSP FSM has highest priority
    5440         if(m_xram_rsp_to_cc_send_inst_fifo.rok() ||
     5755        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
    54415756            r_xram_rsp_to_cc_send_multi_req.read())
    54425757        {
     
    54535768        }
    54545769
    5455         if(m_cas_to_cc_send_inst_fifo.rok() ||
     5770        if(m_cas_to_cc_send_inst_fifo.rok() or
    54565771            r_cas_to_cc_send_multi_req.read())
    54575772        {
     
    54745789        }
    54755790
    5476         if(m_write_to_cc_send_inst_fifo.rok() ||
     5791        if(m_write_to_cc_send_inst_fifo.rok() or
    54775792            r_write_to_cc_send_multi_req.read())
    54785793        {
     
    54935808      {
    54945809        // CAS FSM has highest priority
    5495         if(m_cas_to_cc_send_inst_fifo.rok() ||
     5810        if(m_cas_to_cc_send_inst_fifo.rok() or
    54965811            r_cas_to_cc_send_multi_req.read())
    54975812        {
     
    55145829        }
    55155830
    5516         if(m_write_to_cc_send_inst_fifo.rok() ||
     5831        if(m_write_to_cc_send_inst_fifo.rok() or
    55175832            r_write_to_cc_send_multi_req.read())
    55185833        {
     
    55295844        }
    55305845
    5531         if(m_xram_rsp_to_cc_send_inst_fifo.rok() ||
     5846        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
    55325847            r_xram_rsp_to_cc_send_multi_req.read())
    55335848        {
     
    55555870        }
    55565871
    5557         if(m_write_to_cc_send_inst_fifo.rok() ||
     5872        if(m_write_to_cc_send_inst_fifo.rok() or
    55585873            r_write_to_cc_send_multi_req.read())
    55595874        {
     
    55705885        }
    55715886
    5572         if(m_xram_rsp_to_cc_send_inst_fifo.rok() ||
     5887        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
    55735888            r_xram_rsp_to_cc_send_multi_req.read())
    55745889        {
     
    55855900        }
    55865901
    5587         if(m_cas_to_cc_send_inst_fifo.rok() ||
     5902        if(m_cas_to_cc_send_inst_fifo.rok() or
    55885903            r_cas_to_cc_send_multi_req.read())
    55895904        {
     
    56045919      {
    56055920        // WRITE FSM has highest priority
    5606         if(m_write_to_cc_send_inst_fifo.rok() ||
     5921        if(m_write_to_cc_send_inst_fifo.rok() or
    56075922            r_write_to_cc_send_multi_req.read())
    56085923        {
     
    56195934        }
    56205935
    5621         if(m_xram_rsp_to_cc_send_inst_fifo.rok() ||
     5936        if(m_xram_rsp_to_cc_send_inst_fifo.rok() or
    56225937            r_xram_rsp_to_cc_send_multi_req.read())
    56235938        {
     
    56345949        }
    56355950
    5636         if(m_cas_to_cc_send_inst_fifo.rok() ||
     5951        if(m_cas_to_cc_send_inst_fifo.rok() or
    56375952            r_cas_to_cc_send_multi_req.read())
    56385953        {
     
    56665981
    56675982#if DEBUG_MEMC_CC_SEND
    5668 if(m_debug_cc_send_fsm)
     5983if(m_debug)
    56695984std::cout << "  <MEMC " << name()
    56705985          << " CC_SEND_CLEANUP_ACK> Cleanup Ack for srcid "
     
    57056020
    57066021#if DEBUG_MEMC_CC_SEND
    5707 if(m_debug_cc_send_fsm)
     6022if(m_debug)
    57086023std::cout << "  <MEMC " << name()
    57096024          << " CC_SEND_XRAM_RSP_INVAL_NLINE> BC-Inval for line "
     
    57336048
    57346049#if DEBUG_MEMC_CC_SEND
    5735 if(m_debug_cc_send_fsm)
     6050if(m_debug)
    57366051std::cout << "  <MEMC " << name()
    57376052          << " CC_SEND_XRAM_RSP_BRDCAST_NLINE> BC-Inval for line "
     
    57616076
    57626077#if DEBUG_MEMC_CC_SEND
    5763 if(m_debug_cc_send_fsm)
     6078if(m_debug)
    57646079std::cout << "  <MEMC " << name()
    57656080          << " CC_SEND_WRITE_BRDCAST_NLINE> BC-Inval for line "
     
    58006115
    58016116#if DEBUG_MEMC_CC_SEND
    5802         if(m_debug_cc_send_fsm)
     6117        if(m_debug)
    58036118        {
    58046119          std::cout
     
    58486163
    58496164#if DEBUG_MEMC_CC_SEND
    5850         if(m_debug_cc_send_fsm)
     6165        if(m_debug)
    58516166        {
    58526167          std::cout
     
    58926207
    58936208#if DEBUG_MEMC_CC_SEND
    5894         if(m_debug_cc_send_fsm)
    5895         {
    5896           std::cout
    5897             << "  <MEMC " << name()
    5898             << " CC_SEND_CAS_UPDT_NLINE> Multicast-Update for line "
    5899             << r_cas_to_cc_send_nline.read()
    5900             << std::endl;
    5901         }
     6209if(m_debug)
     6210std::cout << "  <MEMC " << name()
     6211          << " CC_SEND_CAS_UPDT_NLINE> Multicast-Update for line "
     6212          << r_cas_to_cc_send_nline.read() << std::endl;
    59026213#endif
    59036214        break;
     
    59516262              DspinDhccpParam::FROM_L1_TYPE);
    59526263
    5953         if((type == DspinDhccpParam::TYPE_CLEANUP_DATA) ||
     6264        if((type == DspinDhccpParam::TYPE_CLEANUP_DATA) or
    59546265           (type == DspinDhccpParam::TYPE_CLEANUP_INST))
    59556266        {
     
    59646275        }
    59656276
    5966         assert(false &&
     6277        assert(false and
    59676278            "VCI_MEM_CACHE ERROR in CC_RECEIVE : "
    59686279            "Illegal type in coherence request");
     
    60496360        r_tgt_rsp_cpt = r_read_to_tgt_rsp_word.read();
    60506361      }
    6051       else if(r_write_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_WRITE;
    6052       else if(r_cas_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CAS  ;
     6362      else if(r_write_to_tgt_rsp_req)
     6363      {
     6364        r_tgt_rsp_fsm = TGT_RSP_WRITE;
     6365      }
     6366      else if(r_cas_to_tgt_rsp_req)
     6367      {
     6368        r_tgt_rsp_fsm = TGT_RSP_CAS  ;
     6369      }
    60536370      else if(r_xram_rsp_to_tgt_rsp_req)
    60546371      {
     
    60566373        r_tgt_rsp_cpt = r_xram_rsp_to_tgt_rsp_word.read();
    60576374      }
    6058       else if(r_multi_ack_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK;
    6059       else if(r_cleanup_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
    6060       else if(r_tgt_cmd_to_tgt_rsp_req) r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
     6375      else if(r_multi_ack_to_tgt_rsp_req)
     6376      {
     6377        r_tgt_rsp_fsm = TGT_RSP_MULTI_ACK;
     6378      }
     6379      else if(r_cleanup_to_tgt_rsp_req)
     6380      {
     6381        r_tgt_rsp_fsm = TGT_RSP_CLEANUP;
     6382      }
     6383      else if(r_tgt_cmd_to_tgt_rsp_req)
     6384      {
     6385        r_tgt_rsp_fsm = TGT_RSP_TGT_CMD;
     6386      }
    60616387      break;
    60626388    }
     
    61856511    /////////////////////
    61866512    case TGT_RSP_TGT_CMD: // send the response after a segmentation violation
     6513                          // or after a config transaction 
    61876514    {
    61886515      if ( p_vci_tgt.rspack )
     
    61926519
    61936520#if DEBUG_MEMC_TGT_RSP
    6194 if( m_debug_tgt_rsp_fsm )
     6521if( m_debug )
    61956522{
    61966523  std::cout
    61976524    << "  <MEMC " << name()
    6198     << " TGT_RSP_TGT_CMD> Segmentation violation from TGT_CMD response"
     6525    << " TGT_RSP_TGT_CMD> Segmentation violation ior config access response"
    61996526    << " / rsrcid = " << std::hex << r_tgt_cmd_to_tgt_rsp_srcid.read()
    62006527    << " / rtrdid = " << r_tgt_cmd_to_tgt_rsp_trdid.read()
     
    62146541
    62156542#if DEBUG_MEMC_TGT_RSP
    6216 if( m_debug_tgt_rsp_fsm )
     6543if( m_debug )
    62176544{
    62186545  std::cout
     
    62606587
    62616588#if DEBUG_MEMC_TGT_RSP
    6262 if(m_debug_tgt_rsp_fsm)
     6589if(m_debug)
    62636590std::cout << "  <MEMC " << name() << " TGT_RSP_WRITE> Write response"
    62646591          << " / rsrcid = " << std::hex << r_write_to_tgt_rsp_srcid.read()
     
    62716598      break;
    62726599    }
    6273     ///////////////////
     6600    /////////////////////
    62746601    case TGT_RSP_CLEANUP:   // pas clair pour moi (AG)
    62756602    {
     
    62786605
    62796606#if DEBUG_MEMC_TGT_RSP
    6280 if(m_debug_tgt_rsp_fsm)
     6607if(m_debug)
    62816608std::cout << "  <MEMC " << name() << " TGT_RSP_CLEANUP> Cleanup response"
    62826609          << " / rsrcid = " << std::hex << r_cleanup_to_tgt_rsp_srcid.read()
     
    62896616      break;
    62906617    }
    6291     //////////////////
     6618    /////////////////
    62926619    case TGT_RSP_CAS:    // send one atomic word response
    62936620    {
     
    62966623
    62976624#if DEBUG_MEMC_TGT_RSP
    6298 if(m_debug_tgt_rsp_fsm)
     6625if(m_debug)
    62996626std::cout << "  <MEMC " << name() << " TGT_RSP_CAS> CAS response"
    63006627          << " / rsrcid = " << std::hex << r_cas_to_tgt_rsp_srcid.read()
     
    63086635    }
    63096636
    6310     ///////////////////////
     6637    //////////////////
    63116638    case TGT_RSP_XRAM:    // send the response after XRAM access
    63126639    {
     
    63156642
    63166643#if DEBUG_MEMC_TGT_RSP
    6317 if( m_debug_tgt_rsp_fsm )
     6644if( m_debug )
    63186645std::cout << "  <MEMC " << name() << " TGT_RSP_XRAM> Response following XRAM access"
    63196646          << " / rsrcid = " << std::hex << r_xram_rsp_to_tgt_rsp_srcid.read()
     
    63516678      break;
    63526679    }
    6353     //////////////////
     6680    ///////////////////////
    63546681    case TGT_RSP_MULTI_ACK:    // send the write response after coherence transaction
    63556682    {
     
    63586685
    63596686#if DEBUG_MEMC_TGT_RSP
    6360 if(m_debug_tgt_rsp_fsm)
     6687if(m_debug)
    63616688std::cout << "  <MEMC " << name() << " TGT_RSP_MULTI_ACK> Write response after coherence transaction"
    63626689          << " / rsrcid = " << std::hex << r_multi_ack_to_tgt_rsp_srcid.read()
     
    63746701  //    ALLOC_UPT FSM
    63756702  ////////////////////////////////////////////////////////////////////////////////////
    6376   // The ALLOC_UPT FSM allocates the access to the Update/Inval Table (UPT).
    6377   // with a round robin priority between three FSMs : MULTI_ACK > WRITE > XRAM_RSP > CLEANUP
    6378   // - The WRITE FSM initiates update transactions and sets  new entry in UPT.
    6379   // - The XRAM_RSP FSM initiates inval transactions and sets new entry in UPT.
     6703  // The ALLOC_UPT FSM allocates the access to the Update/Inval Table (UPT),
     6704  // with a round robin priority between six FSMs, with the following order:
     6705  //  CONFIG > MULTI_ACK > WRITE > XRAM_RSP > CLEANUP > CAS
     6706  // - The CONFIG FSM initiates an inval transaction and sets a new entry in UPT.
    63806707  // - The MULTI_ACK FSM complete those trasactions and erase the UPT entry.
     6708  // - The WRITE FSM initiates update transaction and sets a new entry in UPT.
     6709  // - The XRAM_RSP FSM initiates an inval transactions and sets a new entry in UPT.
    63816710  // - The CLEANUP  FSM decrement an entry in UPT.
     6711  // - The CAS FSM does the same thing as the WRITE FSM.
    63826712  // The resource is always allocated.
    63836713  /////////////////////////////////////////////////////////////////////////////////////
     
    63856715  switch(r_alloc_upt_fsm.read())
    63866716  {
    6387 
    6388       ////////////////////////
    6389     case ALLOC_UPT_MULTI_ACK:
    6390       if((r_multi_ack_fsm.read() != MULTI_ACK_UPT_LOCK) &&
     6717      //////////////////////
     6718      case ALLOC_UPT_CONFIG:   // allocated to CONFIG FSM
     6719      if ( (r_config_fsm.read() != CONFIG_UPT_LOCK) and
     6720           (r_config_fsm.read() != CONFIG_BC_UPT_LOCK) )
     6721      {
     6722        if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
     6723          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
     6724               
     6725        else if((r_write_fsm.read() == WRITE_UPT_LOCK) or
     6726                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
     6727          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     6728
     6729        else if(r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     6730          r_alloc_upt_fsm = ALLOC_UPT_XRAM_RSP;
     6731
     6732        else if(r_cleanup_fsm.read() == CLEANUP_UPT_LOCK)
     6733          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
     6734
     6735        else if((r_cas_fsm.read() == CAS_UPT_LOCK) or
     6736                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
     6737          r_alloc_upt_fsm = ALLOC_UPT_CAS;
     6738      }
     6739      break;
     6740
     6741      /////////////////////////
     6742      case ALLOC_UPT_MULTI_ACK:   // allocated to MULTI_ACK FSM
     6743      if( (r_multi_ack_fsm.read() != MULTI_ACK_UPT_LOCK) and
    63916744          (r_multi_ack_fsm.read() != MULTI_ACK_UPT_CLEAR))
    63926745      {
    6393         if((r_write_fsm.read() == WRITE_UPT_LOCK) ||
     6746        if((r_write_fsm.read() == WRITE_UPT_LOCK) or
    63946747            (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    63956748          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     
    64016754          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
    64026755
    6403         else if((r_cas_fsm.read() == CAS_UPT_LOCK) ||
     6756        else if((r_cas_fsm.read() == CAS_UPT_LOCK) or
    64046757                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    64056758          r_alloc_upt_fsm = ALLOC_UPT_CAS;
     6759
     6760        else if((r_config_fsm.read() == CONFIG_UPT_LOCK) or
     6761                (r_config_fsm.read() == CONFIG_BC_UPT_LOCK))
     6762          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
    64066763      }
    64076764      break;
    64086765
    64096766      /////////////////////
    6410     case ALLOC_UPT_WRITE:
    6411       if((r_write_fsm.read() != WRITE_UPT_LOCK) &&
     6767      case ALLOC_UPT_WRITE:   // allocated to WRITE FSM
     6768      if((r_write_fsm.read() != WRITE_UPT_LOCK) and
    64126769          (r_write_fsm.read() != WRITE_BC_UPT_LOCK))
    64136770      {
     
    64186775          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
    64196776
    6420         else if((r_cas_fsm.read() == CAS_UPT_LOCK) ||
     6777        else if((r_cas_fsm.read() == CAS_UPT_LOCK) or
    64216778                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    64226779          r_alloc_upt_fsm = ALLOC_UPT_CAS;
    64236780
     6781        else if((r_config_fsm.read() == CONFIG_UPT_LOCK) or
     6782                (r_config_fsm.read() == CONFIG_BC_UPT_LOCK))
     6783          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
     6784
    64246785        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    64256786          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
     
    64286789
    64296790      ////////////////////////
    6430     case ALLOC_UPT_XRAM_RSP:
     6791      case ALLOC_UPT_XRAM_RSP:
    64316792      if(r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK)
    64326793      {
     
    64346795          r_alloc_upt_fsm = ALLOC_UPT_CLEANUP;
    64356796
    6436         else if((r_cas_fsm.read() == CAS_UPT_LOCK) ||
     6797        else if((r_cas_fsm.read() == CAS_UPT_LOCK) or
    64376798                (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    64386799          r_alloc_upt_fsm = ALLOC_UPT_CAS;
    64396800
     6801        else if((r_config_fsm.read() == CONFIG_UPT_LOCK) or
     6802                (r_config_fsm.read() == CONFIG_BC_UPT_LOCK))
     6803          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
     6804
    64406805        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    64416806          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
    64426807
    6443         else if((r_write_fsm.read() == WRITE_UPT_LOCK)   ||
     6808        else if((r_write_fsm.read() == WRITE_UPT_LOCK)   or
    64446809                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    64456810          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     
    64486813
    64496814      //////////////////////////
    6450     case ALLOC_UPT_CLEANUP:
    6451       if((r_cleanup_fsm.read() != CLEANUP_UPT_LOCK     ) &&
     6815      case ALLOC_UPT_CLEANUP:
     6816      if((r_cleanup_fsm.read() != CLEANUP_UPT_LOCK     ) and
    64526817         (r_cleanup_fsm.read() != CLEANUP_UPT_DECREMENT))
    64536818      {
    6454         if((r_cas_fsm.read() == CAS_UPT_LOCK) ||
     6819        if((r_cas_fsm.read() == CAS_UPT_LOCK) or
    64556820            (r_cas_fsm.read() == CAS_BC_UPT_LOCK))
    64566821          r_alloc_upt_fsm = ALLOC_UPT_CAS;
    64576822
     6823        else if((r_config_fsm.read() == CONFIG_UPT_LOCK) or
     6824                (r_config_fsm.read() == CONFIG_BC_UPT_LOCK))
     6825          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
     6826
    64586827        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    64596828          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
    64606829
    6461         else if((r_write_fsm.read() == WRITE_UPT_LOCK) ||
     6830        else if((r_write_fsm.read() == WRITE_UPT_LOCK) or
    64626831                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    64636832          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     
    64696838
    64706839      //////////////////////////
    6471     case ALLOC_UPT_CAS:
    6472       if((r_cas_fsm.read() != CAS_UPT_LOCK) &&
     6840      case ALLOC_UPT_CAS:
     6841      if((r_cas_fsm.read() != CAS_UPT_LOCK) and
    64736842          (r_cas_fsm.read() != CAS_BC_UPT_LOCK))
    64746843      {
    6475         if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
     6844        if((r_config_fsm.read() == CONFIG_UPT_LOCK) or
     6845                (r_config_fsm.read() == CONFIG_BC_UPT_LOCK))
     6846          r_alloc_upt_fsm = ALLOC_UPT_CONFIG;
     6847
     6848        else if(r_multi_ack_fsm.read() == MULTI_ACK_UPT_LOCK)
    64766849          r_alloc_upt_fsm = ALLOC_UPT_MULTI_ACK;
    64776850
    6478         else if((r_write_fsm.read() == WRITE_UPT_LOCK) ||
     6851        else if((r_write_fsm.read() == WRITE_UPT_LOCK) or
    64796852                (r_write_fsm.read() == WRITE_BC_UPT_LOCK))
    64806853          r_alloc_upt_fsm = ALLOC_UPT_WRITE;
     
    64946867  ////////////////////////////////////////////////////////////////////////////////////
    64956868  // The ALLOC_DIR FSM allocates the access to the directory and
    6496   // the data cache with a round robin priority between 5 user FSMs :
    6497   // The cyclic ordering is READ > WRITE > CAS > CLEANUP > XRAM_RSP
     6869  // the data cache with a round robin priority between 6 user FSMs :
     6870  // The cyclic ordering is CONFIG > READ > WRITE > CAS > CLEANUP > XRAM_RSP
    64986871  // The ressource is always allocated.
    64996872  /////////////////////////////////////////////////////////////////////////////////////
     
    65016874  switch(r_alloc_dir_fsm.read())
    65026875  {
     6876    /////////////////////
    65036877    case ALLOC_DIR_RESET: // Initializes the directory one SET per cycle.
    65046878                          // All the WAYS of a SET initialized in parallel
     
    65136887      break;
    65146888
     6889    //////////////////////
     6890    case ALLOC_DIR_CONFIG:    // allocated to CONFIG FSM
     6891    if ( (r_config_fsm.read()    != CONFIG_DIR_REQ) and
     6892         (r_config_fsm.read()    != CONFIG_DIR_ACCESS) and
     6893         (r_config_fsm.read()    != CONFIG_DIR_INVAL) )
     6894    {
     6895        if(r_read_fsm.read() == READ_DIR_REQ)
     6896          r_alloc_dir_fsm = ALLOC_DIR_READ;
     6897
     6898        else if(r_write_fsm.read() == WRITE_DIR_REQ)
     6899          r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     6900
     6901        else if(r_cas_fsm.read() == CAS_DIR_REQ)
     6902          r_alloc_dir_fsm = ALLOC_DIR_CAS;
     6903
     6904        else if(r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
     6905          r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     6906
     6907        else if(r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
     6908          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
     6909    }
     6910    break;
     6911
    65156912    ////////////////////
    6516     case ALLOC_DIR_READ:
    6517       if(((r_read_fsm.read()        != READ_DIR_REQ)   &&
    6518           (r_read_fsm.read()        != READ_DIR_LOCK)   &&
    6519           (r_read_fsm.read()        != READ_TRT_LOCK)   &&
    6520           (r_read_fsm.read()        != READ_HEAP_REQ))
    6521           ||
    6522           ((r_read_fsm.read()       == READ_TRT_LOCK)   &&
    6523            (r_alloc_trt_fsm.read()  == ALLOC_TRT_READ)))
    6524       {
     6913    case ALLOC_DIR_READ:    // allocated to READ FSM
     6914    if( ((r_read_fsm.read()      != READ_DIR_REQ)   and
     6915         (r_read_fsm.read()      != READ_DIR_LOCK)   and
     6916         (r_read_fsm.read()      != READ_TRT_LOCK)   and
     6917         (r_read_fsm.read()      != READ_HEAP_REQ))
     6918         or
     6919         ((r_read_fsm.read()       == READ_TRT_LOCK)   and
     6920          (r_alloc_trt_fsm.read()  == ALLOC_TRT_READ)) )
     6921    {
    65256922        if(r_write_fsm.read() == WRITE_DIR_REQ)
    65266923          r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     
    65346931        else if(r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    65356932          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    6536       }
    6537       break;
    6538 
    6539       /////////////////////
    6540     case ALLOC_DIR_WRITE:
    6541       if(((r_write_fsm.read()       != WRITE_DIR_REQ)  &&
    6542           (r_write_fsm.read()       != WRITE_DIR_LOCK)  &&
    6543           (r_write_fsm.read()       != WRITE_DIR_READ)  &&
    6544           (r_write_fsm.read()       != WRITE_DIR_HIT)  &&
    6545           (r_write_fsm.read()       != WRITE_BC_TRT_LOCK)  &&
    6546           (r_write_fsm.read()       != WRITE_BC_UPT_LOCK)  &&
    6547           (r_write_fsm.read()       != WRITE_MISS_TRT_LOCK)  &&
    6548           (r_write_fsm.read()       != WRITE_UPT_LOCK)  &&
    6549           (r_write_fsm.read()       != WRITE_UPT_HEAP_LOCK))
    6550           ||
    6551           ((r_write_fsm.read()      == WRITE_UPT_HEAP_LOCK)  &&
    6552            (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE))
    6553           ||
    6554           ((r_write_fsm.read()      == WRITE_MISS_TRT_LOCK)  &&
    6555            (r_alloc_trt_fsm.read()  == ALLOC_TRT_WRITE)))
    6556       {
     6933
     6934        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
     6935          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     6936    }
     6937    break;
     6938
     6939    /////////////////////
     6940    case ALLOC_DIR_WRITE:    // allocated to WRITE FSM
     6941    if(((r_write_fsm.read()       != WRITE_DIR_REQ)  and
     6942        (r_write_fsm.read()       != WRITE_DIR_LOCK)  and
     6943        (r_write_fsm.read()       != WRITE_DIR_READ)  and
     6944        (r_write_fsm.read()       != WRITE_DIR_HIT)  and
     6945        (r_write_fsm.read()       != WRITE_BC_TRT_LOCK)  and
     6946        (r_write_fsm.read()       != WRITE_BC_UPT_LOCK)  and
     6947        (r_write_fsm.read()       != WRITE_MISS_TRT_LOCK)  and
     6948        (r_write_fsm.read()       != WRITE_UPT_LOCK)  and
     6949        (r_write_fsm.read()       != WRITE_UPT_HEAP_LOCK))
     6950        or
     6951        ((r_write_fsm.read()      == WRITE_UPT_HEAP_LOCK)  and
     6952         (r_alloc_heap_fsm.read() == ALLOC_HEAP_WRITE))
     6953        or
     6954        ((r_write_fsm.read()      == WRITE_MISS_TRT_LOCK)  and
     6955         (r_alloc_trt_fsm.read()  == ALLOC_TRT_WRITE)))
     6956    {
    65576957        if(r_cas_fsm.read() == CAS_DIR_REQ)
    65586958          r_alloc_dir_fsm = ALLOC_DIR_CAS;
     
    65646964          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    65656965
     6966        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
     6967          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     6968
    65666969        else if(r_read_fsm.read() == READ_DIR_REQ)
    65676970          r_alloc_dir_fsm = ALLOC_DIR_READ;
    6568       }
    6569       break;
    6570 
    6571       ////////////////////
    6572     case ALLOC_DIR_CAS:
    6573       if(((r_cas_fsm.read()         != CAS_DIR_REQ)  &&
    6574           (r_cas_fsm.read()         != CAS_DIR_LOCK)  &&
    6575           (r_cas_fsm.read()         != CAS_DIR_HIT_READ)  &&
    6576           (r_cas_fsm.read()         != CAS_DIR_HIT_COMPARE)  &&
    6577           (r_cas_fsm.read()         != CAS_DIR_HIT_WRITE)  &&
    6578           (r_cas_fsm.read()         != CAS_BC_TRT_LOCK)  &&
    6579           (r_cas_fsm.read()         != CAS_BC_UPT_LOCK)  &&
    6580           (r_cas_fsm.read()         != CAS_MISS_TRT_LOCK)  &&
    6581           (r_cas_fsm.read()         != CAS_UPT_LOCK)  &&
    6582           (r_cas_fsm.read()         != CAS_UPT_HEAP_LOCK))
    6583           ||
    6584           ((r_cas_fsm.read()        == CAS_UPT_HEAP_LOCK)  &&
    6585            (r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS))
    6586           ||
    6587           ((r_cas_fsm.read()        == CAS_MISS_TRT_LOCK)  &&
    6588            (r_alloc_trt_fsm.read()  == ALLOC_TRT_CAS)))
    6589       {
     6971    }
     6972    break;
     6973
     6974    ///////////////////
     6975    case ALLOC_DIR_CAS:    // allocated to CAS FSM
     6976    if(((r_cas_fsm.read()         != CAS_DIR_REQ)  and
     6977        (r_cas_fsm.read()         != CAS_DIR_LOCK)  and
     6978        (r_cas_fsm.read()         != CAS_DIR_HIT_READ)  and
     6979        (r_cas_fsm.read()         != CAS_DIR_HIT_COMPARE)  and
     6980        (r_cas_fsm.read()         != CAS_DIR_HIT_WRITE)  and
     6981        (r_cas_fsm.read()         != CAS_BC_TRT_LOCK)  and
     6982        (r_cas_fsm.read()         != CAS_BC_UPT_LOCK)  and
     6983        (r_cas_fsm.read()         != CAS_MISS_TRT_LOCK)  and
     6984        (r_cas_fsm.read()         != CAS_UPT_LOCK)  and
     6985        (r_cas_fsm.read()         != CAS_UPT_HEAP_LOCK))
     6986        or
     6987        ((r_cas_fsm.read()        == CAS_UPT_HEAP_LOCK)  and
     6988         (r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS))
     6989        or
     6990        ((r_cas_fsm.read()        == CAS_MISS_TRT_LOCK)  and
     6991         (r_alloc_trt_fsm.read()  == ALLOC_TRT_CAS)))
     6992    {
    65906993        if(r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    65916994          r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     
    65946997          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    65956998
     6999        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
     7000          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     7001
    65967002        else if(r_read_fsm.read() == READ_DIR_REQ)
    65977003          r_alloc_dir_fsm = ALLOC_DIR_READ;
     
    65997005        else if(r_write_fsm.read() == WRITE_DIR_REQ)
    66007006          r_alloc_dir_fsm = ALLOC_DIR_WRITE;
    6601       }
    6602       break;
    6603 
    6604       ///////////////////////
    6605     case ALLOC_DIR_CLEANUP:
    6606       if((r_cleanup_fsm.read() != CLEANUP_DIR_REQ) &&
    6607           (r_cleanup_fsm.read() != CLEANUP_DIR_LOCK) &&
    6608           (r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) &&
    6609           (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK))
    6610       {
     7007    }
     7008      break;
     7009
     7010    ///////////////////////
     7011    case ALLOC_DIR_CLEANUP:    // allocated to CLEANUP FSM
     7012    if((r_cleanup_fsm.read() != CLEANUP_DIR_REQ) and
     7013        (r_cleanup_fsm.read() != CLEANUP_DIR_LOCK) and
     7014        (r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) and
     7015        (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK))
     7016    {
    66117017        if(r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    66127018          r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    66137019
     7020        else if(r_config_fsm.read() == CONFIG_DIR_REQ)
     7021          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     7022
    66147023        else if(r_read_fsm.read() == READ_DIR_REQ)
    66157024          r_alloc_dir_fsm = ALLOC_DIR_READ;
     
    66207029        else if(r_cas_fsm.read() == CAS_DIR_REQ)
    66217030          r_alloc_dir_fsm = ALLOC_DIR_CAS;
    6622       }
    6623       break;
    6624 
    6625       ////////////////////////
    6626     case ALLOC_DIR_XRAM_RSP:
    6627       if((r_xram_rsp_fsm.read() != XRAM_RSP_DIR_LOCK) &&
    6628           (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) &&
    6629           (r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK))
    6630       {
    6631         if(r_read_fsm.read() == READ_DIR_REQ)
     7031    }
     7032    break;
     7033
     7034    ////////////////////////
     7035    case ALLOC_DIR_XRAM_RSP:    // allocated to XRAM_RSP FSM
     7036    if( (r_xram_rsp_fsm.read() != XRAM_RSP_DIR_LOCK) and
     7037        (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) and
     7038        (r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK))
     7039    {
     7040        if(r_config_fsm.read() == CONFIG_DIR_REQ)
     7041          r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     7042
     7043        else if(r_read_fsm.read() == READ_DIR_REQ)
    66327044          r_alloc_dir_fsm = ALLOC_DIR_READ;
    66337045
     
    66407052        else if(r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    66417053          r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
    6642       }
    6643       break;
     7054    }
     7055    break;
    66447056
    66457057  } // end switch alloc_dir_fsm
     
    66607072      if(r_read_fsm.read() != READ_TRT_LOCK)
    66617073      {
    6662         if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     7074        if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    66637075            (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    66647076          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    66657077
    6666         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     7078        else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    66677079                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    66687080          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    66697081
    6670         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     7082        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    66717083                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    66727084          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    66737085
    6674         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     7086        else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    66757087                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    66767088          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     
    66807092    /////////////////////
    66817093    case ALLOC_TRT_WRITE:
    6682       if((r_write_fsm.read() != WRITE_MISS_TRT_LOCK) &&
    6683           (r_write_fsm.read() != WRITE_BC_TRT_LOCK) &&
     7094      if((r_write_fsm.read() != WRITE_MISS_TRT_LOCK) and
     7095          (r_write_fsm.read() != WRITE_BC_TRT_LOCK) and
    66847096          (r_write_fsm.read() != WRITE_BC_UPT_LOCK))
    66857097      {
    6686         if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     7098        if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    66877099            (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    66887100          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    66897101
    6690         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     7102        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    66917103                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    66927104          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    66937105
    6694         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     7106        else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    66957107                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    66967108          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     
    67037115    ////////////////////
    67047116    case ALLOC_TRT_CAS:
    6705       if((r_cas_fsm.read() != CAS_MISS_TRT_LOCK) &&
    6706           (r_cas_fsm.read() != CAS_BC_TRT_LOCK) &&
     7117      if((r_cas_fsm.read() != CAS_MISS_TRT_LOCK) and
     7118          (r_cas_fsm.read() != CAS_BC_TRT_LOCK) and
    67077119          (r_cas_fsm.read() != CAS_BC_UPT_LOCK))
    67087120      {
    6709         if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     7121        if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    67107122            (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    67117123          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    67127124
    6713         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     7125        else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    67147126                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    67157127          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     
    67187130          r_alloc_trt_fsm = ALLOC_TRT_READ;
    67197131
    6720         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     7132        else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    67217133                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    67227134          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     
    67267138    ////////////////////////
    67277139    case ALLOC_TRT_XRAM_RSP:
    6728       if(((r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_LOCK)  ||
    6729           (r_alloc_dir_fsm.read() != ALLOC_DIR_XRAM_RSP)) &&
    6730           (r_xram_rsp_fsm.read()  != XRAM_RSP_TRT_COPY)  &&
    6731           (r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_UPDT)  &&
     7140      if(((r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_LOCK)  or
     7141          (r_alloc_dir_fsm.read() != ALLOC_DIR_XRAM_RSP)) and
     7142          (r_xram_rsp_fsm.read()  != XRAM_RSP_TRT_COPY)  and
     7143          (r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_UPDT)  and
    67327144          (r_xram_rsp_fsm.read()  != XRAM_RSP_INVAL_LOCK))
    67337145      {
    6734         if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
     7146        if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    67357147            (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    67367148          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     
    67397151          r_alloc_trt_fsm = ALLOC_TRT_READ;
    67407152
    6741         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     7153        else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    67427154                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    67437155          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    67447156
    6745         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     7157        else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    67467158                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    67477159          r_alloc_trt_fsm = ALLOC_TRT_CAS;
     
    67517163    ////////////////////////
    67527164    case ALLOC_TRT_IXR_RSP:
    6753       if((r_ixr_rsp_fsm.read() != IXR_RSP_TRT_ERASE) &&
     7165      if((r_ixr_rsp_fsm.read() != IXR_RSP_TRT_ERASE) and
    67547166          (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ))
    67557167      {
     
    67577169          r_alloc_trt_fsm = ALLOC_TRT_READ;
    67587170
    6759         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
     7171        else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    67607172                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    67617173          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    67627174
    6763         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
     7175        else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    67647176                (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    67657177          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    67667178
    6767         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
     7179        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    67687180                (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    67697181          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     
    68007212      ////////////////////
    68017213    case ALLOC_HEAP_READ:
    6802       if((r_read_fsm.read() != READ_HEAP_REQ) &&
    6803           (r_read_fsm.read() != READ_HEAP_LOCK) &&
     7214      if((r_read_fsm.read() != READ_HEAP_REQ) and
     7215          (r_read_fsm.read() != READ_HEAP_LOCK) and
    68047216          (r_read_fsm.read() != READ_HEAP_ERASE))
    68057217      {
     
    68207232      /////////////////////
    68217233    case ALLOC_HEAP_WRITE:
    6822       if((r_write_fsm.read() != WRITE_UPT_HEAP_LOCK) &&
    6823           (r_write_fsm.read() != WRITE_UPT_REQ) &&
     7234      if((r_write_fsm.read() != WRITE_UPT_HEAP_LOCK) and
     7235          (r_write_fsm.read() != WRITE_UPT_REQ) and
    68247236          (r_write_fsm.read() != WRITE_UPT_NEXT))
    68257237      {
     
    68407252      ////////////////////
    68417253    case ALLOC_HEAP_CAS:
    6842       if((r_cas_fsm.read() != CAS_UPT_HEAP_LOCK) &&
    6843           (r_cas_fsm.read() != CAS_UPT_REQ) &&
     7254      if((r_cas_fsm.read() != CAS_UPT_HEAP_LOCK) and
     7255          (r_cas_fsm.read() != CAS_UPT_REQ) and
    68447256          (r_cas_fsm.read() != CAS_UPT_NEXT))
    68457257      {
     
    68607272      ///////////////////////
    68617273    case ALLOC_HEAP_CLEANUP:
    6862       if((r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) &&
    6863           (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK) &&
    6864           (r_cleanup_fsm.read() != CLEANUP_HEAP_SEARCH) &&
     7274      if((r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) and
     7275          (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK) and
     7276          (r_cleanup_fsm.read() != CLEANUP_HEAP_SEARCH) and
    68657277          (r_cleanup_fsm.read() != CLEANUP_HEAP_CLEAN))
    68667278      {
     
    68817293      ////////////////////////
    68827294    case ALLOC_HEAP_XRAM_RSP:
    6883       if((r_xram_rsp_fsm.read() != XRAM_RSP_HEAP_REQ) &&
     7295      if((r_xram_rsp_fsm.read() != XRAM_RSP_HEAP_REQ) and
    68847296          (r_xram_rsp_fsm.read() != XRAM_RSP_HEAP_ERASE))
    68857297      {
     
    69017313  } // end switch alloc_heap_fsm
    69027314
    6903 
    6904   ////////////////////////////////////////////////////////////////////////////////////
     7315  /////////////////////////////////////////////////////////////////////
    69057316  //    TGT_CMD to READ FIFO
    6906   ////////////////////////////////////////////////////////////////////////////////////
    6907 
    6908   if(cmd_read_fifo_put)
    6909   {
    6910     if(cmd_read_fifo_get)
    6911     {
    6912       m_cmd_read_addr_fifo.put_and_get((addr_t)(p_vci_tgt.address.read()));
    6913       m_cmd_read_length_fifo.put_and_get(p_vci_tgt.plen.read() >>2);
    6914       m_cmd_read_srcid_fifo.put_and_get(p_vci_tgt.srcid.read());
    6915       m_cmd_read_trdid_fifo.put_and_get(p_vci_tgt.trdid.read());
    6916       m_cmd_read_pktid_fifo.put_and_get(p_vci_tgt.pktid.read());
    6917     }
    6918     else
    6919     {
    6920       m_cmd_read_addr_fifo.simple_put((addr_t)(p_vci_tgt.address.read()));
    6921       m_cmd_read_length_fifo.simple_put(p_vci_tgt.plen.read() >>2);
    6922       m_cmd_read_srcid_fifo.simple_put(p_vci_tgt.srcid.read());
    6923       m_cmd_read_trdid_fifo.simple_put(p_vci_tgt.trdid.read());
    6924       m_cmd_read_pktid_fifo.simple_put(p_vci_tgt.pktid.read());
    6925     }
    6926   }
    6927   else
    6928   {
    6929     if(cmd_read_fifo_get)
    6930     {
    6931       m_cmd_read_addr_fifo.simple_get();
    6932       m_cmd_read_length_fifo.simple_get();
    6933       m_cmd_read_srcid_fifo.simple_get();
    6934       m_cmd_read_trdid_fifo.simple_get();
    6935       m_cmd_read_pktid_fifo.simple_get();
    6936     }
    6937   }
     7317  /////////////////////////////////////////////////////////////////////
     7318
     7319  m_cmd_read_addr_fifo.update(   cmd_read_fifo_get, cmd_read_fifo_put,
     7320                                 p_vci_tgt.address.read() );
     7321  m_cmd_read_length_fifo.update( cmd_read_fifo_get, cmd_read_fifo_put,
     7322                                 p_vci_tgt.plen.read()>>2 );
     7323  m_cmd_read_srcid_fifo.update(  cmd_read_fifo_get, cmd_read_fifo_put,
     7324                                 p_vci_tgt.srcid.read() );
     7325  m_cmd_read_trdid_fifo.update(  cmd_read_fifo_get, cmd_read_fifo_put,
     7326                                 p_vci_tgt.trdid.read() );
     7327  m_cmd_read_pktid_fifo.update(  cmd_read_fifo_get, cmd_read_fifo_put,
     7328                                 p_vci_tgt.pktid.read() );
     7329
    69387330  /////////////////////////////////////////////////////////////////////
    69397331  //    TGT_CMD to WRITE FIFO
     
    72647656  ////////////////////////////////////////////////////
    72657657
    7266   if(((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) &&
    7267       (r_ixr_rsp_fsm.read()   == IXR_RSP_TRT_READ)) ||
     7658  if(((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and
     7659      (r_ixr_rsp_fsm.read()   == IXR_RSP_TRT_READ)) or
    72687660      (r_ixr_rsp_fsm.read()   == IXR_RSP_ACK))
    72697661
     
    73337725      p_vci_tgt.rtrdid  = r_tgt_cmd_to_tgt_rsp_trdid.read();
    73347726      p_vci_tgt.rpktid  = r_tgt_cmd_to_tgt_rsp_pktid.read();
    7335       p_vci_tgt.rerror  = 0x1;
     7727      p_vci_tgt.rerror  = r_tgt_cmd_to_tgt_rsp_error.read();
    73367728      p_vci_tgt.reop    = true;
    73377729
     
    73687760    case TGT_RSP_WRITE:
    73697761      p_vci_tgt.rspval   = true;
    7370       if(((r_write_to_tgt_rsp_pktid.read() & 0x7) == TYPE_SC) && r_write_to_tgt_rsp_sc_fail.read())
     7762      if(((r_write_to_tgt_rsp_pktid.read() & 0x7) == TYPE_SC) and r_write_to_tgt_rsp_sc_fail.read())
    73717763        p_vci_tgt.rdata  = 1;
    73727764      else
Note: See TracChangeset for help on using the changeset viewer.