2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009 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_RUBYTEST_RUBYTESTER_HH__
31 #define __CPU_RUBYTEST_RUBYTESTER_HH__
37 #include "cpu/testers/rubytest/CheckTable.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/RubyTester.hh"
45 class RubyTester : public MemObject
48 class CpuPort : public MasterPort
55 // Currently, each instatiation of the RubyTester::CpuPort supports
56 // only instruction or data requests, not both. However, for those
57 // RubyPorts that support both types of requests, separate InstOnly
58 // and DataOnly CpuPorts will map to that RubyPort
62 // Port supports only instruction requests
64 // Port supports only data requests
68 CpuPort(const std::string &_name, RubyTester *_tester, int _idx,
70 : MasterPort(_name, _tester), tester(_tester), idx(_idx),
78 virtual bool recvTiming(PacketPtr pkt);
79 virtual void recvRetry()
80 { panic("%s does not expect a retry\n", name()); }
81 virtual Tick recvAtomic(PacketPtr pkt);
82 virtual void recvFunctional(PacketPtr pkt) { }
85 struct SenderState : public Packet::SenderState
88 Packet::SenderState *saved;
90 SenderState(Address addr, int size,
91 Packet::SenderState *sender_state = NULL)
94 subBlock = new SubBlock(addr, size);
103 typedef RubyTesterParams Params;
104 RubyTester(const Params *p);
107 virtual MasterPort &getMasterPort(const std::string &if_name,
110 MasterPort* getReadableCpuPort(int idx);
111 MasterPort* getWritableCpuPort(int idx);
117 void incrementCheckCompletions() { m_checks_completed++; }
119 void printStats(std::ostream& out) const {}
121 void printConfig(std::ostream& out) const {}
123 void print(std::ostream& out) const;
124 bool getCheckFlush() { return m_check_flush; }
126 MasterID masterId() { return _masterId; }
128 class CheckStartEvent : public Event
134 CheckStartEvent(RubyTester *_tester)
135 : Event(CPU_Tick_Pri), tester(_tester)
137 void process() { tester->wakeup(); }
138 virtual const char *description() const { return "RubyTester tick"; }
141 CheckStartEvent checkStartEvent;
146 void hitCallback(NodeID proc, SubBlock* data);
148 void checkForDeadlock();
150 // Private copy constructor and assignment operator
151 RubyTester(const RubyTester& obj);
152 RubyTester& operator=(const RubyTester& obj);
154 CheckTable* m_checkTable_ptr;
155 std::vector<Time> m_last_progress_vector;
158 uint64 m_checks_completed;
159 std::vector<CpuPort*> writePorts;
160 std::vector<CpuPort*> readPorts;
161 uint64 m_checks_to_complete;
162 int m_deadlock_threshold;
165 int m_wakeup_frequency;
167 int m_num_inst_ports;
171 operator<<(std::ostream& out, const RubyTester& obj)
178 #endif // __CPU_RUBYTEST_RUBYTESTER_HH__