gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
generators.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013 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 hereunder. 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 
50 #ifndef __CPU_TRAFFIC_GEN_GENERATORS_HH__
51 #define __CPU_TRAFFIC_GEN_GENERATORS_HH__
52 
53 #include "base/bitfield.hh"
54 #include "base/intmath.hh"
55 #include "mem/packet.hh"
56 #include "proto/protoio.hh"
57 
63 class BaseGen
64 {
65 
66  protected:
67 
69  const std::string _name;
70 
73 
82  PacketPtr getPacket(Addr addr, unsigned size, const MemCmd& cmd,
83  Request::FlagsType flags = 0);
84 
85  public:
86 
88  const Tick duration;
89 
97  BaseGen(const std::string& _name, MasterID master_id, Tick _duration);
98 
99  virtual ~BaseGen() { }
100 
106  std::string name() const { return _name; }
107 
111  virtual void enter() = 0;
112 
118  virtual PacketPtr getNextPacket() = 0;
119 
123  virtual void exit() { };
124 
134  virtual Tick nextPacketTick(bool elastic, Tick delay) const = 0;
135 
136 };
137 
141 class IdleGen : public BaseGen
142 {
143 
144  public:
145 
146  IdleGen(const std::string& _name, MasterID master_id, Tick _duration)
147  : BaseGen(_name, master_id, _duration)
148  { }
149 
150  void enter() { }
151 
152  PacketPtr getNextPacket() { return NULL; }
153 
154  Tick nextPacketTick(bool elastic, Tick delay) const { return MaxTick; }
155 };
156 
164 class LinearGen : public BaseGen
165 {
166 
167  public:
168 
185  LinearGen(const std::string& _name, MasterID master_id, Tick _duration,
186  Addr start_addr, Addr end_addr, Addr _blocksize,
187  Tick min_period, Tick max_period,
188  uint8_t read_percent, Addr data_limit)
189  : BaseGen(_name, master_id, _duration),
190  startAddr(start_addr), endAddr(end_addr),
191  blocksize(_blocksize), minPeriod(min_period),
192  maxPeriod(max_period), readPercent(read_percent),
193  dataLimit(data_limit), nextAddr(startAddr), dataManipulated(0)
194  { }
195 
196  void enter();
197 
199 
200  Tick nextPacketTick(bool elastic, Tick delay) const;
201 
202  private:
203 
206 
208  const Addr endAddr;
209 
212 
216 
220  const uint8_t readPercent;
221 
224 
227 
234 };
235 
241 class RandomGen : public BaseGen
242 {
243 
244  public:
245 
262  RandomGen(const std::string& _name, MasterID master_id, Tick _duration,
263  Addr start_addr, Addr end_addr, Addr _blocksize,
264  Tick min_period, Tick max_period,
265  uint8_t read_percent, Addr data_limit)
266  : BaseGen(_name, master_id, _duration),
267  startAddr(start_addr), endAddr(end_addr),
268  blocksize(_blocksize), minPeriod(min_period),
269  maxPeriod(max_period), readPercent(read_percent),
270  dataLimit(data_limit), dataManipulated(0)
271  { }
272 
273  void enter();
274 
276 
277  Tick nextPacketTick(bool elastic, Tick delay) const;
278 
279  protected:
280 
283 
285  const Addr endAddr;
286 
289 
293 
297  const uint8_t readPercent;
298 
301 
308 };
309 
315 class DramGen : public RandomGen
316 {
317 
318  public:
319 
342  DramGen(const std::string& _name, MasterID master_id, Tick _duration,
343  Addr start_addr, Addr end_addr, Addr _blocksize,
344  Tick min_period, Tick max_period,
345  uint8_t read_percent, Addr data_limit,
346  unsigned int num_seq_pkts, unsigned int page_size,
347  unsigned int nbr_of_banks_DRAM, unsigned int nbr_of_banks_util,
348  unsigned int addr_mapping,
349  unsigned int nbr_of_ranks)
350  : RandomGen(_name, master_id, _duration, start_addr, end_addr,
351  _blocksize, min_period, max_period, read_percent, data_limit),
352  numSeqPkts(num_seq_pkts), countNumSeqPkts(0), addr(0),
353  isRead(true), pageSize(page_size),
354  pageBits(floorLog2(page_size / _blocksize)),
355  bankBits(floorLog2(nbr_of_banks_DRAM)),
356  blockBits(floorLog2(_blocksize)),
357  nbrOfBanksDRAM(nbr_of_banks_DRAM),
358  nbrOfBanksUtil(nbr_of_banks_util), addrMapping(addr_mapping),
359  rankBits(floorLog2(nbr_of_ranks)),
360  nbrOfRanks(nbr_of_ranks)
361  {
362  if (addrMapping != 1 && addrMapping != 0) {
363  addrMapping = 1;
364  warn("Unknown address mapping specified, using RoRaBaCoCh\n");
365  }
366  }
367 
369 
376  void genStartAddr(unsigned int new_bank , unsigned int new_rank);
377 
378  protected:
379 
381  const unsigned int numSeqPkts;
382 
384  unsigned int countNumSeqPkts;
385 
388 
390  bool isRead;
391 
393  const unsigned int pageSize;
394 
396  const unsigned int pageBits;
397 
399  const unsigned int bankBits;
400 
402  const unsigned int blockBits;
403 
405  const unsigned int nbrOfBanksDRAM;
406 
408  const unsigned int nbrOfBanksUtil;
409 
411  unsigned int addrMapping;
412 
414  const unsigned int rankBits;
415 
417  const unsigned int nbrOfRanks;
418 
419 };
420 
421 class DramRotGen : public DramGen
422 {
423 
424  public:
425 
453  DramRotGen(const std::string& _name, MasterID master_id, Tick _duration,
454  Addr start_addr, Addr end_addr, Addr _blocksize,
455  Tick min_period, Tick max_period,
456  uint8_t read_percent, Addr data_limit,
457  unsigned int num_seq_pkts, unsigned int page_size,
458  unsigned int nbr_of_banks_DRAM, unsigned int nbr_of_banks_util,
459  unsigned int addr_mapping,
460  unsigned int nbr_of_ranks,
461  unsigned int max_seq_count_per_rank)
462  : DramGen(_name, master_id, _duration, start_addr, end_addr,
463  _blocksize, min_period, max_period, read_percent, data_limit,
464  num_seq_pkts, page_size, nbr_of_banks_DRAM,
465  nbr_of_banks_util, addr_mapping,
466  nbr_of_ranks),
467  maxSeqCountPerRank(max_seq_count_per_rank),
468  nextSeqCount(0)
469  {
470  // Rotating traffic generation can only support a read
471  // percentage of 0, 50, or 100
472  if (readPercent != 50 && readPercent != 100 && readPercent != 0) {
473  fatal("%s: Unsupported read percentage for DramRotGen: %d",
474  _name, readPercent);
475  }
476  }
477 
479 
480  private:
484  const unsigned int maxSeqCountPerRank;
485 
489  unsigned int nextSeqCount;
490 };
491 
497 class TraceGen : public BaseGen
498 {
499 
500  private:
501 
505  struct TraceElement {
506 
509 
512 
515 
518 
521 
527  bool isValid() const {
528  return cmd != MemCmd::InvalidCmd;
529  }
530 
534  void clear() {
536  }
537  };
538 
545  {
546 
547  private:
548 
551 
552  public:
553 
559  InputStream(const std::string& filename);
560 
565  void reset();
566 
571  void init();
572 
581  bool read(TraceElement& element);
582  };
583 
584  public:
585 
595  TraceGen(const std::string& _name, MasterID master_id, Tick _duration,
596  const std::string& trace_file, Addr addr_offset)
597  : BaseGen(_name, master_id, _duration),
598  trace(trace_file),
599  tickOffset(0),
600  addrOffset(addr_offset),
601  traceComplete(false)
602  {
603  }
604 
605  void enter();
606 
608 
609  void exit();
610 
616  Tick nextPacketTick(bool elastic, Tick delay) const;
617 
618  private:
619 
622 
626 
632  mutable Tick tickOffset;
633 
639 
645 };
646 
647 #endif
const Tick duration
Time to spend in this state.
Definition: generators.hh:88
const Tick maxPeriod
Definition: generators.hh:215
const Addr blocksize
Block size.
Definition: generators.hh:288
const Tick maxPeriod
Definition: generators.hh:292
bool traceComplete
Set to true when the trace replay for one instance of state is complete.
Definition: generators.hh:644
const unsigned int numSeqPkts
Number of sequential DRAM packets to be generated per cpu request.
Definition: generators.hh:381
void init()
Check the trace header to make sure that it is of the right format.
Definition: generators.cc:419
RandomGen(const std::string &_name, MasterID master_id, Tick _duration, Addr start_addr, Addr end_addr, Addr _blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit)
Create a random address sequence generator.
Definition: generators.hh:262
std::string name() const
Get the name, useful for DPRINTFs.
Definition: generators.hh:106
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: generators.cc:439
void enter()
Enter this generator state.
Definition: generators.hh:150
Definition: packet.hh:73
BaseGen(const std::string &_name, MasterID master_id, Tick _duration)
Create a base generator.
Definition: generators.cc:51
virtual void enter()=0
Enter this generator state.
const Tick minPeriod
Request generation period.
Definition: generators.hh:214
const Tick minPeriod
Request generation period.
Definition: generators.hh:291
uint32_t FlagsType
Definition: request.hh:90
The linear generator generates sequential requests from a start to an end address, with a fixed block size.
Definition: generators.hh:164
void enter()
Enter this generator state.
Definition: generators.cc:149
void genStartAddr(unsigned int new_bank, unsigned int new_rank)
Insert bank, rank, and column bits into packed address to create address for 1st command in a series...
Definition: generators.cc:334
PacketPtr getPacket(Addr addr, unsigned size, const MemCmd &cmd, Request::FlagsType flags=0)
Generate a new request and associated packet.
Definition: generators.cc:57
PacketPtr getNextPacket()
Get the next generated packet.
Definition: generators.cc:492
virtual PacketPtr getNextPacket()=0
Get the next generated packet.
unsigned int countNumSeqPkts
Track number of sequential packets generated for a request.
Definition: generators.hh:384
ip6_addr_t addr
Definition: inet.hh:335
const unsigned int nbrOfBanksDRAM
Number of banks in DRAM.
Definition: generators.hh:405
void clear()
Make this element invalid.
Definition: generators.hh:534
Tick tick
The time at which the request should be sent.
Definition: generators.hh:517
bool isRead
Remember type of requests to be generated in series.
Definition: generators.hh:390
const Addr endAddr
End of address range.
Definition: generators.hh:208
InputStream(const std::string &filename)
Create a trace input stream for a given file name.
Definition: generators.cc:412
virtual void exit()
Exit this generator state.
Definition: generators.hh:123
DramRotGen(const std::string &_name, MasterID master_id, Tick _duration, Addr start_addr, Addr end_addr, Addr _blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit, unsigned int num_seq_pkts, unsigned int page_size, unsigned int nbr_of_banks_DRAM, unsigned int nbr_of_banks_util, unsigned int addr_mapping, unsigned int nbr_of_ranks, unsigned int max_seq_count_per_rank)
Create a DRAM address sequence generator.
Definition: generators.hh:453
PacketPtr getNextPacket()
Get the next generated packet.
Definition: generators.cc:156
const unsigned int bankBits
Number of bank bits in DRAM address.
Definition: generators.hh:399
const Addr startAddr
Start of address range.
Definition: generators.hh:205
unsigned int addrMapping
Address mapping to be used.
Definition: generators.hh:411
const uint8_t readPercent
Percent of generated transactions that should be reads.
Definition: generators.hh:297
Tick nextPacketTick(bool elastic, Tick delay) const
Determine the tick when the next packet is available.
Definition: generators.cc:121
Tick nextPacketTick(bool elastic, Tick delay) const
Determine the tick when the next packet is available.
Definition: generators.hh:154
const Addr dataLimit
Maximum amount of data to manipulate.
Definition: generators.hh:223
unsigned int nextSeqCount
Next packet series count used to set rank and bank, and update isRead Incremented at the start of a n...
Definition: generators.hh:489
TraceElement currElement
Store the current and next element in the trace.
Definition: generators.hh:624
MemCmd cmd
Specifies if the request is to be a read or a write.
Definition: generators.hh:508
PacketPtr getNextPacket()
Get the next generated packet.
Definition: generators.cc:247
#define warn(...)
Definition: misc.hh:219
void enter()
Enter this generator state.
Definition: generators.cc:479
const MasterID masterID
The MasterID used for generating requests.
Definition: generators.hh:72
const Addr dataLimit
Maximum amount of data to manipulate.
Definition: generators.hh:300
IdleGen(const std::string &_name, MasterID master_id, Tick _duration)
Definition: generators.hh:146
The idle generator does nothing.
Definition: generators.hh:141
The trace replay generator reads a trace file and plays back the transactions.
Definition: generators.hh:497
const Tick MaxTick
Definition: types.hh:65
virtual Tick nextPacketTick(bool elastic, Tick delay) const =0
Determine the tick when the next packet is available.
Addr nextAddr
Address of next request.
Definition: generators.hh:226
const Addr blocksize
Blocksize and address increment.
Definition: generators.hh:211
void exit()
Exit this generator state.
Definition: generators.cc:528
const unsigned int blockBits
Number of block bits in DRAM address.
Definition: generators.hh:402
This struct stores a line in the trace file.
Definition: generators.hh:505
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: generators.hh:520
const unsigned int nbrOfBanksUtil
Number of banks to be utilized for a given configuration.
Definition: generators.hh:408
Tick nextPacketTick(bool elastic, Tick delay) const
Returns the tick when the next request should be generated.
Definition: generators.cc:456
#define fatal(...)
Definition: misc.hh:163
DRAM specific generator is for issuing request with variable page hit length and bank utilization...
Definition: generators.hh:315
The InputStream encapsulates a trace file and the internal buffers and populates TraceElements based ...
Definition: generators.hh:544
virtual ~BaseGen()
Definition: generators.hh:99
void enter()
Enter this generator state.
Definition: generators.cc:80
const unsigned int pageBits
Number of page bits in DRAM address.
Definition: generators.hh:396
Addr blocksize
The size of the access for the request.
Definition: generators.hh:514
Tick nextPacketTick(bool elastic, Tick delay) const
Determine the tick when the next packet is available.
Definition: generators.cc:384
const unsigned int rankBits
Number of rank bits in DRAM address.
Definition: generators.hh:414
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:85
const unsigned int nbrOfRanks
Number of ranks to be utilized for a given configuration.
Definition: generators.hh:417
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
InputStream trace
Input stream used for reading the input trace file.
Definition: generators.hh:621
Addr addrOffset
Offset for memory requests.
Definition: generators.hh:638
const Addr endAddr
End of address range.
Definition: generators.hh:285
ProtoInputStream trace
Input file stream for the protobuf trace.
Definition: generators.hh:550
Addr addr
The address for the request.
Definition: generators.hh:511
bool isValid() const
Check validity of this element.
Definition: generators.hh:527
PacketPtr getNextPacket()
Get the next generated packet.
Definition: generators.cc:183
Addr dataManipulated
Counter to determine the amount of data manipulated.
Definition: generators.hh:233
int floorLog2(unsigned x)
Definition: intmath.hh:100
TraceElement nextElement
Definition: generators.hh:625
int size()
Definition: pagetable.hh:146
const uint8_t readPercent
Percent of generated transactions that should be reads.
Definition: generators.hh:220
Declaration of the Packet class.
Addr addr
Address of request.
Definition: generators.hh:387
TraceGen(const std::string &_name, MasterID master_id, Tick _duration, const std::string &trace_file, Addr addr_offset)
Create a trace generator.
Definition: generators.hh:595
Tick tickOffset
Stores the time when the state was entered.
Definition: generators.hh:632
The random generator is similar to the linear one, but does not generate sequential addresses...
Definition: generators.hh:241
PacketPtr getNextPacket()
Get the next generated packet.
Definition: generators.cc:88
PacketPtr getNextPacket()
Get the next generated packet.
Definition: generators.hh:152
DramGen(const std::string &_name, MasterID master_id, Tick _duration, Addr start_addr, Addr end_addr, Addr _blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit, unsigned int num_seq_pkts, unsigned int page_size, unsigned int nbr_of_banks_DRAM, unsigned int nbr_of_banks_util, unsigned int addr_mapping, unsigned int nbr_of_ranks)
Create a DRAM address sequence generator.
Definition: generators.hh:342
const unsigned int pageSize
Page size of DRAM.
Definition: generators.hh:393
const Addr startAddr
Start of address range.
Definition: generators.hh:282
LinearGen(const std::string &_name, MasterID master_id, Tick _duration, Addr start_addr, Addr end_addr, Addr _blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit)
Create a linear address sequence generator.
Definition: generators.hh:185
const unsigned int maxSeqCountPerRank
Number of command series issued before the rank is changed.
Definition: generators.hh:484
Base class for all generators, with the shared functionality and virtual functions for entering...
Definition: generators.hh:63
void reset()
Reset the stream such that it can be played once again.
Definition: generators.cc:432
Declaration of a wrapper for protobuf output streams and input streams.
const std::string _name
Name to use for status and debug printing.
Definition: generators.hh:69
Addr dataManipulated
Counter to determine the amount of data manipulated.
Definition: generators.hh:307

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6