2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009-2010 Advanced Micro Devices, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
31 #define __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
37 #include "mem/ruby/common/DataBlock.hh"
38 #include "mem/ruby/common/Global.hh"
39 #include "mem/ruby/common/SubBlock.hh"
40 #include "mem/ruby/system/RubyPort.hh"
41 #include "mem/mem_object.hh"
42 #include "mem/packet.hh"
43 #include "params/RubyDirectedTester.hh"
45 class DirectedGenerator;
47 class RubyDirectedTester : public MemObject
50 class CpuPort : public Port
53 RubyDirectedTester *tester;
56 CpuPort(const std::string &_name, RubyDirectedTester *_tester,
58 : Port(_name, _tester), tester(_tester), idx(_idx)
64 virtual bool recvTiming(PacketPtr pkt);
65 virtual Tick recvAtomic(PacketPtr pkt);
66 virtual void recvFunctional(PacketPtr pkt) { }
67 virtual void recvRangeChange() { }
70 typedef RubyDirectedTesterParams Params;
71 RubyDirectedTester(const Params *p);
72 ~RubyDirectedTester();
74 virtual Port *getPort(const std::string &if_name, int idx = -1);
76 Port* getCpuPort(int idx);
82 void incrementCycleCompletions() { m_requests_completed++; }
84 void printStats(std::ostream& out) const {}
86 void printConfig(std::ostream& out) const {}
88 void print(std::ostream& out) const;
91 class DirectedStartEvent : public Event
94 RubyDirectedTester *tester;
97 DirectedStartEvent(RubyDirectedTester *_tester)
98 : Event(CPU_Tick_Pri), tester(_tester)
100 void process() { tester->wakeup(); }
101 virtual const char *description() const { return "Directed tick"; }
104 DirectedStartEvent directedStartEvent;
107 void hitCallback(NodeID proc, Addr addr);
109 void checkForDeadlock();
111 // Private copy constructor and assignment operator
112 RubyDirectedTester(const RubyDirectedTester& obj);
113 RubyDirectedTester& operator=(const RubyDirectedTester& obj);
115 uint64 m_requests_completed;
116 std::vector<CpuPort*> ports;
117 uint64 m_requests_to_complete;
118 DirectedGenerator* generator;
121 #endif // __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__