gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Thomas Grass
38  * Andreas Hansson
39  * Sascha Bischoff
40  * Neha Agarwal
41  */
42 
49 #ifndef __CPU_TRAFFIC_GEN_TRACE_GEN_HH__
50 #define __CPU_TRAFFIC_GEN_TRACE_GEN_HH__
51 
52 #include "base/bitfield.hh"
53 #include "base/intmath.hh"
54 #include "base_gen.hh"
55 #include "mem/packet.hh"
56 #include "proto/protoio.hh"
57 
63 class TraceGen : public BaseGen
64 {
65 
66  private:
67 
71  struct TraceElement {
72 
75 
78 
81 
84 
87 
93  bool isValid() const {
94  return cmd != MemCmd::InvalidCmd;
95  }
96 
100  void clear() {
101  cmd = MemCmd::InvalidCmd;
102  }
103  };
104 
111  {
112 
113  private:
114 
117 
118  public:
119 
125  InputStream(const std::string& filename);
126 
131  void reset();
132 
137  void init();
138 
147  bool read(TraceElement& element);
148  };
149 
150  public:
151 
161  TraceGen(SimObject &obj, MasterID master_id, Tick _duration,
162  const std::string& trace_file, Addr addr_offset)
163  : BaseGen(obj, master_id, _duration),
164  trace(trace_file),
165  tickOffset(0),
166  addrOffset(addr_offset),
167  traceComplete(false)
168  {
169  }
170 
171  void enter();
172 
174 
175  void exit();
176 
182  Tick nextPacketTick(bool elastic, Tick delay) const;
183 
184  private:
185 
188 
192 
198  mutable Tick tickOffset;
199 
205 
211 };
212 
213 #endif
TraceGen(SimObject &obj, MasterID master_id, Tick _duration, const std::string &trace_file, Addr addr_offset)
Create a trace generator.
Definition: trace_gen.hh:161
bool traceComplete
Set to true when the trace replay for one instance of state is complete.
Definition: trace_gen.hh:210
Definition: packet.hh:76
bool isValid() const
Check validity of this element.
Definition: trace_gen.hh:93
PacketPtr getNextPacket()
Get the next generated packet.
Definition: trace_gen.cc:132
void clear()
Make this element invalid.
Definition: trace_gen.hh:100
Tick tick
The time at which the request should be sent.
Definition: trace_gen.hh:83
void reset()
Definition: statistics.cc:570
Tick nextPacketTick(bool elastic, Tick delay) const
Returns the tick when the next request should be generated.
Definition: trace_gen.cc:96
TraceElement currElement
Store the current and next element in the trace.
Definition: trace_gen.hh:190
MemCmd cmd
Specifies if the request is to be a read or a write.
Definition: trace_gen.hh:74
void enter()
Enter this generator state.
Definition: trace_gen.cc:119
The trace replay generator reads a trace file and plays back the transactions.
Definition: trace_gen.hh:63
void exit()
Exit this generator state.
Definition: trace_gen.cc:168
This struct stores a line in the trace file.
Definition: trace_gen.hh:71
uint64_t Tick
Tick count type.
Definition: types.hh:63
A ProtoInputStream wraps a coded stream, potentially with decompression, based on looking at the file...
Definition: protoio.hh:142
Request::FlagsType flags
Potential request flags to use.
Definition: trace_gen.hh:86
Declaration of the base generator class for all generators.
The InputStream encapsulates a trace file and the internal buffers and populates TraceElements based ...
Definition: trace_gen.hh:110
Addr blocksize
The size of the access for the request.
Definition: trace_gen.hh:80
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
uint16_t MasterID
Definition: request.hh:86
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
InputStream trace
Input stream used for reading the input trace file.
Definition: trace_gen.hh:187
Addr addrOffset
Offset for memory requests.
Definition: trace_gen.hh:204
ProtoInputStream trace
Input file stream for the protobuf trace.
Definition: trace_gen.hh:116
Addr addr
The address for the request.
Definition: trace_gen.hh:77
TraceElement nextElement
Definition: trace_gen.hh:191
Declaration of the Packet class.
Tick tickOffset
Stores the time when the state was entered.
Definition: trace_gen.hh:198
uint64_t FlagsType
Definition: request.hh:91
Base class for all generators, with the shared functionality and virtual functions for entering...
Definition: base_gen.hh:62
Abstract superclass for simulation objects.
Definition: sim_object.hh:96
const FlagsType init
This Stat is Initialized.
Definition: info.hh:47
Declaration of a wrapper for protobuf output streams and input streams.

Generated on Fri Feb 28 2020 16:27:00 for gem5 by doxygen 1.8.13