Changeset 494


Ignore:
Timestamp:
Aug 20, 2013, 2:13:08 PM (11 years ago)
Author:
devigne
Message:

Merge with the lastest version of trunk

Location:
branches/ODCCP
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/ODCCP/communication/dspin_dhccp_param

  • branches/ODCCP/communication/dspin_dhccp_param/caba/source/include/dspin_dhccp_param.h

    r479 r494  
    197197    static const uint64_t M2P_BC_MASK                  = 1;
    198198
    199     static const uint8_t  MULTI_INVAL_DEST_SHIFT          = 25;
    200     static const uint64_t MULTI_INVAL_DEST_MASK           = ((1ULL<<SRCID_WIDTH)-1);
    201     static const uint8_t  MULTI_INVAL_SRCID_SHIFT         = 8;
    202     static const uint64_t MULTI_INVAL_SRCID_MASK          = ((1ULL<<SRCID_WIDTH)-1);
    203     static const uint8_t  MULTI_INVAL_UPDT_INDEX_SHIFT    = 4;
    204     static const uint64_t MULTI_INVAL_UPDT_INDEX_MASK     = ((1ULL<<UPDT_INDEX_WIDTH)-1);
    205     static const uint8_t  MULTI_INVAL_NLINE_SHIFT         = 0;
    206     static const uint64_t MULTI_INVAL_NLINE_MASK          = ((1ULL<<NLINE_WIDTH)-1);
     199    static const uint8_t  MULTI_INVAL_DEST_SHIFT       = 25;
     200    static const uint64_t MULTI_INVAL_DEST_MASK        = ((1ULL<<SRCID_WIDTH)-1);
     201    static const uint8_t  MULTI_INVAL_SRCID_SHIFT      = 7;
     202    static const uint64_t MULTI_INVAL_SRCID_MASK       = ((1ULL<<SRCID_WIDTH)-1);
     203    static const uint8_t  MULTI_INVAL_UPDT_INDEX_SHIFT = 3;
     204    static const uint64_t MULTI_INVAL_UPDT_INDEX_MASK  = ((1ULL<<UPDT_INDEX_WIDTH)-1);
     205    static const uint8_t  MULTI_INVAL_NLINE_SHIFT      = 0;
     206    static const uint64_t MULTI_INVAL_NLINE_MASK       = ((1ULL<<NLINE_WIDTH)-1);
    207207
    208208    static const uint8_t  MULTI_UPDT_DEST_SHIFT           = MULTI_INVAL_DEST_SHIFT;
     
    236236    static const uint8_t  CLACK_DEST_SHIFT             = 25;
    237237    static const uint64_t CLACK_DEST_MASK              = ((1ULL<<SRCID_WIDTH)-1);
    238     static const uint8_t  CLACK_SET_SHIFT              = 6;
     238    static const uint8_t  CLACK_SET_SHIFT              = 4;
    239239    static const uint64_t CLACK_SET_MASK               = ((1ULL<<SET_INDEX_WIDTH)-1);
    240     static const uint8_t  CLACK_WAY_SHIFT              = 4;
     240    static const uint8_t  CLACK_WAY_SHIFT              = 2;
    241241    static const uint64_t CLACK_WAY_MASK               = ((1ULL<<WAY_INDEX_WIDTH)-1);
    242242
  • branches/ODCCP/modules/vci_cc_vcache_wrapper

  • branches/ODCCP/modules/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h

    r479 r494  
    179179        CC_RECEIVE_INS_UPDT_HEADER,
    180180        CC_RECEIVE_INS_UPDT_NLINE,
    181         CC_RECEIVE_INS_UPDT_DATA,
    182181        CC_RECEIVE_DATA_INVAL_HEADER,
    183182        CC_RECEIVE_DATA_INVAL_NLINE,
    184183        CC_RECEIVE_DATA_UPDT_HEADER,
    185184        CC_RECEIVE_DATA_UPDT_NLINE,
     185        CC_RECEIVE_INS_UPDT_DATA,
    186186        CC_RECEIVE_DATA_UPDT_DATA,
    187187    };
     
    404404    sc_signal<bool>         r_icache_tlb_rsp_error;      // tlb miss response error
    405405
     406    // Filp-Flop in ICACHE FSM for saving the cleanup victim request
     407    sc_signal<bool>         r_icache_cleanup_victim_req;
     408    sc_signal<paddr_t>      r_icache_cleanup_victim_nline;
     409
    406410    // communication between ICACHE FSM and CC_SEND FSM
    407411    sc_signal<bool>         r_icache_cc_send_req;           // ICACHE cc_send request
     
    497501    sc_signal<int>          r_dcache_xtn_opcode;        // xtn request type
    498502
     503    // Filp-Flop in DCACHE FSM for saving the cleanup victim request
     504    sc_signal<bool>         r_dcache_cleanup_victim_req;
     505    sc_signal<paddr_t>      r_dcache_cleanup_victim_nline;
     506
    499507    // communication between DCACHE FSM and CC_SEND FSM
    500508    sc_signal<bool>         r_dcache_cc_send_req;           // DCACHE cc_send request
     
    507515    sc_signal<bool>         r_dcache_cc_cleanup_updt_data;          // Register for cleanup with data (wb updt)
    508516    sc_signal<bool>         r_dcache_cleanup_ncc;                   // Register for cleanup no coherent
     517    //sc_signal<bool>         r_miss_cleanup_ncc_pending;                   // Register for cleanup no coherent
     518    sc_signal<bool>         r_dcache_cleanup_will_contains_data;                   // Register for cleanup no coherent
     519    sc_signal<bool>         r_dcache_cleanup_will_ncc;                   // Register for cleanup no coherent
    509520    sc_signal<bool>         r_dcache_miss_victim_no_coherence;      // Register for victim in no coherence mode
    510521    sc_signal<bool>         r_dcache_line_no_coherence;             // Register for line current in no coherence mode
  • branches/ODCCP/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp

    r492 r494  
    3636#define DEBUG_CLEANUP             1
    3737#define INSTRUMENTATION       1
    38 #define FETCH_ON_WRITE_ENABLE 0
     38#define FETCH_ON_WRITE_ENABLE 1
    3939#define DEBUG_CMD                 0
    4040
     
    285285      r_icache_tlb_rsp_error("r_icache_tlb_rsp_error"),
    286286
     287      r_icache_cleanup_victim_req("r_icache_cleanup_victim_req"),
     288      r_icache_cleanup_victim_nline("r_icache_cleanup_victim_nline"),
     289
    287290      r_icache_cc_send_req("r_icache_cc_send_req"),
    288291      r_icache_cc_send_type("r_icache_cc_send_type"),
     
    357360      r_dcache_xtn_opcode("r_dcache_xtn_opcode"),
    358361
     362      r_dcache_cleanup_victim_req("r_dcache_cleanup_victim_req"),
     363      r_dcache_cleanup_victim_nline("r_dcache_cleanup_victim_nline"),
     364   
    359365      r_dcache_cc_send_req("r_dcache_cc_send_req"),
    360366      r_dcache_cc_send_type("r_dcache_cc_send_type"),
     
    363369      r_dcache_cc_send_updt_tab_idx("r_dcache_cc_send_updt_tab_idx"),
    364370     
    365       r_cc_send_data_fifo("r_cc_send_data_fifo", 2),  // ODCCP
     371      r_cc_send_data_fifo("r_cc_send_data_fifo", 16),  // ODCCP
    366372
    367373      r_vci_cmd_fsm("r_vci_cmd_fsm"),
     
    792798        // No request from ICACHE_FSM to CC_SEND FSM
    793799        r_icache_cc_send_req       = false;
     800        r_icache_cleanup_victim_req = false;
    794801
    795802        r_icache_clack_req         = false;
     
    814821        // No request from DCACHE FSM to CC_SEND FSM
    815822        r_dcache_cc_send_req       = false;
    816 
     823        r_dcache_cleanup_victim_req = false;
     824   
    817825        r_dcache_clack_req         = false;
    818826
     
    852860        r_dcache_miss_data_cpt               = 0;
    853861        r_dcache_miss_data_addr              = 0;
     862        //r_miss_cleanup_ncc_pending           = false;
    854863
    855864        // activity counters
     
    10931102
    10941103        // coherence interrupt
    1095         if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() )
     1104        if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read())
    10961105        {
    10971106            r_icache_fsm = ICACHE_CC_CHECK;
     
    13301339
    13311340        // coherence interrupt
    1332         if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() )
     1341        if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read())
    13331342        {
    13341343            r_icache_fsm = ICACHE_CC_CHECK;
     
    13821391
    13831392        // coherence request (from CC_RECEIVE FSM)
    1384         if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() )
     1393        if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read())
    13851394        {
    13861395            r_icache_fsm = ICACHE_CC_CHECK;
     
    15721581    ////////////////////////
    15731582    case ICACHE_MISS_SELECT:       // Try to select a slot in associative set,
    1574                                    // if previous cleanup has been sent.
    15751583                                   // Waiting in this state if no slot available.
    1576                                    // Set the r_icache_cleanup_req flip-flop
    1577                                    // and the r_icache_miss_clack flip-flop,
     1584                                   // If a victim slot has been choosen and the r_icache_cc_send_req is false,
     1585                                   // we send the cleanup request in this state.
     1586                                   // If not, a r_icache_cleanup_victim_req flip-flop is
     1587                                   // utilized for saving this cleanup request, and it will be sent later
     1588                                   // in state ICACHE_MISS_WAIT or ICACHE_MISS_UPDT_DIR.
     1589                                   // The r_icache_miss_clack flip-flop is set
    15781590                                   // when a cleanup is required
    15791591    {
     
    15891601
    15901602        // coherence interrupt
    1591         if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() )
     1603        if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read())
    15921604        {
    15931605            r_icache_fsm = ICACHE_CC_CHECK;
     
    15961608        }
    15971609
    1598         if ( not r_icache_cc_send_req.read() ) // wait for previous cc_send request to be sent
    1599         {
    1600             bool        found;
    1601             bool        cleanup;
    1602             size_t      way;
    1603             size_t      set;
    1604             paddr_t     victim;
     1610
     1611        bool        found;
     1612        bool        cleanup;
     1613        size_t          way;
     1614        size_t          set;
     1615        paddr_t         victim;
    16051616
    16061617#ifdef INSTRUMENTATION
    16071618m_cpt_icache_dir_read++;
    16081619#endif
    1609             r_icache.read_select(r_icache_vci_paddr.read(),
    1610                                  &victim,
    1611                                  &way,
    1612                                  &set,
    1613                                  &found,
    1614                                  &cleanup );
    1615             if ( found )
    1616             {
    1617                 r_icache_miss_way     = way;
    1618                 r_icache_miss_set     = set;
    1619 
    1620                 if ( cleanup )
     1620        r_icache.read_select(r_icache_vci_paddr.read(),
     1621                             &victim,
     1622                             &way,
     1623                             &set,
     1624                             &found,
     1625                             &cleanup );
     1626        if ( not found )
     1627        {
     1628            break;
     1629        }
     1630        else
     1631        {
     1632            r_icache_miss_way     = way;
     1633            r_icache_miss_set     = set;
     1634
     1635            if ( cleanup )
     1636            {
     1637                if ( not r_icache_cc_send_req.read() )
    16211638                {
    1622                     r_icache_fsm           = ICACHE_MISS_CLEAN;
    1623                     r_icache_miss_clack    = true;
    1624                     // request cleanup
    1625                     r_icache_cc_send_req   = true;
    1626                     r_icache_cc_send_nline = victim;
    1627                     r_icache_cc_send_way   = way;
    1628                     r_icache_cc_send_type  = CC_TYPE_CLEANUP;
     1639                    r_icache_cc_send_req    = true;
     1640                    r_icache_cc_send_nline  = victim;
     1641                    r_icache_cc_send_way    = way;
     1642                    r_icache_cc_send_type   = CC_TYPE_CLEANUP;   
    16291643                }
    16301644                else
    16311645                {
    1632                     r_icache_fsm          = ICACHE_MISS_WAIT;
     1646                    r_icache_cleanup_victim_req   = true;
     1647                    r_icache_cleanup_victim_nline = victim;
    16331648                }
     1649
     1650                r_icache_miss_clack           = true;
     1651                r_icache_fsm                  = ICACHE_MISS_CLEAN;
     1652            }
     1653            else
     1654            {
     1655                r_icache_fsm          = ICACHE_MISS_WAIT;
     1656            }
    16341657
    16351658#if DEBUG_ICACHE
     
    16441667}
    16451668#endif
    1646             }
    16471669        }
    16481670        break;
     
    16771699        if (m_ireq.valid) m_cost_ins_miss_frz++;
    16781700
     1701        // send cleanup victim request
     1702        if ( r_icache_cleanup_victim_req.read() and not r_icache_cc_send_req.read() )
     1703        {
     1704            r_icache_cc_send_req        = true;
     1705            r_icache_cc_send_nline      = r_icache_cleanup_victim_nline;
     1706            r_icache_cc_send_way        = r_icache_miss_way;
     1707            r_icache_cc_send_type       = CC_TYPE_CLEANUP;
     1708            r_icache_cleanup_victim_req = false;
     1709        }   
     1710
    16791711        // coherence clack interrupt
    16801712        if ( r_icache_clack_req.read() )
     
    16841716            break;
    16851717        }
    1686 
     1718       
    16871719        // coherence interrupt
    1688         if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() )
     1720        if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() and not r_icache_cleanup_victim_req.read() )
    16891721        {
    16901722            r_icache_fsm = ICACHE_CC_CHECK;
     
    17561788        if ( m_ireq.valid ) m_cost_ins_miss_frz++;
    17571789
     1790        // send cleanup victim request
     1791        if ( r_icache_cleanup_victim_req.read() and not r_icache_cc_send_req.read() )
     1792        {
     1793            r_icache_cc_send_req        = true;
     1794            r_icache_cc_send_nline      = r_icache_cleanup_victim_nline;
     1795            r_icache_cc_send_way        = r_icache_miss_way;
     1796            r_icache_cc_send_type       = CC_TYPE_CLEANUP;
     1797            r_icache_cleanup_victim_req = false;
     1798        }   
     1799
    17581800        // coherence clack interrupt
    17591801        if ( r_icache_clack_req.read() )
     
    17651807
    17661808        // coherence interrupt
    1767         if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() )
     1809        if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() and not r_icache_cleanup_victim_req.read() )
    17681810        {
    17691811            r_icache_fsm = ICACHE_CC_CHECK;
     
    18441886
    18451887        // coherence interrupt
    1846         if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read() )
     1888        if ( r_cc_receive_icache_req.read() and not r_icache_cc_send_req.read())
    18471889        {
    18481890            r_icache_fsm = ICACHE_CC_CHECK;
     
    19231965            break;
    19241966        }
     1967       
     1968        assert ( not r_icache_cc_send_req.read() and "CC_SEND must be available in ICACHE_CC_CHECK");
    19251969
    19261970        // Match between MISS address and CC address
     
    19612005#endif
    19622006        }
    1963 
    1964 
    1965         assert ( not r_icache_cc_send_req.read() and "CC_SEND must be available in ICACHE_CC_CHECK");
    19662007
    19672008        // CC request handler
     
    31073148
    31083149        // coherence request (from CC_RECEIVE FSM)
    3109         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     3150        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    31103151        {
    31113152            r_dcache_fsm = DCACHE_CC_CHECK;
     
    34143455
    34153456        // coherence request (from CC_RECEIVE FSM)
    3416         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     3457        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    34173458        {
    34183459            r_dcache_fsm = DCACHE_CC_CHECK;
     
    37213762
    37223763        // coherence request (from CC_RECEIVE FSM)
    3723         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     3764        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    37243765        {
    37253766            r_dcache_fsm = DCACHE_CC_CHECK;
     
    38003841
    38013842        // coherence request (from CC_RECEIVE FSM)
    3802         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     3843        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    38033844        {
    38043845            r_dcache_fsm = DCACHE_CC_CHECK;
     
    38303871
    38313872        // coherence request (from CC_RECEIVE FSM)
    3832         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     3873        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    38333874        {
    38343875            r_dcache_fsm = DCACHE_CC_CHECK;
     
    38733914
    38743915        // coherence request (from CC_RECEIVE FSM)
    3875         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     3916        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    38763917        {
    38773918            r_dcache_fsm = DCACHE_CC_CHECK;
     
    39714012                              &set,
    39724013                              &word);
     4014
     4015        /*if (m_proc_id == 1) { std::cout << "rdata XTN_FLUSH_DATA = " << std::hex << rdata << std::dec << " | at cycle = " << m_cpt_total_cycles << std::endl; }
     4016        if (m_proc_id == 1) { r_cc_send_data_fifo.print(); }*/
     4017
    39734018        if(r_cc_send_data_fifo.wok())
    39744019        {
     
    40474092        {
    40484093            paddr = (paddr_t)r_dcache_save_wdata.read();
     4094            if (vci_param::N > 32)
     4095                paddr = paddr | ((paddr_t)(r_dcache_paddr_ext.read()) << 32);
    40494096            hit   = true;
    40504097        }
     
    42334280                              &set,
    42344281                              &word);
     4282
     4283        /*if (m_proc_id == 1) { std::cout << "rdata XTN_INVAL_DATA = " << std::hex << rdata << std::dec << " | at cycle = " << m_cpt_total_cycles << std::endl; }
     4284        if (m_proc_id == 1) { r_cc_send_data_fifo.print(); }*/
     4285
    42354286        if(r_cc_send_data_fifo.wok())
    42364287        {
     
    42634314    }
    42644315    ////////////////////////
    4265     case DCACHE_MISS_SELECT:   // Try to select a slot in associative set
    4266                                // if previous cleanup has been sent.
    4267                                // Waiting in this state if no slot available
    4268                                // Set the r_dcache_cleanup_req flip-flop
    4269                                // and the r_dcache_miss_clack flip-flop
    4270                                // when a cleanup is required
     4316    case DCACHE_MISS_SELECT:       // Try to select a slot in associative set,
     4317                                   // Waiting in this state if no slot available.
     4318                                   // If a victim slot has been choosen and the r_icache_cc_send_req is false,
     4319                                   // we send the cleanup request in this state.
     4320                                   // If not, a r_icache_cleanup_victim_req flip-flop is
     4321                                   // utilized for saving this cleanup request, and it will be sent later
     4322                                   // in state ICACHE_MISS_WAIT or ICACHE_MISS_UPDT_DIR.
     4323                                   // The r_icache_miss_clack flip-flop is set
     4324                                   // when a cleanup is required
    42714325    {
    42724326        if ( m_dreq.valid) m_cost_data_miss_frz++;
     
    42814335
    42824336        // coherence request (from CC_RECEIVE FSM)
    4283         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     4337        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    42844338        {
    42854339            r_dcache_fsm = DCACHE_CC_CHECK;
     
    42884342        }
    42894343
    4290         if ( not r_dcache_cc_send_req.read() ) // blocked until previous cc_send request is sent
    4291         {
    4292             bool     found = false;
    4293             bool     cleanup = false;
    4294             size_t   way = 0;
    4295             size_t   set = 0;
    4296             paddr_t  victim = 0;
     4344        bool     found = false;
     4345        bool     cleanup = false;
     4346        bool     dirty = false;
     4347        bool     ncc = false;
     4348        size_t   way = 0;
     4349        size_t   set = 0;
     4350        paddr_t  victim = 0;
    42974351            int state;
    42984352
     
    43004354m_cpt_dcache_dir_read++;
    43014355#endif
    4302             r_dcache.read_select( r_dcache_save_paddr.read(),
    4303                                   &victim,
    4304                                   &way,
    4305                                   &set,
    4306                                   &found,
    4307                                   &cleanup );
     4356        r_dcache.read_select( r_dcache_save_paddr.read(),
     4357                              &victim,
     4358                              &way,
     4359                              &set,
     4360                              &found,
     4361                              &cleanup );
    43084362            state = r_dcache.get_cache_state(way,set);
    4309             if ( found )
    4310             {
    4311                 r_dcache_miss_way = way;
    4312                 r_dcache_miss_set = set;
    4313 
    4314                 if ( cleanup )
     4363        if (  not found )
     4364        {
     4365            break;
     4366        }
     4367        else
     4368        {
     4369            r_dcache_miss_way = way;
     4370            r_dcache_miss_set = set;
     4371
     4372            if ( cleanup )
     4373            {
     4374
     4375                r_dcache_miss_clack           = true;
     4376                r_dcache_fsm                  = DCACHE_MISS_CLEAN;
     4377
     4378               
     4379                if( (state == CACHE_SLOT_STATE_VALID_NCC) )
    43154380                {
    4316                     r_dcache_miss_clack   = true;
    4317                     r_dcache_fsm          = DCACHE_MISS_CLEAN;
    4318                     // request cleanup
    4319                     r_dcache_cc_send_req   = true;
    4320                     r_dcache_cc_send_nline = victim;
    4321                     r_dcache_cc_send_way   = way;
    4322                     r_dcache_cc_send_type  = CC_TYPE_CLEANUP;
    4323                    
    4324                     if( (state == CACHE_SLOT_STATE_VALID_NCC) )
     4381                    //r_dcache_cleanup_ncc = true;
     4382                    ncc = true;
     4383                    r_dcache_cleanup_will_ncc = true;
     4384
     4385                    /*ODCCP*/ // if line is dirty we must save the data values
     4386                    if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY)
    43254387                    {
    4326                         r_dcache_cleanup_ncc = true;
    4327                        
    4328                         /*ODCCP*/ // if line is dirty we must save the data values
    4329                         if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY)
     4388                        //r_dcache_cc_cleanup_updt_data = true;
     4389                        dirty = true;
     4390                        r_dcache_cleanup_will_contains_data = true;
     4391                        r_dcache_miss_data_addr = (victim*m_dcache_words)*4;
     4392                        r_dcache_fsm = DCACHE_MISS_DATA;
     4393
     4394                        /*TEST*/
     4395                        /*if (not r_dcache_cc_send_req.read())
     4396                            r_miss_cleanup_ncc_pending = true;
     4397                        else
     4398                            r_miss_cleanup_ncc_pending = false;*/
     4399
     4400                        m_cpt_data_cleanup_dirty ++;
     4401
     4402                        /*STATS DIRTY*/
     4403                        for (size_t w = 0; w < m_dcache_words; w++)
    43304404                        {
    4331                             r_dcache_cc_cleanup_updt_data = true;
    4332                             r_dcache_miss_data_addr = (victim*m_dcache_words)*4;
    4333                             r_dcache_fsm = DCACHE_MISS_DATA;
    4334                             m_cpt_data_cleanup_dirty ++;
    4335 
    4336                             /*STATS DIRTY*/
    4337                             for (size_t w = 0; w < m_dcache_words; w++)
    4338                             {
    4339                                 if(dirty_stats[(way * m_dcache_sets + set) * m_dcache_words + w] == true)
    4340                                     m_cpt_words_dirty++;
    4341                             }
     4405                            if(dirty_stats[(way * m_dcache_sets + set) * m_dcache_words + w] == true)
     4406                                m_cpt_words_dirty++;
    43424407                        }
    4343                         else
    4344                         {
    4345                             r_dcache_cc_cleanup_updt_data = false;
    4346                         }
    4347                     }
     4408                    }
    43484409                    else
    43494410                    {
    4350                         r_dcache_cc_cleanup_updt_data = false;
    4351                         r_dcache_cleanup_ncc = false;
     4411                        //r_dcache_cc_cleanup_updt_data = false;
     4412                        r_dcache_cleanup_will_contains_data = false;
    43524413                    }
     4414                }
     4415                else
     4416                {
     4417                    r_dcache_cleanup_will_contains_data = false;
     4418                    r_dcache_cleanup_will_ncc = false;
     4419                    //r_dcache_cc_cleanup_updt_data = false;
     4420                    //r_dcache_cleanup_ncc = false;
     4421                }
     4422
     4423                if ( not r_dcache_cc_send_req.read() )
     4424                {
     4425                    if (dirty) r_dcache_cc_cleanup_updt_data = true;
     4426                    else       r_dcache_cc_cleanup_updt_data = false;
     4427
     4428                    if (ncc)   r_dcache_cleanup_ncc = true;
     4429                    else       r_dcache_cleanup_ncc = false;
     4430
     4431                    r_dcache_cc_send_req    = true;
     4432                    r_dcache_cc_send_nline  = victim;
     4433                    r_dcache_cc_send_way    = way;
     4434                    r_dcache_cc_send_type   = CC_TYPE_CLEANUP;   
    43534435                }
    43544436                else
    43554437                {
    4356                     r_dcache_fsm          = DCACHE_MISS_WAIT;
     4438                    r_dcache_cleanup_victim_req   = true;
     4439                    r_dcache_cleanup_victim_nline = victim;
    43574440                }
     4441            }
     4442            else
     4443            {
     4444                r_dcache_fsm          = DCACHE_MISS_WAIT;
     4445            }
    43584446
    43594447#if DEBUG_DCACHE
     
    43694457}
    43704458#endif
    4371             } // end found
    4372         }
     4459        } // end found
    43734460        break;
    43744461    }
     
    43854472                              &set,
    43864473                              &word);
     4474
     4475        /*if (m_proc_id == 1) { std::cout << "rdata MISS_DATA = " << std::hex << rdata << std::dec << " | at cycle = " << m_cpt_total_cycles << std::endl; }
     4476        if (m_proc_id == 1) { r_cc_send_data_fifo.print(); }*/
    43874477
    43884478        if(r_cc_send_data_fifo.wok())
     
    44664556        if ( m_dreq.valid) m_cost_data_miss_frz++;
    44674557
     4558        // send cleanup victim request
     4559        if ( r_dcache_cleanup_victim_req.read() and not r_dcache_cc_send_req.read() )
     4560        {
     4561            r_dcache_cc_send_req        = true;
     4562            r_dcache_cc_send_nline      = r_dcache_cleanup_victim_nline;
     4563            r_dcache_cc_send_way        = r_dcache_miss_way;
     4564            r_dcache_cc_send_type       = CC_TYPE_CLEANUP;
     4565            r_dcache_cleanup_victim_req = false;
     4566            if (r_dcache_cleanup_will_contains_data.read() == true)
     4567                r_dcache_cc_cleanup_updt_data = true;
     4568            else
     4569                r_dcache_cc_cleanup_updt_data = false;
     4570                   
     4571            if (r_dcache_cleanup_will_ncc.read())   r_dcache_cleanup_ncc = true;
     4572            else                                    r_dcache_cleanup_ncc = false;
     4573        }   
     4574
    44684575        // coherence clack request (from DSPIN CLACK)
    44694576        if ( r_dcache_clack_req.read() )
     
    44754582
    44764583        // coherence request (from CC_RECEIVE FSM)
    4477         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     4584        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() and not r_dcache_cleanup_victim_req.read() /*and not r_miss_cleanup_ncc_pending.read()*/)
    44784585        {
    44794586            r_dcache_fsm = DCACHE_CC_CHECK;
     
    45894696        if ( m_dreq.valid) m_cost_data_miss_frz++;
    45904697
     4698        // send cleanup victim request
     4699        if ( r_dcache_cleanup_victim_req.read() and not r_dcache_cc_send_req.read() )
     4700        {
     4701            r_dcache_cc_send_req        = true;
     4702            r_dcache_cc_send_nline      = r_dcache_cleanup_victim_nline;
     4703            r_dcache_cc_send_way        = r_dcache_miss_way;
     4704            r_dcache_cc_send_type       = CC_TYPE_CLEANUP;
     4705            r_dcache_cleanup_victim_req = false;
     4706            if (r_dcache_cleanup_will_contains_data.read()) r_dcache_cc_cleanup_updt_data = true;
     4707            else                                            r_dcache_cc_cleanup_updt_data = false;
     4708           
     4709            if (r_dcache_cleanup_will_ncc.read())           r_dcache_cleanup_ncc = true;
     4710            else                                            r_dcache_cleanup_ncc = false;
     4711        }   
     4712
    45914713        // coherence clack request (from DSPIN CLACK)
    45924714        if ( r_dcache_clack_req.read() )
     
    45984720
    45994721        // coherence request (from CC_RECEIVE FSM)
    4600         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     4722        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() and not r_dcache_cleanup_victim_req.read() /*and not r_miss_cleanup_ncc_pending.read()*/)
    46014723        {
    46024724            r_dcache_fsm = DCACHE_CC_CHECK;
     
    47124834
    47134835        // coherence request (from CC_RECEIVE FSM)
    4714         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     4836        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    47154837        {
    47164838            r_dcache_fsm = DCACHE_CC_CHECK;
     
    47574879
    47584880        // coherence request (from CC_RECEIVE FSM)
    4759         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     4881        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    47604882        {
    47614883            r_dcache_fsm = DCACHE_CC_CHECK;
     
    48114933
    48124934        // coherence request (from CC_RECEIVE FSM)
    4813         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     4935        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    48144936        {
    48154937            r_dcache_fsm = DCACHE_CC_CHECK;
     
    49115033
    49125034        // coherence request (from CC_RECEIVE FSM)
    4913         if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read() )
     5035        if ( r_cc_receive_dcache_req.read() and not r_dcache_cc_send_req.read())
    49145036        {
    49155037            r_dcache_fsm = DCACHE_CC_CHECK;
     
    50105132        }
    50115133
    5012        
     5134        assert ( not r_dcache_cc_send_req.read() and "CC_SEND must be available in DCACHE_CC_CHECK" );
     5135
    50135136        // Match between MISS address and CC address
    5014         // note: In the same cycle we can handle a CLACK and a MISS match
    5015         // because the CLACK access the directory but the MISS match dont.
    50165137        if (r_cc_receive_dcache_req.read() and
    50175138          ((r_dcache_fsm_cc_save == DCACHE_MISS_SELECT  )  or
     
    50495170#endif
    50505171        }
    5051 
    5052 
    5053         assert ( not r_dcache_cc_send_req.read() and "CC_SEND must be available in DCACHE_CC_CHECK");
    50545172
    50555173        // CC request handler
     
    52365354                              &set,
    52375355                              &word);
     5356       
     5357        /*if (m_proc_id == 1) { std::cout << "rdata CC_INVAL_DATA = " << std::hex << rdata << std::dec << " | at cycle = " << m_cpt_total_cycles << std::endl; }
     5358        if (m_proc_id == 1) { r_cc_send_data_fifo.print(); }*/
     5359       
    52385360        if(r_cc_send_data_fifo.wok())
    52395361        {
     5362           
    52405363            r_dcache_cc_inval_addr = r_dcache_cc_inval_addr.read() + 4;
    52415364
     
    52585381                        << " / WAY = " << way
    52595382                        << " / SET = " << set << std::endl;
     5383                    r_dcache.printTrace();
    52605384                }
    52615385#endif
     
    60056129                        r_dcache_cc_send_req = false;
    60066130                        r_dcache_cc_cleanup_updt_data = false;
     6131                        //r_miss_cleanup_ncc_pending = false;
    60076132                        r_cc_send_cpt_word = 0;
    60086133                        r_cc_send_fsm = CC_SEND_IDLE;
     
    60956220            // flip_flop to check that ?
    60966221            if (not (r_cc_receive_icache_req.read()) and
    6097                 not (r_cc_receive_dcache_req.read()) and 
     6222                not (r_cc_receive_dcache_req.read()) and
    60986223                (p_dspin_m2p.write.read()))
    60996224            {
     
    61356260            uint64_t receive_data = p_dspin_m2p.data.read();
    61366261            // for data INVAL, wait for dcache to take the request
    6137             if (p_dspin_m2p.write.read() and not r_cc_receive_dcache_req.read())
     6262            if (p_dspin_m2p.write.read()           and
     6263                not r_cc_receive_dcache_req.read() )
    61386264            {
    61396265                // request dcache to handle the INVAL
     
    61536279            uint64_t receive_data = p_dspin_m2p.data.read();
    61546280            // for ins INVAL, wait for icache to take the request
    6155             if (p_dspin_m2p.write.read() and not r_cc_receive_icache_req.read())
     6281            if (p_dspin_m2p.write.read()           and
     6282                not r_cc_receive_icache_req.read() )
    61566283            {
    61576284                // request icache to handle the INVAL
     
    62036330            // for data INVAL, wait for dcache to take the request and fifo to
    62046331            // be empty
    6205             if ( r_cc_receive_updt_fifo_be.empty() and 
     6332            if ( r_cc_receive_updt_fifo_be.empty() and
    62066333                 p_dspin_m2p.write.read() )
    62076334            {
     
    62236350            // for ins INVAL, wait for icache to take the request and fifo to be
    62246351            // empty
    6225             if ( r_cc_receive_updt_fifo_be.empty() and 
     6352            if ( r_cc_receive_updt_fifo_be.empty() and
    62266353                 p_dspin_m2p.write.read() )
    62276354            {
  • branches/ODCCP/modules/vci_mem_cache

  • branches/ODCCP/modules/vci_mem_cache/caba/source/include/mem_cache_directory.h

    r460 r494  
    66#include <cassert>
    77#include "arithmetics.h"
    8 
    9 // !!!
    10 // The L1_MULTI_CACHE mechanism does no longer work with the new pktid encoding
    11 // of TSAR. Turning the define below to a non null value will cause the memcache
    12 // to behave in an unpredicted way.
    13 // TODO Either remove the mechanism from the mem cache or update its behaviour.
    14 
    15 #define L1_MULTI_CACHE 0
    168
    179//#define RANDOM_EVICTION
     
    4638      bool      inst;       // Is the owner an ICache ?
    4739      size_t    srcid;      // The SRCID of the owner
    48 #if L1_MULTI_CACHE
    49       size_t    cache_id;   // In multi_cache configuration
    50 #endif
    5140
    5241    ////////////////////////
    5342    // Constructors
    5443    ////////////////////////
    55       Owner(bool   i_inst
    56             ,size_t i_srcid
    57 #if L1_MULTI_CACHE
    58             ,size_t i_cache_id
    59 #endif
    60             ){
     44      Owner(bool   i_inst,
     45            size_t i_srcid)
     46      {
    6147        inst    = i_inst;
    6248        srcid   = i_srcid;
    63 #if L1_MULTI_CACHE
    64         cache_id= i_cache_id;
    65 #endif
    66       }
    67 
    68       Owner(const Owner &a){
     49      }
     50
     51      Owner(const Owner &a)
     52      {
    6953        inst    = a.inst;
    7054        srcid   = a.srcid;
    71 #if L1_MULTI_CACHE
    72         cache_id= a.cache_id;
    73 #endif
    74       }
    75 
    76       Owner(){
     55      }
     56
     57      Owner()
     58      {
    7759        inst    = false;
    7860        srcid   = 0;
    79 #if L1_MULTI_CACHE
    80         cache_id= 0;
    81 #endif
    8261      }
    8362      // end constructors
     
    11695      owner.inst    = 0;
    11796      owner.srcid   = 0;
    118 #if L1_MULTI_CACHE
    119       owner.cache_id= 0;
    120 #endif
    12197      ptr           = 0;
    12298    }
     
    176152                << " ; Count = " << count
    177153                << " ; Owner = " << owner.srcid
    178 #if L1_MULTI_CACHE
    179                 << "." << owner.cache_id
    180 #endif
    181154                << " " << owner.inst
    182155                << " ; Pointer = " << ptr << std::endl;
     
    327300    // - entry : the entry value
    328301    /////////////////////////////////////////////////////////////////////
    329     void write(const size_t &set, const size_t &way, const DirectoryEntry &entry)
     302    void write( const size_t         &set,
     303                const size_t         &way,
     304                const DirectoryEntry &entry)
    330305    {
    331306      assert( (set<m_sets)
     
    373348    DirectoryEntry select(const size_t &set, size_t &way)
    374349    {
    375       assert( (set < m_sets)
     350        assert( (set < m_sets)
    376351          && "Cache Directory : (select) The set index is invalid");
    377352
    378       for(size_t i=0; i<m_ways; i++){
    379         if(!m_dir_tab[set][i].valid){
    380           way=i;
    381           return DirectoryEntry(m_dir_tab[set][way]);
     353        // looking for an empty slot
     354        for(size_t i=0; i<m_ways; i++)
     355        {
     356            if( not m_dir_tab[set][i].valid )
     357            {
     358                way=i;
     359                return DirectoryEntry(m_dir_tab[set][way]);
     360            }
    382361        }
    383       }
    384362
    385363#ifdef RANDOM_EVICTION
    386       lfsr = (lfsr >> 1) ^ ((-(lfsr & 1)) & 0xd0000001);
    387       way = lfsr % m_ways;
    388       return DirectoryEntry(m_dir_tab[set][way]);
     364        lfsr = (lfsr >> 1) ^ ((-(lfsr & 1)) & 0xd0000001);
     365        way = lfsr % m_ways;
     366        return DirectoryEntry(m_dir_tab[set][way]);
    389367#endif
    390368
    391       for(size_t i=0; i<m_ways; i++){
    392         if(!(m_lru_tab[set][i].recent) && !(m_dir_tab[set][i].lock)){
    393           way=i;
    394           return DirectoryEntry(m_dir_tab[set][way]);
     369        // looking for a not locked and not recently used entry
     370        for(size_t i=0; i<m_ways; i++)
     371        {
     372            if((not m_lru_tab[set][i].recent) && (not m_dir_tab[set][i].lock) )
     373            {
     374                way=i;
     375                return DirectoryEntry(m_dir_tab[set][way]);
     376            }
    395377        }
    396       }
    397       for(size_t i=0; i<m_ways; i++){
    398         if( !(m_lru_tab[set][i].recent) && (m_dir_tab[set][i].lock)){
    399           way=i;
    400           return DirectoryEntry(m_dir_tab[set][way]);
     378
     379        // looking for a locked not recently used entry
     380        for(size_t i=0; i<m_ways; i++)
     381        {
     382            if( (not m_lru_tab[set][i].recent) && (m_dir_tab[set][i].lock))
     383            {
     384                way=i;
     385                return DirectoryEntry(m_dir_tab[set][way]);
     386            }
    401387        }
    402       }
    403       for(size_t i=0; i<m_ways; i++){
    404         if( (m_lru_tab[set][i].recent) && !(m_dir_tab[set][i].lock)){
    405           way=i;
    406           return DirectoryEntry(m_dir_tab[set][way]);
     388
     389        // looking for a recently used entry not locked
     390        for(size_t i=0; i<m_ways; i++)
     391        {
     392            if( (m_lru_tab[set][i].recent) && (not m_dir_tab[set][i].lock))
     393            {
     394                way=i;
     395                return DirectoryEntry(m_dir_tab[set][way]);
     396            }
    407397        }
    408       }
    409       way = 0;
    410       return DirectoryEntry(m_dir_tab[set][0]);
     398
     399        // select way 0 (even if entry is locked and recently used)
     400        way = 0;
     401        return DirectoryEntry(m_dir_tab[set][0]);
    411402    } // end select()
    412403
     
    442433    ////////////////////////
    443434      HeapEntry()
    444       :owner(false,0
    445 #if L1_MULTI_CACHE
    446              ,0
    447 #endif
    448              )
     435      :owner(false,0)
    449436      {
    450437        next = 0;
     
    454441    // Constructor
    455442    ////////////////////////
    456       HeapEntry(const HeapEntry &entry){
     443      HeapEntry(const HeapEntry &entry)
     444      {
    457445        owner.inst  = entry.owner.inst;
    458446        owner.srcid = entry.owner.srcid;
    459 #if L1_MULTI_CACHE
    460         owner.cache_id = entry.owner.cache_id;
    461 #endif       
    462447        next           = entry.next;
    463448      } // end constructor
     
    466451    // The copy() function copies an existing source entry to a target
    467452    /////////////////////////////////////////////////////////////////////
    468       void copy(const HeapEntry &entry){
     453      void copy(const HeapEntry &entry)
     454      {
    469455        owner.inst     = entry.owner.inst;
    470456        owner.srcid    = entry.owner.srcid;
    471 #if L1_MULTI_CACHE
    472         owner.cache_id = entry.owner.cache_id;
    473 #endif
    474457        next           = entry.next;
    475458      } // end copy()
     
    482465        << " -- owner.inst     : " << std::dec << owner.inst << std::endl
    483466        << " -- owner.srcid    : " << std::dec << owner.srcid << std::endl
    484 #if L1_MULTI_CACHE
    485         << " -- owner.cache_id : " << std::dec << owner.cache_id << std::endl
    486 #endif
    487467        << " -- next           : " << std::dec << next << std::endl;
    488468
     
    645625  //                        Cache Data
    646626  ////////////////////////////////////////////////////////////////////////
    647   class CacheData {
     627  class CacheData
     628  {
    648629    private:
    649630      const uint32_t m_sets;
     
    655636    public:
    656637
     638      ///////////////////////////////////////////////////////
    657639      CacheData(uint32_t ways, uint32_t sets, uint32_t words)
    658         : m_sets(sets), m_ways(ways), m_words(words) {
    659 
     640        : m_sets(sets), m_ways(ways), m_words(words)
     641      {
    660642          m_cache_data = new uint32_t ** [ways];
    661           for ( size_t i=0 ; i < ways ; i++ ) {
    662             m_cache_data[i] = new uint32_t * [sets];
     643          for ( size_t i=0 ; i < ways ; i++ )
     644          {
     645              m_cache_data[i] = new uint32_t * [sets];
    663646          }
    664           for ( size_t i=0; i<ways; i++ ) {
    665             for ( size_t j=0; j<sets; j++ ) {
    666               m_cache_data[i][j] = new uint32_t [words];
    667             }
     647          for ( size_t i=0; i<ways; i++ )
     648          {
     649              for ( size_t j=0; j<sets; j++ )
     650              {
     651                  m_cache_data[i][j] = new uint32_t [words];
     652              }
    668653          }
    669         }
    670 
    671       ~CacheData() {
    672           for(size_t i=0; i<m_ways ; i++){
    673               for(size_t j=0; j<m_sets ; j++){
     654      }
     655      ////////////
     656      ~CacheData()
     657      {
     658          for(size_t i=0; i<m_ways ; i++)
     659          {
     660              for(size_t j=0; j<m_sets ; j++)
     661              {
    674662                  delete [] m_cache_data[i][j];
    675663              }
    676664          }
    677           for(size_t i=0; i<m_ways ; i++){
     665          for(size_t i=0; i<m_ways ; i++)
     666          {
    678667              delete [] m_cache_data[i];
    679668          }
    680669          delete [] m_cache_data;
    681670      }
    682 
    683       uint32_t read (
    684           const uint32_t &way,
    685           const uint32_t &set,
    686           const uint32_t &word) const {
    687 
    688         assert((set  < m_sets ) && "Cache data error: Trying to read a wrong set" );
    689         assert((way  < m_ways ) && "Cache data error: Trying to read a wrong way" );
    690         assert((word < m_words) && "Cache data error: Trying to read a wrong word");
    691 
    692         return m_cache_data[way][set][word];
    693       }
    694 
    695       void read_line(
    696           const uint32_t &way,
    697           const uint32_t &set,
    698           sc_core::sc_signal<uint32_t> * cache_line)
    699       {
    700         assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" );
    701         assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" );
    702 
    703         for (uint32_t word=0; word<m_words; word++)
    704           cache_line[word].write(m_cache_data[way][set][word]);
    705       }
    706 
    707       void write (
    708           const uint32_t &way,
    709           const uint32_t &set,
    710           const uint32_t &word,
    711           const uint32_t &data,
    712           const uint32_t &be = 0xF) {
    713 
    714         assert((set  < m_sets ) && "Cache data error: Trying to write a wrong set" );
    715         assert((way  < m_ways ) && "Cache data error: Trying to write a wrong way" );
    716         assert((word < m_words) && "Cache data error: Trying to write a wrong word");
    717         assert((be  <= 0xF    ) && "Cache data error: Trying to write a wrong word cell");
    718 
    719         if (be == 0x0) return;
    720 
    721         if (be == 0xF) {
    722             m_cache_data[way][set][word] = data;
    723             return;
    724         }
    725 
    726         uint32_t mask = 0;
    727         if  (be & 0x1) mask = mask | 0x000000FF;
    728         if  (be & 0x2) mask = mask | 0x0000FF00;
    729         if  (be & 0x4) mask = mask | 0x00FF0000;
    730         if  (be & 0x8) mask = mask | 0xFF000000;
    731 
    732         m_cache_data[way][set][word] =
    733           (data & mask) | (m_cache_data[way][set][word] & ~mask);
     671      //////////////////////////////////////////
     672      uint32_t read ( const uint32_t &way,
     673                      const uint32_t &set,
     674                      const uint32_t &word) const
     675      {
     676          assert((set  < m_sets ) && "Cache data error: Trying to read a wrong set" );
     677          assert((way  < m_ways ) && "Cache data error: Trying to read a wrong way" );
     678          assert((word < m_words) && "Cache data error: Trying to read a wrong word");
     679
     680          return m_cache_data[way][set][word];
     681      }
     682      //////////////////////////////////////////
     683      void read_line( const uint32_t &way,
     684                      const uint32_t &set,
     685                      sc_core::sc_signal<uint32_t> * cache_line)
     686      {
     687          assert((set < m_sets ) && "Cache data error: Trying to read a wrong set" );
     688          assert((way < m_ways ) && "Cache data error: Trying to read a wrong way" );
     689
     690          for (uint32_t word=0; word<m_words; word++)
     691              cache_line[word].write(m_cache_data[way][set][word]);
     692      }
     693      /////////////////////////////////////////
     694      void write ( const uint32_t &way,
     695                   const uint32_t &set,
     696                   const uint32_t &word,
     697                   const uint32_t &data,
     698                   const uint32_t &be = 0xF)
     699      {
     700
     701          assert((set  < m_sets ) && "Cache data error: Trying to write a wrong set" );
     702          assert((way  < m_ways ) && "Cache data error: Trying to write a wrong way" );
     703          assert((word < m_words) && "Cache data error: Trying to write a wrong word");
     704          assert((be  <= 0xF    ) && "Cache data error: Trying to write a wrong be");
     705
     706          if (be == 0x0) return;
     707
     708          if (be == 0xF)
     709          {
     710              m_cache_data[way][set][word] = data;
     711              return;
     712          }
     713
     714          uint32_t mask = 0;
     715          if  (be & 0x1) mask = mask | 0x000000FF;
     716          if  (be & 0x2) mask = mask | 0x0000FF00;
     717          if  (be & 0x4) mask = mask | 0x00FF0000;
     718          if  (be & 0x8) mask = mask | 0xFF000000;
     719
     720          m_cache_data[way][set][word] =
     721              (data & mask) | (m_cache_data[way][set][word] & ~mask);
    734722      }
    735723  }; // end class CacheData
  • branches/ODCCP/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h

    r479 r494  
    2525 * SOCLIB_LGPL_HEADER_END
    2626 *
    27  * Maintainers: alain eric.guthmuller@polytechnique.edu
     27 * Maintainers: alain.greiner@lip6.fr
     28 *              eric.guthmuller@polytechnique.edu
    2829 *              cesar.fuguet-tortolero@lip6.fr
    2930 *              alexandre.joannou@lip6.fr
     
    150151        MULTI_ACK_UPT_LOCK,
    151152        MULTI_ACK_UPT_CLEAR,
    152         MULTI_ACK_WRITE_RSP,
    153         MULTI_ACK_CONFIG_ACK
     153        MULTI_ACK_WRITE_RSP
    154154      };
    155155
     
    159159        CONFIG_IDLE,
    160160        CONFIG_LOOP,
     161        CONFIG_WAIT,
    161162        CONFIG_RSP,
    162163        CONFIG_DIR_REQ,
    163164        CONFIG_DIR_ACCESS,
    164         CONFIG_DIR_IVT_LOCK,
     165        CONFIG_IVT_LOCK,
    165166        CONFIG_BC_SEND,
    166         CONFIG_BC_WAIT,
    167         CONFIG_INV_SEND,
     167        CONFIG_INVAL_SEND,
    168168        CONFIG_HEAP_REQ,
    169169        CONFIG_HEAP_SCAN,
    170170        CONFIG_HEAP_LAST,
    171         CONFIG_INV_WAIT
     171        CONFIG_TRT_LOCK,
     172        CONFIG_TRT_SET,
     173        CONFIG_PUT_REQ
    172174      };
    173175
     
    197199        WRITE_DIR_REQ,
    198200        WRITE_DIR_LOCK,
    199         WRITE_DIR_READ,
    200201        WRITE_DIR_HIT,
    201202        WRITE_UPT_LOCK,
     
    209210        WRITE_MISS_TRT_SET,
    210211        WRITE_MISS_XRAM_REQ,
     212        WRITE_BC_DIR_READ,
    211213        WRITE_BC_TRT_LOCK,
    212214        WRITE_BC_IVT_LOCK,
     
    235237        XRAM_RSP_DIR_UPDT,
    236238        XRAM_RSP_DIR_RSP,
    237         XRAM_RSP_INVAL_LOCK,
     239        XRAM_RSP_IVT_LOCK,
    238240        XRAM_RSP_INVAL_WAIT,
    239241        XRAM_RSP_INVAL,
     
    254256        IXR_CMD_XRAM_IDLE,
    255257        IXR_CMD_CLEANUP_IDLE,
    256         IXR_CMD_TRT_LOCK,
    257         IXR_CMD_READ,
    258         IXR_CMD_WRITE,
    259         IXR_CMD_CAS,
    260         IXR_CMD_XRAM,
    261         IXR_CMD_CLEANUP_DATA
     258        IXR_CMD_CONFIG_IDLE,
     259        IXR_CMD_READ_TRT,
     260        IXR_CMD_WRITE_TRT,
     261        IXR_CMD_CAS_TRT,
     262        IXR_CMD_XRAM_TRT,
     263        IXR_CMD_CLEANUP_TRT,
     264        IXR_CMD_CONFIG_TRT,
     265        IXR_CMD_READ_SEND,
     266        IXR_CMD_WRITE_SEND,
     267        IXR_CMD_CAS_SEND,
     268        IXR_CMD_XRAM_SEND,
     269        IXR_CMD_CLEANUP_DATA_SEND,
     270        IXR_CMD_CONFIG_SEND
    262271      };
    263272
     
    306315        CLEANUP_IVT_CLEAR,
    307316        CLEANUP_WRITE_RSP,
    308         CLEANUP_CONFIG_ACK,
    309317        CLEANUP_IXR_REQ,
    310318        CLEANUP_WAIT,
     
    333341        ALLOC_TRT_IXR_RSP,
    334342        ALLOC_TRT_CLEANUP,
    335         ALLOC_TRT_IXR_CMD
     343        ALLOC_TRT_IXR_CMD,
     344        ALLOC_TRT_CONFIG
    336345      };
    337346
     
    394403      };
    395404
    396       /* Configuration commands */
    397       enum cmd_config_type_e
    398       {
    399           CMD_CONFIG_INVAL = 0,
    400           CMD_CONFIG_SYNC  = 1
    401       };
    402 
    403       // debug variables (for each FSM)
     405      // debug variables
    404406      bool                 m_debug;
    405407      bool                 m_debug_previous_valid;
    406408      size_t               m_debug_previous_count;
    407409      bool                 m_debug_previous_dirty;
    408       sc_signal<data_t>*   m_debug_previous_data;
    409       sc_signal<data_t>*   m_debug_data;
    410 
    411       bool         m_monitor_ok;
    412       addr_t       m_monitor_base;
    413       addr_t       m_monitor_length;
     410      data_t *             m_debug_previous_data;
     411      data_t *             m_debug_data;
    414412
    415413      // instrumentation counters
     
    619617      uint32_t                           m_broadcast_boundaries;
    620618
    621       //////////////////////////////////////////////////
    622       // Registers controlled by the TGT_CMD fsm
    623       //////////////////////////////////////////////////
    624 
    625       sc_signal<int>         r_tgt_cmd_fsm;
    626 
    627619      // Fifo between TGT_CMD fsm and READ fsm
    628620      GenericFifo<addr_t>    m_cmd_read_addr_fifo;
     
    668660      sc_signal<size_t>   r_tgt_cmd_config_cmd;
    669661
     662      //////////////////////////////////////////////////
     663      // Registers controlled by the TGT_CMD fsm
     664      //////////////////////////////////////////////////
     665
     666      sc_signal<int>         r_tgt_cmd_fsm;
     667      sc_signal<size_t>      r_tgt_cmd_srcid;           // srcid for response to config
     668      sc_signal<size_t>      r_tgt_cmd_trdid;           // trdid for response to config
     669      sc_signal<size_t>      r_tgt_cmd_pktid;           // pktid for response to config
     670
    670671      ///////////////////////////////////////////////////////
    671672      // Registers controlled by the CONFIG fsm
    672673      ///////////////////////////////////////////////////////
    673674
    674       sc_signal<int>      r_config_fsm;            // FSM state
    675       sc_signal<bool>     r_config_lock;           // lock protecting exclusive access
    676       sc_signal<int>      r_config_cmd;            // config request status
    677       sc_signal<addr_t>   r_config_address;        // target buffer physical address
    678       sc_signal<size_t>   r_config_srcid;          // config request srcid
    679       sc_signal<size_t>   r_config_trdid;          // config request trdid
    680       sc_signal<size_t>   r_config_pktid;          // config request pktid
    681       sc_signal<size_t>   r_config_nlines;         // number of lines covering the buffer
    682       sc_signal<size_t>   r_config_dir_way;        // DIR: selected way
    683       sc_signal<size_t>   r_config_dir_count;      // DIR: number of copies
    684       sc_signal<bool>     r_config_dir_is_cnt;     // DIR: counter mode (broadcast required)
    685       sc_signal<size_t>   r_config_dir_copy_srcid; // DIR: first copy SRCID
    686       sc_signal<bool>     r_config_dir_copy_inst;  // DIR: first copy L1 type
    687       sc_signal<size_t>   r_config_dir_next_ptr;   // DIR: index of next copy in HEAP
    688       sc_signal<size_t>   r_config_heap_next;      // current pointer to scan HEAP
    689 
    690       sc_signal<size_t>   r_config_ivt_index;      // IVT index
     675      sc_signal<int>      r_config_fsm;               // FSM state
     676      sc_signal<bool>     r_config_lock;              // lock protecting exclusive access
     677      sc_signal<int>      r_config_cmd;               // config request type 
     678      sc_signal<addr_t>   r_config_address;           // target buffer physical address
     679      sc_signal<size_t>   r_config_srcid;             // config request srcid
     680      sc_signal<size_t>   r_config_trdid;             // config request trdid
     681      sc_signal<size_t>   r_config_pktid;             // config request pktid
     682      sc_signal<size_t>   r_config_cmd_lines;         // number of lines to be handled
     683      sc_signal<size_t>   r_config_rsp_lines;         // number of lines not completed
     684      sc_signal<size_t>   r_config_dir_way;           // DIR: selected way
     685      sc_signal<bool>     r_config_dir_lock;          // DIR: locked entry
     686      sc_signal<size_t>   r_config_dir_count;         // DIR: number of copies
     687      sc_signal<bool>     r_config_dir_is_cnt;        // DIR: counter mode (broadcast)
     688      sc_signal<size_t>   r_config_dir_copy_srcid;    // DIR: first copy SRCID
     689      sc_signal<bool>     r_config_dir_copy_inst;     // DIR: first copy L1 type
     690      sc_signal<size_t>   r_config_dir_ptr;           // DIR: index of next copy in HEAP
     691      sc_signal<size_t>   r_config_heap_next;         // current pointer to scan HEAP
     692      sc_signal<size_t>   r_config_trt_index;         // selected entry in TRT
     693      sc_signal<size_t>   r_config_ivt_index;         // selected entry in IVT
     694
     695      // Buffer between CONFIG fsm and IXR_CMD fsm
     696      sc_signal<bool>     r_config_to_ixr_cmd_req;    // valid request
     697      sc_signal<size_t>   r_config_to_ixr_cmd_index;  // TRT index
     698
    691699
    692700      // Buffer between CONFIG fsm and TGT_RSP fsm (send a done response to L1 cache)
     
    705713      GenericFifo<size_t> m_config_to_cc_send_srcid_fifo;   // fifo for owners srcid
    706714
    707 #if L1_MULTI_CACHE
    708       GenericFifo<size_t> m_config_to_cc_send_cache_id_fifo; // fifo for cache_id
    709 #endif
    710 
    711715      ///////////////////////////////////////////////////////
    712716      // Registers controlled by the READ fsm
    713717      ///////////////////////////////////////////////////////
    714718
    715       sc_signal<int>      r_read_fsm;          // FSM state
    716       sc_signal<size_t>   r_read_copy;         // Srcid of the first copy
    717       sc_signal<size_t>   r_read_copy_cache;   // Srcid of the first copy
    718       sc_signal<bool>     r_read_copy_inst;    // Type of the first copy
    719       sc_signal<tag_t>    r_read_tag;          // cache line tag (in directory)
    720       sc_signal<bool>     r_read_is_cnt;       // is_cnt bit (in directory)
    721       sc_signal<bool>     r_read_lock;         // lock bit (in directory)
    722       sc_signal<bool>     r_read_dirty;        // dirty bit (in directory)
    723       sc_signal<size_t>   r_read_count;        // number of copies
    724       sc_signal<size_t>   r_read_ptr;          // pointer to the heap
    725       sc_signal<data_t> * r_read_data;         // data (one cache line)
    726       sc_signal<size_t>   r_read_way;          // associative way (in cache)
    727       sc_signal<size_t>   r_read_trt_index;    // Transaction Table index
    728       sc_signal<size_t>   r_read_next_ptr;     // Next entry to point to
    729       sc_signal<bool>     r_read_last_free;    // Last free entry
    730       sc_signal<addr_t>   r_read_ll_key;       // LL key from the llsc_global_table
    731 
    732       // Buffer between READ fsm and IXR_CMD fsm (ask a missing cache line to XRAM)
    733       sc_signal<bool>     r_read_to_ixr_cmd_req;    // valid request
    734       sc_signal<addr_t>   r_read_to_ixr_cmd_nline;  // cache line index
    735       sc_signal<size_t>   r_read_to_ixr_cmd_trdid;  // index in Transaction Table
     719      sc_signal<int>      r_read_fsm;                 // FSM state
     720      sc_signal<size_t>   r_read_copy;                // Srcid of the first copy
     721      sc_signal<size_t>   r_read_copy_cache;          // Srcid of the first copy
     722      sc_signal<bool>     r_read_copy_inst;           // Type of the first copy
     723      sc_signal<tag_t>    r_read_tag;                 // cache line tag (in directory)
     724      sc_signal<bool>     r_read_is_cnt;              // is_cnt bit (in directory)
     725      sc_signal<bool>     r_read_lock;                // lock bit (in directory)
     726      sc_signal<bool>     r_read_dirty;               // dirty bit (in directory)
     727      sc_signal<size_t>   r_read_count;               // number of copies
     728      sc_signal<size_t>   r_read_ptr;                 // pointer to the heap
     729      sc_signal<data_t> * r_read_data;                // data (one cache line)
     730      sc_signal<size_t>   r_read_way;                 // associative way (in cache)
     731      sc_signal<size_t>   r_read_trt_index;           // Transaction Table index
     732      sc_signal<size_t>   r_read_next_ptr;            // Next entry to point to
     733      sc_signal<bool>     r_read_last_free;           // Last free entry
     734      sc_signal<addr_t>   r_read_ll_key;              // LL key from llsc_global_table
     735
     736      // Buffer between READ fsm and IXR_CMD fsm
     737      sc_signal<bool>     r_read_to_ixr_cmd_req;      // valid request
     738      sc_signal<size_t>   r_read_to_ixr_cmd_index;    // TRT index
    736739
    737740      // Buffer between READ fsm and TGT_RSP fsm (send a hit read response to L1 cache)
    738       sc_signal<bool>     r_read_to_tgt_rsp_req;    // valid request
    739       sc_signal<size_t>   r_read_to_tgt_rsp_srcid;  // Transaction srcid
    740       sc_signal<size_t>   r_read_to_tgt_rsp_trdid;  // Transaction trdid
    741       sc_signal<size_t>   r_read_to_tgt_rsp_pktid;  // Transaction pktid
    742       sc_signal<data_t> * r_read_to_tgt_rsp_data;   // data (one cache line)
    743       sc_signal<size_t>   r_read_to_tgt_rsp_word;   // first word of the response
    744       sc_signal<size_t>   r_read_to_tgt_rsp_length; // length of the response
    745       sc_signal<addr_t>   r_read_to_tgt_rsp_ll_key; // LL key from the llsc_global_table
     741      sc_signal<bool>     r_read_to_tgt_rsp_req;      // valid request
     742      sc_signal<size_t>   r_read_to_tgt_rsp_srcid;    // Transaction srcid
     743      sc_signal<size_t>   r_read_to_tgt_rsp_trdid;    // Transaction trdid
     744      sc_signal<size_t>   r_read_to_tgt_rsp_pktid;    // Transaction pktid
     745      sc_signal<data_t> * r_read_to_tgt_rsp_data;     // data (one cache line)
     746      sc_signal<size_t>   r_read_to_tgt_rsp_word;     // first word of the response
     747      sc_signal<size_t>   r_read_to_tgt_rsp_length;   // length of the response
     748      sc_signal<addr_t>   r_read_to_tgt_rsp_ll_key;   // LL key from llsc_global_table
    746749
    747750      ///////////////////////////////////////////////////////////////
     
    749752      ///////////////////////////////////////////////////////////////
    750753
    751       sc_signal<int>      r_write_fsm;        // FSM state
    752       sc_signal<addr_t>   r_write_address;    // first word address
    753       sc_signal<size_t>   r_write_word_index; // first word index in line
    754       sc_signal<size_t>   r_write_word_count; // number of words in line
    755       sc_signal<size_t>   r_write_srcid;      // transaction srcid
    756       sc_signal<size_t>   r_write_trdid;      // transaction trdid
    757       sc_signal<size_t>   r_write_pktid;      // transaction pktid
    758       sc_signal<data_t> * r_write_data;       // data (one cache line)
    759       sc_signal<be_t>   * r_write_be;         // one byte enable per word
    760       sc_signal<bool>     r_write_byte;       // (BE != 0X0) and (BE != 0xF)
    761       sc_signal<bool>     r_write_is_cnt;     // is_cnt bit (in directory)
    762       sc_signal<bool>     r_write_lock;       // lock bit (in directory)
    763       sc_signal<tag_t>    r_write_tag;        // cache line tag (in directory)
    764       sc_signal<size_t>   r_write_copy;       // first owner of the line
    765       sc_signal<size_t>   r_write_copy_cache; // first owner of the line
    766       sc_signal<bool>     r_write_copy_inst;  // is this owner a ICache ?
    767       sc_signal<size_t>   r_write_count;      // number of copies
    768       sc_signal<size_t>   r_write_ptr;        // pointer to the heap
    769       sc_signal<size_t>   r_write_next_ptr;   // next pointer to the heap
    770       sc_signal<bool>     r_write_to_dec;     // need to decrement update counter
    771       sc_signal<size_t>   r_write_way;        // way of the line
    772       sc_signal<size_t>   r_write_trt_index;  // index in Transaction Table
    773       sc_signal<size_t>   r_write_upt_index;  // index in Update Table
    774       sc_signal<bool>     r_write_sc_fail;    // sc command failed
    775       sc_signal<bool>     r_write_pending_sc; // sc command pending
     754      sc_signal<int>      r_write_fsm;                // FSM state
     755      sc_signal<addr_t>   r_write_address;            // first word address
     756      sc_signal<size_t>   r_write_word_index;         // first word index in line
     757      sc_signal<size_t>   r_write_word_count;         // number of words in line
     758      sc_signal<size_t>   r_write_srcid;              // transaction srcid
     759      sc_signal<size_t>   r_write_trdid;              // transaction trdid
     760      sc_signal<size_t>   r_write_pktid;              // transaction pktid
     761      sc_signal<data_t> * r_write_data;               // data (one cache line)
     762      sc_signal<be_t>   * r_write_be;                 // one byte enable per word
     763      sc_signal<bool>     r_write_byte;               // (BE != 0X0) and (BE != 0xF)
     764      sc_signal<bool>     r_write_is_cnt;             // is_cnt bit (in directory)
     765      sc_signal<bool>     r_write_lock;               // lock bit (in directory)
     766      sc_signal<tag_t>    r_write_tag;                // cache line tag (in directory)
     767      sc_signal<size_t>   r_write_copy;               // first owner of the line
     768      sc_signal<size_t>   r_write_copy_cache;         // first owner of the line
     769      sc_signal<bool>     r_write_copy_inst;          // is this owner a ICache ?
     770      sc_signal<size_t>   r_write_count;              // number of copies
     771      sc_signal<size_t>   r_write_ptr;                // pointer to the heap
     772      sc_signal<size_t>   r_write_next_ptr;           // next pointer to the heap
     773      sc_signal<bool>     r_write_to_dec;             // need to decrement update counter
     774      sc_signal<size_t>   r_write_way;                // way of the line
     775      sc_signal<size_t>   r_write_trt_index;          // index in Transaction Table
     776      sc_signal<size_t>   r_write_upt_index;          // index in Update Table
     777      sc_signal<bool>     r_write_sc_fail;            // sc command failed
     778      sc_signal<bool>     r_write_pending_sc;         // sc command pending
    776779
    777780      // Buffer between WRITE fsm and TGT_RSP fsm (acknowledge a write command from L1)
     
    782785      sc_signal<bool>     r_write_to_tgt_rsp_sc_fail; // sc command failed
    783786
    784       // Buffer between WRITE fsm and IXR_CMD fsm (ask a missing cache line to XRAM)
    785       sc_signal<bool>     r_write_to_ixr_cmd_req;   // valid request
    786       sc_signal<bool>     r_write_to_ixr_cmd_write; // write request
    787       sc_signal<addr_t>   r_write_to_ixr_cmd_nline; // cache line index
    788       sc_signal<data_t> * r_write_to_ixr_cmd_data;  // cache line data
    789       sc_signal<size_t>   r_write_to_ixr_cmd_trdid; // index in Transaction Table
     787      // Buffer between WRITE fsm and IXR_CMD fsm
     788      sc_signal<bool>     r_write_to_ixr_cmd_req;     // valid request
     789      sc_signal<bool>     r_write_to_ixr_cmd_put;     // request type (GET/PUT)
     790      sc_signal<size_t>   r_write_to_ixr_cmd_index;   // TRT index
    790791
    791792      // Buffer between WRITE fsm and CC_SEND fsm (Update/Invalidate L1 caches)
     
    801802      GenericFifo<size_t> m_write_to_cc_send_srcid_fifo;    // fifo for srcids
    802803
    803 #if L1_MULTI_CACHE
    804       GenericFifo<size_t> m_write_to_cc_send_cache_id_fifo; // fifo for srcids
    805 #endif
    806 
    807804      // Buffer between WRITE fsm and MULTI_ACK fsm (Decrement UPT entry)
    808805      sc_signal<bool>     r_write_to_multi_ack_req;       // valid request
     
    820817      sc_signal<addr_t>   r_multi_ack_nline;     // pending write nline
    821818
    822       // signaling completion of multi-inval to CONFIG fsm
    823       sc_signal<bool>     r_multi_ack_to_config_ack;
    824 
    825819      // Buffer between MULTI_ACK fsm and TGT_RSP fsm (complete write/update transaction)
    826820      sc_signal<bool>     r_multi_ack_to_tgt_rsp_req;   // valid request
     
    839833      sc_signal<addr_t>   r_cleanup_nline;         // cache line index
    840834
    841 #if L1_MULTI_CACHE
    842       sc_signal<size_t>   r_cleanup_pktid;         // transaction pktid
    843 #endif
    844835
    845836      sc_signal<copy_t>   r_cleanup_copy;          // first copy
     
    868859      sc_signal<size_t>   r_cleanup_index;         // index of the INVAL line (in the UPT)
    869860
    870       // signaling completion of broadcast-inval to CONFIG fsm
    871       sc_signal<bool>     r_cleanup_to_config_ack; 
    872        
    873861      // Buffer between CLEANUP fsm and TGT_RSP fsm (acknowledge a write command from L1)
    874862      sc_signal<bool>     r_cleanup_to_tgt_rsp_req;   // valid request
     
    881869      ///////////////////////////////////////////////////////
    882870
    883       sc_signal<int>      r_cas_fsm;        // FSM state
    884       sc_signal<data_t>   r_cas_wdata;      // write data word
    885       sc_signal<data_t> * r_cas_rdata;      // read data word
    886       sc_signal<uint32_t> r_cas_lfsr;       // lfsr for random introducing
    887       sc_signal<size_t>   r_cas_cpt;        // size of command
    888       sc_signal<copy_t>   r_cas_copy;       // Srcid of the first copy
    889       sc_signal<copy_t>   r_cas_copy_cache; // Srcid of the first copy
    890       sc_signal<bool>     r_cas_copy_inst;  // Type of the first copy
    891       sc_signal<size_t>   r_cas_count;      // number of copies
    892       sc_signal<size_t>   r_cas_ptr;        // pointer to the heap
    893       sc_signal<size_t>   r_cas_next_ptr;   // next pointer to the heap
    894       sc_signal<bool>     r_cas_is_cnt;     // is_cnt bit (in directory)
    895       sc_signal<bool>     r_cas_dirty;      // dirty bit (in directory)
    896       sc_signal<size_t>   r_cas_way;        // way in directory
    897       sc_signal<size_t>   r_cas_set;        // set in directory
    898       sc_signal<data_t>   r_cas_tag;        // cache line tag (in directory)
    899       sc_signal<size_t>   r_cas_trt_index;  // Transaction Table index
    900       sc_signal<size_t>   r_cas_upt_index;  // Update Table index
    901       sc_signal<data_t> * r_cas_data;       // cache line data
    902 
    903       // Buffer between CAS fsm and IXR_CMD fsm (XRAM write)
     871      sc_signal<int>      r_cas_fsm;              // FSM state
     872      sc_signal<data_t>   r_cas_wdata;            // write data word
     873      sc_signal<data_t> * r_cas_rdata;            // read data word
     874      sc_signal<uint32_t> r_cas_lfsr;             // lfsr for random introducing
     875      sc_signal<size_t>   r_cas_cpt;              // size of command
     876      sc_signal<copy_t>   r_cas_copy;             // Srcid of the first copy
     877      sc_signal<copy_t>   r_cas_copy_cache;       // Srcid of the first copy
     878      sc_signal<bool>     r_cas_copy_inst;        // Type of the first copy
     879      sc_signal<size_t>   r_cas_count;            // number of copies
     880      sc_signal<size_t>   r_cas_ptr;              // pointer to the heap
     881      sc_signal<size_t>   r_cas_next_ptr;         // next pointer to the heap
     882      sc_signal<bool>     r_cas_is_cnt;           // is_cnt bit (in directory)
     883      sc_signal<bool>     r_cas_dirty;            // dirty bit (in directory)
     884      sc_signal<size_t>   r_cas_way;              // way in directory
     885      sc_signal<size_t>   r_cas_set;              // set in directory
     886      sc_signal<data_t>   r_cas_tag;              // cache line tag (in directory)
     887      sc_signal<size_t>   r_cas_trt_index;        // Transaction Table index
     888      sc_signal<size_t>   r_cas_upt_index;        // Update Table index
     889      sc_signal<data_t> * r_cas_data;             // cache line data
     890
     891      // Buffer between CAS fsm and IXR_CMD fsm
    904892      sc_signal<bool>     r_cas_to_ixr_cmd_req;   // valid request
    905       sc_signal<addr_t>   r_cas_to_ixr_cmd_nline; // cache line index
    906       sc_signal<size_t>   r_cas_to_ixr_cmd_trdid; // index in Transaction Table
    907       sc_signal<bool>     r_cas_to_ixr_cmd_write; // write request
    908       sc_signal<data_t> * r_cas_to_ixr_cmd_data;  // cache line data
    909 
     893      sc_signal<bool>     r_cas_to_ixr_cmd_put;   // request type (GET/PUT)
     894      sc_signal<size_t>   r_cas_to_ixr_cmd_index; // TRT index
    910895
    911896      // Buffer between CAS fsm and TGT_RSP fsm
     
    928913      GenericFifo<size_t> m_cas_to_cc_send_srcid_fifo;    // fifo for srcids
    929914
    930 #if L1_MULTI_CACHE
    931       GenericFifo<size_t> m_cas_to_cc_send_cache_id_fifo; // fifo for srcids
    932 #endif
    933 
    934915      ////////////////////////////////////////////////////
    935916      // Registers controlled by the IXR_RSP fsm
    936917      ////////////////////////////////////////////////////
    937918
    938       sc_signal<int>      r_ixr_rsp_fsm;       // FSM state
    939       sc_signal<size_t>   r_ixr_rsp_trt_index; // TRT entry index
    940       sc_signal<size_t>   r_ixr_rsp_cpt;       // word counter
     919      sc_signal<int>      r_ixr_rsp_fsm;                // FSM state
     920      sc_signal<size_t>   r_ixr_rsp_trt_index;          // TRT entry index
     921      sc_signal<size_t>   r_ixr_rsp_cpt;                // word counter
     922
     923      // Buffer between IXR_RSP fsm and CONFIG fsm  (response from the XRAM)
     924      sc_signal<bool>     r_ixr_rsp_to_config_ack;      // one single bit   
    941925
    942926      // Buffer between IXR_RSP fsm and XRAM_RSP fsm  (response from the XRAM)
    943       sc_signal<bool>   * r_ixr_rsp_to_xram_rsp_rok; // A xram response is ready
     927      sc_signal<bool>   * r_ixr_rsp_to_xram_rsp_rok;    // one bit per TRT entry
    944928      sc_signal<bool>   * r_ixr_rsp_to_xram_rsp_no_coherent; // A xram response is ready and no coherent (ODCCP)
    945929
     
    986970      GenericFifo<size_t> m_xram_rsp_to_cc_send_srcid_fifo;    // fifo for srcids
    987971
    988 #if L1_MULTI_CACHE
    989       GenericFifo<size_t> m_xram_rsp_to_cc_send_cache_id_fifo; // fifo for srcids
    990 #endif
    991 
    992       // Buffer between XRAM_RSP fsm and IXR_CMD fsm (XRAM write)
     972      // Buffer between XRAM_RSP fsm and IXR_CMD fsm
    993973      sc_signal<bool>     r_xram_rsp_to_ixr_cmd_req;   // Valid request
    994       sc_signal<addr_t>   r_xram_rsp_to_ixr_cmd_nline; // cache line index
    995       sc_signal<data_t> * r_xram_rsp_to_ixr_cmd_data;  // cache line data
    996       sc_signal<size_t>   r_xram_rsp_to_ixr_cmd_trdid; // index in transaction table
     974      sc_signal<size_t>   r_xram_rsp_to_ixr_cmd_index; // TRT index
    997975
    998976      ////////////////////////////////////////////////////
     
    1001979
    1002980      sc_signal<int>      r_ixr_cmd_fsm;
    1003       sc_signal<size_t>   r_ixr_cmd_cpt;
     981      sc_signal<size_t>   r_ixr_cmd_word;              // word index for a put
     982      sc_signal<size_t>   r_ixr_cmd_trdid;             // TRT index value     
     983      sc_signal<addr_t>   r_ixr_cmd_address;           // address to XRAM
     984      sc_signal<data_t> * r_ixr_cmd_wdata;             // cache line buffer
     985      sc_signal<bool>     r_ixr_cmd_get;               // transaction type (PUT/GET)
    1004986
    1005987      ////////////////////////////////////////////////////
     
    10761058      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_srcid;
    10771059      sc_signal<bool>      r_cleanup_to_ixr_cmd_l1_dirty_ncc; // this cleanup was dirty in L1
    1078       sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_trdid;
     1060      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_index;
    10791061      sc_signal<uint32_t>  r_cleanup_to_ixr_cmd_pktid;
    10801062      sc_signal<addr_t>    r_cleanup_to_ixr_cmd_nline;
  • branches/ODCCP/modules/vci_mem_cache/caba/source/include/xram_transaction.h

    r460 r494  
    3434    bool                rerror;         // error returned by xram
    3535    data_t              ll_key;         // LL key returned by the llsc_global_table
     36    bool                config;         // transaction required by CONFIG FSM
    3637
    3738    /////////////////////////////////////////////////////////////////////
     
    4243        valid           = false;
    4344        rerror      = false;
     45        config      = false;
    4446    }
    4547
     
    8082        rerror      = source.rerror;
    8183        ll_key      = source.ll_key;
     84        config      = source.config;
    8285    }
    8386
     
    8790    void print()
    8891    {
     92        std::cout << "------- TRT entry -------" << std::endl;
    8993        std::cout << "valid       = " << valid        << std::endl;
    9094        std::cout << "xram_read   = " << xram_read    << std::endl;
     
    96100        std::cout << "read_length = " << read_length  << std::endl;
    97101        std::cout << "word_index  = " << word_index   << std::endl;
    98         for(size_t i=0; i<wdata_be.size() ; i++){
    99             std::cout << "wdata_be [" << i <<"] = " << wdata_be[i] << std::endl;
    100         }
    101         for(size_t i=0; i<wdata.size() ; i++){
    102             std::cout << "wdata [" << i <<"] = " << wdata[i] << std::endl;
    103         }
     102        for(size_t i=0; i<wdata_be.size() ; i++)
     103        {
     104            std::cout << "wdata_be[" << std::dec << i << "] = "
     105                      << std::hex << wdata_be[i] << std::endl;
     106        }
     107        for(size_t i=0; i<wdata.size() ; i++)
     108        {
     109            std::cout << "wdata[" << std::dec << i << "] = "
     110                      << std::hex << wdata[i] << std::endl;
     111        }
     112        std::cout << "rerror      = " << rerror       << std::endl;
     113        std::cout << "ll_key      = " << ll_key       << std::endl;
     114        std::cout << "config      = " << config       << std::endl;
    104115        std::cout << std::endl;
    105         std::cout << "rerror      = " << rerror       << std::endl;
    106116    }
    107117
     
    114124        wdata_be.clear();
    115125        wdata.clear();
    116         valid=false;
    117         rerror=false;
    118     }
    119 
    120     TransactionTabEntry(const TransactionTabEntry &source){
     126        valid  = false;
     127        rerror = false;
     128        config = false;
     129    }
     130
     131    TransactionTabEntry(const TransactionTabEntry &source)
     132    {
    121133        valid       = source.valid;
    122134        xram_read       = source.xram_read;
     
    132144        rerror      = source.rerror;
    133145        ll_key      = source.ll_key;
     146        config      = source.config;
    134147    }
    135148
     
    197210        delete [] tab;
    198211    }
    199 
    200212    /////////////////////////////////////////////////////////////////////
    201213    // The size() function returns the size of the tab
     
    205217        return size_tab;
    206218    }
    207 
    208219    /////////////////////////////////////////////////////////////////////
    209220    // The init() function initializes the transaction tab entries
     
    211222    void init()
    212223    {
    213         for ( size_t i=0; i<size_tab; i++) {
     224        for ( size_t i=0; i<size_tab; i++)
     225        {
    214226            tab[i].init();
    215227        }
    216228    }
    217 
    218229    /////////////////////////////////////////////////////////////////////
    219230    // The print() function prints a transaction tab entry
     
    223234    void print(const size_t index)
    224235    {
    225         assert( (index < size_tab)
    226                 && "Invalid Transaction Tab Entry");
     236        assert( (index < size_tab) and
     237        "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()");
     238
    227239        tab[index].print();
    228240        return;
    229241    }
    230 
    231242    /////////////////////////////////////////////////////////////////////
    232243    // The read() function returns a transaction tab entry.
     
    236247    TransactionTabEntry read(const size_t index)
    237248    {
    238         assert( (index < size_tab)
    239                 && "Invalid Transaction Tab Entry");
     249        assert( (index < size_tab) and
     250        "MEMC ERROR: Invalid Transaction Tab Entry");
     251
    240252        return tab[index];
    241253    }
    242 
    243254    /////////////////////////////////////////////////////////////////////
    244255    // The full() function returns the state of the transaction tab
     
    249260    bool full(size_t &index)
    250261    {
    251         for(size_t i=0; i<size_tab; i++){
    252             if(!tab[i].valid){
     262        for(size_t i=0; i<size_tab; i++)
     263        {
     264            if(!tab[i].valid)
     265            {
    253266                index=i;
    254267                return false;   
     
    257270        return true;
    258271    }
    259 
    260272    /////////////////////////////////////////////////////////////////////
    261273    // The hit_read() function checks if an XRAM read transaction exists
     
    268280    bool hit_read(const addr_t nline,size_t &index)
    269281    {
    270         for(size_t i=0; i<size_tab; i++){
    271             if((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read)) {
     282        for(size_t i=0; i<size_tab; i++)
     283        {
     284            if((tab[i].valid && (nline==tab[i].nline)) && (tab[i].xram_read))
     285            {
    272286                index=i;
    273287                return true;   
     
    276290        return false;
    277291    }
    278 
    279292    ///////////////////////////////////////////////////////////////////////
    280293    // The hit_write() function looks if an XRAM write transaction exists
     
    286299    bool hit_write(const addr_t nline)
    287300    {
    288         for(size_t i=0; i<size_tab; i++){
    289             if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read)) {
     301        for(size_t i=0; i<size_tab; i++)
     302        {
     303            if(tab[i].valid && (nline==tab[i].nline) && !(tab[i].xram_read))
     304            {
    290305                return true;   
    291306            }
     
    325340            const std::vector<data_t> &data)
    326341    {
    327         assert( (index < size_tab)
    328                 && "Invalid Transaction Tab Entry");
    329         assert(be.size()==tab[index].wdata_be.size()
    330                 && "Bad data mask in write_data_mask in TransactionTab");
    331         assert(data.size()==tab[index].wdata.size()
    332                 && "Bad data in write_data_mask in TransactionTab");
    333 
    334         for(size_t i=0; i<tab[index].wdata_be.size() ; i++) {
     342        assert( (index < size_tab) and
     343        "MEMC ERROR: The selected entry is out of range in TRT write_data_mask()");
     344
     345        assert( (be.size()==tab[index].wdata_be.size()) and
     346        "MEMC ERROR: Bad be size in TRT write_data_mask()");
     347
     348        assert( (data.size()==tab[index].wdata.size()) and
     349        "MEMC ERROR: Bad data size in TRT write_data_mask()");
     350
     351        for(size_t i=0; i<tab[index].wdata_be.size() ; i++)
     352        {
    335353            tab[index].wdata_be[i] = tab[index].wdata_be[i] | be[i];
    336354            data_t mask = be_to_mask(be[i]);
     
    338356        }
    339357    }
    340 
    341358    /////////////////////////////////////////////////////////////////////
    342359    // The set() function registers a transaction (read or write)
     
    355372    // - data_be : the mask of the data to write (in case of write)
    356373    // - ll_key  : the ll key (if any) returned by the llsc_global_table
     374    // - config  : transaction required by config FSM
    357375    /////////////////////////////////////////////////////////////////////
    358376    void set(const size_t index,
     
    367385            const std::vector<be_t> &data_be,
    368386            const std::vector<data_t> &data,
    369             const data_t ll_key = 0)
    370     {
    371         assert( (index < size_tab)
    372                 && "The selected entry is out of range in set() Transaction Tab");
    373         assert(data_be.size()==tab[index].wdata_be.size()
    374                 && "Bad data_be argument in set() TransactionTab");
    375         assert(data.size()==tab[index].wdata.size()
    376                 && "Bad data argument in set() TransactionTab");
     387            const data_t ll_key = 0,
     388            const bool config = false)
     389    {
     390        assert( (index < size_tab) and
     391        "MEMC ERROR: The selected entry is out of range in TRT set()");
     392
     393        assert( (data_be.size()==tab[index].wdata_be.size()) and
     394        "MEMC ERROR: Bad data_be argument in TRT set()");
     395
     396        assert( (data.size()==tab[index].wdata.size()) and
     397        "MEMC ERROR: Bad data argument in TRT set()");
    377398
    378399        tab[index].valid                = true;
     
    386407        tab[index].word_index       = word_index;
    387408        tab[index].ll_key           = ll_key;
     409        tab[index].config           = config;
    388410        for(size_t i=0; i<tab[index].wdata.size(); i++)
    389411        {
     
    398420    // The BE field in TRT is taken into account.
    399421    // Arguments :
    400     // - index : the index of the transaction in the transaction tab
    401     // - word_index : the index of the data in the line
    402     // - data : a 64 bits value
    403     // - error : invalid data
     422    // - index : index of the entry in TRT
     423    // - word  : index of the 32 bits word in the line
     424    // - data  : 64 bits value (first data right)
    404425    /////////////////////////////////////////////////////////////////////
    405426    void write_rsp(const size_t      index,
    406427                   const size_t      word,
    407                    const wide_data_t data,
    408                    const bool        rerror)
     428                   const wide_data_t data)
    409429    {
    410430        data_t  value;
    411431        data_t  mask;
    412432
    413         if ( index >= size_tab )
    414         {
    415             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    416                       <<  " TRT entry  out of range in write_rsp()" << std::endl;
    417             exit(0);
    418         }
    419         if ( word > tab[index].wdata_be.size() )
    420         {
    421             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    422                       <<  " Bad word_index in write_rsp() in TRT" << std::endl;
    423             exit(0);
    424         }
    425         if ( not tab[index].valid )
    426         {
    427             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    428                       <<  " TRT Entry invalid in write_rsp()" << std::endl;
    429             exit(0);
    430         }
    431         if ( not tab[index].xram_read )
    432         {
    433             std::cout << "VCI_MEM_CACHE ERRROR " << tab_name
    434                       <<  " TRT entry is not an XRAM GET in write_rsp()" << std::endl;
    435             exit(0);
    436         }
     433        assert( (index < size_tab) and
     434        "MEMC ERROR: The selected entry is out of range in TRT write_rsp()");
     435
     436        assert( (word < tab[index].wdata_be.size()) and
     437        "MEMC ERROR: Bad word index in TRT write_rsp()");
     438
     439        assert( (tab[index].valid) and
     440        "MEMC ERROR: TRT entry not valid in TRT write_rsp()");
     441
     442        assert( (tab[index].xram_read ) and
     443        "MEMC ERROR: TRT entry is not a GET in TRT write_rsp()");
    437444
    438445        // first 32 bits word
     
    445452        mask  = be_to_mask(tab[index].wdata_be[word+1]);
    446453        tab[index].wdata[word+1] = (tab[index].wdata[word+1] & mask) | (value & ~mask);
    447 
    448         // error update
    449         tab[index].rerror |= rerror;
    450     }
    451 
     454    }
    452455    /////////////////////////////////////////////////////////////////////
    453456    // The erase() function erases an entry in the transaction tab.
     
    457460    void erase(const size_t index)
    458461    {
    459         assert( (index < size_tab)
    460                 && "The selected entry is out of range in erase() Transaction Tab");
     462        assert( (index < size_tab) and
     463        "MEMC ERROR: The selected entry is out of range in TRT erase()");
     464
    461465        tab[index].valid        = false;
    462466        tab[index].rerror   = false;
     467    }
     468    /////////////////////////////////////////////////////////////////////
     469    // The is_config() function returns the config flag value.
     470    // Arguments :
     471    // - index : the index of the entry in the transaction tab
     472    /////////////////////////////////////////////////////////////////////
     473    bool is_config(const size_t index)
     474    {
     475        assert( (index < size_tab) and
     476        "MEMC ERROR: The selected entry is out of range in TRT is_config()");
     477
     478        return tab[index].config;
    463479    }
    464480}; // end class TransactionTab
  • branches/ODCCP/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r492 r494  
    4545#define DEBUG_MEMC_WRITE     1 // detailed trace of WRITE FSM
    4646#define DEBUG_MEMC_CAS       1 // detailed trace of CAS FSM
    47 #define DEBUG_MEMC_IXR_CMD   1 // detailed trace of IXR_RSP FSM
     47#define DEBUG_MEMC_IXR_CMD   1 // detailed trace of IXR_CMD FSM
    4848#define DEBUG_MEMC_IXR_RSP   1 // detailed trace of IXR_RSP FSM
    4949#define DEBUG_MEMC_XRAM_RSP  1 // detailed trace of XRAM_RSP FSM
     
    127127  "MULTI_ACK_UPT_LOCK",
    128128  "MULTI_ACK_UPT_CLEAR",
    129   "MULTI_ACK_WRITE_RSP",
    130   "MULTI_ACK_CONFIG_ACK"
     129  "MULTI_ACK_WRITE_RSP"
    131130};
    132131const char *config_fsm_str[] =
     
    134133  "CONFIG_IDLE",
    135134  "CONFIG_LOOP",
     135  "CONFIG_WAIT",
    136136  "CONFIG_RSP",
    137137  "CONFIG_DIR_REQ",
    138138  "CONFIG_DIR_ACCESS",
    139   "CONFIG_DIR_IVT_LOCK",
     139  "CONFIG_IVT_LOCK",
    140140  "CONFIG_BC_SEND",
    141   "CONFIG_BC_WAIT",
    142   "CONFIG_INV_SEND",
     141  "CONFIG_INVAL_SEND",
    143142  "CONFIG_HEAP_REQ",
    144143  "CONFIG_HEAP_SCAN",
    145144  "CONFIG_HEAP_LAST",
    146   "CONFIG_INV_WAIT"
     145  "CONFIG_TRT_LOCK",
     146  "CONFIG_TRT_SET",
     147  "CONFIG_PUT_REQ"
    147148};
    148149const char *read_fsm_str[] =
     
    168169  "WRITE_DIR_REQ",
    169170  "WRITE_DIR_LOCK",
    170   "WRITE_DIR_READ",
    171171  "WRITE_DIR_HIT",
    172172  "WRITE_UPT_LOCK",
     
    180180  "WRITE_MISS_TRT_SET",
    181181  "WRITE_MISS_XRAM_REQ",
     182  "WRITE_BC_DIR_READ",
    182183  "WRITE_BC_TRT_LOCK",
    183184  "WRITE_BC_IVT_LOCK",
     
    202203  "XRAM_RSP_DIR_UPDT",
    203204  "XRAM_RSP_DIR_RSP",
    204   "XRAM_RSP_INVAL_LOCK",
     205  "XRAM_RSP_IVT_LOCK",
    205206  "XRAM_RSP_INVAL_WAIT",
    206207  "XRAM_RSP_INVAL",
     
    219220  "IXR_CMD_XRAM_IDLE",
    220221  "IXR_CMD_CLEANUP_IDLE",
    221   "IXR_CMD_TRT_LOCK",
    222   "IXR_CMD_READ",
    223   "IXR_CMD_WRITE",
    224   "IXR_CMD_CAS",
    225   "IXR_CMD_XRAM",
    226   "IXR_CMD_CLEANUP_DATA"
     222  "IXR_CMD_CONFIG_IDLE",
     223  "IXR_CMD_READ_TRT",
     224  "IXR_CMD_WRITE_TRT",
     225  "IXR_CMD_CAS_TRT",
     226  "IXR_CMD_XRAM_TRT",
     227  "IXR_CMD_CLEANUP_TRT",
     228  "IXR_CMD_CONFIG_TRT",
     229  "IXR_CMD_READ_SEND",
     230  "IXR_CMD_WRITE_SEND",
     231  "IXR_CMD_CAS_SEND",
     232  "IXR_CMD_XRAM_SEND",
     233  "IXR_CMD_CLEANUP_DATA_SEND",
     234  "IXR_CMD_CONFIG_SEND"
    227235};
    228236const char *cas_fsm_str[] =
     
    267275  "CLEANUP_IVT_CLEAR",
    268276  "CLEANUP_WRITE_RSP",
    269   "CLEANUP_CONFIG_ACK",
    270277  "CLEANUP_IXR_REQ",
    271278  "CLEANUP_WAIT",
     
    290297  "ALLOC_TRT_IXR_RSP",
    291298  "ALLOC_TRT_CLEANUP",
    292   "ALLOC_TRT_IXR_CMD"
     299  "ALLOC_TRT_IXR_CMD",
     300  "ALLOC_TRT_CONFIG"
    293301};
    294302const char *alloc_upt_fsm_str[] =
    295303{
    296   "ALLOC_UPT_CONFIG",
    297304  "ALLOC_UPT_WRITE",
    298305  "ALLOC_UPT_CAS",
     
    351358  : soclib::caba::BaseModule(name),
    352359
    353     m_monitor_ok(false),
     360    //m_monitor_ok(false),
    354361   
    355362    p_clk( "p_clk" ),
     
    394401    m_broadcast_boundaries(0x7C1F),
    395402
    396     r_tgt_cmd_fsm("r_tgt_cmd_fsm"),
    397403
    398404    //  FIFOs
     
    421427    m_cc_receive_to_multi_ack_fifo("m_cc_receive_to_multi_ack_fifo", 4),
    422428
     429    r_tgt_cmd_fsm("r_tgt_cmd_fsm"),
     430
    423431    r_config_fsm( "r_config_fsm" ),
    424432
     
    432440    m_write_to_cc_send_inst_fifo("m_write_to_cc_send_inst_fifo",8),
    433441    m_write_to_cc_send_srcid_fifo("m_write_to_cc_send_srcid_fifo",8),
    434 #if L1_MULTI_CACHE
    435     m_write_to_cc_send_cache_id_fifo("m_write_to_cc_send_cache_id_fifo",8),
    436 #endif
    437442
    438443    r_multi_ack_fsm("r_multi_ack_fsm"),
     
    444449    m_cas_to_cc_send_inst_fifo("m_cas_to_cc_send_inst_fifo",8),
    445450    m_cas_to_cc_send_srcid_fifo("m_cas_to_cc_send_srcid_fifo",8),
    446 #if L1_MULTI_CACHE
    447     m_cas_to_cc_send_cache_id_fifo("m_cas_to_cc_send_cache_id_fifo",8),
    448 #endif
    449451
    450452    r_ixr_rsp_fsm("r_ixr_rsp_fsm"),
     
    453455    m_xram_rsp_to_cc_send_inst_fifo("m_xram_rsp_to_cc_send_inst_fifo",8),
    454456    m_xram_rsp_to_cc_send_srcid_fifo("m_xram_rsp_to_cc_send_srcid_fifo",8),
    455 #if L1_MULTI_CACHE
    456     m_xram_rsp_to_cc_send_cache_id_fifo("m_xram_rsp_to_cc_send_cache_id_fifo",8),
    457 #endif
    458457
    459458    r_ixr_cmd_fsm("r_ixr_cmd_fsm"),
     
    524523    r_xram_rsp_victim_data     = new sc_signal<data_t>[nwords];
    525524    r_xram_rsp_to_tgt_rsp_data = new sc_signal<data_t>[nwords];
    526     r_xram_rsp_to_ixr_cmd_data = new sc_signal<data_t>[nwords];
    527525
    528526    // Allocation for READ FSM
     
    535533    r_write_to_cc_send_data    = new sc_signal<data_t>[nwords];
    536534    r_write_to_cc_send_be      = new sc_signal<be_t>[nwords];
    537     r_write_to_ixr_cmd_data    = new sc_signal<data_t>[nwords];
    538535
    539536    // Allocation for CAS FSM
    540     r_cas_to_ixr_cmd_data      = new sc_signal<data_t>[nwords];
    541537    r_cas_data                 = new sc_signal<data_t>[nwords];
    542538    r_cas_rdata                = new sc_signal<data_t>[2];
     
    544540    // Allocation for ODCCP
    545541    r_cleanup_data             = new sc_signal<data_t>[nwords];
    546     r_ixr_cmd_data             = new sc_signal<data_t>[nwords];
    547542    r_cleanup_to_ixr_cmd_data  = new sc_signal<data_t>[nwords];
    548543
     544    // Allocation for IXR_CMD FSM
     545    r_ixr_cmd_wdata            = new sc_signal<data_t>[nwords];
     546
    549547    // Allocation for debug
    550     m_debug_previous_data      = new sc_signal<data_t>[nwords];
    551     m_debug_data               = new sc_signal<data_t>[nwords];
     548    m_debug_previous_data      = new data_t[nwords];
     549    m_debug_data               = new data_t[nwords];
    552550
    553551    SC_METHOD(transition);
     
    560558} // end constructor
    561559
    562 ///////////////////////////////////////////////////////////////////////
    563 tmpl(void) ::start_monitor(addr_t addr, addr_t length)
    564 ///////////////////////////////////////////////////////////////////////
    565 {
    566   m_monitor_ok        = true;
    567   m_monitor_base      = addr;
    568   m_monitor_length    = length;
    569 }
    570 
    571 ///////////////////////////////////////////////////////////////////////
    572 tmpl(void) ::stop_monitor()
    573 ///////////////////////////////////////////////////////////////////////
    574 {
    575   m_monitor_ok        = false;
    576 }
    577 
    578 ////////////////////////////////////////////////
    579 tmpl(void) ::check_monitor( addr_t      addr,
    580                             data_t      data,
    581                             bool        read )
    582 ////////////////////////////////////////////////
    583 {
    584   if((addr >= m_monitor_base) and
    585       (addr < m_monitor_base + m_monitor_length))
    586   {
    587     if ( read ) std::cout << " Monitor MEMC Read ";
    588     else        std::cout << " Monitor MEMC Write";
    589     std::cout << " / Address = " << std::hex << addr
    590               << " / Data = " << data
    591               << " at cycle " << std::dec << m_cpt_cycles << std::endl;
    592   }
    593 }
    594560
    595561/////////////////////////////////////////////////////
     
    601567    DirectoryEntry entry = m_cache_directory.read_neutral(addr, &way, &set );
    602568
     569    // read data and compute data_change
    603570    bool data_change = false;
    604 
    605571    if ( entry.valid )
    606572    {
    607         m_cache_data.read_line( way, set, m_debug_data );
    608 
    609         for ( size_t i = 0 ; i<m_words ; i++ )
    610         {
    611             if ( m_debug_previous_valid and
    612                  (m_debug_data[i].read() != m_debug_previous_data[i].read()) )
    613                  data_change = true;
    614             m_debug_previous_data[i] = m_debug_data[i].read();
     573        for ( size_t word = 0 ; word<m_words ; word++ )
     574        {
     575            m_debug_data[word] = m_cache_data.read(way, set, word);
     576            if ( m_debug_previous_valid and
     577                 (m_debug_data[word] != m_debug_previous_data[word]) )
     578            {
     579                data_change = true;
     580            }
    615581        }
    616582    }
    617583   
     584    // print values if any change
    618585    if ( (entry.valid != m_debug_previous_valid) or
    619586         (entry.valid and (entry.count != m_debug_previous_count)) or
     
    623590                  << " at cycle " << std::dec << m_cpt_cycles
    624591                  << " for address " << std::hex << addr
    625                   << " / HIT = " << std::dec << entry.valid
     592                  << " / VAL = " << std::dec << entry.valid
    626593                  << " / WAY = " << way
    627594                  << " / COUNT = " << entry.count
    628595                  << " / DIRTY = " << entry.dirty
    629                   << " / DATA_CHANGE = " << entry.count
     596                  << " / DATA_CHANGE = " << data_change
    630597                  << std::endl;
    631     }
     598        std::cout << std::hex << "     /0:" << m_debug_data[0]
     599                  << "/1:" << m_debug_data[1]
     600                  << "/2:" << m_debug_data[2]
     601                  << "/3:" << m_debug_data[3]
     602                  << "/4:" << m_debug_data[4]
     603                  << "/5:" << m_debug_data[5]
     604                  << "/6:" << m_debug_data[6]
     605                  << "/7:" << m_debug_data[7]
     606                  << "/8:" << m_debug_data[8]
     607                  << "/9:" << m_debug_data[9]
     608                  << "/A:" << m_debug_data[10]
     609                  << "/B:" << m_debug_data[11]
     610                  << "/C:" << m_debug_data[12]
     611                  << "/D:" << m_debug_data[13]
     612                  << "/E:" << m_debug_data[14]
     613                  << "/F:" << m_debug_data[15]
     614                  << std::endl;
     615    }
     616
     617    // register values
    632618    m_debug_previous_count = entry.count;
    633619    m_debug_previous_valid = entry.valid;
    634620    m_debug_previous_dirty = entry.dirty;
     621    for( size_t word=0 ; word<m_words ; word++ )
     622        m_debug_previous_data[word] = m_debug_data[word];
    635623}
    636624
     
    807795  delete [] r_xram_rsp_victim_data;
    808796  delete [] r_xram_rsp_to_tgt_rsp_data;
    809   delete [] r_xram_rsp_to_ixr_cmd_data;
    810797
    811798  delete [] r_read_data;
     
    889876    m_config_to_cc_send_inst_fifo.init();
    890877    m_config_to_cc_send_srcid_fifo.init();
    891 #if L1_MULTI_CACHE
    892     m_config_to_cc_send_cache_id_fifo.init();
    893 #endif
    894878
    895879    r_tgt_cmd_to_tgt_rsp_req = false;
     
    906890    m_write_to_cc_send_inst_fifo.init();
    907891    m_write_to_cc_send_srcid_fifo.init();
    908 #if L1_MULTI_CACHE
    909     m_write_to_cc_send_cache_id_fifo.init();
    910 #endif
    911892
    912893    r_cleanup_to_tgt_rsp_req      = false;
     
    914895    m_cc_receive_to_cleanup_fifo.init();
    915896
    916     r_multi_ack_to_tgt_rsp_req     = false;
     897    r_multi_ack_to_tgt_rsp_req    = false;
    917898
    918899    m_cc_receive_to_multi_ack_fifo.init();
     
    922903    r_cas_lfsr                    = -1   ;
    923904    r_cas_to_ixr_cmd_req          = false;
    924     r_cas_to_cc_send_multi_req   = false;
    925     r_cas_to_cc_send_brdcast_req = false;
     905    r_cas_to_cc_send_multi_req    = false;
     906    r_cas_to_cc_send_brdcast_req  = false;
    926907
    927908    m_cas_to_cc_send_inst_fifo.init();
    928909    m_cas_to_cc_send_srcid_fifo.init();
    929 #if L1_MULTI_CACHE
    930     m_cas_to_cc_send_cache_id_fifo.init();
    931 #endif
    932910
    933911    for(size_t i=0; i<m_trt_lines ; i++)
     
    945923    m_xram_rsp_to_cc_send_inst_fifo.init();
    946924    m_xram_rsp_to_cc_send_srcid_fifo.init();
    947 #if L1_MULTI_CACHE
    948     m_xram_rsp_to_cc_send_cache_id_fifo.init();
    949 #endif
    950 
    951     r_ixr_cmd_cpt          = 0;
     925
    952926    r_alloc_dir_reset_cpt  = 0;
    953927    r_alloc_heap_reset_cpt = 0;
     
    964938    //r_xram_rsp_to_ixr_cmd_inval_ncc_pending = false;
    965939    r_cleanup_to_ixr_cmd_srcid = 0;
    966     r_cleanup_to_ixr_cmd_trdid = 0;
     940    r_cleanup_to_ixr_cmd_index = 0;
    967941    r_cleanup_to_ixr_cmd_pktid = 0;
    968942    r_cleanup_to_ixr_cmd_nline = 0;
     
    971945      r_cleanup_to_ixr_cmd_data[word] = 0;
    972946      r_cleanup_data[word] = 0;
    973       r_ixr_cmd_data[word] = 0;
     947      r_ixr_cmd_wdata[word] = 0;
    974948    }
    975949
     
    10531027  size_t  write_to_cc_send_fifo_srcid = 0;
    10541028
    1055 #if L1_MULTI_CACHE
    1056   size_t  write_to_cc_send_fifo_cache_id = 0;
    1057 #endif
    1058 
    10591029  bool    xram_rsp_to_cc_send_fifo_put   = false;
    10601030  bool    xram_rsp_to_cc_send_fifo_get   = false;
     
    10621032  size_t  xram_rsp_to_cc_send_fifo_srcid = 0;
    10631033
    1064 #if L1_MULTI_CACHE
    1065   size_t  xram_rsp_to_cc_send_fifo_cache_id = 0;
    1066 #endif
    1067 
    10681034  bool    config_to_cc_send_fifo_put   = false;
    10691035  bool    config_to_cc_send_fifo_get   = false;
     
    10751041  bool    cas_to_cc_send_fifo_inst  = false;
    10761042  size_t  cas_to_cc_send_fifo_srcid = 0;
    1077 
    1078 #if L1_MULTI_CACHE
    1079   size_t  cas_to_cc_send_fifo_cache_id = 0;
    1080 #endif
    10811043
    10821044  m_debug = (m_cpt_cycles > m_debug_start_cycle) and m_debug_ok;
     
    11291091  // - For MEMC_CMD_TYPE, the response is delayed until the operation is completed.
    11301092  ////////////////////////////////////////////////////////////////////////////////////
     1093
     1094//std::cout << std::endl << "tgt_cmd_fsm" << std::endl;
    11311095
    11321096  switch(r_tgt_cmd_fsm.read())
     
    12321196    case TGT_CMD_ERROR:  // response error must be sent
    12331197
    1234     // wait if pending TGT_CMD request to TGT_RSP FSM
     1198    // wait if pending request
    12351199    if(r_tgt_cmd_to_tgt_rsp_req.read()) break;
    12361200
     
    12661230        size_t   error; 
    12671231        uint32_t rdata = 0;         // default value
     1232        uint32_t wdata = p_vci_tgt.wdata.read();
    12681233
    12691234        if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_READ)         // get lock
     
    12741239            error            = 0;
    12751240            r_config_lock    = true;
     1241            if ( rdata == 0 )
     1242            {
     1243                r_tgt_cmd_srcid = p_vci_tgt.srcid.read();
     1244                r_tgt_cmd_trdid = p_vci_tgt.trdid.read();
     1245                r_tgt_cmd_pktid = p_vci_tgt.pktid.read();
     1246            }
    12761247        }
    12771248        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)  // release lock
    1278                    and (cell == MEMC_LOCK) )
     1249                   and (cell == MEMC_LOCK)
     1250                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
    12791251        {
    12801252            need_rsp         = true;
     
    12831255        }
    12841256        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_lo
    1285                    and (cell == MEMC_ADDR_LO) )
    1286         {
     1257                   and (cell == MEMC_ADDR_LO)
     1258                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
     1259        {
     1260            assert( ((wdata % (m_words*vci_param_int::B)) == 0) and
     1261            "VCI_MEM_CACHE CONFIG ERROR: The buffer must be aligned on a cache line");
     1262
    12871263            need_rsp         = true;
    12881264            error            = 0;
     
    12911267        }
    12921268        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_hi
    1293                    and (cell == MEMC_ADDR_HI) )
     1269                   and (cell == MEMC_ADDR_HI)
     1270                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
     1271
    12941272        {
    12951273            need_rsp         = true;
     
    12991277        }
    13001278        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set buf_lines
    1301                    and (cell == MEMC_BUF_LENGTH) )
     1279                   and (cell == MEMC_BUF_LENGTH)
     1280                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
    13021281        {
    13031282            need_rsp         = true;
    13041283            error            = 0;
    13051284            size_t lines = (size_t)(p_vci_tgt.wdata.read()/(m_words<<2));
    1306             if ( r_config_address.read()/(m_words*vci_param_int::B) ) lines++;
    1307             r_config_nlines  = lines;
     1285            if ( r_config_address.read()%(m_words*4) ) lines++;
     1286            r_config_cmd_lines  = lines;
     1287            r_config_rsp_lines  = lines;
    13081288        }
    13091289        else if ( (p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set cmd type
    1310                    and (cell == MEMC_CMD_TYPE) )
     1290                   and (cell == MEMC_CMD_TYPE)
     1291                   and (p_vci_tgt.srcid.read() == r_tgt_cmd_srcid.read()) )
    13111292        {
    13121293            need_rsp         = false;
    13131294            error            = 0;
    13141295            r_config_cmd     = p_vci_tgt.wdata.read();
     1296
     1297            // prepare delayed response from CONFIG FSM
    13151298            r_config_srcid   = p_vci_tgt.srcid.read();
    13161299            r_config_trdid   = p_vci_tgt.trdid.read();
     
    13431326          << " address = " << std::hex << p_vci_tgt.address.read()
    13441327          << " / wdata = " << p_vci_tgt.wdata.read()
     1328          << " / need_rsp = " << need_rsp
    13451329          << " / error = " << error << std::endl;
    13461330#endif
     
    14461430  //    MULTI_ACK FSM
    14471431  /////////////////////////////////////////////////////////////////////////
    1448   // This FSM controls the response to the multicast update or multicast
    1449   // inval coherence requests sent by the memory cache to the L1 caches and
    1450   // update the UPT.
     1432  // This FSM controls the response to the multicast update requests sent
     1433  // by the memory cache to the L1 caches and update the UPT.
    14511434  //
    14521435  // - The FSM decrements the proper entry in UPT,
     
    14541437  // - If required, it sends a request to the TGT_RSP FSM to complete
    14551438  //   a pending  write transaction.
    1456   // - If required, it sends an acknowledge to the CONFIG FSM to signal
    1457   //   completion of a line inval.
    14581439  //
    14591440  // All those multi-ack packets are one flit packet.
    1460   // The index in the UPT is defined in the UPDTID field.
     1441  // The index in the UPT is defined in the TRDID field.
    14611442  ////////////////////////////////////////////////////////////////////////
     1443
     1444//std::cout << std::endl << "multi_ack_fsm" << std::endl;
    14621445
    14631446  switch(r_multi_ack_fsm.read())
     
    15741557        r_multi_ack_nline = m_upt.nline(r_multi_ack_upt_index.read());
    15751558        bool need_rsp     = m_upt.need_rsp(r_multi_ack_upt_index.read());
    1576         bool need_ack     = m_upt.need_ack(r_multi_ack_upt_index.read());
    15771559
    15781560        // clear the UPT entry
     
    15801562
    15811563        if      ( need_rsp ) r_multi_ack_fsm = MULTI_ACK_WRITE_RSP;
    1582         else if ( need_ack ) r_multi_ack_fsm = MULTI_ACK_CONFIG_ACK;
    15831564        else                 r_multi_ack_fsm = MULTI_ACK_IDLE;
    15841565
     
    16111592        break;
    16121593    }
    1613     //////////////////////////
    1614     case MULTI_ACK_CONFIG_ACK:    // Signals multi-inval completion to CONFIG FSM
    1615                                   // Wait if pending request
    1616     {
    1617         if ( r_multi_ack_to_config_ack.read() ) break;
    1618 
    1619         r_multi_ack_to_config_ack   = true;
    1620         r_multi_ack_fsm              = MULTI_ACK_IDLE;
    1621 
    1622 #if DEBUG_MEMC_MULTI_ACK
    1623 if(m_debug)
    1624 std::cout << "  <MEMC " << name() << " MULTI_ACK_CONFIG_ACK>"
    1625           << " Signals inval completion to CONFIG FSM" << std::endl;
    1626 #endif
    1627         break;
    1628     }
    16291594  } // end switch r_multi_ack_fsm
    16301595
     
    16341599  // The CONFIG FSM handles the VCI configuration requests (INVAL & SYNC).
    16351600  // The target buffer can have any size, and there is one single command for
    1636   // all cache lines covered by the target buffer.
    1637   // An INVAL or SYNC configuration request is defined by the followinf registers:
    1638   // - bool      r_config_cmd        : INVAL / SYNC / NOP)
     1601  // all cache lines covered by the target buffer.
     1602  //
     1603  // An INVAL or SYNC configuration operation is defined by the following registers:
     1604  // - bool      r_config_cmd        : INVAL / SYNC / NOP
    16391605  // - uint64_t  r_config_address    : buffer base address
    1640   // - uint32_t  r_config_nlines     : number of lines covering buffer
     1606  // - uint32_t  r_config_cmd_lines  : number of lines to be handled
     1607  // - uint32_t  r_config_rsp_lines  : number of lines not completed
    16411608  //
    16421609  // For both INVAL and SYNC commands, the CONFIG FSM contains the loop handling
    1643   // all cache lines covered by the target buffer.
    1644   //
     1610  // all cache lines covered by the buffer. The various lines of a given buffer
     1611  // can be pipelined: the CONFIG FSM does not wait the response for line (n) to send
     1612  // the command for line (n+1). It decrements the r_config_cmd_lines counter until
     1613  // the last request has been registered in TRT (for a SYNC), or in IVT (for an INVAL).
     1614  //
    16451615  // - INVAL request:
    1646   //   For each line, it access to the DIR array.
     1616  //   For each line, it access to the DIR.
    16471617  //   In case of miss, it does nothing, and a response is requested to TGT_RSP FSM.
    16481618  //   In case of hit, with no copies in L1 caches, the line is invalidated and
    16491619  //   a response is requested to TGT_RSP FSM.
    16501620  //   If there is copies, a multi-inval, or a broadcast-inval coherence transaction
    1651   //   is launched and registered in UPT. The multi-inval transaction is signaled
    1652   //   by the r_multi_ack_to config_ack or r_cleanup_to_config_ack flip-flops.
    1653   //   The config inval response is sent only when the last line has been invalidated.
    1654   //
     1621  //   is launched and registered in UPT. The multi-inval transaction completion
     1622  //   is signaled by the CLEANUP FSM by decrementing the r_config_rsp_lines counter.
     1623  //   The CONFIG INVAL response is sent only when the last line has been invalidated.
     1624  //   TODO : The target buffer address must be aligned on a cache line boundary.
     1625  //   This constraint can be released, but it requires to make 2 PUT transactions
     1626  //   for the first and the last line...
     1627  //
    16551628  // - SYNC request:
    1656   //
    1657   //  ...  Not implemented yet ...
     1629  //   For each line, it access to the DIR.
     1630  //   In case of miss, it does nothing, and a response is requested to TGT_RSP FSM.
     1631  //   In case of hit, a PUT transaction is registered in TRT and a request is sent
     1632  //   to IXR_CMD FSM. The IXR_RSP FSM decrements the r_config_rsp_lines counter
     1633  //   when a PUT response is received.
     1634  //   The CONFIG SYNC response is sent only when the last PUT response is received.
    16581635  //
    16591636  // From the software point of view, a configuration request is a sequence
    1660   // of 6 atomic accesses in an uncached segment:
     1637  // of 6 atomic accesses in an uncached segment. A dedicated lock is used
     1638  // to handle only one configuration command at a given time:
    16611639  // - Read  MEMC_LOCK       : Get the lock
    16621640  // - Write MEMC_ADDR_LO    : Set the buffer address LSB
     
    16671645  ////////////////////////////////////////////////////////////////////////////////////
    16681646
     1647//std::cout << std::endl << "config_fsm" << std::endl;
     1648
    16691649  switch( r_config_fsm.read() )
    16701650  {
     
    16791659if(m_debug)
    16801660std::cout << "  <MEMC " << name() << " CONFIG_IDLE> Config Request received"
    1681           << " address = " << std::hex << r_config_address.read()
    1682           << " / nlines = " << std::dec << r_config_nlines.read()
     1661          << " / address = " << std::hex << r_config_address.read()
     1662          << " / lines = " << std::dec << r_config_cmd_lines.read()
    16831663          << " / type = " << r_config_cmd.read() << std::endl;
    16841664#endif
     
    16871667      }
    16881668      /////////////////
    1689       case CONFIG_LOOP:   // test last line
    1690       {
    1691           if ( r_config_nlines.read() == 0 )
     1669      case CONFIG_LOOP:   // test if last line to be handled
     1670      {
     1671          if ( r_config_cmd_lines.read() == 0 )
    16921672          {
    16931673              r_config_cmd = MEMC_CMD_NOP;
    1694               r_config_fsm = CONFIG_RSP;
     1674              r_config_fsm = CONFIG_WAIT;
    16951675          }
    16961676          else
     
    17021682if(m_debug)
    17031683std::cout << "  <MEMC " << name() << " CONFIG_LOOP>"
    1704           << " address = " << std::hex << r_config_address.read()   
    1705           << " / nlines = " << std::dec << r_config_nlines.read()
     1684          << " / address = " << std::hex << r_config_address.read()   
     1685          << " / lines not handled = " << std::dec << r_config_cmd_lines.read()
    17061686          << " / command = " << r_config_cmd.read() << std::endl;
    17071687#endif
    17081688          break;
     1689      }
     1690      /////////////////
     1691      case CONFIG_WAIT:   // wait completion (last response)
     1692      {
     1693          if ( r_config_rsp_lines.read() == 0 )  // last response received
     1694          {
     1695              r_config_fsm = CONFIG_RSP;
     1696          }
     1697
     1698#if DEBUG_MEMC_CONFIG
     1699if(m_debug)
     1700std::cout << "  <MEMC " << name() << " CONFIG_WAIT>"
     1701          << " / lines to do = " << std::dec << r_config_rsp_lines.read() << std::endl;
     1702#endif
     1703          break;
     1704      }
     1705      ////////////////
     1706      case CONFIG_RSP:  // request TGT_RSP FSM to return response
     1707      {
     1708          if ( not r_config_to_tgt_rsp_req.read() )
     1709          {
     1710              r_config_to_tgt_rsp_srcid  = r_config_srcid.read();
     1711              r_config_to_tgt_rsp_trdid  = r_config_trdid.read();
     1712              r_config_to_tgt_rsp_pktid  = r_config_pktid.read();
     1713              r_config_to_tgt_rsp_error  = false;
     1714              r_config_to_tgt_rsp_req    = true;
     1715              r_config_fsm               = CONFIG_IDLE;
     1716
     1717#if DEBUG_MEMC_CONFIG
     1718if(m_debug)
     1719std::cout << "  <MEMC " << name() << " CONFIG_RSP> Request TGT_RSP FSM to return response:"
     1720          << " error = " << r_config_to_tgt_rsp_error.read()
     1721          << " / rsrcid = " << std::hex << r_config_srcid.read()
     1722          << " / rtrdid = " << std::hex << r_config_trdid.read()
     1723          << " / rpktid = " << std::hex << r_config_pktid.read() << std::endl;
     1724#endif
     1725          }
     1726          break;
     1727
    17091728      }
    17101729      ////////////////////
     
    17261745      case CONFIG_DIR_ACCESS:   // Access directory and decode config command
    17271746      {
     1747          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and
     1748          "MEMC ERROR in CONFIG_DIR_ACCESS state: bad DIR allocation");
     1749
    17281750          size_t way = 0;
    17291751          DirectoryEntry entry = m_cache_directory.read(r_config_address.read(), way);
     
    17361758              r_config_dir_copy_srcid = entry.owner.srcid;
    17371759              r_config_dir_is_cnt     = entry.is_cnt;
     1760              r_config_dir_lock       = entry.lock;
    17381761              r_config_dir_count      = entry.count;
    1739               r_config_dir_next_ptr   = entry.ptr;
    1740 
    1741               r_config_fsm    = CONFIG_DIR_IVT_LOCK;
     1762              r_config_dir_ptr        = entry.ptr;
     1763
     1764              r_config_fsm    = CONFIG_IVT_LOCK;
    17421765          }
    17431766          else if ( entry.valid and                       // hit & sync command
     
    17451768                    (r_config_cmd.read() == MEMC_CMD_SYNC) )
    17461769          {
    1747               std::cout << "VCI_MEM_CACHE ERROR: "
    1748                         << "SYNC config request not implemented yet" << std::endl;
    1749               exit(0);
     1770              r_config_fsm  = CONFIG_TRT_LOCK;
    17501771          }
    1751           else                                            // return to LOOP
     1772          else                                            // miss : return to LOOP
    17521773          {
    1753               r_config_nlines  = r_config_nlines.read() - 1;
    1754               r_config_address = r_config_address.read() + (m_words<<2);
    1755               r_config_fsm     = CONFIG_LOOP;
     1774              r_config_cmd_lines = r_config_cmd_lines.read() - 1;
     1775              r_config_rsp_lines = r_config_rsp_lines.read() - 1;
     1776              r_config_cmd_lines = r_config_cmd_lines.read() - 1;
     1777              r_config_address   = r_config_address.read() + (m_words<<2);
     1778              r_config_fsm       = CONFIG_LOOP;
    17561779          }
    17571780
     
    17671790          break;
    17681791      }
    1769       /////////////////////////
    1770       case CONFIG_DIR_IVT_LOCK:  // enter this state in case of INVAL command
    1771                                  // Try to get both DIR & IVT locks, and return
    1772                                  // to LOOP state if IVT full.
    1773                                  // Register inval in IVT, and invalidate the
    1774                                  // directory if IVT not full.
    1775       {
     1792      /////////////////////
     1793      case CONFIG_TRT_LOCK:      // enter this state in case of SYNC command
     1794                                 // to a dirty cache line
     1795                                 // keep DIR lock, and try to get TRT lock
     1796                                 // return to LOOP state if TRT full
     1797                                 // reset dirty bit in DIR and register a PUT
     1798                                 // trabsaction in TRT if not full.
     1799      {
     1800          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and
     1801          "MEMC ERROR in CONFIG_TRT_LOCK state: bad DIR allocation");
     1802
     1803          if ( r_alloc_trt_fsm.read() == ALLOC_TRT_CONFIG )
     1804          {
     1805              size_t index = 0;
     1806              bool   wok   = not m_trt.full(index);
     1807
     1808              if ( not wok )
     1809              {
     1810                  r_config_fsm = CONFIG_LOOP;
     1811              }
     1812              else
     1813              {
     1814                  size_t          way = r_config_dir_way.read();
     1815                  size_t          set = m_y[r_config_address.read()];
     1816
     1817                  // reset dirty bit in DIR
     1818                  DirectoryEntry  entry;
     1819                  entry.valid       = true;
     1820                  entry.dirty       = false;
     1821                  entry.tag         = m_z[r_config_address.read()];
     1822                  entry.is_cnt      = r_config_dir_is_cnt.read();
     1823                  entry.lock        = r_config_dir_lock.read();
     1824                  entry.ptr         = r_config_dir_ptr.read();
     1825                  entry.count       = r_config_dir_count.read();
     1826                  entry.owner.inst  = r_config_dir_copy_inst.read();
     1827                  entry.owner.srcid = r_config_dir_copy_srcid.read();
     1828                  m_cache_directory.write( set,
     1829                                           way,
     1830                                           entry );
     1831
     1832                  r_config_trt_index = index;
     1833                  r_config_fsm       = CONFIG_TRT_SET;
     1834              }
     1835
     1836#if DEBUG_MEMC_CONFIG
     1837if(m_debug)
     1838std::cout << "  <MEMC " << name() << " CONFIG_TRT_LOCK> Access TRT: "
     1839          << " wok = " << std::dec << wok
     1840          << " index = " << index << std::endl;
     1841#endif
     1842          }
     1843          break;
     1844      }
     1845      ////////////////////
     1846      case CONFIG_TRT_SET:       // read data in cache
     1847                                 // and post a PUT request in TRT
     1848      {
     1849          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and
     1850          "MEMC ERROR in CONFIG_TRT_SET state: bad DIR allocation");
     1851
     1852          assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CONFIG) and
     1853          "MEMC ERROR in CONFIG_TRT_SET state: bad TRT allocation");
     1854
     1855          // read data into cache
     1856          size_t          way = r_config_dir_way.read();
     1857          size_t          set = m_y[r_config_address.read()];
     1858
     1859          sc_signal<data_t> config_data[16];
     1860          m_cache_data.read_line( way,
     1861                                  set,
     1862                                  config_data );
     1863           
     1864          // post a PUT request in TRT
     1865          std::vector<data_t> data_vector;
     1866          data_vector.clear();
     1867          for(size_t i=0; i<m_words; i++) data_vector.push_back(config_data[i].read());
     1868          m_trt.set( r_config_trt_index.read(),
     1869                     false,                               // PUT
     1870                     m_nline[r_config_address.read()],    // nline
     1871                     0,                                   // srcid:       unused
     1872                     0,                                   // trdid:       unused
     1873                     0,                                   // pktid:       unused
     1874                     false,                               // not proc_read
     1875                     0,                                   // read_length: unused
     1876                     0,                                   // word_index:  unused
     1877                     std::vector<be_t>(m_words,0xF),                         
     1878                     data_vector);
     1879
     1880#if DEBUG_MEMC_CONFIG
     1881if(m_debug)
     1882std::cout << "  <MEMC " << name() << " CONFIG_TRT_SET> PUT request in TRT:"
     1883          << " address = " << std::hex << r_config_address.read()
     1884          << " index = " << std::dec << r_config_trt_index.read() << std::endl;
     1885#endif
     1886          break;
     1887      }
     1888      ////////////////////
     1889      case CONFIG_PUT_REQ:       // PUT request to IXR_CMD_FSM
     1890      {
     1891          if ( not r_config_to_ixr_cmd_req.read() )
     1892          {
     1893              r_config_to_ixr_cmd_req   = true;
     1894              r_config_to_ixr_cmd_index = r_config_trt_index.read();
     1895
     1896              // prepare next iteration
     1897              r_config_cmd_lines              = r_config_cmd_lines.read() - 1;
     1898              r_config_address                = r_config_address.read() + (m_words<<2);
     1899              r_config_fsm                    = CONFIG_LOOP;
     1900
     1901#if DEBUG_MEMC_CONFIG
     1902if(m_debug)
     1903std::cout << "  <MEMC " << name() << " CONFIG_PUT_REQ> PUT request to IXR_CMD_FSM"
     1904          << " / address = " << std::hex << r_config_address.read() << std::endl;
     1905#endif
     1906          }
     1907          break;
     1908      }
     1909      /////////////////////
     1910      case CONFIG_IVT_LOCK:  // enter this state in case of INVAL command
     1911                             // Keep DIR lock and Try to get IVT lock.
     1912                             // Return to LOOP state if IVT full.
     1913                             // Register inval in IVT, and invalidate the
     1914                             // directory if IVT not full.
     1915      {
     1916          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CONFIG) and
     1917          "MEMC ERROR in CONFIG_IVT_LOCK state: bad DIR allocation");
     1918
    17761919          if ( r_alloc_ivt_fsm.read() == ALLOC_IVT_CONFIG )
    17771920          {
     
    17821925              {
    17831926                  m_cache_directory.inval( way, set );
    1784                   r_config_nlines  = r_config_nlines.read() - 1;
    1785                   r_config_address = r_config_address.read() + (m_words<<2);
    1786                   r_config_fsm     = CONFIG_LOOP;
     1927                  r_config_cmd_lines  = r_config_cmd_lines.read() - 1;
     1928                  r_config_rsp_lines  = r_config_rsp_lines.read() - 1;
     1929                  r_config_address    = r_config_address.read() + (m_words<<2);
     1930                  r_config_fsm        = CONFIG_LOOP;
    17871931
    17881932#if DEBUG_MEMC_CONFIG
    17891933if(m_debug)
    1790 std::cout << "  <MEMC " << name() << " CONFIG_DIR_IVT_LOCK>"
     1934std::cout << "  <MEMC " << name() << " CONFIG_IVT_LOCK>"
    17911935          << " No copies in L1 : inval DIR entry"  << std::endl;
    17921936#endif
     
    18191963                      r_config_ivt_index = index;
    18201964                      if ( broadcast )  r_config_fsm = CONFIG_BC_SEND;
    1821                       else              r_config_fsm = CONFIG_INV_SEND;
     1965                      else              r_config_fsm = CONFIG_INVAL_SEND;
    18221966
    18231967#if DEBUG_MEMC_CONFIG
    18241968if(m_debug)
    1825 std::cout << "  <MEMC " << name() << " CONFIG_DIR_IVT_LOCK>"
     1969std::cout << "  <MEMC " << name() << " CONFIG_IVT_LOCK>"
    18261970          << " Inval DIR entry and register inval in IVT"
    1827           << " : index = " << std::dec << index
     1971          << " / index = " << std::dec << index
    18281972          << " / broadcast = " << broadcast << std::endl;
    18291973#endif
     
    18351979#if DEBUG_MEMC_CONFIG
    18361980if(m_debug)
    1837 std::cout << "  <MEMC " << name() << " CONFIG_DIR_IVT_LOCK>"
     1981std::cout << "  <MEMC " << name() << " CONFIG_IVT_LOCK>"
    18381982          << " IVT full : release DIR & IVT locks and retry" << std::endl;
    18391983#endif
     
    18491993              not r_config_to_cc_send_brdcast_req.read() )
    18501994          {
     1995              // post bc inval request
    18511996              r_config_to_cc_send_multi_req   = false;
    18521997              r_config_to_cc_send_brdcast_req = true;
    18531998              r_config_to_cc_send_trdid       = r_config_ivt_index.read();
    18541999              r_config_to_cc_send_nline       = m_nline[(addr_t)(r_config_address.read())];
    1855               r_cleanup_to_config_ack         = false;
    1856               r_config_fsm                    = CONFIG_BC_WAIT;
     2000
     2001              // prepare next iteration
     2002              r_config_cmd_lines              = r_config_cmd_lines.read() - 1;
     2003              r_config_address                = r_config_address.read() + (m_words<<2);
     2004              r_config_fsm                    = CONFIG_LOOP;
    18572005
    18582006#if DEBUG_MEMC_CONFIG
     
    18652013          break;
    18662014      }
    1867       ////////////////////
    1868       case CONFIG_BC_WAIT:      // wait broadcast completion to return to LOOP
    1869       {
    1870           if ( r_cleanup_to_config_ack.read() )
    1871           {
    1872               r_config_fsm     = CONFIG_LOOP;
    1873               r_config_nlines  = r_config_nlines.read() - 1;
    1874               r_config_address = r_config_address.read() + (m_words<<2);
    1875           }
    1876 
    1877 #if DEBUG_MEMC_CONFIG
    1878 if(m_debug)
    1879 std::cout << "  <MEMC " << name() << " CONFIG_BC_WAIT> Waiting BC completion "
    1880           << " done = " << r_cleanup_to_config_ack.read()
    1881           << std::endl;
    1882 #endif
    1883           break;
    1884       }
    1885       /////////////////////
    1886       case CONFIG_INV_SEND:    // Post a multi inval request to CC_SEND FSM
     2015      ///////////////////////
     2016      case CONFIG_INVAL_SEND:    // Post a multi inval request to CC_SEND FSM
    18872017      {
    18882018          if( not r_config_to_cc_send_multi_req.read() and
    18892019              not r_config_to_cc_send_brdcast_req.read() )
    18902020          {
     2021              // post multi inval request
    18912022              r_config_to_cc_send_multi_req   = true;
    18922023              r_config_to_cc_send_brdcast_req = false;
    18932024              r_config_to_cc_send_trdid       = r_config_ivt_index.read();
    18942025              r_config_to_cc_send_nline       = m_nline[(addr_t)(r_config_address.read())];
    1895               r_multi_ack_to_config_ack       = false;
    1896 
     2026
     2027              // post data into FIFO
    18972028              config_to_cc_send_fifo_srcid    = r_config_dir_copy_srcid.read();
    18982029              config_to_cc_send_fifo_inst     = r_config_dir_copy_inst.read();
    18992030              config_to_cc_send_fifo_put      = true;
    19002031
    1901               if ( r_config_dir_count.read() == 1 )  r_config_fsm = CONFIG_INV_WAIT;
    1902               else                                   r_config_fsm = CONFIG_HEAP_REQ;
     2032              if ( r_config_dir_count.read() == 1 )  // one copy
     2033              {
     2034                  // prepare next iteration
     2035                  r_config_cmd_lines          = r_config_cmd_lines.read() - 1;
     2036                  r_config_address            = r_config_address.read() + (m_words<<2);
     2037                  r_config_fsm                = CONFIG_LOOP;
     2038              }
     2039              else                                   // several copies
     2040              {
     2041                  r_config_fsm = CONFIG_HEAP_REQ;
     2042              }
    19032043
    19042044#if DEBUG_MEMC_CONFIG
    19052045if(m_debug)
    1906 std::cout << "  <MEMC " << name() << " CONFIG_INV_SEND>"
     2046std::cout << "  <MEMC " << name() << " CONFIG_INVAL_SEND>"
    19072047          << " Post multi inval request to CC_SEND FSM"
    19082048          << " / address = " << std::hex << r_config_address.read()
     
    19192059          {
    19202060              r_config_fsm       = CONFIG_HEAP_SCAN;
    1921               r_config_heap_next = r_config_dir_next_ptr.read();
     2061              r_config_heap_next = r_config_dir_ptr.read();
    19222062          }
    19232063
     
    19662106          if ( m_heap.is_full() )
    19672107          {
    1968               last_entry.next = r_config_dir_next_ptr.read();
     2108              last_entry.next = r_config_dir_ptr.read();
    19692109              m_heap.unset_full();
    19702110          }
     
    19742114          }
    19752115
    1976           m_heap.write_free_ptr( r_config_dir_next_ptr.read() );
     2116          m_heap.write_free_ptr( r_config_dir_ptr.read() );
    19772117          m_heap.write( r_config_heap_next.read(), last_entry );
    1978           r_config_fsm = CONFIG_INV_WAIT;
     2118
     2119          // prepare next iteration
     2120          r_config_cmd_lines          = r_config_cmd_lines.read() - 1;
     2121          r_config_address            = r_config_address.read() + (m_words<<2);
     2122          r_config_fsm                = CONFIG_LOOP;
    19792123
    19802124#if DEBUG_MEMC_CONFIG
     
    19842128#endif
    19852129          break;
    1986       }
    1987       /////////////////////
    1988       case CONFIG_INV_WAIT:      // wait inval completion to return to LOOP
    1989       {
    1990           if ( r_multi_ack_to_config_ack.read() )
    1991           {
    1992               r_config_fsm     = CONFIG_LOOP;
    1993               r_config_nlines  = r_config_nlines.read() - 1;
    1994               r_config_address = r_config_address.read() + (m_words<<2);
    1995           }
    1996 
    1997 #if DEBUG_MEMC_CONFIG
    1998 if(m_debug)
    1999 std::cout << "  <MEMC " << name() << " CONFIG_INV_WAIT> Waiting inval completion "
    2000           << " done = " << r_multi_ack_to_config_ack.read()
    2001           << std::endl;
    2002 #endif
    2003           break;
    2004       }
    2005 
    2006       ////////////////
    2007       case CONFIG_RSP:  // request TGT_RSP FSM to return response
    2008       {
    2009           if ( not r_config_to_tgt_rsp_req.read() )
    2010           {
    2011               r_config_to_tgt_rsp_srcid  = r_config_srcid.read();
    2012               r_config_to_tgt_rsp_trdid  = r_config_trdid.read();
    2013               r_config_to_tgt_rsp_pktid  = r_config_pktid.read();
    2014               r_config_to_tgt_rsp_error  = false;
    2015               r_config_to_tgt_rsp_req    = true;
    2016               r_config_fsm               = CONFIG_IDLE;
    2017 
    2018 #if DEBUG_MEMC_CONFIG
    2019 if(m_debug)
    2020 std::cout << "  <MEMC " << name() << " CONFIG_RSP> Request TGT_RSP FSM to return response:"
    2021           << " error = " << r_config_to_tgt_rsp_error.read()
    2022           << " / rsrcid = " << std::hex << r_config_srcid.read() << std::endl;
    2023 #endif
    2024           }
    2025           break;
    2026 
    20272130      }
    20282131  }  // end switch r_config_fsm
     
    20512154  ////////////////////////////////////////////////////////////////////////////////////
    20522155
     2156//std::cout << std::endl << "read_fsm" << std::endl;
     2157
    20532158  switch(r_read_fsm.read())
    20542159  {
     
    20562161    case READ_IDLE:  // waiting a read request
    20572162    {
    2058       if(m_cmd_read_addr_fifo.rok())
    2059       {
     2163        if(m_cmd_read_addr_fifo.rok())
     2164        {
    20602165
    20612166#if DEBUG_MEMC_READ
    2062         if(m_debug)
    2063           std::cout << "  <MEMC " << name() << " READ_IDLE> Read request"
    2064             << " : address = " << std::hex << m_cmd_read_addr_fifo.read()
    2065             << " / srcid = " << m_cmd_read_srcid_fifo.read()
    2066             << " / trdid = " << m_cmd_read_trdid_fifo.read()
    2067             << " / pktid = " << m_cmd_read_pktid_fifo.read()
    2068             << " / nwords = " << std::dec << m_cmd_read_length_fifo.read() << std::endl;
    2069 #endif
    2070         r_read_fsm = READ_DIR_REQ;
    2071       }
    2072       break;
    2073     }
    2074 
     2167if(m_debug)
     2168std::cout << "  <MEMC " << name() << " READ_IDLE> Read request"
     2169          << " : address = " << std::hex << m_cmd_read_addr_fifo.read()
     2170          << " / srcid = " << m_cmd_read_srcid_fifo.read()
     2171          << " / trdid = " << m_cmd_read_trdid_fifo.read()
     2172          << " / pktid = " << m_cmd_read_pktid_fifo.read()
     2173          << " / nwords = " << std::dec << m_cmd_read_length_fifo.read() << std::endl;
     2174#endif
     2175            r_read_fsm = READ_DIR_REQ;
     2176        }
     2177        break;
     2178    }
    20752179    //////////////////
    20762180    case READ_DIR_REQ:  // Get the lock to the directory
     
    20952199    case READ_DIR_LOCK:  // check directory for hit / miss
    20962200    {
    2097       if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
    2098       {
     2201        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and
     2202        "MEMC ERROR in READ_DIR_LOCK state: Bad DIR allocation");
     2203
    20992204        size_t way = 0;
    2100         DirectoryEntry entry =
    2101           m_cache_directory.read(m_cmd_read_addr_fifo.read(), way);
     2205        DirectoryEntry entry = m_cache_directory.read(m_cmd_read_addr_fifo.read(), way);
     2206
    21022207        // access the global table ONLY when we have an LL cmd
    21032208        if((m_cmd_read_pktid_fifo.read() & 0x7) == TYPE_LL)   
    21042209        {
    2105           r_read_ll_key   = m_llsc_table.ll(m_cmd_read_addr_fifo.read());
     2210            r_read_ll_key   = m_llsc_table.ll(m_cmd_read_addr_fifo.read());
    21062211        }
    21072212        r_read_is_cnt     = entry.is_cnt;
     
    21122217        r_read_count      = entry.count;
    21132218        r_read_copy       = entry.owner.srcid;
    2114 
    2115 #if L1_MULTI_CACHE
    2116         r_read_copy_cache = entry.owner.cache_id;
    2117 #endif
    21182219        r_read_copy_inst  = entry.owner.inst;
    21192220        r_read_ptr        = entry.ptr; // pointer to the heap
     
    21252226        if(entry.valid)    // hit
    21262227        {
    2127           // test if we need to register a new copy in the heap
    2128           if(entry.is_cnt or (entry.count == 0) or !cached_read)
    2129           {
    2130             r_read_fsm = READ_DIR_HIT;
    2131           }
    2132           else
    2133           {
    2134             r_read_fsm = READ_HEAP_REQ;
    2135           }
     2228            // test if we need to register a new copy in the heap
     2229            if(entry.is_cnt or (entry.count == 0) or !cached_read)
     2230            {
     2231                r_read_fsm = READ_DIR_HIT;
     2232            }
     2233            else
     2234            {
     2235                r_read_fsm = READ_HEAP_REQ;
     2236            }
    21362237        }
    21372238        else      // miss
    21382239        {
    2139           r_read_fsm = READ_TRT_LOCK;
     2240            r_read_fsm = READ_TRT_LOCK;
    21402241        }
    21412242
     
    21522253}
    21532254#endif
    2154       }
    2155       else
    2156       {
    2157         std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_DIR_LOCK state"
    2158                   << "Bad DIR allocation"   << std::endl;
    2159         exit(0);
    2160       }
    2161       break;
    2162     }
    2163 
     2255        break;
     2256    }
    21642257    //////////////////
    21652258    case READ_DIR_HIT:    //  read data in cache & update the directory
     
    21702263
    21712264    {
    2172       if(r_alloc_dir_fsm.read() == ALLOC_DIR_READ)
    2173       {
     2265        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and
     2266        "MEMC ERROR in READ_DIR_HIT state: Bad DIR allocation");
     2267
    21742268        // check if this is an instruction read, this means pktid is either
    21752269        // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
     
    21882282        m_cache_data.read_line(way, set, r_read_data);
    21892283
    2190         if(m_monitor_ok) check_monitor( m_cmd_read_addr_fifo.read(), r_read_data[0], true);
    2191 
    21922284        // update the cache directory
    21932285        DirectoryEntry entry;
     
    22092301        if(cached_read)   // Cached read => we must update the copies
    22102302        {
    2211           if(!is_cnt)  // Not counter mode
    2212           {
    2213             entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
    2214 #if L1_MULTI_CACHE
    2215             entry.owner.cache_id = m_cmd_read_pktid_fifo.read();
    2216 #endif
    2217             entry.owner.inst     = inst_read;
    2218             entry.count          = r_read_count.read() + 1;
    2219           }
    2220           else  // Counter mode
    2221           {
    2222             entry.owner.srcid    = 0;
    2223 #if L1_MULTI_CACHE
    2224             entry.owner.cache_id = 0;
    2225 #endif
    2226             entry.owner.inst     = false;
    2227             entry.count          = r_read_count.read() + 1;
    2228           }
     2303            if(!is_cnt)  // Not counter mode
     2304            {
     2305                entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
     2306                entry.owner.inst     = inst_read;
     2307                entry.count          = r_read_count.read() + 1;
     2308            }
     2309            else  // Counter mode
     2310            {
     2311                entry.owner.srcid    = 0;
     2312                entry.owner.inst     = false;
     2313                entry.count          = r_read_count.read() + 1;
     2314            }
    22292315        }
    22302316        else            // Uncached read
    22312317        {
    2232           entry.owner.srcid     = r_read_copy.read();
    2233 #if L1_MULTI_CACHE
    2234           entry.owner.cache_id  = r_read_copy_cache.read();
    2235 #endif
    2236           entry.owner.inst      = r_read_copy_inst.read();
    2237           entry.count           = r_read_count.read();
     2318            entry.owner.srcid     = r_read_copy.read();
     2319            entry.owner.inst      = r_read_copy_inst.read();
     2320            entry.count           = r_read_count.read();
    22382321        }
    22392322
    22402323#if DEBUG_MEMC_READ
    2241         if(m_debug)
    2242           std::cout << "  <MEMC " << name() << " READ_DIR_HIT> Update directory entry:"
    2243             << " addr = " << std::hex << m_cmd_read_addr_fifo.read()
    2244             << " / set = " << std::dec << set
    2245             << " / way = " << way
    2246             << " / owner_id = " << std::hex << entry.owner.srcid
    2247             << " / owner_ins = " << std::dec << entry.owner.inst
    2248             << " / count = " << entry.count
    2249             << " / is_cnt = " << entry.is_cnt << std::endl;
    2250 #endif
    2251 
    2252           if(m_monitor_ok)
     2324if(m_debug)
     2325std::cout << "  <MEMC " << name() << " READ_DIR_HIT> Update directory entry:"
     2326          << " addr = " << std::hex << m_cmd_read_addr_fifo.read()
     2327          << " / set = " << std::dec << set
     2328          << " / way = " << way
     2329          << " / owner_id = " << std::hex << entry.owner.srcid
     2330          << " / owner_ins = " << std::dec << entry.owner.inst
     2331          << " / count = " << entry.count
     2332          << " / is_cnt = " << entry.is_cnt << std::endl;
     2333#endif
     2334          /*if(m_monitor_ok)
    22532335          {
    22542336            char buf[80];
     
    22572339                     (int)((m_cmd_read_pktid_fifo.read()&0x2)!=0));
    22582340            check_monitor(m_cmd_read_addr_fifo.read(), r_read_data[0], true);
    2259           }
     2341          }*/
    22602342        m_cache_directory.write(set, way, entry);
    22612343        r_read_fsm    = READ_RSP;
    2262       }
    2263       break;
     2344        break;
    22642345    }
    22652346    ///////////////////
     
    22972378
    22982379        m_cache_data.read_line(way, set, r_read_data);
    2299 
    2300         if(m_monitor_ok) check_monitor( m_cmd_read_addr_fifo.read(), r_read_data[0], true);
    23012380
    23022381        // update the cache directory
     
    23122391        {
    23132392          entry.owner.srcid    = r_read_copy.read();
    2314 #if L1_MULTI_CACHE
    2315           entry.owner.cache_id = r_read_copy_cache.read();
    2316 #endif
    23172393          entry.owner.inst     = r_read_copy_inst.read();
    23182394          entry.ptr            = m_heap.next_free_ptr();   // set pointer on the heap
     
    23212397        {
    23222398          entry.owner.srcid    = 0;
    2323 #if L1_MULTI_CACHE
    2324           entry.owner.cache_id = 0;
    2325 #endif
    23262399          entry.owner.inst     = false;
    23272400          entry.ptr            = 0;
     
    23892462        HeapEntry heap_entry;
    23902463        heap_entry.owner.srcid    = m_cmd_read_srcid_fifo.read();
    2391 #if L1_MULTI_CACHE
    2392         heap_entry.owner.cache_id = m_cmd_read_pktid_fifo.read();
    2393 #endif
    23942464        heap_entry.owner.inst     = ((m_cmd_read_pktid_fifo.read() & 0x2) != 0);
    23952465
     
    24552525        HeapEntry last_entry;
    24562526        last_entry.owner.srcid    = 0;
    2457 #if L1_MULTI_CACHE
    2458         last_entry.owner.cache_id = 0;
    2459 #endif
    24602527        last_entry.owner.inst     = false;
    24612528
     
    24832550    case READ_RSP:    //  request the TGT_RSP FSM to return data
    24842551    {
    2485       if(!r_read_to_tgt_rsp_req)
    2486       {
    2487         for(size_t i=0 ; i<m_words ; i++)  r_read_to_tgt_rsp_data[i] = r_read_data[i];
    2488         r_read_to_tgt_rsp_word   = m_x[(addr_t) m_cmd_read_addr_fifo.read()];
    2489         r_read_to_tgt_rsp_length = m_cmd_read_length_fifo.read();
    2490         r_read_to_tgt_rsp_srcid  = m_cmd_read_srcid_fifo.read();
    2491         r_read_to_tgt_rsp_trdid  = m_cmd_read_trdid_fifo.read();
    2492         r_read_to_tgt_rsp_pktid  = m_cmd_read_pktid_fifo.read();
    2493         r_read_to_tgt_rsp_ll_key = r_read_ll_key.read();
    2494         cmd_read_fifo_get        = true;
    2495         r_read_to_tgt_rsp_req    = true;
    2496         r_read_fsm               = READ_IDLE;
     2552        if(!r_read_to_tgt_rsp_req)
     2553        {
     2554            for(size_t i=0 ; i<m_words ; i++)  r_read_to_tgt_rsp_data[i] = r_read_data[i];
     2555            r_read_to_tgt_rsp_word   = m_x[(addr_t) m_cmd_read_addr_fifo.read()];
     2556            r_read_to_tgt_rsp_length = m_cmd_read_length_fifo.read();
     2557            r_read_to_tgt_rsp_srcid  = m_cmd_read_srcid_fifo.read();
     2558            r_read_to_tgt_rsp_trdid  = m_cmd_read_trdid_fifo.read();
     2559            r_read_to_tgt_rsp_pktid  = m_cmd_read_pktid_fifo.read();
     2560            r_read_to_tgt_rsp_ll_key = r_read_ll_key.read();
     2561            cmd_read_fifo_get        = true;
     2562            r_read_to_tgt_rsp_req    = true;
     2563            r_read_fsm               = READ_IDLE;
    24972564
    24982565#if DEBUG_MEMC_READ
     
    25032570          << " / nwords = " << std::dec << m_cmd_read_length_fifo.read() << std::endl;
    25042571#endif
    2505       }
    2506       break;
     2572        }
     2573        break;
    25072574    }
    25082575    ///////////////////
     
    25252592        if(hit_read or !wok or hit_write)    // missing line already requested or no space
    25262593        {
    2527           if(!wok)      m_cpt_trt_full++;
     2594          if(!wok)                    m_cpt_trt_full++;
    25282595          if(hit_read or hit_write)   m_cpt_trt_rb++;
    25292596          r_read_fsm = READ_IDLE;
     
    25512618      break;
    25522619    }
    2553 
    25542620    //////////////////
    25552621    case READ_TRT_SET:      // register get transaction in TRT
    25562622    {
    2557       if(r_alloc_trt_fsm.read() == ALLOC_TRT_READ)
    2558       {
    2559         m_trt.set(r_read_trt_index.read(),
    2560                               true,
    2561                               m_nline[(addr_t)(m_cmd_read_addr_fifo.read())],
    2562                               m_cmd_read_srcid_fifo.read(),
    2563                               m_cmd_read_trdid_fifo.read(),
    2564                               m_cmd_read_pktid_fifo.read(),
    2565                               true,
    2566                               m_cmd_read_length_fifo.read(),
    2567                               m_x[(addr_t)(m_cmd_read_addr_fifo.read())],
    2568                               std::vector<be_t> (m_words,0),
    2569                               std::vector<data_t> (m_words,0),
    2570                               r_read_ll_key.read());
     2623        if(r_alloc_trt_fsm.read() == ALLOC_TRT_READ)
     2624        {
     2625            m_trt.set( r_read_trt_index.read(),
     2626                       true,      // GET
     2627                       m_nline[(addr_t)(m_cmd_read_addr_fifo.read())],
     2628                       m_cmd_read_srcid_fifo.read(),
     2629                       m_cmd_read_trdid_fifo.read(),
     2630                       m_cmd_read_pktid_fifo.read(),
     2631                       true,      // proc read
     2632                       m_cmd_read_length_fifo.read(),
     2633                       m_x[(addr_t)(m_cmd_read_addr_fifo.read())],
     2634                       std::vector<be_t> (m_words,0),
     2635                       std::vector<data_t> (m_words,0),
     2636                       r_read_ll_key.read() );
    25712637#if DEBUG_MEMC_READ
    25722638if(m_debug)
    2573 std::cout << "  <MEMC " << name() << " READ_TRT_SET> Write in Transaction Table:"
     2639std::cout << "  <MEMC " << name() << " READ_TRT_SET> Set a GET in TRT:"
    25742640          << " address = " << std::hex << m_cmd_read_addr_fifo.read()
    25752641          << " / srcid = " << std::hex << m_cmd_read_srcid_fifo.read() << std::endl;
    25762642#endif
    2577         r_read_fsm = READ_TRT_REQ;
    2578       }
    2579       break;
     2643            r_read_fsm = READ_TRT_REQ;
     2644        }
     2645        break;
    25802646    }
    25812647
     
    25832649    case READ_TRT_REQ:   // consume the read request in FIFO and send it to IXR_CMD_FSM
    25842650    {
    2585       if(not r_read_to_ixr_cmd_req)
    2586       {
    2587         cmd_read_fifo_get       = true;
    2588         r_read_to_ixr_cmd_req   = true;
    2589         r_read_to_ixr_cmd_nline = m_nline[(addr_t)(m_cmd_read_addr_fifo.read())];
    2590         r_read_to_ixr_cmd_trdid = r_read_trt_index.read();
    2591         r_read_fsm              = READ_IDLE;
     2651        if(not r_read_to_ixr_cmd_req)
     2652        {
     2653            cmd_read_fifo_get       = true;
     2654            r_read_to_ixr_cmd_req   = true;
     2655            r_read_to_ixr_cmd_index = r_read_trt_index.read();
     2656            r_read_fsm              = READ_IDLE;
    25922657
    25932658#if DEBUG_MEMC_READ
     
    25962661          << std::hex << m_cmd_read_addr_fifo.read() << std::endl;
    25972662#endif
    2598       }
    2599       break;
     2663        }
     2664        break;
    26002665    }
    26012666  } // end switch read_fsm
     
    26152680  //   If the data is cached by other processors, a coherence transaction must
    26162681  //   be launched (sc requests always require a coherence transaction):
    2617   //   It is a multicast update if the line is not in counter mode, and the processor
     2682  //   It is a multicast update if the line is not in counter mode: the processor
    26182683  //   takes the lock protecting the Update Table (UPT) to register this transaction.
    2619   //   It is a broadcast invalidate if the line is in counter mode.
    26202684  //   If the UPT is full, it releases the lock(s) and retry. Then, it sends
    26212685  //   a multi-update request to all owners of the line (but the writer),
     
    26232687  //   does not respond to the writing processor, as this response will be sent by
    26242688  //   the MULTI_ACK FSM when all update responses have been received.
     2689  //   It is a broadcast invalidate if the line is in counter mode: The line
     2690  //   should be erased in memory cache, and written in XRAM with a PUT transaction,
     2691  //   after registration in TRT.
    26252692  //
    26262693  // - In case of MISS, the WRITE FSM takes the lock protecting the transaction
    26272694  //   table (TRT). If a read transaction to the XRAM for this line already exists,
    26282695  //   it writes in the TRT (write buffer). Otherwise, if a TRT entry is free,
    2629   //   the WRITE FSM register a new transaction in TRT, and sends a read line request
     2696  //   the WRITE FSM register a new transaction in TRT, and sends a GET request
    26302697  //   to the XRAM. If the TRT is full, it releases the lock, and waits.
    26312698  //   Finally, the WRITE FSM returns an aknowledge response to the writing processor.
    26322699  /////////////////////////////////////////////////////////////////////////////////////
     2700
     2701//std::cout << std::endl << "write_fsm" << std::endl;
    26332702
    26342703  switch(r_write_fsm.read())
     
    26372706    case WRITE_IDLE:  // copy first word of a write burst in local buffer
    26382707    {
    2639       if(m_cmd_write_addr_fifo.rok())
    2640       {
    2641         if((m_cmd_write_pktid_fifo.read() & 0x7) == TYPE_SC)
    2642           m_cpt_sc++;
    2643         else
    2644         {
    2645           m_cpt_write++;
    2646           m_cpt_write_cells++;
    2647         }
    2648 
    2649         // consume a word in the FIFO & write it in the local buffer
    2650         cmd_write_fifo_get  = true;
    2651         size_t index        = m_x[(addr_t)(m_cmd_write_addr_fifo.read())];
    2652 
    2653         r_write_address     = (addr_t)(m_cmd_write_addr_fifo.read());
    2654         r_write_word_index  = index;
    2655         r_write_word_count  = 1;
    2656         r_write_data[index] = m_cmd_write_data_fifo.read();
    2657         r_write_srcid       = m_cmd_write_srcid_fifo.read();
    2658         r_write_trdid       = m_cmd_write_trdid_fifo.read();
    2659         r_write_pktid       = m_cmd_write_pktid_fifo.read();
    2660         r_write_pending_sc  = false;
    2661 
    2662         // initialize the be field for all words
    2663         for(size_t word=0 ; word<m_words ; word++)
    2664         {
    2665           if(word == index) r_write_be[word] = m_cmd_write_be_fifo.read();
    2666           else              r_write_be[word] = 0x0;
    2667         }
    2668 
    2669         if (m_cmd_write_eop_fifo.read() or ((m_cmd_write_pktid_fifo.read() & 0x7) == TYPE_SC))
    2670         {
    2671           r_write_fsm = WRITE_DIR_REQ;
    2672         }
    2673         else
    2674         {
    2675           r_write_fsm = WRITE_NEXT;
    2676         }
     2708        if(m_cmd_write_addr_fifo.rok())
     2709        {
     2710            if((m_cmd_write_pktid_fifo.read() & 0x7) == TYPE_SC)
     2711            {
     2712                m_cpt_sc++;
     2713            }
     2714            else
     2715            {
     2716                m_cpt_write++;
     2717                m_cpt_write_cells++;
     2718            }
     2719
     2720            // consume a word in the FIFO & write it in the local buffer
     2721            cmd_write_fifo_get  = true;
     2722            size_t index        = m_x[(addr_t)(m_cmd_write_addr_fifo.read())];
     2723
     2724            r_write_address     = (addr_t)(m_cmd_write_addr_fifo.read());
     2725            r_write_word_index  = index;
     2726            r_write_word_count  = 1;
     2727            r_write_data[index] = m_cmd_write_data_fifo.read();
     2728            r_write_srcid       = m_cmd_write_srcid_fifo.read();
     2729            r_write_trdid       = m_cmd_write_trdid_fifo.read();
     2730            r_write_pktid       = m_cmd_write_pktid_fifo.read();
     2731            r_write_pending_sc  = false;
     2732
     2733            // initialize the be field for all words
     2734            for(size_t word=0 ; word<m_words ; word++)
     2735            {
     2736                if(word == index) r_write_be[word] = m_cmd_write_be_fifo.read();
     2737                else              r_write_be[word] = 0x0;
     2738            }
     2739
     2740            if (m_cmd_write_eop_fifo.read() or ((m_cmd_write_pktid_fifo.read() & 0x7) == TYPE_SC))
     2741            {
     2742                r_write_fsm = WRITE_DIR_REQ;
     2743            }
     2744            else
     2745            {
     2746                r_write_fsm = WRITE_NEXT;
     2747            }
    26772748
    26782749#if DEBUG_MEMC_WRITE
     
    26832754          << " / data = " << m_cmd_write_data_fifo.read() << std::endl;
    26842755#endif
    2685       }
    2686       break;
    2687     }
    2688 
     2756        }
     2757        break;
     2758    }
    26892759    ////////////////
    26902760    case WRITE_NEXT:  // copy next word of a write burst in local buffer
    26912761    {
    2692       if(m_cmd_write_addr_fifo.rok())
    2693       {
     2762        if(m_cmd_write_addr_fifo.rok())
     2763        {
    26942764
    26952765#if DEBUG_MEMC_WRITE
     
    26992769          << std::endl;
    27002770#endif
    2701         m_cpt_write_cells++;
    2702 
    2703         // check that the next word is in the same cache line
    2704         if((m_nline[(addr_t)(r_write_address.read())]       !=
    2705             m_nline[(addr_t)(m_cmd_write_addr_fifo.read())]))
    2706         {
    2707           std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_NEXT state" << std::endl
    2708                     << "all words in a write burst must be in same cache line" << std::endl;
    2709 
    2710           exit(0);
    2711         }
    2712 
    2713         // consume a word in the FIFO & write it in the local buffer
    2714         cmd_write_fifo_get  = true;
    2715         size_t index        = r_write_word_index.read() + r_write_word_count.read();
    2716 
    2717         r_write_be[index]   = m_cmd_write_be_fifo.read();
    2718         r_write_data[index] = m_cmd_write_data_fifo.read();
    2719         r_write_word_count  = r_write_word_count.read() + 1;
    2720 
    2721         if(m_cmd_write_eop_fifo.read())
    2722         {
    2723           r_write_fsm = WRITE_DIR_REQ;
    2724         }
    2725       }
    2726       break;
    2727     }
    2728 
    2729     ////////////////////
    2730     case WRITE_DIR_REQ:
    2731     {
    2732       // Get the lock to the directory
    2733       // and access the llsc_global_table
    2734       if(r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE)
    2735       {
    2736         ///////////////////////////////////////////////////////////////////////
    2737         // SC command treatment
    2738         // We test the r_write_pending_sc register to know if we are returning
    2739         // from the WAIT state.
    2740         // In this case, the SC has already succeed and we cannot consume
    2741         // another time from the FIFO. Also, we don't have to test another
    2742         // time if the SC has succeed
    2743         if(((r_write_pktid.read() & 0x7) == TYPE_SC) and not r_write_pending_sc.read())
    2744         {
    2745           if(not m_cmd_write_addr_fifo.rok()) break;
    2746 
    2747           assert(m_cmd_write_eop_fifo.read() and
    2748                  "Error in VCI_MEM_CACHE : "
    2749                  "invalid packet format for SC command");
    2750 
    2751           size_t index    = r_write_word_index.read();
    2752           bool sc_success = m_llsc_table.sc(r_write_address.read()    ,
     2771            m_cpt_write_cells++;
     2772
     2773            // check that the next word is in the same cache line
     2774            assert( (m_nline[(addr_t)(r_write_address.read())] ==
     2775                     m_nline[(addr_t)(m_cmd_write_addr_fifo.read())]) and
     2776            "MEMC ERROR in WRITE_NEXT state: Illegal write burst");
     2777
     2778            // consume a word in the FIFO & write it in the local buffer
     2779            cmd_write_fifo_get  = true;
     2780            size_t index        = r_write_word_index.read() + r_write_word_count.read();
     2781
     2782            r_write_be[index]   = m_cmd_write_be_fifo.read();
     2783            r_write_data[index] = m_cmd_write_data_fifo.read();
     2784            r_write_word_count  = r_write_word_count.read() + 1;
     2785
     2786            if(m_cmd_write_eop_fifo.read()) r_write_fsm = WRITE_DIR_REQ;
     2787        }
     2788        break;
     2789    }
     2790    ///////////////////
     2791    case WRITE_DIR_REQ:    // Get the lock to the directory
     2792                           // and access the llsc_global_table
     2793    {
     2794        if( r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE )
     2795        {
     2796            if(((r_write_pktid.read() & 0x7) == TYPE_SC) and not r_write_pending_sc.read())
     2797            {
     2798                // We enter here if it is a new SC command
     2799                // If r_write_pending_sc is set the SC is not new and has already been tested
     2800
     2801                if(not m_cmd_write_addr_fifo.rok()) break;
     2802
     2803                assert( m_cmd_write_eop_fifo.read() and
     2804                "MEMC ERROR in WRITE_DIR_REQ state: invalid packet format for SC command");
     2805
     2806                size_t index    = r_write_word_index.read();
     2807                bool sc_success = m_llsc_table.sc(r_write_address.read()    ,
    27532808                                            r_write_data[index].read());
    27542809
    2755           // consume a word in the FIFO & write it in the local buffer
    2756           cmd_write_fifo_get  = true;
    2757           r_write_data[index] = m_cmd_write_data_fifo.read();
    2758           r_write_sc_fail     = not sc_success;
    2759           r_write_pending_sc  = true;
    2760 
    2761           if(not sc_success) r_write_fsm = WRITE_RSP;
    2762           else               r_write_fsm = WRITE_DIR_LOCK;
    2763 
    2764           break;
    2765         }
    2766 
    2767         ///////////////////////////////////////////////////////////////////////
    2768         // WRITE command treatment or SC command returning from the WAIT state
    2769         // In the second case, we must access the LL/SC global table to
    2770         // erase any possible new reservation when we release the lock on the
    2771         // directory
    2772         m_llsc_table.sw(m_nline[(addr_t)r_write_address.read()],r_write_word_index.read(),r_write_word_index.read()+r_write_word_count.read());
    2773 
    2774         r_write_fsm = WRITE_DIR_LOCK;
    2775         m_cpt_write_fsm_n_dir_lock++;
     2810                // consume a word in the FIFO & write it in the local buffer
     2811                cmd_write_fifo_get  = true;
     2812                r_write_data[index] = m_cmd_write_data_fifo.read();
     2813                r_write_sc_fail     = not sc_success;
     2814                r_write_pending_sc  = true;
     2815
     2816                if(not sc_success) r_write_fsm = WRITE_RSP;
     2817                else               r_write_fsm = WRITE_DIR_LOCK;
     2818            }
     2819            else
     2820            {
     2821                // We enter here if it is a SW command or an already tested SC command
     2822
     2823                m_llsc_table.sw( m_nline[(addr_t)r_write_address.read()],
     2824                                 r_write_word_index.read(),
     2825                                 r_write_word_index.read() + r_write_word_count.read() );
     2826
     2827                r_write_fsm = WRITE_DIR_LOCK;
     2828            }
    27762829      }
    27772830
     
    27812834          << std::endl;
    27822835#endif
    2783 
    2784       m_cpt_write_fsm_dir_lock++;
    2785 
    27862836      break;
    27872837    }
    2788 
    27892838    ////////////////////
    27902839    case WRITE_DIR_LOCK:     // access directory to check hit/miss
    27912840    {
    2792       if(r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE)
    2793       {
     2841        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     2842        "MEMC ERROR in ALLOC_DIR_LOCK state: Bad DIR allocation");
     2843
    27942844        size_t  way = 0;
    27952845        DirectoryEntry entry(m_cache_directory.read(r_write_address.read(), way));
     
    27972847        if(entry.valid)    // hit
    27982848        {
    2799           // copy directory entry in local buffer in case of hit
    2800           r_write_is_cnt     = entry.is_cnt;
    2801           r_write_lock       = entry.lock;
    2802           r_write_tag        = entry.tag;
    2803           r_write_copy       = entry.owner.srcid;
    2804 #if L1_MULTI_CACHE
    2805           r_write_copy_cache = entry.owner.cache_id;
    2806 #endif
    2807           r_write_copy_inst  = entry.owner.inst;
    2808           r_write_count      = entry.count;
    2809           r_write_ptr        = entry.ptr;
    2810           r_write_way        = way;
    2811 
    2812           if(entry.is_cnt and entry.count)
    2813           {
    2814             r_write_fsm = WRITE_DIR_READ;
    2815           }
    2816           else
    2817           {
    2818             r_write_fsm = WRITE_DIR_HIT;
    2819           }
     2849            // copy directory entry in local buffer in case of hit
     2850            r_write_is_cnt     = entry.is_cnt;
     2851            r_write_lock       = entry.lock;
     2852            r_write_tag        = entry.tag;
     2853            r_write_copy       = entry.owner.srcid;
     2854            r_write_copy_inst  = entry.owner.inst;
     2855            r_write_count      = entry.count;
     2856            r_write_ptr        = entry.ptr;
     2857            r_write_way        = way;
     2858
     2859            if(entry.is_cnt and entry.count) r_write_fsm = WRITE_BC_DIR_READ;
     2860            else                             r_write_fsm = WRITE_DIR_HIT;
    28202861        }
    28212862        else  // miss
    28222863        {
    2823           r_write_fsm = WRITE_MISS_TRT_LOCK;
     2864            r_write_fsm = WRITE_MISS_TRT_LOCK;
    28242865        }
    28252866
     
    28382879}
    28392880#endif
    2840       }
    2841       else
    2842       {
    2843         std::cout << "VCI_MEM_CACHE ERROR " << name()
    2844                   << " WRITE_DIR_LOCK state"        << std::endl
    2845                   << "bad DIR allocation"           << std::endl;
    2846 
    2847         exit(0);
    2848       }
    2849       break;
    2850     }
    2851     ////////////////////
    2852     case WRITE_DIR_READ:  // read the cache and complete the buffer when be!=0xF
    2853     {
    2854       // update local buffer
    2855       size_t set  = m_y[(addr_t)(r_write_address.read())];
    2856       size_t way  = r_write_way.read();
    2857       for(size_t word=0 ; word<m_words ; word++)
    2858       {
    2859         data_t mask = 0;
    2860         if(r_write_be[word].read() & 0x1) mask = mask | 0x000000FF;
    2861         if(r_write_be[word].read() & 0x2) mask = mask | 0x0000FF00;
    2862         if(r_write_be[word].read() & 0x4) mask = mask | 0x00FF0000;
    2863         if(r_write_be[word].read() & 0x8) mask = mask | 0xFF000000;
    2864 
    2865         // complete only if mask is not null (for energy consumption)
    2866         r_write_data[word]  = (r_write_data[word].read() & mask) |
    2867                               (m_cache_data.read(way, set, word) & ~mask);
    2868 
    2869       } // end for
    2870 
    2871       // test if a coherence broadcast is required
    2872       r_write_fsm = WRITE_BC_TRT_LOCK;
    2873 
    2874 #if DEBUG_MEMC_WRITE
    2875 if(m_debug)
    2876 std::cout << "  <MEMC " << name() << " WRITE_DIR_READ>"
    2877           << " Read the cache to complete local buffer" << std::endl;
    2878 #endif
    2879       break;
    2880     }
    2881 
     2881        break;
     2882    }
    28822883    ///////////////////
    2883     case WRITE_DIR_HIT:
    2884     {
    2885       // update the cache directory
    2886       // update directory with Dirty bit
    2887       DirectoryEntry entry;
    2888       entry.valid          = true;
    2889       entry.dirty          = true;
    2890       entry.tag            = r_write_tag.read();
    2891       entry.is_cnt         = r_write_is_cnt.read();
    2892       entry.lock           = r_write_lock.read();
    2893       entry.owner.srcid    = r_write_copy.read();
    2894 #if L1_MULTI_CACHE
    2895       entry.owner.cache_id = r_write_copy_cache.read();
    2896 #endif
    2897       entry.owner.inst     = r_write_copy_inst.read();
    2898       entry.count          = r_write_count.read();
    2899       entry.ptr            = r_write_ptr.read();
    2900 
    2901       size_t set           = m_y[(addr_t)(r_write_address.read())];
    2902       size_t way           = r_write_way.read();
    2903 
    2904       // update directory
    2905       m_cache_directory.write(set, way, entry);
    2906 
    2907       // owner is true when the  the first registered copy is the writer itself
    2908       bool owner = (((r_write_copy.read() == r_write_srcid.read())
    2909 #if L1_MULTI_CACHE
    2910                      and(r_write_copy_cache.read() ==r_write_pktid.read())
    2911 #endif
    2912                     ) and not r_write_copy_inst.read());
    2913 
    2914       // no_update is true when there is no need for coherence transaction
    2915       // (tests for sc requests)
    2916       bool no_update = ( (r_write_count.read() == 0) or
     2884    case WRITE_DIR_HIT:    // update the cache directory with Dirty bit
     2885                           // and update data cache
     2886    {
     2887        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     2888        "MEMC ERROR in ALLOC_DIR_HIT state: Bad DIR allocation");
     2889
     2890        DirectoryEntry entry;
     2891        entry.valid          = true;
     2892        entry.dirty          = true;
     2893        entry.tag            = r_write_tag.read();
     2894        entry.is_cnt         = r_write_is_cnt.read();
     2895        entry.lock           = r_write_lock.read();
     2896        entry.owner.srcid    = r_write_copy.read();
     2897        entry.owner.inst     = r_write_copy_inst.read();
     2898        entry.count          = r_write_count.read();
     2899        entry.ptr            = r_write_ptr.read();
     2900
     2901        size_t set           = m_y[(addr_t)(r_write_address.read())];
     2902        size_t way           = r_write_way.read();
     2903
     2904        // update directory
     2905        m_cache_directory.write(set, way, entry);
     2906
     2907        // owner is true when the  the first registered copy is the writer itself
     2908        bool owner = ( (r_write_copy.read() == r_write_srcid.read())
     2909                     and not r_write_copy_inst.read() );
     2910
     2911        // no_update is true when there is no need for coherence transaction
     2912        bool no_update = ( (r_write_count.read() == 0) or
    29172913                         (owner and (r_write_count.read() ==1) and
    29182914                         (r_write_pktid.read() != TYPE_SC)));
    29192915
    2920       // write data in the cache if no coherence transaction
    2921       if(no_update)
    2922       {
    2923         for(size_t word=0 ; word<m_words ; word++)
    2924         {
    2925           m_cache_data.write(way, set, word, r_write_data[word].read(), r_write_be[word].read());
    2926 
    2927           if(m_monitor_ok)
    2928           {
    2929             addr_t address = (r_write_address.read() & ~(addr_t) 0x3F) | word<<2;
    2930             check_monitor( address, r_write_data[word].read(), false);
    2931           }
    2932         }
    2933       }
    2934 
    2935       if(owner and not no_update and(r_write_pktid.read() != TYPE_SC))
    2936       {
    2937         r_write_count = r_write_count.read() - 1;
    2938       }
    2939 
    2940       if(no_update)
    2941       // Write transaction completed
    2942       {
    2943         r_write_fsm = WRITE_RSP;
    2944       }
    2945       else
    2946       // coherence update required
    2947       {
    2948         if(!r_write_to_cc_send_multi_req.read() and
    2949            !r_write_to_cc_send_brdcast_req.read())
    2950         {
    2951           r_write_fsm = WRITE_UPT_LOCK;
    2952         }
    2953         else
    2954         {
    2955           r_write_fsm = WRITE_WAIT;
    2956         }
    2957       }
     2916        // write data in the cache if no coherence transaction
     2917        if(no_update)
     2918        {
     2919            for(size_t word=0 ; word<m_words ; word++)
     2920            {
     2921                m_cache_data.write( way,
     2922                                    set,
     2923                                    word,
     2924                                    r_write_data[word].read(),
     2925                                    r_write_be[word].read());
     2926            }
     2927        }
     2928
     2929        if(owner and not no_update and(r_write_pktid.read() != TYPE_SC))
     2930        {
     2931            r_write_count = r_write_count.read() - 1;
     2932        }
     2933
     2934        if(no_update)     // Write transaction completed
     2935        {
     2936            r_write_fsm = WRITE_RSP;
     2937        }
     2938        else              // coherence update required
     2939        {
     2940            if(!r_write_to_cc_send_multi_req.read() and
     2941               !r_write_to_cc_send_brdcast_req.read())
     2942            {
     2943                r_write_fsm = WRITE_UPT_LOCK;
     2944            }
     2945            else
     2946            {
     2947                r_write_fsm = WRITE_WAIT;
     2948            }
     2949        }
    29582950
    29592951#if DEBUG_MEMC_WRITE
    29602952if(m_debug)
    29612953{
    2962     if(no_update)
    2963     {
    2964         std::cout << "  <MEMC " << name()
    2965                   << " WRITE_DIR_HIT> Write into cache / No coherence transaction"
    2966                   << std::endl;
    2967     }
    2968     else
    2969     {
    2970         std::cout << "  <MEMC " << name() << " WRITE_DIR_HIT> Coherence update required:"
    2971                   << " is_cnt = " << r_write_is_cnt.read()
    2972                   << " nb_copies = " << std::dec << r_write_count.read() << std::endl;
    2973         if(owner) std::cout << "       ... but the first copy is the writer" << std::endl;
    2974     }
     2954if(no_update)
     2955{
     2956std::cout << "  <MEMC " << name()
     2957          << " WRITE_DIR_HIT> Write into cache / No coherence transaction" << std::endl;
    29752958}
    2976 #endif
    2977       break;
     2959else
     2960{
     2961std::cout << "  <MEMC " << name() << " WRITE_DIR_HIT> Coherence update required:"
     2962          << " is_cnt = " << r_write_is_cnt.read()
     2963          << " nb_copies = " << std::dec << r_write_count.read() << std::endl;
     2964if(owner) std::cout << "       ... but the first copy is the writer" << std::endl;
     2965}
     2966}
     2967#endif
     2968        break;
    29782969    }
    29792970    ////////////////////
    29802971    case WRITE_UPT_LOCK:  // Try to register the update request in UPT
    29812972    {
    2982       if(r_alloc_upt_fsm.read() == ALLOC_UPT_WRITE)
    2983       {
    2984         bool        wok        = false;
    2985         size_t      index      = 0;
    2986         size_t      srcid      = r_write_srcid.read();
    2987         size_t      trdid      = r_write_trdid.read();
    2988         size_t      pktid      = r_write_pktid.read();
    2989         addr_t      nline      = m_nline[(addr_t)(r_write_address.read())];
    2990         size_t      nb_copies  = r_write_count.read();
    2991         size_t      set        = m_y[(addr_t)(r_write_address.read())];
    2992         size_t      way        = r_write_way.read();
    2993 
    2994         wok = m_upt.set(true,  // it's an update transaction
    2995                         false, // it's not a broadcast
    2996                         true,  // response required
    2997                         false, // no acknowledge required
    2998                         srcid,   
    2999                         trdid,
    3000                         pktid,
    3001                         nline,
    3002                         nb_copies,
    3003                         index);
    3004         if(wok)       // write data in cache
    3005         {
    3006           for(size_t word=0 ; word<m_words ; word++)
    3007           {
    3008             m_cache_data.write(way,
    3009                                set,
    3010                                word,
    3011                                r_write_data[word].read(),
    3012                                r_write_be[word].read());
    3013 
    3014             if(m_monitor_ok)
     2973        if(r_alloc_upt_fsm.read() == ALLOC_UPT_WRITE)
     2974        {
     2975            bool        wok        = false;
     2976            size_t      index      = 0;
     2977            size_t      srcid      = r_write_srcid.read();
     2978            size_t      trdid      = r_write_trdid.read();
     2979            size_t      pktid      = r_write_pktid.read();
     2980            addr_t      nline      = m_nline[(addr_t)(r_write_address.read())];
     2981            size_t      nb_copies  = r_write_count.read();
     2982            size_t      set        = m_y[(addr_t)(r_write_address.read())];
     2983            size_t      way        = r_write_way.read();
     2984
     2985            wok = m_upt.set( true,  // it's an update transaction
     2986                             false, // it's not a broadcast
     2987                             true,  // response required
     2988                             false, // no acknowledge required
     2989                             srcid,   
     2990                             trdid,
     2991                             pktid,
     2992                             nline,
     2993                             nb_copies,
     2994                             index);
     2995
     2996            if( wok )       // write data in cache
    30152997            {
    3016               addr_t address = (r_write_address.read() & ~(addr_t) 0x3F) | word<<2;
    3017               check_monitor( address, r_write_data[word].read(), false);
     2998                for(size_t word=0 ; word<m_words ; word++)
     2999                {
     3000                    m_cache_data.write( way,
     3001                                        set,
     3002                                        word,
     3003                                        r_write_data[word].read(),
     3004                                        r_write_be[word].read());
     3005                }
    30183006            }
    3019           }
    3020         }
    30213007
    30223008#if DEBUG_MEMC_WRITE
    3023 if(m_debug)
     3009if(m_debug and wok)
    30243010{
    3025     if(wok)
    3026     {
    3027         std::cout << "  <MEMC " << name()
    3028                   << " WRITE_UPT_LOCK> Register the multicast update in UPT / "
    3029                   << " nb_copies = " << r_write_count.read() << std::endl;
    3030     }
     3011std::cout << "  <MEMC " << name()
     3012          << " WRITE_UPT_LOCK> Register the multicast update in UPT / "
     3013          << " nb_copies = " << r_write_count.read() << std::endl;
    30313014}
    30323015#endif
    3033         r_write_upt_index = index;
    3034         //  releases the lock protecting UPT and the DIR if no entry...
    3035         if(wok) r_write_fsm = WRITE_UPT_HEAP_LOCK;
    3036         else    r_write_fsm = WRITE_WAIT;
    3037         m_cpt_write_fsm_n_upt_lock++;
    3038       }
    3039 
    3040       m_cpt_write_fsm_upt_lock++;
    3041 
    3042       break;
     3016            r_write_upt_index = index;
     3017            // releases the lock protecting UPT and the DIR if no entry...
     3018            if(wok) r_write_fsm = WRITE_UPT_HEAP_LOCK;
     3019            else    r_write_fsm = WRITE_WAIT;
     3020        }
     3021        break;
    30433022    }
    30443023
     
    30863065      for(size_t i=min ; i<max ; i++) r_write_to_cc_send_data[i] = r_write_data[i];
    30873066
    3088       if((r_write_copy.read() != r_write_srcid.read()) or(r_write_pktid.read() == TYPE_SC) or
    3089 #if L1_MULTI_CACHE
    3090           (r_write_copy_cache.read() != r_write_pktid.read()) or
    3091 #endif
    3092           r_write_copy_inst.read())
     3067      if( (r_write_copy.read() != r_write_srcid.read()) or
     3068          (r_write_pktid.read() == TYPE_SC) or r_write_copy_inst.read())
    30933069      {
    30943070        // put the first srcid in the fifo
     
    30963072        write_to_cc_send_fifo_inst    = r_write_copy_inst.read();
    30973073        write_to_cc_send_fifo_srcid   = r_write_copy.read();
    3098 #if L1_MULTI_CACHE
    3099         write_to_cc_send_fifo_cache_id= r_write_copy_cache.read();
    3100 #endif
    31013074        if(r_write_count.read() == 1)
    31023075        {
     
    31493122      bool dec_upt_counter;
    31503123
    3151       if(((entry.owner.srcid != r_write_srcid.read()) or (r_write_pktid.read() == TYPE_SC)) or
    3152 #if L1_MULTI_CACHE
    3153           (entry.owner.cache_id != r_write_pktid.read()) or
    3154 #endif
    3155           entry.owner.inst)             // put the next srcid in the fifo
     3124      // put the next srcid in the fifo
     3125      if( (entry.owner.srcid != r_write_srcid.read()) or
     3126          (r_write_pktid.read() == TYPE_SC) or entry.owner.inst)   
    31563127      {
    31573128        dec_upt_counter                = false;
     
    31593130        write_to_cc_send_fifo_inst     = entry.owner.inst;
    31603131        write_to_cc_send_fifo_srcid    = entry.owner.srcid;
    3161 #if L1_MULTI_CACHE
    3162         write_to_cc_send_fifo_cache_id = entry.owner.cache_id;
    3163 #endif
    31643132
    31653133#if DEBUG_MEMC_WRITE
     
    32313199
    32323200    ///////////////
    3233     case WRITE_RSP:
    3234     {
    3235       // Post a request to TGT_RSP FSM to acknowledge the write
    3236       // In order to increase the Write requests throughput,
    3237       // we don't wait to return in the IDLE state to consume
    3238       // a new request in the write FIFO
    3239 
     3201    case WRITE_RSP:  // Post a request to TGT_RSP FSM to acknowledge the write
     3202                     // In order to increase the Write requests throughput,
     3203                     // we don't wait to return in the IDLE state to consume
     3204                     // a new request in the write FIFO
     3205    {
    32403206      if(!r_write_to_tgt_rsp_req.read())
    32413207      {
     
    33303296        bool    hit_write = m_trt.hit_write(m_nline[addr]);
    33313297#endif
    3332         bool    wok       = !m_trt.full(wok_index);
     3298        bool    wok       = not m_trt.full(wok_index);
    33333299
    33343300        if(hit_read)      // register the modified data in TRT
     
    34183384          data_vector.push_back(r_write_data[i]);
    34193385        }
    3420         m_trt.write_data_mask(r_write_trt_index.read(),
    3421                                           be_vector,
    3422                                           data_vector);
     3386        m_trt.write_data_mask( r_write_trt_index.read(),
     3387                               be_vector,
     3388                               data_vector );
    34233389        r_write_fsm = WRITE_RSP;
    34243390
     
    34303396      break;
    34313397    }
    3432 
    34333398    /////////////////////////
    34343399    case WRITE_MISS_XRAM_REQ: // send a GET request to IXR_CMD FSM
    34353400    {
    3436       if(!r_write_to_ixr_cmd_req)
     3401      if( not r_write_to_ixr_cmd_req.read() )
    34373402      {
    34383403        r_write_to_ixr_cmd_req   = true;
    3439         r_write_to_ixr_cmd_write = false;
    3440         r_write_to_ixr_cmd_nline = m_nline[(addr_t)(r_write_address.read())];
    3441         r_write_to_ixr_cmd_trdid = r_write_trt_index.read();
     3404        r_write_to_ixr_cmd_put   = false;
     3405        r_write_to_ixr_cmd_index = r_write_trt_index.read();
    34423406        r_write_fsm              = WRITE_RSP;
    34433407
     
    34493413      break;
    34503414    }
    3451 
    34523415    ///////////////////////
    3453     case WRITE_BC_TRT_LOCK:     // Check TRT not full
    3454     {
    3455       if(r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE)
    3456       {
    3457         size_t wok_index = 0;
    3458         bool wok = !m_trt.full(wok_index);
    3459         if(wok)       // set a new entry in TRT
    3460         {
    3461           r_write_trt_index = wok_index;
    3462           r_write_fsm       = WRITE_BC_IVT_LOCK;
    3463         }
    3464         else  // wait an empty entry in TRT
    3465         {
    3466           r_write_fsm       = WRITE_WAIT;
    3467         }
     3416    case WRITE_BC_DIR_READ:  // enter this state if a broadcast-inval is required
     3417                             // the cache line must be erased in mem-cache, and written
     3418                             // into XRAM. we read the cache and complete the buffer
     3419    {
     3420        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3421        "MEMC ERROR in WRITE_BC_DIR_READ state: Bad DIR allocation");
     3422 
     3423        // update local buffer
     3424        size_t set  = m_y[(addr_t)(r_write_address.read())];
     3425        size_t way  = r_write_way.read();
     3426        for(size_t word=0 ; word<m_words ; word++)
     3427        {
     3428            data_t mask = 0;
     3429            if(r_write_be[word].read() & 0x1) mask = mask | 0x000000FF;
     3430            if(r_write_be[word].read() & 0x2) mask = mask | 0x0000FF00;
     3431            if(r_write_be[word].read() & 0x4) mask = mask | 0x00FF0000;
     3432            if(r_write_be[word].read() & 0x8) mask = mask | 0xFF000000;
     3433
     3434            // complete only if mask is not null (for energy consumption)
     3435            r_write_data[word]  = (r_write_data[word].read() & mask) |
     3436                                  (m_cache_data.read(way, set, word) & ~mask);
     3437        } // end for
     3438
     3439        r_write_fsm = WRITE_BC_TRT_LOCK;
     3440
     3441#if DEBUG_MEMC_WRITE
     3442if(m_debug)
     3443std::cout << "  <MEMC " << name() << " WRITE_BC_DIR_READ>"
     3444          << " Read the cache to complete local buffer" << std::endl;
     3445#endif
     3446        break;
     3447    }
     3448    ///////////////////////
     3449    case WRITE_BC_TRT_LOCK:     // get TRT lock to check TRT not full
     3450    {
     3451        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3452        "MEMC ERROR in WRITE_BC_TRT_LOCK state: Bad DIR allocation");
     3453 
     3454        if(r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE)
     3455        {
     3456            size_t wok_index = 0;
     3457            bool wok = not m_trt.full(wok_index);
     3458            if( wok )       
     3459            {
     3460                r_write_trt_index = wok_index;
     3461                r_write_fsm       = WRITE_BC_IVT_LOCK;
     3462            }
     3463            else  // wait an empty slot in TRT
     3464            {
     3465                r_write_fsm       = WRITE_WAIT;
     3466            }
    34683467
    34693468#if DEBUG_MEMC_WRITE
     
    34793478      break;
    34803479    }
    3481 
    34823480    //////////////////////
    3483     case WRITE_BC_IVT_LOCK:      // register BC transaction in IVT
    3484     {
    3485       if(r_alloc_ivt_fsm.read() == ALLOC_IVT_WRITE)
    3486       {
    3487         bool        wok       = false;
    3488         size_t      index     = 0;
    3489         size_t      srcid     = r_write_srcid.read();
    3490         size_t      trdid     = r_write_trdid.read();
    3491         size_t      pktid     = r_write_pktid.read();
    3492         addr_t      nline     = m_nline[(addr_t)(r_write_address.read())];
    3493         size_t      nb_copies = r_write_count.read();
    3494 
    3495         wok = m_ivt.set(false,  // it's an inval transaction
    3496                         true,   // it's a broadcast
    3497                         true,   // response required
    3498                         false,  // no acknowledge required
    3499                         srcid,
    3500                         trdid,
    3501                         pktid,
    3502                         nline,
    3503                         nb_copies,
    3504                         index);
     3481    case WRITE_BC_IVT_LOCK:      // get IVT lock and register BC transaction in IVT
     3482    {
     3483        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3484        "MEMC ERROR in WRITE_BC_IVT_LOCK state: Bad DIR allocation");
     3485 
     3486        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) and
     3487        "MEMC ERROR in WRITE_BC_IVT_LOCK state: Bad TRT allocation");
     3488 
     3489        if(r_alloc_ivt_fsm.read() == ALLOC_IVT_WRITE)
     3490        {
     3491            bool        wok       = false;
     3492            size_t      index     = 0;
     3493            size_t      srcid     = r_write_srcid.read();
     3494            size_t      trdid     = r_write_trdid.read();
     3495            size_t      pktid     = r_write_pktid.read();
     3496            addr_t      nline     = m_nline[(addr_t)(r_write_address.read())];
     3497            size_t      nb_copies = r_write_count.read();
     3498
     3499            wok = m_ivt.set(false,  // it's an inval transaction
     3500                            true,   // it's a broadcast
     3501                            true,   // response required
     3502                            false,  // no acknowledge required
     3503                            srcid,
     3504                            trdid,
     3505                            pktid,
     3506                            nline,
     3507                            nb_copies,
     3508                            index);
    35053509#if DEBUG_MEMC_WRITE
    35063510if( m_debug and wok )
     
    35083512          << " / nb_copies = " << r_write_count.read() << std::endl;
    35093513#endif
    3510         r_write_upt_index = index;
    3511 
    3512         if(wok) r_write_fsm = WRITE_BC_DIR_INVAL;
    3513         else    r_write_fsm = WRITE_WAIT;
    3514         m_cpt_write_fsm_n_upt_lock++;
    3515       }
    3516 
    3517       m_cpt_write_fsm_upt_lock++;
    3518 
    3519       break;
    3520     }
    3521 
     3514            r_write_upt_index = index;
     3515
     3516            if( wok ) r_write_fsm = WRITE_BC_DIR_INVAL;
     3517            else      r_write_fsm = WRITE_WAIT;
     3518        }
     3519        break;
     3520    }
    35223521    ////////////////////////
    3523     case WRITE_BC_DIR_INVAL:
    3524     {
    3525       // Register a put transaction to XRAM in TRT
    3526       // and invalidate the line in directory
    3527       if((r_alloc_trt_fsm.read() != ALLOC_TRT_WRITE) or
    3528          (r_alloc_ivt_fsm.read() != ALLOC_IVT_WRITE) or
    3529          (r_alloc_dir_fsm.read() != ALLOC_DIR_WRITE))
    3530       {
    3531         std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_BC_DIR_INVAL state" << std::endl;
    3532         std::cout << "bad TRT, DIR, or IVT allocation" << std::endl;
    3533         exit(0);
    3534       }
    3535 
    3536       // register a write request to XRAM in TRT
    3537       m_trt.set(r_write_trt_index.read(),
    3538                             false,    // write request to XRAM
    3539                             m_nline[(addr_t)(r_write_address.read())],
    3540                             0,
    3541                             0,
    3542                             0,
    3543                             false,    // not a processor read
    3544                             0,        // not a single word
    3545                             0,            // word index
    3546                             std::vector<be_t> (m_words,0),
    3547                             std::vector<data_t> (m_words,0));
    3548 
    3549       // invalidate directory entry
    3550       DirectoryEntry entry;
    3551       entry.valid         = false;
    3552       entry.dirty         = false;
    3553       entry.tag         = 0;
    3554       entry.is_cnt        = false;
    3555       entry.lock          = false;
    3556       entry.owner.srcid   = 0;
    3557 #if L1_MULTI_CACHE
    3558       entry.owner.cache_id= 0;
    3559 #endif
    3560       entry.owner.inst    = false;
    3561       entry.ptr           = 0;
    3562       entry.count         = 0;
    3563       size_t set          = m_y[(addr_t)(r_write_address.read())];
    3564       size_t way          = r_write_way.read();
    3565 
    3566       m_cache_directory.write(set, way, entry);
     3522    case WRITE_BC_DIR_INVAL:    // Register a put transaction in TRT
     3523                                // and invalidate the line in directory
     3524    {
     3525        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3526        "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad DIR allocation");
     3527 
     3528        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) and
     3529        "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad TRT allocation");
     3530 
     3531        assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_WRITE) and
     3532        "MEMC ERROR in WRITE_BC_DIR_INVAL state: Bad IVT allocation");
     3533 
     3534        // register PUT request in TRT
     3535        std::vector<data_t> data_vector;
     3536        data_vector.clear();
     3537        for(size_t i=0; i<m_words; i++) data_vector.push_back(r_write_data[i].read());
     3538        m_trt.set( r_write_trt_index.read(),
     3539                   false,             // PUT request
     3540                   m_nline[(addr_t)(r_write_address.read())],
     3541                   0,                 // unused
     3542                   0,                 // unused
     3543                   0,                 // unused
     3544                   false,             // not a processor read
     3545                   0,                 // unused
     3546                   0,                 // unused
     3547                   std::vector<be_t> (m_words,0),
     3548                   data_vector );
     3549
     3550        // invalidate directory entry
     3551        DirectoryEntry entry;
     3552        entry.valid         = false;
     3553        entry.dirty         = false;
     3554        entry.tag           = 0;
     3555        entry.is_cnt        = false;
     3556        entry.lock          = false;
     3557        entry.owner.srcid   = 0;
     3558        entry.owner.inst    = false;
     3559        entry.ptr           = 0;
     3560        entry.count         = 0;
     3561        size_t set          = m_y[(addr_t)(r_write_address.read())];
     3562        size_t way          = r_write_way.read();
     3563
     3564        m_cache_directory.write(set, way, entry);
    35673565
    35683566#if DEBUG_MEMC_WRITE
    35693567if(m_debug)
    3570 std::cout << "  <MEMC " << name() << " WRITE_BC_DIR_INVAL> Invalidate the directory entry: @ = "
    3571           << r_write_address.read() << " / register the put transaction in TRT:" << std::endl;
    3572 #endif
    3573       r_write_fsm = WRITE_BC_CC_SEND;
    3574       break;
     3568std::cout << "  <MEMC " << name() << " WRITE_BC_DIR_INVAL> Inval DIR and register in TRT:"
     3569          << " address = " << r_write_address.read() << std::endl;
     3570#endif
     3571        r_write_fsm = WRITE_BC_CC_SEND;
     3572        break;
    35753573    }
    35763574
     
    35783576    case WRITE_BC_CC_SEND:    // Post a coherence broadcast request to CC_SEND FSM
    35793577    {
    3580       if(!r_write_to_cc_send_multi_req.read() and !r_write_to_cc_send_brdcast_req.read())
    3581       {
    3582         r_write_to_cc_send_multi_req   = false;
    3583         r_write_to_cc_send_brdcast_req = true;
    3584         r_write_to_cc_send_trdid       = r_write_upt_index.read();
    3585         r_write_to_cc_send_nline       = m_nline[(addr_t)(r_write_address.read())];
    3586         r_write_to_cc_send_index       = 0;
    3587         r_write_to_cc_send_count       = 0;
    3588 
    3589         for(size_t i=0; i<m_words ; i++)
    3590         {
    3591           r_write_to_cc_send_be[i]=0;
    3592           r_write_to_cc_send_data[i] = 0;
    3593         }
    3594         r_write_fsm = WRITE_BC_XRAM_REQ;
     3578        if(!r_write_to_cc_send_multi_req.read() and !r_write_to_cc_send_brdcast_req.read())
     3579        {
     3580            r_write_to_cc_send_multi_req   = false;
     3581            r_write_to_cc_send_brdcast_req = true;
     3582            r_write_to_cc_send_trdid       = r_write_upt_index.read();
     3583            r_write_to_cc_send_nline       = m_nline[(addr_t)(r_write_address.read())];
     3584            r_write_to_cc_send_index       = 0;
     3585            r_write_to_cc_send_count       = 0;
     3586
     3587            for(size_t i=0; i<m_words ; i++)  // à quoi sert ce for? (AG)
     3588            {
     3589                r_write_to_cc_send_be[i]=0;
     3590                r_write_to_cc_send_data[i] = 0;
     3591            }
     3592            r_write_fsm = WRITE_BC_XRAM_REQ;
    35953593
    35963594#if DEBUG_MEMC_WRITE
     
    35993597          << " WRITE_BC_CC_SEND> Post a broadcast request to CC_SEND FSM" << std::endl;
    36003598#endif
    3601       }
    3602       break;
     3599        }
     3600        break;
    36033601    }
    36043602
    36053603    ///////////////////////
    3606     case WRITE_BC_XRAM_REQ:   // Post a put request to IXR_CMD FSM
    3607     {
    3608       if(!r_write_to_ixr_cmd_req)
    3609       {
    3610         r_write_to_ixr_cmd_req     = true;
    3611         r_write_to_ixr_cmd_write   = true;
    3612         r_write_to_ixr_cmd_nline   = m_nline[(addr_t)(r_write_address.read())];
    3613         r_write_to_ixr_cmd_trdid   = r_write_trt_index.read();
    3614 
    3615         for(size_t i=0; i<m_words; i++) r_write_to_ixr_cmd_data[i] = r_write_data[i];
    3616 
    3617         r_write_fsm = WRITE_IDLE;
     3604    case WRITE_BC_XRAM_REQ:   // Post a PUT request to IXR_CMD FSM
     3605    {
     3606        if( not r_write_to_ixr_cmd_req.read() )
     3607        {
     3608            r_write_to_ixr_cmd_req     = true;
     3609            r_write_to_ixr_cmd_put     = true;
     3610            r_write_to_ixr_cmd_index   = r_write_trt_index.read();
     3611            r_write_fsm = WRITE_IDLE;
    36183612
    36193613#if DEBUG_MEMC_WRITE
     
    36223616          << " WRITE_BC_XRAM_REQ> Post a put request to IXR_CMD FSM" << std::endl;
    36233617#endif
    3624       }
    3625       break;
     3618        }
     3619        break;
    36263620    }
    36273621  } // end switch r_write_fsm
     
    36313625  ///////////////////////////////////////////////////////////////////////
    36323626  // The IXR_CMD fsm controls the command packets to the XRAM :
    3633   // It handles requests from the READ, WRITE, CAS, XRAM_RSP FSMs
    3634   // with a round-robin priority.
     3627  // It handles requests from 5 FSMs with a round-robin priority:
     3628  //  READ > WRITE > CAS > XRAM_RSP > CONFIG
    36353629  //
    3636   // - It sends a single flit VCI read request to the XRAM in case of MISS
    3637   // posted by the READ, WRITE or CAS FSMs : the TRDID field contains
    3638   // the Transaction Tab index.
    3639   // The VCI response is a multi-flit packet : the N cells contain
    3640   // the N data words.
     3630  // - It sends a single flit VCI read to the XRAM in case of
     3631  //   GET request posted by the READ, WRITE or CAS FSMs.
     3632  // - It sends a multi-flit VCI write in case of PUT request posted by
     3633  //   the XRAM_RSP, WRITE, CAS, or CONFIG FSMs.
    36413634  //
    3642   // - It sends a multi-flit VCI write when the XRAM_RSP FSM, WRITE FSM
    3643   // or CAS FSM request to save a dirty line to the XRAM.
    3644   // The VCI response is a single flit packet.
     3635  // For each client, there is three steps:
     3636  // - IXR_CMD_*_IDLE : round-robin allocation to a client
     3637  // - IXR_CMD_*_TRT  : access to TRT for address and data
     3638  // - IXR_CMD_*_SEND : send the PUT or GET VCI command
     3639  //
     3640  // The address and data to be written (for a PUT) are stored in TRT.
     3641  // The trdid field contains always the TRT entry index.
    36453642  ////////////////////////////////////////////////////////////////////////
     3643
     3644//std::cout << std::endl << "ixr_cmd_fsm" << std::endl;
    36463645
    36473646  switch(r_ixr_cmd_fsm.read())
    36483647  {
    3649     ////////////////////////
     3648    ///////////////////////
    36503649    case IXR_CMD_READ_IDLE:
    3651       if     (r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
    3652       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    3653       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3650      if     (r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3651      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3652      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
    36543653#if ODCCP_NON_INCLUSIVE
    3655       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
     3654      else if(r_cleanup_to_ixr_cmd_req.read())
     3655      {
     3656        r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA_SEND;
     3657        r_ixr_cmd_word = 0;
     3658      }
    36563659#else
    3657       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_TRT_LOCK;
    3658 #endif
    3659       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
     3660      else if(r_cleanup_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3661#endif
     3662      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3663      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
    36603664      break;
    36613665    ////////////////////////
    36623666    case IXR_CMD_WRITE_IDLE:
    3663       if(r_cas_to_ixr_cmd_req)           r_ixr_cmd_fsm = IXR_CMD_CAS;
    3664       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3667      if     (r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3668      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
    36653669#if ODCCP_NON_INCLUSIVE
    3666       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
     3670      else if(r_cleanup_to_ixr_cmd_req.read())
     3671      {
     3672        r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA_SEND;
     3673        r_ixr_cmd_word = 0;
     3674      }
    36673675#else
    3668       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_TRT_LOCK;
    3669 #endif
    3670       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3671       else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
     3676      else if(r_cleanup_to_ixr_cmd_req)           r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3677#endif
     3678      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3679      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3680      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
    36723681      break;
    3673     ////////////////////////
     3682    //////////////////////
    36743683    case IXR_CMD_CAS_IDLE:
    3675       if(r_xram_rsp_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3684      if     (r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
    36763685#if ODCCP_NON_INCLUSIVE
    3677       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
     3686      else if(r_cleanup_to_ixr_cmd_req.read())
     3687      {
     3688        r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA_SEND;
     3689        r_ixr_cmd_word = 0;
     3690      }
    36783691#else
    3679       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_TRT_LOCK;
    3680 #endif
    3681       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3682       else if(r_write_to_ixr_cmd_req)    r_ixr_cmd_fsm = IXR_CMD_WRITE;
    3683       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
     3692      else if(r_cleanup_to_ixr_cmd_req)           r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3693#endif
     3694      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3695      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3696      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3697      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
    36843698      break;
    3685     ////////////////////////
     3699    ///////////////////////
    36863700    case IXR_CMD_XRAM_IDLE:
    36873701#if ODCCP_NON_INCLUSIVE
    3688       if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
     3702      if(r_cleanup_to_ixr_cmd_req.read())
     3703      {
     3704        r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA_SEND;
     3705        r_ixr_cmd_word = 0;
     3706      }
    36893707#else
    3690       if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_TRT_LOCK;
    3691 #endif
    3692       else if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3693       else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE;
    3694       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    3695       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3708      if(r_cleanup_to_ixr_cmd_req)                r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3709#endif
     3710      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3711      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3712      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3713      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3714      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
    36963715      break;
    36973716      ////////////////////////
    36983717    case IXR_CMD_CLEANUP_IDLE:
    3699       if(r_read_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_READ;
    3700       else if(r_write_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_WRITE;
    3701       else if(r_cas_to_ixr_cmd_req)      r_ixr_cmd_fsm = IXR_CMD_CAS;
    3702       else if(r_xram_rsp_to_ixr_cmd_req) r_ixr_cmd_fsm = IXR_CMD_XRAM;
     3718      if(r_config_to_ixr_cmd_req.read())          r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3719      else if(r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3720      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3721      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3722      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
    37033723#if ODCCP_NON_INCLUSIVE
    3704       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
     3724      else if(r_cleanup_to_ixr_cmd_req.read())
     3725      {
     3726        r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA_SEND;
     3727        r_ixr_cmd_word = 0;
     3728      }
    37053729#else
    3706       else if(r_cleanup_to_ixr_cmd_req)     r_ixr_cmd_fsm = IXR_CMD_TRT_LOCK;
     3730      else if(r_cleanup_to_ixr_cmd_req.read())    r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
    37073731#endif
    37083732      break;     
    3709 
     3733    /////////////////////////
     3734    case IXR_CMD_CONFIG_IDLE:
     3735      if     (r_read_to_ixr_cmd_req.read())       r_ixr_cmd_fsm = IXR_CMD_READ_TRT;
     3736      else if(r_write_to_ixr_cmd_req.read())      r_ixr_cmd_fsm = IXR_CMD_WRITE_TRT;
     3737      else if(r_cas_to_ixr_cmd_req.read())        r_ixr_cmd_fsm = IXR_CMD_CAS_TRT;
     3738      else if(r_xram_rsp_to_ixr_cmd_req.read())   r_ixr_cmd_fsm = IXR_CMD_XRAM_TRT;
     3739#if ODCCP_NON_INCLUSIVE
     3740      else if(r_cleanup_to_ixr_cmd_req.read())
     3741      {
     3742        r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA_SEND;
     3743        r_ixr_cmd_word = 0;
     3744      }
     3745#else
     3746      else if(r_cleanup_to_ixr_cmd_req.read())    r_ixr_cmd_fsm = IXR_CMD_CLEANUP_TRT;
     3747#endif
     3748      else if(r_config_to_ixr_cmd_req.read())     r_ixr_cmd_fsm = IXR_CMD_CONFIG_TRT;
     3749      break;
     3750
     3751
     3752    //////////////////////
     3753    case IXR_CMD_READ_TRT:       // access TRT for a GET
     3754    {
     3755        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     3756        {
     3757            TransactionTabEntry entry = m_trt.read( r_read_to_ixr_cmd_index.read() );
     3758            r_ixr_cmd_address = entry.nline * (m_words<<2);
     3759            r_ixr_cmd_trdid   = r_read_to_ixr_cmd_index.read();
     3760            r_ixr_cmd_get     = true;
     3761            r_ixr_cmd_word    = 0;
     3762            r_ixr_cmd_fsm     = IXR_CMD_READ_SEND;
     3763            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
     3764
     3765#if DEBUG_MEMC_IXR_CMD
     3766if(m_debug)
     3767std::cout << "  <MEMC " << name() << " IXR_CMD_READ_TRT> TRT access"
     3768          << " index = " << std::dec << r_read_to_ixr_cmd_index.read()
     3769          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     3770#endif
     3771        }
     3772        break;
     3773    }
     3774    ///////////////////////
     3775    case IXR_CMD_WRITE_TRT:       // access TRT for a PUT or a GET
     3776    {
     3777        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     3778        {
     3779            TransactionTabEntry entry = m_trt.read( r_write_to_ixr_cmd_index.read() );
     3780            r_ixr_cmd_address = entry.nline * (m_words<<2);
     3781            r_ixr_cmd_trdid   = r_write_to_ixr_cmd_index.read();
     3782            r_ixr_cmd_get     = entry.xram_read;
     3783            r_ixr_cmd_word    = 0;
     3784            r_ixr_cmd_fsm     = IXR_CMD_WRITE_SEND;
     3785            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
     3786
     3787#if DEBUG_MEMC_IXR_CMD
     3788if(m_debug)
     3789std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE_TRT> TRT access"
     3790          << " index = " << std::dec << r_write_to_ixr_cmd_index.read()
     3791          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     3792#endif
     3793        }
     3794        break;
     3795    }
    37103796    /////////////////////
    3711     case IXR_CMD_TRT_LOCK:
    3712     {
    3713         TransactionTabEntry entry;
    3714        
    3715         if(r_alloc_trt_fsm.read() != ALLOC_TRT_IXR_CMD) break;
    3716         entry.copy( m_trt.read(r_cleanup_to_ixr_cmd_trdid.read()));
    3717         for(size_t i=0; i < m_words; i++)
    3718         {
    3719           r_ixr_cmd_data[i] = entry.wdata[i];
    3720         }
    3721 
    3722         r_ixr_cmd_fsm = IXR_CMD_CLEANUP_DATA;
    3723         break;
    3724     }
    3725 
    3726     //////////////////       // send a get from READ FSM
    3727     case IXR_CMD_READ:
    3728     {
    3729       if(p_vci_ixr.cmdack)
    3730       {
    3731         r_ixr_cmd_fsm = IXR_CMD_READ_IDLE;
    3732         r_read_to_ixr_cmd_req = false;
     3797    case IXR_CMD_CAS_TRT:       // access TRT for a PUT or a GET
     3798    {
     3799        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     3800        {
     3801            TransactionTabEntry entry = m_trt.read( r_cas_to_ixr_cmd_index.read() );
     3802            r_ixr_cmd_address = entry.nline * (m_words<<2);
     3803            r_ixr_cmd_trdid   = r_cas_to_ixr_cmd_index.read();
     3804            r_ixr_cmd_get     = entry.xram_read;
     3805            r_ixr_cmd_word    = 0;
     3806            r_ixr_cmd_fsm     = IXR_CMD_CAS_SEND;
     3807            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    37333808
    37343809#if DEBUG_MEMC_IXR_CMD
    37353810if(m_debug)
    3736 std::cout << "  <MEMC " << name() << " IXR_CMD_READ>"
    3737           << " Send a get request to xram / address = " << std::hex
    3738           << (addr_t)(r_read_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
    3739 #endif
    3740       }
    3741       break;
    3742     }
    3743     ///////////////////
    3744     case IXR_CMD_WRITE:     // send a put or get from WRITE FSM
    3745     {
    3746       if(p_vci_ixr.cmdack)
    3747       {
    3748         if(r_write_to_ixr_cmd_write.read())   // PUT
    3749         {
    3750           if(r_ixr_cmd_cpt.read() == (m_words - 2))
    3751           {
    3752             r_ixr_cmd_cpt = 0;
    3753             r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE;
    3754             r_write_to_ixr_cmd_req = false;
    3755           }
    3756           else
    3757           {
    3758             r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    3759           }
     3811std::cout << "  <MEMC " << name() << " IXR_CMD_CAS_TRT> TRT access"
     3812          << " index = " << std::dec << r_cas_to_ixr_cmd_index.read()
     3813          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     3814#endif
     3815        }
     3816        break;
     3817    }
     3818    //////////////////////
     3819    case IXR_CMD_XRAM_TRT:       // access TRT for a PUT
     3820    {
     3821        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     3822        {
     3823            TransactionTabEntry entry = m_trt.read( r_xram_rsp_to_ixr_cmd_index.read() );
     3824            r_ixr_cmd_address = entry.nline * (m_words<<2);
     3825            r_ixr_cmd_trdid   = r_xram_rsp_to_ixr_cmd_index.read();
     3826            r_ixr_cmd_get     = false;
     3827            r_ixr_cmd_word    = 0;
     3828            r_ixr_cmd_fsm     = IXR_CMD_XRAM_SEND;
     3829            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    37603830
    37613831#if DEBUG_MEMC_IXR_CMD
    37623832if(m_debug)
    3763 std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE>"
    3764           << " Send a put request to xram / address = " << std::hex
    3765           << (addr_t)((r_write_to_ixr_cmd_nline.read() * m_words +
    3766                       r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
    3767 #endif
    3768         }
    3769         else                                  // GET
    3770         {
    3771           r_ixr_cmd_fsm = IXR_CMD_WRITE_IDLE;
    3772           r_write_to_ixr_cmd_req = false;
     3833std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM_TRT> TRT access"
     3834          << " index = " << std::dec << r_xram_rsp_to_ixr_cmd_index.read()
     3835          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     3836#endif
     3837        }
     3838        break;
     3839    }
     3840    //////////////////////
     3841    case IXR_CMD_CLEANUP_TRT:       // access TRT for a PUT
     3842    {
     3843        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     3844        {
     3845         
     3846            TransactionTabEntry entry = m_trt.read( r_cleanup_to_ixr_cmd_index.read() );
     3847            r_ixr_cmd_address = entry.nline * (m_words<<2);
     3848            r_ixr_cmd_trdid   = r_cleanup_to_ixr_cmd_index.read();
     3849            r_ixr_cmd_get     = false;
     3850            r_ixr_cmd_word    = 0;
     3851            r_ixr_cmd_fsm     = IXR_CMD_CLEANUP_DATA_SEND;
     3852            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    37733853
    37743854#if DEBUG_MEMC_IXR_CMD
    37753855if(m_debug)
    3776 std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE>"
    3777           << " Send a get request to xram / address = " << std::hex
    3778           << (addr_t)(r_write_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
    3779 #endif
    3780         }
    3781       }
    3782       break;
    3783     }
    3784     /////////////////
    3785     case IXR_CMD_CAS:      // send a put or get command from CAS FSM
    3786     {
    3787       if(p_vci_ixr.cmdack)
    3788       {
    3789         if(r_cas_to_ixr_cmd_write.read()) // PUT
    3790         {
    3791           if(r_ixr_cmd_cpt.read() == (m_words - 2))
    3792           {
    3793             r_ixr_cmd_cpt = 0;
    3794             r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE;
    3795             r_cas_to_ixr_cmd_req = false;
    3796           }
    3797           else
    3798           {
    3799             r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    3800           }
     3856std::cout << "  <MEMC " << name() << " IXR_CMD_CLEANUP_TRT> TRT access"
     3857          << " index = " << std::dec << r_cleanup_to_ixr_cmd_index.read()
     3858          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     3859#endif
     3860        }
     3861        break;
     3862    }
     3863    ////////////////////////
     3864    case IXR_CMD_CONFIG_TRT:       // access TRT for a PUT
     3865    {
     3866        if ( r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_CMD )
     3867        {
     3868            TransactionTabEntry entry = m_trt.read( r_config_to_ixr_cmd_index.read() );
     3869            r_ixr_cmd_address = entry.nline * (m_words<<2);
     3870            r_ixr_cmd_trdid   = r_config_to_ixr_cmd_index.read();
     3871            r_ixr_cmd_get     = false;
     3872            r_ixr_cmd_word    = 0;
     3873            r_ixr_cmd_fsm     = IXR_CMD_CONFIG_SEND;
     3874            for( size_t i=0 ; i<m_words ; i++ ) r_ixr_cmd_wdata[i] = entry.wdata[i];
    38013875
    38023876#if DEBUG_MEMC_IXR_CMD
    38033877if(m_debug)
    3804 std::cout << "  <MEMC " << name() << " IXR_CMD_CAS>"
    3805           << " Send a put request to xram / address = " << std::hex
    3806           << (addr_t)( (r_cas_to_ixr_cmd_nline.read() * m_words +
    3807                       r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
    3808 #endif
    3809         }
    3810         else                            // GET
    3811         {
    3812           r_ixr_cmd_fsm = IXR_CMD_CAS_IDLE;
    3813           r_cas_to_ixr_cmd_req = false;
     3878std::cout << "  <MEMC " << name() << " IXR_CMD_CONFIG_TRT> TRT access"
     3879          << " index = " << std::dec << r_config_to_ixr_cmd_index.read()
     3880          << " / address = " << std::hex << (entry.nline*(m_words<<2)) << std::endl;
     3881#endif
     3882        }
     3883        break;
     3884    }
     3885
     3886    ///////////////////////
     3887    case IXR_CMD_READ_SEND:      // send a get from READ FSM
     3888    {
     3889        if(p_vci_ixr.cmdack)
     3890        {
     3891            r_ixr_cmd_fsm         = IXR_CMD_READ_IDLE;
     3892            r_read_to_ixr_cmd_req = false;
    38143893
    38153894#if DEBUG_MEMC_IXR_CMD
    38163895if(m_debug)
    3817 std::cout << "  <MEMC " << name() << " IXR_CMD_CAS>"
    3818           << " Send a get request to xram / address = " << std::hex
    3819           << (addr_t)(r_cas_to_ixr_cmd_nline.read()*m_words*4) << std::endl;
    3820 #endif
    3821         }
    3822       }
    3823       break;
    3824     }
    3825     //////////////////
    3826     case IXR_CMD_XRAM:     // send a put from XRAM_RSP FSM
    3827     {
    3828       if(p_vci_ixr.cmdack)
    3829       {
    3830         if(r_ixr_cmd_cpt.read() == (m_words - 2))
    3831         {
    3832           r_ixr_cmd_cpt = 0;
    3833           r_ixr_cmd_fsm = IXR_CMD_XRAM_IDLE;
    3834           r_xram_rsp_to_ixr_cmd_req = false;
    3835         }
    3836         else
    3837         {
    3838           r_ixr_cmd_cpt = r_ixr_cmd_cpt + 2;
    3839         }
     3896std::cout << "  <MEMC " << name() << " IXR_CMD_READ_SEND> GET request:" << std::hex
     3897          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     3898#endif
     3899        }
     3900        break;
     3901    }
     3902    ////////////////////////
     3903    case IXR_CMD_WRITE_SEND:     // send a put or get from WRITE FSM
     3904    {
     3905        if(p_vci_ixr.cmdack)
     3906        {
     3907            if(r_write_to_ixr_cmd_put.read())   // PUT
     3908            {
     3909                if(r_ixr_cmd_word.read() == (m_words - 2))
     3910                {
     3911                    r_ixr_cmd_fsm          = IXR_CMD_WRITE_IDLE;
     3912                    r_write_to_ixr_cmd_req = false;
     3913                }
     3914                else
     3915                {
     3916                    r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
     3917                }
    38403918
    38413919#if DEBUG_MEMC_IXR_CMD
    38423920if(m_debug)
    3843 std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM>"
    3844           << " Send a put request to xram / address = " << std::hex
    3845           << (addr_t)( (r_xram_rsp_to_ixr_cmd_nline.read() * m_words +
    3846                        r_ixr_cmd_cpt.read()) * 4 ) << std::endl;
    3847 #endif
    3848       }
    3849       break;
     3921std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE_SEND> PUT request:" << std::hex
     3922          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     3923#endif
     3924            }
     3925            else                                  // GET
     3926            {
     3927                r_ixr_cmd_fsm          = IXR_CMD_WRITE_IDLE;
     3928                r_write_to_ixr_cmd_req = false;
     3929
     3930#if DEBUG_MEMC_IXR_CMD
     3931if(m_debug)
     3932std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE_SEND> GET request:" << std::hex
     3933          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     3934#endif
     3935            }
     3936        }
     3937        break;
     3938    }
     3939    //////////////////////
     3940    case IXR_CMD_CAS_SEND:      // send a put or get command from CAS FSM
     3941    {
     3942        if(p_vci_ixr.cmdack)
     3943        {
     3944            if(r_cas_to_ixr_cmd_put.read()) // PUT
     3945            {
     3946                if(r_ixr_cmd_word.read() == (m_words - 2))
     3947                {
     3948                    r_ixr_cmd_fsm        = IXR_CMD_CAS_IDLE;
     3949                    r_cas_to_ixr_cmd_req = false;
     3950                }
     3951                else
     3952                {
     3953                    r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
     3954                }
     3955
     3956#if DEBUG_MEMC_IXR_CMD
     3957if(m_debug)
     3958std::cout << "  <MEMC " << name() << " IXR_CMD_CAS_SEND> PUT request:" << std::hex
     3959          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     3960#endif
     3961            }
     3962            else                            // GET
     3963            {
     3964                r_ixr_cmd_fsm        = IXR_CMD_CAS_IDLE;
     3965                r_cas_to_ixr_cmd_req = false;
     3966
     3967#if DEBUG_MEMC_IXR_CMD
     3968if(m_debug)
     3969std::cout << "  <MEMC " << name() << " IXR_CMD_CAS_SEND> GET request:" << std::hex
     3970          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     3971#endif
     3972            }
     3973        }
     3974        break;
     3975    }
     3976    ///////////////////////
     3977    case IXR_CMD_XRAM_SEND:     // send a put from XRAM_RSP FSM
     3978    {
     3979        if(p_vci_ixr.cmdack.read())
     3980        {
     3981            if(r_ixr_cmd_word.read() == (m_words - 2))
     3982            {
     3983                r_ixr_cmd_fsm = IXR_CMD_XRAM_IDLE;
     3984                r_xram_rsp_to_ixr_cmd_req = false;
     3985            }
     3986            else
     3987            {
     3988                r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
     3989            }
     3990#if DEBUG_MEMC_IXR_CMD
     3991if(m_debug)
     3992std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM_SEND> PUT request:" << std::hex
     3993          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     3994#endif
     3995        }
     3996        break;
    38503997    }
    38513998
    38523999      ////////////////////////
    3853     case IXR_CMD_CLEANUP_DATA:     // send a put command to XRAM
    3854       if(p_vci_ixr.cmdack)
    3855       {
    3856         if(r_ixr_cmd_cpt.read() == (m_words - 2))
    3857         {
    3858           r_ixr_cmd_cpt = 0;
     4000    case IXR_CMD_CLEANUP_DATA_SEND:     // send a put command to XRAM
     4001    {
     4002      if(p_vci_ixr.cmdack.read())
     4003      {
     4004        /*ODCCP*/ //std::cout << "IXR_CMD_CLEANUP_DATA_SEND STATE at cycle : " << std::dec << m_cpt_cycles << std::endl;
     4005        if(r_ixr_cmd_word.read() == (m_words - 2))
     4006        {
     4007          /*ODCCP*/ //std::cout << "IXR_CMD_CLEANUP_DATA_SEND GO TO IXR_CMD_CLEANUP_IDLE" << std::endl;
    38594008          r_ixr_cmd_fsm = IXR_CMD_CLEANUP_IDLE;
    38604009          r_cleanup_to_ixr_cmd_req = false;
     4010          //r_ixr_cmd_word = 0;
    38614011          //r_xram_rsp_to_ixr_cmd_inval_ncc_pending = false;
    38624012        }
    38634013        else
    38644014        {
    3865           r_ixr_cmd_cpt = r_ixr_cmd_cpt.read() + 2;
     4015          r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
    38664016        }
    38674017
     
    38694019        if(m_debug)
    38704020        {
    3871           std::cout << "  <MEMC " << name() << ".IXR_CMD_CLEANUP_DATA> Send a put request to xram" << std::endl;
     4021          std::cout << "  <MEMC " << name() << ".IXR_CMD_CLEANUP_DATA_SEND> Send a put request to xram" << std::endl;
    38724022        }
    38734023#endif
    38744024      }
    38754025      break;
    3876 
     4026    }
     4027
     4028    /////////////////////////
     4029    case IXR_CMD_CONFIG_SEND:     // send a put from CONFIG FSM
     4030    {
     4031        if(p_vci_ixr.cmdack.read())
     4032        {
     4033            if(r_ixr_cmd_word.read() == (m_words - 2))
     4034            {
     4035                r_ixr_cmd_fsm = IXR_CMD_CONFIG_IDLE;
     4036                r_config_to_ixr_cmd_req = false;
     4037            }
     4038            else
     4039            {
     4040                r_ixr_cmd_word = r_ixr_cmd_word.read() + 2;
     4041            }
     4042
     4043#if DEBUG_MEMC_IXR_CMD
     4044if(m_debug)
     4045std::cout << "  <MEMC " << name() << " IXR_CMD_CONFIG_SEND> PUT request:" << std::hex
     4046          << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4047#endif
     4048        }
     4049        break;
     4050    }
    38774051  } // end switch r_ixr_cmd_fsm
    38784052
     
    38814055  ////////////////////////////////////////////////////////////////////////////
    38824056  // The IXR_RSP FSM receives the response packets from the XRAM,
    3883   // for both put transaction, and get transaction.
     4057  // for both PUT transaction, and GET transaction.
    38844058  //
    3885   // - A response to a put request is a single-cell VCI packet.
    3886   // The Transaction Tab index is contained in the RTRDID field.
     4059  // - A response to a PUT request is a single-cell VCI packet.
     4060  // The TRT index is contained in the RTRDID field.
    38874061  // The FSM takes the lock protecting the TRT, and the corresponding
    3888   // entry is erased.
     4062  // entry is erased. If an acknowledge was required (in case of software SYNC)
     4063  // the r_config_rsp_lines counter is decremented. 
    38894064  //
    3890   // - A response to a get request is a multi-cell VCI packet.
    3891   // The Transaction Tab index is contained in the RTRDID field.
     4065  // - A response to a GET request is a multi-cell VCI packet.
     4066  // The TRT index is contained in the RTRDID field.
    38924067  // The N cells contain the N words of the cache line in the RDATA field.
    38934068  // The FSM takes the lock protecting the TRT to store the line in the TRT
    38944069  // (taking into account the write requests already stored in the TRT).
    3895   // When the line is completely written, the corresponding rok signal is set.
     4070  // When the line is completely written, the r_ixr_rsp_to_xram_rsp_rok[index] 
     4071  // signal is set to inform the XRAM_RSP FSM.
    38964072  ///////////////////////////////////////////////////////////////////////////////
     4073
     4074//std::cout << std::endl << "ixr_rsp_fsm" << std::endl;
    38974075
    38984076  switch(r_ixr_rsp_fsm.read())
    38994077  {
    3900     //////////////////
    3901     case IXR_RSP_IDLE:  // test transaction type: PUT/GET
    3902     {
    3903       if(p_vci_ixr.rspval.read())
    3904       {
    3905         r_ixr_rsp_cpt   = 0;
    3906         r_ixr_rsp_trt_index = p_vci_ixr.rtrdid.read();
    3907         if(p_vci_ixr.reop.read() and !(p_vci_ixr.rerror.read() &0x1))   // PUT transaction
    3908         {
    3909           r_ixr_rsp_fsm = IXR_RSP_ACK;
     4078      //////////////////
     4079      case IXR_RSP_IDLE:  // test transaction type: PUT/GET
     4080      {
     4081          if(p_vci_ixr.rspval.read())
     4082          {
     4083              r_ixr_rsp_cpt       = 0;
     4084              r_ixr_rsp_trt_index = p_vci_ixr.rtrdid.read();
     4085
     4086              assert( ((p_vci_ixr.rerror.read() & 0x1) == 0) and
     4087              "MEMC ERROR in IXR_RSP state: XRAM response error !");
     4088
     4089              if(p_vci_ixr.reop.read())   // PUT
     4090              {
     4091#if ODCCP_NON_INCLUSIVE
     4092                  if (p_vci_ixr.rtrdid.read() == m_trt_lines)
     4093                    r_ixr_rsp_fsm = IXR_RSP_ACK;
     4094                  else
     4095                    r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE;
     4096#else
     4097                  r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE;
     4098#endif
    39104099
    39114100#if DEBUG_MEMC_IXR_RSP
     
    39144103          << " IXR_RSP_IDLE> Response from XRAM to a put transaction" << std::endl;
    39154104#endif
    3916         }
    3917         else                                                         // GET transaction
    3918         {
    3919           r_ixr_rsp_fsm = IXR_RSP_TRT_READ;
     4105              }
     4106              else                       // GET
     4107              {
     4108                  r_ixr_rsp_fsm = IXR_RSP_TRT_READ;
    39204109
    39214110#if DEBUG_MEMC_IXR_RSP
     
    39244113          << " IXR_RSP_IDLE> Response from XRAM to a get transaction" << std::endl;
    39254114#endif
    3926         }
    3927       }
    3928       break;
    3929     }
    3930     /////////////////
    3931     case IXR_RSP_ACK:        // Aknowledge the VCI response for a PUT
    3932     {
    3933 #if ODCCP_NON_INCLUSIVE
    3934       if(p_vci_ixr.rspval.read())
    3935       {
    3936         if (r_ixr_rsp_trt_index.read() == m_trt_lines)
    3937           r_ixr_rsp_fsm = IXR_RSP_IDLE;
    3938         else
    3939           r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE;
    3940       }
    3941 #else
    3942       if(p_vci_ixr.rspval.read()) r_ixr_rsp_fsm = IXR_RSP_TRT_ERASE;
    3943 #endif
    3944 
    3945 #if DEBUG_MEMC_IXR_RSP
    3946 if(m_debug)
    3947 std::cout << "  <MEMC " << name() << " IXR_RSP_ACK>" << std::endl;
    3948 #endif
    3949       break;
    3950     }
    3951     ////////////////////////
    3952     case IXR_RSP_TRT_ERASE:   // erase the entry in the TRT
    3953     {
    3954       if(r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP)
    3955       {
    3956         m_trt.erase(r_ixr_rsp_trt_index.read());
     4115              }
     4116          }
     4117          break;
     4118      }
     4119      ////////////////////////
     4120      case IXR_RSP_ACK:     // Acknowledge PUT transaction
     4121      {
    39574122        r_ixr_rsp_fsm = IXR_RSP_IDLE;
     4123        break;
     4124      }
     4125      ////////////////////////
     4126      case IXR_RSP_TRT_ERASE:   // erase the entry in the TRT
     4127                                // decrease the line counter if config request
     4128      {
     4129          if(r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP)
     4130          {
     4131              size_t  index = r_ixr_rsp_trt_index.read();
     4132              if (m_trt.is_config(index) ) r_config_rsp_lines = r_config_rsp_lines.read() - 1;
     4133              m_trt.erase(index);
     4134              r_ixr_rsp_fsm = IXR_RSP_IDLE;
    39584135
    39594136#if DEBUG_MEMC_IXR_RSP
     
    39624139          << r_ixr_rsp_trt_index.read() << std::endl;
    39634140#endif
    3964       m_cpt_ixr_fsm_n_trt_lock++;
    3965       }
    3966 
    3967       m_cpt_ixr_fsm_trt_lock++;
    3968 
    3969       break;
    3970     }
    3971     //////////////////////
    3972     case IXR_RSP_TRT_READ:    // write a 64 bits data in the TRT
    3973     {
    3974       if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and  p_vci_ixr.rspval)
    3975       {
    3976         size_t      index    = r_ixr_rsp_trt_index.read();
    3977         bool        eop      = p_vci_ixr.reop.read();
    3978         wide_data_t data     = p_vci_ixr.rdata.read();
    3979         bool        error    = ((p_vci_ixr.rerror.read() & 0x1) == 1);
    3980 
    3981         assert(((eop == (r_ixr_rsp_cpt.read() == (m_words-2))) or p_vci_ixr.rerror.read())
    3982                and "Error in VCI_MEM_CACHE : invalid length for a response from XRAM");
    3983 
    3984         m_trt.write_rsp( index,
    3985                          r_ixr_rsp_cpt.read(),
    3986                          data,
    3987                          error);
    3988 
    3989         r_ixr_rsp_cpt = r_ixr_rsp_cpt.read() + 2;
    3990 
    3991         if(eop)
    3992         {
    3993           r_ixr_rsp_to_xram_rsp_rok[r_ixr_rsp_trt_index.read()]=true;
    3994           /*if(p_vci_ixr.rpktid.read()&0xF == 0x9)
    3995             r_ixr_rsp_to_xram_rsp_no_coherent[r_ixr_rsp_trt_index.read()] = true;
    3996           else
    3997             r_ixr_rsp_to_xram_rsp_no_coherent[r_ixr_rsp_trt_index.read()] = false;*/
    3998           r_ixr_rsp_fsm = IXR_RSP_IDLE;
    3999         }
     4141          }
     4142          break;
     4143      }
     4144      //////////////////////
     4145      case IXR_RSP_TRT_READ:    // write a 64 bits data word in TRT
     4146      {
     4147          if((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and  p_vci_ixr.rspval)
     4148          {
     4149              size_t      index    = r_ixr_rsp_trt_index.read();
     4150              size_t      word     = r_ixr_rsp_cpt.read();
     4151              bool        eop      = p_vci_ixr.reop.read();
     4152              wide_data_t data     = p_vci_ixr.rdata.read();
     4153              bool        error    = ((p_vci_ixr.rerror.read() & 0x1) == 1);
     4154
     4155              assert(((eop == (word == (m_words-2))) or error) and
     4156              "MEMC ERROR in IXR_RSP_TRT_READ state : invalid response from XRAM");
     4157
     4158              m_trt.write_rsp( index,
     4159                               word,
     4160                               data );
     4161
     4162              r_ixr_rsp_cpt = word + 2;
     4163
     4164              if(eop)
     4165              {
     4166                r_ixr_rsp_to_xram_rsp_rok[r_ixr_rsp_trt_index.read()]=true;
     4167                /*if(p_vci_ixr.rpktid.read()&0xF == 0x9)
     4168                  r_ixr_rsp_to_xram_rsp_no_coherent[r_ixr_rsp_trt_index.read()] = true;
     4169                  else
     4170                  r_ixr_rsp_to_xram_rsp_no_coherent[r_ixr_rsp_trt_index.read()] = false;*/
     4171                r_ixr_rsp_fsm = IXR_RSP_IDLE;
     4172              }
    40004173
    40014174#if DEBUG_MEMC_IXR_RSP
    40024175if(m_debug)
    4003 std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_READ> Writing a word in TRT : "
     4176std::cout << "  <MEMC " << name() << " IXR_RSP_TRT_READ> Writing 2 words in TRT : "
    40044177          << " index = " << std::dec << index
    4005           << " / word = " << r_ixr_rsp_cpt.read()
     4178          << " / word = " << word
    40064179          << " / data = " << std::hex << data << std::endl;
    40074180#endif
    4008       m_cpt_ixr_fsm_n_trt_lock++;
    4009       }
    4010       m_cpt_ixr_fsm_trt_lock++;
    4011       break;
    4012     }
     4181          }
     4182          break;
     4183      }
    40134184  } // end swich r_ixr_rsp_fsm
    40144185
     
    40164187  //                XRAM_RSP FSM
    40174188  ////////////////////////////////////////////////////////////////////////////
    4018   // The XRAM_RSP FSM handles the incoming cache lines from the XRAM.
     4189  // The XRAM_RSP FSM handles the incoming cache lines after an XRAM GET.
    40194190  // The cache line has been written in the TRT by the IXR_CMD_FSM.
    40204191  // As the IXR_RSP FSM and the XRAM_RSP FSM are running in parallel,
    4021   // there is as many flip-flops r_ixr_rsp_to_xram_rsp_rok[i]
    4022   // as the number of entries in the TRT, that are handled with
    4023   // a round-robin priority...
     4192  // there is as many flip-flops r_ixr_rsp_to_xram_rsp_rok[i] as the number
     4193  // of entries in the TRT, that are handled with a round-robin priority...
    40244194  //
    4025   // When a response is available, the corresponding TRT entry
    4026   // is copied in a local buffer to be written in the cache.
    4027   // The FSM takes the lock protecting the TRT, and the lock protecting the DIR.
    4028   // It selects a cache slot and writes the line in the cache.
     4195  // The FSM takes the lock protecting TRT, and the lock protecting DIR.
     4196  // The selected TRT entry is copied in the local buffer r_xram_rsp_trt_buf.
     4197  // It selects a cache slot and save the victim line in another local buffer
     4198  // r_xram_rsp_victim_***.
     4199  // It writes the line extracted from TRT in the cache.
    40294200  // If it was a read MISS, the XRAM_RSP FSM send a request to the TGT_RSP
    40304201  // FSM to return the cache line to the registered processor.
     
    40364207  ///////////////////////////////////////////////////////////////////////////////
    40374208
     4209//std::cout << std::endl << "xram_rsp_fsm" << std::endl;
     4210
    40384211  switch(r_xram_rsp_fsm.read())
    40394212  {
     
    40414214    case XRAM_RSP_IDLE: // scan the XRAM responses / select a TRT index (round robin)
    40424215    {
    4043       size_t ptr   = r_xram_rsp_trt_index.read();
    4044       size_t lines = m_trt_lines;
    4045      
    4046       for(size_t i=0 ; i<lines ; i++)
    4047       {
    4048         size_t index = (i+ptr+1) %lines;
    4049         if(r_ixr_rsp_to_xram_rsp_rok[index])
    4050         {
    4051           r_xram_rsp_trt_index             = index;
    4052           r_ixr_rsp_to_xram_rsp_rok[index] = false;
    4053           r_xram_rsp_fsm                   = XRAM_RSP_DIR_LOCK;
     4216        size_t old   = r_xram_rsp_trt_index.read();
     4217        size_t lines = m_trt_lines;
     4218        for(size_t i=0 ; i<lines ; i++)
     4219        {
     4220            size_t index = (i+old+1) %lines;
     4221            if(r_ixr_rsp_to_xram_rsp_rok[index])
     4222            {
     4223                r_xram_rsp_trt_index             = index;
     4224                r_ixr_rsp_to_xram_rsp_rok[index] = false;
     4225                r_xram_rsp_fsm                   = XRAM_RSP_DIR_LOCK;
    40544226
    40554227#if DEBUG_MEMC_XRAM_RSP
     
    40594231          << " index = " << std::dec << index << std::endl;
    40604232#endif
    4061           break;
    4062         }
    4063       }
    4064       break;
     4233                break;
     4234            }
     4235        }
     4236        break;
    40654237    }
    40664238    ///////////////////////
     
    40684240                            // Copy the TRT entry in a local buffer
    40694241    {
    4070       if((r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
    4071           (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP))
    4072       {
    4073         // copy the TRT entry in the r_xram_rsp_trt_buf local buffer
    4074         size_t  index = r_xram_rsp_trt_index.read();
    4075         r_xram_rsp_trt_buf.copy( m_trt.read(index) );
    4076 
    4077         r_xram_rsp_fsm = XRAM_RSP_TRT_COPY;
     4242        if( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
     4243            (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) )
     4244        {
     4245            // copy the TRT entry in the r_xram_rsp_trt_buf local buffer
     4246            size_t  index = r_xram_rsp_trt_index.read();
     4247            r_xram_rsp_trt_buf.copy( m_trt.read(index) );
     4248            r_xram_rsp_fsm = XRAM_RSP_TRT_COPY;
    40784249
    40794250#if DEBUG_MEMC_XRAM_RSP
     
    40824253          << " Get access to DIR and TRT" << std::endl;
    40834254#endif
    4084         m_cpt_xram_rsp_fsm_n_dir_lock++;
    4085         m_cpt_xram_rsp_fsm_n_trt_lock++;
    4086       }
    4087       m_cpt_xram_rsp_fsm_dir_lock++;
    4088       m_cpt_xram_rsp_fsm_trt_lock++;
    4089       break;
     4255        }
     4256        break;
    40904257    }
    40914258    ///////////////////////
     
    40934260                            // and copy it in a local buffer
    40944261    {
    4095       if ( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
    4096            (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) )
    4097       {
     4262        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
     4263        "MEMC ERROR in XRAM_RSP_TRT_COPY state: Bad DIR allocation");
     4264
     4265        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
     4266        "MEMC ERROR in XRAM_RSP_TRT_COPY state: Bad TRT allocation");
     4267
    40984268        // selects & extracts a victim line from cache
    40994269        size_t way = 0;
     
    41084278#endif
    41094279
    4110         // copy the victim line in a local buffer
     4280        // copy the victim line in a local buffer (both data dir)
    41114281        m_cache_data.read_line(way, set, r_xram_rsp_victim_data);
    41124282
    41134283        r_xram_rsp_victim_copy      = victim.owner.srcid;
    4114 
    4115 #if L1_MULTI_CACHE
    4116         r_xram_rsp_victim_copy_cache= victim.owner.cache_id;
    4117 #endif
    41184284       
    41194285        r_xram_rsp_victim_coherent  = victim.coherent;
     
    41284294        r_xram_rsp_victim_dirty     = victim.dirty;
    41294295
    4130 
    4131         if(!r_xram_rsp_trt_buf.rerror)
    4132         {
    4133 #if ODCCP_NON_INCLUSIVE
    4134           r_xram_rsp_fsm = XRAM_RSP_INVAL_LOCK;
    4135 #else
    4136           /*ODCCP*/ //if victim is no coherent and there is an inval no coherent pending we wait
    4137           /*if(!victim.coherent and r_xram_rsp_to_ixr_cmd_inval_ncc_pending.read())
    4138           {
    4139             r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    4140           }
    4141           else
    4142           {*/
    4143             r_xram_rsp_fsm = XRAM_RSP_INVAL_LOCK;
    4144          //}
    4145 #endif
    4146         }
    4147         else
    4148         {
    4149           r_xram_rsp_fsm = XRAM_RSP_ERROR_ERASE;
    4150         }
     4296        if( not r_xram_rsp_trt_buf.rerror ) r_xram_rsp_fsm = XRAM_RSP_IVT_LOCK;
     4297        else                                r_xram_rsp_fsm = XRAM_RSP_ERROR_ERASE;
    41514298
    41524299#if DEBUG_MEMC_XRAM_RSP
    41534300if(m_debug)
    41544301std::cout << "  <MEMC " << name() << " XRAM_RSP_TRT_COPY>"
    4155           << " Select a slot: "
     4302          << " Select a victim slot: "
    41564303          << " way = " << std::dec << way
    41574304          << " / set = " << set
     
    41604307          << " / inval_required = " << inval << std::endl;
    41614308#endif
    4162       }
    4163       else
    4164       {
    4165         std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_TRT_COPY"
    4166                   << " bad TRT or DIR allocation" << std::endl;
    4167         exit(0);
    4168       }
    4169       break;
    4170     }
    4171     /////////////////////////
    4172     case XRAM_RSP_INVAL_LOCK: // Take the IVT lock to check a possible pending inval
    4173     {
    4174       if(r_alloc_ivt_fsm == ALLOC_IVT_XRAM_RSP)
    4175       {
    4176         size_t index = 0;
    4177         if(m_ivt.search_inval(r_xram_rsp_trt_buf.nline, index))  // pending inval
    4178         {
    4179           r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
     4309        break;
     4310    }
     4311    ///////////////////////
     4312    case XRAM_RSP_IVT_LOCK:   // Keep DIR and TRT locks and take the IVT lock
     4313                              // to check a possible pending inval
     4314    {
     4315        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
     4316        "MEMC ERROR in XRAM_RSP_IVT_LOCK state: Bad DIR allocation");
     4317
     4318        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
     4319        "MEMC ERROR in XRAM_RSP_IVT_LOCK state: Bad TRT allocation");
     4320
     4321        if(r_alloc_ivt_fsm == ALLOC_IVT_XRAM_RSP)
     4322        {
     4323            size_t index = 0;
     4324            if(m_ivt.search_inval(r_xram_rsp_trt_buf.nline, index))  // pending inval
     4325            {
     4326                r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    41804327
    41814328#if DEBUG_MEMC_XRAM_RSP
    41824329if(m_debug)
    4183 std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
     4330std::cout << "  <MEMC " << name() << " XRAM_RSP_IVT_LOCK>"
    41844331          << " Get acces to IVT, but line invalidation registered"
    4185           << " / nline = " << std::hex << r_xram_rsp_trt_buf.nline
     4332          << " / address = " << std::hex << r_xram_rsp_trt_buf.nline*m_words*4
    41864333          << " / index = " << std::dec << index << std::endl;
    41874334#endif
    41884335
    4189         }
    4190         else if(m_ivt.is_full() and r_xram_rsp_victim_inval.read()) // IVT full
    4191         {
    4192           r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
     4336            }
     4337            else if(m_ivt.is_full() and r_xram_rsp_victim_inval.read()) // IVT full
     4338            {
     4339                r_xram_rsp_fsm = XRAM_RSP_INVAL_WAIT;
    41934340
    41944341#if DEBUG_MEMC_XRAM_RSP
    41954342if(m_debug)
    4196 std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
     4343std::cout << "  <MEMC " << name() << " XRAM_RSP_IVT_LOCK>"
    41974344          << " Get acces to IVT, but inval required and IVT full" << std::endl;
    41984345#endif
    4199         }
    4200         else
    4201         {
    4202           r_xram_rsp_fsm = XRAM_RSP_DIR_UPDT;
     4346            }
     4347            else
     4348            {
     4349                r_xram_rsp_fsm = XRAM_RSP_DIR_UPDT;
    42034350
    42044351#if DEBUG_MEMC_XRAM_RSP
    42054352if(m_debug)
    4206 std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL_LOCK>"
    4207           << " Get acces to IVT" << std::endl;
    4208 #endif
    4209         }
    4210         m_cpt_xram_rsp_fsm_n_upt_lock++;
    4211       }
    4212 
    4213       m_cpt_xram_rsp_fsm_upt_lock++;
    4214 
    4215       break;
     4353std::cout << "  <MEMC " << name() << " XRAM_RSP_IVT_LOCK>"
     4354          << " Get acces to IVT / no pending inval request" << std::endl;
     4355#endif
     4356            }
     4357        }
     4358        break;
    42164359    }
    42174360    /////////////////////////
     
    42244367          << " Release all locks and retry" << std::endl;
    42254368#endif
    4226       r_xram_rsp_fsm = XRAM_RSP_DIR_LOCK;
    4227       break;
     4369        r_xram_rsp_fsm = XRAM_RSP_DIR_LOCK;
     4370        break;
    42284371    }
    42294372    ///////////////////////
    4230     case XRAM_RSP_DIR_UPDT:   // updates the cache (both data & directory)
    4231                               // and possibly set an inval request in IVT
    4232     {
    4233       // check if this is an instruction read, this means pktid is either
    4234       // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
    4235       // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
    4236       bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) and r_xram_rsp_trt_buf.proc_read;
    4237 
    4238       // check if this is a cached read, this means pktid is either
    4239       // TYPE_READ_DATA_MISS 0bX001 with TSAR encoding
    4240       // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
    4241       bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) and r_xram_rsp_trt_buf.proc_read;
    4242 
    4243       bool dirty = false;
    4244 
    4245       // update cache data
    4246       size_t set   = r_xram_rsp_victim_set.read();
    4247       size_t way   = r_xram_rsp_victim_way.read();
    4248       for(size_t word=0; word<m_words ; word++)
    4249       {
    4250         m_cache_data.write(way, set, word, r_xram_rsp_trt_buf.wdata[word]);
    4251 
    4252         dirty = dirty or (r_xram_rsp_trt_buf.wdata_be[word] != 0);
    4253 
    4254         if(m_monitor_ok)
    4255         {
    4256           addr_t address = r_xram_rsp_trt_buf.nline<<6 | word<<2;
    4257           check_monitor( address, r_xram_rsp_trt_buf.wdata[word], false);
    4258         }
    4259       }
     4373    case XRAM_RSP_DIR_UPDT:   // updates the cache (both data & directory),
     4374                              // erases the TRT entry if victim not dirty,
     4375                              // and set inval request in IVT if required
     4376    {
     4377        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP) and
     4378        "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad DIR allocation");
     4379
     4380        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP) and
     4381        "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad TRT allocation");
     4382
     4383        assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_XRAM_RSP) and
     4384        "MEMC ERROR in XRAM_RSP_DIR_UPDT state: Bad IVT allocation");
     4385
     4386        // check if this is an instruction read, this means pktid is either
     4387        // TYPE_READ_INS_UNC   0bX010 with TSAR encoding
     4388        // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
     4389        bool inst_read = (r_xram_rsp_trt_buf.pktid & 0x2) and r_xram_rsp_trt_buf.proc_read;
     4390
     4391        // check if this is a cached read, this means pktid is either
     4392        // TYPE_READ_DATA_MISS 0bX001 with TSAR encoding
     4393        // TYPE_READ_INS_MISS  0bX011 with TSAR encoding
     4394        bool cached_read = (r_xram_rsp_trt_buf.pktid & 0x1) and r_xram_rsp_trt_buf.proc_read;
     4395
     4396        bool dirty = false;
     4397
     4398        // update cache data
     4399        size_t set   = r_xram_rsp_victim_set.read();
     4400        size_t way   = r_xram_rsp_victim_way.read();
     4401
     4402        for(size_t word=0; word<m_words ; word++)
     4403        {
     4404            m_cache_data.write(way, set, word, r_xram_rsp_trt_buf.wdata[word]);
     4405            dirty = dirty or (r_xram_rsp_trt_buf.wdata_be[word] != 0);
     4406        }
    42604407
    42614408      // update cache directory
     
    42974444      m_cache_directory.write(set, way, entry);
    42984445
    4299       // request an invalidation request in IVT for victim line
    4300       if(r_xram_rsp_victim_inval.read())
    4301       {
    4302         bool   broadcast    = r_xram_rsp_victim_is_cnt.read();
    4303         size_t index        = 0;
    4304         size_t count_copies = r_xram_rsp_victim_count.read();
     4446        // register invalid request in IVT for victim line if required
     4447        if(r_xram_rsp_victim_inval.read())
     4448        {
     4449            bool   broadcast    = r_xram_rsp_victim_is_cnt.read();
     4450            size_t index        = 0;
     4451            size_t count_copies = r_xram_rsp_victim_count.read();
    43054452       
    4306         bool   wok = m_ivt.set(false,      // it's an inval transaction
    4307                                broadcast,  // set broadcast bit
    4308                                false,      // no response required
    4309                                false,      // no acknowledge required
    4310                                0,          // srcid
    4311                                0,          // trdid
    4312                                0,          // pktid
    4313                                r_xram_rsp_victim_nline.read(),
    4314                                count_copies,
    4315                                index);
    4316 
    4317         r_xram_rsp_ivt_index = index;
    4318 
    4319         if(!wok)
    4320         {
    4321           std::cout << "VCI_MEM_CACHE ERROR " << name() << " XRAM_RSP_DIR_UPDT"
    4322                     << " invalidate_tab entry free but write unsuccessful" << std::endl;
    4323           exit(0);
    4324         }
    4325       }
     4453            bool   wok = m_ivt.set(false,      // it's an inval transaction
     4454                                   broadcast,  // set broadcast bit
     4455                                   false,      // no response required
     4456                                   false,      // no acknowledge required
     4457                                   0,          // srcid
     4458                                   0,          // trdid
     4459                                   0,          // pktid
     4460                                   r_xram_rsp_victim_nline.read(),
     4461                                   count_copies,
     4462                                   index);
     4463
     4464            r_xram_rsp_ivt_index = index;
     4465
     4466            assert( wok and
     4467            "MEMC ERROR in XRAM_RSP_DIR_UPDT state: IVT should not be full");
     4468        }
    43264469
    43274470#if DEBUG_MEMC_XRAM_RSP
     
    43374480          << " / is_cnt = " << entry.is_cnt << std::endl;
    43384481if(r_xram_rsp_victim_inval.read())
    4339 std::cout << "                           Invalidation request for victim line "
    4340           << std::hex << r_xram_rsp_victim_nline.read()
     4482std::cout << "                           Invalidation request for address "
     4483          << std::hex << r_xram_rsp_victim_nline.read()*m_words*4
    43414484          << " / broadcast = " << r_xram_rsp_victim_is_cnt.read() << std::endl;
    43424485}
     
    43674510    case XRAM_RSP_TRT_DIRTY:  // set the TRT entry (PUT to XRAM) if the victim is dirty
    43684511    {
    4369       if(r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP)
    4370       {
    4371         std::vector<data_t> data_vector;
    4372         data_vector.clear();
    4373        
    4374         for(size_t i=0; i<m_words; i++)
    4375         {
    4376           data_vector.push_back(r_xram_rsp_victim_data[i]);
    4377         }
    4378         /*m_trt.set(r_xram_rsp_trt_index.read(),
    4379                               false,       // write to XRAM
    4380                               r_xram_rsp_victim_nline.read(),  // line index
    4381                               0,
    4382                               0,
    4383                               0,
    4384                               false,
    4385                               0,
    4386                               0,
    4387                               std::vector<be_t> (m_words,0),
    4388                               std::vector<data_t> (m_words,0));*/
    4389        
    4390         m_trt.set(r_xram_rsp_trt_index.read(),
    4391                   false,       // write to XRAM
    4392                   r_xram_rsp_victim_nline.read(),  // line index
    4393                   0,
    4394                   0,
    4395                   0,
    4396                   false,
    4397                   0,
    4398                   0,
    4399                   std::vector<be_t> (m_words,0),
    4400                   data_vector);
     4512        if(r_alloc_trt_fsm.read() == ALLOC_TRT_XRAM_RSP)
     4513        {
     4514            std::vector<data_t> data_vector;
     4515            data_vector.clear();
     4516            for(size_t i=0; i<m_words; i++)
     4517            {
     4518                data_vector.push_back(r_xram_rsp_victim_data[i].read());
     4519            }
     4520            m_trt.set( r_xram_rsp_trt_index.read(),
     4521                       false,                             // PUT
     4522                       r_xram_rsp_victim_nline.read(),    // line index
     4523                       0,                                 // unused
     4524                       0,                                 // unused
     4525                       0,                                 // unused
     4526                       false,                             // not proc_read
     4527                       0,                                 // unused
     4528                       0,                                 // unused
     4529                       std::vector<be_t>(m_words,0xF),                         
     4530                       data_vector);
    44014531
    44024532#if DEBUG_MEMC_XRAM_RSP
     
    44044534std::cout << "  <MEMC " << name() << " XRAM_RSP_TRT_DIRTY>"
    44054535          << " Set TRT entry for the put transaction"
    4406           << " / dirty victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
    4407 #endif
    4408         if(r_xram_rsp_trt_buf.proc_read)         r_xram_rsp_fsm = XRAM_RSP_DIR_RSP;
    4409         else if(r_xram_rsp_victim_inval.read())  r_xram_rsp_fsm = XRAM_RSP_INVAL;
    4410         else                                     r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
    4411         m_cpt_xram_rsp_fsm_n_trt_lock++;
    4412       }
    4413 
    4414       m_cpt_xram_rsp_fsm_trt_lock++;
    4415 
    4416       break;
     4536          << " / address = " << (r_xram_rsp_victim_nline.read()*m_words*4) << std::endl;
     4537#endif
     4538            if(r_xram_rsp_trt_buf.proc_read)         r_xram_rsp_fsm = XRAM_RSP_DIR_RSP;
     4539            else if(r_xram_rsp_victim_inval.read())  r_xram_rsp_fsm = XRAM_RSP_INVAL;
     4540            else                                     r_xram_rsp_fsm = XRAM_RSP_WRITE_DIRTY;
     4541        }
     4542        break;
    44174543    }
    44184544    //////////////////////
    44194545    case XRAM_RSP_DIR_RSP:     // Request a response to TGT_RSP FSM
    44204546    {
    4421       if(!r_xram_rsp_to_tgt_rsp_req.read())
    4422       {
    4423         r_xram_rsp_to_tgt_rsp_srcid = r_xram_rsp_trt_buf.srcid;
    4424         r_xram_rsp_to_tgt_rsp_trdid = r_xram_rsp_trt_buf.trdid;
    4425         r_xram_rsp_to_tgt_rsp_pktid = r_xram_rsp_trt_buf.pktid;
    4426         for(size_t i=0; i < m_words; i++)
    4427         {
    4428             r_xram_rsp_to_tgt_rsp_data[i] = r_xram_rsp_trt_buf.wdata[i];
    4429         }
    4430         r_xram_rsp_to_tgt_rsp_word   = r_xram_rsp_trt_buf.word_index;
    4431         r_xram_rsp_to_tgt_rsp_length = r_xram_rsp_trt_buf.read_length;
    4432         r_xram_rsp_to_tgt_rsp_ll_key = r_xram_rsp_trt_buf.ll_key;
    4433         r_xram_rsp_to_tgt_rsp_rerror = false;
    4434         r_xram_rsp_to_tgt_rsp_req    = true;
     4547        if ( not r_xram_rsp_to_tgt_rsp_req.read() )
     4548        {
     4549            r_xram_rsp_to_tgt_rsp_srcid = r_xram_rsp_trt_buf.srcid;
     4550            r_xram_rsp_to_tgt_rsp_trdid = r_xram_rsp_trt_buf.trdid;
     4551            r_xram_rsp_to_tgt_rsp_pktid = r_xram_rsp_trt_buf.pktid;
     4552            for(size_t i=0; i < m_words; i++)
     4553            {
     4554                r_xram_rsp_to_tgt_rsp_data[i] = r_xram_rsp_trt_buf.wdata[i];
     4555            }
     4556            r_xram_rsp_to_tgt_rsp_word   = r_xram_rsp_trt_buf.word_index;
     4557            r_xram_rsp_to_tgt_rsp_length = r_xram_rsp_trt_buf.read_length;
     4558            r_xram_rsp_to_tgt_rsp_ll_key = r_xram_rsp_trt_buf.ll_key;
     4559            r_xram_rsp_to_tgt_rsp_rerror = false;
     4560            r_xram_rsp_to_tgt_rsp_req    = true;
    44354561
    44364562#if ODCCP_NON_INCLUSIVE
     
    44544580          << " / nwords = " << std::dec << r_xram_rsp_trt_buf.read_length << std::endl;
    44554581#endif
    4456       }
    4457       break;
     4582        }
     4583        break;
    44584584    }
    44594585    ////////////////////
     
    44734599        xram_rsp_to_cc_send_fifo_srcid     = r_xram_rsp_victim_copy.read();
    44744600        xram_rsp_to_cc_send_fifo_inst      = r_xram_rsp_victim_copy_inst.read();
    4475 #if L1_MULTI_CACHE
    4476         xram_rsp_to_cc_send_fifo_cache_id  = r_xram_rsp_victim_copy_cache.read();
    4477 #endif
    44784601        xram_rsp_to_cc_send_fifo_put       = multi_req;
    4479         r_xram_rsp_next_ptr                 = r_xram_rsp_victim_ptr.read();
     4602        r_xram_rsp_next_ptr                = r_xram_rsp_victim_ptr.read();
    44804603
    44814604#if ODCCP_NON_INCLUSIVE
     
    44944617std::cout << "  <MEMC " << name() << " XRAM_RSP_INVAL>"
    44954618          << " Send an inval request to CC_SEND FSM"
    4496           << " / victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
     4619          << " / address = " << r_xram_rsp_victim_nline.read()*m_words*4 << std::endl;
    44974620#endif
    44984621      }
     
    45064629
    45074630        r_xram_rsp_to_ixr_cmd_req = true;
    4508         r_xram_rsp_to_ixr_cmd_nline = r_xram_rsp_victim_nline.read();
    4509         r_xram_rsp_to_ixr_cmd_trdid = r_xram_rsp_trt_index.read();
    4510         for(size_t i=0; i<m_words ; i++)
    4511         {
    4512             r_xram_rsp_to_ixr_cmd_data[i] = r_xram_rsp_victim_data[i];
    4513         }
    4514         m_cpt_write_dirty++;
    4515 
     4631        //r_xram_rsp_to_ixr_cmd_nline = r_xram_rsp_victim_nline.read();
     4632        r_xram_rsp_to_ixr_cmd_index = r_xram_rsp_trt_index.read();
     4633        /*for(size_t i=0; i<m_words ; i++)
     4634        {
     4635          r_xram_rsp_to_ixr_cmd_data[i] = r_xram_rsp_victim_data[i];
     4636        }*/
    45164637#if (ODCCP_NON_INCLUSIVE == 0)
    45174638        // if victim is no coherent, we dont request a ixr command
     
    45254646#endif
    45264647
    4527         bool multi_req = !r_xram_rsp_victim_is_cnt.read() and r_xram_rsp_victim_inval.read();
     4648        m_cpt_write_dirty++;
     4649
     4650        bool multi_req = not r_xram_rsp_victim_is_cnt.read() and
     4651          r_xram_rsp_victim_inval.read();
    45284652        bool not_last_multi_req = multi_req and (r_xram_rsp_victim_count.read() != 1);
    45294653
     
    45354659std::cout << "  <MEMC " << name() << " XRAM_RSP_WRITE_DIRTY>"
    45364660          << " Send the put request to IXR_CMD FSM"
    4537           << " / victim line = " << r_xram_rsp_victim_nline.read() << std::endl;
    4538 #endif
    4539       }
    4540       break;
     4661          << " / address = " << r_xram_rsp_victim_nline.read()*m_words*4 << std::endl;
     4662#endif
     4663        }
     4664        break;
    45414665    }
    45424666    /////////////////////////
    45434667    case XRAM_RSP_HEAP_REQ:    // Get the lock to the HEAP
    45444668    {
    4545       if(r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP)
    4546       {
    4547         r_xram_rsp_fsm = XRAM_RSP_HEAP_ERASE;
    4548         m_cpt_xram_rsp_fsm_n_heap_lock++;
    4549       }
     4669        if(r_alloc_heap_fsm.read() == ALLOC_HEAP_XRAM_RSP)
     4670        {
     4671            r_xram_rsp_fsm = XRAM_RSP_HEAP_ERASE;
     4672        }
    45504673
    45514674#if DEBUG_MEMC_XRAM_RSP
     
    45544677          << " Requesting HEAP lock" << std::endl;
    45554678#endif
    4556 
    4557       m_cpt_xram_rsp_fsm_heap_lock++;
    4558 
    4559       break;
     4679        break;
    45604680    }
    45614681    /////////////////////////
     
    45674687
    45684688        xram_rsp_to_cc_send_fifo_srcid    = entry.owner.srcid;
    4569 #if L1_MULTI_CACHE
    4570         xram_rsp_to_cc_send_fifo_cache_id = entry.owner.cache_id;
    4571 #endif
    45724689        xram_rsp_to_cc_send_fifo_inst  = entry.owner.inst;
    45734690        xram_rsp_to_cc_send_fifo_put   = true;
     
    46134730      HeapEntry last_entry;
    46144731      last_entry.owner.srcid    = 0;
    4615 #if L1_MULTI_CACHE
    4616       last_entry.owner.cache_id = 0;
    4617 #endif
    46184732      last_entry.owner.inst     = false;
    46194733      if(m_heap.is_full())
     
    46394753      break;
    46404754    }
    4641     // ///////////////////////
     4755    //////////////////////////
    46424756    case XRAM_RSP_ERROR_ERASE:  // erase TRT entry in case of error
    46434757    {
     
    46924806  ////////////////////////////////////////////////////////////////////////////////////
    46934807
     4808//std::cout << std::endl << "cleanup_fsm" << std::endl;
     4809
    46944810  switch(r_cleanup_fsm.read())
    46954811  {
    4696     //////////////////
    4697     case CLEANUP_IDLE:     // Get first DSPIN flit of the CLEANUP command
    4698     {
    4699       if(not m_cc_receive_to_cleanup_fifo.rok()) break;
    4700 
    4701       uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
    4702       uint32_t srcid =
    4703         DspinDhccpParam::dspin_get(
    4704             flit,
    4705             DspinDhccpParam::CLEANUP_SRCID);
    4706 
    4707       uint8_t type =
    4708         DspinDhccpParam::dspin_get(
    4709             flit,
    4710             DspinDhccpParam::P2M_TYPE);
    4711 
    4712       r_cleanup_way_index =
    4713         DspinDhccpParam::dspin_get(
    4714             flit,
    4715             DspinDhccpParam::CLEANUP_WAY_INDEX);
    4716 
    4717       r_cleanup_nline =
    4718         DspinDhccpParam::dspin_get(
    4719             flit,
    4720             DspinDhccpParam::CLEANUP_NLINE_MSB) << 32;
    4721 
    4722       /*ODCCP*/ // Cleanup on no coherent line if 1
    4723       r_cleanup_ncc =
    4724         DspinDhccpParam::dspin_get(
    4725             flit,
    4726             DspinDhccpParam::CLEANUP_NCC);
    4727 
    4728       r_cleanup_inst  = (type == DspinDhccpParam::TYPE_CLEANUP_INST);
    4729       r_cleanup_srcid = srcid;
    4730 
    4731       if(srcid >= m_initiators)
    4732       {
    4733         std::cout
    4734             << "VCI_MEM_CACHE ERROR " << name()
    4735             << " CLEANUP_IDLE state"  << std::endl
    4736             << "illegal srcid for cleanup request" << std::endl;
    4737 
    4738         exit(0);
    4739       }
    4740 
    4741       m_cpt_cleanup++;
    4742       cc_receive_to_cleanup_fifo_get = true;
    4743       r_cleanup_fsm                  = CLEANUP_GET_NLINE;
     4812      //////////////////
     4813      case CLEANUP_IDLE:     // Get first DSPIN flit of the CLEANUP command
     4814      {
     4815          if(not m_cc_receive_to_cleanup_fifo.rok()) break;
     4816
     4817          uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
     4818          uint32_t srcid = DspinDhccpParam::dspin_get( flit,
     4819                           DspinDhccpParam::CLEANUP_SRCID);
     4820
     4821          uint8_t type = DspinDhccpParam::dspin_get( flit,
     4822                         DspinDhccpParam::P2M_TYPE);
     4823
     4824          r_cleanup_way_index = DspinDhccpParam::dspin_get( flit,
     4825                                DspinDhccpParam::CLEANUP_WAY_INDEX);
     4826
     4827          r_cleanup_nline = DspinDhccpParam::dspin_get( flit,
     4828                            DspinDhccpParam::CLEANUP_NLINE_MSB) << 32;
     4829
     4830          /*ODCCP*/ // Cleanup on no coherent line if 1
     4831          r_cleanup_ncc =
     4832            DspinDhccpParam::dspin_get(
     4833                flit,
     4834                DspinDhccpParam::CLEANUP_NCC);
     4835
     4836          r_cleanup_inst  = (type == DspinDhccpParam::TYPE_CLEANUP_INST);
     4837          r_cleanup_srcid = srcid;
     4838
     4839          assert( (srcid < m_initiators) and
     4840          "MEMC ERROR in CLEANUP_IDLE state : illegal SRCID value");
     4841
     4842          m_cpt_cleanup++;
     4843          cc_receive_to_cleanup_fifo_get = true;
     4844          r_cleanup_fsm                  = CLEANUP_GET_NLINE;
    47444845
    47454846#if DEBUG_MEMC_CLEANUP
     
    47474848std::cout << "  <MEMC "         << name()
    47484849          << " CLEANUP_IDLE> Cleanup request:" << std::hex
    4749           << " / owner_id = "   << srcid
     4850          << " owner_id = "   << srcid
    47504851          << " / owner_ins = "  << (type == DspinDhccpParam::TYPE_CLEANUP_INST) << std::endl;
    47514852#endif
    4752       break;
    4753     }
    4754 
    4755     ///////////////////////
    4756     case CLEANUP_GET_NLINE:  // GET second DSPIN flit of the cleanup command
    4757     {
    4758       if(not m_cc_receive_to_cleanup_fifo.rok()) break;
     4853          break;
     4854      }
     4855      ///////////////////////
     4856      case CLEANUP_GET_NLINE:  // GET second DSPIN flit of the cleanup command
     4857      {
     4858          if(not m_cc_receive_to_cleanup_fifo.rok()) break;
     4859
     4860          uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
    47594861     
    47604862
    4761       uint64_t flit = m_cc_receive_to_cleanup_fifo.read();
    4762 
    4763       addr_t nline = r_cleanup_nline.read() |
    4764         DspinDhccpParam::dspin_get(flit, DspinDhccpParam::CLEANUP_NLINE_LSB);
     4863          addr_t nline = r_cleanup_nline.read() |
     4864              DspinDhccpParam::dspin_get(flit, DspinDhccpParam::CLEANUP_NLINE_LSB);
     4865
     4866          cc_receive_to_cleanup_fifo_get = true;
     4867          r_cleanup_nline                = nline;
     4868          r_cleanup_fsm                  = CLEANUP_DIR_REQ;
    47654869     
    47664870      bool eop = DspinDhccpParam::dspin_get(flit, DspinDhccpParam::P2M_EOP);
     
    47894893          << " / address = " << std::hex << nline * m_words * 4 << std::endl;
    47904894#endif
    4791       break;
    4792     }
    4793 
     4895          break;
     4896      }
     4897      /////////////////////
    47944898    /*ODCCP*/ // We save the cleanup's data into a buffer
    47954899    case CLEANUP_GET_DATA :
     
    48184922    case CLEANUP_DIR_REQ:   // Get the lock to the directory
    48194923    {
    4820       m_cpt_cleanup_fsm_dir_lock++;
    48214924      // Get the lock to the directory
    48224925      if(r_alloc_dir_fsm.read() != ALLOC_DIR_CLEANUP) break;
    4823 
    4824       r_cleanup_fsm = CLEANUP_DIR_LOCK;
     4926          r_cleanup_fsm = CLEANUP_DIR_LOCK;
    48254927
    48264928#if DEBUG_MEMC_CLEANUP
     
    48284930std::cout << "  <MEMC " << name() << " CLEANUP_DIR_REQ> Requesting DIR lock" << std::endl;
    48294931#endif
    4830 
    4831       m_cpt_cleanup_fsm_n_dir_lock++;
     4932          break;
     4933      }
     4934      //////////////////////
     4935      case CLEANUP_DIR_LOCK:    // test directory status
     4936      {
     4937          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CLEANUP) and
     4938          "MEMC ERROR in CLEANUP_DIR_LOCK: bad DIR allocation");
     4939
     4940          // Read the directory
     4941          size_t way = 0;
     4942          addr_t cleanup_address = r_cleanup_nline.read() * m_words * 4;
     4943          DirectoryEntry entry   = m_cache_directory.read(cleanup_address , way);
     4944          r_cleanup_is_cnt       = entry.is_cnt;
     4945          r_cleanup_dirty        = entry.dirty;
     4946          r_cleanup_tag          = entry.tag;
     4947          r_cleanup_lock         = entry.lock;
     4948          r_cleanup_way          = way;
     4949          r_cleanup_count        = entry.count;
     4950          r_cleanup_ptr          = entry.ptr;
     4951          r_cleanup_copy         = entry.owner.srcid;
     4952          r_cleanup_copy_inst    = entry.owner.inst;
     4953          if(entry.valid)      // hit : the copy must be cleared
     4954          {
     4955              assert( (entry.count > 0) and
     4956              "MEMC ERROR in CLEANUP_DIR_LOCK state, CLEANUP on valid entry with no copies");
     4957
     4958              if((entry.count == 1) or (entry.is_cnt))   // no access to the heap
     4959              {
     4960                  r_cleanup_fsm = CLEANUP_DIR_WRITE;
     4961              }
     4962              else                                       // access to the heap
     4963              {
     4964                  r_cleanup_fsm = CLEANUP_HEAP_REQ;
     4965              }
     4966          }
     4967          else                // miss : check IVT for a pending inval
     4968          {
     4969              r_cleanup_fsm = CLEANUP_IVT_LOCK;
     4970          }
     4971
     4972#if DEBUG_MEMC_CLEANUP
     4973if(m_debug)
     4974std::cout << "  <MEMC " << name()
     4975          << " CLEANUP_DIR_LOCK> Test directory status: "
     4976          << std::hex << " address = " << cleanup_address
     4977          << " / hit = "        << entry.valid
     4978          << " / dir_id = "     << entry.owner.srcid
     4979          << " / dir_ins = "    << entry.owner.inst
     4980          << " / search_id = "  << r_cleanup_srcid.read()
     4981          << " / search_ins = " << r_cleanup_inst.read()
     4982          << " / count = "      << entry.count
     4983          << " / is_cnt = "     << entry.is_cnt << std::endl;
     4984#endif
     4985          break;
     4986      }
     4987      ///////////////////////
     4988      case CLEANUP_DIR_WRITE:      // Update the directory entry without heap access
     4989      {
     4990          assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CLEANUP) and
     4991          "MEMC ERROR in CLEANUP_DIR_LOCK: bad DIR allocation");
     4992
     4993          size_t way         = r_cleanup_way.read();
     4994          size_t set         = m_y[(addr_t)(r_cleanup_nline.read()*m_words*4)];
     4995          bool   match_srcid = (r_cleanup_copy.read() == r_cleanup_srcid.read());
     4996          bool   match_inst  = (r_cleanup_copy_inst.read() == r_cleanup_inst.read());
     4997          bool   match       = match_srcid and match_inst;
     4998
     4999          assert( (r_cleanup_is_cnt.read() or match) and
     5000          "MEMC ERROR in CLEANUP_DIR_LOCK: illegal CLEANUP on valid entry");
     5001
     5002          // update the cache directory (for the copies)
     5003          DirectoryEntry entry;
     5004          entry.valid       = true;
     5005          entry.is_cnt      = r_cleanup_is_cnt.read();
     5006          entry.dirty       = r_cleanup_dirty.read() or r_cleanup_contains_data.read();
     5007          entry.tag         = r_cleanup_tag.read();
     5008          entry.lock        = r_cleanup_lock.read();
     5009          entry.ptr         = r_cleanup_ptr.read();
     5010          entry.count       = r_cleanup_count.read() - 1;
     5011          entry.owner.srcid = 0;
     5012          entry.owner.inst  = 0;
     5013          /*ODCCP*/ // if cleanup contains data we update the cache data
     5014          if (r_cleanup_contains_data.read())
     5015          {
     5016            for (size_t word = 0; word < m_words; word ++)
     5017            {
     5018              m_cache_data.write(way, set, word, r_cleanup_data[word].read(), 0xF);
     5019            }
     5020          }
     5021
     5022
     5023          m_cache_directory.write(set, way, entry);
     5024
     5025          r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5026
     5027#if DEBUG_MEMC_CLEANUP
     5028if(m_debug)
     5029std::cout << "  <MEMC " << name()
     5030          << " CLEANUP_DIR_WRITE> Update directory:"
     5031          << std::hex << " address = "   << r_cleanup_nline.read() * m_words * 4
     5032          << " / dir_id = "  << entry.owner.srcid
     5033          << " / dir_ins = " << entry.owner.inst
     5034          << " / count = "   << entry.count
     5035          << " / is_cnt = "  << entry.is_cnt << std::endl;
     5036#endif
    48325037
    48335038      break;
    48345039    }
    48355040
    4836     //////////////////////
    4837     case CLEANUP_DIR_LOCK:
    4838     {
    4839       // test directory status
    4840       if(r_alloc_dir_fsm.read() != ALLOC_DIR_CLEANUP)
    4841       {
    4842         std::cout
    4843             << "VCI_MEM_CACHE ERROR " << name()
    4844             << " CLEANUP_DIR_LOCK state"
    4845             << " bad DIR allocation" << std::endl;
    4846 
    4847         exit(0);
    4848       }
    4849       // Read the directory
    4850       size_t way = 0;
    4851       addr_t cleanup_address = r_cleanup_nline.read() * m_words * 4;
    4852 
    4853       DirectoryEntry entry   = m_cache_directory.read(cleanup_address , way);
    4854       r_cleanup_is_cnt       = entry.is_cnt;
    4855       r_cleanup_dirty        = entry.dirty;
    4856       r_cleanup_tag          = entry.tag;
    4857       r_cleanup_lock         = entry.lock;
    4858       r_cleanup_way          = way;
    4859       r_cleanup_count        = entry.count;
    4860       r_cleanup_ptr          = entry.ptr;
    4861       r_cleanup_copy         = entry.owner.srcid;
    4862       r_cleanup_copy_inst    = entry.owner.inst;
    4863 #if L1_MULTI_CACHE
    4864       r_cleanup_copy_cache   = entry.owner.cache_id;
    4865 #endif
    4866 
    4867       if(entry.valid)      // hit : the copy must be cleared
    4868       {
    4869         if(entry.count < 1)
    4870         {
    4871           std::cout << "assert on line " << std::hex <<r_cleanup_nline.read() << " | at cycle " << std::dec <<m_cpt_cycles << std::endl;
    4872           std::cout << "cleanup with data ? " << r_cleanup_contains_data.read() << " | at cycle " << m_cpt_cycles << std::endl;
    4873           std::cout << "cleanup_address = " << std::hex << (r_cleanup_nline.read()*m_words*4) << std::dec << std::endl;
    4874           std::cout << "srcid = " << r_cleanup_srcid.read() << std::endl;
    4875           std::cout << "inst = " << r_cleanup_inst.read() << std::endl;
    4876           std::cout << "inst = " << r_cleanup_inst.read() << std::endl;
    4877         }
    4878         assert(
    4879             (entry.count > 0) and
    4880             "VCI MEM CACHE ERROR: "
    4881             "In CLEANUP_DIR_LOCK, CLEANUP command on a valid entry "
    4882             "with no copies");
    4883 
    4884         // no access to the heap
    4885         if((entry.count == 1) or (entry.is_cnt))
    4886         {
    4887           r_cleanup_fsm = CLEANUP_DIR_WRITE;
    4888         }
    4889         // access to the heap
    4890         else
    4891         {
    4892           r_cleanup_fsm = CLEANUP_HEAP_REQ;
    4893         }
    4894       }
    4895       else                // miss : check UPT for a pending invalidation transaction
    4896       {
    4897         r_cleanup_fsm = CLEANUP_IVT_LOCK;
    4898       }
     5041      //////////////////////
     5042      case CLEANUP_HEAP_REQ:         // get the lock to the HEAP directory
     5043      {
     5044          if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP) break;
     5045
     5046          r_cleanup_fsm = CLEANUP_HEAP_LOCK;
    48995047
    49005048#if DEBUG_MEMC_CLEANUP
    4901       if(m_debug)
    4902       {
    4903         std::cout
    4904             << "  <MEMC " << name()
    4905             << " CLEANUP_DIR_LOCK> Test directory status: "
    4906             << std::hex
    4907             << " line = "         << cleanup_address
    4908             << " / hit = "        << entry.valid
    4909             << " / dir_id = "     << entry.owner.srcid
    4910             << " / dir_ins = "    << entry.owner.inst
    4911             << " / search_id = "  << r_cleanup_srcid.read()
    4912             << " / search_ins = " << r_cleanup_inst.read()
    4913             << " / count = "      << entry.count
    4914             << " / is_cnt = "     << entry.is_cnt
    4915             << std::endl;
    4916       }
    4917 #endif
    4918       break;
    4919     }
    4920 
    4921     ///////////////////////
    4922     case CLEANUP_DIR_WRITE:
    4923     {
    4924       // Update the directory entry without heap access
    4925       if(r_alloc_dir_fsm.read() != ALLOC_DIR_CLEANUP)
    4926       {
    4927         std::cout
    4928             << "VCI_MEM_CACHE ERROR " << name()
    4929             << " CLEANUP_DIR_WRITE state"
    4930             << " bad DIR allocation" << std::endl;
    4931 
    4932         exit(0);
    4933       }
    4934 
    4935       size_t way         = r_cleanup_way.read();
    4936       size_t set         = m_y[(addr_t)(r_cleanup_nline.read()*m_words*4)];
    4937       bool   match_srcid = (r_cleanup_copy.read() == r_cleanup_srcid.read());
    4938 
    4939 #if L1_MULTI_CACHE
    4940       match_srcid       &= (r_cleanup_copy_cache.read() == r_cleanup_pktid.read());
    4941 #endif
    4942 
    4943       bool   match_inst  = (r_cleanup_copy_inst.read() == r_cleanup_inst.read());
    4944       bool   match       = match_srcid and match_inst;
    4945 
    4946       if(not r_cleanup_is_cnt.read() and not match)
    4947       {
    4948         std::cout
    4949             << "VCI_MEM_CACHE ERROR : Cleanup request on a valid"
    4950             << "entry using linked list mode with no corresponding"
    4951             << "directory or heap entry"
    4952             << std::endl;
    4953 
    4954         exit(1);
    4955       }
    4956 
    4957       // update the cache directory (for the copies)
    4958       DirectoryEntry entry;
    4959       entry.valid       = true;
    4960       entry.is_cnt      = r_cleanup_is_cnt.read();
    4961       entry.dirty       = r_cleanup_dirty.read() or r_cleanup_contains_data.read();
    4962       entry.tag         = r_cleanup_tag.read();
    4963       entry.lock        = r_cleanup_lock.read();
    4964       entry.ptr         = r_cleanup_ptr.read();
    4965       entry.count       = r_cleanup_count.read() - 1;
    4966       entry.owner.srcid = 0;
    4967       entry.owner.inst  = 0;
    4968 
    4969 #if L1_MULTI_CACHE
    4970       entry.owner.cache_id = 0;
    4971 #endif
    4972       /*ODCCP*/ // if cleanup contains data we update the cache data
    4973       if (r_cleanup_contains_data.read())
    4974       {
    4975         for (size_t word = 0; word < m_words; word ++)
    4976         {
    4977           m_cache_data.write(way, set, word, r_cleanup_data[word].read(), 0xF);
    4978         }
    4979       }
    4980 
    4981 
    4982       m_cache_directory.write(set, way, entry);
    4983 
    4984       r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5049if(m_debug)
     5050std::cout << "  <MEMC " << name()
     5051          << " CLEANUP_HEAP_REQ> HEAP lock acquired " << std::endl;
     5052#endif
     5053          break;
     5054      }
     5055      //////////////////////
     5056      case CLEANUP_HEAP_LOCK:      // two cases are handled in this state :
     5057                                 // 1. the matching copy is directly in the directory
     5058                                 // 2. the matching copy is the first copy in the heap
     5059      {
     5060          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and
     5061          "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation");
     5062
     5063          size_t way            = r_cleanup_way.read();
     5064          size_t set            = m_y[(addr_t)(r_cleanup_nline.read() *m_words*4)];
     5065
     5066          HeapEntry heap_entry  = m_heap.read(r_cleanup_ptr.read());
     5067          bool last             = (heap_entry.next == r_cleanup_ptr.read());
     5068
     5069          // match_dir computation
     5070          bool match_dir_srcid  = (r_cleanup_copy.read()      == r_cleanup_srcid.read());
     5071          bool match_dir_inst   = (r_cleanup_copy_inst.read() == r_cleanup_inst.read());
     5072          bool match_dir        = match_dir_srcid  and match_dir_inst;
     5073
     5074          // match_heap computation
     5075          bool match_heap_srcid = (heap_entry.owner.srcid == r_cleanup_srcid.read());
     5076          bool match_heap_inst  = (heap_entry.owner.inst  == r_cleanup_inst.read());
     5077          bool match_heap       = match_heap_srcid and match_heap_inst;
     5078
     5079          r_cleanup_prev_ptr    = r_cleanup_ptr.read();
     5080          r_cleanup_prev_srcid  = heap_entry.owner.srcid;
     5081          r_cleanup_prev_inst   = heap_entry.owner.inst;
     5082
     5083          assert( (not last or match_dir or match_heap) and
     5084          "MEMC ERROR in CLEANUP_HEAP_LOCK state: hit but no copy found");
     5085
     5086          assert( (not match_dir or not match_heap) and
     5087          "MEMC ERROR in CLEANUP_HEAP_LOCK state: two matching copies found");
     5088
     5089          DirectoryEntry dir_entry;
     5090          dir_entry.valid          = true;
     5091          dir_entry.is_cnt         = r_cleanup_is_cnt.read();
     5092          dir_entry.dirty          = r_cleanup_dirty.read();
     5093          dir_entry.tag            = r_cleanup_tag.read();
     5094          dir_entry.lock           = r_cleanup_lock.read();
     5095          dir_entry.count          = r_cleanup_count.read()-1;
     5096
     5097          // the matching copy is registered in the directory and
     5098          // it must be replaced by the first copy registered in
     5099          // the heap. The corresponding entry must be freed
     5100          if(match_dir)
     5101          {
     5102              dir_entry.ptr            = heap_entry.next;
     5103              dir_entry.owner.srcid    = heap_entry.owner.srcid;
     5104              dir_entry.owner.inst     = heap_entry.owner.inst;
     5105              r_cleanup_next_ptr       = r_cleanup_ptr.read();
     5106              r_cleanup_fsm            = CLEANUP_HEAP_FREE;
     5107          }
     5108
     5109          // the matching copy is the first copy in the heap
     5110          // It must be freed and the copy registered in directory
     5111          // must point to the next copy in heap
     5112          else if(match_heap)
     5113          {
     5114              dir_entry.ptr            = heap_entry.next;
     5115              dir_entry.owner.srcid    = r_cleanup_copy.read();
     5116              dir_entry.owner.inst     = r_cleanup_copy_inst.read();
     5117              r_cleanup_next_ptr       = r_cleanup_ptr.read();
     5118              r_cleanup_fsm            = CLEANUP_HEAP_FREE;
     5119          }
     5120
     5121          // The matching copy is in the heap, but is not the first copy
     5122          // The directory entry must be modified to decrement count
     5123          else
     5124          {
     5125              dir_entry.ptr            = r_cleanup_ptr.read();
     5126              dir_entry.owner.srcid    = r_cleanup_copy.read();
     5127              dir_entry.owner.inst     = r_cleanup_copy_inst.read();
     5128              r_cleanup_next_ptr       = heap_entry.next;
     5129              r_cleanup_fsm            = CLEANUP_HEAP_SEARCH;
     5130          }
     5131
     5132          m_cache_directory.write(set,way,dir_entry);
    49855133
    49865134#if DEBUG_MEMC_CLEANUP
    4987       if(m_debug)
    4988       {
    4989         std::cout
    4990             << "  <MEMC " << name()
    4991             << " CLEANUP_DIR_WRITE> Update directory:"
    4992             << std::hex
    4993             << " address = "   << r_cleanup_nline.read() * m_words * 4
    4994             << " / dir_id = "  << entry.owner.srcid
    4995             << " / dir_ins = " << entry.owner.inst
    4996             << " / count = "   << entry.count
    4997             << " / is_cnt = "  << entry.is_cnt
    4998             << std::endl;
    4999       }
    5000 #endif
    5001 
    5002       break;
    5003     }
    5004 
    5005     //////////////////////
    5006     case CLEANUP_HEAP_REQ:
    5007     {
    5008       // get the lock to the HEAP directory
    5009       m_cpt_cleanup_fsm_heap_lock++;
    5010       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP) break;
    5011 
    5012       r_cleanup_fsm = CLEANUP_HEAP_LOCK;
     5135if(m_debug)
     5136std::cout << "  <MEMC " << name()
     5137          << " CLEANUP_HEAP_LOCK> Checks matching:"
     5138          << " address = "      << r_cleanup_nline.read() * m_words * 4
     5139          << " / dir_id = "     << r_cleanup_copy.read()
     5140          << " / dir_ins = "    << r_cleanup_copy_inst.read()
     5141          << " / heap_id = "    << heap_entry.owner.srcid
     5142          << " / heap_ins = "   << heap_entry.owner.inst
     5143          << " / search_id = "  << r_cleanup_srcid.read()
     5144          << " / search_ins = " << r_cleanup_inst.read() << std::endl;
     5145#endif
     5146          break;
     5147      }
     5148      ////////////////////////
     5149      case CLEANUP_HEAP_SEARCH:     // This state is handling the case where the copy
     5150                                    // is in the heap, but not the first in linked list
     5151      {
     5152          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and
     5153          "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation");
     5154
     5155          HeapEntry heap_entry  = m_heap.read(r_cleanup_next_ptr.read());
     5156
     5157          bool last             = (heap_entry.next        == r_cleanup_next_ptr.read());
     5158          bool match_heap_srcid = (heap_entry.owner.srcid == r_cleanup_srcid.read());
     5159          bool match_heap_inst  = (heap_entry.owner.inst  == r_cleanup_inst.read());
     5160          bool match_heap       = match_heap_srcid and match_heap_inst;
     5161
     5162          assert( (not last or match_heap) and
     5163          "MEMC ERROR in CLEANUP_HEAP_SEARCH state: no copy found");
     5164
     5165          // the matching copy must be removed
     5166          if(match_heap)
     5167          {
     5168              // re-use ressources
     5169              r_cleanup_ptr = heap_entry.next;
     5170              r_cleanup_fsm = CLEANUP_HEAP_CLEAN;
     5171          }
     5172          // test the next in the linked list
     5173          else
     5174          {
     5175              r_cleanup_prev_ptr      = r_cleanup_next_ptr.read();
     5176              r_cleanup_prev_srcid    = heap_entry.owner.srcid;
     5177              r_cleanup_prev_inst     = heap_entry.owner.inst;
     5178              r_cleanup_next_ptr      = heap_entry.next;
     5179              r_cleanup_fsm           = CLEANUP_HEAP_SEARCH;
     5180          }
    50135181
    50145182#if DEBUG_MEMC_CLEANUP
    5015       if(m_debug)
    5016       {
    5017         std::cout
    5018             << "  <MEMC " << name()
    5019             << " CLEANUP_HEAP_REQ> HEAP lock acquired "
    5020             << std::endl;
    5021       }
    5022 #endif
    5023       m_cpt_cleanup_fsm_n_heap_lock++;
    5024       break;
    5025     }
    5026 
    5027     //////////////////////
    5028     case CLEANUP_HEAP_LOCK:
    5029     {
    5030       // two cases are handled in this state :
    5031       // 1. the matching copy is directly in the directory
    5032       // 2. the matching copy is the first copy in the heap
    5033       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    5034       {
    5035         std::cout
    5036             << "VCI_MEM_CACHE ERROR " << name()
    5037             << " CLEANUP_HEAP_LOCK state"
    5038             << " bad HEAP allocation" << std::endl;
    5039 
    5040         exit(0);
    5041       }
    5042 
    5043       size_t way            = r_cleanup_way.read();
    5044       size_t set            = m_y[(addr_t)(r_cleanup_nline.read() *m_words*4)];
    5045 
    5046       HeapEntry heap_entry  = m_heap.read(r_cleanup_ptr.read());
    5047       bool last             = (heap_entry.next == r_cleanup_ptr.read());
    5048 
    5049       // match_dir computation
    5050       bool match_dir_srcid  = (r_cleanup_copy.read()      == r_cleanup_srcid.read());
    5051       bool match_dir_inst   = (r_cleanup_copy_inst.read() == r_cleanup_inst.read());
    5052       bool match_dir        = match_dir_srcid  and match_dir_inst;
    5053 
    5054       // match_heap computation
    5055       bool match_heap_srcid = (heap_entry.owner.srcid == r_cleanup_srcid.read());
    5056       bool match_heap_inst  = (heap_entry.owner.inst  == r_cleanup_inst.read());
    5057       bool match_heap       = match_heap_srcid and match_heap_inst;
    5058 
    5059       r_cleanup_prev_ptr    = r_cleanup_ptr.read();
    5060       r_cleanup_prev_srcid  = heap_entry.owner.srcid;
    5061       r_cleanup_prev_inst   = heap_entry.owner.inst;
    5062 
    5063 #if L1_MULTI_CACHE
    5064       match_dir  = match_dir  and(r_cleanup_copy_cache.read() == r_cleanup_pktid.read());
    5065       match_heap = match_heap and(heap_entry.owner.cache_id   == r_cleanup_pktid.read());
    5066       r_cleanup_prev_cache_id = heap_entry.owner.cache_id;
    5067 #endif
    5068 
    5069       if(not match_dir and not match_heap and last)
    5070       {
    5071         std::cout
    5072             << "VCI_MEM_CACHE ERROR " << name()
    5073             << " CLEANUP_HEAP_LOCK state"
    5074             << " hit but copy not found"
    5075             << std::endl;
    5076 /**/
    5077         std::cout
    5078           << "r_cleanup_srcid = " << r_cleanup_srcid.read()
    5079           << " / r_cleanup_inst = " << r_cleanup_inst.read() << std::endl
    5080           << "r_cleanup_copy = " << r_cleanup_copy.read()
    5081           << " / r_cleanup_copy_inst = " << r_cleanup_copy_inst.read() << std::endl
    5082           << "heap_entry.owner.srcid = " << heap_entry.owner.srcid
    5083           << " / heap_entry.owner.inst = " << heap_entry.owner.inst << std::endl;
    5084 /**/
    5085         exit(0);
    5086       }
    5087 
    5088       if(match_dir and match_heap)
    5089       {
    5090         std::cout
    5091             << "VCI_MEM_CACHE ERROR " << name()
    5092             << " CLEANUP_HEAP_LOCK state"
    5093             << " two copies matching the cleanup owner id"
    5094             << std::endl;
    5095 /**/
    5096         std::cout
    5097           << "r_cleanup_srcid = " << r_cleanup_srcid.read()
    5098           << " / r_cleanup_inst = " << r_cleanup_inst.read() << std::endl
    5099           << "r_cleanup_copy = " << r_cleanup_copy.read()
    5100           << " / r_cleanup_copy_inst = " << r_cleanup_copy_inst.read() << std::endl
    5101           << "heap_entry.owner.srcid = " << heap_entry.owner.srcid
    5102           << " / heap_entry.owner.inst = " << heap_entry.owner.inst << std::endl
    5103           << " / addr = " << std::hex << (r_cleanup_nline.read() *m_words*4) << std::dec << std::endl;
    5104 /**/
    5105 
    5106         exit(0);
    5107       }
    5108 
    5109       DirectoryEntry dir_entry;
    5110       dir_entry.valid          = true;
    5111       dir_entry.is_cnt         = r_cleanup_is_cnt.read();
    5112       dir_entry.dirty          = r_cleanup_dirty.read();
    5113       dir_entry.tag            = r_cleanup_tag.read();
    5114       dir_entry.lock           = r_cleanup_lock.read();
    5115       dir_entry.count          = r_cleanup_count.read()-1;
    5116 
    5117       // the matching copy is registered in the directory and
    5118       // it must be replaced by the first copy registered in
    5119       // the heap. The corresponding entry must be freed
    5120       if(match_dir)
    5121       {
    5122         dir_entry.ptr            = heap_entry.next;
    5123         dir_entry.owner.srcid    = heap_entry.owner.srcid;
    5124         dir_entry.owner.inst     = heap_entry.owner.inst;
    5125 
    5126 #if L1_MULTI_CACHE
    5127         dir_entry.owner.cache_id = heap_entry.owner.cache_id;
    5128 #endif
    5129 
    5130         r_cleanup_next_ptr       = r_cleanup_ptr.read();
    5131         r_cleanup_fsm            = CLEANUP_HEAP_FREE;
    5132       }
    5133 
    5134       // the matching copy is the first copy in the heap
    5135       // It must be freed and the copy registered in directory
    5136       // must point to the next copy in heap
    5137       else if(match_heap)
    5138       {
    5139         dir_entry.ptr            = heap_entry.next;
    5140         dir_entry.owner.srcid    = r_cleanup_copy.read();
    5141         dir_entry.owner.inst     = r_cleanup_copy_inst.read();
    5142 
    5143 #if L1_MULTI_CACHE
    5144         dir_entry.owner.cache_id = r_cleanup_copy_cache.read();
    5145 #endif
    5146 
    5147         r_cleanup_next_ptr       = r_cleanup_ptr.read();
    5148         r_cleanup_fsm            = CLEANUP_HEAP_FREE;
    5149       }
    5150 
    5151       // The matching copy is in the heap, but is not the first copy
    5152       // The directory entry must be modified to decrement count
    5153       else
    5154       {
    5155         dir_entry.ptr            = r_cleanup_ptr.read();
    5156         dir_entry.owner.srcid    = r_cleanup_copy.read();
    5157         dir_entry.owner.inst     = r_cleanup_copy_inst.read();
    5158 
    5159 #if L1_MULTI_CACHE
    5160         dir_entry.owner.cache_id = r_cleanup_copy_cache.read();
    5161 #endif
    5162 
    5163         r_cleanup_next_ptr       = heap_entry.next;
    5164         r_cleanup_fsm            = CLEANUP_HEAP_SEARCH;
    5165       }
    5166 
    5167       m_cache_directory.write(set,way,dir_entry);
    5168 
    5169 #if DEBUG_MEMC_CLEANUP
    5170       if(m_debug)
    5171       {
    5172         std::cout
    5173             << "  <MEMC " << name()
    5174             << " CLEANUP_HEAP_LOCK> Checks matching:"
    5175             << " address = "      << r_cleanup_nline.read() * m_words * 4
    5176             << " / dir_id = "     << r_cleanup_copy.read()
    5177             << " / dir_ins = "    << r_cleanup_copy_inst.read()
    5178             << " / heap_id = "    << heap_entry.owner.srcid
    5179             << " / heap_ins = "   << heap_entry.owner.inst
    5180             << " / search_id = "  << r_cleanup_srcid.read()
    5181             << " / search_ins = " << r_cleanup_inst.read()
    5182             << std::endl;
    5183       }
    5184 #endif
    5185       break;
    5186     }
    5187 
    5188     ////////////////////////
    5189     case CLEANUP_HEAP_SEARCH:
    5190     {
    5191       // This state is handling the case where the copy
    5192       // is in the heap, but is not the first in the linked list
    5193       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    5194       {
    5195         std::cout
    5196             << "VCI_MEM_CACHE ERROR " << name()
    5197             << " CLEANUP_HEAP_SEARCH state"
    5198             << " bad HEAP allocation" << std::endl;
    5199 
    5200         exit(0);
    5201       }
    5202 
    5203       HeapEntry heap_entry  = m_heap.read(r_cleanup_next_ptr.read());
    5204 
    5205       bool last             = (heap_entry.next        == r_cleanup_next_ptr.read());
    5206       bool match_heap_srcid = (heap_entry.owner.srcid == r_cleanup_srcid.read());
    5207       bool match_heap_inst  = (heap_entry.owner.inst  == r_cleanup_inst.read());
    5208       bool match_heap       = match_heap_srcid and match_heap_inst;
    5209 
    5210 #if L1_MULTI_CACHE
    5211       match_heap = match_heap and(heap_entry.owner.cache_id == r_cleanup_pktid.read());
    5212 #endif
    5213 
    5214       if(not match_heap and last)
    5215       {
    5216         std::cout
    5217             << "VCI_MEM_CACHE_ERROR " << name()
    5218             << " CLEANUP_HEAP_SEARCH state"
    5219             << " cleanup on valid line but copy not found"
    5220             << std::endl;
    5221 
    5222         exit(0);
    5223       }
    5224 
    5225       // the matching copy must be removed
    5226       if(match_heap)
    5227       {
    5228         // re-use ressources
    5229         r_cleanup_ptr = heap_entry.next;
    5230         r_cleanup_fsm = CLEANUP_HEAP_CLEAN;
    5231       }
    5232       // test the next in the linked list
    5233       else
    5234       {
    5235         r_cleanup_prev_ptr      = r_cleanup_next_ptr.read();
    5236         r_cleanup_prev_srcid    = heap_entry.owner.srcid;
    5237         r_cleanup_prev_inst     = heap_entry.owner.inst;
    5238         r_cleanup_next_ptr      = heap_entry.next;
    5239 
    5240         r_cleanup_fsm           = CLEANUP_HEAP_SEARCH;
    5241 
    5242 #if L1_MULTI_CACHE
    5243         r_cleanup_prev_cache_id = heap_entry.owner.cache_id;
    5244 #endif
    5245       }
    5246 
    5247 #if DEBUG_MEMC_CLEANUP
    5248       if(m_debug)
    5249       {
     5183if(m_debug)
     5184{
    52505185        if(not match_heap)
    52515186        {
     
    52625197              << std::endl;
    52635198        }
    5264 
    52655199        std::cout
    52665200            << " address = "      << r_cleanup_nline.read() * m_words * 4
     
    52715205            << " / last = "       << last
    52725206            << std::endl;
    5273       }
    5274 #endif
    5275       break;
    5276     }
    5277     ////////////////////////
    5278     case CLEANUP_HEAP_CLEAN:    // remove a copy in the linked list
    5279     {
    5280       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    5281       {
    5282         std::cout
    5283             << "VCI_MEM_CACHE ERROR " << name()
    5284             << " CLEANUP_HEAP_CLEAN state"
    5285             << "Bad HEAP allocation"  << std::endl;
    5286 
    5287         exit(0);
    5288       }
    5289 
    5290       HeapEntry heap_entry;
    5291       heap_entry.owner.srcid    = r_cleanup_prev_srcid.read();
    5292       heap_entry.owner.inst     = r_cleanup_prev_inst.read();
    5293 
    5294 #if L1_MULTI_CACHE
    5295       heap_entry.owner.cache_id = r_cleanup_prev_cache_id.read();
    5296 #endif
    5297 
    5298       bool last = (r_cleanup_next_ptr.read() == r_cleanup_ptr.read());
    5299 
    5300       // this is the last entry of the list of copies
    5301       if(last)
    5302       {
    5303         heap_entry.next = r_cleanup_prev_ptr.read();
    5304       }
    5305       // this is not the last entry
    5306       else
    5307       {
    5308         heap_entry.next = r_cleanup_ptr.read();
    5309       }
    5310 
    5311       m_heap.write(r_cleanup_prev_ptr.read(), heap_entry);
    5312 
    5313       r_cleanup_fsm = CLEANUP_HEAP_FREE;
     5207}
     5208#endif
     5209          break;
     5210      }
     5211      ////////////////////////
     5212      case CLEANUP_HEAP_CLEAN:    // remove a copy in the linked list
     5213      {
     5214          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and
     5215          "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation");
     5216
     5217          HeapEntry heap_entry;
     5218          heap_entry.owner.srcid    = r_cleanup_prev_srcid.read();
     5219          heap_entry.owner.inst     = r_cleanup_prev_inst.read();
     5220          bool last = (r_cleanup_next_ptr.read() == r_cleanup_ptr.read());
     5221
     5222          if (last)     // this is the last entry of the list of copies
     5223          {
     5224              heap_entry.next = r_cleanup_prev_ptr.read();
     5225          }
     5226          else          // this is not the last entry
     5227          {
     5228              heap_entry.next = r_cleanup_ptr.read();
     5229          }
     5230
     5231          m_heap.write(r_cleanup_prev_ptr.read(), heap_entry);
     5232
     5233          r_cleanup_fsm = CLEANUP_HEAP_FREE;
    53145234
    53155235#if DEBUG_MEMC_CLEANUP
     
    53185238          << " Remove the copy in the linked list" << std::endl;
    53195239#endif
    5320       break;
    5321     }
    5322     ///////////////////////
    5323     case CLEANUP_HEAP_FREE:   // The heap entry pointed by r_cleanup_next_ptr is freed
    5324                               // and becomes the head of the list of free entries
    5325     {
    5326       if(r_alloc_heap_fsm.read() != ALLOC_HEAP_CLEANUP)
    5327       {
    5328         std::cout
    5329             << "VCI_MEM_CACHE ERROR " << name()
    5330             << " CLEANUP_HEAP_CLEAN state" << std::endl
    5331             << "Bad HEAP allocation" << std::endl;
    5332 
    5333         exit(0);
    5334       }
    5335 
    5336       HeapEntry heap_entry;
    5337       heap_entry.owner.srcid    = 0;
    5338       heap_entry.owner.inst     = false;
    5339 
    5340 #if L1_MULTI_CACHE
    5341       heap_entry.owner.cache_id = 0;
    5342 #endif
    5343 
    5344       if(m_heap.is_full())
    5345       {
    5346         heap_entry.next = r_cleanup_next_ptr.read();
    5347       }
    5348       else
    5349       {
    5350         heap_entry.next = m_heap.next_free_ptr();
    5351       }
    5352 
    5353       m_heap.write(r_cleanup_next_ptr.read(),heap_entry);
    5354       m_heap.write_free_ptr(r_cleanup_next_ptr.read());
    5355       m_heap.unset_full();
    5356 
    5357       r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5240          break;
     5241      }
     5242      ///////////////////////
     5243      case CLEANUP_HEAP_FREE:   // The heap entry pointed by r_cleanup_next_ptr is freed
     5244                                // and becomes the head of the list of free entries
     5245      {
     5246          assert( (r_alloc_heap_fsm.read() == ALLOC_HEAP_CLEANUP) and
     5247          "MEMC ERROR in CLEANUP_HEAP_LOCK state: bad HEAP allocation");
     5248
     5249          HeapEntry heap_entry;
     5250          heap_entry.owner.srcid    = 0;
     5251          heap_entry.owner.inst     = false;
     5252
     5253          if(m_heap.is_full())
     5254          {
     5255              heap_entry.next = r_cleanup_next_ptr.read();
     5256          }
     5257          else
     5258          {
     5259              heap_entry.next = m_heap.next_free_ptr();
     5260          }
     5261
     5262          m_heap.write(r_cleanup_next_ptr.read(),heap_entry);
     5263          m_heap.write_free_ptr(r_cleanup_next_ptr.read());
     5264          m_heap.unset_full();
     5265
     5266          r_cleanup_fsm = CLEANUP_SEND_CLACK;
    53585267
    53595268#if DEBUG_MEMC_CLEANUP
     
    53625271          << " Update the list of free entries" << std::endl;
    53635272#endif
    5364       break;
    5365     }
    5366     //////////////////////
    5367     case CLEANUP_IVT_LOCK:   // get the lock protecting the IVT to search a pending
    5368                              // invalidate transaction matching the cleanup
    5369     {
    5370       m_cpt_cleanup_fsm_upt_lock++;
    5371       if(r_alloc_ivt_fsm.read() != ALLOC_IVT_CLEANUP) break;
    5372 
    5373       size_t index = 0;
    5374       bool   match_inval;
    5375 
    5376       match_inval = m_ivt.search_inval(r_cleanup_nline.read(), index);
     5273          break;
     5274      }
     5275      //////////////////////
     5276      case CLEANUP_IVT_LOCK:   // get the lock protecting the IVT to search a pending
     5277                               // invalidate transaction matching the cleanup
     5278      {
     5279          if(r_alloc_ivt_fsm.read() != ALLOC_IVT_CLEANUP) break;
     5280
     5281          size_t index = 0;
     5282          bool   match_inval;
     5283
     5284          match_inval = m_ivt.search_inval(r_cleanup_nline.read(), index);
    53775285
    53785286      if ( not match_inval )     // no pending inval
     
    53905298#if DEBUG_MEMC_CLEANUP
    53915299if(m_debug)
    5392 std::cout << "  <MEMC " << name()
    5393           << " CLEANUP_IVT_LOCK> Unexpected cleanup"
    5394           << " with no corresponding IVT entry:"
    5395           << " address = " << std::hex
    5396           << (r_cleanup_nline.read() *4*m_words)
    5397           << std::endl;
    5398 #endif
    5399       m_cpt_cleanup_fsm_n_upt_lock++;
    5400         break;
    5401       }
    5402 
    5403       // pending inval
    5404       r_cleanup_write_srcid = m_ivt.srcid(index);
    5405       r_cleanup_write_trdid = m_ivt.trdid(index);
    5406       r_cleanup_write_pktid = m_ivt.pktid(index);
    5407       r_cleanup_need_rsp    = m_ivt.need_rsp(index);
    5408       r_cleanup_need_ack    = m_ivt.need_ack(index);
    5409       r_cleanup_index       = index;
    5410 
    5411       r_cleanup_fsm         = CLEANUP_IVT_DECREMENT;
     5300std::cout << "  <MEMC " << name() << " CLEANUP_IVT_LOCK>"
     5301          << " Unexpected cleanup with no corresponding IVT entry:"
     5302          << " address = " << std::hex << (r_cleanup_nline.read()*4*m_words) << std::endl;
     5303#endif
     5304        break;
     5305      }
     5306      else                     // pending inval in IVT
     5307      {
     5308        r_cleanup_write_srcid = m_ivt.srcid(index);
     5309        r_cleanup_write_trdid = m_ivt.trdid(index);
     5310        r_cleanup_write_pktid = m_ivt.pktid(index);
     5311        r_cleanup_need_rsp    = m_ivt.need_rsp(index);
     5312        r_cleanup_need_ack    = m_ivt.need_ack(index);
     5313        r_cleanup_index       = index;
     5314        r_cleanup_fsm         = CLEANUP_IVT_DECREMENT;
    54125315
    54135316#if DEBUG_MEMC_CLEANUP
    5414 if(m_debug)
    5415 std::cout << "  <MEMC " << name()
    5416           << " CLEANUP_IVT_LOCK> Cleanup matching pending"
    5417           << " invalidate transaction on IVT:"
    5418           << " address = " << std::hex << r_cleanup_nline.read() * m_words * 4
    5419           << " / ivt_entry = " << index << std::endl;
    5420 #endif
     5317        if(m_debug)
     5318          std::cout << "  <MEMC " << name() << " CLEANUP_IVT_LOCK>"
     5319            << " Cleanup matching pending invalidate transaction on IVT:"
     5320            << " address = " << std::hex << (r_cleanup_nline.read()*m_words*4)
     5321            << " / ivt_entry = " << index << std::endl;
     5322#endif
     5323      }
    54215324      break;
    5422     }
    5423     ///////////////////////////
    5424     case CLEANUP_IVT_DECREMENT: // decrement response counter in IVT matching entry
    5425     {
    5426       if(r_alloc_ivt_fsm.read() != ALLOC_IVT_CLEANUP)
    5427       {
    5428         std::cout
    5429             << "VCI_MEM_CACHE ERROR "         << name()
    5430             << " CLEANUP_IVT_DECREMENT state" << std::endl
    5431             << "Bad IVT allocation"
    5432             << std::endl;
    5433 
    5434         exit(0);
    5435       }
    5436 
    5437       size_t count = 0;
    5438       m_ivt.decrement(r_cleanup_index.read(), count);
    5439 
    5440       if(count == 0)   // multi inval transaction completed
    5441       {
    5442         r_cleanup_fsm = CLEANUP_IVT_CLEAR;
    5443       }
    5444       else             // multi inval transaction not completed
    5445       {
    5446         /*ODCCP*/ // If cleanup is on no coherent line we go to CLEANUP_IXR_REQ
    5447         if (r_cleanup_ncc.read())
    5448         {
    5449           r_cleanup_fsm = CLEANUP_IXR_REQ;
    5450         }
    5451         else
    5452         {
    5453           r_cleanup_fsm = CLEANUP_SEND_CLACK;
    5454         }
    5455       }
     5325      }
     5326      ///////////////////////////
     5327      case CLEANUP_IVT_DECREMENT: // decrement response counter in IVT matching entry
     5328                                  // and test if last
     5329      {
     5330          assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CLEANUP) and
     5331          "MEMC ERROR in CLEANUP_IVT_DECREMENT state: Bad IVT allocation");
     5332
     5333          size_t count = 0;
     5334          m_ivt.decrement(r_cleanup_index.read(), count);
     5335
     5336          if(count == 0)   // multi inval transaction completed
     5337          {
     5338            r_cleanup_fsm = CLEANUP_IVT_CLEAR;
     5339          }
     5340          else             // multi inval transaction not completed
     5341          {
     5342            /*ODCCP*/ // If cleanup is on no coherent line we go to CLEANUP_IXR_REQ
     5343            if (r_cleanup_ncc.read())
     5344            {
     5345              r_cleanup_fsm = CLEANUP_IXR_REQ;
     5346            }
     5347            else
     5348            {
     5349              r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5350            }
     5351          }
    54565352
    54575353#if DEBUG_MEMC_CLEANUP
     
    54595355std::cout << "  <MEMC " << name() << " CLEANUP_IVT_DECREMENT>"
    54605356          << " Decrement response counter in IVT:"
    5461             << " IVT_index = " << r_cleanup_index.read()
    5462             << " / rsp_count = " << count << std::endl;
    5463 #endif
    5464       break;
    5465     }
    5466     ///////////////////////
    5467     case CLEANUP_IVT_CLEAR:    // Clear IVT entry
    5468     {
    5469       if(r_alloc_ivt_fsm.read() != ALLOC_IVT_CLEANUP)
    5470       {
    5471         std::cout
    5472             << "VCI_MEM_CACHE ERROR "     << name()
    5473             << " CLEANUP_IVT_CLEAR state" << std::endl
    5474             << "Bad IVT allocation"
    5475             << std::endl;
    5476 
    5477         exit(0);
    5478       }
    5479 
    5480       m_ivt.clear(r_cleanup_index.read());
     5357          << " IVT_index = " << r_cleanup_index.read()
     5358          << " / rsp_count = " << count << std::endl;
     5359#endif
     5360          break;
     5361      }
     5362      ///////////////////////
     5363      case CLEANUP_IVT_CLEAR:    // Clear IVT entry
     5364                                 // Acknowledge CONFIG FSM if required
     5365      {
     5366          assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CLEANUP) and
     5367          "MEMC ERROR in CLEANUP_IVT_CLEAR state : bad IVT allocation");
     5368
     5369          m_ivt.clear(r_cleanup_index.read());
     5370
     5371          if ( r_cleanup_need_ack.read() )
     5372          {
     5373              assert( (r_config_rsp_lines.read() > 0) and
     5374              "MEMC ERROR in CLEANUP_IVT_CLEAR state");
     5375   
     5376              r_config_rsp_lines = r_config_rsp_lines.read() - 1;
     5377          }
    54815378
    54825379      if      ( r_cleanup_need_rsp.read() ) r_cleanup_fsm = CLEANUP_WRITE_RSP;
    5483       else if ( r_cleanup_need_ack.read() ) r_cleanup_fsm = CLEANUP_CONFIG_ACK;
    54845380      else if ( r_cleanup_ncc.read()      ) r_cleanup_fsm = CLEANUP_IXR_REQ;
    54855381      else                                  r_cleanup_fsm = CLEANUP_SEND_CLACK;
     
    54915387          << " IVT_index = " << r_cleanup_index.read() << std::endl;
    54925388#endif
    5493       break;
    5494     }
    5495     ///////////////////////
    5496     case CLEANUP_WRITE_RSP:    // response to a previous write on the direct network
     5389          break;
     5390      }
     5391      ///////////////////////
     5392      case CLEANUP_WRITE_RSP:    // response to a previous write on the direct network
    54975393                               // wait if pending request to the TGT_RSP FSM
    5498     {
    5499       if(r_cleanup_to_tgt_rsp_req.read()) break;
    5500 
    5501       // no pending request
    5502       r_cleanup_to_tgt_rsp_req     = true;
    5503       r_cleanup_to_tgt_rsp_srcid   = r_cleanup_write_srcid.read();
    5504       r_cleanup_to_tgt_rsp_trdid   = r_cleanup_write_trdid.read();
    5505       r_cleanup_to_tgt_rsp_pktid   = r_cleanup_write_pktid.read();
    5506 
    5507       /*ODCCP*/ // If cleanup is on no coherent line we go to CLEANUP_IXR_REQ
    5508       if (r_cleanup_ncc.read())
    5509       {
    5510         r_cleanup_fsm = CLEANUP_IXR_REQ;
    5511       }
    5512       else
    5513       {
    5514         r_cleanup_fsm = CLEANUP_SEND_CLACK;
    5515       }
     5394      {
     5395          if(r_cleanup_to_tgt_rsp_req.read()) break;
     5396
     5397          // no pending request
     5398          r_cleanup_to_tgt_rsp_req     = true;
     5399          r_cleanup_to_tgt_rsp_srcid   = r_cleanup_write_srcid.read();
     5400          r_cleanup_to_tgt_rsp_trdid   = r_cleanup_write_trdid.read();
     5401          r_cleanup_to_tgt_rsp_pktid   = r_cleanup_write_pktid.read();
     5402
     5403          /*ODCCP*/ // If cleanup is on no coherent line we go to CLEANUP_IXR_REQ
     5404          if (r_cleanup_ncc.read())
     5405          {
     5406            r_cleanup_fsm = CLEANUP_IXR_REQ;
     5407          }
     5408          else
     5409          {
     5410            r_cleanup_fsm = CLEANUP_SEND_CLACK;
     5411          }
    55165412
    55175413#if DEBUG_MEMC_CLEANUP
     
    55235419          << " / rpktid = " << r_cleanup_write_pktid.read() << std::endl;
    55245420#endif
    5525       break;
    5526     }
    5527     ////////////////////////
    5528     case CLEANUP_CONFIG_ACK:   // signals inval completion to CONFIG FSM
    5529                                // wait if pending request
    5530     {
    5531       if ( r_cleanup_to_config_ack.read() ) break;
    5532       r_cleanup_to_config_ack      = true;
    5533       r_cleanup_fsm                = CLEANUP_SEND_CLACK;
    5534 
    5535 #if DEBUG_MEMC_CLEANUP
    5536 if(m_debug)
    5537 std::cout << "  <MEMC " << name() << " CLEANUP_CONFIG_ACK>"
    5538           << " Acknowledge broacast inval completion" << std::endl;
    5539 #endif
    5540       break;
    5541     }
     5421          break;
     5422      }
    55425423
    55435424    /*ODCCP*/
     
    55605441            r_cleanup_to_ixr_cmd_req          = r_cleanup_contains_data.read();
    55615442            r_cleanup_to_ixr_cmd_srcid        = r_cleanup_srcid.read();
    5562             r_cleanup_to_ixr_cmd_trdid        = m_trt_lines;
     5443            r_cleanup_to_ixr_cmd_index        = m_trt_lines;
    55635444            r_cleanup_to_ixr_cmd_pktid        = r_cleanup_pktid.read();
    55645445            r_cleanup_to_ixr_cmd_nline        = r_cleanup_nline.read();
     
    56045485          }
    56055486          r_cleanup_to_ixr_cmd_srcid        = r_cleanup_srcid.read();
    5606           r_cleanup_to_ixr_cmd_trdid        = index;
     5487          r_cleanup_to_ixr_cmd_index        = index;
    56075488          r_cleanup_to_ixr_cmd_pktid        = r_cleanup_pktid.read();
    56085489          r_cleanup_to_ixr_cmd_nline        = r_cleanup_nline.read();
     
    56525533std::cout << "  <MEMC " << name()
    56535534          << " CLEANUP_SEND_CLACK> Send the response to a cleanup request:"
    5654           << " nline = "   << std::hex << r_cleanup_nline.read()
     5535          << " address = "   << std::hex << r_cleanup_nline.read()*m_words*4
    56555536          << " / way = "   << std::dec << r_cleanup_way.read()
    56565537          << " / srcid = " << std::dec << r_cleanup_srcid.read()
    56575538          << std::endl;
    56585539#endif
    5659       break;
    5660     }
     5540          break;
     5541      }
    56615542  } // end switch cleanup fsm
    56625543
     
    56645545  //    CAS FSM
    56655546  ////////////////////////////////////////////////////////////////////////////////////
    5666   // The CAS FSM handles the CAS (Store Conditionnal) atomic commands,
    5667   // that are handled as "compare-and-swap instructions.
     5547  // The CAS FSM handles the CAS (Compare And Swap) atomic commands.
    56685548  //
    56695549  // This command contains two or four flits:
    56705550  // - In case of 32 bits atomic access, the first flit contains the value read
    5671   // by a previous LL instruction, the second flit contains the value to be writen.
     5551  // by a previous READ instruction, the second flit contains the value to be writen.
    56725552  // - In case of 64 bits atomic access, the 2 first flits contains the value read
    5673   // by a previous LL instruction, the 2 next flits contains the value to be writen.
     5553  // by a previous READ instruction, the 2 next flits contains the value to be writen.
    56745554  //
    56755555  // The target address is cachable. If it is replicated in other L1 caches
     
    56785558  // It access the directory to check hit / miss.
    56795559  // - In case of miss, the CAS FSM must register a GET transaction in TRT.
    5680   // If a read transaction to the XRAM for this line already exists,
    5681   // or if the transaction table is full, it goes to the WAIT state
    5682   // to release the locks and try again. When the GET transaction has been
    5683   // launched, it goes to the WAIT state and try again.
    5684   // The CAS request is not consumed in the FIFO until a HIT is obtained.
     5560  //   If a read transaction to the XRAM for this line already exists,
     5561  //   or if the transaction table is full, it goes to the WAIT state
     5562  //   to release the locks and try again. When the GET transaction has been
     5563  //   launched, it goes to the WAIT state and try again.
     5564  //   The CAS request is not consumed in the FIFO until a HIT is obtained.
    56855565  // - In case of hit...
    56865566  ///////////////////////////////////////////////////////////////////////////////////
    56875567
     5568//std::cout << std::endl << "cas_fsm" << std::endl;
     5569
    56885570  switch(r_cas_fsm.read())
    56895571  {
    5690       /////////////
     5572    ////////////
    56915573    case CAS_IDLE:     // fill the local rdata buffers
    56925574    {
    5693       if(m_cmd_cas_addr_fifo.rok())
    5694       {
     5575        if (m_cmd_cas_addr_fifo.rok() )
     5576        {
    56955577
    56965578#if DEBUG_MEMC_CAS
    5697         if(m_debug)
    5698         {
    5699           std::cout << "  <MEMC " << name() << " CAS_IDLE> CAS command: " << std::hex
    5700                     << " srcid = " <<  std::dec << m_cmd_cas_srcid_fifo.read()
    5701                     << " addr = " << std::hex << m_cmd_cas_addr_fifo.read()
    5702                     << " wdata = " << m_cmd_cas_wdata_fifo.read()
    5703                     << " eop = " << std::dec << m_cmd_cas_eop_fifo.read()
    5704                     << " cpt  = " << std::dec << r_cas_cpt.read() << std::endl;
    5705         }
    5706 #endif
    5707         if(m_cmd_cas_eop_fifo.read())
    5708         {
    5709           m_cpt_cas++;
    5710           r_cas_fsm = CAS_DIR_REQ;
    5711         }
    5712         else  // we keep the last word in the FIFO
    5713         {
    5714           cmd_cas_fifo_get = true;
    5715         }
    5716         // We fill the two buffers
    5717         if(r_cas_cpt.read() < 2)    // 32 bits access
    5718           r_cas_rdata[r_cas_cpt.read()] = m_cmd_cas_wdata_fifo.read();
    5719 
    5720         if((r_cas_cpt.read() == 1) and m_cmd_cas_eop_fifo.read())
    5721           r_cas_wdata = m_cmd_cas_wdata_fifo.read();
    5722 
    5723         if(r_cas_cpt.read() >3)  // more than 4 flits...
    5724         {
    5725           std::cout << "VCI_MEM_CACHE ERROR in CAS_IDLE state : illegal CAS command"
    5726                     << std::endl;
    5727           exit(0);
    5728         }
    5729 
    5730         if(r_cas_cpt.read() ==2)
    5731           r_cas_wdata = m_cmd_cas_wdata_fifo.read();
    5732 
    5733         r_cas_cpt = r_cas_cpt.read() +1;
    5734       }
    5735       break;
    5736     }
    5737 
     5579if(m_debug)
     5580std::cout << "  <MEMC " << name() << " CAS_IDLE> CAS command: " << std::hex
     5581          << " srcid = " <<  std::dec << m_cmd_cas_srcid_fifo.read()
     5582          << " addr = " << std::hex << m_cmd_cas_addr_fifo.read()
     5583          << " wdata = " << m_cmd_cas_wdata_fifo.read()
     5584          << " eop = " << std::dec << m_cmd_cas_eop_fifo.read()
     5585          << " cpt  = " << std::dec << r_cas_cpt.read() << std::endl;
     5586#endif
     5587            if(m_cmd_cas_eop_fifo.read())
     5588            {
     5589                m_cpt_cas++;
     5590                r_cas_fsm = CAS_DIR_REQ;
     5591            }
     5592            else  // we keep the last word in the FIFO
     5593            {
     5594                cmd_cas_fifo_get = true;
     5595            }
     5596
     5597            // We fill the two buffers
     5598            if(r_cas_cpt.read() < 2)    // 32 bits access
     5599                r_cas_rdata[r_cas_cpt.read()] = m_cmd_cas_wdata_fifo.read();
     5600
     5601            if((r_cas_cpt.read() == 1) and m_cmd_cas_eop_fifo.read())
     5602                r_cas_wdata = m_cmd_cas_wdata_fifo.read();
     5603
     5604            assert( (r_cas_cpt.read() <= 3) and  // no more than 4 flits...
     5605            "MEMC ERROR in CAS_IDLE state: illegal CAS command");
     5606
     5607            if(r_cas_cpt.read() ==2)
     5608                r_cas_wdata = m_cmd_cas_wdata_fifo.read();
     5609
     5610            r_cas_cpt = r_cas_cpt.read() +1;
     5611        }
     5612        break;
     5613    }
    57385614    /////////////////
    57395615    case CAS_DIR_REQ:
    57405616    {
    5741       if(r_alloc_dir_fsm.read() == ALLOC_DIR_CAS)
    5742       {
    5743         r_cas_fsm = CAS_DIR_LOCK;
    5744         m_cpt_cas_fsm_n_dir_lock++;
    5745       }
     5617        if(r_alloc_dir_fsm.read() == ALLOC_DIR_CAS)
     5618        {
     5619            r_cas_fsm = CAS_DIR_LOCK;
     5620        }
    57465621
    57475622#if DEBUG_MEMC_CAS
    5748       if(m_debug)
    5749       {
    5750         std::cout
    5751             << "  <MEMC " << name() << " CAS_DIR_REQ> Requesting DIR lock "
    5752             << std::endl;
    5753       }
    5754 #endif
    5755 
    5756       m_cpt_cas_fsm_dir_lock++;
    5757 
    5758       break;
    5759     }
    5760 
     5623if(m_debug)
     5624std::cout << "  <MEMC " << name() << " CAS_DIR_REQ> Requesting DIR lock " << std::endl;
     5625#endif
     5626        break;
     5627    }
    57615628    /////////////////
    57625629    case CAS_DIR_LOCK:  // Read the directory
    57635630    {
    5764       if(r_alloc_dir_fsm.read() == ALLOC_DIR_CAS)
    5765       {
     5631        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     5632        "MEMC ERROR in CAS_DIR_LOCK: Bad DIR allocation");
     5633
    57665634        size_t way = 0;
    57675635        DirectoryEntry entry(m_cache_directory.read(m_cmd_cas_addr_fifo.read(), way));
     
    57725640        r_cas_way        = way;
    57735641        r_cas_copy       = entry.owner.srcid;
    5774 #if L1_MULTI_CACHE
    5775         r_cas_copy_cache = entry.owner.cache_id;
    5776 #endif
    57775642        r_cas_copy_inst  = entry.owner.inst;
    57785643        r_cas_ptr        = entry.ptr;
     
    57835648
    57845649#if DEBUG_MEMC_CAS
    5785         if(m_debug)
    5786         {
    5787           std::cout << "  <MEMC " << name() << " CAS_DIR_LOCK> Directory acces"
    5788                     << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
    5789                     << " / hit = " << std::dec << entry.valid
    5790                     << " / count = " << entry.count
    5791                     << " / is_cnt = " << entry.is_cnt << std::endl;
    5792         }
    5793 #endif
    5794       }
    5795       else
    5796       {
    5797         std::cout
    5798             << "VCI_MEM_CACHE ERROR " << name()
    5799             << " CAS_DIR_LOCK state" << std::endl
    5800             << "Bad DIR allocation"   << std::endl;
    5801 
    5802         exit(0);
    5803       }
    5804 
    5805       break;
     5650if(m_debug)
     5651std::cout << "  <MEMC " << name() << " CAS_DIR_LOCK> Directory acces"
     5652          << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
     5653          << " / hit = " << std::dec << entry.valid
     5654          << " / count = " << entry.count
     5655          << " / is_cnt = " << entry.is_cnt << std::endl;
     5656#endif
     5657
     5658        break;
    58065659    }
    58075660    /////////////////////
     
    58095662                            // and check data change in cache
    58105663    {
    5811       size_t way  = r_cas_way.read();
    5812       size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
    5813 
    5814       // update directory (lock & dirty bits)
    5815       DirectoryEntry entry;
    5816       entry.valid          = true;
    5817       entry.is_cnt         = r_cas_is_cnt.read();
    5818       entry.dirty          = true;
    5819       entry.lock           = true;
    5820       entry.tag            = r_cas_tag.read();
    5821       entry.owner.srcid    = r_cas_copy.read();
    5822 #if L1_MULTI_CACHE
    5823       entry.owner.cache_id = r_cas_copy_cache.read();
    5824 #endif
    5825       entry.owner.inst     = r_cas_copy_inst.read();
    5826       entry.count          = r_cas_count.read();
    5827       entry.ptr            = r_cas_ptr.read();
    5828 
    5829       m_cache_directory.write(set, way, entry);
    5830 
    5831       // Stored data from cache in buffer to do the comparison in next state
    5832       m_cache_data.read_line(way, set, r_cas_data);
    5833 
    5834       r_cas_fsm = CAS_DIR_HIT_COMPARE;
     5664        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     5665        "MEMC ERROR in CAS_DIR_HIT_READ: Bad DIR allocation");
     5666
     5667        size_t way  = r_cas_way.read();
     5668        size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5669
     5670        // update directory (lock & dirty bits)
     5671        DirectoryEntry entry;
     5672        entry.valid          = true;
     5673        entry.is_cnt         = r_cas_is_cnt.read();
     5674        entry.dirty          = true;
     5675        entry.lock           = true;
     5676        entry.tag            = r_cas_tag.read();
     5677        entry.owner.srcid    = r_cas_copy.read();
     5678        entry.owner.inst     = r_cas_copy_inst.read();
     5679        entry.count          = r_cas_count.read();
     5680        entry.ptr            = r_cas_ptr.read();
     5681
     5682        m_cache_directory.write(set, way, entry);
     5683
     5684        // Store data from cache in buffer to do the comparison in next state
     5685        m_cache_data.read_line(way, set, r_cas_data);
     5686
     5687        r_cas_fsm = CAS_DIR_HIT_COMPARE;
    58355688
    58365689#if DEBUG_MEMC_CAS
     
    58395692          << " cache and store it in buffer" << std::endl;
    58405693#endif
    5841       break;
    5842     }
    5843 
     5694        break;
     5695    }
     5696    ////////////////////////
    58445697    case CAS_DIR_HIT_COMPARE:
    58455698    {
    5846       size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    5847 
    5848       // Read data in buffer & check data change
     5699        size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5700
     5701        // check data change
    58495702      bool ok = (r_cas_rdata[0].read() == r_cas_data[word].read());
    58505703
     
    58565709      r_cas_lfsr = (r_cas_lfsr >> 1) ^ ((- (r_cas_lfsr & 1)) & 0xd0000001);
    58575710
    5858       // cas success
    5859       if(ok and not forced_fail)
    5860       {
    5861         r_cas_fsm = CAS_DIR_HIT_WRITE;
    5862       }
    5863       // cas failure
    5864       else
    5865       {
    5866         r_cas_fsm = CAS_RSP_FAIL;
    5867       }
     5711      if(ok and not forced_fail) r_cas_fsm = CAS_DIR_HIT_WRITE;
     5712      else                       r_cas_fsm = CAS_RSP_FAIL;
    58685713
    58695714#if DEBUG_MEMC_CAS
    58705715if(m_debug)
    5871 std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_COMPARE> Compare the old"
    5872           << " and the new data"
    5873           << " / expected value = " << r_cas_rdata[0].read()
    5874           << " / actual value = "   << r_cas_data[word].read()
    5875           << " / forced_fail = "    << forced_fail << std::endl;
     5716std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_COMPARE> Compare old and new data"
     5717          << " / expected value = " << std::hex << r_cas_rdata[0].read()
     5718          << " / actual value = "   << std::hex << r_cas_data[word].read()
     5719          << " / forced_fail = "    << std::dec << forced_fail << std::endl;
    58765720#endif
    58775721      break;
     
    58795723    //////////////////////
    58805724    case CAS_DIR_HIT_WRITE:    // test if a CC transaction is required
    5881       // write data in cache if no CC request
    5882     {
    5883       // The CAS is a success => sw access to the llsc_global_table
    5884       m_llsc_table.sw(m_nline[(addr_t)m_cmd_cas_addr_fifo.read()],m_x[(addr_t)(m_cmd_cas_addr_fifo.read())],m_x[(addr_t)(m_cmd_cas_addr_fifo.read())]);
    5885 
    5886       // test coherence request
    5887       if(r_cas_count.read())   // replicated line
    5888       {
    5889         if(r_cas_is_cnt.read())
    5890         {
    5891           r_cas_fsm = CAS_BC_TRT_LOCK;    // broadcast invalidate required
    5892         }
    5893         else if(!r_cas_to_cc_send_multi_req.read() and
    5894                 !r_cas_to_cc_send_brdcast_req.read())
    5895         {
    5896           r_cas_fsm = CAS_UPT_LOCK;       // multi update required
    5897         }
    5898         else
    5899         {
    5900           r_cas_fsm = CAS_WAIT;
    5901         }
    5902       }
    5903       else                    // no copies
    5904       {
    5905         size_t way  = r_cas_way.read();
    5906         size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
    5907         size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    5908 
    5909         // cache update
    5910         m_cache_data.write(way, set, word, r_cas_wdata.read());
    5911         if(r_cas_cpt.read() == 4)
    5912           m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read());
    5913 
    5914         r_cas_fsm = CAS_RSP_SUCCESS;
    5915 
    5916         // monitor
    5917         if(m_monitor_ok)
    5918         {
    5919           addr_t address = m_cmd_cas_addr_fifo.read();
    5920           check_monitor( address, r_cas_wdata.read(), false);
    5921 
    5922           if(r_cas_cpt.read() == 4)
    5923             check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);
    5924         }
     5725                               // write data in cache if no CC request
     5726    {
     5727        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     5728        "MEMC ERROR in CAS_DIR_HIT_WRITE: Bad DIR allocation");
     5729
     5730        // The CAS is a success => sw access to the llsc_global_table
     5731        m_llsc_table.sw( m_nline[(addr_t)m_cmd_cas_addr_fifo.read()],
     5732                         m_x[(addr_t)(m_cmd_cas_addr_fifo.read())],
     5733                         m_x[(addr_t)(m_cmd_cas_addr_fifo.read())] );
     5734
     5735        // test coherence request
     5736        if(r_cas_count.read())   // replicated line
     5737        {
     5738            if(r_cas_is_cnt.read())
     5739            {
     5740                r_cas_fsm = CAS_BC_TRT_LOCK;    // broadcast invalidate required
     5741
     5742#if DEBUG_MEMC_CAS
     5743if(m_debug)
     5744std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
     5745          << " Broacast Inval required"
     5746          << " / copies = " << r_cas_count.read() << std::endl;
     5747#endif
     5748            }
     5749            else if( not r_cas_to_cc_send_multi_req.read() and
     5750                     not r_cas_to_cc_send_brdcast_req.read() )
     5751            {
     5752                r_cas_fsm = CAS_UPT_LOCK;       // multi update required
     5753
     5754#if DEBUG_MEMC_CAS
     5755if(m_debug)
     5756std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
     5757          << " Multi Inval required"
     5758          << " / copies = " << r_cas_count.read() << std::endl;
     5759#endif
     5760            }
     5761            else
     5762            {
     5763                r_cas_fsm = CAS_WAIT;
     5764
     5765#if DEBUG_MEMC_CAS
     5766if(m_debug)
     5767std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
     5768          << " CC_SEND FSM busy: release all locks and retry" << std::endl;
     5769#endif
     5770            }
     5771        }
     5772        else                    // no copies
     5773        {
     5774            size_t way  = r_cas_way.read();
     5775            size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5776            size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5777
     5778            // cache update
     5779            m_cache_data.write(way, set, word, r_cas_wdata.read());
     5780            if(r_cas_cpt.read() == 4)
     5781            m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read());
     5782
     5783            r_cas_fsm = CAS_RSP_SUCCESS;
    59255784
    59265785#if DEBUG_MEMC_CAS
     
    59395798    /////////////////
    59405799    case CAS_UPT_LOCK:  // try to register the transaction in UPT
    5941       // and write data in cache if successful registration
    5942       // releases locks to retry later if UPT full
    5943     {
    5944       if(r_alloc_upt_fsm.read() == ALLOC_UPT_CAS)
    5945       {
    5946         bool        wok        = false;
    5947         size_t      index      = 0;
    5948         size_t      srcid      = m_cmd_cas_srcid_fifo.read();
    5949         size_t      trdid      = m_cmd_cas_trdid_fifo.read();
    5950         size_t      pktid      = m_cmd_cas_pktid_fifo.read();
    5951         addr_t      nline      = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    5952         size_t      nb_copies  = r_cas_count.read();
    5953 
    5954         wok = m_upt.set(true,    // it's an update transaction
    5955                         false,   // it's not a broadcast
    5956                         true,    // response required 
    5957                         false,   // no acknowledge required
    5958                         srcid,
    5959                         trdid,
    5960                         pktid,
    5961                         nline,
    5962                         nb_copies,
    5963                         index);
    5964         if(wok)   // coherence transaction registered in UPT
    5965         {
    5966           // cache update
    5967           size_t way  = r_cas_way.read();
    5968           size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
    5969           size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    5970 
    5971           m_cache_data.write(way, set, word, r_cas_wdata.read());
    5972           if(r_cas_cpt.read() ==4)
    5973             m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read());
    5974 
    5975           r_cas_upt_index = index;
    5976           r_cas_fsm = CAS_UPT_HEAP_LOCK;
    5977 
    5978           // monitor
    5979           if(m_monitor_ok)
    5980           {
    5981             addr_t address = m_cmd_cas_addr_fifo.read();
    5982             check_monitor( address, r_cas_wdata.read(), false);
    5983 
    5984             if(r_cas_cpt.read() ==4)
    5985               check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);
    5986           }
    5987         }
    5988         else       //  releases the locks protecting UPT and DIR UPT full
    5989         {
    5990           r_cas_fsm = CAS_WAIT;
    5991         }
     5800                        // and write data in cache if successful registration
     5801                        // releases locks to retry later if UPT full
     5802    {
     5803        if(r_alloc_upt_fsm.read() == ALLOC_UPT_CAS)
     5804        {
     5805            bool        wok        = false;
     5806            size_t      index      = 0;
     5807            size_t      srcid      = m_cmd_cas_srcid_fifo.read();
     5808            size_t      trdid      = m_cmd_cas_trdid_fifo.read();
     5809            size_t      pktid      = m_cmd_cas_pktid_fifo.read();
     5810            addr_t      nline      = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5811            size_t      nb_copies  = r_cas_count.read();
     5812
     5813            wok = m_upt.set( true,    // it's an update transaction
     5814                             false,   // it's not a broadcast
     5815                             true,    // response required 
     5816                             false,   // no acknowledge required
     5817                             srcid,
     5818                             trdid,
     5819                             pktid,
     5820                             nline,
     5821                             nb_copies,
     5822                             index);
     5823            if(wok)   // coherence transaction registered in UPT
     5824            {
     5825                // cache update
     5826                size_t way  = r_cas_way.read();
     5827                size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5828                size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
     5829
     5830                m_cache_data.write(way, set, word, r_cas_wdata.read());
     5831                if(r_cas_cpt.read() ==4)
     5832                    m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read());
     5833
     5834                r_cas_upt_index = index;
     5835                r_cas_fsm = CAS_UPT_HEAP_LOCK;
     5836            }
     5837            else       //  releases the locks protecting UPT and DIR UPT full
     5838            {
     5839                r_cas_fsm = CAS_WAIT;
     5840            }
    59925841
    59935842#if DEBUG_MEMC_CAS
     
    59965845          << " CAS_UPT_LOCK> Register multi-update transaction in UPT"
    59975846          << " / wok = " << wok
    5998           << " / nline  = " << std::hex << nline
     5847          << " / address  = " << std::hex << nline*m_words*4
    59995848          << " / count = " << nb_copies << std::endl;
    60005849#endif
    6001         m_cpt_cas_fsm_n_upt_lock++;
    6002       }
    6003 
    6004       m_cpt_cas_fsm_upt_lock++;
    6005 
    6006       break;
     5850        }
     5851        break;
    60075852    }
    60085853    /////////////
     
    60115856
    60125857#if DEBUG_MEMC_CAS
    6013       if(m_debug)
    6014       {
    6015         std::cout << "  <MEMC " << name()
    6016                   << " CAS_WAIT> Release all locks" << std::endl;
    6017       }
    6018 #endif
    6019       r_cas_fsm = CAS_DIR_REQ;
    6020       break;
    6021     }
    6022     //////////////////
     5858if(m_debug)
     5859std::cout << "  <MEMC " << name() << " CAS_WAIT> Release all locks" << std::endl;
     5860#endif
     5861        r_cas_fsm = CAS_DIR_REQ;
     5862        break;
     5863    }
     5864    //////////////////////
    60235865    case CAS_UPT_HEAP_LOCK:  // lock the heap
    60245866    {
     
    60705912        cas_to_cc_send_fifo_inst    = r_cas_copy_inst.read();
    60715913        cas_to_cc_send_fifo_srcid   = r_cas_copy.read();
    6072 #if L1_MULTI_CACHE
    6073         cas_to_cc_send_fifo_cache_id= r_cas_copy_cache.read();
    6074 #endif
    60755914        if(r_cas_count.read() == 1)  // one single copy
    60765915        {
     
    61075946      HeapEntry entry = m_heap.read(r_cas_ptr.read());
    61085947      cas_to_cc_send_fifo_srcid    = entry.owner.srcid;
    6109 #if L1_MULTI_CACHE
    6110       cas_to_cc_send_fifo_cache_id = entry.owner.cache_id;
    6111 #endif
    61125948      cas_to_cc_send_fifo_inst     = entry.owner.inst;
    61135949      cas_to_cc_send_fifo_put = true;
     
    61395975    }
    61405976    /////////////////////
    6141     case CAS_BC_TRT_LOCK:      // check the TRT to register a PUT transaction
    6142     {
    6143       if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)
    6144       {
    6145         if(!r_cas_to_ixr_cmd_req)    // we can transfer the request to IXR_CMD FSM
    6146         {
    6147           // fill the data buffer
    6148           size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6149           for(size_t i = 0; i<m_words; i++)
    6150           {
    6151             if(i == word)
     5977    case CAS_BC_TRT_LOCK:      // get TRT lock to check TRT not full
     5978    {
     5979        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     5980        "MEMC ERROR in CAS_BC_TRT_LOCK state: Bas DIR allocation");
     5981
     5982        if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)
     5983        {
     5984            size_t wok_index = 0;
     5985            bool   wok       = !m_trt.full(wok_index);
     5986            if( wok )
    61525987            {
    6153               r_cas_to_ixr_cmd_data[i] = r_cas_wdata.read();
    6154             }
    6155             else if((i == word+1) and (r_cas_cpt.read() == 4))   // 64 bit CAS
    6156             {
    6157               r_cas_to_ixr_cmd_data[i] = m_cmd_cas_wdata_fifo.read();
     5988                r_cas_trt_index = wok_index;
     5989                r_cas_fsm       = CAS_BC_IVT_LOCK;
    61585990            }
    61595991            else
    61605992            {
    6161               r_cas_to_ixr_cmd_data[i] = r_cas_data[i].read();
     5993                r_cas_fsm       = CAS_WAIT;
    61625994            }
    6163           }
    6164           size_t wok_index = 0;
    6165           bool   wok       = !m_trt.full(wok_index);
    6166           if(wok)
    6167           {
    6168             r_cas_trt_index = wok_index;
    6169             r_cas_fsm       = CAS_BC_IVT_LOCK;
    6170           }
    6171           else
    6172           {
    6173             r_cas_fsm       = CAS_WAIT;
    6174           }
    6175         }
    6176         else
    6177         {
    6178           r_cas_fsm = CAS_WAIT;
    6179         }
    6180         m_cpt_cas_fsm_n_trt_lock++;
    6181       }
    6182 
    6183       m_cpt_cas_fsm_trt_lock++;
    6184 
    6185       break;
     5995
     5996#if DEBUG_MEMC_CAS
     5997if(m_debug)
     5998std::cout << "  <MEMC " << name() << " CAS_BC_TRT_LOCK> Check TRT"
     5999          << " : wok = " << wok << " / index = " << wok_index << std::endl;
     6000#endif
     6001        }
     6002        break;
    61866003    }
    61876004    /////////////////////
    6188     case CAS_BC_IVT_LOCK:  // register a broadcast inval transaction in IVT
    6189                            // write data in cache in case of successful registration
    6190     {
    6191       if(r_alloc_ivt_fsm.read() == ALLOC_IVT_CAS)
    6192       {
    6193         bool        wok       = false;
    6194         size_t      index     = 0;
    6195         size_t      srcid     = m_cmd_cas_srcid_fifo.read();
    6196         size_t      trdid     = m_cmd_cas_trdid_fifo.read();
    6197         size_t      pktid     = m_cmd_cas_pktid_fifo.read();
    6198         addr_t      nline     = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6199         size_t      nb_copies = r_cas_count.read();
    6200 
    6201         // register a broadcast inval transaction in IVT
    6202         wok = m_ivt.set(false,  // it's an inval transaction
    6203                         true,   // it's a broadcast
    6204                         true,   // response required
    6205                         false,  // no acknowledge required
    6206                         srcid,
    6207                         trdid,
    6208                         pktid,
    6209                         nline,
    6210                         nb_copies,
    6211                         index);
    6212 
    6213         if(wok)     // IVT not full
    6214         {
    6215           // cache update
    6216           size_t way  = r_cas_way.read();
    6217           size_t set  = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6218           size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6219 
    6220           m_cache_data.write(way, set, word, r_cas_wdata.read());
    6221           if(r_cas_cpt.read() ==4)
    6222             m_cache_data.write(way, set, word+1, m_cmd_cas_wdata_fifo.read());
    6223 
    6224           // monitor
    6225           if(m_monitor_ok)
    6226           {
    6227             addr_t address = m_cmd_cas_addr_fifo.read();
    6228             check_monitor( address, r_cas_wdata.read(), false);
    6229 
    6230             if(r_cas_cpt.read() ==4)
    6231               check_monitor( address+4, m_cmd_cas_wdata_fifo.read(), false);
    6232           }
    6233           r_cas_upt_index = index;
    6234           r_cas_fsm = CAS_BC_DIR_INVAL;
    6235 
     6005    case CAS_BC_IVT_LOCK:  // get IVT lock and register BC transaction in IVT
     6006    {
     6007        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     6008        "MEMC ERROR in CAS_BC_IVT_LOCK state: Bas DIR allocation");
     6009
     6010        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
     6011        "MEMC ERROR in CAS_BC_IVT_LOCK state: Bas TRT allocation");
     6012
     6013        if( r_alloc_ivt_fsm.read() == ALLOC_IVT_CAS )
     6014        {
     6015            // register broadcast inval transaction in IVT
     6016            bool        wok       = false;
     6017            size_t      index     = 0;
     6018            size_t      srcid     = m_cmd_cas_srcid_fifo.read();
     6019            size_t      trdid     = m_cmd_cas_trdid_fifo.read();
     6020            size_t      pktid     = m_cmd_cas_pktid_fifo.read();
     6021            addr_t      nline     = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
     6022            size_t      nb_copies = r_cas_count.read();
     6023
     6024            wok = m_ivt.set( false,  // it's an inval transaction
     6025                             true,   // it's a broadcast
     6026                             true,   // response required
     6027                             false,  // no acknowledge required
     6028                             srcid,
     6029                             trdid,
     6030                             pktid,
     6031                             nline,
     6032                             nb_copies,
     6033                             index);
    62366034#if DEBUG_MEMC_CAS
    6237 if(m_debug)
    6238 std::cout << "  <MEMC " << name()
    6239           << " CAS_BC_IVT_LOCK> Register a broadcast inval transaction in IVT"
    6240           << " / nline = " << std::hex << nline
    6241           << " / count = " << std::dec << nb_copies
    6242           << " / ivt_index = " << index << std::endl;
    6243 #endif
    6244         }
    6245         else      //  releases the lock protecting IVT
    6246         {
    6247           r_cas_fsm = CAS_WAIT;
    6248         }
    6249         m_cpt_cas_fsm_n_upt_lock++;
    6250       }
    6251 
    6252       m_cpt_cas_fsm_upt_lock++;
    6253 
    6254       break;
     6035if( m_debug and wok )
     6036std::cout << "  <MEMC " << name() << " CAS_BC_IVT_LOCK> Register broadcast inval in IVT"
     6037          << " / copies = " << r_cas_count.read() << std::endl;
     6038#endif
     6039            r_cas_upt_index = index;
     6040            if( wok ) r_cas_fsm = CAS_BC_DIR_INVAL;   
     6041            else      r_cas_fsm = CAS_WAIT;
     6042        }
     6043        break;
    62556044    }
    62566045    //////////////////////
    6257     case CAS_BC_DIR_INVAL:  // Register the PUT transaction in TRT, and inval the DIR entry
    6258     {
    6259       if((r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
    6260          (r_alloc_ivt_fsm.read() == ALLOC_IVT_CAS) and
    6261          (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS))
    6262       {
     6046    case CAS_BC_DIR_INVAL:  // Register PUT transaction in TRT,
     6047                            // and inval the DIR entry
     6048    {
     6049        assert( (r_alloc_dir_fsm.read() == ALLOC_DIR_CAS) and
     6050        "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad DIR allocation");
     6051
     6052        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
     6053        "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad TRT allocation");
     6054
     6055        assert( (r_alloc_ivt_fsm.read() == ALLOC_IVT_CAS) and
     6056        "MEMC ERROR in CAS_BC_DIR_INVAL state: Bad IVT allocation");
     6057
    62636058        // set TRT
    6264         m_trt.set(r_cas_trt_index.read(),
    6265                               false,    // PUT request to XRAM
    6266                               m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())],
    6267                               0,
    6268                               0,
    6269                               0,
    6270                               false,    // not a processor read
    6271                               0,
    6272                               0,
    6273                               std::vector<be_t> (m_words,0),
    6274                               std::vector<data_t> (m_words,0));
     6059        std::vector<data_t> data_vector;
     6060        data_vector.clear();
     6061        size_t word = m_x[(addr_t)(m_cmd_cas_addr_fifo.read())];
     6062        for(size_t i=0; i<m_words; i++)
     6063        {
     6064            if(i == word)                                        // first modified word
     6065                data_vector.push_back( r_cas_wdata.read() );     
     6066            else if((i == word+1) and (r_cas_cpt.read() == 4))   // second modified word
     6067                data_vector.push_back( m_cmd_cas_wdata_fifo.read() );
     6068            else                                                 // unmodified words
     6069                data_vector.push_back( r_cas_data[i].read() );
     6070        }
     6071        m_trt.set( r_cas_trt_index.read(),
     6072                   false,    // PUT request
     6073                   m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())],
     6074                   0,
     6075                   0,
     6076                   0,
     6077                   false,    // not a processor read
     6078                   0,
     6079                   0,
     6080                   std::vector<be_t> (m_words,0),
     6081                   data_vector );
    62756082
    62766083        // invalidate directory entry
     
    62786085        entry.valid         = false;
    62796086        entry.dirty         = false;
    6280         entry.tag         = 0;
     6087        entry.tag           = 0;
    62816088        entry.is_cnt        = false;
    62826089        entry.lock          = false;
    62836090        entry.count         = 0;
    62846091        entry.owner.srcid   = 0;
    6285 #if L1_MULTI_CACHE
    6286         entry.owner.cache_id= 0;
    6287 #endif
    62886092        entry.owner.inst    = false;
    62896093        entry.ptr           = 0;
    62906094        size_t set          = m_y[(addr_t)(m_cmd_cas_addr_fifo.read())];
    62916095        size_t way          = r_cas_way.read();
     6096
    62926097        m_cache_directory.write(set, way, entry);
    62936098
     
    62966101#if DEBUG_MEMC_CAS
    62976102if(m_debug)
    6298 std::cout << "  <MEMC " << name()
    6299           << " CAS_BC_DIR_INVAL> Register the PUT in TRT and invalidate DIR entry"
    6300           << " / nline = " << std::hex << m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())]
    6301           << " / set = " << std::dec << set << " / way = " << way << std::endl;
    6302 #endif
    6303       }
    6304       else
    6305       {
    6306         assert(false and "LOCK ERROR in CAS_FSM, STATE = CAS_BC_DIR_INVAL");
    6307       }
    6308       break;
     6103std::cout << "  <MEMC " << name() << " CAS_BC_DIR_INVAL> Inval DIR & register in TRT:"
     6104          << " address = " << m_cmd_cas_addr_fifo.read() << std::endl;
     6105#endif
     6106        break;
    63096107    }
    63106108    ///////////////////
    63116109    case CAS_BC_CC_SEND:  // Request the broadcast inval to CC_SEND FSM
    63126110    {
    6313       if(!r_cas_to_cc_send_multi_req.read() and
    6314           !r_cas_to_cc_send_brdcast_req.read())
    6315       {
    6316         r_cas_to_cc_send_multi_req    = false;
    6317         r_cas_to_cc_send_brdcast_req  = true;
    6318         r_cas_to_cc_send_trdid        = r_cas_upt_index.read();
    6319         r_cas_to_cc_send_nline        = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6320         r_cas_to_cc_send_index        = 0;
    6321         r_cas_to_cc_send_wdata        = 0;
    6322 
    6323         r_cas_fsm = CAS_BC_XRAM_REQ;
    6324       }
    6325       break;
     6111        if( not r_cas_to_cc_send_multi_req.read() and
     6112            not r_cas_to_cc_send_brdcast_req.read() )
     6113        {
     6114            r_cas_to_cc_send_multi_req    = false;
     6115            r_cas_to_cc_send_brdcast_req  = true;
     6116            r_cas_to_cc_send_trdid        = r_cas_upt_index.read();
     6117            r_cas_to_cc_send_nline        = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
     6118            r_cas_to_cc_send_index        = 0;
     6119            r_cas_to_cc_send_wdata        = 0;
     6120
     6121            r_cas_fsm = CAS_BC_XRAM_REQ;
     6122
     6123#if DEBUG_MEMC_CAS
     6124if(m_debug)
     6125std::cout << "  <MEMC " << name()
     6126          << " CAS_BC_CC_SEND> Post a broadcast request to CC_SEND FSM" << std::endl;
     6127#endif
     6128        }
     6129        break;
    63266130    }
    63276131    ////////////////////
    6328     case CAS_BC_XRAM_REQ: // request the IXR FSM to start a put transaction
    6329     {
    6330       if(!r_cas_to_ixr_cmd_req)
    6331       {
    6332         r_cas_to_ixr_cmd_req     = true;
    6333         r_cas_to_ixr_cmd_write   = true;
    6334         r_cas_to_ixr_cmd_nline   = m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())];
    6335         r_cas_to_ixr_cmd_trdid   = r_cas_trt_index.read();
    6336         r_cas_fsm                = CAS_IDLE;
    6337         cmd_cas_fifo_get         = true;
    6338         r_cas_cpt                = 0;
     6132    case CAS_BC_XRAM_REQ: // request the IXR FSM to start a PUT transaction
     6133    {
     6134        if( not r_cas_to_ixr_cmd_req.read() )
     6135        {
     6136            r_cas_to_ixr_cmd_req     = true;
     6137            r_cas_to_ixr_cmd_put     = true;
     6138            r_cas_to_ixr_cmd_index   = r_cas_trt_index.read();
     6139            r_cas_fsm                = CAS_IDLE;
     6140            cmd_cas_fifo_get         = true;
     6141            r_cas_cpt                = 0;
    63396142
    63406143#if DEBUG_MEMC_CAS
     
    63426145std::cout << "  <MEMC " << name()
    63436146          << " CAS_BC_XRAM_REQ> Request a PUT transaction to IXR_CMD FSM" << std::hex
    6344           << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
     6147          << " / address = " << (addr_t) m_cmd_cas_addr_fifo.read()
    63456148          << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    63466149#endif
    6347       }
    6348       else
    6349       {
    6350         std::cout << "ERROR in MEM_CACHE / CAS_BC_XRAM_REQ state"
    6351                   << " : request should not have been previously set" << std::endl;
    6352       }
    6353       break;
     6150        }
     6151        break;
    63546152    }
    63556153    /////////////////
    63566154    case CAS_RSP_FAIL:  // request TGT_RSP FSM to send a failure response
    63576155    {
    6358       if(!r_cas_to_tgt_rsp_req)
    6359       {
    6360         cmd_cas_fifo_get     = true;
    6361         r_cas_cpt              = 0;
    6362         r_cas_to_tgt_rsp_req = true;
    6363         r_cas_to_tgt_rsp_data  = 1;
    6364         r_cas_to_tgt_rsp_srcid = m_cmd_cas_srcid_fifo.read();
    6365         r_cas_to_tgt_rsp_trdid = m_cmd_cas_trdid_fifo.read();
    6366         r_cas_to_tgt_rsp_pktid = m_cmd_cas_pktid_fifo.read();
    6367         r_cas_fsm              = CAS_IDLE;
     6156        if( not r_cas_to_tgt_rsp_req.read() )
     6157        {
     6158            cmd_cas_fifo_get       = true;
     6159            r_cas_cpt              = 0;
     6160            r_cas_to_tgt_rsp_req  = true;
     6161            r_cas_to_tgt_rsp_data  = 1;
     6162            r_cas_to_tgt_rsp_srcid = m_cmd_cas_srcid_fifo.read();
     6163            r_cas_to_tgt_rsp_trdid = m_cmd_cas_trdid_fifo.read();
     6164            r_cas_to_tgt_rsp_pktid = m_cmd_cas_pktid_fifo.read();
     6165            r_cas_fsm              = CAS_IDLE;
    63686166
    63696167#if DEBUG_MEMC_CAS
     
    63726170          << " CAS_RSP_FAIL> Request TGT_RSP to send a failure response" << std::endl;
    63736171#endif
    6374       }
    6375       break;
     6172        }
     6173        break;
    63766174    }
    63776175    ////////////////////
    63786176    case CAS_RSP_SUCCESS:  // request TGT_RSP FSM to send a success response
    63796177    {
    6380       if(!r_cas_to_tgt_rsp_req)
    6381       {
    6382         cmd_cas_fifo_get       = true;
    6383         r_cas_cpt              = 0;
    6384         r_cas_to_tgt_rsp_req = true;
    6385         r_cas_to_tgt_rsp_data  = 0;
    6386         r_cas_to_tgt_rsp_srcid = m_cmd_cas_srcid_fifo.read();
    6387         r_cas_to_tgt_rsp_trdid = m_cmd_cas_trdid_fifo.read();
    6388         r_cas_to_tgt_rsp_pktid = m_cmd_cas_pktid_fifo.read();
    6389         r_cas_fsm              = CAS_IDLE;
     6178        if( not r_cas_to_tgt_rsp_req.read() )
     6179        {
     6180            cmd_cas_fifo_get       = true;
     6181            r_cas_cpt              = 0;
     6182            r_cas_to_tgt_rsp_req  = true;
     6183            r_cas_to_tgt_rsp_data  = 0;
     6184            r_cas_to_tgt_rsp_srcid = m_cmd_cas_srcid_fifo.read();
     6185            r_cas_to_tgt_rsp_trdid = m_cmd_cas_trdid_fifo.read();
     6186            r_cas_to_tgt_rsp_pktid = m_cmd_cas_pktid_fifo.read();
     6187            r_cas_fsm              = CAS_IDLE;
    63906188
    63916189#if DEBUG_MEMC_CAS
     
    63946192          << " CAS_RSP_SUCCESS> Request TGT_RSP to send a success response" << std::endl;
    63956193#endif
    6396       }
    6397       break;
    6398     }
    6399     /////////////////////
     6194        }
     6195        break;
     6196    }
     6197    ///////////////////////
    64006198    case CAS_MISS_TRT_LOCK:         // cache miss : request access to transaction Table
    64016199    {
    6402       if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)
    6403       {
    6404         size_t   index = 0;
    6405         bool hit_read = m_trt.hit_read(
    6406                           m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],index);
    6407         bool hit_write = m_trt.hit_write(
    6408                            m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]);
    6409         bool wok = !m_trt.full(index);
     6200        if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)
     6201        {
     6202            size_t   index = 0;
     6203            bool hit_read = m_trt.hit_read(
     6204                             m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],index);
     6205            bool hit_write = m_trt.hit_write(
     6206                             m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]);
     6207            bool wok       = not m_trt.full(index);
    64106208
    64116209#if DEBUG_MEMC_CAS
    6412         if(m_debug)
    6413         {
    6414           std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_LOCK> Check TRT state"
    6415                     << " / hit_read = "  << hit_read
    6416                     << " / hit_write = " << hit_write
    6417                     << " / wok = " << wok
    6418                     << " / index = " << index << std::endl;
    6419         }
    6420 #endif
    6421 
    6422         if(hit_read or !wok or hit_write)    // missing line already requested or no space in TRT
    6423         {
    6424           r_cas_fsm = CAS_WAIT;
    6425         }
    6426         else
    6427         {
    6428           r_cas_trt_index = index;
    6429           r_cas_fsm       = CAS_MISS_TRT_SET;
    6430         }
    6431         m_cpt_cas_fsm_n_trt_lock++;
    6432       }
    6433 
    6434       m_cpt_cas_fsm_trt_lock++;
    6435 
    6436       break;
    6437     }
    6438     ////////////////////
     6210if(m_debug)
     6211std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_LOCK> Check TRT state"
     6212          << " / hit_read = "  << hit_read
     6213          << " / hit_write = " << hit_write
     6214          << " / wok = " << wok
     6215          << " / index = " << index << std::endl;
     6216#endif
     6217
     6218            if(hit_read or !wok or hit_write)    // missing line already requested or TRT full
     6219            {
     6220                r_cas_fsm = CAS_WAIT;
     6221            }
     6222            else
     6223            {
     6224                r_cas_trt_index = index;
     6225                r_cas_fsm       = CAS_MISS_TRT_SET;
     6226            }
     6227        }
     6228        break;
     6229    }
     6230    //////////////////////
    64396231    case CAS_MISS_TRT_SET: // register the GET transaction in TRT
    64406232    {
    6441       if(r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)
    6442       {
     6233        assert( (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS) and
     6234        "MEMC ERROR in CAS_MISS_TRT_SET state: Bad TRT allocation");
     6235
    64436236        std::vector<be_t> be_vector;
    64446237        std::vector<data_t> data_vector;
     
    64516244        }
    64526245
    6453         m_trt.set(r_cas_trt_index.read(),
    6454                               true,   // read request
    6455                               m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],
    6456                               m_cmd_cas_srcid_fifo.read(),
    6457                               m_cmd_cas_trdid_fifo.read(),
    6458                               m_cmd_cas_pktid_fifo.read(),
    6459                               false,    // write request from processor
    6460                               0,
    6461                               0,
    6462                               be_vector,
    6463                               data_vector);
     6246        m_trt.set( r_cas_trt_index.read(),
     6247                   true,     // GET
     6248                   m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],
     6249                   m_cmd_cas_srcid_fifo.read(),
     6250                   m_cmd_cas_trdid_fifo.read(),
     6251                   m_cmd_cas_pktid_fifo.read(),
     6252                   false,    // write request from processor
     6253                   0,
     6254                   0,
     6255                   std::vector<be_t>(m_words,0),                         
     6256                   std::vector<data_t>(m_words,0) );                         
     6257
    64646258        r_cas_fsm = CAS_MISS_XRAM_REQ;
    64656259
    64666260#if DEBUG_MEMC_CAS
    6467         if(m_debug)
    6468         {
    6469           std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_SET> Register a GET transaction in TRT" << std::hex
    6470                     << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
    6471                     << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    6472         }
    6473 #endif
    6474       }
    6475       break;
     6261if(m_debug)
     6262std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_SET> Register GET transaction in TRT"
     6263          << " / address = " << std::hex << (addr_t)m_cmd_cas_addr_fifo.read()
     6264          << " / trt_index = " << std::dec << r_cas_trt_index.read() << std::endl;
     6265#endif
     6266        break;
    64766267    }
    64776268    //////////////////////
    6478     case CAS_MISS_XRAM_REQ:  // request the IXR_CMD FSM to fetch the missing line
    6479     {
    6480       if(!r_cas_to_ixr_cmd_req)
    6481       {
    6482         r_cas_to_ixr_cmd_req        = true;
    6483         r_cas_to_ixr_cmd_write      = false;
    6484         r_cas_to_ixr_cmd_trdid      = r_cas_trt_index.read();
    6485         r_cas_to_ixr_cmd_nline      = m_nline[(addr_t) m_cmd_cas_addr_fifo.read()];
    6486         r_cas_fsm                   = CAS_WAIT;
     6269    case CAS_MISS_XRAM_REQ:  // request the IXR_CMD FSM a GET request
     6270    {
     6271        if( not r_cas_to_ixr_cmd_req.read() )
     6272        {
     6273            r_cas_to_ixr_cmd_req        = true;
     6274            r_cas_to_ixr_cmd_put        = false;
     6275            r_cas_to_ixr_cmd_index      = r_cas_trt_index.read();
     6276            r_cas_fsm                   = CAS_WAIT;
    64876277
    64886278#if DEBUG_MEMC_CAS
    6489         if(m_debug)
    6490         {
    6491           std::cout << "  <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction to IXR_CMD FSM" << std::hex
    6492                     << " / nline = " << m_nline[(addr_t) m_cmd_cas_addr_fifo.read()]
    6493                     << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    6494         }
    6495 #endif
    6496       }
    6497       break;
     6279if(m_debug)
     6280std::cout << "  <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction"
     6281          << " / address = " << std::hex << (addr_t) m_cmd_cas_addr_fifo.read()
     6282          << " / trt_index = " << std::dec << r_cas_trt_index.read() << std::endl;
     6283#endif
     6284        }
     6285        break;
    64986286    }
    64996287  } // end switch r_cas_fsm
     
    65286316  ///////////////////////////////////////////////////////////////////////////////
    65296317
     6318//std::cout << std::endl << "cc_send_fsm" << std::endl;
     6319
    65306320  switch(r_cc_send_fsm.read())
    65316321  {
     
    69286718if(m_debug)
    69296719std::cout << "  <MEMC " << name()
    6930           << " CC_SEND_WRITE_UPDT_NLINE> Multicast-Update for line "
    6931           << r_write_to_cc_send_nline.read() << std::endl;
     6720          << " CC_SEND_WRITE_UPDT_NLINE> Multicast-Update for address "
     6721          << r_write_to_cc_send_nline.read()*m_words*4 << std::endl;
    69326722#endif
    69336723        break;
    69346724      }
    69356725      /////////////////////////////
    6936       case CC_SEND_WRITE_UPDT_DATA:   // send N data flits for a multi-update (from WRITE FSM)
     6726      case CC_SEND_WRITE_UPDT_DATA:   // send data flits for multi-update (from WRITE FSM)
    69376727      {
    69386728        if(not p_dspin_m2p.read) break;
     
    69666756if(m_debug)
    69676757std::cout << "  <MEMC " << name()
    6968           << " CC_SEND_CAS_BRDCAST_NLINE> Broadcast-Inval for line "
    6969           << r_cas_to_cc_send_nline.read() << std::endl;
     6758          << " CC_SEND_CAS_BRDCAST_NLINE> Broadcast-Inval for address: "
     6759          << r_cas_to_cc_send_nline.read()*m_words*4 << std::endl;
    69706760#endif
    69716761        break;
     
    70046794if(m_debug)
    70056795std::cout << "  <MEMC " << name()
    7006           << " CC_SEND_CAS_UPDT_NLINE> Multicast-Update for line "
    7007           << r_cas_to_cc_send_nline.read() << std::endl;
     6796          << " CC_SEND_CAS_UPDT_NLINE> Multicast-Update for address "
     6797          << r_cas_to_cc_send_nline.read()*m_words*4 << std::endl;
    70086798#endif
    70096799        break;
     
    70256815      }
    70266816      ////////////////////////////////
    7027       case CC_SEND_CAS_UPDT_DATA_HIGH:   // send second data for a multi-update (from CAS FSM)
     6817      case CC_SEND_CAS_UPDT_DATA_HIGH:   // send second data for multi-update (from CAS FSM)
    70286818      {
    70296819        if(not p_dspin_m2p.read) break;
     
    70426832  //////////////////////////////////////////////////////////////////////////////
    70436833
     6834//std::cout << std::endl << "cc_receive_fsm" << std::endl;
     6835
    70446836  switch(r_cc_receive_fsm.read())
    70456837  {
     
    71236915      }
    71246916  }
     6917
    71256918  //////////////////////////////////////////////////////////////////////////
    71266919  //    TGT_RSP FSM
     
    71416934  //////////////////////////////////////////////////////////////////////////
    71426935
     6936//std::cout << std::endl << "tgt_rsp_fsm" << std::endl;
     6937
    71436938  switch(r_tgt_rsp_fsm.read())
    71446939  {
     
    73367131    }
    73377132    /////////////////////
    7338     case TGT_RSP_TGT_CMD: // send the response for a segmentation violation
     7133    case TGT_RSP_TGT_CMD: // send the response for a configuration access
    73397134    {
    73407135      if ( p_vci_tgt.rspack )
     
    73487143  std::cout
    73497144    << "  <MEMC " << name()
    7350     << " TGT_RSP_TGT_CMD> Segmentation violation response"
     7145    << " TGT_RSP_TGT_CMD> Send response for a configuration access"
    73517146    << " / rsrcid = " << std::hex << r_tgt_cmd_to_tgt_rsp_srcid.read()
    73527147    << " / rtrdid = " << r_tgt_cmd_to_tgt_rsp_trdid.read()
    73537148    << " / rpktid = " << r_tgt_cmd_to_tgt_rsp_pktid.read()
     7149    << " / error = " << r_tgt_cmd_to_tgt_rsp_error.read()
    73547150    << std::endl;
    73557151}
     
    75327328  // The resource is always allocated.
    75337329  /////////////////////////////////////////////////////////////////////////////////////
     7330
     7331//std::cout << std::endl << "alloc_upt_fsm" << std::endl;
     7332
    75347333  switch(r_alloc_upt_fsm.read())
    75357334  {
     
    75877386  // The resource is always allocated.
    75887387  /////////////////////////////////////////////////////////////////////////////////////
     7388
     7389//std::cout << std::endl << "alloc_ivt_fsm" << std::endl;
     7390
    75897391  switch(r_alloc_ivt_fsm.read())
    75907392  {
    7591       //////////////////////////
     7393      /////////////////////
    75927394      case ALLOC_IVT_WRITE:            // allocated to WRITE FSM
    75937395          if (r_write_fsm.read() != WRITE_BC_IVT_LOCK)
    75947396          {
    7595               if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     7397              if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    75967398                  r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    75977399
     
    76027404                  r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    76037405             
    7604               else if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     7406              else if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    76057407                  r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    76067408
     
    76107412          break;
    76117413
    7612       //////////////////////////
     7414      ////////////////////////
    76137415      case ALLOC_IVT_XRAM_RSP:         // allocated to XRAM_RSP FSM
    7614           if(r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK)
     7416          if(r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK)
    76157417          {
    76167418            if(r_cleanup_fsm.read() == CLEANUP_IVT_LOCK)
     
    76207422              r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    76217423
    7622             else if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     7424            else if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    76237425              r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    76247426
     
    76317433          break;
    76327434
    7633       //////////////////////////
     7435      ///////////////////////
    76347436      case ALLOC_IVT_CLEANUP:          // allocated to CLEANUP FSM
    76357437          if ((r_cleanup_fsm.read() != CLEANUP_IVT_LOCK     ) and
     
    76397441              r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    76407442
    7641             else if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     7443            else if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    76427444              r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    76437445
     
    76457447              r_alloc_ivt_fsm = ALLOC_IVT_WRITE;
    76467448
    7647             else if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     7449            else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    76487450              r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    7649 
    7650             else
    7651               m_cpt_ivt_unused++;
    76527451          }
    76537452          break;
     
    76577456          if (r_cas_fsm.read() != CAS_BC_IVT_LOCK)
    76587457          {
    7659             if (r_config_fsm.read() == CONFIG_DIR_IVT_LOCK)
     7458            if (r_config_fsm.read() == CONFIG_IVT_LOCK)
    76607459              r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    76617460
     
    76637462              r_alloc_ivt_fsm = ALLOC_IVT_WRITE;
    76647463
    7665             else if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     7464            else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    76667465              r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    76677466
     
    76697468              r_alloc_ivt_fsm = ALLOC_IVT_CLEANUP;
    76707469     
    7671             else
    7672               m_cpt_ivt_unused++;
    76737470          }
    76747471          break;
     
    76767473      //////////////////////////
    76777474      case ALLOC_IVT_CONFIG:           // allocated to CONFIG FSM
    7678           if (r_config_fsm.read() != CONFIG_DIR_IVT_LOCK)
     7475          if (r_config_fsm.read() != CONFIG_IVT_LOCK)
    76797476          {
    76807477            if (r_write_fsm.read() == WRITE_BC_IVT_LOCK)
    76817478              r_alloc_ivt_fsm = ALLOC_IVT_WRITE;
    76827479
    7683             else if (r_xram_rsp_fsm.read() == XRAM_RSP_INVAL_LOCK)
     7480            else if (r_xram_rsp_fsm.read() == XRAM_RSP_IVT_LOCK)
    76847481              r_alloc_ivt_fsm = ALLOC_IVT_XRAM_RSP;
    76857482
     
    76907487              r_alloc_ivt_fsm = ALLOC_IVT_CAS;
    76917488         
    7692             else
    7693               m_cpt_ivt_unused++;
    76947489          }
    76957490          break;
     
    77067501  /////////////////////////////////////////////////////////////////////////////////////
    77077502
     7503//std::cout << std::endl << "alloc_dir_fsm" << std::endl;
     7504
    77087505  switch(r_alloc_dir_fsm.read())
    77097506  {
     
    77257522    if ( (r_config_fsm.read()    != CONFIG_DIR_REQ) and
    77267523         (r_config_fsm.read()    != CONFIG_DIR_ACCESS) and
    7727          (r_config_fsm.read()    != CONFIG_DIR_IVT_LOCK) )
     7524         (r_config_fsm.read()    != CONFIG_TRT_LOCK) and
     7525         (r_config_fsm.read()    != CONFIG_TRT_SET) and
     7526         (r_config_fsm.read()    != CONFIG_IVT_LOCK) )
    77287527    {
    77297528        if(r_read_fsm.read() == READ_DIR_REQ)
     
    77807579    if(((r_write_fsm.read()       != WRITE_DIR_REQ)  and
    77817580        (r_write_fsm.read()       != WRITE_DIR_LOCK)  and
    7782         (r_write_fsm.read()       != WRITE_DIR_READ)  and
     7581        (r_write_fsm.read()       != WRITE_BC_DIR_READ)  and
    77837582        (r_write_fsm.read()       != WRITE_DIR_HIT)  and
    77847583        (r_write_fsm.read()       != WRITE_BC_TRT_LOCK)  and
     
    78907689    if( (r_xram_rsp_fsm.read() != XRAM_RSP_DIR_LOCK) and
    78917690        (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) and
    7892         (r_xram_rsp_fsm.read() != XRAM_RSP_INVAL_LOCK))
     7691        (r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK))
    78937692    {
    78947693        if(r_config_fsm.read() == CONFIG_DIR_REQ)
     
    79207719  ////////////////////////////////////////////////////////////////////////////////////
    79217720  // The ALLOC_TRT fsm allocates the access to the Transaction Table (write buffer)
    7922   // with a round robin priority between 4 user FSMs :
    7923   // The cyclic priority is READ > WRITE > CAS > XRAM_RSP
     7721  // with a round robin priority between 7 user FSMs :
     7722  // The priority is READ > WRITE > CAS > IXR_CMD > XRAM_RSP > IXR_RSP > CONFIG
    79247723  // The ressource is always allocated.
    79257724  ///////////////////////////////////////////////////////////////////////////////////
    79267725
     7726//std::cout << std::endl << "alloc_trt_fsm" << std::endl;
     7727
    79277728  switch(r_alloc_trt_fsm.read())
    79287729  {
    7929     ////////////////////
    7930     case ALLOC_TRT_READ:
    7931       if(r_read_fsm.read() != READ_TRT_LOCK)
    7932       {
    7933         if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    7934             (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     7730      ////////////////////
     7731      case ALLOC_TRT_READ:
     7732          if(r_read_fsm.read() != READ_TRT_LOCK)
     7733          {
     7734              if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     7735                  (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     7736                  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     7737
     7738              else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     7739                      (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     7740                  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     7741
     7742              else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     7743                      (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     7744                      (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     7745                      (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     7746                      (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     7747                      (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     7748                  r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     7749
     7750              else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     7751                      (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     7752                  r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     7753
     7754              else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     7755                      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     7756                  r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7757
     7758              else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     7759                  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     7760             
     7761              else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7762                r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     7763          }
     7764          break;
     7765
     7766      /////////////////////
     7767      case ALLOC_TRT_WRITE:
     7768          if((r_write_fsm.read() != WRITE_MISS_TRT_LOCK) and
     7769             (r_write_fsm.read() != WRITE_BC_TRT_LOCK) and
     7770             (r_write_fsm.read() != WRITE_BC_IVT_LOCK))
     7771          {
     7772              if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     7773                 (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     7774                  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     7775
     7776              else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     7777                      (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     7778                      (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     7779                      (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     7780                      (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     7781                      (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     7782                  r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     7783
     7784              else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     7785                      (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     7786                  r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     7787
     7788              else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     7789                      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     7790                  r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7791
     7792              else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     7793                  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     7794             
     7795              else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7796                r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     7797 
     7798              else if(r_read_fsm.read() == READ_TRT_LOCK)
     7799                  r_alloc_trt_fsm = ALLOC_TRT_READ;
     7800          }
     7801          break;
     7802      ///////////////////
     7803      case ALLOC_TRT_CAS:
     7804          if((r_cas_fsm.read() != CAS_MISS_TRT_LOCK) and
     7805             (r_cas_fsm.read() != CAS_BC_TRT_LOCK) and
     7806             (r_cas_fsm.read() != CAS_BC_IVT_LOCK))
     7807          {
     7808              if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     7809                 (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     7810                 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     7811                 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     7812                 (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     7813                 (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     7814                  r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     7815
     7816              if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     7817                 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     7818                  r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     7819
     7820              else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     7821                      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     7822                  r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7823
     7824              else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     7825                  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     7826             
     7827              else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7828                r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     7829
     7830              else if(r_read_fsm.read() == READ_TRT_LOCK)
     7831                  r_alloc_trt_fsm = ALLOC_TRT_READ;
     7832
     7833              else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     7834                      (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     7835                  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     7836          }
     7837          break;
     7838      ///////////////////////
     7839      case ALLOC_TRT_IXR_CMD:
     7840          if((r_ixr_cmd_fsm.read() != IXR_CMD_READ_TRT) and
     7841             (r_ixr_cmd_fsm.read() != IXR_CMD_WRITE_TRT) and
     7842             (r_ixr_cmd_fsm.read() != IXR_CMD_CAS_TRT) and
     7843             (r_ixr_cmd_fsm.read() != IXR_CMD_XRAM_TRT) and
     7844             (r_ixr_cmd_fsm.read() != IXR_CMD_CLEANUP_TRT) and
     7845             (r_ixr_cmd_fsm.read() != IXR_CMD_CONFIG_TRT))
     7846          {
     7847              if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     7848                 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     7849                  r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     7850
     7851              else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     7852                      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     7853                  r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7854
     7855              else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     7856                  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     7857             
     7858              else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7859                r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     7860
     7861              else if(r_read_fsm.read() == READ_TRT_LOCK)
     7862                  r_alloc_trt_fsm = ALLOC_TRT_READ;
     7863
     7864              else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     7865                      (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     7866                  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     7867
     7868              else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     7869                      (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     7870                  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     7871          }
     7872          break;
     7873      ////////////////////////
     7874      case ALLOC_TRT_XRAM_RSP:
     7875          if(((r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_LOCK)  or
     7876              (r_alloc_dir_fsm.read() != ALLOC_DIR_XRAM_RSP)) and
     7877              (r_xram_rsp_fsm.read()  != XRAM_RSP_TRT_COPY)  and
     7878              (r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_UPDT)  and
     7879              (r_xram_rsp_fsm.read()  != XRAM_RSP_IVT_LOCK))
     7880          {
     7881              if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     7882                 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     7883                  r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7884
     7885              else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     7886                  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     7887             
     7888              else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7889                r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     7890
     7891              else if(r_read_fsm.read() == READ_TRT_LOCK)
     7892                  r_alloc_trt_fsm = ALLOC_TRT_READ;
     7893
     7894              else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     7895                      (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     7896                  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     7897
     7898              else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     7899                      (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     7900                  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     7901
     7902              else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     7903                      (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     7904                      (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     7905                      (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     7906                      (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     7907                      (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     7908                  r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     7909
     7910          }
     7911          break;
     7912      ///////////////////////
     7913      case ALLOC_TRT_IXR_RSP:
     7914          if((r_ixr_rsp_fsm.read() != IXR_RSP_TRT_ERASE) and
     7915             (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ))
     7916          {
     7917              if(r_config_fsm.read() == CONFIG_TRT_LOCK)
     7918                  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     7919             
     7920              else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7921                r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     7922
     7923              else if(r_read_fsm.read() == READ_TRT_LOCK)
     7924                  r_alloc_trt_fsm = ALLOC_TRT_READ;
     7925
     7926              else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     7927                      (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     7928                  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     7929
     7930              else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     7931                      (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     7932                  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     7933
     7934              else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     7935                      (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     7936                      (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     7937                      (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     7938                      (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     7939                      (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     7940                  r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     7941
     7942              else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     7943                      (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     7944                  r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     7945          }
     7946          break;
     7947      //////////////////////
     7948      case ALLOC_TRT_CONFIG:
     7949          if((r_config_fsm.read() != CONFIG_TRT_LOCK) and
     7950             (r_config_fsm.read() != CONFIG_TRT_SET))
     7951          {
     7952              if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
     7953                r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
     7954
     7955              else if(r_read_fsm.read() == READ_TRT_LOCK)
     7956                  r_alloc_trt_fsm = ALLOC_TRT_READ;
     7957
     7958              else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     7959                      (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
     7960                  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     7961
     7962              else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     7963                      (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
     7964                  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     7965
     7966              else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     7967                      (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     7968                      (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     7969                      (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     7970                      (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     7971                      (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     7972                  r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     7973
     7974              else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
     7975                      (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
     7976                  r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     7977
     7978              else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
     7979                      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
     7980                  r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
     7981
     7982          }
     7983          break;
     7984
     7985      ////////////////////////
     7986    case ALLOC_TRT_CLEANUP:
     7987      if(r_cleanup_fsm.read() != CLEANUP_IXR_REQ)
     7988      {
     7989        if(r_read_fsm.read() == READ_TRT_LOCK)
     7990          r_alloc_trt_fsm = ALLOC_TRT_READ;
     7991
     7992        else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     7993                (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    79357994          r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    79367995
     
    79397998          r_alloc_trt_fsm = ALLOC_TRT_CAS;
    79407999
     8000        else if((r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8001            (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
     8002            (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
     8003            (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8004            (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_TRT) or
     8005            (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT) )
     8006          r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
     8007
    79418008        else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    7942                 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    7943           r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    7944 
    7945         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    7946                 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    7947           r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    7948 
    7949         else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
    7950           r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    7951 
    7952         else if (r_ixr_cmd_fsm.read() == IXR_CMD_TRT_LOCK)
    7953           r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
    7954 
    7955         else
    7956           m_cpt_trt_unused++;
    7957       }
    7958       else
    7959         m_cpt_read_fsm_trt_used++;
    7960       break;
    7961 
    7962     /////////////////////
    7963     case ALLOC_TRT_WRITE:
    7964       if((r_write_fsm.read() != WRITE_MISS_TRT_LOCK) and
    7965           (r_write_fsm.read() != WRITE_BC_TRT_LOCK) and
    7966           (r_write_fsm.read() != WRITE_BC_IVT_LOCK))
    7967       {
    7968         if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    7969             (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    7970           r_alloc_trt_fsm = ALLOC_TRT_CAS;
    7971 
    7972         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    7973                 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    7974           r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    7975 
    7976         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    7977                 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    7978           r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    7979        
    7980         else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
    7981           r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    7982        
    7983         else if (r_ixr_cmd_fsm.read() == IXR_CMD_TRT_LOCK)
    7984           r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
    7985 
    7986         else if(r_read_fsm.read() == READ_TRT_LOCK)
    7987           r_alloc_trt_fsm = ALLOC_TRT_READ;
    7988 
    7989         else
    7990           m_cpt_trt_unused++;
    7991       }
    7992       else
    7993         m_cpt_write_fsm_trt_used++;
    7994       break;
    7995 
    7996     ////////////////////
    7997     case ALLOC_TRT_CAS:
    7998       if((r_cas_fsm.read() != CAS_MISS_TRT_LOCK) and
    7999           (r_cas_fsm.read() != CAS_BC_TRT_LOCK) and
    8000           (r_cas_fsm.read() != CAS_BC_IVT_LOCK))
    8001       {
    8002         if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    80038009            (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    80048010          r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    80058011
    80068012        else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    8007                 (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    8008           r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    8009        
    8010         else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
    8011           r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    8012        
    8013         else if (r_ixr_cmd_fsm.read() == IXR_CMD_TRT_LOCK)
    8014           r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
    8015 
    8016         else if(r_read_fsm.read() == READ_TRT_LOCK)
    8017           r_alloc_trt_fsm = ALLOC_TRT_READ;
    8018 
    8019         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    8020                 (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    8021           r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    8022 
    8023         else
    8024           m_cpt_trt_unused++;
    8025       }
    8026       else
    8027         m_cpt_cas_fsm_trt_used++;
    8028       break;
    8029 
    8030     ////////////////////////
    8031     case ALLOC_TRT_XRAM_RSP:
    8032       if(((r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_LOCK)  or
    8033           (r_alloc_dir_fsm.read() != ALLOC_DIR_XRAM_RSP)) and
    8034           (r_xram_rsp_fsm.read()  != XRAM_RSP_TRT_COPY)  and
    8035           (r_xram_rsp_fsm.read()  != XRAM_RSP_DIR_UPDT)  and
    8036           (r_xram_rsp_fsm.read()  != XRAM_RSP_INVAL_LOCK))
    8037       {
    8038         if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    80398013            (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    80408014          r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    8041        
    8042         else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
    8043           r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    8044        
    8045         else if (r_ixr_cmd_fsm.read() == IXR_CMD_TRT_LOCK)
    8046           r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
    8047 
    8048         else if(r_read_fsm.read() == READ_TRT_LOCK)
    8049           r_alloc_trt_fsm = ALLOC_TRT_READ;
    8050 
    8051         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    8052                 (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    8053           r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    8054 
    8055         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    8056                 (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    8057           r_alloc_trt_fsm = ALLOC_TRT_CAS;
    8058 
    8059         else
    8060           m_cpt_trt_unused++;
    8061       }
    8062       else
    8063         m_cpt_xram_rsp_fsm_trt_used++;
     8015             
     8016        else if( r_config_fsm.read() == CONFIG_TRT_LOCK )
     8017                  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     8018      }
    80648019      break;
    80658020
    8066     ////////////////////////
    8067     case ALLOC_TRT_IXR_RSP:
    8068       if((r_ixr_rsp_fsm.read() != IXR_RSP_TRT_ERASE) and
    8069           (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ))
    8070       {
    8071        
    8072         if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
    8073           r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    8074        
    8075         else if (r_ixr_cmd_fsm.read() == IXR_CMD_TRT_LOCK)
    8076           r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
    8077 
    8078         else if(r_read_fsm.read() == READ_TRT_LOCK)
    8079           r_alloc_trt_fsm = ALLOC_TRT_READ;
    8080 
    8081         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) ||
    8082                 (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    8083           r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    8084 
    8085         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) ||
    8086                 (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    8087           r_alloc_trt_fsm = ALLOC_TRT_CAS;
    8088 
    8089         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) &&
    8090                 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    8091           r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    8092 
    8093         else
    8094           m_cpt_trt_unused++;
    8095       }
    8096       else
    8097         m_cpt_ixr_fsm_trt_used++;
    8098       break;
    8099 
    8100       ////////////////////////
    8101     case ALLOC_TRT_CLEANUP:
    8102       if(r_cleanup_fsm.read() != CLEANUP_IXR_REQ)
    8103       {
    8104         if (r_ixr_cmd_fsm.read() == IXR_CMD_TRT_LOCK)
    8105           r_alloc_trt_fsm = ALLOC_TRT_IXR_CMD;
    8106        
    8107         else if(r_read_fsm.read() == READ_TRT_LOCK)
    8108           r_alloc_trt_fsm = ALLOC_TRT_READ;
    8109 
    8110         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    8111                 (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    8112           r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    8113 
    8114         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    8115                 (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    8116           r_alloc_trt_fsm = ALLOC_TRT_CAS;
    8117 
    8118         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    8119                 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    8120           r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    8121 
    8122         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
    8123             (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    8124           r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    8125       }
    8126       break;
    8127 
    8128       ////////////////////////
    8129     case ALLOC_TRT_IXR_CMD:
    8130       if(r_ixr_cmd_fsm.read() != IXR_CMD_TRT_LOCK)
    8131       {
    8132         if(r_read_fsm.read() == READ_TRT_LOCK)
    8133           r_alloc_trt_fsm = ALLOC_TRT_READ;
    8134 
    8135         else if((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    8136                 (r_write_fsm.read() == WRITE_BC_TRT_LOCK))
    8137           r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    8138 
    8139         else if((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    8140                 (r_cas_fsm.read() == CAS_BC_TRT_LOCK))
    8141           r_alloc_trt_fsm = ALLOC_TRT_CAS;
    8142 
    8143         else if((r_xram_rsp_fsm.read()  == XRAM_RSP_DIR_LOCK) and
    8144                 (r_alloc_dir_fsm.read() == ALLOC_DIR_XRAM_RSP))
    8145           r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
    8146 
    8147         else if((r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) ||
    8148             (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ))
    8149           r_alloc_trt_fsm = ALLOC_TRT_IXR_RSP;
    8150        
    8151         else if (r_cleanup_fsm.read() == CLEANUP_IXR_REQ)
    8152           r_alloc_trt_fsm = ALLOC_TRT_CLEANUP;
    8153       }
    8154       break;
     8021
    81558022  } // end switch alloc_trt_fsm
    81568023
     
    81648031  /////////////////////////////////////////////////////////////////////////////////////
    81658032
     8033//std::cout << std::endl << "alloc_heap_fsm" << std::endl;
     8034
    81668035  switch(r_alloc_heap_fsm.read())
    81678036  {
     
    83428211
    83438212  } // end switch alloc_heap_fsm
     8213
     8214//std::cout << std::endl << "fifo_update" << std::endl;
    83448215
    83458216  /////////////////////////////////////////////////////////////////////
     
    84358306  ////////////////////////////////////////////////////////////////////////////////////
    84368307
    8437   m_write_to_cc_send_inst_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,
     8308  m_write_to_cc_send_inst_fifo.update( write_to_cc_send_fifo_get,
     8309                                       write_to_cc_send_fifo_put,
    84388310                                       write_to_cc_send_fifo_inst );
    8439   m_write_to_cc_send_srcid_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,
     8311  m_write_to_cc_send_srcid_fifo.update( write_to_cc_send_fifo_get,
     8312                                        write_to_cc_send_fifo_put,
    84408313                                        write_to_cc_send_fifo_srcid );
    8441 #if L1_MULTI_CACHE
    8442   m_write_to_cc_send_cache_id_fifo.update( write_to_cc_send_fifo_get, write_to_cc_send_fifo_put,
    8443                                            write_to_cc_send_fifo_cache_id );
    8444 #endif
    84458314
    84468315  ////////////////////////////////////////////////////////////////////////////////////
     
    84488317  ////////////////////////////////////////////////////////////////////////////////////
    84498318
    8450   m_config_to_cc_send_inst_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,
     8319  m_config_to_cc_send_inst_fifo.update( config_to_cc_send_fifo_get,
     8320                                        config_to_cc_send_fifo_put,
    84518321                                        config_to_cc_send_fifo_inst );
    8452   m_config_to_cc_send_srcid_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,
     8322  m_config_to_cc_send_srcid_fifo.update( config_to_cc_send_fifo_get,
     8323                                         config_to_cc_send_fifo_put,
    84538324                                         config_to_cc_send_fifo_srcid );
    8454 #if L1_MULTI_CACHE
    8455   m_config_to_cc_send_cache_id_fifo.update( config_to_cc_send_fifo_get, config_to_cc_send_fifo_put,
    8456                                             config_to_cc_send_fifo_cache_id );
    8457 #endif
    84588325
    84598326  ////////////////////////////////////////////////////////////////////////////////////
     
    84618328  ////////////////////////////////////////////////////////////////////////////////////
    84628329
    8463   m_xram_rsp_to_cc_send_inst_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,
     8330  m_xram_rsp_to_cc_send_inst_fifo.update( xram_rsp_to_cc_send_fifo_get,
     8331                                          xram_rsp_to_cc_send_fifo_put,
    84648332                                          xram_rsp_to_cc_send_fifo_inst );
    8465   m_xram_rsp_to_cc_send_srcid_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,
     8333  m_xram_rsp_to_cc_send_srcid_fifo.update( xram_rsp_to_cc_send_fifo_get,
     8334                                           xram_rsp_to_cc_send_fifo_put,
    84668335                                           xram_rsp_to_cc_send_fifo_srcid );
    8467 #if L1_MULTI_CACHE
    8468   m_xram_rsp_to_cc_send_cache_id_fifo.update( xram_rsp_to_cc_send_fifo_get, xram_rsp_to_cc_send_fifo_put,
    8469                                               xram_rsp_to_cc_send_fifo_cache_id );
    8470 #endif
    84718336
    84728337  ////////////////////////////////////////////////////////////////////////////////////
     
    84748339  ////////////////////////////////////////////////////////////////////////////////////
    84758340
    8476   m_cas_to_cc_send_inst_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,
     8341  m_cas_to_cc_send_inst_fifo.update( cas_to_cc_send_fifo_get,
     8342                                     cas_to_cc_send_fifo_put,
    84778343                                     cas_to_cc_send_fifo_inst );
    8478   m_cas_to_cc_send_srcid_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,
     8344  m_cas_to_cc_send_srcid_fifo.update( cas_to_cc_send_fifo_get,
     8345                                      cas_to_cc_send_fifo_put,
    84798346                                      cas_to_cc_send_fifo_srcid );
    8480 #if L1_MULTI_CACHE
    8481   m_cas_to_cc_send_cache_id_fifo.update( cas_to_cc_send_fifo_get, cas_to_cc_send_fifo_put,
    8482                                          cas_to_cc_send_fifo_cache_id );
    8483 #endif
    8484 
    84858347  m_cpt_cycles++;
    84868348
     
    84958357  ////////////////////////////////////////////////////////////
    84968358
    8497   p_vci_ixr.be      = 0xFF;   // nor transmited to external ram
     8359  // DATA width is 8 bytes
     8360  // The following values are not transmitted to XRAM
     8361  //   p_vci_ixr.be
     8362  //   p_vci_ixr.pktid 
     8363  //   p_vci_ixr.cons
     8364  //   p_vci_ixr.wrap
     8365  //   p_vci_ixr.contig
     8366  //   p_vci_ixr.clen
     8367  //   p_vci_ixr.cfixed
     8368
     8369  p_vci_ixr.plen    = 64;
     8370  p_vci_ixr.srcid   = m_srcid_x;
     8371  p_vci_ixr.trdid   = r_ixr_cmd_trdid.read();
     8372  p_vci_ixr.address = (addr_t)r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2);
     8373  p_vci_ixr.be      = 0xFF;
    84988374  p_vci_ixr.pktid   = 0;
    8499   p_vci_ixr.srcid   = m_srcid_x;
    85008375  p_vci_ixr.cons    = false;
    85018376  p_vci_ixr.wrap    = false;
     
    85038378  p_vci_ixr.clen    = 0;
    85048379  p_vci_ixr.cfixed  = false;
    8505   p_vci_ixr.plen    = 64;
    8506 
    8507   if(r_ixr_cmd_fsm.read() == IXR_CMD_READ)
     8380
     8381  if ( (r_ixr_cmd_fsm.read() == IXR_CMD_READ_SEND) or
     8382       (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_SEND) or
     8383       (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_SEND) or
     8384       (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_SEND) or
     8385       (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_SEND) )
    85088386  {
    8509     p_vci_ixr.cmd       = vci_param_ext::CMD_READ;
    8510     p_vci_ixr.cmdval    = true;
    8511     p_vci_ixr.address   = (addr_t)(r_read_to_ixr_cmd_nline.read() * m_words * 4);
    8512     p_vci_ixr.wdata     = 0;
    8513     p_vci_ixr.trdid     = r_read_to_ixr_cmd_trdid.read();
    8514     p_vci_ixr.eop       = true;
     8387      p_vci_ixr.cmdval  = true;
     8388
     8389      if ( r_ixr_cmd_get.read() )  // GET
     8390      {
     8391          p_vci_ixr.cmd     = vci_param_ext::CMD_READ;
     8392          p_vci_ixr.wdata   = 0;
     8393          p_vci_ixr.eop     = true;
     8394      }
     8395      else                         // PUT
     8396      {
     8397          size_t word       = r_ixr_cmd_word.read();
     8398          p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
     8399          p_vci_ixr.wdata   = ((wide_data_t)(r_ixr_cmd_wdata[word].read()))  |
     8400                              ((wide_data_t)(r_ixr_cmd_wdata[word+1].read()) << 32);
     8401          p_vci_ixr.eop     = (word == (m_words-2));
     8402      }
    85158403  }
    8516   else if(r_ixr_cmd_fsm.read() == IXR_CMD_CAS)
    8517   {
    8518     if(r_cas_to_ixr_cmd_write.read())
    8519     {
    8520       size_t word       = r_ixr_cmd_cpt.read();
    8521       p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
    8522       p_vci_ixr.cmdval  = true;
    8523       p_vci_ixr.address = (addr_t)( (r_cas_to_ixr_cmd_nline.read() * m_words + word) * 4 );
    8524       p_vci_ixr.wdata   = ((wide_data_t)(r_cas_to_ixr_cmd_data[word].read()))  |
    8525                           ((wide_data_t)(r_cas_to_ixr_cmd_data[word+1].read()) << 32);
    8526       p_vci_ixr.trdid   = r_cas_to_ixr_cmd_trdid.read();
    8527       p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-2));
    8528     }
    8529     else
    8530     {
    8531       p_vci_ixr.cmd     = vci_param_ext::CMD_READ;
    8532       p_vci_ixr.cmdval  = true;
    8533       p_vci_ixr.address = (addr_t)(r_cas_to_ixr_cmd_nline.read() *m_words*4);
    8534       p_vci_ixr.wdata   = 0;
    8535       p_vci_ixr.trdid   = r_cas_to_ixr_cmd_trdid.read();
    8536       p_vci_ixr.eop     = true;
    8537     }
    8538   }
    8539   else if(r_ixr_cmd_fsm.read() == IXR_CMD_WRITE)
    8540   {
    8541     if(r_write_to_ixr_cmd_write.read())
    8542     {
    8543       p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
    8544       p_vci_ixr.cmdval  = true;
    8545       p_vci_ixr.address = (addr_t)( (r_write_to_ixr_cmd_nline.read() * m_words +
    8546                                      r_ixr_cmd_cpt.read()) * 4 );
    8547       p_vci_ixr.wdata   = ((wide_data_t)(r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    8548                           ((wide_data_t)(r_write_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32));
    8549       p_vci_ixr.trdid   = r_write_to_ixr_cmd_trdid.read();
    8550       p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words-2));
    8551     }
    8552     else
    8553     {
    8554       p_vci_ixr.cmd     = vci_param_ext::CMD_READ;
    8555       p_vci_ixr.cmdval  = true;
    8556       p_vci_ixr.address = (addr_t)(r_write_to_ixr_cmd_nline.read() *m_words*4);
    8557       p_vci_ixr.wdata   = 0;
    8558       p_vci_ixr.trdid   = r_write_to_ixr_cmd_trdid.read();
    8559       p_vci_ixr.eop     = true;
    8560     }
    8561   }
    8562   else if(r_ixr_cmd_fsm.read() == IXR_CMD_XRAM)
    8563   {
    8564     p_vci_ixr.cmd       = vci_param_ext::CMD_WRITE;
    8565     p_vci_ixr.cmdval    = true;
    8566     p_vci_ixr.address   = (addr_t)( (r_xram_rsp_to_ixr_cmd_nline.read() * m_words +
    8567                                    r_ixr_cmd_cpt.read()) * 4 );
    8568     p_vci_ixr.wdata     = ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    8569                           ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()+1].read()) << 32));
    8570     p_vci_ixr.trdid     = r_xram_rsp_to_ixr_cmd_trdid.read();
    8571     p_vci_ixr.eop       = (r_ixr_cmd_cpt == (m_words-2));
    8572   }
    85738404  /*ODCCP*/
    8574   else if (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_DATA)
     8405  else if (r_ixr_cmd_fsm.read() == IXR_CMD_CLEANUP_DATA_SEND)
    85758406  {
    85768407    p_vci_ixr.cmd     = vci_param_ext::CMD_WRITE;
    85778408    p_vci_ixr.cmdval  = true;
     8409#if ODCCP_NON_INCLUSIVE
    85788410    p_vci_ixr.address = (addr_t)((r_cleanup_to_ixr_cmd_nline.read() * m_words +
    8579                                     r_ixr_cmd_cpt.read()) * 4);
    8580 #if ODCCP_NON_INCLUSIVE
    8581     p_vci_ixr.wdata   = ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    8582           ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read() + 1].read()) << 32));
     8411                                    r_ixr_cmd_word.read()) * 4);
     8412    p_vci_ixr.wdata   = ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_word.read()].read()) |
     8413          ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_word.read() + 1].read()) << 32));
    85838414#else
    8584     p_vci_ixr.wdata   = ((wide_data_t)(r_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    8585           ((wide_data_t)(r_ixr_cmd_data[r_ixr_cmd_cpt.read() + 1].read()) << 32));
     8415    /*p_vci_ixr.address = (addr_t)((r_cleanup_to_ixr_cmd_nline.read() * m_words +
     8416                                    r_ixr_cmd_word.read()) * 4);*/
     8417    p_vci_ixr.address = (addr_t)r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2);
     8418    p_vci_ixr.wdata   = ((wide_data_t)(r_ixr_cmd_wdata[r_ixr_cmd_word.read()].read()) |
     8419          ((wide_data_t)(r_ixr_cmd_wdata[r_ixr_cmd_word.read() + 1].read()) << 32));
    85868420#endif
    85878421   
    8588     /*
    8589     if(r_cleanup_to_ixr_cmd_l1_dirty_ncc.read()) // if cleanup data contains data, we use cleanup_data buffer (cleanup dirty)
    8590     {
    8591       p_vci_ixr.wdata   = ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    8592           ((wide_data_t)(r_cleanup_to_ixr_cmd_data[r_ixr_cmd_cpt.read() + 1].read()) << 32));
    8593     }
    8594     else // if cleanup data doesnt contain data, we use xram_rsp_data buffer (cleanup not dirty)
    8595     {
    8596       p_vci_ixr.wdata   = ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read()].read()) |
    8597           ((wide_data_t)(r_xram_rsp_to_ixr_cmd_data[r_ixr_cmd_cpt.read() + 1].read()) << 32));
    8598     }
    8599     */
    8600     p_vci_ixr.trdid   = r_cleanup_to_ixr_cmd_trdid.read();
    8601     p_vci_ixr.eop     = (r_ixr_cmd_cpt == (m_words - 2));
     8422    p_vci_ixr.trdid   = r_cleanup_to_ixr_cmd_index.read();
     8423    p_vci_ixr.eop     = (r_ixr_cmd_word == (m_words - 2));
    86028424  }
    86038425  else
    86048426  {
    8605     p_vci_ixr.cmdval    = false;
    8606     p_vci_ixr.cmd       = vci_param_ext::CMD_READ;
    8607     p_vci_ixr.address   = 0;
    8608     p_vci_ixr.wdata     = 0;
    8609     p_vci_ixr.trdid     = 0;
    8610     p_vci_ixr.eop       = false;
     8427      p_vci_ixr.cmdval = false;
    86118428  }
    86128429
     
    86158432  ////////////////////////////////////////////////////
    86168433
    8617   if(((r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP) and
    8618       (r_ixr_rsp_fsm.read()   == IXR_RSP_TRT_READ)) or
    8619       (r_ixr_rsp_fsm.read()   == IXR_RSP_ACK))
    8620 
    8621     p_vci_ixr.rspack = true;
    8622 
    8623   else
    8624     p_vci_ixr.rspack = false;
     8434  if( (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ) or
     8435      (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) )
     8436  {
     8437      p_vci_ixr.rspack = (r_alloc_trt_fsm.read() == ALLOC_TRT_IXR_RSP);
     8438  }
     8439  else if (r_ixr_rsp_fsm.read() == IXR_RSP_ACK)
     8440  {
     8441      p_vci_ixr.rspack = true;
     8442  }
     8443  else // r_ixr_rsp_fsm == IXR_RSP_IDLE
     8444  {
     8445      p_vci_ixr.rspack = false;
     8446  }
    86258447
    86268448  ////////////////////////////////////////////////////
     
    86888510      break;
    86898511    }
    8690 
    86918512    case TGT_RSP_TGT_CMD:
    86928513    {
    86938514      p_vci_tgt.rspval  = true;
    8694       p_vci_tgt.rdata   = 0;
     8515      p_vci_tgt.rdata   = r_tgt_cmd_to_tgt_rsp_rdata.read();
    86958516      p_vci_tgt.rsrcid  = r_tgt_cmd_to_tgt_rsp_srcid.read();
    86968517      p_vci_tgt.rtrdid  = r_tgt_cmd_to_tgt_rsp_trdid.read();
     
    87018522      break;
    87028523    }
    8703 
    87048524    case TGT_RSP_READ:
    87058525    {
     
    91969016  ////////////////////////////////////////////////////////////////////
    91979017
    9198   switch(r_cleanup_fsm.read())
     9018  if ( r_cleanup_fsm.read() == CLEANUP_SEND_CLACK )
    91999019  {
    9200     case CLEANUP_IDLE:
    9201     case CLEANUP_GET_NLINE:
    9202     case CLEANUP_DIR_REQ:
    9203     case CLEANUP_DIR_LOCK:
    9204     case CLEANUP_DIR_WRITE:
    9205     case CLEANUP_HEAP_REQ:
    9206     case CLEANUP_HEAP_LOCK:
    9207     case CLEANUP_HEAP_SEARCH:
    9208     case CLEANUP_HEAP_CLEAN:
    9209     case CLEANUP_HEAP_FREE:
    9210     case CLEANUP_IVT_LOCK:
    9211     case CLEANUP_IVT_DECREMENT:
    9212     case CLEANUP_IVT_CLEAR:
    9213     case CLEANUP_WRITE_RSP:
    9214     case CLEANUP_CONFIG_ACK:
     9020      uint8_t cleanup_ack_type;
     9021      if(r_cleanup_inst.read())
     9022      {
     9023          cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_INST;
     9024      }
     9025      else
     9026      {
     9027          cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_DATA;
     9028      }
     9029
     9030      uint64_t flit = 0;
     9031      uint64_t dest = r_cleanup_srcid.read() <<
     9032          (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
     9033
     9034      DspinDhccpParam::dspin_set(
     9035            flit,
     9036            dest,
     9037            DspinDhccpParam::CLACK_DEST);
     9038
     9039      DspinDhccpParam::dspin_set(
     9040            flit,
     9041            r_cleanup_nline.read() & 0xFFFF,
     9042            DspinDhccpParam::CLACK_SET);
     9043
     9044      DspinDhccpParam::dspin_set(
     9045            flit,
     9046            r_cleanup_way_index.read(),
     9047            DspinDhccpParam::CLACK_WAY);
     9048
     9049      DspinDhccpParam::dspin_set(
     9050            flit,
     9051            cleanup_ack_type,
     9052            DspinDhccpParam::CLACK_TYPE);
     9053
     9054      p_dspin_clack.eop   = true;
     9055      p_dspin_clack.write = true;
     9056      p_dspin_clack.data  = flit;
     9057  }
     9058  else
     9059  {
    92159060      p_dspin_clack.write = false;
    92169061      p_dspin_clack.eop   = false;
    92179062      p_dspin_clack.data  = 0;
    9218 
    9219       break;
    9220 
    9221     case CLEANUP_SEND_CLACK:
    9222       {
    9223         uint8_t cleanup_ack_type;
    9224         if(r_cleanup_inst.read())
    9225         {
    9226           cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_INST;
    9227         }
    9228         else
    9229         {
    9230           cleanup_ack_type = DspinDhccpParam::TYPE_CLACK_DATA;
    9231         }
    9232 
    9233         uint64_t flit = 0;
    9234         uint64_t dest =
    9235           r_cleanup_srcid.read() <<
    9236           (DspinDhccpParam::SRCID_WIDTH - vci_param_int::S);
    9237 
    9238         DspinDhccpParam::dspin_set(
    9239             flit,
    9240             dest,
    9241             DspinDhccpParam::CLACK_DEST);
    9242 
    9243         DspinDhccpParam::dspin_set(
    9244             flit,
    9245             r_cleanup_nline.read() & 0xFFFF,
    9246             DspinDhccpParam::CLACK_SET);
    9247 
    9248         DspinDhccpParam::dspin_set(
    9249             flit,
    9250             r_cleanup_way_index.read(),
    9251             DspinDhccpParam::CLACK_WAY);
    9252 
    9253         DspinDhccpParam::dspin_set(
    9254             flit,
    9255             cleanup_ack_type,
    9256             DspinDhccpParam::CLACK_TYPE);
    9257 
    9258         p_dspin_clack.eop   = true;
    9259         p_dspin_clack.write = true;
    9260         p_dspin_clack.data  = flit;
    9261       }
    9262       break;
    92639063  }
    92649064
  • branches/ODCCP/modules/vci_mem_cache/include/soclib/mem_cache.h

    r434 r494  
    3131{
    3232    MEMC_LOCK,
    33     MEMC_CMD_TYPE,
    3433    MEMC_ADDR_LO,
    3534    MEMC_ADDR_HI,
    36     MEMC_BUF_LENGTH
     35    MEMC_BUF_LENGTH,
     36    MEMC_CMD_TYPE
    3737};
    3838
Note: See TracChangeset for help on using the changeset viewer.