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

Introducing a preliminary configuration interface in vci_mem_cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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();
Note: See TracChangeset for help on using the changeset viewer.