Ignore:
Timestamp:
Sep 24, 2014, 3:48:50 PM (10 years ago)
Author:
devigne
Message:

RWT commit : Cosmetic (Remove trailing whitespace)

Location:
branches/RWT/modules/vci_mem_cache
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/RWT/modules/vci_mem_cache

  • branches/RWT/modules/vci_mem_cache/caba/source/include

  • branches/RWT/modules/vci_mem_cache/caba/source/include/mem_cache_directory.h

    r495 r814  
    11#ifndef SOCLIB_CABA_MEM_CACHE_DIRECTORY_H
    2 #define SOCLIB_CABA_MEM_CACHE_DIRECTORY_H 
     2#define SOCLIB_CABA_MEM_CACHE_DIRECTORY_H
    33
    44#include <inttypes.h>
     
    1414
    1515  ////////////////////////////////////////////////////////////////////////
    16   //                    A LRU entry 
     16  //                    A LRU entry
    1717  ////////////////////////////////////////////////////////////////////////
    1818  class LruEntry {
     
    2020    public:
    2121
    22       bool recent;           
     22      bool recent;
    2323
    2424      void init()
     
    3333  ////////////////////////////////////////////////////////////////////////
    3434  class Owner{
    35    
     35
    3636    public:
    3737    // Fields
     
    6666
    6767  ////////////////////////////////////////////////////////////////////////
    68   //                    A directory entry                               
     68  //                    A directory entry
    6969  ////////////////////////////////////////////////////////////////////////
    7070  class DirectoryEntry {
     
    8181    tag_t   tag;                    // tag of the entry
    8282    size_t  count;                  // number of copies
    83     Owner   owner;                  // an owner of the line 
     83    Owner   owner;                  // an owner of the line
    8484    size_t  ptr;                    // pointer to the next owner
    8585
     
    109109      owner         = source.owner;
    110110      ptr           = source.ptr;
    111     }         
    112 
    113     /////////////////////////////////////////////////////////////////////
    114     // The init() function initializes the entry 
     111    }
     112
     113    /////////////////////////////////////////////////////////////////////
     114    // The init() function initializes the entry
    115115    /////////////////////////////////////////////////////////////////////
    116116    void init()
     
    125125
    126126    /////////////////////////////////////////////////////////////////////
    127     // The copy() function copies an existing source entry to a target 
     127    // The copy() function copies an existing source entry to a target
    128128    /////////////////////////////////////////////////////////////////////
    129129    void copy(const DirectoryEntry &source)
    130130    {
    131       valid         = source.valid;
     131      valid     = source.valid;
    132132      cache_coherent = source.cache_coherent;
    133133      is_cnt    = source.is_cnt;
    134       dirty         = source.dirty;
    135       lock          = source.lock;
    136       tag           = source.tag;
     134      dirty     = source.dirty;
     135      lock      = source.lock;
     136      tag       = source.tag;
    137137      count     = source.count;
    138138      owner     = source.owner;
     
    141141
    142142    ////////////////////////////////////////////////////////////////////
    143     // The print() function prints the entry 
     143    // The print() function prints the entry
    144144    ////////////////////////////////////////////////////////////////////
    145145    void print()
    146146    {
    147       std::cout << "Valid = " << valid 
     147      std::cout << "Valid = " << valid
    148148                << " ; COHERENCE = " << cache_coherent
    149                 << " ; IS COUNT = " << is_cnt 
    150                 << " ; Dirty = " << dirty 
    151                 << " ; Lock = " << lock 
    152                 << " ; Tag = " << std::hex << tag << std::dec 
    153                 << " ; Count = " << count 
    154                 << " ; Owner = " << owner.srcid 
    155                 << " " << owner.inst 
     149                << " ; IS COUNT = " << is_cnt
     150                << " ; Dirty = " << dirty
     151                << " ; Lock = " << lock
     152                << " ; Tag = " << std::hex << tag << std::dec
     153                << " ; Count = " << count
     154                << " ; Owner = " << owner.srcid
     155                << " " << owner.inst
    156156                << " ; Pointer = " << ptr << std::endl;
    157157    }
     
    160160
    161161  ////////////////////////////////////////////////////////////////////////
    162   //                       The directory 
     162  //                       The directory
    163163  ////////////////////////////////////////////////////////////////////////
    164164  class CacheDirectory {
     
    171171
    172172    // Directory constants
    173     size_t                                      m_ways;
    174     size_t                                      m_sets;
    175     size_t                                      m_words;
    176     size_t                                      m_width;
    177     uint32_t                lfsr;
     173    size_t   m_ways;
     174    size_t   m_sets;
     175    size_t   m_words;
     176    size_t   m_width;
     177    uint32_t lfsr;
    178178
    179179    // the directory & lru tables
    180     DirectoryEntry                              **m_dir_tab;
    181     LruEntry                                    **m_lru_tab;
     180    DirectoryEntry **m_dir_tab;
     181    LruEntry       **m_lru_tab;
    182182
    183183    public:
     
    186186    // Constructor
    187187    ////////////////////////
    188     CacheDirectory( size_t ways, size_t sets, size_t words, size_t address_width)       
    189     {
    190       m_ways  = ways; 
     188    CacheDirectory( size_t ways, size_t sets, size_t words, size_t address_width)
     189    {
     190      m_ways  = ways;
    191191      m_sets  = sets;
    192192      m_words = words;
     
    223223    // LRU is updated.
    224224    // Arguments :
    225     // - address : the address of the entry 
     225    // - address : the address of the entry
    226226    // - way : (return argument) the way of the entry in case of hit
    227     // The function returns a copy of a (valid or invalid) entry 
     227    // The function returns a copy of a (valid or invalid) entry
    228228    /////////////////////////////////////////////////////////////////////
    229229    DirectoryEntry read(const addr_t &address, size_t &way)
     
    240240        bool valid = m_dir_tab[set][i].valid;
    241241        hit = equal && valid;
    242         if ( hit ) {                   
     242        if ( hit ) {
    243243          way = i;
    244244          break;
    245         } 
     245        }
    246246      }
    247247      if ( hit ) {
     
    255255    /////////////////////////////////////////////////////////////////////
    256256    // The inval function invalidate an entry defined by the set and
    257     // way arguments. 
     257    // way arguments.
    258258    /////////////////////////////////////////////////////////////////////
    259259    void inval( const size_t &way, const size_t &set )
     
    266266    // changing the LRU
    267267    // Arguments :
    268     // - address : the address of the entry 
    269     // The function returns a copy of a (valid or invalid) entry 
    270     /////////////////////////////////////////////////////////////////////
    271     DirectoryEntry read_neutral( const addr_t &address, 
     268    // - address : the address of the entry
     269    // The function returns a copy of a (valid or invalid) entry
     270    /////////////////////////////////////////////////////////////////////
     271    DirectoryEntry read_neutral( const addr_t &address,
    272272                                 size_t*      ret_way,
    273273                                 size_t*      ret_set )
     
    279279#undef L2
    280280
    281         for ( size_t way = 0 ; way < m_ways ; way++ ) 
     281        for ( size_t way = 0 ; way < m_ways ; way++ )
    282282        {
    283283            bool equal = ( m_dir_tab[set][way].tag == tag );
     
    286286            {
    287287                *ret_set = set;
    288                 *ret_way = way; 
     288                *ret_way = way;
    289289                return DirectoryEntry(m_dir_tab[set][way]);
    290290            }
    291         } 
     291        }
    292292        return DirectoryEntry();
    293293    } // end read_neutral()
    294294
    295295    /////////////////////////////////////////////////////////////////////
    296     // The write function writes a new entry, 
     296    // The write function writes a new entry,
    297297    // and updates the LRU bits if necessary.
    298298    // Arguments :
     
    301301    // - entry : the entry value
    302302    /////////////////////////////////////////////////////////////////////
    303     void write( const size_t         &set, 
    304                 const size_t         &way, 
     303    void write( const size_t         &set,
     304                const size_t         &way,
    305305                const DirectoryEntry &entry)
    306306    {
    307       assert( (set<m_sets) 
     307      assert( (set<m_sets)
    308308          && "Cache Directory write : The set index is invalid");
    309       assert( (way<m_ways) 
     309      assert( (way<m_ways)
    310310          && "Cache Directory write : The way index is invalid");
    311311
     
    315315      // update LRU bits
    316316      bool all_recent = true;
    317       for ( size_t i=0 ; i<m_ways ; i++ ) 
     317      for ( size_t i=0 ; i<m_ways ; i++ )
    318318      {
    319319          if ( i != way ) all_recent = m_lru_tab[set][i].recent && all_recent;
    320320      }
    321       if ( all_recent ) 
     321      if ( all_recent )
    322322      {
    323323          for( size_t i=0 ; i<m_ways ; i++ ) m_lru_tab[set][i].recent = false;
    324       } 
    325       else 
     324      }
     325      else
    326326      {
    327327          m_lru_tab[set][way].recent = true;
     
    349349    DirectoryEntry select(const size_t &set, size_t &way)
    350350    {
    351         assert( (set < m_sets) 
     351        assert( (set < m_sets)
    352352          && "Cache Directory : (select) The set index is invalid");
    353353
     
    404404
    405405    /////////////////////////////////////////////////////////////////////
    406     //          Global initialisation function
     406    //               Global initialisation function
    407407    /////////////////////////////////////////////////////////////////////
    408408    void init()
    409409    {
    410       for ( size_t set=0 ; set<m_sets ; set++ ) 
    411       {
    412         for ( size_t way=0 ; way<m_ways ; way++ ) 
     410      for ( size_t set=0 ; set<m_sets ; set++ )
     411      {
     412        for ( size_t way=0 ; way<m_ways ; way++ )
    413413        {
    414414          m_dir_tab[set][way].init();
     
    446446        owner.inst  = entry.owner.inst;
    447447        owner.srcid = entry.owner.srcid;
    448         next           = entry.next;
     448        next        = entry.next;
    449449      } // end constructor
    450450
    451451    /////////////////////////////////////////////////////////////////////
    452     // The copy() function copies an existing source entry to a target 
     452    // The copy() function copies an existing source entry to a target
    453453    /////////////////////////////////////////////////////////////////////
    454454      void copy(const HeapEntry &entry)
    455455      {
    456         owner.inst     = entry.owner.inst;
    457         owner.srcid    = entry.owner.srcid;
    458         next           = entry.next;
     456        owner.inst  = entry.owner.inst;
     457        owner.srcid = entry.owner.srcid;
     458        next        = entry.next;
    459459      } // end copy()
    460460
    461461    ////////////////////////////////////////////////////////////////////
    462     // The print() function prints the entry 
     462    // The print() function prints the entry
    463463    ////////////////////////////////////////////////////////////////////
    464464      void print(){
    465         std::cout 
     465        std::cout
    466466        << " -- owner.inst     : " << std::dec << owner.inst << std::endl
    467467        << " -- owner.srcid    : " << std::dec << owner.srcid << std::endl
     
    473473
    474474  ////////////////////////////////////////////////////////////////////////
    475   //                        The Heap 
     475  //                        The Heap
    476476  ////////////////////////////////////////////////////////////////////////
    477477  class HeapDirectory{
    478    
     478
    479479    private:
    480480    // Registers and the heap
     
    506506
    507507    /////////////////////////////////////////////////////////////////////
    508     //          Global initialisation function
     508    //              Global initialisation function
    509509    /////////////////////////////////////////////////////////////////////
    510510      void init(){
     
    541541            if(ptr_temp == m_heap_tab[ptr_temp].next) end = true;
    542542            ptr_temp = m_heap_tab[ptr_temp].next;
    543         } 
     543        }
    544544      } // end print_list()
    545545
     
    552552
    553553    /////////////////////////////////////////////////////////////////////
    554     // The next_free_ptr() function returns the pointer 
     554    // The next_free_ptr() function returns the pointer
    555555    // to the next free entry.
    556556    /////////////////////////////////////////////////////////////////////
     
    560560
    561561    /////////////////////////////////////////////////////////////////////
    562     // The next_free_entry() function returns 
     562    // The next_free_entry() function returns
    563563    // a copy of the next free entry.
    564564    /////////////////////////////////////////////////////////////////////
     
    566566        return HeapEntry(m_heap_tab[ptr_free]);
    567567      } // end next_free_entry()
    568    
     568
    569569    /////////////////////////////////////////////////////////////////////
    570570    // The write_free_entry() function modify the next free entry.
     
    624624
    625625  ////////////////////////////////////////////////////////////////////////
    626   //                        Cache Data 
    627   ////////////////////////////////////////////////////////////////////////
    628   class CacheData 
     626  //                        Cache Data
     627  ////////////////////////////////////////////////////////////////////////
     628  class CacheData
    629629  {
    630630    private:
     
    639639      ///////////////////////////////////////////////////////
    640640      CacheData(uint32_t ways, uint32_t sets, uint32_t words)
    641         : m_sets(sets), m_ways(ways), m_words(words) 
     641        : m_sets(sets), m_ways(ways), m_words(words)
    642642      {
    643643          m_cache_data = new uint32_t ** [ways];
    644           for ( size_t i=0 ; i < ways ; i++ ) 
     644          for ( size_t i=0 ; i < ways ; i++ )
    645645          {
    646646              m_cache_data[i] = new uint32_t * [sets];
    647647          }
    648           for ( size_t i=0; i<ways; i++ ) 
     648          for ( size_t i=0; i<ways; i++ )
    649649          {
    650               for ( size_t j=0; j<sets; j++ ) 
     650              for ( size_t j=0; j<sets; j++ )
    651651              {
    652652                  m_cache_data[i][j] = new uint32_t [words];
     
    655655      }
    656656      ////////////
    657       ~CacheData() 
     657      ~CacheData()
    658658      {
    659659          for(size_t i=0; i<m_ways ; i++)
     
    673673      uint32_t read ( const uint32_t &way,
    674674                      const uint32_t &set,
    675                       const uint32_t &word) const 
     675                      const uint32_t &word) const
    676676      {
    677677          assert((set  < m_sets ) && "Cache data error: Trying to read a wrong set" );
     
    697697                   const uint32_t &word,
    698698                   const uint32_t &data,
    699                    const uint32_t &be = 0xF) 
     699                   const uint32_t &be = 0xF)
    700700      {
    701701
     
    707707          if (be == 0x0) return;
    708708
    709           if (be == 0xF) 
     709          if (be == 0xF)
    710710          {
    711               m_cache_data[way][set][word] = data; 
     711              m_cache_data[way][set][word] = data;
    712712              return;
    713713          }
     
    719719          if  (be & 0x8) mask = mask | 0xFF000000;
    720720
    721           m_cache_data[way][set][word] = 
     721          m_cache_data[way][set][word] =
    722722              (data & mask) | (m_cache_data[way][set][word] & ~mask);
    723723      }
Note: See TracChangeset for help on using the changeset viewer.