RubySystem.hh revision 10920
12330SN/A/*
22330SN/A * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
32330SN/A * All rights reserved.
42330SN/A *
52330SN/A * Redistribution and use in source and binary forms, with or without
62330SN/A * modification, are permitted provided that the following conditions are
72330SN/A * met: redistributions of source code must retain the above copyright
82330SN/A * notice, this list of conditions and the following disclaimer;
92330SN/A * redistributions in binary form must reproduce the above copyright
102330SN/A * notice, this list of conditions and the following disclaimer in the
112330SN/A * documentation and/or other materials provided with the distribution;
122330SN/A * neither the name of the copyright holders nor the names of its
132330SN/A * contributors may be used to endorse or promote products derived from
142330SN/A * this software without specific prior written permission.
152330SN/A *
162330SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172330SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182330SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192330SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202330SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212330SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222330SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232330SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242330SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252330SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262330SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272689Sktlim@umich.edu */
282689Sktlim@umich.edu
292330SN/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 */
342980Sgblack@eecs.umich.edu
356658Snate@binkert.org#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__
368229Snate@binkert.org#define __MEM_RUBY_SYSTEM_SYSTEM_HH__
372362SN/A
382680Sktlim@umich.edu#include "base/callback.hh"
392683Sktlim@umich.edu#include "base/output.hh"
402678Sktlim@umich.edu#include "mem/ruby/profiler/Profiler.hh"
412292SN/A#include "mem/ruby/slicc_interface/AbstractController.hh"
422292SN/A#include "mem/ruby/system/CacheRecorder.hh"
432292SN/A#include "mem/packet.hh"
4413905Sgabeblack@google.com#include "params/RubySystem.hh"
4513905Sgabeblack@google.com#include "sim/clocked_object.hh"
468902Sandreas.hansson@arm.com
472292SN/Aclass Network;
482862Sktlim@umich.educlass AbstractController;
492862Sktlim@umich.edu
5014022Sgabeblack@google.comclass RubySystem : public ClockedObject
5114022Sgabeblack@google.com{
5214022Sgabeblack@google.com  public:
532330SN/A    class RubyEvent : public Event
542330SN/A    {
552330SN/A      public:
562330SN/A        RubyEvent(RubySystem* _ruby_system)
572330SN/A        {
582330SN/A            m_ruby_system = _ruby_system;
5910905Sandreas.sandberg@arm.com        }
602683Sktlim@umich.edu      private:
612683Sktlim@umich.edu        void process();
626331Sgblack@eecs.umich.edu
632683Sktlim@umich.edu        RubySystem* m_ruby_system;
648735Sandreas.hanson@arm.com    };
653486Sktlim@umich.edu
6611168Sandreas.hansson@arm.com    friend class RubyEvent;
672862Sktlim@umich.edu
6811168Sandreas.hansson@arm.com    typedef RubySystemParams Params;
692862Sktlim@umich.edu    RubySystem(const Params *p);
7010110Sandreas.hansson@arm.com    ~RubySystem();
712683Sktlim@umich.edu
7210190Sakash.bagdia@arm.com    // config accessors
7310190Sakash.bagdia@arm.com    static int getRandomSeed() { return m_random_seed; }
7411005Sandreas.sandberg@arm.com    static int getRandomization() { return m_randomization; }
755714Shsul@eecs.umich.edu    static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
7611005Sandreas.sandberg@arm.com    static uint32_t getBlockSizeBits() { return m_block_size_bits; }
775714Shsul@eecs.umich.edu    static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
786221Snate@binkert.org    static bool getWarmupEnabled() { return m_warmup_enabled; }
792683Sktlim@umich.edu    static bool getCooldownEnabled() { return m_cooldown_enabled; }
8010110Sandreas.hansson@arm.com
812683Sktlim@umich.edu    SimpleMemory *getPhysMem() { return m_phys_mem; }
8210110Sandreas.hansson@arm.com    Cycles getStartCycle() { return m_start_cycle; }
832683Sktlim@umich.edu    const bool getAccessBackingStore() { return m_access_backing_store; }
8410110Sandreas.hansson@arm.com
852683Sktlim@umich.edu    // Public Methods
868706Sandreas.hansson@arm.com    Profiler*
878706Sandreas.hansson@arm.com    getProfiler()
888706Sandreas.hansson@arm.com    {
898706Sandreas.hansson@arm.com        assert(m_profiler != NULL);
908921Sandreas.hansson@arm.com        return m_profiler;
918706Sandreas.hansson@arm.com    }
928706Sandreas.hansson@arm.com
933675Sktlim@umich.edu    void regStats() { m_profiler->regStats(name()); }
942683Sktlim@umich.edu    void collateStats() { m_profiler->collateStats(); }
952683Sktlim@umich.edu    void resetStats();
962683Sktlim@umich.edu
972683Sktlim@umich.edu    void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
982683Sktlim@umich.edu    void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
992683Sktlim@umich.edu    void process();
1002683Sktlim@umich.edu    void startup();
1012683Sktlim@umich.edu    bool functionalRead(Packet *ptr);
10213905Sgabeblack@google.com    bool functionalWrite(Packet *ptr);
1032683Sktlim@umich.edu
1049101SBrad.Beckmann@amd.com    void registerNetwork(Network*);
1052690Sktlim@umich.edu    void registerAbstractController(AbstractController*);
10614022Sgabeblack@google.com
1078799Sgblack@eecs.umich.edu    bool eventQueueEmpty() { return eventq->empty(); }
1082683Sktlim@umich.edu    void enqueueRubyEvent(Tick tick)
1092683Sktlim@umich.edu    {
11011886Sbrandon.potter@amd.com        RubyEvent* e = new RubyEvent(this);
11111886Sbrandon.potter@amd.com        schedule(e, tick);
11211886Sbrandon.potter@amd.com    }
11311886Sbrandon.potter@amd.com
11411886Sbrandon.potter@amd.com  private:
11511886Sbrandon.potter@amd.com    // Private copy constructor and assignment operator
11611886Sbrandon.potter@amd.com    RubySystem(const RubySystem& obj);
11711886Sbrandon.potter@amd.com    RubySystem& operator=(const RubySystem& obj);
11814023Sgabeblack@google.com
11914023Sgabeblack@google.com    void readCompressedTrace(std::string filename,
12014023Sgabeblack@google.com                             uint8_t *&raw_data,
12111886Sbrandon.potter@amd.com                             uint64& uncompressed_trace_size);
12211886Sbrandon.potter@amd.com    void writeCompressedTrace(uint8_t *raw_data, std::string file,
12311886Sbrandon.potter@amd.com                              uint64 uncompressed_trace_size);
12411886Sbrandon.potter@amd.com
12514022Sgabeblack@google.com  private:
1262292SN/A    // configuration parameters
1272683Sktlim@umich.edu    static int m_random_seed;
1282683Sktlim@umich.edu    static bool m_randomization;
1292683Sktlim@umich.edu    static uint32_t m_block_size_bytes;
13013865Sgabeblack@google.com    static uint32_t m_block_size_bits;
1312683Sktlim@umich.edu    static uint32_t m_memory_size_bits;
1322683Sktlim@umich.edu
1332683Sktlim@umich.edu    static bool m_warmup_enabled;
1342683Sktlim@umich.edu    static unsigned m_systems_to_warmup;
1352683Sktlim@umich.edu    static bool m_cooldown_enabled;
1362683Sktlim@umich.edu    SimpleMemory *m_phys_mem;
1372683Sktlim@umich.edu    const bool m_access_backing_store;
1382683Sktlim@umich.edu
1392683Sktlim@umich.edu    Network* m_network;
1402683Sktlim@umich.edu    std::vector<AbstractController *> m_abs_cntrl_vec;
1412683Sktlim@umich.edu    Cycles m_start_cycle;
1422683Sktlim@umich.edu
1433673Srdreslin@umich.edu  public:
1443486Sktlim@umich.edu    Profiler* m_profiler;
1452683Sktlim@umich.edu    CacheRecorder* m_cache_recorder;
1462683Sktlim@umich.edu    std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls;
1472683Sktlim@umich.edu};
1485999Snate@binkert.org
1498834Satgutier@umich.educlass RubyStatsCallback : public Callback
1508834Satgutier@umich.edu{
1518834Satgutier@umich.edu  private:
1528834Satgutier@umich.edu    RubySystem *m_ruby_system;
1532683Sktlim@umich.edu
1545999Snate@binkert.org  public:
1552683Sktlim@umich.edu    virtual ~RubyStatsCallback() {}
1562683Sktlim@umich.edu    RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {}
1572683Sktlim@umich.edu    void process() { m_ruby_system->collateStats(); }
1582683Sktlim@umich.edu};
1592683Sktlim@umich.edu
1602683Sktlim@umich.edu#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__
1612683Sktlim@umich.edu