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 --- 80 unchanged lines hidden (view full) --- 89 90 Packet::Command cmd; 91 92 // 1 in 8 chance this will be an exclusive prefetch 93 if (random_mt.random(0, 0x7) != 0) { 94 cmd = MemCmd::ReadReq; 95 96 // if necessary, make the request an instruction fetch |
97 if (m_tester_ptr->isInstOnlyCpuPort(index) || 98 (m_tester_ptr->isInstDataCpuPort(index) && 99 (random_mt.random(0, 0x1)))) { |
100 flags.set(Request::INST_FETCH); 101 } 102 } else { 103 cmd = MemCmd::WriteReq; 104 flags.set(Request::PF_EXCLUSIVE); 105 } 106 107 // Prefetches are assumed to be 0 sized --- 82 unchanged lines hidden (view full) --- 190 cmd = MemCmd::WriteReq; 191 // } 192 193 PacketPtr pkt = new Packet(req, cmd); 194 uint8_t *writeData = new uint8_t[1]; 195 *writeData = m_value + m_store_count; 196 pkt->dataDynamic(writeData); 197 |
198 DPRINTF(RubyTest, "Seq write: index %d data 0x%x check 0x%x\n", index, |
199 *(pkt->getConstPtr<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 = new SenderState(writeAddr, req->getSize()); 204 205 if (port->sendTimingReq(pkt)) { 206 DPRINTF(RubyTest, "initiating action - successful\n"); 207 DPRINTF(RubyTest, "status before action update: %s\n", 208 (TesterStatus_to_string(m_status)).c_str()); 209 m_status = TesterStatus_Action_Pending; |
210 DPRINTF(RubyTest, "Check %s, State=Action_Pending\n", m_address); |
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 delete pkt->senderState; 216 delete pkt->req; 217 delete pkt; 218 --- 11 unchanged lines hidden (view full) --- 230 assert(m_status == TesterStatus_Ready); 231 232 int index = random_mt.random(0, m_num_readers - 1); 233 MasterPort* port = m_tester_ptr->getReadableCpuPort(index); 234 235 Request::Flags flags; 236 237 // If necessary, make the request an instruction fetch |
238 if (m_tester_ptr->isInstOnlyCpuPort(index) || 239 (m_tester_ptr->isInstDataCpuPort(index) && 240 (random_mt.random(0, 0x1)))) { |
241 flags.set(Request::INST_FETCH); 242 } 243 244 // Checks are sized depending on the number of bytes written 245 Request *req = new Request(m_address, CHECK_SIZE, flags, 246 m_tester_ptr->masterId(), curTick(), m_pc); 247 248 req->setThreadContext(index, 0); 249 PacketPtr pkt = new Packet(req, MemCmd::ReadReq); 250 uint8_t *dataArray = new uint8_t[CHECK_SIZE]; 251 pkt->dataDynamic(dataArray); 252 |
253 DPRINTF(RubyTest, "Seq read: index %d\n", index); 254 |
255 // push the subblock onto the sender state. The sequencer will 256 // update the subblock on the return 257 pkt->senderState = new SenderState(m_address, req->getSize()); 258 259 if (port->sendTimingReq(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 DPRINTF(RubyTest, "Check %s, State=Check_Pending\n", m_address); |
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 delete pkt->senderState; 270 delete pkt->req; 271 delete pkt; 272 --- 21 unchanged lines hidden (view full) --- 294 if (m_status == TesterStatus_Action_Pending) { 295 DPRINTF(RubyTest, "Action callback write value: %d, currently %d\n", 296 (m_value + m_store_count), data->getByte(0)); 297 // Perform store one byte at a time 298 data->setByte(0, (m_value + m_store_count)); 299 m_store_count++; 300 if (m_store_count == CHECK_SIZE) { 301 m_status = TesterStatus_Ready; |
302 DPRINTF(RubyTest, "Check %s, State=Ready\n", m_address); |
303 } else { 304 m_status = TesterStatus_Idle; |
305 DPRINTF(RubyTest, "Check %s, State=Idle store_count: %d\n", 306 m_address, m_store_count); |
307 } 308 DPRINTF(RubyTest, "Action callback return data now %d\n", 309 data->getByte(0)); 310 } else if (m_status == TesterStatus_Check_Pending) { 311 DPRINTF(RubyTest, "Check callback\n"); 312 // Perform load/check 313 for (int byte_number=0; byte_number<CHECK_SIZE; byte_number++) { 314 if (uint8_t(m_value + byte_number) != data->getByte(byte_number)) { --- 7 unchanged lines hidden (view full) --- 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 DPRINTF(RubyTest, "Check %s, State=Idle\n", m_address); |
331 pickValue(); 332 333 } else { 334 panic("Unexpected TesterStatus: %s proc: %d data: %s m_status: %s " 335 "time: %d\n", *this, proc, data, m_status, curTime); 336 } 337 338 DPRINTF(RubyTest, "proc: %d, Address: 0x%x\n", proc, 339 makeLineAddress(m_address)); 340 DPRINTF(RubyTest, "Callback done\n"); 341 debugPrint(); 342} 343 344void 345Check::changeAddress(Addr address) 346{ 347 assert(m_status == TesterStatus_Idle || m_status == TesterStatus_Ready); 348 m_status = TesterStatus_Idle; 349 m_address = address; |
350 DPRINTF(RubyTest, "Check %s, State=Idle\n", m_address); |
351 m_store_count = 0; 352} 353 354void 355Check::pickValue() 356{ 357 assert(m_status == TesterStatus_Idle); |
358 m_value = random_mt.random(0, 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; 367 m_initiatingNode = (random_mt.random(0, m_num_writers - 1)); |
368 DPRINTF(RubyTest, "Check %s, State=Idle, picked initiating node %d\n", 369 m_address, m_initiatingNode); |
370 m_store_count = 0; 371} 372 373void 374Check::print(std::ostream& out) const 375{ 376 out << "[" 377 << m_address << ", value: " --- 15 unchanged lines hidden --- |