memtest.cc (8232:b28d06a175be) memtest.cc (8436:5648986156db)
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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;

--- 132 unchanged lines hidden (view full) ---

141 percentFunctional(p->percent_functional),
142 percentUncacheable(p->percent_uncacheable),
143 issueDmas(p->issue_dmas),
144 progressInterval(p->progress_interval),
145 nextProgressMessage(p->progress_interval),
146 percentSourceUnaligned(p->percent_source_unaligned),
147 percentDestUnaligned(p->percent_dest_unaligned),
148 maxLoads(p->max_loads),
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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;

--- 132 unchanged lines hidden (view full) ---

141 percentFunctional(p->percent_functional),
142 percentUncacheable(p->percent_uncacheable),
143 issueDmas(p->issue_dmas),
144 progressInterval(p->progress_interval),
145 nextProgressMessage(p->progress_interval),
146 percentSourceUnaligned(p->percent_source_unaligned),
147 percentDestUnaligned(p->percent_dest_unaligned),
148 maxLoads(p->max_loads),
149 atomic(p->atomic)
149 atomic(p->atomic),
150 suppress_func_warnings(p->suppress_func_warnings)
150{
151 cachePort.snoopRangeSent = false;
152 funcPort.snoopRangeSent = true;
153
154 id = TESTER_ALLOCATOR++;
155
156 // Needs to be masked off once we know the block size.
157 traceBlockAddr = p->trace_addr;
158 baseAddr1 = 0x100000;
159 baseAddr2 = 0x400000;
160 uncacheAddr = 0x800000;
161
162 // set up counters
163 noResponseCycles = 0;
164 numReads = 0;
151{
152 cachePort.snoopRangeSent = false;
153 funcPort.snoopRangeSent = true;
154
155 id = TESTER_ALLOCATOR++;
156
157 // Needs to be masked off once we know the block size.
158 traceBlockAddr = p->trace_addr;
159 baseAddr1 = 0x100000;
160 baseAddr2 = 0x400000;
161 uncacheAddr = 0x800000;
162
163 // set up counters
164 noResponseCycles = 0;
165 numReads = 0;
166 numWrites = 0;
165 schedule(tickEvent, 0);
166
167 accessRetry = false;
168 dmaOutstanding = false;
169}
170
171Port *
172MemTest::getPort(const std::string &if_name, int idx)

--- 23 unchanged lines hidden (view full) ---

196MemTest::completeRequest(PacketPtr pkt)
197{
198 Request *req = pkt->req;
199
200 if (issueDmas) {
201 dmaOutstanding = false;
202 }
203
167 schedule(tickEvent, 0);
168
169 accessRetry = false;
170 dmaOutstanding = false;
171}
172
173Port *
174MemTest::getPort(const std::string &if_name, int idx)

--- 23 unchanged lines hidden (view full) ---

198MemTest::completeRequest(PacketPtr pkt)
199{
200 Request *req = pkt->req;
201
202 if (issueDmas) {
203 dmaOutstanding = false;
204 }
205
204 DPRINTF(MemTest, "completing %s at address %x (blk %x)\n",
206 DPRINTF(MemTest, "completing %s at address %x (blk %x) %s\n",
205 pkt->isWrite() ? "write" : "read",
207 pkt->isWrite() ? "write" : "read",
206 req->getPaddr(), blockAddr(req->getPaddr()));
208 req->getPaddr(), blockAddr(req->getPaddr()),
209 pkt->isError() ? "error" : "success");
207
208 MemTestSenderState *state =
209 dynamic_cast<MemTestSenderState *>(pkt->senderState);
210
211 uint8_t *data = state->data;
212 uint8_t *pkt_data = pkt->getPtr<uint8_t>();
213
214 //Remove the address from the list of outstanding
215 std::set<unsigned>::iterator removeAddr =
216 outstandingAddrs.find(req->getPaddr());
217 assert(removeAddr != outstandingAddrs.end());
218 outstandingAddrs.erase(removeAddr);
219
210
211 MemTestSenderState *state =
212 dynamic_cast<MemTestSenderState *>(pkt->senderState);
213
214 uint8_t *data = state->data;
215 uint8_t *pkt_data = pkt->getPtr<uint8_t>();
216
217 //Remove the address from the list of outstanding
218 std::set<unsigned>::iterator removeAddr =
219 outstandingAddrs.find(req->getPaddr());
220 assert(removeAddr != outstandingAddrs.end());
221 outstandingAddrs.erase(removeAddr);
222
220 if (pkt->isRead()) {
221 if (memcmp(pkt_data, data, pkt->getSize()) != 0) {
222 panic("%s: read of %x (blk %x) @ cycle %d "
223 "returns %x, expected %x\n", name(),
224 req->getPaddr(), blockAddr(req->getPaddr()), curTick(),
225 *pkt_data, *data);
223 if (pkt->isError()) {
224 if (!suppress_func_warnings) {
225 warn("Functional Access failed for %x at %x\n",
226 pkt->isWrite() ? "write" : "read", req->getPaddr());
226 }
227 }
228 } else {
229 if (pkt->isRead()) {
230 if (memcmp(pkt_data, data, pkt->getSize()) != 0) {
231 panic("%s: read of %x (blk %x) @ cycle %d "
232 "returns %x, expected %x\n", name(),
233 req->getPaddr(), blockAddr(req->getPaddr()), curTick(),
234 *pkt_data, *data);
235 }
227
236
228 numReads++;
229 numReadsStat++;
237 numReads++;
238 numReadsStat++;
230
239
231 if (numReads == (uint64_t)nextProgressMessage) {
232 ccprintf(cerr, "%s: completed %d read accesses @%d\n",
233 name(), numReads, curTick());
234 nextProgressMessage += progressInterval;
235 }
240 if (numReads == (uint64_t)nextProgressMessage) {
241 ccprintf(cerr, "%s: completed %d read, %d write accesses @%d\n",
242 name(), numReads, numWrites, curTick());
243 nextProgressMessage += progressInterval;
244 }
236
245
237 if (maxLoads != 0 && numReads >= maxLoads)
238 exitSimLoop("maximum number of loads reached");
239 } else {
240 assert(pkt->isWrite());
241 numWritesStat++;
246 if (maxLoads != 0 && numReads >= maxLoads)
247 exitSimLoop("maximum number of loads reached");
248 } else {
249 assert(pkt->isWrite());
250 funcPort.writeBlob(req->getPaddr(), pkt_data, req->getSize());
251 numWrites++;
252 numWritesStat++;
253 }
242 }
243
244 noResponseCycles = 0;
245 delete state;
246 delete [] data;
247 delete pkt->req;
248 delete pkt;
249}

--- 106 unchanged lines hidden (view full) ---

356
357 PacketPtr pkt = new Packet(req, MemCmd::ReadReq, Packet::Broadcast);
358 pkt->setSrc(0);
359 pkt->dataDynamicArray(new uint8_t[req->getSize()]);
360 MemTestSenderState *state = new MemTestSenderState(result);
361 pkt->senderState = state;
362
363 if (do_functional) {
254 }
255
256 noResponseCycles = 0;
257 delete state;
258 delete [] data;
259 delete pkt->req;
260 delete pkt;
261}

--- 106 unchanged lines hidden (view full) ---

368
369 PacketPtr pkt = new Packet(req, MemCmd::ReadReq, Packet::Broadcast);
370 pkt->setSrc(0);
371 pkt->dataDynamicArray(new uint8_t[req->getSize()]);
372 MemTestSenderState *state = new MemTestSenderState(result);
373 pkt->senderState = state;
374
375 if (do_functional) {
376 assert(pkt->needsResponse());
377 pkt->setSuppressFuncError();
364 cachePort.sendFunctional(pkt);
365 completeRequest(pkt);
366 } else {
367 sendPkt(pkt);
368 }
369 } else {
370 // write
371

--- 15 unchanged lines hidden (view full) ---

387 PacketPtr pkt = new Packet(req, MemCmd::WriteReq, Packet::Broadcast);
388 pkt->setSrc(0);
389 uint8_t *pkt_data = new uint8_t[req->getSize()];
390 pkt->dataDynamicArray(pkt_data);
391 memcpy(pkt_data, &data, req->getSize());
392 MemTestSenderState *state = new MemTestSenderState(result);
393 pkt->senderState = state;
394
378 cachePort.sendFunctional(pkt);
379 completeRequest(pkt);
380 } else {
381 sendPkt(pkt);
382 }
383 } else {
384 // write
385

--- 15 unchanged lines hidden (view full) ---

401 PacketPtr pkt = new Packet(req, MemCmd::WriteReq, Packet::Broadcast);
402 pkt->setSrc(0);
403 uint8_t *pkt_data = new uint8_t[req->getSize()];
404 pkt->dataDynamicArray(pkt_data);
405 memcpy(pkt_data, &data, req->getSize());
406 MemTestSenderState *state = new MemTestSenderState(result);
407 pkt->senderState = state;
408
395 funcPort.writeBlob(req->getPaddr(), pkt_data, req->getSize());
396
397 if (do_functional) {
409 if (do_functional) {
410 pkt->setSuppressFuncError();
398 cachePort.sendFunctional(pkt);
399 completeRequest(pkt);
400 } else {
401 sendPkt(pkt);
402 }
403 }
404}
405

--- 23 unchanged lines hidden ---
411 cachePort.sendFunctional(pkt);
412 completeRequest(pkt);
413 } else {
414 sendPkt(pkt);
415 }
416 }
417}
418

--- 23 unchanged lines hidden ---