2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Daniel Sanchez
31 #ifndef __RUBY_MEMORY_HH__
32 #define __RUBY_MEMORY_HH__
36 #include "mem/physical.hh"
37 #include "params/RubyMemory.hh"
38 #include "base/callback.hh"
39 #include "mem/ruby/common/Driver.hh"
41 class RubyMemory : public PhysicalMemory, public Driver
43 class RubyMemoryPort : public MemoryPort
48 RubyMemoryPort(const std::string &_name, RubyMemory *_memory);
49 void sendTiming(PacketPtr pkt);
52 virtual bool recvTiming(PacketPtr pkt);
55 class RubyEvent : public Event
59 RubyEvent(RubyMemory *p)
60 : Event(), ruby_ptr(p) {}
62 virtual void process() { ruby_ptr->tick(); }
64 virtual const char *description() const { return "ruby tick"; }
69 // prevent copying of a RubyMemory object
70 RubyMemory(const RubyMemory &specmem);
71 const RubyMemory &operator=(const RubyMemory &specmem);
73 RubyEvent* rubyTickEvent;
76 typedef RubyMemoryParams Params;
77 RubyMemory(const Params *p);
78 virtual ~RubyMemory();
81 virtual Port *getPort(const std::string &if_name, int idx = -1);
84 //Ruby-related specifics
85 void printConfigStats(); //dsm: Maybe this function should disappear once the configuration options change & M5 determines the stats file to use
87 void hitCallback(Packet* pkt); // called by the Ruby sequencer
89 void printStats(std::ostream & out) const;
91 void printConfig(std::ostream & out) const;
97 std::string config_file, config_options, stats_file, debug_file;
100 Tick ruby_clock, ruby_phase;
102 std::map<Packet*, RubyMemoryPort*> m_packet_to_port_map;
105 class RubyExitCallback : public Callback
112 * virtualize the destructor to make sure that the correct one
116 virtual ~RubyExitCallback() {};
118 RubyExitCallback(RubyMemory* rm) {ruby=rm;};
121 * virtual process function that is invoked when the callback
124 virtual void process() {ruby->printConfigStats(); /*delete ruby; was doing double delete...*/};
128 #endif //__RUBY_MEMORY_HH__