RubySystem.hh revision 10525
1955SN/A/*
2955SN/A * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
31762SN/A * All rights reserved.
4955SN/A *
5955SN/A * Redistribution and use in source and binary forms, with or without
6955SN/A * modification, are permitted provided that the following conditions are
7955SN/A * met: redistributions of source code must retain the above copyright
8955SN/A * notice, this list of conditions and the following disclaimer;
9955SN/A * redistributions in binary form must reproduce the above copyright
10955SN/A * notice, this list of conditions and the following disclaimer in the
11955SN/A * documentation and/or other materials provided with the distribution;
12955SN/A * neither the name of the copyright holders nor the names of its
13955SN/A * contributors may be used to endorse or promote products derived from
14955SN/A * this software without specific prior written permission.
15955SN/A *
16955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27955SN/A */
28955SN/A
29955SN/A/*
30955SN/A * Contains all of the various parts of the system we are simulating.
311608SN/A * Performs allocation, deallocation, and setup of all the major
32955SN/A * components of the system
33955SN/A */
34955SN/A
35955SN/A#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__
36955SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__
37955SN/A
38955SN/A#include "base/callback.hh"
39955SN/A#include "base/output.hh"
40955SN/A#include "mem/ruby/profiler/Profiler.hh"
41955SN/A#include "mem/ruby/slicc_interface/AbstractController.hh"
42955SN/A#include "mem/ruby/system/CacheRecorder.hh"
43955SN/A#include "mem/packet.hh"
44955SN/A#include "params/RubySystem.hh"
45955SN/A#include "sim/clocked_object.hh"
462023SN/A
47955SN/Aclass Network;
48955SN/A
49955SN/Aclass RubySystem : public ClockedObject
50955SN/A{
51955SN/A  public:
52955SN/A    class RubyEvent : public Event
53955SN/A    {
54955SN/A      public:
55955SN/A        RubyEvent(RubySystem* _ruby_system)
561031SN/A        {
57955SN/A            ruby_system = _ruby_system;
581388SN/A        }
59955SN/A      private:
60955SN/A        void process();
611296SN/A
62955SN/A        RubySystem* ruby_system;
632609SN/A    };
64955SN/A
65955SN/A    friend class RubyEvent;
66955SN/A
67955SN/A    typedef RubySystemParams Params;
68955SN/A    RubySystem(const Params *p);
69955SN/A    ~RubySystem();
70955SN/A
71955SN/A    // config accessors
72955SN/A    static int getRandomSeed() { return m_random_seed; }
73955SN/A    static int getRandomization() { return m_randomization; }
74955SN/A    static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
75955SN/A    static uint32_t getBlockSizeBits() { return m_block_size_bits; }
76955SN/A    static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
77955SN/A
78955SN/A    SimpleMemory *getPhysMem() { return m_phys_mem; }
79955SN/A
80955SN/A    // Public Methods
81955SN/A    Profiler*
821717SN/A    getProfiler()
832190SN/A    {
842652Ssaidi@eecs.umich.edu        assert(m_profiler != NULL);
85955SN/A        return m_profiler;
862410SN/A    }
87955SN/A
88955SN/A    void regStats() { m_profiler->regStats(name()); }
891717SN/A    void collateStats() { m_profiler->collateStats(); }
902568SN/A    void resetStats();
912568SN/A
922568SN/A    void serialize(std::ostream &os);
932499SN/A    void unserialize(Checkpoint *cp, const std::string &section);
942462SN/A    void process();
952568SN/A    void startup();
962395SN/A    bool functionalRead(Packet *ptr);
972405SN/A    bool functionalWrite(Packet *ptr);
982568SN/A
99955SN/A    void registerNetwork(Network*);
100955SN/A    void registerAbstractController(AbstractController*);
101955SN/A
102955SN/A    bool eventQueueEmpty() { return eventq->empty(); }
103955SN/A    void enqueueRubyEvent(Tick tick)
1042090SN/A    {
105955SN/A        RubyEvent* e = new RubyEvent(this);
106955SN/A        schedule(e, tick);
107955SN/A    }
1081696SN/A
109955SN/A  private:
110955SN/A    // Private copy constructor and assignment operator
111955SN/A    RubySystem(const RubySystem& obj);
112955SN/A    RubySystem& operator=(const RubySystem& obj);
1131127SN/A
114955SN/A    void readCompressedTrace(std::string filename,
115955SN/A                             uint8_t *&raw_data,
1162379SN/A                             uint64& uncompressed_trace_size);
117955SN/A    void writeCompressedTrace(uint8_t *raw_data, std::string file,
118955SN/A                              uint64 uncompressed_trace_size);
119955SN/A
1202155SN/A  private:
1212155SN/A    // configuration parameters
1222155SN/A    static int m_random_seed;
1232155SN/A    static bool m_randomization;
1242155SN/A    static uint32_t m_block_size_bytes;
1252155SN/A    static uint32_t m_block_size_bits;
1262155SN/A    static uint32_t m_memory_size_bits;
1272155SN/A    SimpleMemory *m_phys_mem;
1282155SN/A
1292155SN/A    Network* m_network;
1302155SN/A    std::vector<AbstractController *> m_abs_cntrl_vec;
1312155SN/A
1322155SN/A  public:
1332155SN/A    Profiler* m_profiler;
1342155SN/A    bool m_warmup_enabled;
1352155SN/A    bool m_cooldown_enabled;
1362155SN/A    CacheRecorder* m_cache_recorder;
1372155SN/A};
1382155SN/A
1392155SN/Aclass RubyStatsCallback : public Callback
1402155SN/A{
1412155SN/A  private:
1422155SN/A    RubySystem *ruby_system;
1432155SN/A
1442155SN/A  public:
1452155SN/A    virtual ~RubyStatsCallback() {}
1462155SN/A    RubyStatsCallback(RubySystem *system) : ruby_system(system) {}
1472155SN/A    void process() { ruby_system->collateStats(); }
1482155SN/A};
1492155SN/A
1502155SN/A#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__
1512155SN/A