Index: branches/RWT/lib/generic_cache_tsar/include/generic_cache.h
===================================================================
--- branches/RWT/lib/generic_cache_tsar/include/generic_cache.h	(revision 771)
+++ branches/RWT/lib/generic_cache_tsar/include/generic_cache.h	(revision 814)
@@ -38,5 +38,5 @@
 // Hit if ( (matching tag) and (state == VALID).
 // The replacement policy is pseudo-LRU. The victim selection process cannot
-// fail if the ZOMBI state is not used. 
+// fail if the ZOMBI state is not used.
 // But it can fail if all ways are in ZOMBI state.
 /////////////////////////////////////////////////////////////////////////////////
@@ -49,5 +49,5 @@
 // Constructor parameters are :
 // - std::string    &name
-// - size_t         nways   : number of associativity levels 
+// - size_t         nways   : number of associativity levels
 // - size_t         nsets   : number of sets
 // - size_t         nwords  : number of words in a cache line
@@ -58,5 +58,5 @@
 /////////////////////////////////////////////////////////////////////////////////
 // Template parameter is :
-// - addr_t : address format to access the cache 
+// - addr_t : address format to access the cache
 /////////////////////////////////////////////////////////////////////////////////
 
@@ -71,5 +71,5 @@
 #include <cstring>
 
-namespace soclib { 
+namespace soclib {
 
 enum cache_slot_state_e
@@ -83,5 +83,5 @@
 //////////////////////////
 template<typename addr_t>
-class GenericCache 
+class GenericCache
 //////////////////////////
 {
@@ -94,6 +94,6 @@
     bool             *r_lru ;
 
-    size_t           m_ways;	
-    size_t           m_sets;	
+    size_t           m_ways;
+    size_t           m_sets;
     size_t           m_words;
 
@@ -119,5 +119,5 @@
         return r_lru[(way*m_sets)+set];
     }
-    
+
     //////////////////////////////////////////////
     inline int &cache_state(size_t way, size_t set)
@@ -126,21 +126,21 @@
     }
 
-    
+
     /////////////////////////////////////////////////
     inline void cache_set_lru(size_t way, size_t set)
     {
-	    size_t way2;
+        size_t way2;
 
         cache_lru(way, set) = true;
 
-	    for (way2 = 0; way2 < m_ways; way2++) 
-        {
-	        if (cache_lru(way2, set) == false) return;
-	    }
- 	    // all lines are new -> they all become old 
-	    for (way2 = 0; way2 < m_ways; way2++) 
-        {
-	        cache_lru(way2, set) = false;
-	    }
+        for (way2 = 0; way2 < m_ways; way2++)
+        {
+            if (cache_lru(way2, set) == false) return;
+        }
+        // all lines are new -> they all become old
+        for (way2 = 0; way2 < m_ways; way2++)
+        {
+            cache_lru(way2, set) = false;
+        }
     }
 
@@ -160,6 +160,6 @@
     //////////////////////////////////////////
     GenericCache(const std::string &name,
-                    size_t            nways, 
-                    size_t            nsets, 
+                    size_t            nways,
+                    size_t            nsets,
                     size_t            nwords)
         : m_ways(nways),
@@ -190,5 +190,5 @@
           << "- nsets  = " << nsets << std::endl
           << "- nwords = " << nwords << std::endl
-          << " m_x: " << m_x 
+          << " m_x: " << m_x
           << " m_y: " << m_y
           << " m_z: " << m_z
@@ -224,11 +224,11 @@
         return cache_state(way,set);
     }
-    
+
     /////////////////////////////////////////////////////////////////////
     // Read a single 32 bits word.
-    // returns true if (matching tag) and (state == VALID) 
-    // Both data & directory are accessed. 
+    // returns true if (matching tag) and (state == VALID)
+    // Both data & directory are accessed.
     /////////////////////////////////////////////////////////////////////
