gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
dram_rot_gen.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2016-2017, 2019 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 
44 
45 #include <algorithm>
46 
47 #include "base/random.hh"
48 #include "base/trace.hh"
49 #include "debug/TrafficGen.hh"
50 #include "enums/AddrMap.hh"
51 
54 {
55  // if this is the first of the packets in series to be generated,
56  // start counting again
57  if (countNumSeqPkts == 0) {
59 
60  // choose if we generate a read or a write here
61  if (readPercent == 50) {
62  if ((nextSeqCount % nbrOfBanksUtil) == 0) {
63  // Change type after all banks have been rotated
64  // Otherwise, keep current value
65  isRead = !isRead;
66  }
67  } else {
68  // Set randomly based on percentage
69  isRead = readPercent != 0;
70  }
71 
72  assert((readPercent == 0 && !isRead) ||
73  (readPercent == 100 && isRead) ||
74  readPercent != 100);
75 
76  // Overwrite random bank value
77  // Rotate across banks
78  unsigned int new_bank = nextSeqCount % nbrOfBanksUtil;
79 
80  // Overwrite random rank value
81  // Will rotate to the next rank after rotating through all banks,
82  // for each specified command type.
83 
84  // Use modular function to ensure that calculated rank is within
85  // system limits after state transition
86  unsigned int new_rank = (nextSeqCount / maxSeqCountPerRank) %
87  nbrOfRanks;
88 
89  // Increment nextSeqCount
90  // Roll back to 0 after completing a full rotation across
91  // banks, command type, and ranks
92  nextSeqCount = (nextSeqCount + 1) %
94 
95  DPRINTF(TrafficGen, "DramRotGen::getNextPacket nextSeqCount: %d "
96  "new_rank: %d new_bank: %d\n",
97  nextSeqCount, new_rank, new_bank);
98 
99  // Generate the start address of the command series
100  // routine will update addr variable with bank, rank, and col
101  // bits updated for rotation scheme
102  genStartAddr(new_bank, new_rank);
103 
104  } else {
105  // increment the column by one
106  if (addrMapping == Enums::RoRaBaCoCh ||
107  addrMapping == Enums::RoRaBaChCo)
108  // Simply increment addr by blocksize to
109  // increment the column by one
110  addr += blocksize;
111 
112  else if (addrMapping == Enums::RoCoRaBaCh) {
113  // Explicity increment the column bits
114 
115  unsigned int new_col = ((addr / blocksize /
117  (pageSize / blocksize)) + 1;
119  blockBits + bankBits + rankBits, new_col);
120  }
121  }
122 
123  DPRINTF(TrafficGen, "DramRotGen::getNextPacket: %c to addr %x, "
124  "size %d, countNumSeqPkts: %d, numSeqPkts: %d\n",
126 
127  // create a new request packet
130 
131  // add the amount of data manipulated to the total
133 
134  // subtract the number of packets remained to be generated
135  --countNumSeqPkts;
136 
137  // return the generated packet
138  return pkt;
139 }
#define DPRINTF(x,...)
Definition: trace.hh:229
const unsigned int numSeqPkts
Number of sequential DRAM packets to be generated per cpu request.
Definition: dram_gen.hh:114
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: dram_gen.cc:148
PacketPtr getPacket(Addr addr, unsigned size, const MemCmd &cmd, Request::FlagsType flags=0)
Generate a new request and associated packet.
Definition: base_gen.cc:61
unsigned int countNumSeqPkts
Track number of sequential packets generated for a request.
Definition: dram_gen.hh:117
const unsigned int nbrOfBanksDRAM
Number of banks in DRAM.
Definition: dram_gen.hh:138
bool isRead
Remember type of requests to be generated in series.
Definition: dram_gen.hh:123
Declaration of DRAM rotation generator that rotates through each rank.
const unsigned int bankBits
Number of bank bits in DRAM address.
Definition: dram_gen.hh:132
unsigned int nextSeqCount
Next packet series count used to set rank and bank, and update isRead Incremented at the start of a n...
PacketPtr getNextPacket()
Get the next generated packet.
Definition: dram_rot_gen.cc:53
const unsigned int blockBits
Number of block bits in DRAM address.
Definition: dram_gen.hh:135
The traffic generator is a master module that generates stimuli for the memory system, based on a collection of simple behaviours that are either probabilistic or based on traces.
Definition: traffic_gen.hh:71
const uint8_t readPercent
Percent of generated transactions that should be reads.
Definition: base_gen.hh:167
void replaceBits(T &val, int first, int last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
Definition: bitfield.hh:157
const unsigned int nbrOfBanksUtil
Number of banks to be utilized for a given configuration.
Definition: dram_gen.hh:141
const unsigned int pageBits
Number of page bits in DRAM address.
Definition: dram_gen.hh:129
const unsigned int rankBits
Number of rank bits in DRAM address.
Definition: dram_gen.hh:147
const unsigned int nbrOfRanks
Number of ranks to be utilized for a given configuration.
Definition: dram_gen.hh:150
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
Addr addr
Address of request.
Definition: dram_gen.hh:120
const Addr blocksize
Blocksize and address increment.
Definition: base_gen.hh:155
const unsigned int pageSize
Page size of DRAM.
Definition: dram_gen.hh:126
const unsigned int maxSeqCountPerRank
Number of command series issued before the rank is changed.
Enums::AddrMap addrMapping
Address mapping to be used.
Definition: dram_gen.hh:144
Addr dataManipulated
Counter to determine the amount of data manipulated.
Definition: random_gen.hh:106

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