Deleted Added
sdiff udiff text old ( 10302:0e9e99e6369a ) new ( 10348:c91b23c72d5e )
full compact
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

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

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 "base/random.hh"
31#include "cpu/testers/rubytest/Check.hh"
32#include "debug/RubyTest.hh"
33#include "mem/ruby/common/SubBlock.hh"
34#include "mem/ruby/system/Sequencer.hh"
35#include "mem/ruby/system/System.hh"
36
37typedef RubyTester::SenderState SenderState;
38
39Check::Check(const Address& address, const Address& pc,
40 int _num_writers, int _num_readers, RubyTester* _tester)
41 : m_num_writers(_num_writers), m_num_readers(_num_readers),
42 m_tester_ptr(_tester)
43{
44 m_status = TesterStatus_Idle;
45
46 pickValue();
47 pickInitiatingNode();
48 changeAddress(address);
49 m_pc = pc;
50 m_access_mode = RubyAccessMode(random_mt.random(0,
51 RubyAccessMode_NUM - 1));
52 m_store_count = 0;
53}
54
55void
56Check::initiate()
57{
58 DPRINTF(RubyTest, "initiating\n");
59 debugPrint();
60
61 // currently no protocols support prefetches
62 if (false && (random_mt.random(0, 0xf) == 0)) {
63 initiatePrefetch(); // Prefetch from random processor
64 }
65
66 if (m_tester_ptr->getCheckFlush() && (random_mt.random(0, 0xff) == 0)) {
67 initiateFlush(); // issue a Flush request from random processor
68 }
69
70 if (m_status == TesterStatus_Idle) {
71 initiateAction();
72 } else if (m_status == TesterStatus_Ready) {
73 initiateCheck();
74 } else {
75 // Pending - do nothing
76 DPRINTF(RubyTest,
77 "initiating action/check - failed: action/check is pending\n");
78 }
79}
80
81void
82Check::initiatePrefetch()
83{
84 DPRINTF(RubyTest, "initiating prefetch\n");
85
86 int index = random_mt.random(0, m_num_readers - 1);
87 MasterPort* port = m_tester_ptr->getReadableCpuPort(index);
88
89 Request::Flags flags;
90 flags.set(Request::PREFETCH);
91
92 Packet::Command cmd;
93
94 // 1 in 8 chance this will be an exclusive prefetch
95 if (random_mt.random(0, 0x7) != 0) {
96 cmd = MemCmd::ReadReq;
97
98 // if necessary, make the request an instruction fetch
99 if (m_tester_ptr->isInstReadableCpuPort(index)) {
100 flags.set(Request::INST_FETCH);
101 }
102 } else {
103 cmd = MemCmd::WriteReq;

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

129}
130
131void
132Check::initiateFlush()
133{
134
135 DPRINTF(RubyTest, "initiating Flush\n");
136
137 int index = random_mt.random(0, m_num_writers - 1);
138 MasterPort* port = m_tester_ptr->getWritableCpuPort(index);
139
140 Request::Flags flags;
141
142 Request *req = new Request(m_address.getAddress(), CHECK_SIZE, flags,
143 m_tester_ptr->masterId(), curTick(), m_pc.getAddress());
144
145 Packet::Command cmd;

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

158}
159
160void
161Check::initiateAction()
162{
163 DPRINTF(RubyTest, "initiating Action\n");
164 assert(m_status == TesterStatus_Idle);
165
166 int index = random_mt.random(0, m_num_writers - 1);
167 MasterPort* port = m_tester_ptr->getWritableCpuPort(index);
168
169 Request::Flags flags;
170
171 // Create the particular address for the next byte to be written
172 Address writeAddr(m_address.getAddress() + m_store_count);
173
174 // Stores are assumed to be 1 byte-sized

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

219}
220
221void
222Check::initiateCheck()
223{
224 DPRINTF(RubyTest, "Initiating Check\n");
225 assert(m_status == TesterStatus_Ready);
226
227 int index = random_mt.random(0, m_num_readers - 1);
228 MasterPort* port = m_tester_ptr->getReadableCpuPort(index);
229
230 Request::Flags flags;
231
232 // If necessary, make the request an instruction fetch
233 if (m_tester_ptr->isInstReadableCpuPort(index)) {
234 flags.set(Request::INST_FETCH);
235 }

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

336 m_store_count = 0;
337}
338
339void
340Check::pickValue()
341{
342 assert(m_status == TesterStatus_Idle);
343 m_status = TesterStatus_Idle;
344 m_value = random_mt.random(0, 0xff); // One byte
345 m_store_count = 0;
346}
347
348void
349Check::pickInitiatingNode()
350{
351 assert(m_status == TesterStatus_Idle || m_status == TesterStatus_Ready);
352 m_status = TesterStatus_Idle;
353 m_initiatingNode = (random_mt.random(0, m_num_writers - 1));
354 DPRINTF(RubyTest, "picked initiating node %d\n", m_initiatingNode);
355 m_store_count = 0;
356}
357
358void
359Check::print(std::ostream& out) const
360{
361 out << "["

--- 17 unchanged lines hidden ---