Changeset 223 for trunk/modules


Ignore:
Timestamp:
Mar 29, 2012, 6:43:02 PM (12 years ago)
Author:
alain
Message:

Fixing a bub in SC_FSM: The write was done too sytematically in the SC_DIR_HIT_WRITE
state: The actual cache update is done now in three states: DIR_HIT_WRITE (if no CC transactions)
in SC_UPT_LOCK in case of CC_UPDATE, and in SC_BC_UPT_LOCK states in case of SC_BROADCAST.
Because we want to be sur that the SC will be completed (no retry in WAITstate) before updating the cache

File:
1 edited

Legend:

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

    r222 r223  
    17331733if( m_debug_write_fsm )
    17341734{
    1735     if( r_write_is_cnt.read() && r_write_count.read() )
    1736     {
    1737         std::cout << "  <MEMC.WRITE_DIR_READ> Read the cache to complete local buffer /"
    1738                   << " coherence broadcast required" << std::endl;
    1739     }
    1740     else
    1741     {
    1742         std::cout << "  <MEMC.WRITE_DIR_READ> Read the cache to complete local buffer"
    1743                   << std::endl;
    1744     }
     1735    std::cout << "  <MEMC.WRITE_DIR_READ> Read the cache to complete local buffer" << std::endl;
    17451736}
    17461737#endif
     
    18001791            }
    18011792
    1802             if ( owner )   r_write_count = r_write_count.read() - 1;
     1793            if ( owner and not no_update )   r_write_count = r_write_count.read() - 1;
    18031794
    18041795            if ( no_update )      // Write transaction completed
     
    18251816        std::cout << "  <MEMC.WRITE_DIR_HIT> Coherence update required:"
    18261817                  << " is_cnt = " << r_write_is_cnt.read()
    1827                   << " count = " << std::dec << r_write_count.read()
    1828                   << std::endl;
     1818                  << " nb_copies = " << std::dec << r_write_count.read() << std::endl;
     1819        if (owner)
     1820        std::cout << "       ... but the first copy is the writer" << std::endl;
    18291821    }
    18301822}
     
    18921884            break;
    18931885        }
    1894         /////////////////////
     1886        /////////////////////////
    18951887        case WRITE_UPT_HEAP_LOCK:   // get access to heap
    18961888        {
     
    19091901        }
    19101902        //////////////////
    1911         case WRITE_UPT_REQ:     //  prepare the request to INIT_CMD FSM
    1912                                 //  and write the first srcid in the FIFO
     1903        case WRITE_UPT_REQ:     //  prepare the coherence ransaction for the INIT_CMD FSM
     1904                                //  and write the first copy in the FIFO
    19131905                                //  send the request if only one copy
    19141906        {
     
    19581950                    r_write_to_dec = false;
    19591951                }
     1952
     1953#if DEBUG_MEMC_WRITE
     1954if( m_debug_write_fsm )
     1955{
     1956    std::cout << "  <MEMC.WRITE_UPT_REQ> Post first request to INIT_CMD FSM"
     1957              << " / srcid = " << r_write_copy.read()
     1958              << " / inst = "  << r_write_copy_inst.read() << std::endl;
     1959    if ( r_write_count.read() == 1)
     1960    std::cout << "         ... and this is the last" << std::endl;
     1961}
     1962#endif
    19601963            }
    19611964            break;
     
    19731976            HeapEntry entry = m_heap.read(r_write_ptr.read());
    19741977         
    1975             bool dec_upt_counter; // = r_write_to_dec.read();
     1978            bool dec_upt_counter;
    19761979
    19771980            if( (entry.owner.srcid != r_write_srcid.read()) or
     
    19791982                (entry.owner.cache_id != r_write_pktid.read()) or
    19801983#endif
    1981                 entry.owner.inst)   // put te next srcid in the fifo
     1984                entry.owner.inst)               // put te next srcid in the fifo
    19821985            {
    19831986                dec_upt_counter                 = false;
     
    19881991                write_to_init_cmd_fifo_cache_id = entry.owner.cache_id;
    19891992#endif
     1993
     1994#if DEBUG_MEMC_WRITE
     1995if( m_debug_write_fsm )
     1996{
     1997    std::cout << "  <MEMC.WRITE_UPT_NEXT> Post another request to INIT_CMD FSM"
     1998              << " / heap_index = " << std::dec << r_write_ptr.read()
     1999              << " / srcid = " << r_write_copy.read()
     2000              << " / inst = "  << r_write_copy_inst.read() << std::endl;
     2001    if( entry.next == r_write_ptr.read() )
     2002    std::cout << "        ... and this is the last" << std::endl;
     2003}
     2004#endif
    19902005            }
    1991             else                    // the UPT counter must be decremented
     2006            else                                // the UPT counter must be decremented
    19922007            {
    19932008                dec_upt_counter = true;
     2009
     2010#if DEBUG_MEMC_WRITE
     2011if( m_debug_write_fsm )
     2012{
     2013    std::cout << "  <MEMC.WRITE_UPT_NEXT> Skip one entry in heap matching the writer"
     2014              << " / heap_index = " << std::dec << r_write_ptr.read()
     2015              << " / srcid = " << r_write_copy.read()
     2016              << " / inst = "  << r_write_copy_inst.read() << std::endl;
     2017    if( entry.next == r_write_ptr.read() )
     2018    std::cout << "        ... and this is the last" << std::endl;
     2019}
     2020#endif
    19942021            }
    19952022
     
    20002027            {
    20012028                std::cout << "VCI_MEM_CACHE ERROR " << name() << " WRITE_UPT_NEXT state" << std::endl
    2002                           << "The write_to_cmd_write_fifo should not be full" << std::endl
     2029                          << "The write_to_init_cmd_fifo should not be full" << std::endl
    20032030                          << "as the depth should be larger than the max number of copies" << std::endl;
    20042031                exit(0);
     
    39393966        }
    39403967        //////////////////////
    3941         case SC_DIR_HIT_WRITE:          // write data in the cache
    3942                                     // and test if a coherence request is required
    3943         {
    3944             size_t way  = r_sc_way.read();
    3945             size_t set  = m_y[(vci_addr_t)(m_cmd_sc_addr_fifo.read())];
    3946             size_t word = m_x[(vci_addr_t)(m_cmd_sc_addr_fifo.read())];
    3947 
    3948             // cache update
    3949             m_cache_data[way][set][word] = r_sc_wdata.read();
    3950             if(r_sc_cpt.read()==4)
    3951                 m_cache_data[way][set][word+1] = m_cmd_sc_wdata_fifo.read();
    3952 
    3953             // monitor
    3954             if ( m_monitor_ok )
    3955             {
    3956                 vci_addr_t address = m_cmd_sc_addr_fifo.read();
    3957                 char buf[80];
    3958                 snprintf(buf, 80, "SC_DIR_HIT_WRITE srcid %d", m_cmd_sc_srcid_fifo.read());
    3959                 check_monitor( buf, address, r_sc_wdata.read() );
    3960                 if ( r_sc_cpt.read()==4 )
    3961                     check_monitor( buf, address+4, m_cmd_sc_wdata_fifo.read() );
    3962             }
    3963 
     3968        case SC_DIR_HIT_WRITE:          // test if a CC transaction is required
     3969                                    // write data in cache if no CC request
     3970        {
    39643971            // test coherence request
    39653972            if(r_sc_count.read())   // replicated line
     
    39813988            else                    // no copies
    39823989            {
     3990                size_t way      = r_sc_way.read();
     3991                size_t set      = m_y[(vci_addr_t)(m_cmd_sc_addr_fifo.read())];
     3992                size_t word     = m_x[(vci_addr_t)(m_cmd_sc_addr_fifo.read())];
     3993
     3994                // cache update
     3995                m_cache_data[way][set][word] = r_sc_wdata.read();
     3996                if(r_sc_cpt.read()==4)
     3997                    m_cache_data[way][set][word+1] = m_cmd_sc_wdata_fifo.read();
     3998
     3999                // monitor
     4000                if ( m_monitor_ok )
     4001                {
     4002                    vci_addr_t address = m_cmd_sc_addr_fifo.read();
     4003                            char buf[80];
     4004                            snprintf(buf, 80, "SC_DIR_HIT_WRITE srcid %d", m_cmd_sc_srcid_fifo.read());
     4005                    check_monitor( buf, address, r_sc_wdata.read() );
     4006                    if ( r_sc_cpt.read()==4 )
     4007                    check_monitor( buf, address+4, m_cmd_sc_wdata_fifo.read() );
     4008                }
    39834009                r_sc_fsm = SC_RSP_SUCCESS;
    3984             }
    39854010
    39864011#if DEBUG_MEMC_SC
     
    39954020}
    39964021#endif
     4022            }
    39974023            break;
    39984024        }
    39994025        /////////////////
    4000         case SC_UPT_LOCK:  //  register the transaction in UPT
     4026        case SC_UPT_LOCK:  // try to register the transaction in UPT
     4027                           // and write data in cache if successful registration
     4028                           // releases locks to retry later if UPT full
    40014029        {
    40024030            if ( r_alloc_upt_fsm.read() == ALLOC_UPT_SC )
     
    40214049                if (wok)  // coherence transaction registered in UPT
    40224050                {
     4051                    // cache update
     4052                    size_t way  = r_sc_way.read();
     4053                    size_t set  = m_y[(vci_addr_t)(m_cmd_sc_addr_fifo.read())];
     4054                    size_t word = m_x[(vci_addr_t)(m_cmd_sc_addr_fifo.read())];
     4055
     4056                    m_cache_data[way][set][word] = r_sc_wdata.read();
     4057                    if(r_sc_cpt.read()==4)
     4058                        m_cache_data[way][set][word+1] = m_cmd_sc_wdata_fifo.read();
     4059
     4060                    // monitor
     4061                    if ( m_monitor_ok )
     4062                    {
     4063                        vci_addr_t address = m_cmd_sc_addr_fifo.read();
     4064                                char buf[80];
     4065                                snprintf(buf, 80, "SC_DIR_HIT_WRITE srcid %d", m_cmd_sc_srcid_fifo.read());
     4066                        check_monitor( buf, address, r_sc_wdata.read() );
     4067                        if ( r_sc_cpt.read()==4 )
     4068                        check_monitor( buf, address+4, m_cmd_sc_wdata_fifo.read() );
     4069                    }
     4070
    40234071                    r_sc_upt_index = index;
    40244072                    r_sc_fsm = SC_UPT_HEAP_LOCK;
    40254073                }
    4026                 else       //  releases the locks protecting UPT and DIR if no entry
     4074                else       //  releases the locks protecting UPT and DIR UPT full
    40274075                {
    40284076                    r_sc_fsm = SC_WAIT;
     
    42134261        }
    42144262        ///////////////////
    4215         case SC_BC_UPT_LOCK:  // Register a broadcast inval transaction in UPT
     4263        case SC_BC_UPT_LOCK:  // register a broadcast inval transaction in UPT
     4264                              // write data in cache in case of successful registration
    42164265        {
    42174266            if ( r_alloc_upt_fsm.read() == ALLOC_UPT_SC )
     
    42384287                if ( wok )      // UPT not full
    42394288                {
     4289                    // cache update
     4290                    size_t way  = r_sc_way.read();
     4291                    size_t set  = m_y[(vci_addr_t)(m_cmd_sc_addr_fifo.read())];
     4292                    size_t word = m_x[(vci_addr_t)(m_cmd_sc_addr_fifo.read())];
     4293
     4294                    m_cache_data[way][set][word] = r_sc_wdata.read();
     4295                    if(r_sc_cpt.read()==4)
     4296                        m_cache_data[way][set][word+1] = m_cmd_sc_wdata_fifo.read();
     4297
     4298                    // monitor
     4299                    if ( m_monitor_ok )
     4300                    {
     4301                        vci_addr_t address = m_cmd_sc_addr_fifo.read();
     4302                                char buf[80];
     4303                                snprintf(buf, 80, "SC_DIR_HIT_WRITE srcid %d", m_cmd_sc_srcid_fifo.read());
     4304                        check_monitor( buf, address, r_sc_wdata.read() );
     4305                        if ( r_sc_cpt.read()==4 )
     4306                        check_monitor( buf, address+4, m_cmd_sc_wdata_fifo.read() );
     4307                    }
    42404308                    r_sc_upt_index = index;
    42414309                    r_sc_fsm = SC_BC_DIR_INVAL;
Note: See TracChangeset for help on using the changeset viewer.