Index: branches/ODCCP/lib/generic_cache_tsar/include/generic_cache.h
===================================================================
--- trunk/lib/generic_cache_tsar/include/generic_cache.h	(revision 393)
+++ branches/ODCCP/lib/generic_cache_tsar/include/generic_cache.h	(revision 460)
@@ -76,6 +76,7 @@
 {
     CACHE_SLOT_STATE_EMPTY,
-    CACHE_SLOT_STATE_VALID,
+    CACHE_SLOT_STATE_VALID_CC,
     CACHE_SLOT_STATE_ZOMBI,
+    CACHE_SLOT_STATE_VALID_NCC,
 };
 
@@ -118,5 +119,5 @@
         return r_lru[(way*m_sets)+set];
     }
-
+    
     //////////////////////////////////////////////
     inline int &cache_state(size_t way, size_t set)
@@ -125,4 +126,5 @@
     }
 
+    
     /////////////////////////////////////////////////
     inline void cache_set_lru(size_t way, size_t set)
@@ -218,4 +220,9 @@
     }
 
+    inline int get_cache_state(int way, int set)
+    {
+        return cache_state(way,set);
+    }
+    
     /////////////////////////////////////////////////////////////////////
     // Read a single 32 bits word.
@@ -233,5 +240,5 @@
         {
             if ( (tag == cache_tag(way, set))  
-                   && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
+                   && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC)) )
             {
                 *dt = cache_data(way, set, word);
@@ -262,5 +269,5 @@
         {
             if ( (tag == cache_tag(way, set)) and
-                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
+                 ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC)))
             {
                 *selway  = way;
@@ -308,7 +315,16 @@
             {
 
-                if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID )
+                if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC )
                 {
-                    *state   = CACHE_SLOT_STATE_VALID;
+                    *state   = CACHE_SLOT_STATE_VALID_CC;
+                    *selway  = way;
+                    *selset  = set;
+                    *selword = word;
+                    *dt      = cache_data(way, set, word);
+                    cache_set_lru(way, set);
+                }
+                else if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC )
+                {
+                    *state   = CACHE_SLOT_STATE_VALID_NCC;
                     *selway  = way;
                     *selset  = set;
@@ -347,5 +363,5 @@
         {
             if ( (tag == cache_tag(way, set))  
-                   && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) )
+                   && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC) ) )
             {
                 *selway  = way;
@@ -382,5 +398,5 @@
         {
             if ( (tag == cache_tag(way, set))   
-                   && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) ) 
+                   &&( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) ) 
             {
                 *dt      = cache_data(way, set, word);
@@ -433,7 +449,7 @@
             {
 
-                if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID )
+                if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC )
                 {
-                    *state   = CACHE_SLOT_STATE_VALID;
+                    *state   = CACHE_SLOT_STATE_VALID_CC;
                     *selway  = way;
                     *selset  = set;
@@ -446,4 +462,19 @@
                     cache_set_lru(way, set);
                 }
