RubySystem.hh revision 11168
16145SN/A/*
28688SN/A * Copyright (c) 1999-2012 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
296145SN/A/*
307039SN/A * Contains all of the various parts of the system we are simulating.
317039SN/A * Performs allocation, deallocation, and setup of all the major
327039SN/A * components of the system
336145SN/A */
346145SN/A
357039SN/A#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__
367039SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__
376145SN/A
387039SN/A#include "base/callback.hh"
399350SN/A#include "base/output.hh"
4011108Sdavid.hashe@amd.com#include "mem/packet.hh"
4110301SN/A#include "mem/ruby/profiler/Profiler.hh"
4210301SN/A#include "mem/ruby/slicc_interface/AbstractController.hh"
4310301SN/A#include "mem/ruby/system/CacheRecorder.hh"
447039SN/A#include "params/RubySystem.hh"
459206SN/A#include "sim/clocked_object.hh"
466145SN/A
477039SN/Aclass Network;
4810920SN/Aclass AbstractController;
496285SN/A
509206SN/Aclass RubySystem : public ClockedObject
517039SN/A{
527039SN/A  public:
538688SN/A    class RubyEvent : public Event
548688SN/A    {
558688SN/A      public:
568688SN/A        RubyEvent(RubySystem* _ruby_system)
578688SN/A        {
5810919SN/A            m_ruby_system = _ruby_system;
598688SN/A        }
608688SN/A      private:
618688SN/A        void process();
628688SN/A
6310919SN/A        RubySystem* m_ruby_system;
648688SN/A    };
658688SN/A
668688SN/A    friend class RubyEvent;
678688SN/A
686876SN/A    typedef RubySystemParams Params;
696876SN/A    RubySystem(const Params *p);
707039SN/A    ~RubySystem();
716145SN/A
727039SN/A    // config accessors
737039SN/A    static int getRandomization() { return m_randomization; }
749504SN/A    static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
759504SN/A    static uint32_t getBlockSizeBits() { return m_block_size_bits; }
769504SN/A    static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
7710837SN/A    static bool getWarmupEnabled() { return m_warmup_enabled; }
7810837SN/A    static bool getCooldownEnabled() { return m_cooldown_enabled; }
796285SN/A
8010525SN/A    SimpleMemory *getPhysMem() { return m_phys_mem; }
8110918SN/A    Cycles getStartCycle() { return m_start_cycle; }
8210706SN/A    const bool getAccessBackingStore() { return m_access_backing_store; }
8310525SN/A
847039SN/A    // Public Methods
857039SN/A    Profiler*
867039SN/A    getProfiler()
877039SN/A    {
8810012SN/A        assert(m_profiler != NULL);
8910012SN/A        return m_profiler;
907039SN/A    }
916285SN/A
9210012SN/A    void regStats() { m_profiler->regStats(name()); }
9310012SN/A    void collateStats() { m_profiler->collateStats(); }
949350SN/A    void resetStats();
956285SN/A
9610991SN/A    void memWriteback();
9711168Sandreas.hansson@arm.com    void serialize(CheckpointOut &cp) const override;
9811168Sandreas.hansson@arm.com    void unserialize(CheckpointIn &cp) override;
9911168Sandreas.hansson@arm.com    void drainResume() override;
1008688SN/A    void process();
1018688SN/A    void startup();
1029270SN/A    bool functionalRead(Packet *ptr);
1039270SN/A    bool functionalWrite(Packet *ptr);
1047562SN/A
1058436SN/A    void registerNetwork(Network*);
1068436SN/A    void registerAbstractController(AbstractController*);
1078436SN/A
1088937SN/A    bool eventQueueEmpty() { return eventq->empty(); }
1098937SN/A    void enqueueRubyEvent(Tick tick)
1108937SN/A    {
1118937SN/A        RubyEvent* e = new RubyEvent(this);
1128937SN/A        schedule(e, tick);
1138937SN/A    }
1148937SN/A
1157039SN/A  private:
1167039SN/A    // Private copy constructor and assignment operator
1177039SN/A    RubySystem(const RubySystem& obj);
1187039SN/A    RubySystem& operator=(const RubySystem& obj);
1196285SN/A
12010991SN/A    void makeCacheRecorder(uint8_t *uncompressed_trace,
12111061SN/A                           uint64_t cache_trace_size,
12211061SN/A                           uint64_t block_size_bytes);
12310991SN/A
12411060SN/A    static void readCompressedTrace(std::string filename,
12511060SN/A                                    uint8_t *&raw_data,
12611061SN/A                                    uint64_t &uncompressed_trace_size);
12711060SN/A    static void writeCompressedTrace(uint8_t *raw_data, std::string file,
12811061SN/A                                     uint64_t uncompressed_trace_size);
1297039SN/A
1307039SN/A  private:
1317039SN/A    // configuration parameters
1327039SN/A    static bool m_randomization;
1339504SN/A    static uint32_t m_block_size_bytes;
1349504SN/A    static uint32_t m_block_size_bits;
1359504SN/A    static uint32_t m_memory_size_bits;
13610919SN/A
13710837SN/A    static bool m_warmup_enabled;
13810837SN/A    static unsigned m_systems_to_warmup;
13910837SN/A    static bool m_cooldown_enabled;
14010525SN/A    SimpleMemory *m_phys_mem;
14110706SN/A    const bool m_access_backing_store;
1427039SN/A
14310012SN/A    Network* m_network;
1449300SN/A    std::vector<AbstractController *> m_abs_cntrl_vec;
14510918SN/A    Cycles m_start_cycle;
1469103SN/A
1477039SN/A  public:
14810012SN/A    Profiler* m_profiler;
1498688SN/A    CacheRecorder* m_cache_recorder;
15010920SN/A    std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls;
1516145SN/A};
1526145SN/A
15310012SN/Aclass RubyStatsCallback : public Callback
1546895SN/A{
1556895SN/A  private:
15610919SN/A    RubySystem *m_ruby_system;
1576895SN/A
1586895SN/A  public:
15910012SN/A    virtual ~RubyStatsCallback() {}
16010919SN/A    RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {}
16110919SN/A    void process() { m_ruby_system->collateStats(); }
1626895SN/A};
1636895SN/A
1647039SN/A#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__
165