Ignore:
Timestamp:
Apr 14, 2014, 2:15:01 PM (10 years ago)
Author:
haoliu
Message:

MESI bug fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/MESI/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r676 r677  
    135135        "MULTI_ACK_HEAP_LOCK",
    136136        "MULTI_ACK_HEAP_WRITE",
    137         "MULTI_ACK_WAIT"
     137        "MULTI_ACK_IVT_CHANGE"
    138138    };
    139139    const char *config_fsm_str[] =
     
    11121112            r_tgt_cmd_to_tgt_rsp_req = false;
    11131113
     1114            r_read_to_cc_send_multi_req = false;
     1115            r_read_to_cc_send_brdcast_req = false;
    11141116            r_read_to_tgt_rsp_req = false;
    11151117            r_read_to_ixr_cmd_req = false;
    1116             r_read_to_cc_send_req = false;
    11171118            r_read_to_cleanup_req = false;
    11181119            r_read_to_multi_ack_req     = false;
     
    21552156                        if(not entry.count)
    21562157                        {
     2158                            r_multi_ack_fsm = MULTI_ACK_IVT_LOCK;
    21572159                            r_multi_ack_miss_updt = false;
    21582160                        }
    2159                         r_multi_ack_fsm = MULTI_ACK_WAIT;
     2161                        else
     2162                        {
     2163                            r_multi_ack_fsm = MULTI_ACK_IVT_CHANGE;
     2164                        }
    21602165                    }
    21612166                    else if( not entry.count or match_ll) // The line has been already evicted from cache L1
     
    21732178                }
    21742179                /////////////
    2175             case MULTI_ACK_WAIT:   // release all locks and retry from beginning
    2176                 {
    2177 
     2180            case MULTI_ACK_IVT_CHANGE:   // release all locks and retry from beginning
     2181                {                 
     2182                    if(r_alloc_ivt_fsm.read() != ALLOC_IVT_MULTI_ACK)  break;
     2183                   
     2184                    m_ivt.change(r_multi_ack_ivt_index.read());
    21782185#if DEBUG_MEMC_MULTI_ACK
    21792186                    if(m_debug)
    21802187                    {
    21812188                        std::cout << "  <MEMC " << name()
    2182                             << " MULTI_ACK_WAIT> Release all locks" << std::endl;
    2183                     }
    2184 #endif
    2185                     r_multi_ack_fsm = MULTI_ACK_IVT_LOCK;
     2189                            << " MULTI_ACK_IVT_CHANGE> multi ack miss, count is 1, change ivt state" << std::endl;
     2190                    }
     2191#endif
     2192                    r_multi_ack_fsm = MULTI_ACK_IDLE;
    21862193                    break;
    21872194                }
     
    32343241                            r_read_to_cc_send_brdcast_req   = not multi_req;
    32353242                            r_read_to_cc_send_nline         = nline;
    3236                             r_read_to_cc_send_srcid         = m_cmd_read_srcid_fifo.read();
    3237                             r_read_to_cc_send_is_shared     = r_read_state.read() == ENTRY_SHARED;
     3243                            //r_read_to_cc_send_srcid         = m_cmd_read_srcid_fifo.read();
     3244                            //r_read_to_cc_send_is_shared     = r_read_state.read() == ENTRY_SHARED;
    32383245
    32393246                            if(r_read_need_block.read())
     
    34423449                                                           false,             // multi_inval 
    34433450                                                           true,              // it needs a read response
    3444                                                            true,              // acknowledge required
     3451                                                           false,              // acknowledge required
    34453452                                                           m_cmd_read_srcid_fifo.read(),
    34463453                                                           m_cmd_read_trdid_fifo.read(),
     
    66356642                            << " CLEANUP_LOCKED_IVT_LOCK> :"
    66366643                            << "/ is_updt =" << m_ivt.is_update(index)
     6644                            << "/ is_change =" << m_ivt.is_change(index)
    66376645                            << "/ match =" << match_inval
    66386646                            << "/ need rsp  =" << m_ivt.need_rsp(index)
     
    66416649#endif
    66426650
    6643                         r_cleanup_locked_srcid    = m_ivt.srcid(index);
    6644                         r_cleanup_locked_trdid    = m_ivt.trdid(index);
    6645                         r_cleanup_locked_pktid    = m_ivt.pktid(index);
    6646                         r_cleanup_locked_index    = index;
    6647                         r_cleanup_locked_is_updt  = m_ivt.is_update(index);
    6648 
    6649                         if( not m_ivt.is_update(index))
    6650                         {
    6651                            r_cleanup_fsm = CLEANUP_LOCKED_IVT_DECREMENT;
     6651                        r_cleanup_locked_srcid      = m_ivt.srcid(index);
     6652                        r_cleanup_locked_trdid      = m_ivt.trdid(index);
     6653                        r_cleanup_locked_pktid      = m_ivt.pktid(index);
     6654                        r_cleanup_locked_index      = index;
     6655                        r_cleanup_locked_is_updt    = m_ivt.is_update(index);
     6656                        r_cleanup_locked_is_change  = m_ivt.is_change(index);
     6657
     6658                        if( m_ivt.is_update(index) and not m_ivt.is_change(index))
     6659                        {
     6660                            r_cleanup_fsm = CLEANUP_LOCKED_IVT_CLEAR;
    66526661                        }
    66536662                        else
    66546663                        {
    6655                             r_cleanup_fsm = CLEANUP_LOCKED_IVT_CLEAR;
     6664                            r_cleanup_fsm = CLEANUP_LOCKED_IVT_DECREMENT;
    66566665                        }
    66576666
     
    67056714                    size_t match_cas_multi_inval = r_cas_to_cleanup_req.read() and
    67066715                                                  (r_cas_to_cleanup_nline.read() == r_cleanup_nline.read());
     6716
     6717                    bool match_ll = ((r_cleanup_locked_pktid.read() & 0x07) == TYPE_LL);
    67076718                    DirectoryEntry  entry;
    67086719                    entry.is_cnt        = false;
    67096720                    entry.lock          = r_cleanup_lock.read();
    6710                     entry.dirty         = r_cleanup_dirty.read();
     6721                    entry.dirty         = r_cleanup_dirty.read() or r_cleanup_contains_data.read();
    67116722                    entry.tag           = r_cleanup_tag.read();
    67126723                    entry.ptr           = r_cleanup_ptr.read();
     
    67286739                    }
    67296740
    6730                     if(r_cleanup_locked_is_updt.read()) //cleanup req cross with multi ack rsp. here, just decrements the count and remains the state.
    6731                     {
     6741                    if(r_cleanup_locked_is_updt.read() and not r_cleanup_locked_is_change.read()) //cleanup req cross with multi ack rsp. here, just decrements the count and remains the state.
     6742                    {
     6743                        assert(r_cleanup_count.read() == 1 && " only one copy when cleanup fsm receives a req for is_updt command");
    67326744                        entry.state         = r_cleanup_state.read();  //cross with cc updt cmd, don't modify the state
    67336745                        entry.count         = 0;
     
    67356747                        entry.owner.inst    = 0;
    67366748                        r_cleanup_fsm       = CLEANUP_SEND_CLACK;
     6749                    }
     6750                    else if(r_cleanup_locked_is_updt.read() and r_cleanup_locked_is_change.read())
     6751                    {
     6752                        entry.state = ENTRY_SHARED;
     6753                        if(match_ll)
     6754                        {
     6755                            entry.count       = 0;
     6756                            entry.owner.srcid = 0;
     6757                        }
     6758                        else
     6759                        {
     6760                            entry.count       = 1;
     6761                            entry.owner.srcid = r_cleanup_locked_srcid.read();
     6762                        }
     6763
     6764                        if((r_cleanup_locked_pktid.read() & 0x7) == 0x03)
     6765                        {
     6766                            entry.owner.inst = true;
     6767                        }
     6768                        else
     6769                        {
     6770                            entry.owner.inst = false;
     6771                        }
     6772
     6773                        r_cleanup_fsm       = CLEANUP_LOCKED_RSP;
     6774                        m_ivt.clear(r_cleanup_locked_index.read());
    67376775                    }
    67386776                    else // cas, getm, one copy updated in dir
     
    67816819                    r_cleanup_to_tgt_rsp_nline   = r_cleanup_nline.read();
    67826820                   
    6783                     r_cleanup_to_tgt_rsp_pktid   = 0x8 + r_cleanup_locked_pktid.read(); // there is not a brdcast for cas operation. in cache L1, the line can be in M state
    6784                    
    6785                     if(r_read_to_cleanup_req.read() and (r_read_to_cleanup_nline.read() == r_cleanup_nline.read())) // rsp for LL or pheriph
     6821                    if(r_cleanup_locked_is_change.read() and r_cleanup_locked_is_updt.read())
     6822                    {
     6823                        r_cleanup_to_tgt_rsp_pktid   = r_cleanup_locked_pktid.read(); // rsp for is_updt in shared state
     6824                    }
     6825                    else
     6826                    {
     6827
     6828                        r_cleanup_to_tgt_rsp_pktid   = 0x8 + r_cleanup_locked_pktid.read(); // there is not a brdcast for cas operation. in cache L1, the line can be in M state
     6829                    }
     6830
     6831                    if(r_read_to_multi_ack_req.read() and (r_read_to_multi_ack_nline.read() == r_cleanup_nline.read()) and // rsp for LL or pheriph
     6832                      (r_cleanup_locked_is_change.read() and r_cleanup_locked_is_updt.read()))
     6833                    {
     6834                        r_cleanup_to_tgt_rsp_ll_key     = r_read_to_multi_ack_ll_key.read();
     6835                        r_cleanup_to_tgt_rsp_length     = r_read_to_multi_ack_length.read();
     6836                        r_cleanup_to_tgt_rsp_first_word = r_read_to_multi_ack_first_word.read();
     6837                        r_read_to_multi_ack_req           = false;
     6838                    }
     6839                    else if(r_read_to_cleanup_req.read() and (r_read_to_cleanup_nline.read() == r_cleanup_nline.read())) // rsp for LL or pheriph
    67866840                    {
    67876841                        r_cleanup_to_tgt_rsp_ll_key     = r_read_to_cleanup_ll_key.read();
     
    68206874                            << " <MEMC " << name()
    68216875                            << " CLEANUP_LOCKED_RSP>"
    6822                             << "type rsp =" << r_cleanup_locked_pktid.read()
    6823                             << "r_read_to_cleanup_req  =" << r_read_to_cleanup_req.read()
    6824                             << "r_read_to_cleanup_length  =" << r_read_to_cleanup_length.read()
    6825                             << "r_read_to_cleanup_first_word  =" << r_read_to_cleanup_first_word.read()
     6876                            << " type rsp =" << r_cleanup_locked_pktid.read()
     6877                            << " r_read_to_cleanup_req  =" << r_read_to_cleanup_req.read()
     6878                            << " r_read_to_cleanup_length  =" << r_read_to_cleanup_length.read()
     6879                            << " r_read_to_cleanup_first_word  =" << r_read_to_cleanup_first_word.read()
    68266880                            << std::endl;
    68276881                    }
     
    72677321                            }
    72687322                            //std::cout << "cleanup with a non coherent ligne in trt index = " << index << std::endl;
    7269                             r_cleanup_to_ixr_cmd_srcid        = r_cleanup_srcid.read();
     7323                            //r_cleanup_to_ixr_cmd_srcid        = r_cleanup_srcid.read();
    72707324                            r_cleanup_to_ixr_cmd_index        = index;
    7271                             r_cleanup_to_ixr_cmd_pktid        = r_cleanup_pktid.read();
    7272                             r_cleanup_to_ixr_cmd_nline        = r_cleanup_nline.read();
     7325                            //r_cleanup_to_ixr_cmd_pktid        = r_cleanup_pktid.read();
     7326                            //r_cleanup_to_ixr_cmd_nline        = r_cleanup_nline.read();
    72737327                            //r_cleanup_to_ixr_cmd_l1_dirty_ncc = r_cleanup_contains_data.read();
    72747328                            r_cleanup_fsm = CLEANUP_SEND_CLACK;
     
    98269880                        r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    98279881
    9828                     else if (r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK)
     9882                    else if ((r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK) or
     9883                            (r_multi_ack_fsm.read() == MULTI_ACK_IVT_CHANGE))
    98299884                        r_alloc_ivt_fsm = ALLOC_IVT_MULTI_ACK;
    98309885
     
    98539908                        r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    98549909
    9855                     else if (r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK)
     9910                    else if ((r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK) or
     9911                            (r_multi_ack_fsm.read() == MULTI_ACK_IVT_CHANGE))
    98569912                        r_alloc_ivt_fsm = ALLOC_IVT_MULTI_ACK;
    98579913
     
    98799935                        r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    98809936
    9881                     else if (r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK)
     9937                    else if ((r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK) or
     9938                            (r_multi_ack_fsm.read() == MULTI_ACK_IVT_CHANGE))
    98829939                        r_alloc_ivt_fsm = ALLOC_IVT_MULTI_ACK;
    98839940
     
    99089965                        r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    99099966
    9910                     else if (r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK)
     9967                    else if ((r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK) or
     9968                            (r_multi_ack_fsm.read() == MULTI_ACK_IVT_CHANGE))
    99119969                        r_alloc_ivt_fsm = ALLOC_IVT_MULTI_ACK;
    99129970
     
    99349992                        r_alloc_ivt_fsm = ALLOC_IVT_CONFIG;
    99359993
    9936                     else if (r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK)
     9994                    else if ((r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK) or
     9995                            (r_multi_ack_fsm.read() == MULTI_ACK_IVT_CHANGE))
    99379996                        r_alloc_ivt_fsm = ALLOC_IVT_MULTI_ACK;
    99389997
     
    996010019                if (r_config_fsm.read() != CONFIG_IVT_LOCK)
    996110020                {
    9962                     if (r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK)
     10021                    if ((r_multi_ack_fsm.read() == MULTI_ACK_IVT_LOCK) or
     10022                            (r_multi_ack_fsm.read() == MULTI_ACK_IVT_CHANGE))
    996310023                        r_alloc_ivt_fsm = ALLOC_IVT_MULTI_ACK;
    996410024
     
    998710047                //////////////////////////
    998810048            case ALLOC_IVT_MULTI_ACK:           // allocated to MULTI ACK FSM
    9989                 if (r_multi_ack_fsm.read() != MULTI_ACK_IVT_LOCK)
     10049                if ((r_multi_ack_fsm.read() != MULTI_ACK_IVT_LOCK) and
     10050                    (r_multi_ack_fsm.read() != MULTI_ACK_IVT_CHANGE))
    999010051                {
    999110052                    if ((r_write_fsm.read() == WRITE_INVAL_IVT_LOCK))
     
    1151711578
    1151811579                    DspinDhccpParam::dspin_set( flit,
    11519                             m_cc_global_id + 0xff,
     11580                            m_cc_global_id,
    1152011581                            DspinDhccpParam::BROADCAST_SRCID);
    1152111582
     
    1153911600
    1154011601                    DspinDhccpParam::dspin_set( flit,
    11541                             m_cc_global_id + 0xff,
     11602                            m_cc_global_id,
    1154211603                            DspinDhccpParam::BROADCAST_SRCID);
    1154311604
     
    1155811619                            DspinDhccpParam::BROADCAST_BOX);
    1155911620
    11560                     DspinDhccpParam::dspin_set( flit,
    11561                             r_read_to_cc_send_srcid.read(),    // send the srcid itself which demands the request getM
    11562                             DspinDhccpParam::BROADCAST_SRCID);
    11563 
    11564                     DspinDhccpParam::dspin_set( flit,
    11565                             r_read_to_cc_send_is_shared.read(),    // send the actuel line state in memcache
    11566                             DspinDhccpParam::BRDCAST_IS_SHARED);
     11621                   // DspinDhccpParam::dspin_set( flit,
     11622                   //         r_read_to_cc_send_srcid.read(),    // send the srcid itself which demands the request getM
     11623                   //         DspinDhccpParam::BROADCAST_SRCID);
     11624
     11625                   // DspinDhccpParam::dspin_set( flit,
     11626                   //         r_read_to_cc_send_is_shared.read(),    // send the actuel line state in memcache
     11627                   //         DspinDhccpParam::BRDCAST_IS_SHARED);
    1156711628
    1156811629                    DspinDhccpParam::dspin_set( flit,
Note: See TracChangeset for help on using the changeset viewer.