RubySystem.hh revision 10706
12SN/A/*
21458SN/A * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu */
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.edu/*
302SN/A * Contains all of the various parts of the system we are simulating.
312SN/A * Performs allocation, deallocation, and setup of all the major
321147SN/A * components of the system
331147SN/A */
342SN/A
352037SN/A#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__
362037SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__
372428SN/A
386216Snate@binkert.org#include "base/callback.hh"
398542Sgblack@eecs.umich.edu#include "base/output.hh"
402SN/A#include "mem/ruby/profiler/Profiler.hh"
415569Snate@binkert.org#include "mem/ruby/slicc_interface/AbstractController.hh"
422238SN/A#include "mem/ruby/system/CacheRecorder.hh"
435569Snate@binkert.org#include "mem/packet.hh"
442107SN/A#include "params/RubySystem.hh"
455569Snate@binkert.org#include "sim/clocked_object.hh"
465569Snate@binkert.org
475569Snate@binkert.orgclass Network;
485569Snate@binkert.org
495569Snate@binkert.orgclass RubySystem : public ClockedObject
505569Snate@binkert.org{
515569Snate@binkert.org  public:
525569Snate@binkert.org    class RubyEvent : public Event
535569Snate@binkert.org    {
545569Snate@binkert.org      public:
555569Snate@binkert.org        RubyEvent(RubySystem* _ruby_system)
565569Snate@binkert.org        {
575569Snate@binkert.org            ruby_system = _ruby_system;
585569Snate@binkert.org        }
595569Snate@binkert.org      private:
605569Snate@binkert.org        void process();
615569Snate@binkert.org
625569Snate@binkert.org        RubySystem* ruby_system;
635569Snate@binkert.org    };
645569Snate@binkert.org
655569Snate@binkert.org    friend class RubyEvent;
665569Snate@binkert.org
675569Snate@binkert.org    typedef RubySystemParams Params;
685569Snate@binkert.org    RubySystem(const Params *p);
695569Snate@binkert.org    ~RubySystem();
705569Snate@binkert.org
715569Snate@binkert.org    // config accessors
725569Snate@binkert.org    static int getRandomSeed() { return m_random_seed; }
735569Snate@binkert.org    static int getRandomization() { return m_randomization; }
745569Snate@binkert.org    static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
755569Snate@binkert.org    static uint32_t getBlockSizeBits() { return m_block_size_bits; }
765569Snate@binkert.org    static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
775569Snate@binkert.org
785569Snate@binkert.org    SimpleMemory *getPhysMem() { return m_phys_mem; }
795569Snate@binkert.org    const bool getAccessBackingStore() { return m_access_backing_store; }
805569Snate@binkert.org
815569Snate@binkert.org    // Public Methods
825569Snate@binkert.org    Profiler*
835569Snate@binkert.org    getProfiler()
845569Snate@binkert.org    {
855569Snate@binkert.org        assert(m_profiler != NULL);
865569Snate@binkert.org        return m_profiler;
875569Snate@binkert.org    }
885569Snate@binkert.org
895569Snate@binkert.org    void regStats() { m_profiler->regStats(name()); }
905569Snate@binkert.org    void collateStats() { m_profiler->collateStats(); }
915569Snate@binkert.org    void resetStats();
925569Snate@binkert.org
935569Snate@binkert.org    void serialize(std::ostream &os);
945569Snate@binkert.org    void unserialize(Checkpoint *cp, const std::string &section);
955569Snate@binkert.org    void process();
965569Snate@binkert.org    void startup();
975569Snate@binkert.org    bool functionalRead(Packet *ptr);
985569Snate@binkert.org    bool functionalWrite(Packet *ptr);
995569Snate@binkert.org
1005569Snate@binkert.org    void registerNetwork(Network*);
1015569Snate@binkert.org    void registerAbstractController(AbstractController*);
1025569Snate@binkert.org
1035569Snate@binkert.org    bool eventQueueEmpty() { return eventq->empty(); }
1045569Snate@binkert.org    void enqueueRubyEvent(Tick tick)
1055569Snate@binkert.org    {
1065569Snate@binkert.org        RubyEvent* e = new RubyEvent(this);
1075569Snate@binkert.org        schedule(e, tick);
1085569Snate@binkert.org    }
1095569Snate@binkert.org
1105569Snate@binkert.org  private:
1115569Snate@binkert.org    // Private copy constructor and assignment operator
1125569Snate@binkert.org    RubySystem(const RubySystem& obj);
1136227Snate@binkert.org    RubySystem& operator=(const RubySystem& obj);
1146227Snate@binkert.org
1156227Snate@binkert.org    void readCompressedTrace(std::string filename,
1165569Snate@binkert.org                             uint8_t *&raw_data,
1176227Snate@binkert.org                             uint64& uncompressed_trace_size);
1185569Snate@binkert.org    void writeCompressedTrace(uint8_t *raw_data, std::string file,
1196227Snate@binkert.org                              uint64 uncompressed_trace_size);
1206227Snate@binkert.org
1216227Snate@binkert.org  private:
1228902Sandreas.hansson@arm.com    // configuration parameters
1236227Snate@binkert.org    static int m_random_seed;
1245569Snate@binkert.org    static bool m_randomization;
1255569Snate@binkert.org    static uint32_t m_block_size_bytes;
1269057SAli.Saidi@ARM.com    static uint32_t m_block_size_bits;
1279057SAli.Saidi@ARM.com    static uint32_t m_memory_size_bits;
1285569Snate@binkert.org    SimpleMemory *m_phys_mem;
1296974Stjones1@inf.ed.ac.uk    const bool m_access_backing_store;
1306974Stjones1@inf.ed.ac.uk
1316974Stjones1@inf.ed.ac.uk    Network* m_network;
1325569Snate@binkert.org    std::vector<AbstractController *> m_abs_cntrl_vec;
1335569Snate@binkert.org
1341147SN/A  public:
135    Profiler* m_profiler;
136    bool m_warmup_enabled;
137    bool m_cooldown_enabled;
138    CacheRecorder* m_cache_recorder;
139};
140
141class RubyStatsCallback : public Callback
142{
143  private:
144    RubySystem *ruby_system;
145
146  public:
147    virtual ~RubyStatsCallback() {}
148    RubyStatsCallback(RubySystem *system) : ruby_system(system) {}
149    void process() { ruby_system->collateStats(); }
150};
151
152#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__
153