Changeset 656


Ignore:
Timestamp:
Mar 7, 2014, 10:24:17 AM (10 years ago)
Author:
cfuguet
Message:

TSAR FAULT TOLERANCE BRANCH

vci_simple_rom:

  • Introducing ROM component which can discard most significant bits when calling the load function of the loader. This allows us to replicate some code in several cluster as we can mask the cluster ID bits of the address.

vci_cc_vcache_wrapper:

  • Introducing a INST_PADDR_EXT register. This register allows to access addresses further than 4Gbytes when MMU is de-activated.
  • Introducing a way to initialize the INST_PADDR_EXT and DATA_ PADDR_EXT registers during reset.
Location:
branches/fault_tolerance/module/internal_component
Files:
9 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/fault_tolerance/module/internal_component/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h

    r616 r656  
    113113        DCACHE_XTN_IC_FLUSH,
    114114        DCACHE_XTN_IC_INVAL_PA,
     115        DCACHE_XTN_IC_PADDR_EXT,
    115116        DCACHE_XTN_IT_INVAL,
    116117        DCACHE_XTN_DC_FLUSH,
     
    322323    bool                                m_debug_ok;
    323324
     325    uint32_t                            m_dcache_paddr_ext_reset;
     326    uint32_t                            m_icache_paddr_ext_reset;
     327
    324328    ////////////////////////////////////////
    325329    // Communication with processor ISS
     
    399403    sc_signal<size_t>       r_icache_cc_send_way;           // ICACHE cc_send way
    400404    sc_signal<size_t>       r_icache_cc_send_updt_tab_idx;  // ICACHE cc_send update table index
     405
     406    // Physical address extension for data access
     407    sc_signal<uint32_t>     r_icache_paddr_ext;             // CP2 register (if vci_address > 32)
    401408
    402409    ///////////////////////////////
     
    747754    }
    748755
     756    /////////////////////////////////////////////////////////////
     757    // Set the m_dcache_paddr_ext_reset attribute
     758    //
     759    // The r_dcache_paddr_ext register will be initialized after
     760    // reset with the m_dcache_paddr_ext_reset value
     761    /////////////////////////////////////////////////////////////
     762    inline void set_dcache_paddr_ext_reset(uint32_t v)
     763    {
     764        m_dcache_paddr_ext_reset = v;
     765    }
     766
     767    /////////////////////////////////////////////////////////////
     768    // Set the m_icache_paddr_ext_reset attribute
     769    //
     770    // The r_icache_paddr_ext register will be initialized after
     771    // reset with the m_icache_paddr_ext_reset value
     772    /////////////////////////////////////////////////////////////
     773    inline void set_icache_paddr_ext_reset(uint32_t v)
     774    {
     775        m_icache_paddr_ext_reset = v;
     776    }
     777
    749778private:
    750779    void transition();
  • branches/fault_tolerance/module/internal_component/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp

    r627 r656  
    3232#include "../include/vci_cc_vcache_wrapper.h"
    3333
    34 #define DEBUG_DCACHE            1
    35 #define DEBUG_ICACHE            1
    36 #define DEBUG_CMD               0
     34#define DEBUG_DCACHE        1
     35#define DEBUG_ICACHE        1
     36#define DEBUG_CMD           0
    3737
    3838namespace soclib {
     
    8585        "DCACHE_XTN_IC_FLUSH",
    8686        "DCACHE_XTN_IC_INVAL_PA",
     87        "DCACHE_XTN_IC_PADDR_EXT"
    8788        "DCACHE_XTN_IT_INVAL",
    8889        "DCACHE_XTN_DC_FLUSH",
     
    190191/////////////////////////////////
    191192tmpl(/**/)::VciCcVCacheWrapper(
    192     sc_module_name                      name,
    193     const int                           proc_id,
    194     const MappingTable      &mtd,
    195     const IntTab                &srcid,
    196     const size_t                cc_global_id,
    197     const size_t                        itlb_ways,
    198     const size_t                        itlb_sets,
    199     const size_t                        dtlb_ways,
    200     const size_t                        dtlb_sets,
    201     const size_t                        icache_ways,
    202     const size_t                        icache_sets,
    203     const size_t                        icache_words,
    204     const size_t                        dcache_ways,
    205     const size_t                        dcache_sets,
    206     const size_t                        dcache_words,
    207     const size_t                        wbuf_nlines,
    208     const size_t                        wbuf_nwords,
    209     const size_t                        x_width,
    210     const size_t                        y_width,
    211     const uint32_t                      max_frozen_cycles,
    212     const uint32_t                      debug_start_cycle,
    213     const bool                          debug_ok )
     193    sc_module_name          name,
     194    const int               proc_id,
     195    const MappingTable      &mtd,
     196    const IntTab            &srcid,
     197    const size_t            cc_global_id,
     198    const size_t            itlb_ways,
     199    const size_t            itlb_sets,
     200    const size_t            dtlb_ways,
     201    const size_t            dtlb_sets,
     202    const size_t            icache_ways,
     203    const size_t            icache_sets,
     204    const size_t            icache_words,
     205    const size_t            dcache_ways,
     206    const size_t            dcache_sets,
     207    const size_t            dcache_words,
     208    const size_t            wbuf_nlines,
     209    const size_t            wbuf_nwords,
     210    const size_t            x_width,
     211    const size_t            y_width,
     212    const uint32_t          max_frozen_cycles,
     213    const uint32_t          debug_start_cycle,
     214    const bool              debug_ok )
    214215    : soclib::caba::BaseModule(name),
    215216
     
    244245      m_debug_start_cycle( debug_start_cycle ),
    245246      m_debug_ok( debug_ok ),
     247      m_dcache_paddr_ext_reset(0),
     248      m_icache_paddr_ext_reset(0),
    246249
    247250      r_mmu_ptpr("r_mmu_ptpr"),
     
    371374      r_vci_rsp_ins_error("r_vci_rsp_ins_error"),
    372375      r_vci_rsp_data_error("r_vci_rsp_data_error"),
    373       r_vci_rsp_fifo_icache("r_vci_rsp_fifo_icache", 2),        // 2 words depth
    374       r_vci_rsp_fifo_dcache("r_vci_rsp_fifo_dcache", 2),        // 2 words depth
     376      r_vci_rsp_fifo_icache("r_vci_rsp_fifo_icache", 2),    // 2 words depth
     377      r_vci_rsp_fifo_dcache("r_vci_rsp_fifo_dcache", 2),    // 2 words depth
    375378
    376379      r_cc_send_fsm("r_cc_send_fsm"),
     
    380383      r_cc_receive_data_ins("r_cc_receive_data_ins"),
    381384      r_cc_receive_word_idx("r_cc_receive_word_idx"),
    382       r_cc_receive_updt_fifo_be("r_cc_receive_updt_fifo_be", 2),        // 2 words depth
    383       r_cc_receive_updt_fifo_data("r_cc_receive_updt_fifo_data", 2),    // 2 words depth
    384       r_cc_receive_updt_fifo_eop("r_cc_receive_updt_fifo_eop", 2),      // 2 words depth
     385      r_cc_receive_updt_fifo_be("r_cc_receive_updt_fifo_be", 2),    // 2 words depth
     386      r_cc_receive_updt_fifo_data("r_cc_receive_updt_fifo_data", 2),    // 2 words depth
     387      r_cc_receive_updt_fifo_eop("r_cc_receive_updt_fifo_eop", 2),  // 2 words depth
    385388
    386389      r_cc_receive_icache_req("r_cc_receive_icache_req"),
     
    528531{
    529532    bool        cache_hit;
    530     size_t          cache_way = 0;
    531     size_t          cache_set = 0;
    532     size_t          cache_word = 0;
    533     uint32_t    cache_rdata = 0;
     533    size_t      cache_way = 0;
     534    size_t      cache_set = 0;
     535    size_t      cache_word = 0;
     536    uint32_t    cache_rdata = 0;
    534537
    535538    cache_hit = r_dcache.read_neutral( addr,
     
    547550                  << " / DATA = " << cache_rdata
    548551                  << " / WAY = " << cache_way << std::endl;
    549             m_debug_previous_d_hit = cache_hit;
     552        m_debug_previous_d_hit = cache_hit;
    550553    }
    551554
     
    564567                  << " / DATA = " << cache_rdata
    565568                  << " / WAY = " << cache_way << std::endl;
    566             m_debug_previous_i_hit = cache_hit;
     569        m_debug_previous_i_hit = cache_hit;
    567570    }
    568571}
     
    735738
    736739        // reset data physical address extension
    737         r_dcache_paddr_ext = 0;
     740        r_dcache_paddr_ext = m_dcache_paddr_ext_reset;
     741
     742        // reset inst physical address extension
     743        r_icache_paddr_ext = m_icache_paddr_ext_reset;
    738744
    739745        // reset dcache directory extension
     
    752758        r_mmu_mode = 0x3;
    753759
    754             // No request from ICACHE FSM to CMD FSM
     760        // No request from ICACHE FSM to CMD FSM
    755761        r_icache_miss_req          = false;
    756762        r_icache_unc_req           = false;
     
    809815        m_debug_previous_i_hit     = false;
    810816        m_debug_previous_d_hit     = false;
    811         m_debug_activated              = false;
     817        m_debug_activated          = false;
    812818
    813819        // activity counters
     
    870876        m_cost_data_tlb_occup_cache_frz  = 0;
    871877
    872         m_cpt_ins_tlb_inval       = 0;
    873         m_cpt_data_tlb_inval      = 0;
    874         m_cost_ins_tlb_inval_frz  = 0;
    875         m_cost_data_tlb_inval_frz = 0;
     878        m_cpt_ins_tlb_inval       = 0;
     879        m_cpt_data_tlb_inval      = 0;
     880        m_cost_ins_tlb_inval_frz  = 0;
     881        m_cost_data_tlb_inval_frz = 0;
    876882
    877883        m_cpt_cc_broadcast   = 0;
    878884
    879             m_cost_updt_data_frz  = 0;
    880             m_cost_inval_ins_frz  = 0;
    881             m_cost_inval_data_frz = 0;
    882             m_cost_broadcast_frz  = 0;
    883 
    884             m_cpt_cc_cleanup_data = 0;
    885             m_cpt_cc_cleanup_ins  = 0;
     885        m_cost_updt_data_frz  = 0;
     886        m_cost_inval_ins_frz  = 0;
     887        m_cost_inval_data_frz = 0;
     888        m_cost_broadcast_frz  = 0;
     889
     890        m_cpt_cc_cleanup_data = 0;
     891        m_cpt_cc_cleanup_ins  = 0;
    886892
    887893        m_cpt_itlbmiss_transaction      = 0;
     
    906912        m_cpt_read              = 0;
    907913        m_cpt_write             = 0;
    908             m_cpt_cc_update_data = 0;
    909             m_cpt_cc_inval_ins   = 0;
    910             m_cpt_cc_inval_data  = 0;
     914        m_cpt_cc_update_data = 0;
     915        m_cpt_cc_inval_ins   = 0;
     916        m_cpt_cc_inval_data  = 0;
    911917*/
    912918
     
    10181024    {
    10191025    /////////////////
    1020     case ICACHE_IDLE:   // In this state, we handle processor requests, XTN requests,
     1026    case ICACHE_IDLE:   // In this state, we handle processor requests, XTN requests,
    10211027                        // and coherence requests with a fixed priority:
    10221028                        // 1/ Coherence requests                        => ICACHE_CC_CHECK
     
    10431049
    10441050        // XTN requests sent by DCACHE FSM
    1045         // These request are not executed in this IDLE state, because
    1046         // they require access to icache or itlb, that are already accessed
     1051        // These request are not executed in this IDLE state (except XTN_INST_PADDR_EXT),
     1052        // because they require access to icache or itlb, that are already accessed
    10471053        if ( r_dcache_xtn_req.read() )
    10481054        {
     
    10661072            else if ( (int)r_dcache_xtn_opcode.read() == (int)iss_t::XTN_MMU_ICACHE_PA_INV)
    10671073            {
    1068                         if (sizeof(paddr_t) <= 32)
     1074                if (sizeof(paddr_t) <= 32)
    10691075                {
    1070                                 assert(r_mmu_word_hi.read() == 0 &&
    1071                                 "illegal XTN request in ICACHE: high bits should be 0 for 32bit paddr");
    1072                                 r_icache_vci_paddr = (paddr_t)r_mmu_word_lo.read();
     1076                    assert(r_mmu_word_hi.read() == 0 &&
     1077                    "illegal XTN request in ICACHE: high bits should be 0 for 32bit paddr");
     1078                    r_icache_vci_paddr = (paddr_t)r_mmu_word_lo.read();
    10731079                }
    10741080                else
    10751081                {
    1076                                 r_icache_vci_paddr = (paddr_t)r_mmu_word_hi.read() << 32 |
    1077                                                          (paddr_t)r_mmu_word_lo.read();
    1078                         }
    1079                 r_icache_fsm         = ICACHE_XTN_CACHE_INVAL_PA;
     1082                    r_icache_vci_paddr = (paddr_t)r_mmu_word_hi.read() << 32 |
     1083                                         (paddr_t)r_mmu_word_lo.read();
     1084                }
     1085                r_icache_fsm = ICACHE_XTN_CACHE_INVAL_PA;
     1086            }
     1087            else if ( (int)r_dcache_xtn_opcode.read() == (int)iss_t::XTN_INST_PADDR_EXT)
     1088            {
     1089                r_icache_paddr_ext = r_dcache_save_wdata.read();
     1090                r_dcache_xtn_req   = false;
    10801091            }
    10811092            else
     
    10901101        if ( m_ireq.valid )
    10911102        {
    1092             bool            cacheable;
    1093             paddr_t         paddr;
     1103            bool        cacheable;
     1104            paddr_t     paddr;
    10941105            bool        tlb_hit = false;
    10951106            pte_info_t  tlb_flags;
     
    11161127                                            &paddr,
    11171128                                            &tlb_flags,
    1118                                             &tlb_nline, // unused
    1119                                             &tlb_way,   // unused
    1120                                             &tlb_set ); // unused
     1129                                            &tlb_nline, // unused
     1130                                            &tlb_way,   // unused
     1131                                            &tlb_set ); // unused
    11211132            }
    11221133            else
    11231134            {
    1124                 paddr = (paddr_t)m_ireq.addr;
     1135                if (vci_param::N > 32)
     1136                {
     1137                    paddr =  (paddr_t)m_ireq.addr |
     1138                            ((paddr_t)r_icache_paddr_ext.read() << 32);
     1139                }
     1140                else
     1141                {
     1142                    paddr = (paddr_t)m_ireq.addr;
     1143                }
    11251144            }
    11261145
     
    11481167            //   and there is no access rights checking
    11491168
    1150             if ( not (r_mmu_mode.read() & INS_TLB_MASK) )       // tlb not activated:
     1169            if ( not (r_mmu_mode.read() & INS_TLB_MASK) )   // tlb not activated:
    11511170            {
    11521171                // cacheability
     
    11541173                else     cacheable = m_cacheability_table[(uint64_t)m_ireq.addr];
    11551174            }
    1156             else                                                        // itlb activated
    1157             {
    1158                 if ( tlb_hit )  // ITLB hit
     1175            else                                // itlb activated
     1176            {
     1177                if ( tlb_hit )  // ITLB hit
    11591178                {
    11601179                    // cacheability
     
    12001219            if ( cacheable )
    12011220            {
    1202                 if (cache_state == CACHE_SLOT_STATE_EMPTY)          // cache miss
     1221                if (cache_state == CACHE_SLOT_STATE_EMPTY)      // cache miss
    12031222                {
    12041223
     
    12151234                   r_icache_miss_req = true;
    12161235                }
    1217                 else if (cache_state == CACHE_SLOT_STATE_ZOMBI )        // pending cleanup
     1236                else if (cache_state == CACHE_SLOT_STATE_ZOMBI )    // pending cleanup
    12181237                {
    12191238                    // stalled until cleanup is acknowledged
    12201239                    r_icache_fsm       = ICACHE_IDLE;
    12211240                }
    1222                 else                                                // cache hit
     1241                else                                        // cache hit
    12231242                {
    12241243
     
    12371256                }
    12381257            }
    1239             else                // non cacheable read
     1258            else                // non cacheable read
    12401259            {
    12411260                r_icache_unc_req  = true;
     
    12551274    }
    12561275    /////////////////////
    1257     case ICACHE_TLB_WAIT:       // Waiting the itlb update by the DCACHE FSM after a tlb miss
     1276    case ICACHE_TLB_WAIT:   // Waiting the itlb update by the DCACHE FSM after a tlb miss
    12581277                            // the itlb is udated by the DCACHE FSM, as well as the
    12591278                            // r_mmu_ietr and r_mmu_ibvar registers in case of error.
     
    12901309                r_icache_fsm             = ICACHE_IDLE;
    12911310            }
    1292             else                                // tlb updated : return to IDLE state
     1311            else                // tlb updated : return to IDLE state
    12931312            {
    12941313                r_icache_fsm  = ICACHE_IDLE;
     
    12981317    }
    12991318    //////////////////////////
    1300     case ICACHE_XTN_TLB_FLUSH:          // invalidate in one cycle all non global TLB entries
     1319    case ICACHE_XTN_TLB_FLUSH:      // invalidate in one cycle all non global TLB entries
    13011320    {
    13021321        r_itlb.flush();
     
    13061325    }
    13071326    ////////////////////////////
    1308     case ICACHE_XTN_CACHE_FLUSH:        // Invalidate sequencially all cache lines, using
     1327    case ICACHE_XTN_CACHE_FLUSH:    // Invalidate sequencially all cache lines, using
    13091328                                    // r_icache_flush_count as a slot counter,
    1310                                         // looping in this state until all slots are visited.
     1329                                    // looping in this state until all slots are visited.
    13111330                                    // It can require two cycles per slot:
    13121331                                    // We test here the slot state, and make the actual inval
    13131332                                    // (if line is valid) in ICACHE_XTN_CACHE_FLUSH_GO state.
    1314                                         // A cleanup request is generated for each valid line
     1333                                    // A cleanup request is generated for each valid line
    13151334    {
    13161335        // coherence clack interrupt
     
    13341353            int       state;
    13351354            paddr_t   tag;
    1336             size_t        way = r_icache_flush_count.read()/m_icache_sets;
    1337             size_t        set = r_icache_flush_count.read()%m_icache_sets;
     1355            size_t    way = r_icache_flush_count.read()/m_icache_sets;
     1356            size_t    set = r_icache_flush_count.read()%m_icache_sets;
    13381357
    13391358#ifdef INSTRUMENTATION
     
    13611380                      (m_icache_sets*m_icache_ways - 1) )  // last slot
    13621381            {
    1363                 r_dcache_xtn_req = false;
     1382                r_dcache_xtn_req = false;
    13641383                m_drsp.valid     = true;
    1365                 r_icache_fsm    = ICACHE_IDLE;
     1384                r_icache_fsm    = ICACHE_IDLE;
    13661385            }
    13671386
     
    13761395    }
    13771396    ///////////////////////////////
    1378     case ICACHE_XTN_CACHE_FLUSH_GO:         // Switch slot state to ZOMBI for an XTN flush
    1379     {
    1380         size_t    way = r_icache_miss_way.read();
    1381         size_t    set = r_icache_miss_set.read();
     1397    case ICACHE_XTN_CACHE_FLUSH_GO:     // Switch slot state to ZOMBI for an XTN flush
     1398    {
     1399        size_t    way = r_icache_miss_way.read();
     1400        size_t    set = r_icache_miss_set.read();
    13821401
    13831402#ifdef INSTRUMENTATION
     
    13921411                      (m_icache_sets*m_icache_ways - 1) )  // last slot
    13931412        {
    1394                 r_dcache_xtn_req = false;
     1413            r_dcache_xtn_req = false;
    13951414            m_drsp.valid     = true;
    1396                 r_icache_fsm    = ICACHE_IDLE;
     1415            r_icache_fsm    = ICACHE_IDLE;
    13971416        }
    13981417        else
     
    14041423
    14051424    //////////////////////////
    1406     case ICACHE_XTN_TLB_INVAL:          // invalidate one TLB entry selected by the virtual address
    1407                                                     // stored in the r_dcache_save_wdata register
     1425    case ICACHE_XTN_TLB_INVAL:      // invalidate one TLB entry selected by the virtual address
     1426                                    // stored in the r_dcache_save_wdata register
    14081427    {
    14091428        r_itlb.inval(r_dcache_save_wdata.read());
     
    14131432    }
    14141433    ///////////////////////////////
    1415     case ICACHE_XTN_CACHE_INVAL_VA:     // Selective cache line invalidate with virtual address
     1434    case ICACHE_XTN_CACHE_INVAL_VA: // Selective cache line invalidate with virtual address
    14161435                                    // requires 3 cycles (in case of hit on itlb and icache).
    1417                                                         // In this state, access TLB to translate virtual address
    1418                                                     // stored in the r_dcache_save_wdata register.
    1419     {
    1420         paddr_t         paddr;
    1421         bool            hit;
     1436                                    // In this state, access TLB to translate virtual address
     1437                                    // stored in the r_dcache_save_wdata register.
     1438    {
     1439        paddr_t     paddr;
     1440        bool        hit;
    14221441
    14231442        // read physical address in TLB when MMU activated
    1424         if ( r_mmu_mode.read() & INS_TLB_MASK )         // itlb activated
     1443        if ( r_mmu_mode.read() & INS_TLB_MASK )     // itlb activated
    14251444        {
    14261445
     
    14311450                                   &paddr);
    14321451        }
    1433         else                                            // itlb not activated
    1434         {
    1435             paddr       = (paddr_t)r_dcache_save_wdata.read();
    1436             hit         = true;
    1437         }
    1438 
    1439         if ( hit )              // continue the selective inval process
     1452        else                        // itlb not activated
     1453        {
     1454            paddr   = (paddr_t)r_dcache_save_wdata.read();
     1455            hit     = true;
     1456        }
     1457
     1458        if ( hit )      // continue the selective inval process
    14401459        {
    14411460            r_icache_vci_paddr    = paddr;
    14421461            r_icache_fsm          = ICACHE_XTN_CACHE_INVAL_PA;
    14431462        }
    1444         else                    // miss : send a request to DCACHE FSM
     1463        else            // miss : send a request to DCACHE FSM
    14451464        {
    14461465
     
    14491468#endif
    14501469            r_icache_tlb_miss_req = true;
    1451                 r_icache_vaddr_save   = r_dcache_save_wdata.read();
     1470            r_icache_vaddr_save   = r_dcache_save_wdata.read();
    14521471            r_icache_fsm          = ICACHE_TLB_WAIT;
    14531472        }
     
    14551474    }
    14561475    ///////////////////////////////
    1457     case ICACHE_XTN_CACHE_INVAL_PA:     // selective invalidate cache line with physical address
     1476    case ICACHE_XTN_CACHE_INVAL_PA: // selective invalidate cache line with physical address
    14581477                                    // require 2 cycles. In this state, we read directory
    14591478                                    // with address stored in r_icache_vci_paddr register.
    14601479    {
    14611480        int         state;
    1462         size_t          way;
    1463         size_t          set;
    1464         size_t          word;
     1481        size_t      way;
     1482        size_t      set;
     1483        size_t      word;
    14651484
    14661485#ifdef INSTRUMENTATION
     
    14731492                          &word);
    14741493
    1475         if ( state == CACHE_SLOT_STATE_VALID )  // inval to be done
     1494        if ( state == CACHE_SLOT_STATE_VALID )  // inval to be done
    14761495        {
    14771496            r_icache_miss_way = way;
     
    14791498            r_icache_fsm      = ICACHE_XTN_CACHE_INVAL_GO;
    14801499        }
    1481         else            // miss : acknowlege the XTN request and return
     1500        else        // miss : acknowlege the XTN request and return
    14821501        {
    14831502            r_dcache_xtn_req = false;
     
    15431562        bool        found;
    15441563        bool        cleanup;
    1545         size_t          way;
    1546         size_t          set;
    1547         paddr_t         victim;
     1564        size_t      way;
     1565        size_t      set;
     1566        paddr_t     victim;
    15481567
    15491568#ifdef INSTRUMENTATION
     
    16031622    }
    16041623    ///////////////////////
    1605     case ICACHE_MISS_CLEAN:              // switch the slot to zombi state
     1624    case ICACHE_MISS_CLEAN:          // switch the slot to zombi state
    16061625    {
    16071626        if (m_ireq.valid) m_cost_ins_miss_frz++;
     
    16271646    }
    16281647    //////////////////////
    1629     case ICACHE_MISS_WAIT:        // waiting response from VCI_RSP FSM
     1648    case ICACHE_MISS_WAIT:    // waiting response from VCI_RSP FSM
    16301649    {
    16311650        if (m_ireq.valid) m_cost_ins_miss_frz++;
     
    16741693    }
    16751694    ///////////////////////////
    1676     case ICACHE_MISS_DATA_UPDT:   // update the cache (one word per cycle)
     1695    case ICACHE_MISS_DATA_UPDT:   // update the cache (one word per cycle)
    16771696    {
    16781697        if ( m_ireq.valid ) m_cost_ins_miss_frz++;
    16791698
    1680         if ( r_vci_rsp_fifo_icache.rok() )      // response available
     1699        if ( r_vci_rsp_fifo_icache.rok() )  // response available
    16811700        {
    16821701
     
    17021721            r_icache_miss_word = r_icache_miss_word.read() + 1;
    17031722
    1704             if ( r_icache_miss_word.read() == m_icache_words-1 )        // last word
     1723            if ( r_icache_miss_word.read() == m_icache_words-1 )    // last word
    17051724            {
    17061725                r_icache_fsm = ICACHE_MISS_DIR_UPDT;
     
    17101729    }
    17111730    //////////////////////////
    1712     case ICACHE_MISS_DIR_UPDT:  // Stalled if a victim line has been evicted,
     1731    case ICACHE_MISS_DIR_UPDT:  // Stalled if a victim line has been evicted,
    17131732                                // and the cleanup ack has not been received,
    17141733                                // as indicated by r_icache_miss_clack.
     
    18071826    }
    18081827    ////////////////////
    1809     case ICACHE_UNC_WAIT:       // waiting a response to an uncacheable read from VCI_RSP FSM
     1828    case ICACHE_UNC_WAIT:   // waiting a response to an uncacheable read from VCI_RSP FSM
    18101829    {
    18111830        // coherence clack interrupt
     
    18481867    }
    18491868    /////////////////////
    1850     case ICACHE_CC_CHECK:       // This state is the entry point of a sub-fsm
     1869    case ICACHE_CC_CHECK:       // This state is the entry point of a sub-fsm
    18511870                                // handling coherence requests.
    18521871                                // if there is a matching pending miss, it is
     
    19381957        // CC request handler
    19391958
    1940         int             state = 0;
    1941         size_t      way = 0;
    1942         size_t      set = 0;
    1943         size_t      word = 0;
     1959        int         state = 0;
     1960        size_t      way = 0;
     1961        size_t      set = 0;
     1962        size_t      word = 0;
    19441963
    19451964#ifdef INSTRUMENTATION
     
    19892008    }
    19902009    /////////////////////
    1991     case ICACHE_CC_INVAL:       // hit inval : switch slot to ZOMBI state
     2010    case ICACHE_CC_INVAL:   // hit inval : switch slot to ZOMBI state
    19922011    {
    19932012        assert (not r_icache_cc_send_req.read() &&
     
    20252044    }
    20262045    ////////////////////
    2027     case ICACHE_CC_UPDT:        // hit update : write one word per cycle
     2046    case ICACHE_CC_UPDT:    // hit update : write one word per cycle
    20282047    {
    20292048        assert (not r_icache_cc_send_req.read() &&
     
    20642083        }
    20652084
    2066         if ( r_cc_receive_updt_fifo_eop.read() )        // last word
     2085        if ( r_cc_receive_updt_fifo_eop.read() )    // last word
    20672086        {
    20682087            // no need to write in the cache anymore
     
    22042223    {
    22052224        paddr_t     paddr;                          // physical address
    2206         pte_info_t      tlb_flags;
    2207         size_t          tlb_way;
    2208         size_t          tlb_set;
    2209         paddr_t         tlb_nline = 0;
    2210         size_t          cache_way;
    2211         size_t          cache_set;
    2212         size_t          cache_word;
    2213         uint32_t        cache_rdata = 0;
    2214         bool        tlb_hit = false;
    2215         int             cache_state = CACHE_SLOT_STATE_EMPTY;
     2225        pte_info_t  tlb_flags;
     2226        size_t      tlb_way;
     2227        size_t      tlb_set;
     2228        paddr_t     tlb_nline = 0;
     2229        size_t      cache_way;
     2230        size_t      cache_set;
     2231        size_t      cache_word;
     2232        uint32_t    cache_rdata = 0;
     2233        bool        tlb_hit = false;
     2234        int         cache_state = CACHE_SLOT_STATE_EMPTY;
    22162235
    22172236        bool        tlb_inval_required = false;     // request TLB inval after cache update
     
    23012320            {
    23022321                tlb_inval_required       = true;
    2303                     r_dcache_tlb_inval_set   = 0;
    2304                     r_dcache_tlb_inval_line  = r_dcache_save_paddr.read()>>
     2322                r_dcache_tlb_inval_set   = 0;
     2323                r_dcache_tlb_inval_line  = r_dcache_save_paddr.read()>>
    23052324                                           (uint32_log2(m_dcache_words<<2));
    2306                     r_dcache_in_tlb[way*m_dcache_sets+set] = false;
     2325                r_dcache_in_tlb[way*m_dcache_sets+set] = false;
    23072326            }
    23082327            else if ( r_dcache_contains_ptd[way*m_dcache_sets+set] )
     
    23102329                r_itlb.reset();
    23112330                r_dtlb.reset();
    2312                     r_dcache_contains_ptd[way*m_dcache_sets+set] = false;
     2331                r_dcache_contains_ptd[way*m_dcache_sets+set] = false;
    23132332            }
    23142333
     
    24672486                        break;
    24682487
     2488                    case iss_t::XTN_INST_PADDR_EXT:
     2489                        m_drsp.rdata = r_icache_paddr_ext.read();
     2490                        m_drsp.valid = true;
     2491                        m_drsp.error = false;
     2492                        break;
     2493
    24692494                    default:
    24702495                        r_mmu_detr = MMU_READ_UNDEFINED_XTN;
     
    25082533                    switch( xtn_opcode )
    25092534                    {
    2510                     case iss_t::XTN_PTPR:                       // itlb & dtlb must be flushed
     2535                    case iss_t::XTN_PTPR:               // itlb & dtlb must be flushed
    25112536                        r_dcache_xtn_req = true;
    25122537                        r_dcache_fsm     = DCACHE_XTN_SWITCH;
    25132538                        break;
    25142539
    2515                     case iss_t::XTN_TLB_MODE:                   // no cache or tlb access
     2540                    case iss_t::XTN_TLB_MODE:           // no cache or tlb access
    25162541                        r_mmu_mode       = m_dreq.wdata;
    25172542                        m_drsp.valid     = true;
     
    25192544                        break;
    25202545
    2521                     case iss_t::XTN_DTLB_INVAL:                 // dtlb access
     2546                    case iss_t::XTN_DTLB_INVAL:             // dtlb access
    25222547                        r_dcache_fsm     = DCACHE_XTN_DT_INVAL;
    25232548                        break;
    25242549
    2525                     case iss_t::XTN_ITLB_INVAL:                 // itlb access
     2550                    case iss_t::XTN_ITLB_INVAL:             // itlb access
    25262551                        r_dcache_xtn_req = true;
    25272552                        r_dcache_fsm     = DCACHE_XTN_IT_INVAL;
    25282553                        break;
    25292554
    2530                     case iss_t::XTN_DCACHE_INVAL:               // dcache, dtlb & itlb access
     2555                    case iss_t::XTN_DCACHE_INVAL:           // dcache, dtlb & itlb access
    25312556                        r_dcache_fsm     = DCACHE_XTN_DC_INVAL_VA;
    25322557                        break;
    25332558
    2534                     case iss_t::XTN_MMU_DCACHE_PA_INV:          // dcache, dtlb & itlb access
     2559                    case iss_t::XTN_MMU_DCACHE_PA_INV:      // dcache, dtlb & itlb access
    25352560                        r_dcache_fsm     = DCACHE_XTN_DC_INVAL_PA;
    25362561                        if (sizeof(paddr_t) <= 32)
     
    25472572                        break;
    25482573
    2549                     case iss_t::XTN_DCACHE_FLUSH:              // itlb and dtlb must be reset
     2574                    case iss_t::XTN_DCACHE_FLUSH:              // itlb and dtlb must be reset
    25502575                        r_dcache_flush_count = 0;
    25512576                        r_dcache_fsm     = DCACHE_XTN_DC_FLUSH;
    25522577                        break;
    25532578
    2554                     case iss_t::XTN_ICACHE_INVAL:               // icache and itlb access
     2579                    case iss_t::XTN_ICACHE_INVAL:           // icache and itlb access
    25552580                        r_dcache_xtn_req = true;
    25562581                        r_dcache_fsm     = DCACHE_XTN_IC_INVAL_VA;
    25572582                        break;
    25582583
    2559                     case iss_t::XTN_MMU_ICACHE_PA_INV:          // icache access
     2584                    case iss_t::XTN_MMU_ICACHE_PA_INV:      // icache access
    25602585                        r_dcache_xtn_req = true;
    25612586                        r_dcache_fsm     = DCACHE_XTN_IC_INVAL_PA;
    25622587                        break;
    25632588
    2564                     case iss_t::XTN_ICACHE_FLUSH:               // icache access
     2589                    case iss_t::XTN_ICACHE_FLUSH:           // icache access
    25652590                        r_dcache_xtn_req = true;
    25662591                        r_dcache_fsm     = DCACHE_XTN_IC_FLUSH;
    25672592                        break;
    25682593
    2569                     case iss_t::XTN_SYNC:                       // wait until write buffer empty
     2594                    case iss_t::XTN_SYNC:                   // wait until write buffer empty
    25702595                        r_dcache_fsm     = DCACHE_XTN_SYNC;
    25712596                        break;
    25722597
    2573                     case iss_t::XTN_MMU_WORD_LO:                // no cache or tlb access
     2598                    case iss_t::XTN_MMU_WORD_LO:        // no cache or tlb access
    25742599                        r_mmu_word_lo    = m_dreq.wdata;
    25752600                        m_drsp.valid     = true;
     
    25772602                        break;
    25782603
    2579                     case iss_t::XTN_MMU_WORD_HI:                // no cache or tlb access
     2604                    case iss_t::XTN_MMU_WORD_HI:        // no cache or tlb access
    25802605                        r_mmu_word_hi    = m_dreq.wdata;
    25812606                        m_drsp.valid     = true;
     
    25952620                    break;
    25962621
    2597                         case iss_t::XTN_ICACHE_PREFETCH:                // not implemented : no action
    2598                         case iss_t::XTN_DCACHE_PREFETCH:                // not implemented : no action
     2622                    case iss_t::XTN_INST_PADDR_EXT:     // no cache or tlb access
     2623                        r_dcache_xtn_req = true;
     2624                        r_dcache_fsm     = DCACHE_XTN_IC_PADDR_EXT;
     2625                    break;
     2626
     2627                    case iss_t::XTN_ICACHE_PREFETCH:        // not implemented : no action
     2628                    case iss_t::XTN_DCACHE_PREFETCH:        // not implemented : no action
    25992629                        m_drsp.valid     = true;
    26002630                        r_dcache_fsm     = DCACHE_IDLE;
    2601                             break;
     2631                    break;
    26022632
    26032633                    default:
     
    26222652            else
    26232653            {
    2624                 bool        valid_req;
    2625                 bool        cacheable;
    2626 
    2627                 if ( not (r_mmu_mode.read() & DATA_TLB_MASK) )          // dtlb not activated
     2654                bool        valid_req;
     2655                bool        cacheable;
     2656
     2657                if ( not (r_mmu_mode.read() & DATA_TLB_MASK) )      // dtlb not activated
    26282658                {
    26292659                    valid_req     = true;
     
    26322662                    else cacheable = m_cacheability_table[(uint64_t)m_dreq.addr];
    26332663                }
    2634                 else                                                                       // dtlb activated
     2664                else                                               // dtlb activated
    26352665                {
    2636                     if ( tlb_hit )                                      // tlb hit
     2666                    if ( tlb_hit )                  // tlb hit
    26372667                    {
    26382668                        // cacheability
     
    26842714                        }
    26852715                    }
    2686                     else                                                // tlb miss
     2716                    else                        // tlb miss
    26872717                    {
    26882718                        valid_req            = false;
     
    26932723                }    // end DTLB activated
    26942724
    2695                 if ( valid_req )        // processor request is valid (after MMU check)
     2725                if ( valid_req )    // processor request is valid (after MMU check)
    26962726                {
    26972727                    // READ request
     
    27022732                          and not r_dcache_updt_req.read() )
    27032733                    {
    2704                         if ( cacheable )                // cacheable read
     2734                        if ( cacheable )            // cacheable read
    27052735                        {
    27062736                            if ( cache_state == CACHE_SLOT_STATE_EMPTY )   // cache miss
     
    27492779                            }
    27502780                        }
    2751                         else                                    // uncacheable read
     2781                        else                    // uncacheable read
    27522782                        {
    27532783                            r_dcache_vci_paddr      = paddr;
     
    27942824                    {
    27952825                        if ( (r_mmu_mode.read() & DATA_TLB_MASK )
    2796                               and not tlb_flags.d )             // Dirty bit must be set
     2826                              and not tlb_flags.d )     // Dirty bit must be set
    27972827                        {
    27982828                            // The PTE physical address is obtained from the nline value (dtlb),
    27992829                            // and from the virtual address (word index)
    2800                             if ( tlb_flags.b )  // PTE1
     2830                            if ( tlb_flags.b )  // PTE1
    28012831                            {
    28022832                                r_dcache_dirty_paddr = (paddr_t)(tlb_nline*(m_dcache_words<<2)) |
    28032833                                                       (paddr_t)((m_dreq.addr>>19) & 0x3c);
    28042834                            }
    2805                             else                // PTE2
     2835                            else        // PTE2
    28062836                            {
    28072837                                r_dcache_dirty_paddr = (paddr_t)(tlb_nline*(m_dcache_words<<2)) |
     
    28102840                            r_dcache_fsm      = DCACHE_DIRTY_GET_PTE;
    28112841                        }
    2812                         else                                    // Write request accepted
     2842                        else                    // Write request accepted
    28132843                        {
    28142844#ifdef INSTRUMENTATION
     
    28522882                    {
    28532883                        if ( (r_mmu_mode.read() & DATA_TLB_MASK )
    2854                               and not tlb_flags.d )                     // Dirty bit must be set
     2884                              and not tlb_flags.d )         // Dirty bit must be set
    28552885                        {
    28562886                            // The PTE physical address is obtained from the nline value (dtlb),
    28572887                            // and the word index (virtual address)
    2858                             if ( tlb_flags.b )  // PTE1
     2888                            if ( tlb_flags.b )  // PTE1
    28592889                            {
    28602890                                r_dcache_dirty_paddr = (paddr_t)(tlb_nline*(m_dcache_words<<2)) |
    28612891                                                       (paddr_t)((m_dreq.addr>>19) & 0x3c);
    28622892                            }
    2863                             else                        // PTE2
     2893                            else            // PTE2
    28642894                            {
    28652895                                r_dcache_dirty_paddr = (paddr_t)(tlb_nline*(m_dcache_words<<2)) |
     
    28712901                            m_drsp.rdata = 0;
    28722902                        }
    2873                         else                                    // SC request accepted
     2903                        else                    // SC request accepted
    28742904                        {
    28752905#ifdef INSTRUMENTATION
     
    28882918                            else                                          // local fail
    28892919                            {
    2890                                     m_drsp.valid = true;
    2891                                     m_drsp.error = false;
    2892                                     m_drsp.rdata = 0x1;
     2920                                m_drsp.valid = true;
     2921                                m_drsp.error = false;
     2922                                m_drsp.rdata = 0x1;
    28932923                            }
    28942924                        }
     
    28992929
    29002930        // itlb miss request
    2901         else if ( r_icache_tlb_miss_req.read() and not wbuf_write_miss )
     2931        else if ( r_icache_tlb_miss_req.read() and not wbuf_write_miss )
    29022932        {
    29032933            r_dcache_tlb_ins    = true;
     
    29252955                          // r_mmu_ins_* or r_mmu_data* error reporting registers.
    29262956    {
    2927         uint32_t        ptba = 0;
    2928         bool            bypass;
    2929         paddr_t         pte_paddr;
     2957        uint32_t    ptba = 0;
     2958        bool        bypass;
     2959        paddr_t     pte_paddr;
    29302960
    29312961        // evaluate bypass in order to skip first level page table access
    2932         if ( r_dcache_tlb_ins.read() )                          // itlb miss
     2962        if ( r_dcache_tlb_ins.read() )              // itlb miss
    29332963        {
    29342964            bypass = r_itlb.get_bypass(r_dcache_tlb_vaddr.read(), &ptba);
    29352965        }
    2936         else                                                    // dtlb miss
     2966        else                            // dtlb miss
    29372967        {
    29382968            bypass = r_dtlb.get_bypass(r_dcache_tlb_vaddr.read(), &ptba);
     
    29713001    }
    29723002    /////////////////////////
    2973     case DCACHE_TLB_PTE1_GET:   // try to read a PT1 entry in dcache
     3003    case DCACHE_TLB_PTE1_GET:   // try to read a PT1 entry in dcache
    29743004    {
    29753005        // coherence clack request (from DSPIN CLACK)
     
    29893019        }
    29903020
    2991         uint32_t        entry;
    2992         size_t          way;
    2993         size_t          set;
    2994         size_t          word;
     3021        uint32_t    entry;
     3022        size_t      way;
     3023        size_t      set;
     3024        size_t      word;
    29953025        int         cache_state;
    29963026        r_dcache.read( r_dcache_tlb_paddr.read(),
     
    30063036        if ( cache_state == CACHE_SLOT_STATE_VALID )   // hit in dcache
    30073037        {
    3008             if ( not (entry & PTE_V_MASK) )     // unmapped
     3038            if ( not (entry & PTE_V_MASK) ) // unmapped
    30093039            {
    30103040                if ( r_dcache_tlb_ins.read() )
     
    30383068
    30393069            }
    3040             else if( entry & PTE_T_MASK )       //  PTD : me must access PT2
     3070            else if( entry & PTE_T_MASK )   //  PTD : me must access PT2
    30413071            {
    30423072                // mark the cache line ac containing a PTD
     
    30443074
    30453075                // register bypass
    3046                 if ( r_dcache_tlb_ins.read() )          // itlb
     3076                if ( r_dcache_tlb_ins.read() )      // itlb
    30473077                {
    30483078                    r_itlb.set_bypass(r_dcache_tlb_vaddr.read(),
     
    30503080                                      r_dcache_tlb_paddr.read() / (m_icache_words<<2) );
    30513081                }
    3052                 else                                    // dtlb
     3082                else                    // dtlb
    30533083                {
    30543084                    r_dtlb.set_bypass(r_dcache_tlb_vaddr.read(),
     
    30743104#endif
    30753105            }
    3076             else                        //  PTE1 :  we must update the TLB
     3106            else            //  PTE1 :  we must update the TLB
    30773107            {
    30783108                r_dcache_in_tlb[m_icache_sets*way+set] = true;
     
    31023132            r_dcache_fsm   = DCACHE_TLB_PTE1_GET;
    31033133        }
    3104         else            // we must load the missing cache line in dcache
     3134        else        // we must load the missing cache line in dcache
    31053135        {
    31063136            r_dcache_vci_miss_req  = true;
     
    31223152    }
    31233153    ////////////////////////////
    3124     case DCACHE_TLB_PTE1_SELECT:        // select a slot for PTE1
    3125     {
    3126         size_t  way;
    3127         size_t  set;
     3154    case DCACHE_TLB_PTE1_SELECT:    // select a slot for PTE1
     3155    {
     3156        size_t  way;
     3157        size_t  set;
    31283158
    31293159        if ( r_dcache_tlb_ins.read() )
     
    31673197    }
    31683198    //////////////////////////
    3169     case DCACHE_TLB_PTE1_UPDT:  // write a new PTE1 in tlb after testing the L/R bit
     3199    case DCACHE_TLB_PTE1_UPDT:  // write a new PTE1 in tlb after testing the L/R bit
    31703200                                // - if L/R bit already set, exit the sub-fsm.
    31713201                                // - if not, we update the page table but we dont write
     
    31733203                                //   the coherence mechanism.
    31743204    {
    3175         paddr_t   nline    = r_dcache_tlb_paddr.read() >> (uint32_log2(m_dcache_words)+2);
     3205        paddr_t   nline    = r_dcache_tlb_paddr.read() >> (uint32_log2(m_dcache_words)+2);
    31763206        uint32_t  pte      = r_dcache_tlb_pte_flags.read();
    3177         bool      pt_updt  = false;
    3178         bool      local    = true;
     3207        bool      pt_updt  = false;
     3208        bool      local    = true;
    31793209
    31803210        // We should compute the access locality:
     
    31853215        // As long as this computation is not done, all access are local.
    31863216
    3187         if ( local )                                            // local access
     3217        if ( local )                        // local access
    31883218        {
    31893219            if ( not ((pte & PTE_L_MASK) == PTE_L_MASK) ) // we must set the L bit
     
    31963226            }
    31973227        }
    3198         else                                                    // remote access
     3228        else                            // remote access
    31993229        {
    32003230            if ( not ((pte & PTE_R_MASK) == PTE_R_MASK) ) // we must set the R bit
     
    32083238        }
    32093239
    3210         if ( not pt_updt )                                      // update TLB and return
     3240        if ( not pt_updt )                  // update TLB and return
    32113241        {
    32123242            if ( r_dcache_tlb_ins.read() )
    32133243            {
    3214                 r_itlb.write( true,             // 2M page
     3244                r_itlb.write( true,     // 2M page
    32153245                              pte,
    3216                               0,                // argument unused for a PTE1
     3246                              0,        // argument unused for a PTE1
    32173247                              r_dcache_tlb_vaddr.read(),
    32183248                              r_dcache_tlb_way.read(),
     
    32363266            else
    32373267            {
    3238                 r_dtlb.write( true,             // 2M page
     3268                r_dtlb.write( true,     // 2M page
    32393269                              pte,
    3240                               0,                // argument unused for a PTE1
     3270                              0,        // argument unused for a PTE1
    32413271                              r_dcache_tlb_vaddr.read(),
    32423272                              r_dcache_tlb_way.read(),
     
    32763306    }
    32773307    /////////////////////////
    3278     case DCACHE_TLB_PTE2_GET:   // Try to get a PTE2 (64 bits) in the dcache
     3308    case DCACHE_TLB_PTE2_GET:   // Try to get a PTE2 (64 bits) in the dcache
    32793309    {
    32803310        // coherence clack request (from DSPIN CLACK)
     
    32943324        }
    32953325
    3296         uint32_t        pte_flags;
    3297         uint32_t        pte_ppn;
    3298         size_t          way;
    3299         size_t          set;
    3300         size_t          word;
     3326        uint32_t    pte_flags;
     3327        uint32_t    pte_ppn;
     3328        size_t      way;
     3329        size_t      set;
     3330        size_t      word;
    33013331        int         cache_state;
    33023332
     
    33143344        if ( cache_state == CACHE_SLOT_STATE_VALID )   // hit in dcache
    33153345        {
    3316             if ( not (pte_flags & PTE_V_MASK) ) // unmapped
     3346            if ( not (pte_flags & PTE_V_MASK) ) // unmapped
    33173347            {
    33183348                if ( r_dcache_tlb_ins.read() )
     
    33423372#endif
    33433373            }
    3344             else                                // mapped : we must update the TLB
     3374            else                // mapped : we must update the TLB
    33453375            {
    33463376                r_dcache_in_tlb[m_dcache_sets*way+set] = true;
     
    34053435        {
    34063436            r_itlb.select( r_dcache_tlb_vaddr.read(),
    3407                            false,       // PTE2
     3437                           false,   // PTE2
    34083438                           &way,
    34093439                           &set );
     
    34153445        {
    34163446            r_dtlb.select( r_dcache_tlb_vaddr.read(),
    3417                            false,       // PTE2
     3447                           false,   // PTE2
    34183448                           &way,
    34193449                           &set );
     
    34423472    }
    34433473    //////////////////////////
    3444     case DCACHE_TLB_PTE2_UPDT:  // write a new PTE2 in tlb after testing the L/R bit
     3474    case DCACHE_TLB_PTE2_UPDT:  // write a new PTE2 in tlb after testing the L/R bit
    34453475                                // - if L/R bit already set, exit the sub-fsm.
    34463476                                // - if not, we update the page table but we dont write
     
    34483478                                //   the coherence mechanism.
    34493479    {
    3450         paddr_t         nline     = r_dcache_tlb_paddr.read() >> (uint32_log2(m_dcache_words)+2);
     3480        paddr_t         nline     = r_dcache_tlb_paddr.read() >> (uint32_log2(m_dcache_words)+2);
    34513481        uint32_t        pte_flags = r_dcache_tlb_pte_flags.read();
    34523482        uint32_t        pte_ppn   = r_dcache_tlb_pte_ppn.read();
     
    34613491        // As long as this computation is not done, all access are local.
    34623492
    3463         if ( local )                                            // local access
     3493        if ( local )                        // local access
    34643494        {
    34653495            if ( not ((pte_flags & PTE_L_MASK) == PTE_L_MASK) ) // we must set the L bit
     
    34693499                r_dcache_vci_cas_new   = pte_flags | PTE_L_MASK;
    34703500                pte_flags              = pte_flags | PTE_L_MASK;
    3471                         r_dcache_tlb_pte_flags = pte_flags;
     3501                r_dcache_tlb_pte_flags = pte_flags;
    34723502            }
    34733503        }
     
    34803510                r_dcache_vci_cas_new   = pte_flags | PTE_R_MASK;
    34813511                pte_flags              = pte_flags | PTE_R_MASK;
    3482                         r_dcache_tlb_pte_flags = pte_flags;
     3512                r_dcache_tlb_pte_flags = pte_flags;
    34833513            }
    34843514        }
     
    34883518            if ( r_dcache_tlb_ins.read() )
    34893519            {
    3490                 r_itlb.write( false,    // 4K page
     3520                r_itlb.write( false,    // 4K page
    34913521                              pte_flags,
    34923522                              pte_ppn,
     
    35123542            else
    35133543            {
    3514                 r_dtlb.write( false,    // 4K page
     3544                r_dtlb.write( false,    // 4K page
    35153545                              pte_flags,
    35163546                              pte_ppn,
     
    35393569        else                                   // update page table but not TLB
    35403570        {
    3541             r_dcache_fsm = DCACHE_TLB_LR_UPDT;  // dcache and page table update
     3571            r_dcache_fsm = DCACHE_TLB_LR_UPDT;  // dcache and page table update
    35423572
    35433573#if DEBUG_DCACHE
     
    35743604    }
    35753605    ////////////////////////
    3576     case DCACHE_TLB_LR_WAIT:            // Waiting the response to SC transaction for DIRTY bit.
     3606    case DCACHE_TLB_LR_WAIT:        // Waiting the response to SC transaction for DIRTY bit.
    35773607                                    // We consume the response in rsp FIFO,
    35783608                                    // and exit the sub-fsm, but we don't
     
    35993629        }
    36003630
    3601         if ( r_vci_rsp_data_error.read() )      // bus error
     3631        if ( r_vci_rsp_data_error.read() )  // bus error
    36023632        {
    36033633            std::cout << "BUS ERROR in DCACHE_TLB_LR_WAIT state" << std::endl;
     
    36203650    }
    36213651    ///////////////////////
    3622     case DCACHE_TLB_RETURN:             // return to caller depending on tlb miss type
     3652    case DCACHE_TLB_RETURN:     // return to caller depending on tlb miss type
    36233653    {
    36243654#if DEBUG_DCACHE
     
    36343664    }
    36353665    ///////////////////////
    3636     case DCACHE_XTN_SWITCH:             // The r_ptpr registers must be written,
     3666    case DCACHE_XTN_SWITCH:     // The r_ptpr registers must be written,
    36373667                                // and both itlb and dtlb must be flushed.
    36383668                                // Caution : the itlb miss requests must be taken
     
    36763706    }
    36773707    /////////////////////
    3678     case DCACHE_XTN_SYNC:               // waiting until write buffer empty
     3708    case DCACHE_XTN_SYNC:       // waiting until write buffer empty
    36793709                                // The coherence request must be taken
    36803710                                // as there is a risk of dead-lock
     
    37043734    }
    37053735    ////////////////////////
    3706     case DCACHE_XTN_IC_FLUSH:           // Waiting completion of an XTN request to the ICACHE FSM
    3707     case DCACHE_XTN_IC_INVAL_VA:        // Caution : the itlb miss requests must be taken
    3708     case DCACHE_XTN_IC_INVAL_PA:        // because the XTN_ICACHE_INVAL request to icache
    3709     case DCACHE_XTN_IT_INVAL:           // can generate an itlb miss,
    3710                                     // and because it can exist a simultaneous ITLB miss
     3736    case DCACHE_XTN_IC_FLUSH:       // Waiting completion of an XTN request to the ICACHE FSM
     3737    case DCACHE_XTN_IC_INVAL_VA:    // Caution : the itlb miss requests must be taken
     3738    case DCACHE_XTN_IC_INVAL_PA:    // because the XTN_ICACHE_INVAL request to icache
     3739    case DCACHE_XTN_IC_PADDR_EXT:   // can generate an itlb miss,
     3740    case DCACHE_XTN_IT_INVAL:       // and because it can exist a simultaneous ITLB miss
     3741
    37113742    {
    37123743        // coherence clack request (from DSPIN CLACK)
     
    37443775    }
    37453776    /////////////////////////
    3746     case DCACHE_XTN_DC_FLUSH:   // Invalidate sequencially all cache lines, using
     3777    case DCACHE_XTN_DC_FLUSH:   // Invalidate sequencially all cache lines, using
    37473778                                // r_dcache_flush_count as a slot counter,
    37483779                                // looping in this state until all slots have been visited.
     
    38453876    }
    38463877    /////////////////////////
    3847     case DCACHE_XTN_DT_INVAL:   // handling processor XTN_DTLB_INVAL request
     3878    case DCACHE_XTN_DT_INVAL:   // handling processor XTN_DTLB_INVAL request
    38483879    {
    38493880        r_dtlb.inval(r_dcache_save_wdata.read());
     
    38553886    case DCACHE_XTN_DC_INVAL_VA:  // selective cache line invalidate with virtual address
    38563887                                  // requires 3 cycles: access tlb, read cache, inval cache
    3857                                   // we compute the physical address in this state
     3888                                  // we compute the physical address in this state
    38583889    {
    38593890        paddr_t paddr;
    38603891        bool    hit;
    38613892
    3862         if ( r_mmu_mode.read() & DATA_TLB_MASK )        // dtlb activated
     3893        if ( r_mmu_mode.read() & DATA_TLB_MASK )    // dtlb activated
    38633894        {
    38643895
     
    38693900                                    &paddr );
    38703901        }
    3871         else                                            // dtlb not activated
     3902        else                        // dtlb not activated
    38723903        {
    38733904            paddr = (paddr_t)r_dcache_save_wdata.read();
     
    38773908        }
    38783909
    3879         if ( hit )              // tlb hit
     3910        if ( hit )      // tlb hit
    38803911        {
    38813912            r_dcache_save_paddr = paddr;
    38823913            r_dcache_fsm      = DCACHE_XTN_DC_INVAL_PA;
    38833914        }
    3884         else                    // tlb miss
    3885         {
     3915        else            // tlb miss
     3916        {
    38863917
    38873918#ifdef INSTRUMENTATION
    38883919m_cpt_dtlb_miss++;
    38893920#endif
    3890             r_dcache_tlb_ins    = false;                // dtlb
     3921            r_dcache_tlb_ins    = false;        // dtlb
    38913922            r_dcache_tlb_vaddr  = r_dcache_save_wdata.read();
    38923923            r_dcache_fsm        = DCACHE_TLB_MISS;
     
    39103941                                  // In this state we read dcache.
    39113942    {
    3912         size_t          way;
    3913         size_t          set;
    3914         size_t          word;
     3943        size_t      way;
     3944        size_t      set;
     3945        size_t      word;
    39153946        int         state;
    39163947
     
    39243955                           &word );
    39253956
    3926         if ( state == CACHE_SLOT_STATE_VALID )  // inval to be done
     3957        if ( state == CACHE_SLOT_STATE_VALID )  // inval to be done
    39273958        {
    39283959            r_dcache_xtn_way = way;
     
    39303961            r_dcache_fsm      = DCACHE_XTN_DC_INVAL_GO;
    39313962        }
    3932         else            // miss : nothing to do
     3963        else        // miss : nothing to do
    39333964        {
    39343965            r_dcache_fsm      = DCACHE_IDLE;
     
    39513982    ////////////////////////////
    39523983    case DCACHE_XTN_DC_INVAL_GO:  // In this state, we invalidate the cache line
    3953                                               // Blocked if previous cleanup not completed
     3984                                  // Blocked if previous cleanup not completed
    39543985                                  // Test if itlb or dtlb inval is required
    39553986    {
    39563987        if ( not r_dcache_cc_send_req.read() ) // blocked until previous cc_send request is sent
    39573988        {
    3958             size_t      way        = r_dcache_xtn_way.read();
    3959             size_t      set        = r_dcache_xtn_set.read();
     3989            size_t  way        = r_dcache_xtn_way.read();
     3990            size_t  set        = r_dcache_xtn_set.read();
    39603991            paddr_t nline      = r_dcache_save_paddr.read() / (m_dcache_words<<2);
    39613992
     
    40044035}
    40054036#endif
    4006             }
     4037        }
    40074038        break;
    40084039    }
    40094040    //////////////////////////////
    4010     case DCACHE_XTN_DC_INVAL_END:       // send response to processor XTN request
     4041    case DCACHE_XTN_DC_INVAL_END:   // send response to processor XTN request
    40114042    {
    40124043        r_dcache_fsm = DCACHE_IDLE;
     
    41084139    }
    41094140    ///////////////////////
    4110     case DCACHE_MISS_CLEAN:             // switch the slot to ZOMBI state
     4141    case DCACHE_MISS_CLEAN:     // switch the slot to ZOMBI state
    41114142                                // and possibly request itlb or dtlb invalidate
    41124143    {
     
    41604191    }
    41614192    //////////////////////
    4162     case DCACHE_MISS_WAIT:      // waiting the response to a miss request from VCI_RSP FSM
     4193    case DCACHE_MISS_WAIT:  // waiting the response to a miss request from VCI_RSP FSM
    41634194                            // This state is in charge of error signaling
    41644195                            // There is 5 types of error depending on the requester
     
    41924223        }
    41934224
    4194         if ( r_vci_rsp_data_error.read() )                      // bus error
     4225        if ( r_vci_rsp_data_error.read() )          // bus error
    41954226        {
    41964227            switch ( r_dcache_miss_type.read() )
     
    42464277            r_vci_rsp_data_error = false;
    42474278        }
    4248         else if ( r_vci_rsp_fifo_dcache.rok() )         // valid response available
     4279        else if ( r_vci_rsp_fifo_dcache.rok() )     // valid response available
    42494280        {
    42504281            r_dcache_miss_word = 0;
    4251                 r_dcache_fsm       = DCACHE_MISS_DATA_UPDT;
     4282            r_dcache_fsm       = DCACHE_MISS_DATA_UPDT;
    42524283        }
    42534284        break;
    42544285    }
    42554286    //////////////////////////
    4256     case DCACHE_MISS_DATA_UPDT:   // update the dcache (one word per cycle)
     4287    case DCACHE_MISS_DATA_UPDT:   // update the dcache (one word per cycle)
    42574288    {
    42584289        if ( m_dreq.valid) m_cost_data_miss_frz++;
    42594290
    4260         if ( r_vci_rsp_fifo_dcache.rok() )      // one word available
     4291        if ( r_vci_rsp_fifo_dcache.rok() )  // one word available
    42614292        {
    42624293#ifdef INSTRUMENTATION
     
    44074438        }
    44084439
    4409         if ( r_vci_rsp_data_error.read() )      // bus error
     4440        if ( r_vci_rsp_data_error.read() )  // bus error
    44104441        {
    44114442            if(r_dcache_vci_unc_write.read())
     
    44214452            break;
    44224453        }
    4423             else if ( r_vci_rsp_fifo_dcache.rok() )     // data available
    4424             {
     4454        else if ( r_vci_rsp_fifo_dcache.rok() )     // data available
     4455        {
    44254456            // consume data
    44264457            vci_rsp_fifo_dcache_get = true;
     
    44304461            if ( m_dreq.valid and (m_dreq.addr == r_dcache_save_vaddr.read()) )
    44314462            {
    4432                     m_drsp.valid        = true;
     4463                m_drsp.valid        = true;
    44334464                m_drsp.error        = false;
    4434                     m_drsp.rdata        = r_vci_rsp_fifo_dcache.read();
    4435             }
    4436             }
     4465                m_drsp.rdata        = r_vci_rsp_fifo_dcache.read();
     4466            }
     4467        }
    44374468        break;
    44384469    }
     
    44564487        }
    44574488
    4458         if ( r_vci_rsp_data_error.read() )      // bus error
     4489        if ( r_vci_rsp_data_error.read() )  // bus error
    44594490        {
    44604491            r_mmu_detr           = MMU_READ_DATA_ILLEGAL_ACCESS;
     
    44664497            break;
    44674498        }
    4468             else if ( r_vci_rsp_fifo_dcache.rok() )     // data available
    4469             {
     4499        else if ( r_vci_rsp_fifo_dcache.rok() )     // data available
     4500        {
    44704501            // consume data
    44714502            vci_rsp_fifo_dcache_get = true;
     
    44884519                r_dcache_fsm = DCACHE_IDLE;
    44894520            }
    4490             }
     4521        }
    44914522        break;
    44924523    }
    44934524    ////////////////////
    4494     case DCACHE_SC_WAIT:        // waiting VCI response to a SC transaction
     4525    case DCACHE_SC_WAIT:    // waiting VCI response to a SC transaction
    44954526    {
    44964527        // coherence clack request (from DSPIN CLACK)
     
    45104541        }
    45114542
    4512         if ( r_vci_rsp_data_error.read() )              // bus error
     4543        if ( r_vci_rsp_data_error.read() )      // bus error
    45134544        {
    45144545            r_mmu_detr           = MMU_READ_DATA_ILLEGAL_ACCESS;
     
    45204551            break;
    45214552        }
    4522             else if ( r_vci_rsp_fifo_dcache.rok() ) // response available
    4523             {
     4553        else if ( r_vci_rsp_fifo_dcache.rok() ) // response available
     4554        {
    45244555            // consume response
    45254556            vci_rsp_fifo_dcache_get = true;
     
    45274558            m_drsp.rdata            = r_vci_rsp_fifo_dcache.read();
    45284559            r_dcache_fsm            = DCACHE_IDLE;
    4529             }
     4560        }
    45304561        break;
    45314562    }
    45324563    //////////////////////////
    4533     case DCACHE_DIRTY_GET_PTE:          // This sub_fsm set the PTE Dirty bit in memory
     4564    case DCACHE_DIRTY_GET_PTE:      // This sub_fsm set the PTE Dirty bit in memory
    45344565                                    // before handling a processor WRITE or SC request
    45354566                                    // Input argument is r_dcache_dirty_paddr
     
    49374968    }
    49384969    ///////////////////////////
    4939     case DCACHE_INVAL_TLB_SCAN:         // Scan sequencially all sets for both ITLB & DTLB
     4970    case DCACHE_INVAL_TLB_SCAN:         // Scan sequencially all sets for both ITLB & DTLB
    49404971                                        // It makes assumption: m_itlb_sets == m_dtlb_sets
    49414972                                        // All ways are handled in parallel.
     
    49534984                                        // - r_dcache_fsm_scan_save
    49544985    {
    4955         paddr_t line = r_dcache_tlb_inval_line.read();
     4986        paddr_t line = r_dcache_tlb_inval_line.read();
    49564987        size_t  set  = r_dcache_tlb_inval_set.read();
    49574988        size_t  way;
     
    50105041    if ( (m_ireq.valid and not m_irsp.valid) or (m_dreq.valid and not m_drsp.valid) )
    50115042    {
    5012         m_cpt_frz_cycles++;             // used for instrumentation
    5013         m_cpt_stop_simulation++;        // used for debug
     5043        m_cpt_frz_cycles++;         // used for instrumentation
     5044        m_cpt_stop_simulation++;    // used for debug
    50145045        if ( m_cpt_stop_simulation > m_max_frozen_cycles )
    50155046        {
Note: See TracChangeset for help on using the changeset viewer.