RubySystem.hh revision 10918
17259Sgblack@eecs.umich.edu/*
211574SCurtis.Dunham@arm.com * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
37259Sgblack@eecs.umich.edu * All rights reserved.
47259Sgblack@eecs.umich.edu *
57259Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67259Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77259Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87259Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97259Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107259Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117259Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127259Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137259Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
147259Sgblack@eecs.umich.edu * this software without specific prior written permission.
157259Sgblack@eecs.umich.edu *
167259Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177259Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187259Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197259Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207259Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217259Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
227259Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237259Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247259Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257259Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
267259Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
277259Sgblack@eecs.umich.edu */
287259Sgblack@eecs.umich.edu
297259Sgblack@eecs.umich.edu/*
307259Sgblack@eecs.umich.edu * Contains all of the various parts of the system we are simulating.
317259Sgblack@eecs.umich.edu * Performs allocation, deallocation, and setup of all the major
327259Sgblack@eecs.umich.edu * components of the system
337259Sgblack@eecs.umich.edu */
347259Sgblack@eecs.umich.edu
357259Sgblack@eecs.umich.edu#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__
367259Sgblack@eecs.umich.edu#define __MEM_RUBY_SYSTEM_SYSTEM_HH__
377259Sgblack@eecs.umich.edu
387405SAli.Saidi@ARM.com#include "base/callback.hh"
3910037SARM gem5 Developers#include "base/output.hh"
407259Sgblack@eecs.umich.edu#include "mem/ruby/profiler/Profiler.hh"
417259Sgblack@eecs.umich.edu#include "mem/ruby/slicc_interface/AbstractController.hh"
4211793Sbrandon.potter@amd.com#include "mem/ruby/system/CacheRecorder.hh"
4311793Sbrandon.potter@amd.com#include "mem/packet.hh"
447405SAli.Saidi@ARM.com#include "params/RubySystem.hh"
457404SAli.Saidi@ARM.com#include "sim/clocked_object.hh"
4610037SARM gem5 Developers
4710828SGiacomo.Gabrielli@arm.comclass Network;
487259Sgblack@eecs.umich.edu
497259Sgblack@eecs.umich.educlass RubySystem : public ClockedObject
507259Sgblack@eecs.umich.edu{
517259Sgblack@eecs.umich.edu  public:
527259Sgblack@eecs.umich.edu    class RubyEvent : public Event
538868SMatt.Horsnell@arm.com    {
548868SMatt.Horsnell@arm.com      public:
558868SMatt.Horsnell@arm.com        RubyEvent(RubySystem* _ruby_system)
568868SMatt.Horsnell@arm.com        {
5710037SARM gem5 Developers            ruby_system = _ruby_system;
588868SMatt.Horsnell@arm.com        }
5910037SARM gem5 Developers      private:
608868SMatt.Horsnell@arm.com        void process();
6110037SARM gem5 Developers
6210037SARM gem5 Developers        RubySystem* ruby_system;
6310037SARM gem5 Developers    };
6410037SARM gem5 Developers
6510037SARM gem5 Developers    friend class RubyEvent;
6610037SARM gem5 Developers
6710037SARM gem5 Developers    typedef RubySystemParams Params;
688868SMatt.Horsnell@arm.com    RubySystem(const Params *p);
6910037SARM gem5 Developers    ~RubySystem();
7010037SARM gem5 Developers
7110037SARM gem5 Developers    // config accessors
7210037SARM gem5 Developers    static int getRandomSeed() { return m_random_seed; }
7310037SARM gem5 Developers    static int getRandomization() { return m_randomization; }
7410037SARM gem5 Developers    static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
7510037SARM gem5 Developers    static uint32_t getBlockSizeBits() { return m_block_size_bits; }
7610037SARM gem5 Developers    static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
7710037SARM gem5 Developers    static bool getWarmupEnabled() { return m_warmup_enabled; }
7810037SARM gem5 Developers    static bool getCooldownEnabled() { return m_cooldown_enabled; }
7910037SARM gem5 Developers
809959Schander.sudanthi@arm.com    SimpleMemory *getPhysMem() { return m_phys_mem; }
8110037SARM gem5 Developers    Cycles getStartCycle() { return m_start_cycle; }
829959Schander.sudanthi@arm.com    const bool getAccessBackingStore() { return m_access_backing_store; }
839959Schander.sudanthi@arm.com
849959Schander.sudanthi@arm.com    // Public Methods
859959Schander.sudanthi@arm.com    Profiler*
869959Schander.sudanthi@arm.com    getProfiler()
879959Schander.sudanthi@arm.com    {
889959Schander.sudanthi@arm.com        assert(m_profiler != NULL);
899959Schander.sudanthi@arm.com        return m_profiler;
909959Schander.sudanthi@arm.com    }
9110037SARM gem5 Developers
929959Schander.sudanthi@arm.com    void regStats() { m_profiler->regStats(name()); }
9310037SARM gem5 Developers    void collateStats() { m_profiler->collateStats(); }
9410037SARM gem5 Developers    void resetStats();
9510037SARM gem5 Developers
9610037SARM gem5 Developers    void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
9710037SARM gem5 Developers    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
9810037SARM gem5 Developers    void process();
9910037SARM gem5 Developers    void startup();
10010037SARM gem5 Developers    bool functionalRead(Packet *ptr);
10110037SARM gem5 Developers    bool functionalWrite(Packet *ptr);
10210037SARM gem5 Developers
10310037SARM gem5 Developers    void registerNetwork(Network*);
1048868SMatt.Horsnell@arm.com    void registerAbstractController(AbstractController*);
10510037SARM gem5 Developers
10610037SARM gem5 Developers    bool eventQueueEmpty() { return eventq->empty(); }
10710037SARM gem5 Developers    void enqueueRubyEvent(Tick tick)
10810037SARM gem5 Developers    {
10910037SARM gem5 Developers        RubyEvent* e = new RubyEvent(this);
11010037SARM gem5 Developers        schedule(e, tick);
11110037SARM gem5 Developers    }
11210037SARM gem5 Developers
11310037SARM gem5 Developers  private:
11410037SARM gem5 Developers    // Private copy constructor and assignment operator
11510037SARM gem5 Developers    RubySystem(const RubySystem& obj);
11610037SARM gem5 Developers    RubySystem& operator=(const RubySystem& obj);
11710037SARM gem5 Developers
11810037SARM gem5 Developers    void readCompressedTrace(std::string filename,
11910037SARM gem5 Developers                             uint8_t *&raw_data,
1208868SMatt.Horsnell@arm.com                             uint64& uncompressed_trace_size);
12110037SARM gem5 Developers    void writeCompressedTrace(uint8_t *raw_data, std::string file,
12210037SARM gem5 Developers                              uint64 uncompressed_trace_size);
12310037SARM gem5 Developers
12410037SARM gem5 Developers  private:
12510037SARM gem5 Developers    // configuration parameters
1268868SMatt.Horsnell@arm.com    static int m_random_seed;
12710037SARM gem5 Developers    static bool m_randomization;
12810037SARM gem5 Developers    static uint32_t m_block_size_bytes;
12910037SARM gem5 Developers    static uint32_t m_block_size_bits;
13010037SARM gem5 Developers    static uint32_t m_memory_size_bits;
13110506SAli.Saidi@ARM.com    static bool m_warmup_enabled;
13210037SARM gem5 Developers    static unsigned m_systems_to_warmup;
13310506SAli.Saidi@ARM.com    static bool m_cooldown_enabled;
13410037SARM gem5 Developers    SimpleMemory *m_phys_mem;
13510506SAli.Saidi@ARM.com    const bool m_access_backing_store;
13610037SARM gem5 Developers
13710506SAli.Saidi@ARM.com    Network* m_network;
13810037SARM gem5 Developers    std::vector<AbstractController *> m_abs_cntrl_vec;
13910506SAli.Saidi@ARM.com    Cycles m_start_cycle;
14010037SARM gem5 Developers
14110506SAli.Saidi@ARM.com  public:
14210037SARM gem5 Developers    Profiler* m_profiler;
14310506SAli.Saidi@ARM.com    CacheRecorder* m_cache_recorder;
14410037SARM gem5 Developers};
14510506SAli.Saidi@ARM.com
14610037SARM gem5 Developersclass RubyStatsCallback : public Callback
14710506SAli.Saidi@ARM.com{
14810037SARM gem5 Developers  private:
14910506SAli.Saidi@ARM.com    RubySystem *ruby_system;
15010037SARM gem5 Developers
15110506SAli.Saidi@ARM.com  public:
15210037SARM gem5 Developers    virtual ~RubyStatsCallback() {}
15310506SAli.Saidi@ARM.com    RubyStatsCallback(RubySystem *system) : ruby_system(system) {}
15410037SARM gem5 Developers    void process() { ruby_system->collateStats(); }
15510506SAli.Saidi@ARM.com};
15610037SARM gem5 Developers
15710506SAli.Saidi@ARM.com#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__
15810037SARM gem5 Developers