gem5  v22.1.0.0
SeriesRequestGenerator.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3  * Copyright (c) 2009-2010 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
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.
16  *
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.
28  */
29 
31 
32 #include "base/random.hh"
33 #include "base/trace.hh"
36 #include "debug/DirectedTest.hh"
37 
38 namespace gem5
39 {
40 
43  m_addr_increment_size(p.addr_increment_size),
44  m_percent_writes(p.percent_writes)
45 {
46  m_status = ruby::SeriesRequestGeneratorStatus_Thinking;
47  m_active_node = 0;
48  m_address = 0x0;
49 }
50 
52 {
53 }
54 
55 bool
57 {
58  DPRINTF(DirectedTest, "initiating request\n");
59  assert(m_status == ruby::SeriesRequestGeneratorStatus_Thinking);
60 
62 
64 
65  // For simplicity, requests are assumed to be 1 byte-sized
66  RequestPtr req = std::make_shared<Request>(m_address, 1, flags,
67  requestorId);
68 
69  Packet::Command cmd;
70  bool do_write = (random_mt.random(0, 100) < m_percent_writes);
71  if (do_write) {
72  cmd = MemCmd::WriteReq;
73  } else {
74  cmd = MemCmd::ReadReq;
75  }
76 
77  PacketPtr pkt = new Packet(req, cmd);
78  pkt->allocate();
79 
80  if (port->sendTimingReq(pkt)) {
81  DPRINTF(DirectedTest, "initiating request - successful\n");
82  m_status = ruby::SeriesRequestGeneratorStatus_Request_Pending;
83  return true;
84  } else {
85  // If the packet did not issue, must delete
86  // Note: No need to delete the data, the packet destructor
87  // will delete it
88  delete pkt;
89 
90  DPRINTF(DirectedTest, "failed to initiate request - sequencer not ready\n");
91  return false;
92  }
93 }
94 
95 void
97 {
98  assert(m_active_node == proc);
99  assert(m_address == address);
100  assert(m_status == ruby::SeriesRequestGeneratorStatus_Request_Pending);
101 
102  m_status = ruby::SeriesRequestGeneratorStatus_Thinking;
103  m_active_node++;
104  if (m_active_node == m_num_cpus) {
105  //
106  // Cycle of requests completed, increment cycle completions and restart
107  // at cpu zero
108  //
111  m_active_node = 0;
112  }
113 }
114 
115 } // namespace gem5
#define DPRINTF(x,...)
Definition: trace.hh:186
RubyDirectedTester * m_directed_tester
DirectedGeneratorParams Params
Command
List of all commands associated with a packet.
Definition: packet.hh:84
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
void allocate()
Allocate memory for the packet.
Definition: packet.hh:1354
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:79
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
Definition: port.hh:495
RequestPort * getCpuPort(int idx)
ruby::SeriesRequestGeneratorStatus m_status
void performCallback(uint32_t proc, Addr address)
Random random_mt
Definition: random.cc:99
std::enable_if_t< std::is_integral_v< T >, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
Definition: random.hh:90
uint8_t flags
Definition: helpers.cc:66
Bitfield< 54 > p
Definition: pagetable.hh:70
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:109
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1