summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2015-07-06 17:08:53 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2015-07-06 17:08:53 +0100
commit777cc71c4a54412f78eabe381532f661c6174fee (patch)
treec4639bc7ca138c337095e2cced775ad7e94eff7c /src/mem
parent381e9191ddcacb78f2f1e72040d9843d43b3461b (diff)
downloadgem5-777cc71c4a54412f78eabe381532f661c6174fee.tar.xz
mem: Cleanup CommMonitor in preparation for probe support
Make configuration parameters constant and get rid of an unnecessary dependency on the Time class.
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/comm_monitor.cc18
-rw-r--r--src/mem/comm_monitor.hh64
2 files changed, 42 insertions, 40 deletions
diff --git a/src/mem/comm_monitor.cc b/src/mem/comm_monitor.cc
index a0f8688f2..d95a2fd5a 100644
--- a/src/mem/comm_monitor.cc
+++ b/src/mem/comm_monitor.cc
@@ -52,12 +52,13 @@ CommMonitor::CommMonitor(Params* params)
slavePort(name() + "-slave", *this),
samplePeriodicEvent(this),
samplePeriodTicks(params->sample_period),
+ samplePeriod(params->sample_period / SimClock::Float::s),
readAddrMask(params->read_addr_mask),
writeAddrMask(params->write_addr_mask),
- stats(params),
stackDistCalc(params->stack_dist_calc),
- traceStream(NULL),
- system(params->system)
+ system(params->system),
+ traceStream(nullptr),
+ stats(params)
{
// If we are using a trace file, then open the file
if (params->trace_enable) {
@@ -98,12 +99,9 @@ CommMonitor::CommMonitor(Params* params)
registerExitCallback(cb);
}
- // keep track of the sample period both in ticks and absolute time
- samplePeriod.setTick(params->sample_period);
-
DPRINTF(CommMonitor,
"Created monitor %s with sample period %d ticks (%f ms)\n",
- name(), samplePeriodTicks, samplePeriod.msec());
+ name(), samplePeriodTicks, samplePeriod * 1E3);
}
CommMonitor::~CommMonitor()
@@ -180,9 +178,9 @@ CommMonitor::recvAtomic(PacketPtr pkt)
if (stackDistCalc)
stackDistCalc->update(pkt->cmd, pkt->getAddr());
- // if tracing enabled, store the packet information
- // to the trace stream
- if (traceStream != NULL) {
+ // if tracing enabled, store the packet information
+ // to the trace stream
+ if (traceStream != NULL) {
ProtoMessage::Packet pkt_msg;
pkt_msg.set_tick(curTick());
pkt_msg.set_cmd(pkt->cmdToIndex());
diff --git a/src/mem/comm_monitor.hh b/src/mem/comm_monitor.hh
index f4aa9a20e..74c711955 100644
--- a/src/mem/comm_monitor.hh
+++ b/src/mem/comm_monitor.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 ARM Limited
+ * Copyright (c) 2012-2013, 2015 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -42,7 +42,6 @@
#define __MEM_COMM_MONITOR_HH__
#include "base/statistics.hh"
-#include "base/time.hh"
#include "mem/mem_object.hh"
#include "mem/stack_dist_calc.hh"
#include "params/CommMonitor.hh"
@@ -63,7 +62,7 @@
class CommMonitor : public MemObject
{
- public:
+ public: // Construction & SimObject interfaces
/** Parameters of communication monitor */
typedef CommMonitorParams Params;
@@ -80,22 +79,16 @@ class CommMonitor : public MemObject
/** Destructor */
~CommMonitor();
- /**
- * Callback to flush and close all open output streams on exit. If
- * we were calling the destructor it could be done there.
- */
- void closeStreams();
-
- virtual BaseMasterPort& getMasterPort(const std::string& if_name,
- PortID idx = InvalidPortID);
+ void init() M5_ATTR_OVERRIDE;
+ void regStats() M5_ATTR_OVERRIDE;
+ void startup() M5_ATTR_OVERRIDE;
- virtual BaseSlavePort& getSlavePort(const std::string& if_name,
- PortID idx = InvalidPortID);
+ public: // MemObject interfaces
+ BaseMasterPort& getMasterPort(const std::string& if_name,
+ PortID idx = InvalidPortID) M5_ATTR_OVERRIDE;
- virtual void init();
-
- /** Register statistics */
- void regStats();
+ BaseSlavePort& getSlavePort(const std::string& if_name,
+ PortID idx = InvalidPortID) M5_ATTR_OVERRIDE;
private:
@@ -397,33 +390,44 @@ class CommMonitor : public MemObject
/** This function is called periodically at the end of each time bin */
void samplePeriodic();
- /** Schedule the first periodic event */
- void startup();
+ /**
+ * Callback to flush and close all open output streams on exit. If
+ * we were calling the destructor it could be done there.
+ */
+ void closeStreams();
/** Periodic event called at the end of each simulation time bin */
EventWrapper<CommMonitor, &CommMonitor::samplePeriodic> samplePeriodicEvent;
+ /**
+ *@{
+ * @name Configuration
+ */
+
/** Length of simulation time bin*/
- Tick samplePeriodTicks;
- Time samplePeriod;
+ const Tick samplePeriodTicks;
+ /** Sample period in seconds */
+ const double samplePeriod;
/** Address mask for sources of read accesses to be captured */
- Addr readAddrMask;
+ const Addr readAddrMask;
/** Address mask for sources of write accesses to be captured */
- Addr writeAddrMask;
-
- /** Instantiate stats */
- MonitorStats stats;
+ const Addr writeAddrMask;
/** Optional stack distance calculator */
- StackDistCalc* stackDistCalc;
+ StackDistCalc *const stackDistCalc;
+
+ /** The system in which the monitor lives */
+ System *const system;
+
+ /** @} */
/** Output stream for a potential trace. */
- ProtoOutputStream* traceStream;
+ ProtoOutputStream *traceStream;
- /** The system in which the monitor lives */
- System *system;
+ /** Instantiate stats */
+ MonitorStats stats;
};
#endif //__MEM_COMM_MONITOR_HH__