-    inline bool read(addr_t  ad, 
+    inline bool read(addr_t  ad,
                      data_t* dt)
     {
@@ -237,7 +237,7 @@
         const size_t word = m_x[ad];
 
-        for (size_t way = 0; way < m_ways; way++) 
-        {
-            if ((tag == cache_tag(way, set))  
+        for (size_t way = 0; way < m_ways; way++)
+        {
+            if ((tag == cache_tag(way, set))
                    && ((cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC)) )
             {
@@ -252,13 +252,13 @@
     ////////////////////////////////////////////////////////////////////
     // Read a single 32 bits word.
-    // returns true if (matching tag) and (state == VALID) 
-    // Both data & directory are accessed. 
+    // returns true if (matching tag) and (state == VALID)
+    // Both data & directory are accessed.
     // The selected way, set and word index are returned in case of hit.
     /////////////////////////////////////////////////////////////////////
-    inline bool read(addr_t ad, 
+    inline bool read(addr_t ad,
                      data_t* dt,
                      size_t* selway,
                      size_t* selset,
-                     size_t* selword) 
+                     size_t* selword)
     {
         const addr_t tag  = m_z[ad];
@@ -266,5 +266,5 @@
         const size_t word = m_x[ad];
 
-        for (size_t way = 0; way < m_ways; way++) 
+        for (size_t way = 0; way < m_ways; way++)
         {
             if ((tag == cache_tag(way, set)) and
@@ -286,8 +286,8 @@
     // Both data and directory are accessed.
     // returns the access status in the state argument:
-    // - VALID : (matching tag) and (state == VALID) 
-    // - ZOMBI : (matching tag) and (state == ZOMBI) 
+    // - VALID : (matching tag) and (state == VALID)
+    // - ZOMBI : (matching tag) and (state == ZOMBI)
     // - MISS  : no matching tag or EMPTY state
-    // If VALID or ZOMBI, the data, the way, set and word index are 
+    // If VALID or ZOMBI, the data, the way, set and word index are
     // returned in the other arguments.
     ////////////////////////////////////////////////////////////////////
@@ -297,5 +297,5 @@
                      size_t* selset,
                      size_t* selword,
-                     int*    state) 
+                     int*    state)
     {
         const addr_t tag  = m_z[ad];
@@ -303,5 +303,5 @@
         const size_t word = m_x[ad];
 
-        // default return values 
+        // default return values
         *state   = CACHE_SLOT_STATE_EMPTY;
         *selway  = 0;
@@ -310,5 +310,5 @@
         *dt      = 0;
 
-        for (size_t way = 0; way < m_ways; way++) 
+        for (size_t way = 0; way < m_ways; way++)
         {
             if (tag == cache_tag(way, set))  // matching tag
@@ -343,16 +343,16 @@
         }
     }
-              
+
     ////////////////////////////////////////////////////////////////////
     // Read a single 32 bits word, without LRU update.
-    // returns true if (matching tag) and (state == VALID) 
-    // Both data & directory are accessed. 
+    // returns true if (matching tag) and (state == VALID)
+    // Both data & directory are accessed.
     // The selected way, set and word index are returned in case of hit.
     /////////////////////////////////////////////////////////////////////
-    inline bool read_neutral(addr_t  ad, 
+    inline bool read_neutral(addr_t  ad,
                              data_t* dt,
                              size_t* selway,
                              size_t* selset,
-                             size_t* selword) 
+                             size_t* selword)
     {
         const addr_t tag  = m_z[ad];
@@ -360,7 +360,7 @@
         const size_t word = m_x[ad];
 
-        for (size_t way = 0; way < m_ways; way++) 
-        {
-            if ((tag == cache_tag(way, set))  
+        for (size_t way = 0; way < m_ways; way++)
+        {
+            if ((tag == cache_tag(way, set))
                    && ((cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC) or (cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC) ))
             {
@@ -377,6 +377,6 @@
     /////////////////////////////////////////////////////////////////////////////
     // Read one or two 32 bits word.
-    // Both data & directory are accessed. 
-    // Hit if (matching tag) and (valid == true) and (zombi == false) 
+    // Both data & directory are accessed.
+    // Hit if (matching tag) and (valid == true) and (zombi == false)
     // If the addressed word is not the last in the cache line,
     // two successive words are returned.
@@ -384,6 +384,6 @@
     // This function is used by the cc_vcache to get a 64 bits page table entry.
     /////////////////////////////////////////////////////////////////////////////
-    inline bool read( addr_t  ad, 
-                      data_t* dt, 
+    inline bool read( addr_t  ad,
+                      data_t* dt,
                       data_t* dt_next,
                       size_t* selway,
@@ -395,11 +395,11 @@
         const size_t word = m_x[ad];
 
-        for (size_t way = 0; way < m_ways; way++) 
-        {
-            if ((tag == cache_tag(way, set))   
-                   &&( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC))) 
+        for (size_t way = 0; way < m_ways; way++)
+        {
+            if ((tag == cache_tag(way, set))
+                   &&( (cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)))
             {
                 *dt = cache_data(way, set, word);
-                if (word + 1 < m_words) 
+                if (word + 1 < m_words)
                 {
                     *dt_next = cache_data(way, set, word + 1);
@@ -419,8 +419,8 @@
     // Both data and directory are accessed.
     // returns the access status in the state argument:
-    // - VALID : (matching tag) and (state == VALID) 
-    // - ZOMBI : (matching tag) and (state == ZOMBI) 
+    // - VALID : (matching tag) and (state == VALID)
+    // - ZOMBI : (matching tag) and (state == ZOMBI)
     // - MISS  : no matching tag or EMPTY state
-    // If VALID or ZOMBI, the data, the way, set and word index are 
+    // If VALID or ZOMBI, the data, the way, set and word index are
     // returned in the other arguments.
     ////////////////////////////////////////////////////////////////////
@@ -431,5 +431,5 @@
                      size_t* selset,
                      size_t* selword,
-                     int*    state) 
+                     int*    state)
     {
         const addr_t tag  = m_z[ad];
@@ -437,5 +437,5 @@
         const size_t word = m_x[ad];
 
-        // default return values 
+        // default return values
         *state   = CACHE_SLOT_STATE_EMPTY;
         *selway  = 0;
@@ -444,5 +444,5 @@
         *dt      = 0;
 
-        for (size_t way = 0; way < m_ways; way++) 
+        for (size_t way = 0; way < m_ways; way++)
         {
             if (tag == cache_tag(way, set))  // matching tag
@@ -456,5 +456,5 @@
                     *selword = word;
                     *dt      = cache_data(way, set, word);
-                    if (word + 1 < m_words) 
+                    if (word + 1 < m_words)
                     {
                         *dt_next = cache_data(way, set, word+1);
@@ -470,5 +470,5 @@
                     *selword = word;
                     *dt      = cache_data(way, set, word);
-                    if (word + 1 < m_words) 
+                    if (word + 1 < m_words)
                     {
                         *dt_next = cache_data(way, set, word + 1);
@@ -490,11 +490,11 @@
     ///////////////////////////////////////////////////////////////////////////////
     // Checks the cache state for a given address.
-    // Only the directory is accessed. 
-    // returns true if (matching tag) and (state == VALID) 
+    // Only the directory is accessed.
+    // returns true if (matching tag) and (state == VALID)
     // The selected way, set and first word index are returned in case of hit.
     // This function can be used when we need to access the directory
     // while we write in the data part with a different address in the same cycle.
     ///////////////////////////////////////////////////////////////////////////////
-    inline bool hit(addr_t  ad, 
+    inline bool hit(addr_t  ad,
                     size_t* selway,
                     size_t* selset,
@@ -505,8 +505,8 @@
         const size_t word = m_x[ad];
 
-        for (size_t way = 0; way < m_ways; way++) 
-        {
-            if ((tag == cache_tag(way, set)) 
-                   && ((cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)or(cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC))) 
+        for (size_t way = 0; way < m_ways; way++)
+        {
+            if ((tag == cache_tag(way, set))
+                   && ((cache_state(way, set) == CACHE_SLOT_STATE_VALID_CC)or(cache_state(way, set) == CACHE_SLOT_STATE_VALID_NCC)))
             {
                 *selway  = way;
@@ -519,11 +519,11 @@
         return false;
     }
-  
+
     ///////////////////////////////////////////////////////////////////////////////
     // Checks the cache state for a given address, when the ZOMBI state is used.
-    // Only the directory is accessed. 
+    // Only the directory is accessed.
     // Returns the access status in the state argument:
-    // - VALID if (matching tag) and (state == VALID) 
-    // - ZOMBI if (matching tag) and (state == ZOMBI) 
+    // - VALID if (matching tag) and (state == VALID)
+    // - ZOMBI if (matching tag) and (state == ZOMBI)
     // - EMPTY if no match or (state == EMPTY)
     // The selected way, set and first word index are returned if not empty.
@@ -531,5 +531,5 @@
     // while we write in the data part with a different address in the same cycle.
     ///////////////////////////////////////////////////////////////////////////////
-    inline void read_dir(addr_t  ad, 
+    inline void read_dir(addr_t  ad,
                          int*    state,
                          size_t* way,
@@ -540,8 +540,8 @@
         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++) 
-        {
-            if ((ad_tag == cache_tag(_way, ad_set)) and 
-                (cache_state(_way, ad_set) != CACHE_SLOT_STATE_EMPTY)) 
+        for (size_t _way = 0; _way < m_ways; _way++)
+        {
+            if ((ad_tag == cache_tag(_way, ad_set)) and
+                (cache_state(_way, ad_set) != CACHE_SLOT_STATE_EMPTY))
             {
                 *state = cache_state(_way, ad_set);
@@ -552,5 +552,5 @@
             }
         }
-        
+
         // return value if not (VALID or ZOMBI)
         *state = CACHE_SLOT_STATE_EMPTY;
@@ -559,5 +559,5 @@
     ///////////////////////////////////////////////////////////////////////////////
     // Checks the cache state for a slot (set,way), when the ZOMBI state is used.
-    // Only the directory is accessed. 
+    // Only the directory is accessed.
     // Returns the access status and the tag value in the state and tag argument.
     ///////////////////////////////////////////////////////////////////////////////
@@ -581,7 +581,7 @@
     // It does not use the directory and cannot miss.
     //////////////////////////////////////////////////////////////////
-    inline void write(size_t way, 
-                      size_t set, 
-                      size_t word, 
+    inline void write(size_t way,
+                      size_t set,
+                      size_t word,
                       data_t data)
     {
@@ -594,8 +594,8 @@
     // It does not use the directory and cannot miss.
     ////////////////////////////////////////////////////////////////////////////
-    inline void write(size_t way, 
-                      size_t set, 
-                      size_t word, 
-                      data_t data, 
+    inline void write(size_t way,
+                      size_t set,
+                      size_t word,
+                      data_t data,
                       be_t   be)
     {
@@ -610,6 +610,6 @@
     // It returns true if the line was valid, and returns the line index.
     //////////////////////////////////////////////////////////////////////////
-    inline bool inval(size_t  way, 
-                      size_t  set, 
+    inline bool inval(size_t  way,
+                      size_t  set,
                       addr_t* nline)
     {
@@ -626,12 +626,12 @@
     // This function selects a victim slot in an associative set.
     // It cannot fail, as a slot in ZOMBI state is considered EMPTY.
-    // - we search first an EMPTY slot 
+    // - we search first an EMPTY slot
     // - if no EMPTY slot, we search an OLD slot, using lru
-    // It returns the line index (Z + Y fields), the selected slot way and set, 
+    // It returns the line index (Z + Y fields), the selected slot way and set,
     // and a Boolean indicating that a cleanup is requested.
     //////////////////////////////////////////////////////////////////////////////////
-    inline bool victim_select(addr_t  ad, 
-                              addr_t* victim, 
-                              size_t* way, 
+    inline bool victim_select(addr_t  ad,
+                              addr_t* victim,
+                              size_t* way,
                               size_t* set)
     {
@@ -642,5 +642,5 @@
         *way = 0;
 
-        // Search first empty slot 
+        // Search first empty slot
         for (size_t _way = 0 ; _way < m_ways && !found ; _way++)
         {
@@ -653,7 +653,7 @@
         }
 
-        // If no empty slot, search first  old slot (lru == false) 
+        // If no empty slot, search first  old slot (lru == false)
         if (!found)
-        { 
+        {
             for (size_t _way = 0 ; _way < m_ways && !found ; _way++)
             {
@@ -678,10 +678,10 @@
     // - if no empty slot, we search an OLD slot not in ZOMBI state,
     // - if not found, we take the first not ZOMBI slot.
-    // It returns the line index (Z + Y fields), the selected slot way and set, 
+    // It returns the line index (Z + Y fields), the selected slot way and set,
     // and two Boolean indicating success and a required cleanup.
     //////////////////////////////////////////////////////////////////////////////////
-    inline void read_select(addr_t  ad, 
-                            addr_t* victim, 
-                            size_t* way, 
+    inline void read_select(addr_t  ad,
+                            addr_t* victim,
+                            size_t* way,
                             size_t* set,
                             bool*   found,
@@ -692,5 +692,5 @@
         *found = false;
 
-        // Search first empty slot 
+        // Search first empty slot
         for (size_t _way = 0 ; _way < m_ways && !(*found) ; _way++)
         {
@@ -704,9 +704,9 @@
             }
         }
-        
-        // Search first not zombi old slot 
+
+        // Search first not zombi old slot
         for (size_t _way = 0 ; _way < m_ways && !(*found) ; _way++)
         {
-            if (not cache_lru(_way, _set) and 
+            if (not cache_lru(_way, _set) and
                  (cache_state(_way, _set) != CACHE_SLOT_STATE_ZOMBI))
             {
@@ -722,5 +722,5 @@
         for (size_t _way = 0 ; _way < m_ways && !(*found) ; _way++)
         {
-            if (cache_state(_way, _set) != CACHE_SLOT_STATE_ZOMBI) 
+            if (cache_state(_way, _set) != CACHE_SLOT_STATE_ZOMBI)
             {
                 *found   = true;
@@ -742,6 +742,6 @@
     // identified by the way & set.
     //////////////////////////////////////////////////////////////////
-    inline void victim_update_tag(addr_t ad, 
-                                  size_t way, 
+    inline void victim_update_tag(addr_t ad,
+                                  size_t way,
                                   size_t set)
     {
@@ -757,6 +757,6 @@
     // identified by the way & set, when using the ZOMBI state.
     //////////////////////////////////////////////////////////////////
-    inline void write_dir(addr_t ad, 
-                          size_t way, 
+    inline void write_dir(addr_t ad,
+                          size_t way,
                           size_t set,
                           int    state)
@@ -787,5 +787,5 @@
     // It does not affect the tag
     //////////////////////////////////////////////////////////////////
-    inline void write_dir(size_t way, 
+    inline void write_dir(size_t way,
                           size_t set,
                           int    state)
@@ -813,7 +813,7 @@
     // Both DATA and DIRECTORY are written
     ///////////////////////////////////////////////////////////////////
-    inline void update(addr_t  ad, 
-                       size_t  way, 
-                       size_t  set, 
+    inline void update(addr_t  ad,
+                       size_t  way,
+                       size_t  set,
                        data_t* buf)
     {
@@ -823,5 +823,5 @@
         cache_state(way, set) = CACHE_SLOT_STATE_VALID_CC;
         cache_set_lru(way, set);
-        for (size_t word = 0 ; word < m_words ; word++) 
+        for (size_t word = 0 ; word < m_words ; word++)
         {
             cache_data(way, set, word) = buf[word] ;
@@ -832,14 +832,14 @@
     void fileTrace(FILE* file)
     {
-        for (size_t nway = 0 ; nway < m_ways ; nway++) 
-        {
-            for (size_t nset = 0 ; nset < m_sets ; nset++) 
+        for (size_t nway = 0 ; nway < m_ways ; nway++)
+        {
+            for (size_t nset = 0 ; nset < m_sets ; nset++)
             {
                 fprintf(file, "%d / ", (int)cache_state(nway, nset));
                 fprintf(file, "way %d / ", (int)nway);
                 fprintf(file, "set %d / ", (int)nset);
-                fprintf(file, "@ = %08zX / ", 
+                fprintf(file, "@ = %08zX / ",
                         ((cache_tag(nway, nset) * m_sets + nset) * m_words * 4));
-                for (size_t nword = m_words ; nword > 0 ; nword--) 
+                for (size_t nword = m_words ; nword > 0 ; nword--)
                 {
                     unsigned int data = cache_data(nway, nset, nword - 1);
@@ -854,12 +854,12 @@
     inline void printTrace()
     {
-        for (size_t way = 0; way < m_ways ; way++) 
+        for (size_t way = 0; way < m_ways ; way++)
         {
             for (size_t set = 0 ; set < m_sets ; set++)
             {
                 addr_t addr = (((addr_t)cache_tag(way,set))*m_words*m_sets+m_words*set)*4;
-                std::cout << std::dec << cache_state(way, set) 
-                          << " | way " << way 
-                          << " | set " << set 
+                std::cout << std::dec << cache_state(way, set)
+                          << " | way " << way
+                          << " | set " << set
                           << std::hex << " | @ " << addr;
 
@@ -872,5 +872,5 @@
         }
     }
-   
+
 };
 
