DirectoryMemory.hh revision 11025
16145SN/A/*
26145SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
36145SN/A * All rights reserved.
46145SN/A *
56145SN/A * Redistribution and use in source and binary forms, with or without
66145SN/A * modification, are permitted provided that the following conditions are
76145SN/A * met: redistributions of source code must retain the above copyright
86145SN/A * notice, this list of conditions and the following disclaimer;
96145SN/A * redistributions in binary form must reproduce the above copyright
106145SN/A * notice, this list of conditions and the following disclaimer in the
116145SN/A * documentation and/or other materials provided with the distribution;
126145SN/A * neither the name of the copyright holders nor the names of its
136145SN/A * contributors may be used to endorse or promote products derived from
146145SN/A * this software without specific prior written permission.
156145SN/A *
166145SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176145SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186145SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196145SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206145SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216145SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226145SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236145SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246145SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256145SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266145SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276145SN/A */
286145SN/A
2910441Snilay@cs.wisc.edu#ifndef __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__
3010441Snilay@cs.wisc.edu#define __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__
316145SN/A
327055SN/A#include <iostream>
337055SN/A#include <string>
347055SN/A
3510301Snilay@cs.wisc.edu#include "mem/protocol/DirectoryRequestType.hh"
367039SN/A#include "mem/ruby/common/Address.hh"
378644SN/A#include "mem/ruby/slicc_interface/AbstractEntry.hh"
387039SN/A#include "params/RubyDirectoryMemory.hh"
397039SN/A#include "sim/sim_object.hh"
406145SN/A
417039SN/Aclass DirectoryMemory : public SimObject
427039SN/A{
437039SN/A  public:
446876SN/A    typedef RubyDirectoryMemoryParams Params;
456876SN/A    DirectoryMemory(const Params *p);
467039SN/A    ~DirectoryMemory();
476145SN/A
487039SN/A    void init();
496145SN/A
5011025Snilay@cs.wisc.edu    uint64_t mapAddressToLocalIdx(Addr address);
5111025Snilay@cs.wisc.edu    static uint64_t mapAddressToDirectoryVersion(Addr address);
526285SN/A
5311025Snilay@cs.wisc.edu    uint64_t getSize() { return m_size_bytes; }
546285SN/A
5511025Snilay@cs.wisc.edu    bool isPresent(Addr address);
5611025Snilay@cs.wisc.edu    AbstractEntry *lookup(Addr address);
5711025Snilay@cs.wisc.edu    AbstractEntry *allocate(Addr address, AbstractEntry* new_entry);
586145SN/A
597055SN/A    void print(std::ostream& out) const;
609104SN/A    void recordRequestType(DirectoryRequestType requestType);
619104SN/A
627039SN/A  private:
637039SN/A    // Private copy constructor and assignment operator
647039SN/A    DirectoryMemory(const DirectoryMemory& obj);
657039SN/A    DirectoryMemory& operator=(const DirectoryMemory& obj);
666145SN/A
677039SN/A  private:
687055SN/A    const std::string m_name;
698644SN/A    AbstractEntry **m_entries;
707039SN/A    // int m_size;  // # of memory module blocks this directory is
717039SN/A                    // responsible for
7211025Snilay@cs.wisc.edu    uint64_t m_size_bytes;
7311025Snilay@cs.wisc.edu    uint64_t m_size_bits;
7411025Snilay@cs.wisc.edu    uint64_t m_num_entries;
757039SN/A    int m_version;
766145SN/A
777039SN/A    static int m_num_directories;
787039SN/A    static int m_num_directories_bits;
797039SN/A    static uint64_t m_total_size_bytes;
807039SN/A    static int m_numa_high_bit;
816145SN/A};
826145SN/A
837055SN/Ainline std::ostream&
847055SN/Aoperator<<(std::ostream& out, const DirectoryMemory& obj)
856145SN/A{
867039SN/A    obj.print(out);
877055SN/A    out << std::flush;
887039SN/A    return out;
896145SN/A}
906145SN/A
9110441Snilay@cs.wisc.edu#endif // __MEM_RUBY_STRUCTURES_DIRECTORYMEMORY_HH__
92