RubyDirectedTester.cc revision 8975
17008Snate@binkert.org/* 27008Snate@binkert.org * Copyright (c) 2012 ARM Limited 37008Snate@binkert.org * All rights reserved 47008Snate@binkert.org * 57008Snate@binkert.org * The license below extends only to copyright in the software and shall 67008Snate@binkert.org * not be construed as granting a license to any other intellectual 77008Snate@binkert.org * property including but not limited to intellectual property relating 87008Snate@binkert.org * to a hardware implementation of the functionality of the software 97008Snate@binkert.org * licensed hereunder. You may use the software subject to the license 107008Snate@binkert.org * terms below provided that you ensure that this notice is replicated 117008Snate@binkert.org * unmodified and in its entirety in all distributions of the software, 127008Snate@binkert.org * modified or unmodified, in source code or in binary form. 137008Snate@binkert.org * 147008Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 157008Snate@binkert.org * Copyright (c) 2009-2010 Advanced Micro Devices, Inc. 167008Snate@binkert.org * All rights reserved. 177008Snate@binkert.org * 187008Snate@binkert.org * Redistribution and use in source and binary forms, with or without 197008Snate@binkert.org * modification, are permitted provided that the following conditions are 207008Snate@binkert.org * met: redistributions of source code must retain the above copyright 217008Snate@binkert.org * notice, this list of conditions and the following disclaimer; 227008Snate@binkert.org * redistributions in binary form must reproduce the above copyright 237008Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 247008Snate@binkert.org * documentation and/or other materials provided with the distribution; 257008Snate@binkert.org * neither the name of the copyright holders nor the names of its 267008Snate@binkert.org * contributors may be used to endorse or promote products derived from 277008Snate@binkert.org * this software without specific prior written permission. 286285Snate@binkert.org * 297039Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 307039Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 316285Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 327055Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 337055Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 346876Ssteve.reinhardt@amd.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 358341Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 369596Snilay@cs.wisc.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 376506Spdudnik@gmail.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 387055Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 398436SBrad.Beckmann@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 409497Snilay@cs.wisc.edu */ 416881SBrad.Beckmann@amd.com 428683Snilay@cs.wisc.edu#include "cpu/testers/directedtest/DirectedGenerator.hh" 439364Snilay@cs.wisc.edu#include "cpu/testers/directedtest/RubyDirectedTester.hh" 449364Snilay@cs.wisc.edu#include "debug/DirectedTest.hh" 457055Snate@binkert.org#include "mem/ruby/eventqueue/RubyEventQueue.hh" 469465Snilay@cs.wisc.edu#include "sim/sim_exit.hh" 476285Snate@binkert.org 486285Snate@binkert.orgRubyDirectedTester::RubyDirectedTester(const Params *p) 496285Snate@binkert.org : MemObject(p), directedStartEvent(this), 509465Snilay@cs.wisc.edu m_requests_to_complete(p->requests_to_complete), 517039Snate@binkert.org generator(p->generator) 527039Snate@binkert.org{ 536876Ssteve.reinhardt@amd.com m_requests_completed = 0; 548436SBrad.Beckmann@amd.com 559496Snilay@cs.wisc.edu // create the ports 568257SBrad.Beckmann@amd.com for (int i = 0; i < p->port_cpuPort_connection_count; ++i) { 577039Snate@binkert.org ports.push_back(new CpuPort(csprintf("%s-port%d", name(), i), 587039Snate@binkert.org this, i)); 597055Snate@binkert.org } 607055Snate@binkert.org 617055Snate@binkert.org // add the check start event to the event queue 627039Snate@binkert.org schedule(directedStartEvent, 1); 637039Snate@binkert.org} 647039Snate@binkert.org 658531Snilay@cs.wisc.eduRubyDirectedTester::~RubyDirectedTester() 668531Snilay@cs.wisc.edu{ 676285Snate@binkert.org for (int i = 0; i < ports.size(); i++) 687055Snate@binkert.org delete ports[i]; 697055Snate@binkert.org} 707039Snate@binkert.org 717055Snate@binkert.orgvoid 727039Snate@binkert.orgRubyDirectedTester::init() 738683Snilay@cs.wisc.edu{ 748683Snilay@cs.wisc.edu assert(ports.size() > 0); 759302Snilay@cs.wisc.edu generator->setDirectedTester(this); 769302Snilay@cs.wisc.edu} 779302Snilay@cs.wisc.edu 789302Snilay@cs.wisc.eduMasterPort & 799302Snilay@cs.wisc.eduRubyDirectedTester::getMasterPort(const std::string &if_name, int idx) 809302Snilay@cs.wisc.edu{ 819302Snilay@cs.wisc.edu if (if_name != "cpuPort") { 829302Snilay@cs.wisc.edu // pass it along to our super class 839302Snilay@cs.wisc.edu return MemObject::getMasterPort(if_name, idx); 849363Snilay@cs.wisc.edu } else { 859363Snilay@cs.wisc.edu if (idx >= static_cast<int>(ports.size())) { 869363Snilay@cs.wisc.edu panic("RubyDirectedTester::getMasterPort: unknown index %d\n", idx); 879363Snilay@cs.wisc.edu } 889364Snilay@cs.wisc.edu 899496Snilay@cs.wisc.edu return *ports[idx]; 909496Snilay@cs.wisc.edu } 919496Snilay@cs.wisc.edu} 929496Snilay@cs.wisc.edu 939496Snilay@cs.wisc.edubool 949496Snilay@cs.wisc.eduRubyDirectedTester::CpuPort::recvTimingResp(PacketPtr pkt) 959496Snilay@cs.wisc.edu{ 969497Snilay@cs.wisc.edu tester->hitCallback(id, pkt->getAddr()); 979497Snilay@cs.wisc.edu 989497Snilay@cs.wisc.edu // 999497Snilay@cs.wisc.edu // Now that the tester has completed, delete the packet, then return 1009595Snilay@cs.wisc.edu // 1019595Snilay@cs.wisc.edu delete pkt->req; 1029595Snilay@cs.wisc.edu delete pkt; 1039595Snilay@cs.wisc.edu return true; 1049595Snilay@cs.wisc.edu} 1059595Snilay@cs.wisc.edu 1069595Snilay@cs.wisc.eduMasterPort* 1079595Snilay@cs.wisc.eduRubyDirectedTester::getCpuPort(int idx) 1089496Snilay@cs.wisc.edu{ 1099496Snilay@cs.wisc.edu assert(idx >= 0 && idx < ports.size()); 1109496Snilay@cs.wisc.edu 1119497Snilay@cs.wisc.edu return ports[idx]; 1129507Snilay@cs.wisc.edu} 1139496Snilay@cs.wisc.edu 1149595Snilay@cs.wisc.eduvoid 1159595Snilay@cs.wisc.eduRubyDirectedTester::hitCallback(NodeID proc, Addr addr) 1169595Snilay@cs.wisc.edu{ 1179595Snilay@cs.wisc.edu DPRINTF(DirectedTest, 1189595Snilay@cs.wisc.edu "completed request for proc: %d addr: 0x%x\n", 1199596Snilay@cs.wisc.edu proc, 1209596Snilay@cs.wisc.edu addr); 1219596Snilay@cs.wisc.edu 1229596Snilay@cs.wisc.edu generator->performCallback(proc, addr); 1239596Snilay@cs.wisc.edu schedule(directedStartEvent, curTick()); 1249364Snilay@cs.wisc.edu} 1259364Snilay@cs.wisc.edu 1269364Snilay@cs.wisc.eduvoid 1279499Snilay@cs.wisc.eduRubyDirectedTester::wakeup() 1289364Snilay@cs.wisc.edu{ 1299364Snilay@cs.wisc.edu if (m_requests_completed < m_requests_to_complete) { 1309364Snilay@cs.wisc.edu if (!generator->initiate()) { 1319364Snilay@cs.wisc.edu schedule(directedStartEvent, curTick() + 1); 1329364Snilay@cs.wisc.edu } 1339364Snilay@cs.wisc.edu } else { 1349364Snilay@cs.wisc.edu exitSimLoop("Ruby DirectedTester completed"); 1359364Snilay@cs.wisc.edu } 1369364Snilay@cs.wisc.edu} 1379364Snilay@cs.wisc.edu 1389364Snilay@cs.wisc.eduRubyDirectedTester * 1399364Snilay@cs.wisc.eduRubyDirectedTesterParams::create() 1409496Snilay@cs.wisc.edu{ 1419595Snilay@cs.wisc.edu return new RubyDirectedTester(this); 1429595Snilay@cs.wisc.edu} 1439595Snilay@cs.wisc.edu