RubySystem.hh revision 12492
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
3512492Sodanrc@yahoo.com.br#ifndef __MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__
3612492Sodanrc@yahoo.com.br#define __MEM_RUBY_SYSTEM_RUBYSYSTEM_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:
536876SN/A    typedef RubySystemParams Params;
546876SN/A    RubySystem(const Params *p);
557039SN/A    ~RubySystem();
566145SN/A
577039SN/A    // config accessors
587039SN/A    static int getRandomization() { return m_randomization; }
599504SN/A    static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
609504SN/A    static uint32_t getBlockSizeBits() { return m_block_size_bits; }
619504SN/A    static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
6210837SN/A    static bool getWarmupEnabled() { return m_warmup_enabled; }
6310837SN/A    static bool getCooldownEnabled() { return m_cooldown_enabled; }
646285SN/A
6510525SN/A    SimpleMemory *getPhysMem() { return m_phys_mem; }
6610918SN/A    Cycles getStartCycle() { return m_start_cycle; }
6711294Sandreas.hansson@arm.com    bool getAccessBackingStore() { return m_access_backing_store; }
6810525SN/A
697039SN/A    // Public Methods
707039SN/A    Profiler*
717039SN/A    getProfiler()
727039SN/A    {
7310012SN/A        assert(m_profiler != NULL);
7410012SN/A        return m_profiler;
757039SN/A    }
766285SN/A
7711523Sdavid.guillen@arm.com    void regStats() override {
7811523Sdavid.guillen@arm.com        ClockedObject::regStats();
7911523Sdavid.guillen@arm.com        m_profiler->regStats(name());
8011523Sdavid.guillen@arm.com    }
8110012SN/A    void collateStats() { m_profiler->collateStats(); }
8211169Sandreas.hansson@arm.com    void resetStats() override;
836285SN/A
8411169Sandreas.hansson@arm.com    void memWriteback() override;
8511168Sandreas.hansson@arm.com    void serialize(CheckpointOut &cp) const override;
8611168Sandreas.hansson@arm.com    void unserialize(CheckpointIn &cp) override;
8711168Sandreas.hansson@arm.com    void drainResume() override;
888688SN/A    void process();
8911169Sandreas.hansson@arm.com    void startup() override;
909270SN/A    bool functionalRead(Packet *ptr);
919270SN/A    bool functionalWrite(Packet *ptr);
927562SN/A
938436SN/A    void registerNetwork(Network*);
948436SN/A    void registerAbstractController(AbstractController*);
958436SN/A
968937SN/A    bool eventQueueEmpty() { return eventq->empty(); }
978937SN/A    void enqueueRubyEvent(Tick tick)
988937SN/A    {
9912133Sspwilson2@wisc.edu        auto e = new EventFunctionWrapper(
10012133Sspwilson2@wisc.edu            [this]{ processRubyEvent(); }, "RubyEvent");
1018937SN/A        schedule(e, tick);
1028937SN/A    }
1038937SN/A
1047039SN/A  private:
1057039SN/A    // Private copy constructor and assignment operator
1067039SN/A    RubySystem(const RubySystem& obj);
1077039SN/A    RubySystem& operator=(const RubySystem& obj);
1086285SN/A
10910991SN/A    void makeCacheRecorder(uint8_t *uncompressed_trace,
11011061SN/A                           uint64_t cache_trace_size,
11111061SN/A                           uint64_t block_size_bytes);
11210991SN/A
11311060SN/A    static void readCompressedTrace(std::string filename,
11411060SN/A                                    uint8_t *&raw_data,
11511061SN/A                                    uint64_t &uncompressed_trace_size);
11611060SN/A    static void writeCompressedTrace(uint8_t *raw_data, std::string file,
11711061SN/A                                     uint64_t uncompressed_trace_size);
1187039SN/A
11912133Sspwilson2@wisc.edu    void processRubyEvent();
1207039SN/A  private:
1217039SN/A    // configuration parameters
1227039SN/A    static bool m_randomization;
1239504SN/A    static uint32_t m_block_size_bytes;
1249504SN/A    static uint32_t m_block_size_bits;
1259504SN/A    static uint32_t m_memory_size_bits;
12610919SN/A
12710837SN/A    static bool m_warmup_enabled;
12810837SN/A    static unsigned m_systems_to_warmup;
12910837SN/A    static bool m_cooldown_enabled;
13010525SN/A    SimpleMemory *m_phys_mem;
13110706SN/A    const bool m_access_backing_store;
1327039SN/A
13310012SN/A    Network* m_network;
1349300SN/A    std::vector<AbstractController *> m_abs_cntrl_vec;
13510918SN/A    Cycles m_start_cycle;
1369103SN/A
1377039SN/A  public:
13810012SN/A    Profiler* m_profiler;
1398688SN/A    CacheRecorder* m_cache_recorder;
14010920SN/A    std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls;
1416145SN/A};
1426145SN/A
14310012SN/Aclass RubyStatsCallback : public Callback
1446895SN/A{
1456895SN/A  private:
14610919SN/A    RubySystem *m_ruby_system;
1476895SN/A
1486895SN/A  public:
14910012SN/A    virtual ~RubyStatsCallback() {}
15010919SN/A    RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {}
15110919SN/A    void process() { m_ruby_system->collateStats(); }
1526895SN/A};
1536895SN/A
15412492Sodanrc@yahoo.com.br#endif //__MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__
155