Ignore:
Timestamp:
Jul 29, 2013, 11:31:38 AM (11 years ago)
Author:
devigne
Message:

Merge with the lastest version of Trunk
Modification in vci_mem_cache : Using TRT's wdata field for
put request to ixr_cmd (just for INCLUSIVE mode)

Location:
branches/ODCCP/modules/vci_cc_vcache_wrapper
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/ODCCP/modules/vci_cc_vcache_wrapper

  • branches/ODCCP/modules/vci_cc_vcache_wrapper/caba/metadata/vci_cc_vcache_wrapper.sd

    r421 r479  
    3737            ports = [
    3838            Port('caba:vci_initiator', 'p_vci'),
    39             Port('caba:dspin_input', 'p_dspin_in',
     39            Port('caba:dspin_input', 'p_dspin_m2p',
    4040                  dspin_data_size = parameter.Reference('dspin_in_width')),
    41             Port('caba:dspin_output', 'p_dspin_out',
     41            Port('caba:dspin_output', 'p_dspin_p2m',
    4242                  dspin_data_size = parameter.Reference('dspin_out_width')),
     43            Port('caba:dspin_input', 'p_dspin_clack',
     44                  dspin_data_size = parameter.Reference('dspin_in_width')),
    4345                Port('caba:bit_in','p_irq', parameter.Constant('n_irq')),
    4446                Port('caba:bit_in', 'p_resetn', auto = 'resetn'),
  • branches/ODCCP/modules/vci_cc_vcache_wrapper/caba/source/include/vci_cc_vcache_wrapper.h

    r460 r479  
    8989        // handling coherence requests
    9090        ICACHE_CC_CHECK,
     91        ICACHE_CC_UPDT,
    9192        ICACHE_CC_INVAL,
    92         ICACHE_CC_UPDT,
    93         ICACHE_CC_BROADCAST,
    94         ICACHE_CC_SEND_WAIT,
    9593    };
    9694
     
    141139        // handling coherence requests
    142140        DCACHE_CC_CHECK,
     141        DCACHE_CC_UPDT,
     142        DCACHE_CC_INVAL,
    143143        DCACHE_CC_INVAL_DATA,
    144         DCACHE_CC_INVAL,
    145         DCACHE_CC_UPDT,
    146         DCACHE_CC_BROADCAST,
    147         DCACHE_CC_SEND_WAIT,
    148144        // handling TLB inval (after a coherence or XTN request)
    149145        DCACHE_INVAL_TLB_SCAN,
     
    177173    {
    178174        CC_RECEIVE_IDLE,
    179         CC_RECEIVE_CLACK,
    180175        CC_RECEIVE_BRDCAST_HEADER,
    181176        CC_RECEIVE_BRDCAST_NLINE,
    182         CC_RECEIVE_INVAL_HEADER,
    183         CC_RECEIVE_INVAL_NLINE,
    184         CC_RECEIVE_UPDT_HEADER,
    185         CC_RECEIVE_UPDT_NLINE,
    186         CC_RECEIVE_UPDT_DATA,
     177        CC_RECEIVE_INS_INVAL_HEADER,
     178        CC_RECEIVE_INS_INVAL_NLINE,
     179        CC_RECEIVE_INS_UPDT_HEADER,
     180        CC_RECEIVE_INS_UPDT_NLINE,
     181        CC_RECEIVE_INS_UPDT_DATA,
     182        CC_RECEIVE_DATA_INVAL_HEADER,
     183        CC_RECEIVE_DATA_INVAL_NLINE,
     184        CC_RECEIVE_DATA_UPDT_HEADER,
     185        CC_RECEIVE_DATA_UPDT_NLINE,
     186        CC_RECEIVE_DATA_UPDT_DATA,
    187187    };
    188188
     
    301301
    302302public:
    303     sc_in<bool>                                 p_clk;
    304     sc_in<bool>                                 p_resetn;
    305     sc_in<bool>                                 p_irq[iss_t::n_irq];
    306     soclib::caba::VciInitiator<vci_param>       p_vci;
    307     soclib::caba::DspinInput <dspin_in_width>   p_dspin_in;
    308     soclib::caba::DspinOutput<dspin_out_width>  p_dspin_out;
     303    sc_in<bool>                                p_clk;
     304    sc_in<bool>                                p_resetn;
     305    sc_in<bool>                                p_irq[iss_t::n_irq];
     306    soclib::caba::VciInitiator<vci_param>      p_vci;
     307    soclib::caba::DspinInput<dspin_in_width>   p_dspin_m2p;
     308    soclib::caba::DspinOutput<dspin_out_width> p_dspin_p2m;
     309    soclib::caba::DspinInput<dspin_in_width>   p_dspin_clack;
    309310
    310311private:
     
    387388    sc_signal<bool>         r_icache_cc_need_write;     // activate the cache for writing
    388389
     390    // coherence clack handling
     391    sc_signal<bool>         r_icache_clack_req;         // clack request
     392    sc_signal<size_t>       r_icache_clack_way;             // clack way
     393    sc_signal<size_t>       r_icache_clack_set;             // clack set
     394
    389395    // icache flush handling
    390396    sc_signal<size_t>       r_icache_flush_count;           // slot counter used for cache flush
     
    459465    sc_signal<size_t>       r_dcache_cc_word;               // word counter for cc update
    460466    sc_signal<bool>         r_dcache_cc_need_write;     // activate the cache for writing
     467
     468    // coherence clack handling
     469    sc_signal<bool>         r_dcache_clack_req;         // clack request
     470    sc_signal<size_t>       r_dcache_clack_way;             // clack way
     471    sc_signal<size_t>       r_dcache_clack_set;             // clack set
    461472
    462473    // dcache flush handling
     
    586597    sc_signal<paddr_t>      r_cc_receive_dcache_nline;      // cache line physical address
    587598
     599    ///////////////////////////////////
     600    //  DSPIN CLACK INTERFACE REGISTER
     601    ///////////////////////////////////
     602    sc_signal<bool>         r_dspin_clack_req;
     603    sc_signal<uint64_t>     r_dspin_clack_flit;
     604   
    588605    //////////////////////////////////////////////////////////////////
    589606    // processor, write buffer, caches , TLBs
  • branches/ODCCP/modules/vci_cc_vcache_wrapper/caba/source/src/vci_cc_vcache_wrapper.cpp

    r460 r479  
    6565
    6666        "ICACHE_CC_CHECK",
     67        "ICACHE_CC_UPDT",
    6768        "ICACHE_CC_INVAL",
    68         "ICACHE_CC_UPDT",
    69         "ICACHE_CC_BROADCAST",
    70         "ICACHE_CC_SEND_WAIT",
    7169    };
    7270
     
    116114
    117115        "DCACHE_CC_CHECK",
     116        "DCACHE_CC_UPDT",
     117        "DCACHE_CC_INVAL",
    118118        "DCACHE_CC_INVAL_DATA",
    119         "DCACHE_CC_INVAL",
    120         "DCACHE_CC_UPDT",
    121         "DCACHE_CC_BROADCAST",
    122         "DCACHE_CC_SEND_WAIT",
    123119
    124120        "DCACHE_INVAL_TLB_SCAN",
     
    167163const char *cc_receive_fsm_state_str[] = {
    168164        "CC_RECEIVE_IDLE",
    169         "CC_RECEIVE_CLACK",
    170165        "CC_RECEIVE_BRDCAST_HEADER",
    171166        "CC_RECEIVE_BRDCAST_NLINE",
    172         "CC_RECEIVE_INVAL_HEADER",
    173         "CC_RECEIVE_INVAL_NLINE",
    174         "CC_RECEIVE_UPDT_HEADER",
    175         "CC_RECEIVE_UPDT_NLINE",
    176         "CC_RECEIVE_UPDT_DATA",
     167        "CC_RECEIVE_INS_INVAL_HEADER",
     168        "CC_RECEIVE_INS_INVAL_NLINE",
     169        "CC_RECEIVE_INS_UPDT_HEADER",
     170        "CC_RECEIVE_INS_UPDT_NLINE",
     171        "CC_RECEIVE_INS_UPDT_DATA",
     172        "CC_RECEIVE_DATA_INVAL_HEADER",
     173        "CC_RECEIVE_DATA_INVAL_NLINE",
     174        "CC_RECEIVE_DATA_UPDT_HEADER",
     175        "CC_RECEIVE_DATA_UPDT_NLINE",
     176        "CC_RECEIVE_DATA_UPDT_DATA",
    177177    };
    178178
     
    224224      p_resetn("p_resetn"),
    225225      p_vci("p_vci"),
    226       p_dspin_in("p_dspin_in"),
    227       p_dspin_out("p_dspin_out"),
     226      p_dspin_m2p("p_dspin_m2p"),
     227      p_dspin_p2m("p_dspin_p2m"),
     228      p_dspin_clack("p_dspin_clack"),
    228229
    229230      m_cacheability_table( mtd.getCacheabilityTable() ),
     
    792793        r_icache_cc_send_req       = false;
    793794
     795        r_icache_clack_req         = false;
     796
    794797        // No pending write in pipeline
    795798        r_dcache_wbuf_req          = false;
     
    812815        r_dcache_cc_send_req       = false;
    813816
     817        r_dcache_clack_req         = false;
     818
    814819        // No request from CC_RECEIVE FSM to ICACHE/DCACHE FSMs
    815820        r_cc_receive_icache_req    = false;
     
    826831        r_icache_miss_inval        = false;
    827832        r_dcache_miss_inval        = false;
     833
     834        r_dspin_clack_req          = false;
    828835
    829836        // No signalisation  of errors
     
    10771084                        // 5/ uncacheable read miss                     => ICACHE_UNC_REQ
    10781085    {
     1086        // coherence clack interrupt
     1087        if ( r_icache_clack_req.read() )
     1088        {
     1089            r_icache_fsm = ICACHE_CC_CHECK;
     1090            r_icache_fsm_save = r_icache_fsm.read();
     1091            break;
     1092        }
     1093
    10791094        // coherence interrupt
    10801095        if ( r_cc_receive_icache_req.read())
     
    13061321                            // external coherence request are accepted in this state.
    13071322    {
     1323        // coherence clack interrupt
     1324        if ( r_icache_clack_req.read() )
     1325        {
     1326            r_icache_fsm = ICACHE_CC_CHECK;
     1327            r_icache_fsm_save = r_icache_fsm.read();
     1328            break;
     1329        }
     1330
    13081331        // coherence interrupt
    13091332        if ( r_cc_receive_icache_req.read() )
     
    13501373                                        // A cleanup request is generated for each valid line
    13511374    {
     1375        // coherence clack interrupt
     1376        if ( r_icache_clack_req.read() )
     1377        {
     1378            r_icache_fsm = ICACHE_CC_CHECK;
     1379            r_icache_fsm_save = r_icache_fsm.read();
     1380            break;
     1381        }
     1382
    13521383        // coherence request (from CC_RECEIVE FSM)
    13531384        if ( r_cc_receive_icache_req.read() )
     
    15481579    {
    15491580        if (m_ireq.valid) m_cost_ins_miss_frz++;
     1581
     1582        // coherence clack interrupt
     1583        if ( r_icache_clack_req.read() )
     1584        {
     1585            r_icache_fsm = ICACHE_CC_CHECK;
     1586            r_icache_fsm_save = r_icache_fsm.read();
     1587            break;
     1588        }
    15501589
    15511590        // coherence interrupt
     
    16381677        if (m_ireq.valid) m_cost_ins_miss_frz++;
    16391678
     1679        // coherence clack interrupt
     1680        if ( r_icache_clack_req.read() )
     1681        {
     1682            r_icache_fsm = ICACHE_CC_CHECK;
     1683            r_icache_fsm_save = r_icache_fsm.read();
     1684            break;
     1685        }
     1686
    16401687        // coherence interrupt
    16411688        if ( r_cc_receive_icache_req.read() )
     
    17091756        if ( m_ireq.valid ) m_cost_ins_miss_frz++;
    17101757
     1758        // coherence clack interrupt
     1759        if ( r_icache_clack_req.read() )
     1760        {
     1761            r_icache_fsm = ICACHE_CC_CHECK;
     1762            r_icache_fsm_save = r_icache_fsm.read();
     1763            break;
     1764        }
     1765
    17111766        // coherence interrupt
    17121767        if ( r_cc_receive_icache_req.read() )
     
    17801835    case ICACHE_UNC_WAIT:       // waiting a response to an uncacheable read from VCI_RSP FSM
    17811836    {
     1837        // coherence clack interrupt
     1838        if ( r_icache_clack_req.read() )
     1839        {
     1840            r_icache_fsm = ICACHE_CC_CHECK;
     1841            r_icache_fsm_save = r_icache_fsm.read();
     1842            break;
     1843        }
     1844
    17821845        // coherence interrupt
    17831846        if ( r_cc_receive_icache_req.read() )
     
    18201883        paddr_t  mask  = ~((m_icache_words<<2)-1);
    18211884
    1822         if (r_cc_receive_icache_type.read() == CC_TYPE_CLACK)
    1823                                 // We switch the directory slot to EMPTY state
    1824                             // and reset r_icache_miss_clack if the cleanup ack
    1825                             // is matching a pending miss
    1826         {
    1827 
    1828             if ( m_ireq.valid ) m_cost_ins_miss_frz++;
    1829 
    1830 #ifdef INSTRUMENTATION
    1831 m_cpt_icache_dir_write++;
    1832 #endif
    1833             r_icache.write_dir( 0,
    1834                                 r_cc_receive_icache_way.read(),
    1835                                 r_cc_receive_icache_set.read(),
    1836                                 CACHE_SLOT_STATE_EMPTY);
    1837 
    1838             if ( (r_icache_miss_set.read() == r_cc_receive_icache_set.read()) and
    1839                  (r_icache_miss_way.read() == r_cc_receive_icache_way.read()) )
    1840                     r_icache_miss_clack = false;
    1841 
    1842             r_icache_fsm = r_icache_fsm_save.read() ;
    1843             r_cc_receive_icache_req = false;
    1844 
    1845 #if DEBUG_ICACHE
    1846 if ( m_debug_activated )
    1847 {
    1848     std::cout << "  <PROC " << name()
    1849     << " ICACHE_CC_CHECK>  CC_TYPE_CLACK slot returns to empty state"
    1850     << " set = " << r_cc_receive_icache_set.read()
    1851     << " / way = " << r_cc_receive_icache_way.read() << std::endl;
    1852 }
    1853 #endif
    1854         }
    1855         else if( ((r_icache_fsm_save.read() == ICACHE_MISS_SELECT) or
    1856                  (r_icache_fsm_save.read() == ICACHE_MISS_WAIT) or
    1857                  (r_icache_fsm_save.read() == ICACHE_MISS_DIR_UPDT)) and
    1858                  ((r_icache_vci_paddr.read() & mask) == (paddr & mask)) ) // matching
     1885
     1886        // Match between MISS address and CC address
     1887        // note: In the same cycle we can handle a CLACK and a MISS match
     1888        // because the CLACK access the directory but the MISS match dont.
     1889        if (r_cc_receive_icache_req.read() and
     1890          ((r_icache_fsm_save.read() == ICACHE_MISS_SELECT  )  or
     1891           (r_icache_fsm_save.read() == ICACHE_MISS_WAIT    )  or
     1892           (r_icache_fsm_save.read() == ICACHE_MISS_DIR_UPDT)) and
     1893          ((r_icache_vci_paddr.read() & mask) == (paddr & mask)) ) // matching
    18591894        {
    18601895            // signaling the matching
     
    18671902                r_icache_fsm        = ICACHE_CC_UPDT;
    18681903                r_icache_cc_word    = r_cc_receive_word_idx.read();
     1904
    18691905                // just pop the fifo , don't write in icache
    18701906                r_icache_cc_need_write = false;
     
    18851921#endif
    18861922        }
    1887         else                                                                                        // no match
    1888         {
    1889             int         state = 0;
    1890             size_t          way = 0;
    1891             size_t          set = 0;
    1892             size_t          word = 0;
     1923
     1924        // CLACK handler
     1925        // We switch the directory slot to EMPTY state
     1926        // and reset r_icache_miss_clack if the cleanup ack
     1927        // is matching a pending miss.
     1928        if ( r_icache_clack_req.read() )
     1929        {
     1930
     1931            if ( m_ireq.valid ) m_cost_ins_miss_frz++;
    18931932
    18941933#ifdef INSTRUMENTATION
    1895 m_cpt_icache_dir_read++;
    1896 #endif
    1897             r_icache.read_dir(paddr,
    1898                               &state,
    1899                               &way,
    1900                               &set,
    1901                               &word);
    1902 
    1903             r_icache_cc_way = way;
    1904             r_icache_cc_set = set;
    1905 
    1906             if ( state == CACHE_SLOT_STATE_VALID_CC)            // hit
    1907             {
    1908                 // need to update the cache state
    1909                 r_icache_cc_need_write = true;
    1910                 if (r_cc_receive_icache_type.read() == CC_TYPE_UPDT)  // hit update
    1911                 {
    1912                     r_icache_fsm          = ICACHE_CC_UPDT;
    1913                     r_icache_cc_word      = r_cc_receive_word_idx.read();
    1914                 }
    1915                 else if (r_cc_receive_icache_type.read() == CC_TYPE_INVAL)   // hit inval
    1916                 {
    1917                     r_icache_fsm          = ICACHE_CC_INVAL;
    1918                 }
    1919                 else if (r_cc_receive_icache_type.read() == CC_TYPE_BRDCAST)  // hit broadcast
    1920                 {
    1921                     r_icache_fsm          = ICACHE_CC_BROADCAST;
    1922                 }
    1923             }
    1924             else                                      // miss
    1925             {
    1926                 // multicast acknowledgement required in case of update
    1927                 if(r_cc_receive_icache_type.read() == CC_TYPE_UPDT)
    1928                 {
    1929                     r_icache_fsm          = ICACHE_CC_UPDT;
    1930                     r_icache_cc_word      = r_cc_receive_word_idx.read();
    1931                     // just pop the fifo , don't write in icache
    1932                     r_icache_cc_need_write = false;
    1933                 }
    1934                 else // No response needed
    1935                 {
    1936                     r_cc_receive_icache_req = false;
    1937                     r_icache_fsm          = r_icache_fsm_save.read();
    1938                 }
    1939             }
    1940         }
    1941         break;
    1942     }
    1943     /////////////////////
    1944     case ICACHE_CC_INVAL:       // hit inval : switch slot to EMPTY state
    1945     {
     1934m_cpt_icache_dir_write++;
     1935#endif
     1936            r_icache.write_dir( 0,
     1937                                r_icache_clack_way.read(),
     1938                                r_icache_clack_set.read(),
     1939                                CACHE_SLOT_STATE_EMPTY);
     1940
     1941            if ( (r_icache_miss_set.read() == r_icache_clack_set.read()) and
     1942                 (r_icache_miss_way.read() == r_icache_clack_way.read()) )
     1943            {
     1944                r_icache_miss_clack = false;
     1945            }
     1946
     1947            r_icache_clack_req = false;
     1948
     1949            // return to cc_save state if no pending CC request
     1950            if ( not r_cc_receive_icache_req.read() )
     1951                r_icache_fsm = r_icache_fsm_save.read();
    19461952
    19471953#if DEBUG_ICACHE
     
    19491955{
    19501956    std::cout << "  <PROC " << name()
    1951               << " ICACHE_//CC_INVAL> slot returns to empty state"
    1952               << " set = " << r_icache_cc_set.read()
    1953               << " / way = " << r_icache_cc_way.read() << std::endl;
     1957        << " ICACHE_CC_CHECK>  CC_TYPE_CLACK slot returns to empty state"
     1958        << " set = " << r_icache_clack_set.read()
     1959        << " / way = " << r_icache_clack_way.read() << std::endl;
    19541960}
    19551961#endif
     1962
     1963            break;
     1964        }
     1965
     1966        // wait if pending request to CC_SEND. This way if there are pending
     1967        // CLACK they can be treated in this state and then a deadlock
     1968        // situation is avoided
     1969        if ( r_icache_cc_send_req.read() ) break;
     1970
     1971        // CC request handler
     1972
     1973        int             state = 0;
     1974        size_t      way = 0;
     1975        size_t      set = 0;
     1976        size_t      word = 0;
    19561977
    19571978#ifdef INSTRUMENTATION
    19581979m_cpt_icache_dir_read++;
    19591980#endif
    1960 
    1961             if (r_icache_cc_need_write.read())
    1962             {
    1963                 r_icache.write_dir( 0,
    1964                         r_icache_cc_way.read(),
    1965                         r_icache_cc_set.read(),
    1966                         CACHE_SLOT_STATE_EMPTY );
    1967                 // no need to write in the cache anymore
     1981        r_icache.read_dir(paddr,
     1982                          &state,
     1983                          &way,
     1984                          &set,
     1985                          &word);
     1986
     1987        r_icache_cc_way = way;
     1988        r_icache_cc_set = set;
     1989
     1990        if ( state == CACHE_SLOT_STATE_VALID_CC)            // hit
     1991        {
     1992            // need to update the cache state
     1993            if (r_cc_receive_icache_type.read() == CC_TYPE_UPDT)  // hit update
     1994            {
     1995                r_icache_cc_need_write = true;
     1996                r_icache_fsm           = ICACHE_CC_UPDT;
     1997                r_icache_cc_word       = r_cc_receive_word_idx.read();
     1998            }
     1999            else if ( r_cc_receive_icache_type.read() == CC_TYPE_INVAL ) // hit inval
     2000            {
     2001                r_icache_fsm           = ICACHE_CC_INVAL;
     2002            }
     2003        }
     2004        else                                      // miss
     2005        {
     2006            // multicast acknowledgement required in case of update
     2007            if(r_cc_receive_icache_type.read() == CC_TYPE_UPDT)
     2008            {
     2009                r_icache_fsm           = ICACHE_CC_UPDT;
     2010                r_icache_cc_word       = r_cc_receive_word_idx.read();
     2011
     2012                // just pop the fifo , don't write in icache
    19682013                r_icache_cc_need_write = false;
    19692014            }
    1970         // multicast acknowledgement
    1971         // send a request to cc_send_fsm
    1972         if(not r_icache_cc_send_req.read()) // cc_send is available
    1973         {
    1974             // coherence request completed
    1975             r_cc_receive_icache_req = false;
    1976             // request multicast acknowledgement
    1977             r_icache_cc_send_req = true;
    1978             r_icache_cc_send_nline = r_cc_receive_icache_nline.read();
    1979             r_icache_cc_send_updt_tab_idx = r_cc_receive_icache_updt_tab_idx.read();
    1980             r_icache_cc_send_type = CC_TYPE_MULTI_ACK;
    1981 
    1982             r_icache_fsm          = r_icache_fsm_save.read();
    1983         }
    1984         //else wait for previous cc_send request to be sent
     2015            else // No response needed
     2016            {
     2017                r_cc_receive_icache_req = false;
     2018                r_icache_fsm            = r_icache_fsm_save.read();
     2019            }
     2020        }
     2021        break;
     2022    }
     2023    /////////////////////
     2024    case ICACHE_CC_INVAL:       // hit inval : switch slot to ZOMBI state
     2025    {
     2026        assert (not r_icache_cc_send_req.read() &&
     2027                "ERROR in ICACHE_CC_INVAL: the r_icache_cc_send_req "
     2028                "must not be set");
     2029
     2030#ifdef INSTRUMENTATION
     2031m_cpt_icache_dir_read++;
     2032#endif
     2033
     2034        // Switch slot state to ZOMBI and send CLEANUP command
     2035        r_icache.write_dir( 0,
     2036                            r_icache_cc_way.read(),
     2037                            r_icache_cc_set.read(),
     2038                            CACHE_SLOT_STATE_ZOMBI );
     2039
     2040        // coherence request completed
     2041        r_icache_cc_send_req   = true;
     2042        r_icache_cc_send_nline = r_cc_receive_icache_nline.read();
     2043        r_icache_cc_send_way   = r_icache_cc_way.read();
     2044        r_icache_cc_send_type  = CC_TYPE_CLEANUP;
     2045
     2046        r_icache_fsm           = r_icache_fsm_save.read();
     2047
     2048#if DEBUG_ICACHE
     2049if ( m_debug_activated )
     2050{
     2051std::cout << "  <PROC " << name()
     2052          << " ICACHE_CC_INVAL> slot returns to ZOMBI state"
     2053          << " set = " << r_icache_cc_set.read()
     2054          << " / way = " << r_icache_cc_way.read() << std::endl;
     2055}
     2056#endif
     2057
    19852058        break;
    19862059    }
     
    19882061    case ICACHE_CC_UPDT:        // hit update : write one word per cycle
    19892062    {
     2063        assert (not r_icache_cc_send_req.read() &&
     2064                "ERROR in ICACHE_CC_UPDT: the r_icache_cc_send_req "
     2065                "must not be set");
     2066
     2067        if ( not r_cc_receive_updt_fifo_be.rok() ) break;
     2068
     2069
     2070        size_t  word  = r_icache_cc_word.read();
     2071        size_t  way   = r_icache_cc_way.read();
     2072        size_t  set   = r_icache_cc_set.read();
     2073
     2074        if (r_icache_cc_need_write.read())
     2075        {
     2076            r_icache.write( way,
     2077                            set,
     2078                            word,
     2079                            r_cc_receive_updt_fifo_data.read(),
     2080                            r_cc_receive_updt_fifo_be.read() );
     2081
     2082            r_icache_cc_word = word+1;
     2083
     2084#ifdef INSTRUMENTATION
     2085m_cpt_icache_data_write++;
     2086#endif
    19902087
    19912088#if DEBUG_ICACHE
     
    19992096}
    20002097#endif
    2001 
    2002 #ifdef INSTRUMENTATION
    2003 m_cpt_icache_data_write++;
    2004 #endif
    2005         size_t  word  = r_icache_cc_word.read();
    2006         size_t  way   = r_icache_cc_way.read();
    2007         size_t  set   = r_icache_cc_set.read();
    2008 
    2009         if (r_cc_receive_updt_fifo_be.rok())
    2010         {
    2011             if (r_icache_cc_need_write.read())
    2012             {
    2013                 r_icache.write( way,
    2014                                 set,
    2015                                 word,
    2016                                 r_cc_receive_updt_fifo_data.read(),
    2017                                 r_cc_receive_updt_fifo_be.read() );
    2018 
    2019                 r_icache_cc_word = word+1;
    2020             }
    2021             if ( r_cc_receive_updt_fifo_eop.read() )    // last word
    2022             {
     2098        }
     2099
     2100        if ( r_cc_receive_updt_fifo_eop.read() )        // last word
     2101        {
    20232102                // no need to write in the cache anymore
    2024                 r_icache_cc_need_write = false;
    2025                 // wait to send a request to cc_send_fsm
    2026                 if(not r_icache_cc_send_req.read()) // cc_send is available
    2027                 {
    2028                     //consume last flit
    2029                     cc_receive_updt_fifo_get  = true;
    2030                     // coherence request completed
    2031                     r_cc_receive_icache_req = false;
    2032                     // request multicast acknowledgement
    2033                     r_icache_cc_send_req = true;
    2034                     r_icache_cc_send_nline = r_cc_receive_icache_nline.read();
    2035                     r_icache_cc_send_updt_tab_idx = r_cc_receive_icache_updt_tab_idx.read();
    2036                     r_icache_cc_send_type = CC_TYPE_MULTI_ACK;
    2037 
    2038                     r_icache_fsm          = r_icache_fsm_save.read();
    2039                 }
    2040             }
    2041             else
    2042             {
    2043                 //consume fifo if not eop
    2044                 cc_receive_updt_fifo_get  = true;
    2045             }
    2046         }
     2103            r_icache_cc_need_write        = false;
     2104
     2105            // coherence request completed
     2106            r_cc_receive_icache_req       = false;
     2107
     2108            // request multicast acknowledgement
     2109            r_icache_cc_send_req          = true;
     2110            r_icache_cc_send_nline        = r_cc_receive_icache_nline.read();
     2111            r_icache_cc_send_updt_tab_idx = r_cc_receive_icache_updt_tab_idx.read();
     2112            r_icache_cc_send_type         = CC_TYPE_MULTI_ACK;
     2113
     2114            r_icache_fsm                  = r_icache_fsm_save.read();
     2115        }
     2116        //consume fifo if not eop
     2117        cc_receive_updt_fifo_get  = true;
     2118
    20472119        break;
    20482120    }
    2049     /////////////////////////
    2050     case ICACHE_CC_BROADCAST:  // hit broadcast : switch slot to ZOMBI state
    2051                                // and request a cleanup
    2052     {
    2053 
    2054 #if DEBUG_ICACHE
    2055 if ( m_debug_activated )
    2056 {
    2057     std::cout << "  <PROC " << name()
    2058               << " ICACHE_CC_BROADCAST > Slot goes to zombi state "
    2059               << " set = " << r_icache_cc_set.read()
    2060               << " / way = " << r_icache_cc_way.read() << std::endl;
    2061 }
    2062 #endif
    2063 
    2064 #ifdef INSTRUMENTATION
    2065 m_cpt_icache_dir_write++;
    2066 #endif
    2067        if (r_icache_cc_need_write.read())
    2068        {
    2069             r_icache.write_dir( r_icache_cc_way.read(),
    2070                                 r_icache_cc_set.read(),
    2071                                 CACHE_SLOT_STATE_ZOMBI );
    2072                 // no need to write in the cache anymore
    2073             r_icache_cc_need_write = false;
    2074         }
    2075 
    2076         // cleanup
    2077         // send a request to cc_send_fsm
    2078         if(not r_icache_cc_send_req.read()) // cc_send is available
    2079         {
    2080             // coherence request completed
    2081             r_cc_receive_icache_req = false;
    2082             // request cleanup
    2083             r_icache_cc_send_req = true;
    2084             r_icache_cc_send_nline = r_cc_receive_icache_nline.read();
    2085             r_icache_cc_send_way   = r_icache_cc_way.read();
    2086             r_icache_cc_send_type  = CC_TYPE_CLEANUP;
    2087 
    2088             r_icache_fsm          = r_icache_fsm_save.read();
    2089         }
    2090         //else wait for previous cc_send request to be sent
    2091         break;
    2092     }
     2121
    20932122    } // end switch r_icache_fsm
    20942123
     
    23712400        }
    23722401
     2402        // coherence clack request (from DSPIN CLACK)
     2403        else if ( r_dcache_clack_req.read() )
     2404        {
     2405            r_dcache_fsm = DCACHE_CC_CHECK;
     2406            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     2407        }
    23732408        // coherence request (from CC_RECEIVE FSM)
    23742409        else if ( r_cc_receive_dcache_req.read() )
     
    30673102    case DCACHE_TLB_PTE1_GET:   // try to read a PT1 entry in dcache
    30683103    {
     3104        // coherence clack request (from DSPIN CLACK)
     3105        if ( r_dcache_clack_req.read() )
     3106        {
     3107            r_dcache_fsm = DCACHE_CC_CHECK;
     3108            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     3109            break;
     3110        }
     3111
    30693112        // coherence request (from CC_RECEIVE FSM)
    30703113        if ( r_cc_receive_dcache_req.read() )
     
    33663409    case DCACHE_TLB_PTE2_GET:   // Try to get a PTE2 (64 bits) in the dcache
    33673410    {
     3411        // coherence clack request (from DSPIN CLACK)
     3412        if ( r_dcache_clack_req.read() )
     3413        {
     3414            r_dcache_fsm = DCACHE_CC_CHECK;
     3415            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     3416            break;
     3417        }
     3418
    33683419        // coherence request (from CC_RECEIVE FSM)
    33693420        if ( r_cc_receive_dcache_req.read() )
     
    36653716
    36663717    {
     3718        // coherence clack request (from DSPIN CLACK)
     3719        if ( r_dcache_clack_req.read() )
     3720        {
     3721            r_dcache_fsm = DCACHE_CC_CHECK;
     3722            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     3723            break;
     3724        }
     3725
    36673726        // coherence request (from CC_RECEIVE FSM)
    36683727        if ( r_cc_receive_dcache_req.read() )
     
    37363795                                // as there is a risk of dead-lock
    37373796    {
     3797        // coherence clack request (from DSPIN CLACK)
     3798        if ( r_dcache_clack_req.read() )
     3799        {
     3800            r_dcache_fsm = DCACHE_CC_CHECK;
     3801            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     3802            break;
     3803        }
     3804
    37383805        // coherence request (from CC_RECEIVE FSM)
    37393806        if ( r_cc_receive_dcache_req.read() )
     
    37413808            r_dcache_fsm = DCACHE_CC_CHECK;
    37423809            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     3810            break;
    37433811        }
    37443812
     
    37573825                                    // and because it can exist a simultaneous ITLB miss
    37583826    {
     3827        // coherence clack request (from DSPIN CLACK)
     3828        if ( r_dcache_clack_req.read() )
     3829        {
     3830            r_dcache_fsm = DCACHE_CC_CHECK;
     3831            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     3832            break;
     3833        }
     3834
    37593835        // coherence request (from CC_RECEIVE FSM)
    37603836        if ( r_cc_receive_dcache_req.read() )
     
    37923868                                // returns to IDLE and flush TLBs when last slot
    37933869    {
     3870        // coherence clack request (from DSPIN CLACK)
     3871        if ( r_dcache_clack_req.read() )
     3872        {
     3873            r_dcache_fsm = DCACHE_CC_CHECK;
     3874            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     3875            break;
     3876        }
     3877
    37943878        // coherence request (from CC_RECEIVE FSM)
    37953879        if ( r_cc_receive_dcache_req.read() )
     
    38953979            r_dcache_xtn_flush_addr_data = r_dcache_xtn_flush_addr_data.read() + 4;
    38963980
    3897             cleanup_data_updt_fifo_dcache_get   = false;
    38983981            cleanup_data_updt_fifo_dcache_put   = true;
    38993982            cleanup_data_updt_fifo_dcache_data  = rdata;
     
    41584241            r_dcache_xtn_data_addr = r_dcache_xtn_data_addr.read() + 4;
    41594242
    4160             cleanup_data_updt_fifo_dcache_get   = false;
    41614243            cleanup_data_updt_fifo_dcache_put   = true;
    41624244            cleanup_data_updt_fifo_dcache_data  = rdata;
     
    41934275    {
    41944276        if ( m_dreq.valid) m_cost_data_miss_frz++;
     4277
     4278        // coherence clack request (from DSPIN CLACK)
     4279        if ( r_dcache_clack_req.read() )
     4280        {
     4281            r_dcache_fsm = DCACHE_CC_CHECK;
     4282            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     4283            break;
     4284        }
    41954285
    41964286        // coherence request (from CC_RECEIVE FSM)
     
    42474337                            r_dcache_fsm = DCACHE_MISS_DATA;
    42484338                            m_cpt_data_cleanup_dirty ++;
    4249                            
     4339
    42504340                            /*STATS DIRTY*/
    42514341                            for (size_t w = 0; w < m_dcache_words; w++)
     
    42944384        size_t set;
    42954385        size_t word;
    4296 
    42974386        r_dcache.read_neutral(r_dcache_miss_data_addr,
    42984387                              &rdata,
     
    43004389                              &set,
    43014390                              &word);
     4391
    43024392        if(r_cc_send_data_fifo.wok())
    43034393        {
    43044394            r_dcache_miss_data_addr = r_dcache_miss_data_addr.read() + 4;
    43054395
    4306             cleanup_data_updt_fifo_dcache_get   = false;
    43074396            cleanup_data_updt_fifo_dcache_put   = true;
    43084397            cleanup_data_updt_fifo_dcache_data  = rdata;
     
    43144403                r_dcache_fsm = DCACHE_MISS_CLEAN;
    43154404            }
     4405#if DEBUG_DCACHE
     4406if ( m_debug_activated )
     4407{
     4408    std::cout << "  <PROC " << name()
     4409              << " DCACHE_MISS_DATA>:" << std::hex
     4410              << " / DATA  = "   << rdata
     4411              << " / WORD  = "   << word
     4412              << " / PADDR = " << std::hex << r_dcache_miss_data_addr.read() << std::endl;
     4413}
     4414#endif
    43164415        }
    43174416        break;
     
    43704469    {
    43714470        if ( m_dreq.valid) m_cost_data_miss_frz++;
     4471
     4472        // coherence clack request (from DSPIN CLACK)
     4473        if ( r_dcache_clack_req.read() )
     4474        {
     4475            r_dcache_fsm = DCACHE_CC_CHECK;
     4476            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     4477            break;
     4478        }
    43724479
    43734480        // coherence request (from CC_RECEIVE FSM)
     
    44864593        if ( m_dreq.valid) m_cost_data_miss_frz++;
    44874594
     4595        // coherence clack request (from DSPIN CLACK)
     4596        if ( r_dcache_clack_req.read() )
     4597        {
     4598            r_dcache_fsm = DCACHE_CC_CHECK;
     4599            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     4600            break;
     4601        }
     4602
    44884603        // coherence request (from CC_RECEIVE FSM)
    44894604        if ( r_cc_receive_dcache_req.read() )
     
    45924707    case DCACHE_UNC_WAIT:  // waiting a response to an uncacheable read
    45934708    {
     4709        // coherence clack request (from DSPIN CLACK)
     4710        if ( r_dcache_clack_req.read() )
     4711        {
     4712            r_dcache_fsm = DCACHE_CC_CHECK;
     4713            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     4714            break;
     4715        }
     4716
    45944717        // coherence request (from CC_RECEIVE FSM)
    45954718        if ( r_cc_receive_dcache_req.read() )
     
    46294752    case DCACHE_LL_WAIT:    // waiting VCI response to a LL transaction
    46304753    {
     4754        // coherence clack request (from DSPIN CLACK)
     4755        if ( r_dcache_clack_req.read() )
     4756        {
     4757            r_dcache_fsm = DCACHE_CC_CHECK;
     4758            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     4759            break;
     4760        }
     4761
    46314762        // coherence request (from CC_RECEIVE FSM)
    46324763        if ( r_cc_receive_dcache_req.read() )
     
    46754806    case DCACHE_SC_WAIT:        // waiting VCI response to a SC transaction
    46764807    {
     4808        // coherence clack request (from DSPIN CLACK)
     4809        if ( r_dcache_clack_req.read() )
     4810        {
     4811            r_dcache_fsm = DCACHE_CC_CHECK;
     4812            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     4813            break;
     4814        }
     4815
    46774816        // coherence request (from CC_RECEIVE FSM)
    46784817        if ( r_cc_receive_dcache_req.read() )
     
    47144853        size_t   way;
    47154854        size_t   set;
    4716         size_t   word;  // unused
     4855        size_t   word; // unused
    47174856        int      state;
    47184857
     
    47674906                                    // - if the CAS is a failure, we just retry the write.
    47684907    {
     4908        // coherence clack request (from DSPIN CLACK)
     4909        if ( r_dcache_clack_req.read() )
     4910        {
     4911            r_dcache_fsm = DCACHE_CC_CHECK;
     4912            r_dcache_fsm_cc_save = r_dcache_fsm.read();
     4913            break;
     4914        }
     4915
    47694916        // coherence request (from CC_RECEIVE FSM)
    47704917        if ( r_cc_receive_dcache_req.read() )
     
    47754922        }
    47764923
    4777         if ( r_vci_rsp_data_error.read() )      // bus error
     4924        if ( r_vci_rsp_data_error.read() )      // bus error
    47784925        {
    47794926            std::cout << "BUS ERROR in DCACHE_DIRTY_WAIT state" << std::endl;
     
    47814928            exit(0);
    47824929        }
    4783         else if ( r_vci_rsp_fifo_dcache.rok() ) // response available
     4930        else if ( r_vci_rsp_fifo_dcache.rok() ) // response available
    47844931        {
    47854932            vci_rsp_fifo_dcache_get = true;
     
    48254972#endif
    48264973
    4827         if (r_cc_receive_dcache_type.read() == CC_TYPE_CLACK)
    4828                             // We switch the directory slot to EMPTY state
    4829                             // and reset r_icache_miss_clack if the cleanup ack
    4830                             // is matching a pending miss.
    4831         {
    4832 
    4833             if ( m_dreq.valid ) m_cost_data_miss_frz++;
    4834 
    4835 #ifdef INSTRUMENTATION
    4836 m_cpt_dcache_dir_write++;
    4837 #endif
    4838             r_dcache.write_dir( 0,
    4839                                 r_cc_receive_dcache_way.read(),
    4840                                 r_cc_receive_dcache_set.read(),
    4841                                 CACHE_SLOT_STATE_EMPTY);
    4842            
    4843             /*STATS DIRTY*/
    4844             for (size_t word = 0; word < m_dcache_words; word++)
    4845             {
    4846                 dirty_stats[(r_cc_receive_dcache_way * m_dcache_sets + r_cc_receive_dcache_set) * m_dcache_words + word] = false;
    4847             }
    4848 
    4849            
    4850             if ( (r_dcache_miss_set.read() == r_cc_receive_dcache_set.read()) and
    4851                  (r_dcache_miss_way.read() == r_cc_receive_dcache_way.read()) )
    4852                   r_dcache_miss_clack = false;
    4853 
    4854             r_dcache_fsm = r_dcache_fsm_cc_save.read() ;
    4855             r_cc_receive_dcache_req = false;
    4856 #if DEBUG_DCACHE
    4857 if ( m_debug_activated )
    4858 {
    4859     std::cout << "  <PROC " << name()
    4860               << " DCACHE_CC_CHECK> CC_TYPE_CLACK Switch slot to EMPTY state"
    4861               << " set = " << r_cc_receive_dcache_set.read()
    4862               << " / way = " << r_cc_receive_dcache_way.read() << std::endl;
    4863 }
    4864 #endif
    4865         }
    4866         else if( ((r_dcache_fsm_cc_save == DCACHE_MISS_SELECT) or
    4867                   (r_dcache_fsm_cc_save == DCACHE_MISS_WAIT) or
    4868                   (r_dcache_fsm_cc_save == DCACHE_MISS_DIR_UPDT)) and
    4869                   ((r_dcache_vci_paddr.read() & mask) == (paddr & mask)) ) // matching
     4974       
     4975        // Match between MISS address and CC address
     4976        // note: In the same cycle we can handle a CLACK and a MISS match
     4977        // because the CLACK access the directory but the MISS match dont.
     4978        if (r_cc_receive_dcache_req.read() and
     4979          ((r_dcache_fsm_cc_save == DCACHE_MISS_SELECT  )  or
     4980           (r_dcache_fsm_cc_save == DCACHE_MISS_WAIT    )  or
     4981           (r_dcache_fsm_cc_save == DCACHE_MISS_DIR_UPDT)) and
     4982          ((r_dcache_vci_paddr.read() & mask) == (paddr & mask))) // matching
    48704983        {
    48714984            // signaling matching
     
    48784991                r_dcache_fsm        = DCACHE_CC_UPDT;
    48794992                r_dcache_cc_word    = r_cc_receive_word_idx.read();
     4993
    48804994                // just pop the fifo , don't write in icache
    48814995                r_dcache_cc_need_write = false;
     
    48854999            {
    48865000                r_cc_receive_dcache_req = false;
    4887                 r_dcache_fsm          = r_dcache_fsm_cc_save.read();
     5001                r_dcache_fsm            = r_dcache_fsm_cc_save.read();
    48885002            }
    48895003
     
    48965010}
    48975011#endif
    4898 
    4899         }
    4900         else                                                    // no match
    4901             {
    4902             int        state = 0;
    4903             size_t         way = 0;
    4904             size_t         set = 0;
    4905             size_t         word = 0;
     5012        }
     5013
     5014        // CLACK handler
     5015        // We switch the directory slot to EMPTY state and reset
     5016        // r_dcache_miss_clack if the cleanup ack is matching a pending miss.
     5017        if ( r_dcache_clack_req.read() )
     5018        {
     5019            if ( m_dreq.valid ) m_cost_data_miss_frz++;
     5020
     5021#ifdef INSTRUMENTATION
     5022m_cpt_dcache_dir_write++;
     5023#endif
     5024            r_dcache.write_dir( 0,
     5025                                r_dcache_clack_way.read(),
     5026                                r_dcache_clack_set.read(),
     5027                                CACHE_SLOT_STATE_EMPTY);
     5028            /*STATS DIRTY*/
     5029            for (size_t word = 0; word < m_dcache_words; word++)
     5030            {
     5031                dirty_stats[(r_cc_receive_dcache_way * m_dcache_sets + r_cc_receive_dcache_set) * m_dcache_words + word] = false;
     5032            }
     5033
     5034            if ( (r_dcache_miss_set.read() == r_dcache_clack_set.read()) and
     5035                 (r_dcache_miss_way.read() == r_dcache_clack_way.read()) )
     5036            {
     5037                  r_dcache_miss_clack = false;
     5038            }
     5039
     5040            r_dcache_clack_req = false;
     5041
     5042            // return to cc_save state if no pending CC request
     5043            if ( not r_cc_receive_dcache_req.read() )
     5044            {
     5045                r_dcache_fsm = r_dcache_fsm_cc_save.read() ;
     5046            }
     5047
     5048#if DEBUG_DCACHE
     5049if ( m_debug_activated )
     5050{
     5051    std::cout << "  <PROC " << name()
     5052              << " DCACHE_CC_CHECK> CC_TYPE_CLACK Switch slot to EMPTY state"
     5053              << " set = " << r_dcache_clack_set.read()
     5054              << " / way = " << r_dcache_clack_way.read() << std::endl;
     5055}
     5056#endif
     5057            break;
     5058        }
     5059
     5060        // wait if pending request to CC_SEND. This way if there are pending
     5061        // CLACK they can be treated in this state and then a deadlock
     5062        // situation is avoided
     5063        if ( r_dcache_cc_send_req.read() ) break;
     5064
     5065        // CC request handler
     5066       
     5067        int    state = 0;
     5068        size_t way   = 0;
     5069        size_t set   = 0;
     5070        size_t word  = 0;
    49065071
    49075072#ifdef INSTRUMENTATION
    49085073m_cpt_dcache_dir_read++;
    49095074#endif
    4910             r_dcache.read_dir( paddr,
    4911                                &state,
    4912                                &way,
    4913                                &set,
    4914                                &word ); // unused
    4915 
    4916             r_dcache_cc_way = way;
    4917             r_dcache_cc_set = set;
    4918             /*ODCCP*/
    4919             if ((state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC))             // hit
    4920             {
    4921                 // need to update the cache state
    4922                 r_dcache_cleanup_ncc = false;
    4923                 r_dcache_cc_need_write = true;
    4924                 if (r_cc_receive_dcache_type.read() == CC_TYPE_UPDT)  // hit update
     5075        r_dcache.read_dir( paddr,
     5076                           &state,
     5077                           &way,
     5078                           &set,
     5079                           &word ); // unused
     5080
     5081        r_dcache_cc_way = way;
     5082        r_dcache_cc_set = set;
     5083        /*ODCCP*/
     5084        if ((state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC))             // hit
     5085        {
     5086            r_dcache_cleanup_ncc = false;
     5087            r_dcache_cc_need_write = true;
     5088            if (r_cc_receive_dcache_type.read() == CC_TYPE_UPDT)  // hit update
     5089            {
     5090                    /*ODCCP*/ // we can't receive a CC_UPDT on a NCC line
     5091                if (state == CACHE_SLOT_STATE_VALID_NCC)
     5092                    std::cout << "DCACHE_CC_CHECK : IMPOSSIBLE NCC STATE FOR CC_UPDT at cycle " << m_cpt_total_cycles << std::endl;
     5093                assert((state != CACHE_SLOT_STATE_VALID_NCC) and "DCACHE_CC_CHECK : IMPOSSIBLE NCC STATE FOR CC_UPDT");
     5094                   
     5095                r_dcache_fsm          = DCACHE_CC_UPDT;
     5096                r_dcache_cc_word      = r_cc_receive_word_idx.read();
     5097            }
     5098            else if (r_cc_receive_dcache_type.read() == CC_TYPE_INVAL)   // hit inval
     5099            {
     5100                if ( (state == CACHE_SLOT_STATE_VALID_NCC) )
    49255101                {
    4926                     /*ODCCP*/ // we can't receive a CC_UPDT on a NCC line
    4927                     if (state == CACHE_SLOT_STATE_VALID_NCC)
    4928                         std::cout << "DCACHE_CC_CHECK : IMPOSSIBLE NCC STATE FOR CC_UPDT at cycle " << m_cpt_total_cycles << std::endl;
    4929                     assert((state != CACHE_SLOT_STATE_VALID_NCC) and "DCACHE_CC_CHECK : IMPOSSIBLE NCC STATE FOR CC_UPDT");
    4930                    
    4931                     r_dcache_fsm          = DCACHE_CC_UPDT;
    4932                     r_dcache_cc_word      = r_cc_receive_word_idx.read();
     5102                    if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY)
     5103                        m_cpt_data_cleanup_dirty ++;
     5104                    r_dcache_cc_state           = state;
     5105                    r_dcache_cc_inval_addr      = (paddr &~0x3F);
     5106                    r_dcache_cc_inval_data_cpt  = 0;
    49335107                }
    4934                 else if (r_cc_receive_dcache_type.read() == CC_TYPE_INVAL)   // hit inval
     5108                else
    49355109                {
    4936                     if ( (state == CACHE_SLOT_STATE_VALID_NCC) )
    4937                     {
    4938                         if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY)
    4939                             m_cpt_data_cleanup_dirty ++;
    4940                         r_dcache_cc_state           = state;
    4941                         r_dcache_cc_inval_addr      = (paddr &~0x3F);
    4942                         r_dcache_cc_inval_data_cpt  = 0;
    4943                     }
    4944                     else
    4945                     {
    4946                         r_dcache_cc_state           = state;
    4947                         r_dcache_cc_inval_addr      = (paddr &~0x3F);
    4948                     }
    4949                     r_dcache_fsm                = DCACHE_CC_INVAL;
     5110                    r_dcache_cc_state           = state;
     5111                    r_dcache_cc_inval_addr      = (paddr &~0x3F);
    49505112                }
    4951                 else if ( r_cc_receive_dcache_type.read() == CC_TYPE_BRDCAST)  // hit broadcast
    4952                 {
    4953                     assert((state != CACHE_SLOT_STATE_VALID_NCC) and "DCACHE_CC_CHECK : IMPOSSIBLE NCC STATE FOR CC_BROADCAST");
    4954                     r_dcache_fsm          = DCACHE_CC_BROADCAST;
    4955                 }
    4956             }
    4957             else                                      // miss
    4958             {
    4959                 // multicast acknowledgement required in case of update
    4960                 if(r_cc_receive_dcache_type.read() == CC_TYPE_UPDT)
    4961                 {
    4962                     r_dcache_fsm          = DCACHE_CC_UPDT;
    4963                     r_dcache_cc_word      = r_cc_receive_word_idx.read();
    4964                     // just pop the fifo , don't write in icache
    4965                     r_dcache_cc_need_write = false;
    4966                 }
    4967                 else // No response needed
    4968                 {
    4969                     r_cc_receive_dcache_req = false;
    4970                     r_dcache_fsm          = r_dcache_fsm_cc_save.read();
    4971                 }
    4972             }
     5113                r_dcache_fsm                = DCACHE_CC_INVAL;
     5114            }
     5115        }
     5116        else                                  // miss
     5117        {
     5118            // multicast acknowledgement required in case of update
     5119            if(r_cc_receive_dcache_type.read() == CC_TYPE_UPDT)
     5120            {
     5121                r_dcache_fsm           = DCACHE_CC_UPDT;
     5122                r_dcache_cc_word       = r_cc_receive_word_idx.read();
     5123
     5124                // just pop the fifo , don't write in icache
     5125                r_dcache_cc_need_write = false;
     5126            }
     5127            else // No response needed
     5128            {
     5129                r_cc_receive_dcache_req = false;
     5130                r_dcache_fsm            = r_dcache_fsm_cc_save.read();
     5131            }
     5132        }
    49735133
    49745134#if DEBUG_DCACHE
     
    49825142}
    49835143#endif
     5144
     5145        break;
     5146    }
     5147    /////////////////////
     5148    case DCACHE_CC_INVAL: // hit inval: switch slot to ZOMBI state and send a
     5149                          // CLEANUP after possible invalidation of copies in
     5150                          // TLBs
     5151    {
     5152        size_t way    = r_dcache_cc_way.read();
     5153        size_t set    = r_dcache_cc_set.read();
     5154        int      state  = r_dcache_cc_state.read();
     5155        if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB )
     5156        {
     5157            r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
     5158            r_dcache_tlb_inval_line  = r_cc_receive_dcache_nline.read();
     5159            r_dcache_tlb_inval_set   = 0;
     5160            r_dcache_fsm_scan_save   = r_dcache_fsm.read();
     5161            r_dcache_fsm             = DCACHE_INVAL_TLB_SCAN;
     5162            break;
     5163        }
     5164        if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD )
     5165        {
     5166            r_itlb.reset();
     5167            r_dtlb.reset();
     5168            r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
     5169
     5170#if DEBUG_DCACHE
     5171if ( m_debug_activated )
     5172{
     5173    std::cout << "  <PROC " << name()
     5174    << " DCACHE_CC_INVAL> Flush DTLB & ITLB" << std::endl;
     5175}
     5176#endif
     5177        }
     5178
     5179
     5180        if ( state == CACHE_SLOT_STATE_VALID_CC )
     5181        {
     5182            // Switch slot state to ZOMBI and send CLEANUP command
     5183            r_dcache.write_dir( way,
     5184                                set,
     5185                                CACHE_SLOT_STATE_ZOMBI );
     5186#if DEBUG_DCACHE
     5187if ( m_debug_activated )
     5188{
     5189    std::cout << "  <PROC " << name()
     5190    << " DCACHE_CC_INVAL> Switch slot valid CC to ZOMBI state:" << std::dec
     5191    << " / WAY = " << way
     5192    << " / SET = " << set << std::endl;
     5193}
     5194#endif
     5195        }
     5196
     5197        assert (not r_dcache_cc_send_req.read() &&
     5198                "ERROR in DCACHE_CC_INVAL: the r_dcache_cc_send_req "
     5199                "must not be set");
     5200
     5201        // coherence request completed
     5202        r_cc_receive_dcache_req = false;
     5203        r_dcache_cc_send_req    = true;
     5204        r_dcache_cc_send_nline  = r_cc_receive_dcache_nline.read();
     5205        r_dcache_cc_send_way    = way;
     5206        r_dcache_cc_send_type   = CC_TYPE_CLEANUP;
     5207        r_dcache_fsm            = r_dcache_fsm_cc_save.read();
     5208           
     5209        if ( (state == CACHE_SLOT_STATE_VALID_NCC) )
     5210        {
     5211            r_dcache_cleanup_ncc = true;
     5212               
     5213            if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY)
     5214            {
     5215                r_dcache_cc_cleanup_updt_data = true;
     5216                r_dcache_fsm = DCACHE_CC_INVAL_DATA;
     5217                   
     5218                    /*STATS DIRTY*/
     5219                    for (size_t w = 0; w < m_dcache_words; w++)
     5220                    {
     5221                       if(dirty_stats[(way * m_dcache_sets + set) * m_dcache_words + w] == true)
     5222                           m_cpt_words_dirty++;
     5223                    }
     5224            }
     5225            else
     5226            {
     5227                r_dcache_cc_cleanup_updt_data = false;
     5228                r_dcache.write_dir( way,
     5229                                    set,
     5230                                    CACHE_SLOT_STATE_ZOMBI );
     5231                r_dcache_fsm = r_dcache_fsm_cc_save.read();
     5232            }
    49845233        }
    49855234        break;
     
    50015250            r_dcache_cc_inval_addr = r_dcache_cc_inval_addr.read() + 4;
    50025251
    5003             cleanup_data_updt_fifo_dcache_get   = false;
    50045252            cleanup_data_updt_fifo_dcache_put   = true;
    50055253            cleanup_data_updt_fifo_dcache_data  = rdata;
     
    50265274        break;
    50275275    }
    5028     /////////////////////
    5029     case DCACHE_CC_INVAL:       // hit inval: switch slot to EMPTY state,
     5276    ///////////////////
     5277    case DCACHE_CC_UPDT:        // hit update: write one word per cycle,
    50305278                                // after possible invalidation of copies in TLBs
    50315279    {
    5032         size_t   way    = r_dcache_cc_way.read();
    5033         size_t   set    = r_dcache_cc_set.read();
    5034         int      state  = r_dcache_cc_state.read();
    5035         if (r_dcache_cc_need_write.read())
    5036         {
    5037             if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB )
    5038             {
    5039                 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
    5040                 r_dcache_tlb_inval_line  = r_cc_receive_dcache_nline.read();
    5041                 r_dcache_tlb_inval_set   = 0;
    5042                 r_dcache_fsm_scan_save   = r_dcache_fsm.read();
    5043                 r_dcache_fsm             = DCACHE_INVAL_TLB_SCAN;
    5044                 break;
    5045             }
    5046             else
    5047             {
    5048                 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD )
    5049                 {
    5050                     r_itlb.reset();
    5051                     r_dtlb.reset();
    5052                     r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
    5053 
    5054 #if DEBUG_DCACHE
    5055                     if ( m_debug_activated )
    5056                     {
    5057                         std::cout << "  <PROC " << name()
    5058                             << " DCACHE_CC_INVAL> Flush DTLB & ITLB" << std::endl;
    5059                     }
    5060 #endif
    5061                 }
    5062 
    5063                 if ( state == CACHE_SLOT_STATE_VALID_CC )
    5064                 {
    5065                     r_dcache.write_dir( 0,
    5066                             way,
    5067                             set,
    5068                             CACHE_SLOT_STATE_EMPTY );
    5069 #if DEBUG_DCACHE
    5070                     if ( m_debug_activated )
    5071                     {
    5072                         std::cout << "  <PROC " << name()
    5073 
    5074                             << " DCACHE_CC_INVAL> Switch slot to EMPTY state:" << std::dec
    5075                             << " / WAY = " << way
    5076                             << " / SET = " << set << std::endl;
    5077                     }
    5078 #endif
    5079                 }
    5080                 r_dcache_cc_need_write = false;
    5081 
    5082             }
    5083         }
    5084 
    5085         // multicast acknowledgement
    5086         // send a request to cc_send_fsm
    5087         if(not r_dcache_cc_send_req.read()) // cc_send is available
    5088         {
    5089 
    5090             // coherence request completed
    5091             r_cc_receive_dcache_req = false;
    5092             r_dcache_cc_send_req = true;
    5093             r_dcache_cc_send_nline = r_cc_receive_dcache_nline.read();
    5094 
    5095            
    5096             if ( (state == CACHE_SLOT_STATE_VALID_NCC) )
    5097             {
    5098                 r_dcache_cleanup_ncc = true;
    5099                 r_dcache_cc_send_type = CC_TYPE_CLEANUP;
    5100                 r_dcache_cc_send_way = way;
    5101                
    5102                 if (r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_DATA_DIRTY)
    5103                 {
    5104                     r_dcache_cc_cleanup_updt_data = true;
    5105                     r_dcache_fsm = DCACHE_CC_INVAL_DATA;
    5106                    
    5107                     /*STATS DIRTY*/
    5108                     for (size_t w = 0; w < m_dcache_words; w++)
    5109                     {
    5110                        if(dirty_stats[(way * m_dcache_sets + set) * m_dcache_words + w] == true)
    5111                            m_cpt_words_dirty++;
    5112                     }
    5113                 }
    5114                 else
    5115                 {
    5116                     r_dcache_cc_cleanup_updt_data = false;
    5117                     r_dcache.write_dir( way,
    5118                                         set,
    5119                                         CACHE_SLOT_STATE_ZOMBI );
    5120                     r_dcache_fsm = r_dcache_fsm_cc_save.read();
    5121                 }
    5122             }
    5123             else
    5124             {
    5125                 // request multicast acknowledgement
    5126                 r_dcache_cc_send_updt_tab_idx = r_cc_receive_dcache_updt_tab_idx.read();
    5127                 r_dcache_cc_send_type = CC_TYPE_MULTI_ACK;
    5128                 r_dcache_fsm = r_dcache_fsm_cc_save.read();
    5129             }
    5130         }
    5131         //else wait for previous cc_send request to be sent
    5132         break;
    5133     }
    5134     ///////////////////
    5135     case DCACHE_CC_UPDT:        // hit update: write one word per cycle,
    5136                                 // after possible invalidation of copies in TLBs
    5137     {
    5138         size_t   word       = r_dcache_cc_word.read();
    5139         size_t   way        = r_dcache_cc_way.read();
    5140         size_t   set        = r_dcache_cc_set.read();
    5141 
    5142         if (r_cc_receive_updt_fifo_be.rok())
    5143         {
    5144             if (r_dcache_cc_need_write.read())
    5145             {
    5146                 // selective TLB inval
    5147                 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB )
    5148                 {
    5149                     r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
    5150                     r_dcache_tlb_inval_line  = r_cc_receive_dcache_nline.read();
    5151                     r_dcache_tlb_inval_set   = 0;
    5152                     r_dcache_fsm_scan_save   = r_dcache_fsm.read();
    5153                     r_dcache_fsm             = DCACHE_INVAL_TLB_SCAN;
    5154                     break;
    5155                 }
    5156                 // TLB flush
    5157                 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD )
    5158                 {
    5159                     r_itlb.reset();
    5160                     r_dtlb.reset();
    5161                     r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
     5280        size_t word       = r_dcache_cc_word.read();
     5281        size_t way        = r_dcache_cc_way.read();
     5282        size_t set        = r_dcache_cc_set.read();
     5283
     5284        // selective TLB inval
     5285        if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB )
     5286        {
     5287            r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
     5288            r_dcache_tlb_inval_line  = r_cc_receive_dcache_nline.read();
     5289            r_dcache_tlb_inval_set   = 0;
     5290            r_dcache_fsm_scan_save   = r_dcache_fsm.read();
     5291            r_dcache_fsm             = DCACHE_INVAL_TLB_SCAN;
     5292            break;
     5293        }
     5294        // TLB flush
     5295        if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD )
     5296        {
     5297            r_itlb.reset();
     5298            r_dtlb.reset();
     5299            r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
    51625300
    51635301#if DEBUG_DCACHE
     
    51655303{
    51665304    std::cout << "  <PROC " << name()
    5167               << " DCACHE_CC_UPDT> Flush DTLB & ITLB" << std::endl;
     5305    << " DCACHE_CC_UPDT> Flush DTLB & ITLB" << std::endl;
    51685306}
    51695307#endif
    5170                 }
    5171 
     5308        }
     5309
     5310        assert (not r_dcache_cc_send_req.read() &&
     5311                "ERROR in DCACHE_CC_INVAL: the r_dcache_cc_send_req "
     5312                "must not be set");
     5313       
     5314        if ( not r_cc_receive_updt_fifo_be.rok() ) break;
     5315
     5316        if (r_dcache_cc_need_write.read())
     5317        {
     5318       
    51725319#ifdef INSTRUMENTATION
    51735320m_cpt_dcache_data_write++;
    51745321#endif
    5175                 r_dcache.write( way,
    5176                                 set,
    5177                                 word,
    5178                                 r_cc_receive_updt_fifo_data.read(),
    5179                                 r_cc_receive_updt_fifo_be.read() );
    5180 
    5181                 r_dcache_cc_word = word + 1;
     5322            r_dcache.write( way,
     5323                            set,
     5324                            word,
     5325                            r_cc_receive_updt_fifo_data.read(),
     5326                            r_cc_receive_updt_fifo_be.read() );
     5327
     5328            r_dcache_cc_word = word + 1;
    51825329
    51835330#if DEBUG_DCACHE
     
    51925339}
    51935340#endif
    5194             }
    5195 
    5196             if ( r_cc_receive_updt_fifo_eop.read() )    // last word
    5197             {
    5198                 // no need to write in the cache anymore
    5199                 r_dcache_cc_need_write = false;
    5200 
    5201                 // wait to send a request to cc_send_fsm
    5202                 if(not r_dcache_cc_send_req.read())
    5203                 // cc_send is available
    5204                 {
    5205                     //consume last fifo flit if eop and request to cc_send possible
    5206                     cc_receive_updt_fifo_get  = true;
    5207 
    5208                     // coherence request completed
    5209                     r_cc_receive_dcache_req = false;
    5210 
    5211                     // request multicast acknowledgement
    5212                     r_dcache_cc_send_req = true;
    5213                     r_dcache_cc_send_nline = r_cc_receive_dcache_nline.read();
    5214                     r_dcache_cc_send_updt_tab_idx = r_cc_receive_dcache_updt_tab_idx.read();
    5215                     r_dcache_cc_send_type = CC_TYPE_MULTI_ACK;
    5216 
    5217                     r_dcache_fsm          = r_dcache_fsm_cc_save.read();
    5218                 }
    5219             }
    5220             else
    5221             {
    5222                 //consume fifo if not eop
    5223                 cc_receive_updt_fifo_get  = true;
    5224             }
    5225         }
    5226         break;
    5227     }
    5228     /////////////////////////
    5229     case DCACHE_CC_BROADCAST:   // hit broadcast : switch state to ZOMBI state
    5230                                 // and request a cleanup, after possible
    5231                                 // invalidation of copies in TLBs
    5232     {
    5233         size_t   way   = r_dcache_cc_way.read();
    5234         size_t   set   = r_dcache_cc_set.read();
    5235         paddr_t  nline = r_cc_receive_dcache_nline.read();
    5236 
    5237         if (r_dcache_cc_need_write.read())
    5238         {
    5239             // selective TLB inval
    5240             if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_IN_TLB )
    5241             {
    5242                 r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
    5243                 r_dcache_tlb_inval_line  = nline;
    5244                 r_dcache_tlb_inval_set   = 0;
    5245                 r_dcache_fsm_scan_save   = r_dcache_fsm.read();
    5246                 r_dcache_fsm             = DCACHE_INVAL_TLB_SCAN;
    5247                 break;
    5248             }
    5249             else
    5250             {
    5251                 // TLB flush
    5252                 if ( r_dcache_content_state[way*m_dcache_sets+set] == LINE_CACHE_CONTAINS_PTD )
    5253                 {
    5254                     r_itlb.reset();
    5255                     r_dtlb.reset();
    5256                     r_dcache_content_state[way*m_dcache_sets+set] = LINE_CACHE_DATA_NOT_DIRTY;
    5257 
    5258 #if DEBUG_DCACHE
    5259                     if ( m_debug_activated )
    5260                     {
    5261                         std::cout << "  <PROC " << name()
    5262                             << " DCACHE_CC_BROADCAST> Flush DTLB & ITLB" << std::endl;
    5263                     }
    5264 #endif
    5265                 }
    5266 
    5267 #ifdef INSTRUMENTATION
    5268                 m_cpt_dcache_dir_write++;
    5269 #endif
    5270                 r_dcache.write_dir( way,
    5271                         set,
    5272                         CACHE_SLOT_STATE_ZOMBI );
    5273 
    5274                 r_dcache_cc_need_write = false;
    5275 #if DEBUG_DCACHE
    5276                 if ( m_debug_activated )
    5277                 {
    5278                     std::cout << "  <PROC " << name()
    5279                         << " DCACHE_CC_BROADCAST > Slot goes to ZOMBI state "
    5280                         << " SET = " << set
    5281                         << " / WAY = " << way << std::endl;
    5282                 }
    5283 #endif
    5284             }
    5285         }
    5286         // cleanup
    5287         // send a request to cc_send_fsm
    5288         if(not r_dcache_cc_send_req.read()) // cc_send is available
    5289         {
     5341        }
     5342
     5343        if ( r_cc_receive_updt_fifo_eop.read() )  // last word
     5344        {
     5345            // no need to write in the cache anymore
     5346            r_dcache_cc_need_write = false;
     5347
    52905348            // coherence request completed
    52915349            r_cc_receive_dcache_req = false;
    5292             // request cleanup
    5293             r_dcache_cc_send_req = true;
    5294             r_dcache_cc_send_nline = r_cc_receive_dcache_nline.read();
    5295             r_dcache_cc_send_way   = r_dcache_cc_way.read();
    5296             r_dcache_cc_send_type  = CC_TYPE_CLEANUP;
    5297 
    5298             r_dcache_fsm          = r_dcache_fsm_cc_save.read();
    5299         }
    5300         //else wait for previous cc_send request to be sent
     5350
     5351            // request multicast acknowledgement
     5352            r_dcache_cc_send_req          = true;
     5353            r_dcache_cc_send_nline        = r_cc_receive_dcache_nline.read();
     5354            r_dcache_cc_send_updt_tab_idx = r_cc_receive_dcache_updt_tab_idx.read();
     5355            r_dcache_cc_send_type         = CC_TYPE_MULTI_ACK;
     5356
     5357            r_dcache_fsm                  = r_dcache_fsm_cc_save.read();
     5358        }
     5359
     5360        //consume fifo if not eop
     5361        cc_receive_updt_fifo_get  = true;
     5362
    53015363        break;
    53025364    }
     
    56895751                    if ( r_vci_rsp_fifo_icache.wok() )
    56905752                    {
    5691                         assert( (r_vci_rsp_cpt.read() < m_icache_words) and
    5692                         "The VCI response packet for instruction miss is too long" );
    5693 
     5753                        if ( r_vci_rsp_cpt.read() >= m_icache_words )
     5754                        {
     5755                            std::cout << "ERROR in VCI_CC_VCACHE " << name()
     5756                                      << " VCI response packet too long "
     5757                                      << " for instruction miss" << std::endl;
     5758                            exit(0);
     5759                        }
    56945760                        r_vci_rsp_cpt                 = r_vci_rsp_cpt.read() + 1;
    56955761                        vci_rsp_fifo_icache_put       = true,
     
    56975763                        if ( p_vci.reop.read() )
    56985764                        {
    5699                             assert( (r_vci_rsp_cpt.read() == m_icache_words - 1) and
    5700                             "The VCI response packet for instruction miss is too short");
    5701 
     5765                            if ( r_vci_rsp_cpt.read() != (m_icache_words - 1) )
     5766                            {
     5767                                std::cout << "ERROR in VCI_CC_VCACHE " << name()
     5768                                          << " VCI response packet too short"
     5769                                          << " for instruction miss" << std::endl;
     5770                                exit(0);
     5771                            }
    57025772                            r_vci_rsp_fsm    = RSP_IDLE;
    57035773                        }
     
    59025972        {
    59035973            // wait for the first flit to be consumed
    5904             if (p_dspin_out.read.read())
     5974            if (p_dspin_p2m.read.read())
    59055975                r_cc_send_fsm = CC_SEND_CLEANUP_2;
    59065976
     
    59115981        {
    59125982            // wait for the second flit to be consumed
    5913             if (p_dspin_out.read.read())
     5983            if (p_dspin_p2m.read.read())
    59145984            {
    59155985                /*ODCCP*/ // If there is a cleanup with data and dcache active request we send other flits contained data
     
    59336003        case CC_SEND_CLEANUP_DATA_UPDT: /*ODCCP*/ // we send the data values of line cache into [m_dcache_words] flits
    59346004        {
    5935             if (p_dspin_out.read.read())
     6005            if (p_dspin_p2m.read.read())
    59366006            {
    59376007                if(r_cc_send_data_fifo.rok())
     
    59566026        {
    59576027            // wait for the flit to be consumed
    5958             if(p_dspin_out.read.read())
     6028            if(p_dspin_p2m.read.read())
    59596029            {
    59606030                if(r_cc_send_last_client.read() == 0) // dcache active request
     
    59706040
    59716041    ///////////////////////////////////////////////////////////////////////////////
    5972     //   C_RECEIVE  FSM
     6042    //  CC_RECEIVE  FSM
    59736043    // This FSM receive all coherence packets on a DSPIN40 port.
    5974     // There is 7 packet types:
     6044    // There is 5 packet types:
    59756045    // - CC_DATA_INVAL : DCACHE invalidate request
    59766046    // - CC_DATA_UPDT  : DCACHE update request (multi-words)
     
    59786048    // - CC_INST_UPDT  : ICACHE update request (multi-words)
    59796049    // - CC_BROADCAST  : Broadcast invalidate request (both DCACHE & ICACHE)
    5980     // - CC_DATA_CLACK : DCACHE cleanup acknowledge
    5981     // - CC_INST_CLACK : ICACHE cleanup acknowledge
    59826050    //////////////////////////////////////////////////////////////////////////////
    59836051    switch( r_cc_receive_fsm.read() )
     
    59876055        {
    59886056            // a coherence request has arrived
    5989             if (p_dspin_in.write.read())
     6057            if (p_dspin_m2p.write.read())
    59906058            {
    59916059                // initialize dspin received data
    5992                 uint64_t receive_data = p_dspin_in.data.read();
     6060                uint64_t receive_data = p_dspin_m2p.data.read();
    59936061                // initialize coherence packet type
    59946062                uint64_t receive_type = DspinDhccpParam::dspin_get(receive_data,
    5995                                             DspinDhccpParam::FROM_MC_TYPE);
    5996                 // initialize data/ins flip_flop (0 data / 1 ins)
    5997                 r_cc_receive_data_ins = (bool)(receive_type & 0x1);
     6063                                            DspinDhccpParam::M2P_TYPE);
    59986064                // test for a broadcast
    5999                 if (DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::FROM_MC_BC))
     6065                if (DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::M2P_BC))
    60006066                {
    60016067                    r_cc_receive_fsm = CC_RECEIVE_BRDCAST_HEADER;
    60026068                }
    6003                 // test for a CLACK
    6004                 else if ((receive_type == DspinDhccpParam::TYPE_CLEANUP_ACK_DATA) or
    6005                          (receive_type == DspinDhccpParam::TYPE_CLEANUP_ACK_INST))
     6069                // test for a multi updt
     6070                else if (receive_type == DspinDhccpParam::TYPE_MULTI_UPDT_DATA)
    60066071                {
    6007                     r_cc_receive_fsm = CC_RECEIVE_CLACK;
     6072                    r_cc_receive_fsm = CC_RECEIVE_DATA_UPDT_HEADER;
    60086073                }
    6009                 // test for a multi updt
    6010                 else if ((receive_type == DspinDhccpParam::TYPE_MULTI_UPDT_DATA) or
    6011                          (receive_type == DspinDhccpParam::TYPE_MULTI_UPDT_INST))
     6074                else if (receive_type == DspinDhccpParam::TYPE_MULTI_UPDT_INST)
    60126075                {
    6013                     r_cc_receive_fsm = CC_RECEIVE_UPDT_HEADER;
     6076                    r_cc_receive_fsm = CC_RECEIVE_INS_UPDT_HEADER;
    60146077                }
    60156078                // test for a multi inval
     6079                else if (receive_type == DspinDhccpParam::TYPE_MULTI_INVAL_DATA)
     6080                {
     6081                    r_cc_receive_fsm = CC_RECEIVE_DATA_INVAL_HEADER;
     6082                }
    60166083                else
    60176084                {
    6018                     r_cc_receive_fsm = CC_RECEIVE_INVAL_HEADER;
     6085                    r_cc_receive_fsm = CC_RECEIVE_INS_INVAL_HEADER;
    60196086                }
    60206087            }
    6021             break;
    6022         }
    6023         //////////////////////
    6024         case CC_RECEIVE_CLACK:
    6025         {
    6026             // initialize dspin received data
    6027             uint64_t receive_data = p_dspin_in.data.read();
    6028 
    6029             // for data CLACK, wait for dcache to take the request
    6030             if ((r_cc_receive_data_ins.read() == 0) and
    6031                     not r_cc_receive_dcache_req.read())
    6032             {
    6033                 // request dcache to handle the CLACK
    6034                 r_cc_receive_dcache_req  = true;
    6035                 r_cc_receive_dcache_set  = DspinDhccpParam::dspin_get(receive_data,
    6036                                            DspinDhccpParam::CLEANUP_ACK_SET) &
    6037                                            ((1ULL<<(uint32_log2(m_dcache_sets)))-1);
    6038                 r_cc_receive_dcache_way  = DspinDhccpParam::dspin_get(receive_data,
    6039                                            DspinDhccpParam::CLEANUP_ACK_WAY) &
    6040                                            ((1ULL<<(uint32_log2(m_dcache_ways)))-1);
    6041                 r_cc_receive_dcache_type = CC_TYPE_CLACK;
    6042                 // get back to idle state
    6043                 r_cc_receive_fsm = CC_RECEIVE_IDLE;
    6044                 break;
    6045             }
    6046             // for ins CLACK, wait for icache to take the request
    6047             if ((r_cc_receive_data_ins.read() == 1) and
    6048                    not (r_cc_receive_icache_req.read()))
    6049             {
    6050                 // request icache to handle the CLACK
    6051                 r_cc_receive_icache_req  = true;
    6052                 r_cc_receive_icache_set  = DspinDhccpParam::dspin_get(receive_data,
    6053                                            DspinDhccpParam::CLEANUP_ACK_SET) &
    6054                                            ((1ULL<<(uint32_log2(m_icache_sets)))-1);
    6055                 r_cc_receive_icache_way  = DspinDhccpParam::dspin_get(receive_data,
    6056                                            DspinDhccpParam::CLEANUP_ACK_WAY) &
    6057                                            ((1ULL<<(uint32_log2(m_icache_ways)))-1);
    6058                 r_cc_receive_icache_type = CC_TYPE_CLACK;
    6059                 // get back to idle state
    6060                 r_cc_receive_fsm = CC_RECEIVE_IDLE;
    6061                 break;
    6062             }
    6063             // keep waiting for the correct cache to accept the request
    60646088            break;
    60656089        }
     
    60756099        {
    60766100            // initialize dspin received data
    6077             uint64_t receive_data = p_dspin_in.data.read();
     6101            uint64_t receive_data = p_dspin_m2p.data.read();
    60786102            // wait for both dcache and icache to take the request
    60796103            // TODO maybe we need to wait for both only to leave the state, but
     
    60826106            if (not (r_cc_receive_icache_req.read()) and
    60836107                not (r_cc_receive_dcache_req.read()) and
    6084                 (p_dspin_in.write.read()))
     6108                (p_dspin_m2p.write.read()))
    60856109            {
    60866110                // request dcache to handle the BROADCAST
    6087                 r_cc_receive_dcache_req  = true;
     6111                r_cc_receive_dcache_req = true;
    60886112                r_cc_receive_dcache_nline  = DspinDhccpParam::dspin_get(receive_data,
    60896113                                             DspinDhccpParam::BROADCAST_NLINE);
    6090                 r_cc_receive_dcache_type = CC_TYPE_BRDCAST;
     6114                r_cc_receive_dcache_type = CC_TYPE_INVAL;
    60916115                // request icache to handle the BROADCAST
    6092                 r_cc_receive_icache_req  = true;
     6116                r_cc_receive_icache_req = true;
    60936117                r_cc_receive_icache_nline  = DspinDhccpParam::dspin_get(receive_data,
    60946118                                             DspinDhccpParam::BROADCAST_NLINE);
    6095                 r_cc_receive_icache_type = CC_TYPE_BRDCAST;
     6119                r_cc_receive_icache_type = CC_TYPE_INVAL;
    60966120                // get back to idle state
    60976121                r_cc_receive_fsm = CC_RECEIVE_IDLE;
     
    61026126        }
    61036127        /////////////////////////////
    6104         case CC_RECEIVE_INVAL_HEADER:
     6128        case CC_RECEIVE_DATA_INVAL_HEADER:
    61056129        {
    61066130            // sample updt tab index in the HEADER, then skip to second flit
    6107             uint64_t receive_data = p_dspin_in.data.read();
     6131            r_cc_receive_fsm = CC_RECEIVE_DATA_INVAL_NLINE;
     6132            break;
     6133        }
     6134        /////////////////////////////
     6135        case CC_RECEIVE_INS_INVAL_HEADER:
     6136        {
     6137            // sample updt tab index in the HEADER, then skip to second flit
     6138            r_cc_receive_fsm = CC_RECEIVE_INS_INVAL_NLINE;
     6139            break;
     6140        }
     6141        ////////////////////////////
     6142        case CC_RECEIVE_DATA_INVAL_NLINE:
     6143        {
     6144            // sample nline in the second flit
     6145            uint64_t receive_data = p_dspin_m2p.data.read();
    61086146            // for data INVAL, wait for dcache to take the request
    6109             if ((r_cc_receive_data_ins.read() == 0) and
    6110                  not (r_cc_receive_dcache_req.read()))
    6111             {
    6112                 r_cc_receive_dcache_updt_tab_idx = DspinDhccpParam::dspin_get(receive_data,
    6113                                                    DspinDhccpParam::MULTI_INVAL_UPDT_INDEX);
    6114                 r_cc_receive_fsm = CC_RECEIVE_INVAL_NLINE;
    6115                 break;
    6116             }
    6117             // for ins INVAL, wait for icache to take the request
    6118             if ((r_cc_receive_data_ins.read() == 1) and
    6119                  not (r_cc_receive_icache_req.read()))
    6120             {
    6121                 r_cc_receive_icache_updt_tab_idx = DspinDhccpParam::dspin_get(receive_data,
    6122                                                    DspinDhccpParam::MULTI_INVAL_UPDT_INDEX);
    6123                 r_cc_receive_fsm = CC_RECEIVE_INVAL_NLINE;
    6124                 break;
    6125             }
    6126             // keep waiting for the correct cache to accept the request
    6127             break;
    6128         }
    6129         ////////////////////////////
    6130         case CC_RECEIVE_INVAL_NLINE:
    6131         {
    6132             // sample nline in the second flit
    6133             uint64_t receive_data = p_dspin_in.data.read();
    6134             // for data INVAL, wait for dcache to take the request
    6135             if ( (r_cc_receive_data_ins.read() == 0) and
    6136                  not (r_cc_receive_dcache_req.read()) and
    6137                  (p_dspin_in.write.read()) )
     6147            if (p_dspin_m2p.write.read() and not r_cc_receive_dcache_req.read())
    61386148            {
    61396149                // request dcache to handle the INVAL
    6140                 r_cc_receive_dcache_req  = true;
    6141                 r_cc_receive_dcache_nline  = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_INVAL_NLINE);
     6150                r_cc_receive_dcache_req = true;
     6151                r_cc_receive_dcache_nline = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_INVAL_NLINE);
    61426152                r_cc_receive_dcache_type = CC_TYPE_INVAL;
    61436153                // get back to idle state
     
    61456155                break;
    61466156            }
     6157            break;
     6158        }
     6159        //////////////////////////////
     6160        case CC_RECEIVE_INS_INVAL_NLINE:
     6161        {
     6162            // sample nline in the second flit
     6163            uint64_t receive_data = p_dspin_m2p.data.read();
    61476164            // for ins INVAL, wait for icache to take the request
    6148             if ((r_cc_receive_data_ins.read() == 1) and not (r_cc_receive_icache_req.read()) and (p_dspin_in.write.read()))
     6165            if (p_dspin_m2p.write.read() and not r_cc_receive_icache_req.read())
    61496166            {
    61506167                // request icache to handle the INVAL
    6151                 r_cc_receive_icache_req  = true;
    6152                 r_cc_receive_icache_nline  = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_INVAL_NLINE);
     6168                r_cc_receive_icache_req = true;
     6169                r_cc_receive_icache_nline = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_INVAL_NLINE);
    61536170                r_cc_receive_icache_type = CC_TYPE_INVAL;
    61546171                // get back to idle state
     
    61566173                break;
    61576174            }
    6158             // we should never get there
    6159             assert ( false && "ERROR in CC_VCACHE : CC_RECEIVE_INVAL_NLINE\n");
     6175            break;
    61606176        }
    61616177        ////////////////////////////
    6162         case CC_RECEIVE_UPDT_HEADER:
     6178        case CC_RECEIVE_DATA_UPDT_HEADER:
    61636179        {
    61646180            // sample updt tab index in the HEADER, than skip to second flit
    6165             uint64_t receive_data = p_dspin_in.data.read();
     6181            uint64_t receive_data = p_dspin_m2p.data.read();
    61666182            // for data INVAL, wait for dcache to take the request and fifo to
    61676183            // be empty
    6168             if ((r_cc_receive_data_ins.read() == 0) and not r_cc_receive_dcache_req.read() and r_cc_receive_updt_fifo_be.empty())
     6184            if (not r_cc_receive_dcache_req.read())
    61696185            {
    61706186                r_cc_receive_dcache_updt_tab_idx  = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_UPDT_INDEX);
    6171                 r_cc_receive_fsm = CC_RECEIVE_UPDT_NLINE;
     6187                r_cc_receive_fsm = CC_RECEIVE_DATA_UPDT_NLINE;
    61726188                break;
    61736189            }
     6190            break;
     6191        }
     6192        ////////////////////////////
     6193        case CC_RECEIVE_INS_UPDT_HEADER:
     6194        {
     6195            // sample updt tab index in the HEADER, than skip to second flit
     6196            uint64_t receive_data = p_dspin_m2p.data.read();
    61746197            // for ins INVAL, wait for icache to take the request and fifo to be
    61756198            // empty
    6176             if ((r_cc_receive_data_ins.read() == 1) and not r_cc_receive_icache_req.read() and r_cc_receive_updt_fifo_be.empty())
     6199            if (not r_cc_receive_icache_req.read())
    61776200            {
    61786201                r_cc_receive_icache_updt_tab_idx  = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_UPDT_INDEX);
    6179                 r_cc_receive_fsm = CC_RECEIVE_UPDT_NLINE;
     6202                r_cc_receive_fsm = CC_RECEIVE_INS_UPDT_NLINE;
    61806203                break;
    61816204            }
     
    61846207        }
    61856208        ///////////////////////////
    6186         case CC_RECEIVE_UPDT_NLINE:
     6209        case CC_RECEIVE_DATA_UPDT_NLINE:
    61876210        {
    61886211            // sample nline and word index in the second flit
    6189             uint64_t receive_data = p_dspin_in.data.read();
     6212            uint64_t receive_data = p_dspin_m2p.data.read();
    61906213            // for data INVAL, wait for dcache to take the request and fifo to
    61916214            // be empty
    6192             if ( (r_cc_receive_data_ins.read() == 0) and
    6193                  not (r_cc_receive_dcache_req.read()) and
    6194                  r_cc_receive_updt_fifo_be.empty() and
    6195                  (p_dspin_in.write.read()) )
    6196             {
     6215            if ( r_cc_receive_updt_fifo_be.empty() and
     6216                 p_dspin_m2p.write.read() )
     6217            {
     6218                r_cc_receive_dcache_req = true;
    61976219                r_cc_receive_dcache_nline  = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_NLINE);
    61986220                r_cc_receive_word_idx  = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_WORD_INDEX);
    61996221                r_cc_receive_dcache_type = CC_TYPE_UPDT;
    62006222                // get back to idle state
    6201                 r_cc_receive_fsm = CC_RECEIVE_UPDT_DATA;
     6223                r_cc_receive_fsm = CC_RECEIVE_DATA_UPDT_DATA;
    62026224                break;
    62036225            }
     6226            break;
     6227        }
     6228        ////////////////////////////
     6229        case CC_RECEIVE_INS_UPDT_NLINE:
     6230        {
     6231            // sample nline and word index in the second flit
     6232            uint64_t receive_data = p_dspin_m2p.data.read();
    62046233            // for ins INVAL, wait for icache to take the request and fifo to be
    62056234            // empty
    6206             if ( (r_cc_receive_data_ins.read() == 1) and
    6207                  not (r_cc_receive_icache_req.read()) and
    6208                  r_cc_receive_updt_fifo_be.empty() and
    6209                  (p_dspin_in.write.read()))
    6210             {
     6235            if ( r_cc_receive_updt_fifo_be.empty() and
     6236                 p_dspin_m2p.write.read() )
     6237            {
     6238                r_cc_receive_icache_req = true;
    62116239                r_cc_receive_icache_nline  = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_NLINE);
    62126240                r_cc_receive_word_idx  = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_WORD_INDEX);
    62136241                r_cc_receive_icache_type = CC_TYPE_UPDT;
    62146242                // get back to idle state
    6215                 r_cc_receive_fsm = CC_RECEIVE_UPDT_DATA;
     6243                r_cc_receive_fsm = CC_RECEIVE_INS_UPDT_DATA;
    62166244                break;
    62176245            }
    6218             // we should never get there
    6219             assert ( false && "ERROR in CC_VCACHE : CC_RECEIVE_UPDT_NLINE \n");
    62206246            break;
    62216247        }
    62226248        //////////////////////////
    6223         case CC_RECEIVE_UPDT_DATA:
    6224         {
    6225             if ((r_cc_receive_data_ins.read() == 0) and not (r_cc_receive_dcache_req.read()) and (p_dspin_in.write.read()))
    6226                 r_cc_receive_dcache_req = true;
    6227             if ((r_cc_receive_data_ins.read() == 1) and not (r_cc_receive_icache_req.read()) and (p_dspin_in.write.read()))
    6228                 r_cc_receive_icache_req = true;
    6229 
     6249        case CC_RECEIVE_DATA_UPDT_DATA:
     6250        {
    62306251            // wait for the fifo
    6231             if (r_cc_receive_updt_fifo_be.wok() and (p_dspin_in.write.read()))
    6232             {
    6233                 uint64_t receive_data = p_dspin_in.data.read();
    6234                 bool     receive_eop  = p_dspin_in.eop.read();
     6252            if (r_cc_receive_updt_fifo_be.wok() and (p_dspin_m2p.write.read()))
     6253            {
     6254                uint64_t receive_data = p_dspin_m2p.data.read();
     6255                bool     receive_eop  = p_dspin_m2p.eop.read();
    62356256                cc_receive_updt_fifo_be   = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_BE);
    62366257                cc_receive_updt_fifo_data = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_DATA);
     
    62416262            break;
    62426263        }
     6264        //////////////////////////
     6265        case CC_RECEIVE_INS_UPDT_DATA:
     6266        {
     6267            // wait for the fifo
     6268            if (r_cc_receive_updt_fifo_be.wok() and (p_dspin_m2p.write.read()))
     6269            {
     6270                uint64_t receive_data = p_dspin_m2p.data.read();
     6271                bool     receive_eop  = p_dspin_m2p.eop.read();
     6272                cc_receive_updt_fifo_be   = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_BE);
     6273                cc_receive_updt_fifo_data = DspinDhccpParam::dspin_get(receive_data,DspinDhccpParam::MULTI_UPDT_DATA);
     6274                cc_receive_updt_fifo_eop  = receive_eop;
     6275                cc_receive_updt_fifo_put  = true;
     6276                if ( receive_eop ) r_cc_receive_fsm = CC_RECEIVE_IDLE;
     6277            }
     6278            break;
     6279        }
     6280
    62436281    } // end switch CC_RECEIVE FSM
     6282
     6283    ///////////////// DSPIN CLACK interface ///////////////
     6284   
     6285    uint64_t clack_type = DspinDhccpParam::dspin_get(r_dspin_clack_flit.read(),
     6286                                                     DspinDhccpParam::CLACK_TYPE);
     6287
     6288    size_t clack_way  = DspinDhccpParam::dspin_get(r_dspin_clack_flit.read(),
     6289                                                   DspinDhccpParam::CLACK_WAY);
     6290
     6291    size_t clack_set  = DspinDhccpParam::dspin_get(r_dspin_clack_flit.read(),
     6292                                                   DspinDhccpParam::CLACK_SET);
     6293
     6294    bool dspin_clack_get      = false;
     6295    bool dcache_clack_request = (clack_type == DspinDhccpParam::TYPE_CLACK_DATA);
     6296    bool icache_clack_request = (clack_type == DspinDhccpParam::TYPE_CLACK_INST);
     6297
     6298    if (r_dspin_clack_req.read())
     6299    {
     6300        // CLACK DATA: Send request to DCACHE FSM
     6301        if (dcache_clack_request and not r_dcache_clack_req.read()){
     6302            r_dcache_clack_req = true;
     6303            r_dcache_clack_way = clack_way & ((1ULL<<(uint32_log2(m_dcache_ways)))-1);
     6304            r_dcache_clack_set = clack_set & ((1ULL<<(uint32_log2(m_dcache_sets)))-1);
     6305            dspin_clack_get    = true;
     6306        }
     6307
     6308        // CLACK INST: Send request to ICACHE FSM
     6309        else if (icache_clack_request and not r_icache_clack_req.read()){
     6310            r_icache_clack_req = true;
     6311            r_icache_clack_way = clack_way & ((1ULL<<(uint32_log2(m_dcache_ways)))-1);
     6312            r_icache_clack_set = clack_set & ((1ULL<<(uint32_log2(m_icache_sets)))-1);
     6313            dspin_clack_get    = true;
     6314        }
     6315    }
     6316    else
     6317    {
     6318        dspin_clack_get = true;
     6319    }
     6320
     6321    if (dspin_clack_get)
     6322    {
     6323        r_dspin_clack_req  = p_dspin_clack.write.read();
     6324        r_dspin_clack_flit = p_dspin_clack.data.read();
     6325    }
    62446326
    62456327    ///////////////// Response FIFOs update  //////////////////////
     
    64476529        case CC_SEND_IDLE:
    64486530        {
    6449             p_dspin_out.write = false;
     6531            p_dspin_p2m.write = false;
    64506532            break;
    64516533        }
     
    64546536        {
    64556537            // initialize dspin send data
     6538//            DspinDhccpParam::dspin_set(dspin_send_data,
     6539//                                       0,
     6540//                                       DspinDhccpParam::P2M_EOP);
    64566541            DspinDhccpParam::dspin_set(dspin_send_data,
    64576542                                       m_cc_global_id,
     
    64596544            DspinDhccpParam::dspin_set(dspin_send_data,
    64606545                                       0,
    6461                                        DspinDhccpParam::FROM_L1_BC);
     6546                                       DspinDhccpParam::P2M_BC);
    64626547
    64636548            if(r_cc_send_last_client.read() == 0) // dcache active request
     
    64806565                DspinDhccpParam::dspin_set(dspin_send_data,
    64816566                                           DspinDhccpParam::TYPE_CLEANUP_DATA,
    6482                                            DspinDhccpParam::FROM_L1_TYPE);
     6567                                           DspinDhccpParam::P2M_TYPE);
    64836568                /*ODCCP*/ // If cleanup on NCC line we set the CLEANUP_NCC bit in cleanup flit
    64846569                if (r_dcache_cleanup_ncc.read())                 
     
    65166601                DspinDhccpParam::dspin_set(dspin_send_data,
    65176602                                           DspinDhccpParam::TYPE_CLEANUP_INST,
    6518                                            DspinDhccpParam::FROM_L1_TYPE);
     6603                                           DspinDhccpParam::P2M_TYPE);
    65196604               
    65206605                DspinDhccpParam::dspin_set(dspin_send_data,
     
    65236608            }
    65246609            // send flit
    6525             p_dspin_out.data  = dspin_send_data;
    6526             p_dspin_out.write = true;
    6527             p_dspin_out.eop   = false;
     6610            p_dspin_p2m.data  = dspin_send_data;
     6611            p_dspin_p2m.write = true;
     6612            p_dspin_p2m.eop   = false;
    65286613            break;
    65296614        }
     
    65356620            if (r_dcache_cc_cleanup_updt_data.read() and not r_cc_send_last_client.read())
    65366621            {
    6537                 p_dspin_out.eop   = false;
     6622                p_dspin_p2m.eop   = false;
    65386623            }
    65396624            else
    65406625            {
    6541                 p_dspin_out.eop   = true;
     6626                p_dspin_p2m.eop   = true;
    65426627            }
    65436628
     
    65556640            }
    65566641            // send flit
    6557             p_dspin_out.data  = dspin_send_data;
    6558             p_dspin_out.write = true;
     6642            p_dspin_p2m.data  = dspin_send_data;
     6643            p_dspin_p2m.write = true;
    65596644            break;
    65606645        }
     
    65646649            if (r_cc_send_cpt_word.read() == m_dcache_words-1) /*ODCCP*/ // Last flit sent
    65656650            {
    6566                 p_dspin_out.eop   = true;
     6651                p_dspin_p2m.eop   = true;
    65676652            }
    65686653            else
    65696654            {
    6570                 p_dspin_out.eop   = false;
     6655                p_dspin_p2m.eop   = false;
    65716656            }
    65726657
     
    65756660                                       DspinDhccpParam::CLEANUP_DATA_UPDT);
    65766661           
    6577             p_dspin_out.data = dspin_send_data;
    6578             p_dspin_out.write = true;
     6662            p_dspin_p2m.data = dspin_send_data;
     6663            //p_dspin_p2m.write = true;
     6664            if(r_cc_send_data_fifo.rok())
     6665                p_dspin_p2m.write = true;
     6666            else
     6667                p_dspin_p2m.write = false;
    65796668            break;
    65806669        }
     
    65856674//            DspinDhccpParam::dspin_set(dspin_send_data,
    65866675//                                       1,
    6587 //                                       DspinDhccpParam::FROM_L1_EOP);
     6676//                                       DspinDhccpParam::P2M_EOP);
    65886677            DspinDhccpParam::dspin_set(dspin_send_data,
    65896678                                       0,
    6590                                        DspinDhccpParam::FROM_L1_BC);
     6679                                       DspinDhccpParam::P2M_BC);
    65916680            DspinDhccpParam::dspin_set(dspin_send_data,
    65926681                                       DspinDhccpParam::TYPE_MULTI_ACK,
    6593                                        DspinDhccpParam::FROM_L1_TYPE);
     6682                                       DspinDhccpParam::P2M_TYPE);
    65946683
    65956684            if(r_cc_send_last_client.read() == 0) // dcache active request
     
    66236712            }
    66246713            // send flit
    6625             p_dspin_out.data  = dspin_send_data;
    6626             p_dspin_out.write = true;
    6627             p_dspin_out.eop   = true;
     6714            p_dspin_p2m.data  = dspin_send_data;
     6715            p_dspin_p2m.write = true;
     6716            p_dspin_p2m.eop   = true;
    66286717
    66296718            break;
     
    66336722    // Receive coherence packets
    66346723    // It depends on the CC_RECEIVE FSM
    6635 
    66366724    switch( r_cc_receive_fsm.read() )
    66376725    {
     
    66396727        case CC_RECEIVE_IDLE:
    66406728        {
    6641             p_dspin_in.read = false;
    6642             break;
    6643         }
    6644         //////////////////////
    6645         case CC_RECEIVE_CLACK:
    6646         {
    6647             if (((r_cc_receive_data_ins.read() == 0) and not (r_cc_receive_dcache_req.read())) or
    6648                 ((r_cc_receive_data_ins.read() == 1) and not (r_cc_receive_icache_req.read())))
    6649                 p_dspin_in.read = true;
    6650             else
    6651                 p_dspin_in.read = false;
     6729            p_dspin_m2p.read = false;
    66526730            break;
    66536731        }
     
    66556733        case CC_RECEIVE_BRDCAST_HEADER:
    66566734        {
    6657             p_dspin_in.read = true;
     6735            p_dspin_m2p.read = true;
    66586736            break;
    66596737        }
     
    66656743            // flip_flop to check that ?
    66666744            if (not (r_cc_receive_icache_req.read()) and not (r_cc_receive_dcache_req.read()))
    6667                 p_dspin_in.read = true;
     6745                p_dspin_m2p.read = true;
    66686746            else
    6669                 p_dspin_in.read = false;
     6747                p_dspin_m2p.read = false;
    66706748            break;
    66716749        }
    66726750        /////////////////////////////
    6673         case CC_RECEIVE_INVAL_HEADER:
    6674         {
    6675             if (((r_cc_receive_data_ins.read() == 0) and not (r_cc_receive_dcache_req.read())) or
    6676                 ((r_cc_receive_data_ins.read() == 1) and not (r_cc_receive_icache_req.read())))
    6677                 p_dspin_in.read = true;
     6751        case CC_RECEIVE_DATA_INVAL_HEADER:
     6752        case CC_RECEIVE_INS_INVAL_HEADER:
     6753        {
     6754            p_dspin_m2p.read = true;
     6755            break;
     6756        }
     6757        ////////////////////////////
     6758        case CC_RECEIVE_DATA_INVAL_NLINE:
     6759        {
     6760            p_dspin_m2p.read = not r_cc_receive_dcache_req.read();
     6761            break;
     6762        }
     6763        case CC_RECEIVE_INS_INVAL_NLINE:
     6764        {
     6765            p_dspin_m2p.read = not r_cc_receive_icache_req.read();
     6766            break;
     6767        }
     6768        ///////////////////////////
     6769        case CC_RECEIVE_DATA_UPDT_HEADER:
     6770        {
     6771            if (not r_cc_receive_dcache_req.read())
     6772                p_dspin_m2p.read = true;
    66786773            else
    6679                 p_dspin_in.read = false;
     6774                p_dspin_m2p.read = false;
    66806775            break;
    66816776        }
    66826777        ////////////////////////////
    6683         case CC_RECEIVE_INVAL_NLINE:
    6684         {
    6685             p_dspin_in.read = true;
    6686             break;
    6687         }
    6688         ////////////////////////////
    6689         case CC_RECEIVE_UPDT_HEADER:
    6690         {
    6691             if (((r_cc_receive_data_ins.read() == 0) and
    6692                 not r_cc_receive_dcache_req.read() and
    6693                 r_cc_receive_updt_fifo_be.empty())
    6694                 or
    6695                 (((r_cc_receive_data_ins.read() == 1) and
    6696                 not r_cc_receive_icache_req.read()) and
    6697                 r_cc_receive_updt_fifo_be.empty()))
    6698                 p_dspin_in.read = true;
     6778        case CC_RECEIVE_INS_UPDT_HEADER:
     6779        {
     6780            if ( not r_cc_receive_icache_req.read())
     6781                p_dspin_m2p.read = true;
    66996782            else
    6700                 p_dspin_in.read = false;
     6783                p_dspin_m2p.read = false;
    67016784            break;
    67026785        }
    67036786        ///////////////////////////
    6704         case CC_RECEIVE_UPDT_NLINE:
    6705         {
    6706             if (((r_cc_receive_data_ins.read() == 0) and
    6707                 not (r_cc_receive_dcache_req.read()) and
    6708                 r_cc_receive_updt_fifo_be.empty())
    6709                 or
    6710                 ((r_cc_receive_data_ins.read() == 1) and
    6711                 not (r_cc_receive_icache_req.read()) and
    6712                 r_cc_receive_updt_fifo_be.empty()))
    6713                 p_dspin_in.read = true;
     6787        case CC_RECEIVE_DATA_UPDT_NLINE:
     6788        case CC_RECEIVE_INS_UPDT_NLINE:
     6789        {
     6790            if(r_cc_receive_updt_fifo_be.empty())
     6791                p_dspin_m2p.read = true;
    67146792            else
    6715                 p_dspin_in.read = false;
    6716             break;
    6717         }
    6718         //////////////////////////
    6719         case CC_RECEIVE_UPDT_DATA:
     6793                p_dspin_m2p.read = false;
     6794            break;
     6795        }
     6796        ///////////////////////////
     6797        case CC_RECEIVE_DATA_UPDT_DATA:
     6798        case CC_RECEIVE_INS_UPDT_DATA:
    67206799        {
    67216800            if (r_cc_receive_updt_fifo_be.wok())
    6722                 p_dspin_in.read = true;
     6801                p_dspin_m2p.read = true;
    67236802            else
    6724                 p_dspin_in.read = false;
     6803                p_dspin_m2p.read = false;
    67256804            break;
    67266805        }
    67276806    } // end switch CC_RECEIVE FSM
    67286807
     6808
     6809    int clack_type = DspinDhccpParam::dspin_get(r_dspin_clack_flit.read(),
     6810                                                DspinDhccpParam::CLACK_TYPE);
     6811
     6812    bool dspin_clack_get      = false;
     6813    bool dcache_clack_request = (clack_type == DspinDhccpParam::TYPE_CLACK_DATA);
     6814    bool icache_clack_request = (clack_type == DspinDhccpParam::TYPE_CLACK_INST);
     6815
     6816    if (r_dspin_clack_req.read())
     6817    {
     6818        // CLACK DATA: wait if pending request to DCACHE FSM
     6819        if (dcache_clack_request and not r_dcache_clack_req.read())
     6820        {
     6821            dspin_clack_get = true;
     6822        }
     6823
     6824        // CLACK INST: wait if pending request to ICACHE FSM
     6825        else if (icache_clack_request and not r_icache_clack_req.read())
     6826        {
     6827            dspin_clack_get = true;
     6828        }
     6829    }
     6830    else
     6831    {
     6832        dspin_clack_get = true;
     6833    }
     6834
     6835    p_dspin_clack.read = dspin_clack_get;
    67296836} // end genMoore
    67306837
Note: See TracChangeset for help on using the changeset viewer.