Check.cc (8832:247fee427324) Check.cc (8932:1b2c17565ac8)
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#include "cpu/testers/rubytest/Check.hh"
31#include "debug/RubyTest.hh"
32#include "mem/ruby/common/SubBlock.hh"
33#include "mem/ruby/system/Sequencer.hh"
34#include "mem/ruby/system/System.hh"
35
36typedef RubyTester::SenderState SenderState;
37
38Check::Check(const Address& address, const Address& pc,
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#include "cpu/testers/rubytest/Check.hh"
31#include "debug/RubyTest.hh"
32#include "mem/ruby/common/SubBlock.hh"
33#include "mem/ruby/system/Sequencer.hh"
34#include "mem/ruby/system/System.hh"
35
36typedef RubyTester::SenderState SenderState;
37
38Check::Check(const Address& address, const Address& pc,
39 int _num_cpu_sequencers, RubyTester* _tester)
40 : m_num_cpu_sequencers(_num_cpu_sequencers), m_tester_ptr(_tester)
39 int _num_writers, int _num_readers, RubyTester* _tester)
40 : m_num_writers(_num_writers), m_num_readers(_num_readers),
41 m_tester_ptr(_tester)
41{
42 m_status = TesterStatus_Idle;
43
44 pickValue();
45 pickInitiatingNode();
46 changeAddress(address);
47 m_pc = pc;
48 m_access_mode = RubyAccessMode(random() % RubyAccessMode_NUM);
49 m_store_count = 0;
50}
51
52void
53Check::initiate()
54{
55 DPRINTF(RubyTest, "initiating\n");
56 debugPrint();
57
58 // currently no protocols support prefetches
59 if (false && (random() & 0xf) == 0) {
60 initiatePrefetch(); // Prefetch from random processor
61 }
62
63 if (m_tester_ptr->getCheckFlush() && (random() & 0xff) == 0) {
64 initiateFlush(); // issue a Flush request from random processor
65 }
66
67 if (m_status == TesterStatus_Idle) {
68 initiateAction();
69 } else if (m_status == TesterStatus_Ready) {
70 initiateCheck();
71 } else {
72 // Pending - do nothing
73 DPRINTF(RubyTest,
74 "initiating action/check - failed: action/check is pending\n");
75 }
76}
77
78void
79Check::initiatePrefetch()
80{
81 DPRINTF(RubyTest, "initiating prefetch\n");
82
42{
43 m_status = TesterStatus_Idle;
44
45 pickValue();
46 pickInitiatingNode();
47 changeAddress(address);
48 m_pc = pc;
49 m_access_mode = RubyAccessMode(random() % RubyAccessMode_NUM);
50 m_store_count = 0;
51}
52
53void
54Check::initiate()
55{
56 DPRINTF(RubyTest, "initiating\n");
57 debugPrint();
58
59 // currently no protocols support prefetches
60 if (false && (random() & 0xf) == 0) {
61 initiatePrefetch(); // Prefetch from random processor
62 }
63
64 if (m_tester_ptr->getCheckFlush() && (random() & 0xff) == 0) {
65 initiateFlush(); // issue a Flush request from random processor
66 }
67
68 if (m_status == TesterStatus_Idle) {
69 initiateAction();
70 } else if (m_status == TesterStatus_Ready) {
71 initiateCheck();
72 } else {
73 // Pending - do nothing
74 DPRINTF(RubyTest,
75 "initiating action/check - failed: action/check is pending\n");
76 }
77}
78
79void
80Check::initiatePrefetch()
81{
82 DPRINTF(RubyTest, "initiating prefetch\n");
83
83 int index = random() % m_num_cpu_sequencers;
84 int index = random() % m_num_readers;
84 RubyTester::CpuPort* port =
85 RubyTester::CpuPort* port =
85 safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getCpuPort(index));
86 safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getReadableCpuPort(index));
86
87 Request::Flags flags;
88 flags.set(Request::PREFETCH);
89
90 Packet::Command cmd;
91
92 // 1 in 8 chance this will be an exclusive prefetch
93 if ((random() & 0x7) != 0) {
94 cmd = MemCmd::ReadReq;
95
87
88 Request::Flags flags;
89 flags.set(Request::PREFETCH);
90
91 Packet::Command cmd;
92
93 // 1 in 8 chance this will be an exclusive prefetch
94 if ((random() & 0x7) != 0) {
95 cmd = MemCmd::ReadReq;
96
96 // 50% chance that the request will be an instruction fetch
97 if ((random() & 0x1) == 0) {
97 // if necessary, make the request an instruction fetch
98 if (port->type == RubyTester::CpuPort::InstOnly) {
98 flags.set(Request::INST_FETCH);
99 }
100 } else {
101 cmd = MemCmd::WriteReq;
102 flags.set(Request::PF_EXCLUSIVE);
103 }
104
105 // Prefetches are assumed to be 0 sized
106 Request *req = new Request(m_address.getAddress(), 0, flags,
107 m_tester_ptr->masterId(), curTick(), m_pc.getAddress());
108 req->setThreadContext(index, 0);
109
110 PacketPtr pkt = new Packet(req, cmd, port->idx);
111
112 // push the subblock onto the sender state. The sequencer will
113 // update the subblock on the return
114 pkt->senderState =
115 new SenderState(m_address, req->getSize(), pkt->senderState);
116
117 if (port->sendTiming(pkt)) {
118 DPRINTF(RubyTest, "successfully initiated prefetch.\n");
119 } else {
120 // If the packet did not issue, must delete
121 SenderState* senderState = safe_cast<SenderState*>(pkt->senderState);
122 pkt->senderState = senderState->saved;
123 delete senderState;
124 delete pkt->req;
125 delete pkt;
126
127 DPRINTF(RubyTest,
128 "prefetch initiation failed because Port was busy.\n");
129 }
130}
131
132void
133Check::initiateFlush()
134{
135
136 DPRINTF(RubyTest, "initiating Flush\n");
137
99 flags.set(Request::INST_FETCH);
100 }
101 } else {
102 cmd = MemCmd::WriteReq;
103 flags.set(Request::PF_EXCLUSIVE);
104 }
105
106 // Prefetches are assumed to be 0 sized
107 Request *req = new Request(m_address.getAddress(), 0, flags,
108 m_tester_ptr->masterId(), curTick(), m_pc.getAddress());
109 req->setThreadContext(index, 0);
110
111 PacketPtr pkt = new Packet(req, cmd, port->idx);
112
113 // push the subblock onto the sender state. The sequencer will
114 // update the subblock on the return
115 pkt->senderState =
116 new SenderState(m_address, req->getSize(), pkt->senderState);
117
118 if (port->sendTiming(pkt)) {
119 DPRINTF(RubyTest, "successfully initiated prefetch.\n");
120 } else {
121 // If the packet did not issue, must delete
122 SenderState* senderState = safe_cast<SenderState*>(pkt->senderState);
123 pkt->senderState = senderState->saved;
124 delete senderState;
125 delete pkt->req;
126 delete pkt;
127
128 DPRINTF(RubyTest,
129 "prefetch initiation failed because Port was busy.\n");
130 }
131}
132
133void
134Check::initiateFlush()
135{
136
137 DPRINTF(RubyTest, "initiating Flush\n");
138
138 int index = random() % m_num_cpu_sequencers;
139 int index = random() % m_num_writers;
139 RubyTester::CpuPort* port =
140 RubyTester::CpuPort* port =
140 safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getCpuPort(index));
141 safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getWritableCpuPort(index));
141
142 Request::Flags flags;
143
144 Request *req = new Request(m_address.getAddress(), CHECK_SIZE, flags,
145 m_tester_ptr->masterId(), curTick(), m_pc.getAddress());
146
147 Packet::Command cmd;
148
149 cmd = MemCmd::FlushReq;
150
151 PacketPtr pkt = new Packet(req, cmd, port->idx);
152
153 // push the subblock onto the sender state. The sequencer will
154 // update the subblock on the return
155 pkt->senderState =
156 new SenderState(m_address, req->getSize(), pkt->senderState);
157
158 if (port->sendTiming(pkt)) {
159 DPRINTF(RubyTest, "initiating Flush - successful\n");
160 }
161}
162
163void
164Check::initiateAction()
165{
166 DPRINTF(RubyTest, "initiating Action\n");
167 assert(m_status == TesterStatus_Idle);
168
142
143 Request::Flags flags;
144
145 Request *req = new Request(m_address.getAddress(), CHECK_SIZE, flags,
146 m_tester_ptr->masterId(), curTick(), m_pc.getAddress());
147
148 Packet::Command cmd;
149
150 cmd = MemCmd::FlushReq;
151
152 PacketPtr pkt = new Packet(req, cmd, port->idx);
153
154 // push the subblock onto the sender state. The sequencer will
155 // update the subblock on the return
156 pkt->senderState =
157 new SenderState(m_address, req->getSize(), pkt->senderState);
158
159 if (port->sendTiming(pkt)) {
160 DPRINTF(RubyTest, "initiating Flush - successful\n");
161 }
162}
163
164void
165Check::initiateAction()
166{
167 DPRINTF(RubyTest, "initiating Action\n");
168 assert(m_status == TesterStatus_Idle);
169
169 int index = random() % m_num_cpu_sequencers;
170 int index = random() % m_num_writers;
170 RubyTester::CpuPort* port =
171 RubyTester::CpuPort* port =
171 safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getCpuPort(index));
172 safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getWritableCpuPort(index));
172
173 Request::Flags flags;
174
175 // Create the particular address for the next byte to be written
176 Address writeAddr(m_address.getAddress() + m_store_count);
177
178 // Stores are assumed to be 1 byte-sized
179 Request *req = new Request(writeAddr.getAddress(), 1, flags,
180 m_tester_ptr->masterId(), curTick(),
181 m_pc.getAddress());
182
183 req->setThreadContext(index, 0);
184 Packet::Command cmd;
185
186 // 1 out of 8 chance, issue an atomic rather than a write
187 // if ((random() & 0x7) == 0) {
188 // cmd = MemCmd::SwapReq;
189 // } else {
190 cmd = MemCmd::WriteReq;
191 // }
192
193 PacketPtr pkt = new Packet(req, cmd, port->idx);
194 uint8_t* writeData = new uint8_t;
195 *writeData = m_value + m_store_count;
196 pkt->dataDynamic(writeData);
197
198 DPRINTF(RubyTest, "data 0x%x check 0x%x\n",
199 *(pkt->getPtr<uint8_t>()), *writeData);
200
201 // push the subblock onto the sender state. The sequencer will
202 // update the subblock on the return
203 pkt->senderState =
204 new SenderState(writeAddr, req->getSize(), pkt->senderState);
205
206 if (port->sendTiming(pkt)) {
207 DPRINTF(RubyTest, "initiating action - successful\n");
208 DPRINTF(RubyTest, "status before action update: %s\n",
209 (TesterStatus_to_string(m_status)).c_str());
210 m_status = TesterStatus_Action_Pending;
211 } else {
212 // If the packet did not issue, must delete
213 // Note: No need to delete the data, the packet destructor
214 // will delete it
215 SenderState* senderState = safe_cast<SenderState*>(pkt->senderState);
216 pkt->senderState = senderState->saved;
217 delete senderState;
218 delete pkt->req;
219 delete pkt;
220
221 DPRINTF(RubyTest, "failed to initiate action - sequencer not ready\n");
222 }
223
224 DPRINTF(RubyTest, "status after action update: %s\n",
225 (TesterStatus_to_string(m_status)).c_str());
226}
227
228void
229Check::initiateCheck()
230{
231 DPRINTF(RubyTest, "Initiating Check\n");
232 assert(m_status == TesterStatus_Ready);
233
173
174 Request::Flags flags;
175
176 // Create the particular address for the next byte to be written
177 Address writeAddr(m_address.getAddress() + m_store_count);
178
179 // Stores are assumed to be 1 byte-sized
180 Request *req = new Request(writeAddr.getAddress(), 1, flags,
181 m_tester_ptr->masterId(), curTick(),
182 m_pc.getAddress());
183
184 req->setThreadContext(index, 0);
185 Packet::Command cmd;
186
187 // 1 out of 8 chance, issue an atomic rather than a write
188 // if ((random() & 0x7) == 0) {
189 // cmd = MemCmd::SwapReq;
190 // } else {
191 cmd = MemCmd::WriteReq;
192 // }
193
194 PacketPtr pkt = new Packet(req, cmd, port->idx);
195 uint8_t* writeData = new uint8_t;
196 *writeData = m_value + m_store_count;
197 pkt->dataDynamic(writeData);
198
199 DPRINTF(RubyTest, "data 0x%x check 0x%x\n",
200 *(pkt->getPtr<uint8_t>()), *writeData);
201
202 // push the subblock onto the sender state. The sequencer will
203 // update the subblock on the return
204 pkt->senderState =
205 new SenderState(writeAddr, req->getSize(), pkt->senderState);
206
207 if (port->sendTiming(pkt)) {
208 DPRINTF(RubyTest, "initiating action - successful\n");
209 DPRINTF(RubyTest, "status before action update: %s\n",
210 (TesterStatus_to_string(m_status)).c_str());
211 m_status = TesterStatus_Action_Pending;
212 } else {
213 // If the packet did not issue, must delete
214 // Note: No need to delete the data, the packet destructor
215 // will delete it
216 SenderState* senderState = safe_cast<SenderState*>(pkt->senderState);
217 pkt->senderState = senderState->saved;
218 delete senderState;
219 delete pkt->req;
220 delete pkt;
221
222 DPRINTF(RubyTest, "failed to initiate action - sequencer not ready\n");
223 }
224
225 DPRINTF(RubyTest, "status after action update: %s\n",
226 (TesterStatus_to_string(m_status)).c_str());
227}
228
229void
230Check::initiateCheck()
231{
232 DPRINTF(RubyTest, "Initiating Check\n");
233 assert(m_status == TesterStatus_Ready);
234
234 int index = random() % m_num_cpu_sequencers;
235 int index = random() % m_num_readers;
235 RubyTester::CpuPort* port =
236 RubyTester::CpuPort* port =
236 safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getCpuPort(index));
237 safe_cast<RubyTester::CpuPort*>(m_tester_ptr->getReadableCpuPort(index));
237
238 Request::Flags flags;
239
238
239 Request::Flags flags;
240
240 // 50% chance that the request will be an instruction fetch
241 if ((random() & 0x1) == 0) {
241 // If necessary, make the request an instruction fetch
242 if (port->type == RubyTester::CpuPort::InstOnly) {
242 flags.set(Request::INST_FETCH);
243 }
244
245 // Checks are sized depending on the number of bytes written
246 Request *req = new Request(m_address.getAddress(), CHECK_SIZE, flags,
247 m_tester_ptr->masterId(), curTick(), m_pc.getAddress());
248
249 req->setThreadContext(index, 0);
250 PacketPtr pkt = new Packet(req, MemCmd::ReadReq, port->idx);
251 uint8_t* dataArray = new uint8_t[CHECK_SIZE];
252 pkt->dataDynamicArray(dataArray);
253
254 // push the subblock onto the sender state. The sequencer will
255 // update the subblock on the return
256 pkt->senderState =
257 new SenderState(m_address, req->getSize(), pkt->senderState);
258
259 if (port->sendTiming(pkt)) {
260 DPRINTF(RubyTest, "initiating check - successful\n");
261 DPRINTF(RubyTest, "status before check update: %s\n",
262 TesterStatus_to_string(m_status).c_str());
263 m_status = TesterStatus_Check_Pending;
264 } else {
265 // If the packet did not issue, must delete
266 // Note: No need to delete the data, the packet destructor
267 // will delete it
268 SenderState* senderState = safe_cast<SenderState*>(pkt->senderState);
269 pkt->senderState = senderState->saved;
270 delete senderState;
271 delete pkt->req;
272 delete pkt;
273
274 DPRINTF(RubyTest, "failed to initiate check - cpu port not ready\n");
275 }
276
277 DPRINTF(RubyTest, "status after check update: %s\n",
278 TesterStatus_to_string(m_status).c_str());
279}
280
281void
282Check::performCallback(NodeID proc, SubBlock* data)
283{
284 Address address = data->getAddress();
285
286 // This isn't exactly right since we now have multi-byte checks
287 // assert(getAddress() == address);
288
289 assert(getAddress().getLineAddress() == address.getLineAddress());
290 assert(data != NULL);
291
292 DPRINTF(RubyTest, "RubyTester Callback\n");
293 debugPrint();
294
295 if (m_status == TesterStatus_Action_Pending) {
296 DPRINTF(RubyTest, "Action callback write value: %d, currently %d\n",
297 (m_value + m_store_count), data->getByte(0));
298 // Perform store one byte at a time
299 data->setByte(0, (m_value + m_store_count));
300 m_store_count++;
301 if (m_store_count == CHECK_SIZE) {
302 m_status = TesterStatus_Ready;
303 } else {
304 m_status = TesterStatus_Idle;
305 }
306 DPRINTF(RubyTest, "Action callback return data now %d\n",
307 data->getByte(0));
308 } else if (m_status == TesterStatus_Check_Pending) {
309 DPRINTF(RubyTest, "Check callback\n");
310 // Perform load/check
311 for (int byte_number=0; byte_number<CHECK_SIZE; byte_number++) {
312 if (uint8(m_value + byte_number) != data->getByte(byte_number)) {
313 panic("Action/check failure: proc: %d address: %s data: %s "
314 "byte_number: %d m_value+byte_number: %d byte: %d %s"
315 "Time: %d\n",
316 proc, address, data, byte_number,
317 (int)m_value + byte_number,
318 (int)data->getByte(byte_number), *this,
319 g_eventQueue_ptr->getTime());
320 }
321 }
322 DPRINTF(RubyTest, "Action/check success\n");
323 debugPrint();
324
325 // successful check complete, increment complete
326 m_tester_ptr->incrementCheckCompletions();
327
328 m_status = TesterStatus_Idle;
329 pickValue();
330
331 } else {
332 panic("Unexpected TesterStatus: %s proc: %d data: %s m_status: %s "
333 "time: %d\n",
334 *this, proc, data, m_status, g_eventQueue_ptr->getTime());
335 }
336
337 DPRINTF(RubyTest, "proc: %d, Address: 0x%x\n", proc,
338 getAddress().getLineAddress());
339 DPRINTF(RubyTest, "Callback done\n");
340 debugPrint();
341}
342
343void
344Check::changeAddress(const Address& address)
345{
346 assert(m_status == TesterStatus_Idle || m_status == TesterStatus_Ready);
347 m_status = TesterStatus_Idle;
348 m_address = address;
349 m_store_count = 0;
350}
351
352void
353Check::pickValue()
354{
355 assert(m_status == TesterStatus_Idle);
356 m_status = TesterStatus_Idle;
357 m_value = random() & 0xff; // One byte
358 m_store_count = 0;
359}
360
361void
362Check::pickInitiatingNode()
363{
364 assert(m_status == TesterStatus_Idle || m_status == TesterStatus_Ready);
365 m_status = TesterStatus_Idle;
243 flags.set(Request::INST_FETCH);
244 }
245
246 // Checks are sized depending on the number of bytes written
247 Request *req = new Request(m_address.getAddress(), CHECK_SIZE, flags,
248 m_tester_ptr->masterId(), curTick(), m_pc.getAddress());
249
250 req->setThreadContext(index, 0);
251 PacketPtr pkt = new Packet(req, MemCmd::ReadReq, port->idx);
252 uint8_t* dataArray = new uint8_t[CHECK_SIZE];
253 pkt->dataDynamicArray(dataArray);
254
255 // push the subblock onto the sender state. The sequencer will
256 // update the subblock on the return
257 pkt->senderState =
258 new SenderState(m_address, req->getSize(), pkt->senderState);
259
260 if (port->sendTiming(pkt)) {
261 DPRINTF(RubyTest, "initiating check - successful\n");
262 DPRINTF(RubyTest, "status before check update: %s\n",
263 TesterStatus_to_string(m_status).c_str());
264 m_status = TesterStatus_Check_Pending;
265 } else {
266 // If the packet did not issue, must delete
267 // Note: No need to delete the data, the packet destructor
268 // will delete it
269 SenderState* senderState = safe_cast<SenderState*>(pkt->senderState);
270 pkt->senderState = senderState->saved;
271 delete senderState;
272 delete pkt->req;
273 delete pkt;
274
275 DPRINTF(RubyTest, "failed to initiate check - cpu port not ready\n");
276 }
277
278 DPRINTF(RubyTest, "status after check update: %s\n",
279 TesterStatus_to_string(m_status).c_str());
280}
281
282void
283Check::performCallback(NodeID proc, SubBlock* data)
284{
285 Address address = data->getAddress();
286
287 // This isn't exactly right since we now have multi-byte checks
288 // assert(getAddress() == address);
289
290 assert(getAddress().getLineAddress() == address.getLineAddress());
291 assert(data != NULL);
292
293 DPRINTF(RubyTest, "RubyTester Callback\n");
294 debugPrint();
295
296 if (m_status == TesterStatus_Action_Pending) {
297 DPRINTF(RubyTest, "Action callback write value: %d, currently %d\n",
298 (m_value + m_store_count), data->getByte(0));
299 // Perform store one byte at a time
300 data->setByte(0, (m_value + m_store_count));
301 m_store_count++;
302 if (m_store_count == CHECK_SIZE) {
303 m_status = TesterStatus_Ready;
304 } else {
305 m_status = TesterStatus_Idle;
306 }
307 DPRINTF(RubyTest, "Action callback return data now %d\n",
308 data->getByte(0));
309 } else if (m_status == TesterStatus_Check_Pending) {
310 DPRINTF(RubyTest, "Check callback\n");
311 // Perform load/check
312 for (int byte_number=0; byte_number<CHECK_SIZE; byte_number++) {
313 if (uint8(m_value + byte_number) != data->getByte(byte_number)) {
314 panic("Action/check failure: proc: %d address: %s data: %s "
315 "byte_number: %d m_value+byte_number: %d byte: %d %s"
316 "Time: %d\n",
317 proc, address, data, byte_number,
318 (int)m_value + byte_number,
319 (int)data->getByte(byte_number), *this,
320 g_eventQueue_ptr->getTime());
321 }
322 }
323 DPRINTF(RubyTest, "Action/check success\n");
324 debugPrint();
325
326 // successful check complete, increment complete
327 m_tester_ptr->incrementCheckCompletions();
328
329 m_status = TesterStatus_Idle;
330 pickValue();
331
332 } else {
333 panic("Unexpected TesterStatus: %s proc: %d data: %s m_status: %s "
334 "time: %d\n",
335 *this, proc, data, m_status, g_eventQueue_ptr->getTime());
336 }
337
338 DPRINTF(RubyTest, "proc: %d, Address: 0x%x\n", proc,
339 getAddress().getLineAddress());
340 DPRINTF(RubyTest, "Callback done\n");
341 debugPrint();
342}
343
344void
345Check::changeAddress(const Address& address)
346{
347 assert(m_status == TesterStatus_Idle || m_status == TesterStatus_Ready);
348 m_status = TesterStatus_Idle;
349 m_address = address;
350 m_store_count = 0;
351}
352
353void
354Check::pickValue()
355{
356 assert(m_status == TesterStatus_Idle);
357 m_status = TesterStatus_Idle;
358 m_value = random() & 0xff; // One byte
359 m_store_count = 0;
360}
361
362void
363Check::pickInitiatingNode()
364{
365 assert(m_status == TesterStatus_Idle || m_status == TesterStatus_Ready);
366 m_status = TesterStatus_Idle;
366 m_initiatingNode = (random() % m_num_cpu_sequencers);
367 m_initiatingNode = (random() % m_num_writers);
367 DPRINTF(RubyTest, "picked initiating node %d\n", m_initiatingNode);
368 m_store_count = 0;
369}
370
371void
372Check::print(std::ostream& out) const
373{
374 out << "["
375 << m_address << ", value: "
376 << (int)m_value << ", status: "
377 << m_status << ", initiating node: "
378 << m_initiatingNode << ", store_count: "
379 << m_store_count
380 << "]" << std::flush;
381}
382
383void
384Check::debugPrint()
385{
386 DPRINTF(RubyTest,
387 "[%#x, value: %d, status: %s, initiating node: %d, store_count: %d]\n",
388 m_address.getAddress(), (int)m_value,
389 TesterStatus_to_string(m_status).c_str(),
390 m_initiatingNode, m_store_count);
391}
368 DPRINTF(RubyTest, "picked initiating node %d\n", m_initiatingNode);
369 m_store_count = 0;
370}
371
372void
373Check::print(std::ostream& out) const
374{
375 out << "["
376 << m_address << ", value: "
377 << (int)m_value << ", status: "
378 << m_status << ", initiating node: "
379 << m_initiatingNode << ", store_count: "
380 << m_store_count
381 << "]" << std::flush;
382}
383
384void
385Check::debugPrint()
386{
387 DPRINTF(RubyTest,
388 "[%#x, value: %d, status: %s, initiating node: %d, store_count: %d]\n",
389 m_address.getAddress(), (int)m_value,
390 TesterStatus_to_string(m_status).c_str(),
391 m_initiatingNode, m_store_count);
392}