Ignore:
Timestamp:
Jul 19, 2013, 2:34:03 PM (11 years ago)
Author:
devigne
Message:

Introducing merged components between the last trunk TSAR version
and the ODCCP modifications

Location:
branches/ODCCP/lib/generic_cache_tsar
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/ODCCP/lib/generic_cache_tsar/include/generic_cache.h

    r393 r460  
    7676{
    7777    CACHE_SLOT_STATE_EMPTY,
    78     CACHE_SLOT_STATE_VALID,
     78    CACHE_SLOT_STATE_VALID_CC,
    7979    CACHE_SLOT_STATE_ZOMBI,
     80    CACHE_SLOT_STATE_VALID_NCC,
    8081};
    8182
     
    118119        return r_lru[(way*m_sets)+set];
    119120    }
    120 
     121   
    121122    //////////////////////////////////////////////
    122123    inline int &cache_state(size_t way, size_t set)
     
    125126    }
    126127
     128   
    127129    /////////////////////////////////////////////////
    128130    inline void cache_set_lru(size_t way, size_t set)
     
    218220    }
    219221
     222    inline int get_cache_state(int way, int set)
     223    {
     224        return cache_state(way,set);
     225    }
     226   
    220227    /////////////////////////////////////////////////////////////////////
    221228    // Read a single 32 bits word.
     
    233240        {
    234241            if ( (tag == cache_tag(way, set)) 
    235                    && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     242                   && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC)) )
    236243            {
    237244                *dt = cache_data(way, set, word);
     
    262269        {
    263270            if ( (tag == cache_tag(way, set)) and
    264                  (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     271                 ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC)))
    265272            {
    266273                *selway  = way;
     
    308315            {
    309316
    310                 if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID )
     317                if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC )
    311318                {
    312                     *state   = CACHE_SLOT_STATE_VALID;
     319                    *state   = CACHE_SLOT_STATE_VALID_CC;
     320                    *selway  = way;
     321                    *selset  = set;
     322                    *selword = word;
     323                    *dt      = cache_data(way, set, word);
     324                    cache_set_lru(way, set);
     325                }
     326                else if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC )
     327                {
     328                    *state   = CACHE_SLOT_STATE_VALID_NCC;
    313329                    *selway  = way;
    314330                    *selset  = set;
     
    347363        {
    348364            if ( (tag == cache_tag(way, set)) 
    349                    && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     365                   && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC) ) )
    350366            {
    351367                *selway  = way;
     
    382398        {
    383399            if ( (tag == cache_tag(way, set))   
    384                    && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     400                   &&( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) )
    385401            {
    386402                *dt      = cache_data(way, set, word);
     
    433449            {
    434450
    435                 if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID )
     451                if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC )
    436452                {
    437                     *state   = CACHE_SLOT_STATE_VALID;
     453                    *state   = CACHE_SLOT_STATE_VALID_CC;
    438454                    *selway  = way;
    439455                    *selset  = set;
     
    446462                    cache_set_lru(way, set);
    447463                }
     464
     465                /*else if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC )
     466                {
     467                    *state   = CACHE_SLOT_STATE_VALID_NCC;
     468                    *selway  = way;
     469                    *selset  = set;
     470                    *selword = word;
     471                    *dt      = cache_data(way, set, word);
     472                    if ( word+1 < m_words)
     473                    {
     474                        *dt_next = cache_data(way, set, word+1);
     475                    }
     476                    cache_set_lru(way, set);
     477                }*/
     478
    448479                else if ( cache_state(way, set) == CACHE_SLOT_STATE_ZOMBI )
    449480                {
     
    477508        {
    478509            if ( (tag == cache_tag(way, set))
    479                    && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     510                   && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)or(cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC) ) )
    480511            {
    481512                *selway  = way;
     
    509540        const size_t      ad_set  = m_y[ad];
    510541        const size_t      ad_word = m_x[ad];
    511 
    512542        for ( size_t _way = 0; _way < m_ways; _way++ )
    513543        {
     
    556586                      data_t    data)
    557587    {
     588       /**/ //std::cout << "write cache : way = "<<way<<" | set = "<<set<<" | word = "<<word<<" | data = "<<(uint32_t)data << std::endl;
    558589        cache_data(way, set, word) = data;
    559590        cache_set_lru(way, set);
     
    584615                      addr_t*   nline)
    585616    {
    586         if ( cache_state(way,set) == CACHE_SLOT_STATE_VALID )
     617        if( (cache_state(way,set) == CACHE_SLOT_STATE_VALID_CC) )
    587618        {
    588619            cache_state(way,set) = CACHE_SLOT_STATE_EMPTY;
     
    615646        for ( size_t _way = 0 ; _way < m_ways && !found ; _way++ )
    616647        {
    617             if ( cache_state(_way, *set) != CACHE_SLOT_STATE_VALID )  // empty
     648            if( ( cache_state(_way, *set) != CACHE_SLOT_STATE_VALID_CC ) )  // empty
    618649            {
    619650                found   = true;
     
    674705            }
    675706        }
     707        //////////////////////////////////////////////////////////////
     708        /*for ( size_t _way = 0 ; _way < m_ways && !(*found) ; _way++ )
     709        {
     710            if ( not cache_lru(_way, _set) and
     711                 (cache_state(_way, _set) != CACHE_SLOT_STATE_ZOMBI) and
     712                 (cache_state(_way, _set) == CACHE_SLOT_STATE_VALID_NCC) )
     713            {
     714                *found   = true;
     715                *cleanup = true;
     716                *way     = _way;
     717                *set     = m_y[ad];
     718                *victim  = (addr_t)((cache_tag(*way,_set) * m_sets) + _set);
     719                return;
     720            }
     721        }*/
    676722        // Search first not zombi old slot
    677723        for ( size_t _way = 0 ; _way < m_ways && !(*found) ; _way++ )
     
    718764
    719765        cache_tag(way, set)   = tag;
    720         cache_state(way, set) = CACHE_SLOT_STATE_VALID;
     766        cache_state(way, set) = CACHE_SLOT_STATE_VALID_CC;
    721767        cache_set_lru(way, set);
    722768    }
     
    733779        addr_t  tag     = m_z[ad];
    734780
    735         assert( ( (state == CACHE_SLOT_STATE_VALID) or
     781        assert( ( (state == CACHE_SLOT_STATE_VALID_CC) or
     782                  (state == CACHE_SLOT_STATE_VALID_NCC) or
    736783                  (state == CACHE_SLOT_STATE_ZOMBI) or
    737784                  (state == CACHE_SLOT_STATE_EMPTY) ) and
     
    747794        cache_state(way, set) = state;
    748795
    749         if ( state == CACHE_SLOT_STATE_VALID ) cache_set_lru(way, set);
     796        if ( (state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC) ) cache_set_lru(way, set);
    750797    }
    751798
     
    759806                           int      state)
    760807    {
    761         assert( ( (state == CACHE_SLOT_STATE_VALID) or
     808        assert( ( (state == CACHE_SLOT_STATE_VALID_CC) or
     809                  (state == CACHE_SLOT_STATE_VALID_NCC) or
    762810                  (state == CACHE_SLOT_STATE_ZOMBI) or
    763811                  (state == CACHE_SLOT_STATE_EMPTY) ) and
     
    772820        cache_state(way, set) = state;
    773821
    774         if ( state == CACHE_SLOT_STATE_VALID ) cache_set_lru(way, set);
     822        if ( (state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC) ) cache_set_lru(way, set);
    775823    }
    776824
     
    788836
    789837        cache_tag(way, set)   = tag;
    790         cache_state(way, set) = CACHE_SLOT_STATE_VALID;
     838        cache_state(way, set) = CACHE_SLOT_STATE_VALID_CC;
    791839        cache_set_lru(way, set);
    792840        for ( size_t word = 0 ; word < m_words ; word++ )
     
    853901        {
    854902            if ( (tag == cache_tag(way, set)) and
    855                  (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     903                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) )
    856904            {
    857905                hit                   = true;
     
    878926        {
    879927            if ( (tag == cache_tag(way, set)) and
    880                  (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     928                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) )
    881929            {
    882930                hit                   = true;
     
    923971        {
    924972            if ( (tag == cache_tag(way, set)) and
    925                  (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     973                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) )
    926974            {
    927975                cache_data(way, set, word) = dt;
     
    948996        {
    949997            if ( (tag == cache_tag(way, set)) and
    950                  (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     998                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) )
    951999            {
    9521000                data_t mask = be2mask(be);
     
    9751023        {
    9761024            if ( (tag == cache_tag(way, set)) and
    977                  (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     1025                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) )
    9781026            {
    9791027                cache_data(way, set, word) = dt;
     
    10021050        {
    10031051            if ( (tag == cache_tag(way, set)) and
    1004                  (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
     1052                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) )
    10051053            {
    10061054                data_t mask = be2mask(be);
Note: See TracChangeset for help on using the changeset viewer.