RubySystem.hh revision 10920
12292SN/A/*
212355Snikos.nikoleris@arm.com * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
39444SAndreas.Sandberg@ARM.com * All rights reserved.
49444SAndreas.Sandberg@ARM.com *
59444SAndreas.Sandberg@ARM.com * Redistribution and use in source and binary forms, with or without
69444SAndreas.Sandberg@ARM.com * modification, are permitted provided that the following conditions are
79444SAndreas.Sandberg@ARM.com * met: redistributions of source code must retain the above copyright
89444SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer;
99444SAndreas.Sandberg@ARM.com * redistributions in binary form must reproduce the above copyright
109444SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer in the
119444SAndreas.Sandberg@ARM.com * documentation and/or other materials provided with the distribution;
129444SAndreas.Sandberg@ARM.com * neither the name of the copyright holders nor the names of its
139444SAndreas.Sandberg@ARM.com * contributors may be used to endorse or promote products derived from
142329SN/A * this software without specific prior written permission.
1510239Sbinhpham@cs.rutgers.edu *
162292SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172292SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182292SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192292SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202292SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212292SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222292SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232292SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242292SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252292SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262292SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272292SN/A */
282292SN/A
292292SN/A/*
302292SN/A * Contains all of the various parts of the system we are simulating.
312292SN/A * Performs allocation, deallocation, and setup of all the major
322292SN/A * components of the system
332292SN/A */
342292SN/A
352292SN/A#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__
362292SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__
372292SN/A
382292SN/A#include "base/callback.hh"
392292SN/A#include "base/output.hh"
402689Sktlim@umich.edu#include "mem/ruby/profiler/Profiler.hh"
412689Sktlim@umich.edu#include "mem/ruby/slicc_interface/AbstractController.hh"
422689Sktlim@umich.edu#include "mem/ruby/system/CacheRecorder.hh"
432292SN/A#include "mem/packet.hh"
442292SN/A#include "params/RubySystem.hh"
452292SN/A#include "sim/clocked_object.hh"
462292SN/A
472292SN/Aclass Network;
482329SN/Aclass AbstractController;
494395Ssaidi@eecs.umich.edu
502292SN/Aclass RubySystem : public ClockedObject
512292SN/A{
522292SN/A  public:
538591Sgblack@eecs.umich.edu    class RubyEvent : public Event
548506Sgblack@eecs.umich.edu    {
553326Sktlim@umich.edu      public:
568481Sgblack@eecs.umich.edu        RubyEvent(RubySystem* _ruby_system)
576658Snate@binkert.org        {
582292SN/A            m_ruby_system = _ruby_system;
598230Snate@binkert.org        }
608232Snate@binkert.org      private:
613348Sbinkertn@umich.edu        void process();
622669Sktlim@umich.edu
632292SN/A        RubySystem* m_ruby_system;
648737Skoansin.tan@gmail.com    };
655529Snate@binkert.org
662292SN/A    friend class RubyEvent;
672329SN/A
682329SN/A    typedef RubySystemParams Params;
692329SN/A    RubySystem(const Params *p);
702329SN/A    ~RubySystem();
712329SN/A
722329SN/A    // config accessors
732329SN/A    static int getRandomSeed() { return m_random_seed; }
742329SN/A    static int getRandomization() { return m_randomization; }
752329SN/A    static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
762329SN/A    static uint32_t getBlockSizeBits() { return m_block_size_bits; }
772292SN/A    static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
782292SN/A    static bool getWarmupEnabled() { return m_warmup_enabled; }
792292SN/A    static bool getCooldownEnabled() { return m_cooldown_enabled; }
802292SN/A
812733Sktlim@umich.edu    SimpleMemory *getPhysMem() { return m_phys_mem; }
822292SN/A    Cycles getStartCycle() { return m_start_cycle; }
832292SN/A    const bool getAccessBackingStore() { return m_access_backing_store; }
842907Sktlim@umich.edu
852292SN/A    // Public Methods
862292SN/A    Profiler*
872292SN/A    getProfiler()
882292SN/A    {
892292SN/A        assert(m_profiler != NULL);
902292SN/A        return m_profiler;
912292SN/A    }
925529Snate@binkert.org
935529Snate@binkert.org    void regStats() { m_profiler->regStats(name()); }
945529Snate@binkert.org    void collateStats() { m_profiler->collateStats(); }
952292SN/A    void resetStats();
962292SN/A
972292SN/A    void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
982292SN/A    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
992727Sktlim@umich.edu    void process();
1002727Sktlim@umich.edu    void startup();
1012727Sktlim@umich.edu    bool functionalRead(Packet *ptr);
1022907Sktlim@umich.edu    bool functionalWrite(Packet *ptr);
1038922Swilliam.wang@arm.com
1042907Sktlim@umich.edu    void registerNetwork(Network*);
1059444SAndreas.Sandberg@ARM.com    void registerAbstractController(AbstractController*);
1069444SAndreas.Sandberg@ARM.com
1072307SN/A    bool eventQueueEmpty() { return eventq->empty(); }
1082348SN/A    void enqueueRubyEvent(Tick tick)
1092307SN/A    {
1102307SN/A        RubyEvent* e = new RubyEvent(this);
1112292SN/A        schedule(e, tick);
1122292SN/A    }
1132292SN/A
1142292SN/A  private:
1152292SN/A    // Private copy constructor and assignment operator
11611780Sarthur.perais@inria.fr    RubySystem(const RubySystem& obj);
1172292SN/A    RubySystem& operator=(const RubySystem& obj);
1182292SN/A
11913429Srekai.gonzalezalberquilla@arm.com    void readCompressedTrace(std::string filename,
1202292SN/A                             uint8_t *&raw_data,
12113429Srekai.gonzalezalberquilla@arm.com                             uint64& uncompressed_trace_size);
1222292SN/A    void writeCompressedTrace(uint8_t *raw_data, std::string file,
12313429Srekai.gonzalezalberquilla@arm.com                              uint64 uncompressed_trace_size);
1242292SN/A
1258545Ssaidi@eecs.umich.edu  private:
1268545Ssaidi@eecs.umich.edu    // configuration parameters
1278545Ssaidi@eecs.umich.edu    static int m_random_seed;
1288199SAli.Saidi@ARM.com    static bool m_randomization;
1298199SAli.Saidi@ARM.com    static uint32_t m_block_size_bytes;
1308199SAli.Saidi@ARM.com    static uint32_t m_block_size_bits;
13113429Srekai.gonzalezalberquilla@arm.com    static uint32_t m_memory_size_bits;
1328199SAli.Saidi@ARM.com
1338545Ssaidi@eecs.umich.edu    static bool m_warmup_enabled;
1348545Ssaidi@eecs.umich.edu    static unsigned m_systems_to_warmup;
1358545Ssaidi@eecs.umich.edu    static bool m_cooldown_enabled;
1368545Ssaidi@eecs.umich.edu    SimpleMemory *m_phys_mem;
1378545Ssaidi@eecs.umich.edu    const bool m_access_backing_store;
1388545Ssaidi@eecs.umich.edu
1392292SN/A    Network* m_network;
14013429Srekai.gonzalezalberquilla@arm.com    std::vector<AbstractController *> m_abs_cntrl_vec;
1412292SN/A    Cycles m_start_cycle;
1422329SN/A
1432292SN/A  public:
14413429Srekai.gonzalezalberquilla@arm.com    Profiler* m_profiler;
1452292SN/A    CacheRecorder* m_cache_recorder;
1462292SN/A    std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls;
1472292SN/A};
1482292SN/A
1492292SN/Aclass RubyStatsCallback : public Callback
1502292SN/A{
1512292SN/A  private:
1522292SN/A    RubySystem *m_ruby_system;
1532292SN/A
1542292SN/A  public:
1552292SN/A    virtual ~RubyStatsCallback() {}
1562292SN/A    RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {}
1572790Sktlim@umich.edu    void process() { m_ruby_system->collateStats(); }
1582790Sktlim@umich.edu};
1592669Sktlim@umich.edu
1602669Sktlim@umich.edu#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__
1612292SN/A