gem5  v22.1.0.0
activity.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __CPU_ACTIVITY_HH__
30 #define __CPU_ACTIVITY_HH__
31 
32 #include "base/trace.hh"
33 #include "cpu/timebuf.hh"
34 
35 namespace gem5
36 {
37 
54 {
55  public:
56  ActivityRecorder(const std::string &name, int num_stages,
57  int longest_latency, int count);
59 
61  void activity();
62 
67  void advance();
68 
70  void activateStage(const int idx);
71 
73  void deactivateStage(const int idx);
74 
76  bool getStageActive(const int idx) const { return stageActive[idx]; }
77 
79  int getNumStages() const { return numStages; }
80 
82  int getActivityCount() const { return activityCount; }
83 
88  { activityCount = count; }
89 
91  bool active() { return activityCount; }
92 
94  void reset();
95 
97  void dump();
98 
102  void validate();
103 
104  const std::string &name() const { return _name; }
105 
106  private:
107  // provide name() for DPRINTF.
108  std::string _name;
109 
119 
122 
133 
136 
138  bool *stageActive;
139 };
140 
141 } // namespace gem5
142 
143 #endif // __CPU_ACTIVITY_HH__
ActivityRecorder helper class that informs the CPU if it can switch over to being idle or not.
Definition: activity.hh:54
int activityCount
Tracks how many stages and cycles of time buffer have activity.
Definition: activity.hh:132
int numStages
Number of stages that can be marked as active or inactive.
Definition: activity.hh:135
void dump()
Debug function to dump the contents of the time buffer.
Definition: activity.cc:134
int longestLatency
Longest latency time buffer in the CPU.
Definition: activity.hh:121
int getActivityCount() const
Returns how many things are active within the recorder.
Definition: activity.hh:82
void advance()
Advances the activity buffer, decrementing the activityCount if active communication just left the ti...
Definition: activity.cc:71
bool getStageActive(const int idx) const
Returns the activity status of a stage.
Definition: activity.hh:76
void validate()
Debug function to ensure that the activity count matches the contents of the time buffer.
Definition: activity.cc:152
void reset()
Clears the time buffer and the activity count.
Definition: activity.cc:125
void activity()
Records that there is activity this cycle.
Definition: activity.cc:55
int getNumStages() const
Returns the number of stages.
Definition: activity.hh:79
bool * stageActive
Records which stages are active/inactive.
Definition: activity.hh:138
ActivityRecorder(const std::string &name, int num_stages, int longest_latency, int count)
Definition: activity.cc:39
void deactivateStage(const int idx)
Deactivates a stage.
Definition: activity.cc:108
bool active()
Returns if the CPU should be active.
Definition: activity.hh:91
TimeBuffer< bool > activityBuffer
Time buffer that tracks if any cycles has active communication in them.
Definition: activity.hh:118
void activateStage(const int idx)
Marks a stage as active.
Definition: activity.cc:91
const std::string & name() const
Definition: activity.hh:104
void setActivityCount(int count)
Sets the count to a starting value.
Definition: activity.hh:87
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....

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