DirectoryMemory.hh revision 11025:4872dbdea907
12246SN/A/* 22246SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 32246SN/A * All rights reserved. 42246SN/A * 52246SN/A * Redistribution and use in source and binary forms, with or without 62246SN/A * modification, are permitted provided that the following conditions are 72246SN/A * met: redistributions of source code must retain the above copyright 82246SN/A * notice, this list of conditions and the following disclaimer; 92246SN/A * redistributions in binary form must reproduce the above copyright 102246SN/A * notice, this list of conditions and the following disclaimer in the 112246SN/A * documentation and/or other materials provided with the distribution; 122246SN/A * neither the name of the copyright holders nor the names of its 132246SN/A * contributors may be used to endorse or promote products derived from 142246SN/A * this software without specific prior written permission. 152246SN/A * 162246SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172246SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182246SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192246SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202246SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212246SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222246SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232246SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242246SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252246SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262246SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu */ 282665Ssaidi@eecs.umich.edu 292246SN/A#ifndef __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__ 302246SN/A#define __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__ 312977Sgblack@eecs.umich.edu 322977Sgblack@eecs.umich.edu#include <iostream> 332246SN/A#include <string> 347706Sgblack@eecs.umich.edu 357706Sgblack@eecs.umich.edu#include "mem/protocol/DirectoryRequestType.hh" 367706Sgblack@eecs.umich.edu#include "mem/ruby/common/Address.hh" 372246SN/A#include "mem/ruby/slicc_interface/AbstractEntry.hh" 382246SN/A#include "params/RubyDirectoryMemory.hh" 392680Sktlim@umich.edu#include "sim/sim_object.hh" 403570Sgblack@eecs.umich.edu 413570Sgblack@eecs.umich.educlass DirectoryMemory : public SimObject 427706Sgblack@eecs.umich.edu{ 433570Sgblack@eecs.umich.edu public: 443570Sgblack@eecs.umich.edu typedef RubyDirectoryMemoryParams Params; 457706Sgblack@eecs.umich.edu DirectoryMemory(const Params *p); 462246SN/A ~DirectoryMemory(); 473570Sgblack@eecs.umich.edu 487706Sgblack@eecs.umich.edu void init(); 497706Sgblack@eecs.umich.edu 507706Sgblack@eecs.umich.edu uint64_t mapAddressToLocalIdx(Addr address); 517706Sgblack@eecs.umich.edu static uint64_t mapAddressToDirectoryVersion(Addr address); 527706Sgblack@eecs.umich.edu 532246SN/A uint64_t getSize() { return m_size_bytes; } 547706Sgblack@eecs.umich.edu 552246SN/A bool isPresent(Addr address); 563570Sgblack@eecs.umich.edu AbstractEntry *lookup(Addr address); 573570Sgblack@eecs.umich.edu AbstractEntry *allocate(Addr address, AbstractEntry* new_entry); 583570Sgblack@eecs.umich.edu 592246SN/A void print(std::ostream& out) const; 602246SN/A void recordRequestType(DirectoryRequestType requestType); 612977Sgblack@eecs.umich.edu 62 private: 63 // Private copy constructor and assignment operator 64 DirectoryMemory(const DirectoryMemory& obj); 65 DirectoryMemory& operator=(const DirectoryMemory& obj); 66 67 private: 68 const std::string m_name; 69 AbstractEntry **m_entries; 70 // int m_size; // # of memory module blocks this directory is 71 // responsible for 72 uint64_t m_size_bytes; 73 uint64_t m_size_bits; 74 uint64_t m_num_entries; 75 int m_version; 76 77 static int m_num_directories; 78 static int m_num_directories_bits; 79 static uint64_t m_total_size_bytes; 80 static int m_numa_high_bit; 81}; 82 83inline std::ostream& 84operator<<(std::ostream& out, const DirectoryMemory& obj) 85{ 86 obj.print(out); 87 out << std::flush; 88 return out; 89} 90 91#endif // __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__ 92