RubyTester.hh (8948:e95ee70f876c) RubyTester.hh (8950:a6830d615eff)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
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.
16 *
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.
28 */
29
30#ifndef __CPU_RUBYTEST_RUBYTESTER_HH__
31#define __CPU_RUBYTEST_RUBYTESTER_HH__
32
33#include <iostream>
34#include <string>
35#include <vector>
36
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"
44
45class RubyTester : public MemObject
46{
47 public:
48 class CpuPort : public MasterPort
49 {
50 private:
51 RubyTester *tester;
52
53 public:
54 //
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
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
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.
16 *
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.
28 */
29
30#ifndef __CPU_RUBYTEST_RUBYTESTER_HH__
31#define __CPU_RUBYTEST_RUBYTESTER_HH__
32
33#include <iostream>
34#include <string>
35#include <vector>
36
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"
44
45class RubyTester : public MemObject
46{
47 public:
48 class CpuPort : public MasterPort
49 {
50 private:
51 RubyTester *tester;
52
53 public:
54 //
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
59 //
60 enum Type
61 {
62 // Port supports only instruction requests
63 InstOnly,
64 // Port supports only data requests
65 DataOnly
66 };
67
59
68 CpuPort(const std::string &_name, RubyTester *_tester, int _idx,
69 Type _type)
70 : MasterPort(_name, _tester), tester(_tester), idx(_idx),
71 type(_type)
60 CpuPort(const std::string &_name, RubyTester *_tester, int _idx)
61 : MasterPort(_name, _tester), tester(_tester), idx(_idx)
72 {}
73
74 int idx;
62 {}
63
64 int idx;
75 Type type;
76
77 protected:
78 virtual bool recvTiming(PacketPtr pkt);
79 virtual void recvRetry()
80 { panic("%s does not expect a retry\n", name()); }
81 };
82
83 struct SenderState : public Packet::SenderState
84 {
85 SubBlock* subBlock;
86 Packet::SenderState *saved;
87
88 SenderState(Address addr, int size,
89 Packet::SenderState *sender_state = NULL)
90 : saved(sender_state)
91 {
92 subBlock = new SubBlock(addr, size);
93 }
94
95 ~SenderState()
96 {
97 delete subBlock;
98 }
99 };
100
101 typedef RubyTesterParams Params;
102 RubyTester(const Params *p);
103 ~RubyTester();
104
105 virtual MasterPort &getMasterPort(const std::string &if_name,
106 int idx = -1);
107
65
66 protected:
67 virtual bool recvTiming(PacketPtr pkt);
68 virtual void recvRetry()
69 { panic("%s does not expect a retry\n", name()); }
70 };
71
72 struct SenderState : public Packet::SenderState
73 {
74 SubBlock* subBlock;
75 Packet::SenderState *saved;
76
77 SenderState(Address addr, int size,
78 Packet::SenderState *sender_state = NULL)
79 : saved(sender_state)
80 {
81 subBlock = new SubBlock(addr, size);
82 }
83
84 ~SenderState()
85 {
86 delete subBlock;
87 }
88 };
89
90 typedef RubyTesterParams Params;
91 RubyTester(const Params *p);
92 ~RubyTester();
93
94 virtual MasterPort &getMasterPort(const std::string &if_name,
95 int idx = -1);
96
97 bool isInstReadableCpuPort(int idx);
98
108 MasterPort* getReadableCpuPort(int idx);
109 MasterPort* getWritableCpuPort(int idx);
110
111 virtual void init();
112
113 void wakeup();
114
115 void incrementCheckCompletions() { m_checks_completed++; }
116
117 void printStats(std::ostream& out) const {}
118 void clearStats() {}
119 void printConfig(std::ostream& out) const {}
120
121 void print(std::ostream& out) const;
122 bool getCheckFlush() { return m_check_flush; }
123
124 MasterID masterId() { return _masterId; }
125 protected:
126 class CheckStartEvent : public Event
127 {
128 private:
129 RubyTester *tester;
130
131 public:
132 CheckStartEvent(RubyTester *_tester)
133 : Event(CPU_Tick_Pri), tester(_tester)
134 {}
135 void process() { tester->wakeup(); }
136 virtual const char *description() const { return "RubyTester tick"; }
137 };
138
139 CheckStartEvent checkStartEvent;
140
141 MasterID _masterId;
142
143 private:
144 void hitCallback(NodeID proc, SubBlock* data);
145
146 void checkForDeadlock();
147
148 // Private copy constructor and assignment operator
149 RubyTester(const RubyTester& obj);
150 RubyTester& operator=(const RubyTester& obj);
151
152 CheckTable* m_checkTable_ptr;
153 std::vector<Time> m_last_progress_vector;
154
155 int m_num_cpus;
156 uint64 m_checks_completed;
99 MasterPort* getReadableCpuPort(int idx);
100 MasterPort* getWritableCpuPort(int idx);
101
102 virtual void init();
103
104 void wakeup();
105
106 void incrementCheckCompletions() { m_checks_completed++; }
107
108 void printStats(std::ostream& out) const {}
109 void clearStats() {}
110 void printConfig(std::ostream& out) const {}
111
112 void print(std::ostream& out) const;
113 bool getCheckFlush() { return m_check_flush; }
114
115 MasterID masterId() { return _masterId; }
116 protected:
117 class CheckStartEvent : public Event
118 {
119 private:
120 RubyTester *tester;
121
122 public:
123 CheckStartEvent(RubyTester *_tester)
124 : Event(CPU_Tick_Pri), tester(_tester)
125 {}
126 void process() { tester->wakeup(); }
127 virtual const char *description() const { return "RubyTester tick"; }
128 };
129
130 CheckStartEvent checkStartEvent;
131
132 MasterID _masterId;
133
134 private:
135 void hitCallback(NodeID proc, SubBlock* data);
136
137 void checkForDeadlock();
138
139 // Private copy constructor and assignment operator
140 RubyTester(const RubyTester& obj);
141 RubyTester& operator=(const RubyTester& obj);
142
143 CheckTable* m_checkTable_ptr;
144 std::vector<Time> m_last_progress_vector;
145
146 int m_num_cpus;
147 uint64 m_checks_completed;
157 std::vector<CpuPort*> writePorts;
158 std::vector<CpuPort*> readPorts;
148 std::vector<MasterPort*> writePorts;
149 std::vector<MasterPort*> readPorts;
159 uint64 m_checks_to_complete;
160 int m_deadlock_threshold;
161 int m_num_writers;
162 int m_num_readers;
163 int m_wakeup_frequency;
164 bool m_check_flush;
165 int m_num_inst_ports;
166};
167
168inline std::ostream&
169operator<<(std::ostream& out, const RubyTester& obj)
170{
171 obj.print(out);
172 out << std::flush;
173 return out;
174}
175
176#endif // __CPU_RUBYTEST_RUBYTESTER_HH__
150 uint64 m_checks_to_complete;
151 int m_deadlock_threshold;
152 int m_num_writers;
153 int m_num_readers;
154 int m_wakeup_frequency;
155 bool m_check_flush;
156 int m_num_inst_ports;
157};
158
159inline std::ostream&
160operator<<(std::ostream& out, const RubyTester& obj)
161{
162 obj.print(out);
163 out << std::flush;
164 return out;
165}
166
167#endif // __CPU_RUBYTEST_RUBYTESTER_HH__