+
+                /*else if ( cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC )
+                {
+                    *state   = CACHE_SLOT_STATE_VALID_NCC;
+                    *selway  = way;
+                    *selset  = set;
+                    *selword = word;
+                    *dt      = cache_data(way, set, word);
+                    if ( word+1 < m_words) 
+                    {
+                        *dt_next = cache_data(way, set, word+1);
+                    }
+                    cache_set_lru(way, set);
+                }*/
+
                 else if ( cache_state(way, set) == CACHE_SLOT_STATE_ZOMBI )
                 {
@@ -477,5 +508,5 @@
         {
             if ( (tag == cache_tag(way, set)) 
-                   && (cache_state(way, set) == CACHE_SLOT_STATE_VALID) ) 
+                   && ( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)or(cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC) ) ) 
             {
                 *selway  = way;
@@ -509,5 +540,4 @@
         const size_t      ad_set  = m_y[ad];
         const size_t      ad_word = m_x[ad];
-
         for ( size_t _way = 0; _way < m_ways; _way++ ) 
         {
@@ -556,4 +586,5 @@
                       data_t 	data)
     {
+       /**/ //std::cout << "write cache : way = "<<way<<" | set = "<<set<<" | word = "<<word<<" | data = "<<(uint32_t)data << std::endl;
         cache_data(way, set, word) = data;
         cache_set_lru(way, set);
@@ -584,5 +615,5 @@
                       addr_t* 	nline)
     {
-        if ( cache_state(way,set) == CACHE_SLOT_STATE_VALID ) 
+        if( (cache_state(way,set) == CACHE_SLOT_STATE_VALID_CC) )
         {
             cache_state(way,set) = CACHE_SLOT_STATE_EMPTY;
@@ -615,5 +646,5 @@
         for ( size_t _way = 0 ; _way < m_ways && !found ; _way++ )
         {
-            if ( cache_state(_way, *set) != CACHE_SLOT_STATE_VALID )  // empty
+            if( ( cache_state(_way, *set) != CACHE_SLOT_STATE_VALID_CC ) )  // empty
             {
                 found   = true;
@@ -674,4 +705,19 @@
             }
         }
+        //////////////////////////////////////////////////////////////
+        /*for ( size_t _way = 0 ; _way < m_ways && !(*found) ; _way++ )
+        {
+            if ( not cache_lru(_way, _set) and 
+                 (cache_state(_way, _set) != CACHE_SLOT_STATE_ZOMBI) and
+                 (cache_state(_way, _set) == CACHE_SLOT_STATE_VALID_NCC) )
+            {
+                *found   = true;
+                *cleanup = true;
+                *way     = _way;
+                *set     = m_y[ad];
+                *victim  = (addr_t)((cache_tag(*way,_set) * m_sets) + _set);
+                return;
+            }
+        }*/
         // Search first not zombi old slot 
         for ( size_t _way = 0 ; _way < m_ways && !(*found) ; _way++ )
@@ -718,5 +764,5 @@
 
         cache_tag(way, set)   = tag;
-        cache_state(way, set) = CACHE_SLOT_STATE_VALID;
+        cache_state(way, set) = CACHE_SLOT_STATE_VALID_CC;
         cache_set_lru(way, set);
     }
@@ -733,5 +779,6 @@
         addr_t  tag     = m_z[ad];
 
-        assert( ( (state == CACHE_SLOT_STATE_VALID) or 
+        assert( ( (state == CACHE_SLOT_STATE_VALID_CC) or
+                  (state == CACHE_SLOT_STATE_VALID_NCC) or
                   (state == CACHE_SLOT_STATE_ZOMBI) or
                   (state == CACHE_SLOT_STATE_EMPTY) ) and
@@ -747,5 +794,5 @@
         cache_state(way, set) = state;
 
-        if ( state == CACHE_SLOT_STATE_VALID ) cache_set_lru(way, set);
+        if ( (state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC) ) cache_set_lru(way, set);
     }
 
@@ -759,5 +806,6 @@
                            int      state)
     {
-        assert( ( (state == CACHE_SLOT_STATE_VALID) or 
+        assert( ( (state == CACHE_SLOT_STATE_VALID_CC) or
+                  (state == CACHE_SLOT_STATE_VALID_NCC) or
                   (state == CACHE_SLOT_STATE_ZOMBI) or
                   (state == CACHE_SLOT_STATE_EMPTY) ) and
@@ -772,5 +820,5 @@
         cache_state(way, set) = state;
 
-        if ( state == CACHE_SLOT_STATE_VALID ) cache_set_lru(way, set);
+        if ( (state == CACHE_SLOT_STATE_VALID_CC) or (state == CACHE_SLOT_STATE_VALID_NCC) ) cache_set_lru(way, set);
     }
 
@@ -788,5 +836,5 @@
 
         cache_tag(way, set)   = tag;
-        cache_state(way, set) = CACHE_SLOT_STATE_VALID;
+        cache_state(way, set) = CACHE_SLOT_STATE_VALID_CC;
         cache_set_lru(way, set);
         for ( size_t word = 0 ; word < m_words ; word++ ) 
@@ -853,5 +901,5 @@
         {
             if ( (tag == cache_tag(way, set)) and
-                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID) ) 
+                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 
             {
                 hit                   = true;
@@ -878,5 +926,5 @@
         {
             if ( (tag == cache_tag(way, set)) and 
-                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID) ) 
+                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 
             {
                 hit                   = true;
@@ -923,5 +971,5 @@
         {
             if ( (tag == cache_tag(way, set)) and
-                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID) ) 
+                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 
             {
                 cache_data(way, set, word) = dt;
@@ -948,5 +996,5 @@
         {
             if ( (tag == cache_tag(way, set)) and 
-                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID) ) 
+                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 
             {
                 data_t mask = be2mask(be);
@@ -975,5 +1023,5 @@
         {
             if ( (tag == cache_tag(way, set)) and
-                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID) ) 
+                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 
             {
                 cache_data(way, set, word) = dt;
@@ -1002,5 +1050,5 @@
         {
             if ( (tag == cache_tag(way, set)) and 
-                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID) ) 
+                 (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) ) 
             {
                 data_t mask = be2mask(be);
