gem5  v21.1.0.2
trace_gen.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2017-2018 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed here under. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
44 #ifndef __CPU_TRAFFIC_GEN_TRACE_GEN_HH__
45 #define __CPU_TRAFFIC_GEN_TRACE_GEN_HH__
46 
47 #include "base/bitfield.hh"
48 #include "base/intmath.hh"
49 #include "base_gen.hh"
50 #include "mem/packet.hh"
51 #include "proto/protoio.hh"
52 
53 namespace gem5
54 {
55 
61 class TraceGen : public BaseGen
62 {
63 
64  private:
65 
69  struct TraceElement
70  {
71 
74 
77 
80 
83 
86 
92  bool isValid() const {
93  return cmd != MemCmd::InvalidCmd;
94  }
95 
99  void clear() {
101  }
102  };
103 
110  {
111 
112  private:
113 
116 
117  public:
118 
124  InputStream(const std::string& filename);
125 
130  void reset();
131 
136  void init();
137 
146  bool read(TraceElement& element);
147  };
148 
149  public:
150 
160  TraceGen(SimObject &obj, RequestorID requestor_id, Tick _duration,
161  const std::string& trace_file, Addr addr_offset)
162  : BaseGen(obj, requestor_id, _duration),
163  trace(trace_file),
164  tickOffset(0),
165  addrOffset(addr_offset),
166  traceComplete(false)
167  {
168  }
169 
170  void enter();
171 
173 
174  void exit();
175 
181  Tick nextPacketTick(bool elastic, Tick delay) const;
182 
183  private:
184 
187 
191 
197  mutable Tick tickOffset;
198 
204 
210 };
211 
212 } // namespace gem5
213 
214 #endif
gem5::TraceGen::TraceElement::blocksize
Addr blocksize
The size of the access for the request.
Definition: trace_gen.hh:79
gem5::TraceGen::tickOffset
Tick tickOffset
Stores the time when the state was entered.
Definition: trace_gen.hh:197
gem5::TraceGen::InputStream::init
void init()
Check the trace header to make sure that it is of the right format.
Definition: trace_gen.cc:59
gem5::TraceGen::TraceElement::clear
void clear()
Make this element invalid.
Definition: trace_gen.hh:99
gem5::TraceGen::nextElement
TraceElement nextElement
Definition: trace_gen.hh:190
gem5::TraceGen::TraceElement::isValid
bool isValid() const
Check validity of this element.
Definition: trace_gen.hh:92
gem5::TraceGen::InputStream::InputStream
InputStream(const std::string &filename)
Create a trace input stream for a given file name.
Definition: trace_gen.cc:52
gem5::TraceGen::TraceElement
This struct stores a line in the trace file.
Definition: trace_gen.hh:69
protoio.hh
gem5::TraceGen::nextPacketTick
Tick nextPacketTick(bool elastic, Tick delay) const
Returns the tick when the next request should be generated.
Definition: trace_gen.cc:96
gem5::TraceGen::traceComplete
bool traceComplete
Set to true when the trace replay for one instance of state is complete.
Definition: trace_gen.hh:209
gem5::TraceGen::addrOffset
Addr addrOffset
Offset for memory requests.
Definition: trace_gen.hh:203
gem5::Request::FlagsType
uint64_t FlagsType
Definition: request.hh:100
gem5::TraceGen::InputStream::trace
ProtoInputStream trace
Input file stream for the protobuf trace.
Definition: trace_gen.hh:115
packet.hh
gem5::TraceGen::trace
InputStream trace
Input stream used for reading the input trace file.
Definition: trace_gen.hh:186
gem5::MemCmd
Definition: packet.hh:75
gem5::TraceGen::exit
void exit()
Exit this generator state.
Definition: trace_gen.cc:168
gem5::TraceGen::InputStream::reset
void reset()
Reset the stream such that it can be played once again.
Definition: trace_gen.cc:72
gem5::TraceGen
The trace replay generator reads a trace file and plays back the transactions.
Definition: trace_gen.hh:61
gem5::TraceGen::getNextPacket
PacketPtr getNextPacket()
Get the next generated packet.
Definition: trace_gen.cc:132
bitfield.hh
gem5::TraceGen::InputStream
The InputStream encapsulates a trace file and the internal buffers and populates TraceElements based ...
Definition: trace_gen.hh:109
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::TraceGen::currElement
TraceElement currElement
Store the current and next element in the trace.
Definition: trace_gen.hh:189
gem5::TraceGen::TraceGen
TraceGen(SimObject &obj, RequestorID requestor_id, Tick _duration, const std::string &trace_file, Addr addr_offset)
Create a trace generator.
Definition: trace_gen.hh:160
gem5::TraceGen::TraceElement::cmd
MemCmd cmd
Specifies if the request is to be a read or a write.
Definition: trace_gen.hh:73
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::TraceGen::InputStream::read
bool read(TraceElement &element)
Attempt to read a trace element from the stream, and also notify the caller if the end of the file wa...
Definition: trace_gen.cc:79
gem5::TraceGen::enter
void enter()
Enter this generator state.
Definition: trace_gen.cc:119
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::TraceGen::TraceElement::tick
Tick tick
The time at which the request should be sent.
Definition: trace_gen.hh:82
gem5::TraceGen::TraceElement::flags
Request::FlagsType flags
Potential request flags to use.
Definition: trace_gen.hh:85
gem5::BaseGen
Base class for all generators, with the shared functionality and virtual functions for entering,...
Definition: base_gen.hh:64
gem5::TraceGen::TraceElement::addr
Addr addr
The address for the request.
Definition: trace_gen.hh:76
gem5::RequestorID
uint16_t RequestorID
Definition: request.hh:95
intmath.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::MemCmd::InvalidCmd
@ InvalidCmd
Definition: packet.hh:85
ProtoInputStream
A ProtoInputStream wraps a coded stream, potentially with decompression, based on looking at the file...
Definition: protoio.hh:140
base_gen.hh

Generated on Tue Sep 21 2021 12:25:09 for gem5 by doxygen 1.8.17