2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009-2010 Advanced Micro Devices, Inc.
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.
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.
30 #include "cpu/testers/directedtest/DirectedGenerator.hh"
31 #include "cpu/testers/directedtest/RubyDirectedTester.hh"
32 #include "debug/DirectedTest.hh"
33 #include "mem/ruby/eventqueue/RubyEventQueue.hh"
34 #include "sim/sim_exit.hh"
36 RubyDirectedTester::RubyDirectedTester(const Params
*p
)
37 : MemObject(p
), directedStartEvent(this),
38 m_requests_to_complete(p
->requests_to_complete
),
39 generator(p
->generator
)
41 m_requests_completed
= 0;
43 // add the check start event to the event queue
44 schedule(directedStartEvent
, 1);
47 RubyDirectedTester::~RubyDirectedTester()
49 for (int i
= 0; i
< ports
.size(); i
++)
54 RubyDirectedTester::init()
56 assert(ports
.size() > 0);
57 generator
->setDirectedTester(this);
61 RubyDirectedTester::getPort(const std::string
&if_name
, int idx
)
63 if (if_name
!= "cpuPort") {
64 panic("RubyDirectedTester::getPort: unknown port %s requested", if_name
);
67 if (idx
>= (int)ports
.size()) {
68 ports
.resize(idx
+ 1);
71 if (ports
[idx
] != NULL
) {
72 panic("RubyDirectedTester::getPort: port %d already assigned", idx
);
75 CpuPort
*port
= new CpuPort(csprintf("%s-port%d", name(), idx
), this, idx
);
82 RubyDirectedTester::CpuPort::recvAtomic(PacketPtr pkt
)
84 panic("RubyDirectedTester::CpuPort::recvAtomic() not implemented!\n");
89 RubyDirectedTester::CpuPort::recvTiming(PacketPtr pkt
)
91 tester
->hitCallback(idx
, pkt
->getAddr());
94 // Now that the tester has completed, delete the packet, then return
102 RubyDirectedTester::getCpuPort(int idx
)
104 assert(idx
>= 0 && idx
< ports
.size());
110 RubyDirectedTester::hitCallback(NodeID proc
, Addr addr
)
112 DPRINTF(DirectedTest
,
113 "completed request for proc: %d addr: 0x%x\n",
117 generator
->performCallback(proc
, addr
);
118 schedule(directedStartEvent
, curTick());
122 RubyDirectedTester::wakeup()
124 if (m_requests_completed
< m_requests_to_complete
) {
125 if (!generator
->initiate()) {
126 schedule(directedStartEvent
, curTick() + 1);
129 exitSimLoop("Ruby DirectedTester completed");
134 RubyDirectedTesterParams::create()
136 return new RubyDirectedTester(this);