RubySystem.hh revision 10919
12810SN/A/*
212724Snikos.nikoleris@arm.com * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
38856Sandreas.hansson@arm.com * All rights reserved.
48856Sandreas.hansson@arm.com *
58856Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
68856Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
78856Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
88856Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
98856Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
108856Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
118856Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
128856Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
138856Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
142810SN/A * this software without specific prior written permission.
152810SN/A *
162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272810SN/A */
282810SN/A
292810SN/A/*
302810SN/A * Contains all of the various parts of the system we are simulating.
312810SN/A * Performs allocation, deallocation, and setup of all the major
322810SN/A * components of the system
332810SN/A */
342810SN/A
352810SN/A#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__
362810SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__
372810SN/A
382810SN/A#include "base/callback.hh"
392810SN/A#include "base/output.hh"
402810SN/A#include "mem/ruby/profiler/Profiler.hh"
4112724Snikos.nikoleris@arm.com#include "mem/ruby/slicc_interface/AbstractController.hh"
422810SN/A#include "mem/ruby/system/CacheRecorder.hh"
432810SN/A#include "mem/packet.hh"
442810SN/A#include "params/RubySystem.hh"
452810SN/A#include "sim/clocked_object.hh"
462810SN/A
472810SN/Aclass Network;
482810SN/A
4911486Snikos.nikoleris@arm.comclass RubySystem : public ClockedObject
5011486Snikos.nikoleris@arm.com{
5112724Snikos.nikoleris@arm.com  public:
5212724Snikos.nikoleris@arm.com    class RubyEvent : public Event
538232Snate@binkert.org    {
5412724Snikos.nikoleris@arm.com      public:
5513222Sodanrc@yahoo.com.br        RubyEvent(RubySystem* _ruby_system)
5612724Snikos.nikoleris@arm.com        {
5711486Snikos.nikoleris@arm.com            m_ruby_system = _ruby_system;
5812724Snikos.nikoleris@arm.com        }
5912724Snikos.nikoleris@arm.com      private:
6012724Snikos.nikoleris@arm.com        void process();
6113352Snikos.nikoleris@arm.com
6212724Snikos.nikoleris@arm.com        RubySystem* m_ruby_system;
6312724Snikos.nikoleris@arm.com    };
6412724Snikos.nikoleris@arm.com
6512724Snikos.nikoleris@arm.com    friend class RubyEvent;
662810SN/A
672810SN/A    typedef RubySystemParams Params;
682810SN/A    RubySystem(const Params *p);
698856Sandreas.hansson@arm.com    ~RubySystem();
708856Sandreas.hansson@arm.com
718856Sandreas.hansson@arm.com    // config accessors
7213564Snikos.nikoleris@arm.com    static int getRandomSeed() { return m_random_seed; }
7313564Snikos.nikoleris@arm.com    static int getRandomization() { return m_randomization; }
7412084Sspwilson2@wisc.edu    static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
7512084Sspwilson2@wisc.edu    static uint32_t getBlockSizeBits() { return m_block_size_bits; }
768856Sandreas.hansson@arm.com    static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
778856Sandreas.hansson@arm.com    static bool getWarmupEnabled() { return m_warmup_enabled; }
784475SN/A    static bool getCooldownEnabled() { return m_cooldown_enabled; }
7911053Sandreas.hansson@arm.com
805034SN/A    SimpleMemory *getPhysMem() { return m_phys_mem; }
8112724Snikos.nikoleris@arm.com    Cycles getStartCycle() { return m_start_cycle; }
8212724Snikos.nikoleris@arm.com    const bool getAccessBackingStore() { return m_access_backing_store; }
8311377Sandreas.hansson@arm.com
8411377Sandreas.hansson@arm.com    // Public Methods
8512724Snikos.nikoleris@arm.com    Profiler*
8612724Snikos.nikoleris@arm.com    getProfiler()
8713352Snikos.nikoleris@arm.com    {
8812724Snikos.nikoleris@arm.com        assert(m_profiler != NULL);
8912724Snikos.nikoleris@arm.com        return m_profiler;
9012724Snikos.nikoleris@arm.com    }
9112724Snikos.nikoleris@arm.com
9212724Snikos.nikoleris@arm.com    void regStats() { m_profiler->regStats(name()); }
9311053Sandreas.hansson@arm.com    void collateStats() { m_profiler->collateStats(); }
9411722Ssophiane.senni@gmail.com    void resetStats();
9511722Ssophiane.senni@gmail.com
9611722Ssophiane.senni@gmail.com    void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
9711722Ssophiane.senni@gmail.com    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
989263Smrinmoy.ghosh@arm.com    void process();
9913418Sodanrc@yahoo.com.br    void startup();
1005034SN/A    bool functionalRead(Packet *ptr);
10111331Sandreas.hansson@arm.com    bool functionalWrite(Packet *ptr);
10212724Snikos.nikoleris@arm.com
10310884Sandreas.hansson@arm.com    void registerNetwork(Network*);
1044626SN/A    void registerAbstractController(AbstractController*);
10510360Sandreas.hansson@arm.com
10611484Snikos.nikoleris@arm.com    bool eventQueueEmpty() { return eventq->empty(); }
1075034SN/A    void enqueueRubyEvent(Tick tick)
1088883SAli.Saidi@ARM.com    {
1098833Sdam.sunwoo@arm.com        RubyEvent* e = new RubyEvent(this);
1104458SN/A        schedule(e, tick);
11111377Sandreas.hansson@arm.com    }
11211377Sandreas.hansson@arm.com
11311377Sandreas.hansson@arm.com  private:
11411377Sandreas.hansson@arm.com    // Private copy constructor and assignment operator
11511377Sandreas.hansson@arm.com    RubySystem(const RubySystem& obj);
11611377Sandreas.hansson@arm.com    RubySystem& operator=(const RubySystem& obj);
11711331Sandreas.hansson@arm.com
11811331Sandreas.hansson@arm.com    void readCompressedTrace(std::string filename,
11912724Snikos.nikoleris@arm.com                             uint8_t *&raw_data,
12012843Srmk35@cl.cam.ac.uk                             uint64& uncompressed_trace_size);
12112724Snikos.nikoleris@arm.com    void writeCompressedTrace(uint8_t *raw_data, std::string file,
12213419Sodanrc@yahoo.com.br                              uint64 uncompressed_trace_size);
12312724Snikos.nikoleris@arm.com
12412724Snikos.nikoleris@arm.com  private:
12512724Snikos.nikoleris@arm.com    // configuration parameters
12612724Snikos.nikoleris@arm.com    static int m_random_seed;
12712724Snikos.nikoleris@arm.com    static bool m_randomization;
12812724Snikos.nikoleris@arm.com    static uint32_t m_block_size_bytes;
12912724Snikos.nikoleris@arm.com    static uint32_t m_block_size_bits;
1302810SN/A    static uint32_t m_memory_size_bits;
1312810SN/A
1323013SN/A    static bool m_warmup_enabled;
1338856Sandreas.hansson@arm.com    static unsigned m_systems_to_warmup;
1342810SN/A    static bool m_cooldown_enabled;
1353013SN/A    SimpleMemory *m_phys_mem;
13610714Sandreas.hansson@arm.com    const bool m_access_backing_store;
1372810SN/A
1389614Srene.dejong@arm.com    Network* m_network;
1399614Srene.dejong@arm.com    std::vector<AbstractController *> m_abs_cntrl_vec;
1409614Srene.dejong@arm.com    Cycles m_start_cycle;
14110345SCurtis.Dunham@arm.com
14210714Sandreas.hansson@arm.com  public:
14310345SCurtis.Dunham@arm.com    Profiler* m_profiler;
1449614Srene.dejong@arm.com    CacheRecorder* m_cache_recorder;
1452810SN/A};
1462810SN/A
1472810SN/Aclass RubyStatsCallback : public Callback
1488856Sandreas.hansson@arm.com{
1492810SN/A  private:
1503013SN/A    RubySystem *m_ruby_system;
15110714Sandreas.hansson@arm.com
1523013SN/A  public:
1538856Sandreas.hansson@arm.com    virtual ~RubyStatsCallback() {}
15410714Sandreas.hansson@arm.com    RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {}
1558922Swilliam.wang@arm.com    void process() { m_ruby_system->collateStats(); }
1562897SN/A};
1572810SN/A
1582810SN/A#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__
15910344Sandreas.hansson@arm.com