comm_monitor.cc (9356:b279bad40aa3) comm_monitor.cc (9398:6a348f61220c)
1/*
2 * Copyright (c) 2012 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

--- 24 unchanged lines hidden (view full) ---

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 */
40
1/*
2 * Copyright (c) 2012 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

--- 24 unchanged lines hidden (view full) ---

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 */
40
41#include "base/callback.hh"
42#include "base/output.hh"
41#include "base/trace.hh"
42#include "debug/CommMonitor.hh"
43#include "mem/comm_monitor.hh"
43#include "base/trace.hh"
44#include "debug/CommMonitor.hh"
45#include "mem/comm_monitor.hh"
46#include "proto/packet.pb.h"
44#include "sim/stats.hh"
45
46CommMonitor::CommMonitor(Params* params)
47 : MemObject(params),
48 masterPort(name() + "-master", *this),
49 slavePort(name() + "-slave", *this),
50 samplePeriodicEvent(this),
51 samplePeriodTicks(params->sample_period),
52 readAddrMask(params->read_addr_mask),
53 writeAddrMask(params->write_addr_mask),
47#include "sim/stats.hh"
48
49CommMonitor::CommMonitor(Params* params)
50 : MemObject(params),
51 masterPort(name() + "-master", *this),
52 slavePort(name() + "-slave", *this),
53 samplePeriodicEvent(this),
54 samplePeriodTicks(params->sample_period),
55 readAddrMask(params->read_addr_mask),
56 writeAddrMask(params->write_addr_mask),
54 stats(params)
57 stats(params),
58 traceStream(NULL)
55{
59{
60 // If we are using a trace file, then open the file,
61 if (params->trace_file != "") {
62 // If the trace file is not specified as an absolute path,
63 // append the current simulation output directory
64 std::string filename = simout.resolve(params->trace_file);
65 traceStream = new ProtoOutputStream(filename);
66
67 // Create a protobuf message for the header and write it to
68 // the stream
69 Message::PacketHeader header_msg;
70 header_msg.set_obj_id(name());
71 header_msg.set_tick_freq(SimClock::Frequency);
72 traceStream->write(header_msg);
73
74 // Register a callback to compensate for the destructor not
75 // being called. The callback forces the stream to flush and
76 // closes the output file.
77 Callback* cb = new MakeCallback<CommMonitor,
78 &CommMonitor::closeStreams>(this);
79 registerExitCallback(cb);
80 }
81
56 // keep track of the sample period both in ticks and absolute time
57 samplePeriod.setTick(params->sample_period);
58
59 DPRINTF(CommMonitor,
60 "Created monitor %s with sample period %d ticks (%f s)\n",
61 name(), samplePeriodTicks, samplePeriod);
62}
63
82 // keep track of the sample period both in ticks and absolute time
83 samplePeriod.setTick(params->sample_period);
84
85 DPRINTF(CommMonitor,
86 "Created monitor %s with sample period %d ticks (%f s)\n",
87 name(), samplePeriodTicks, samplePeriod);
88}
89
90void
91CommMonitor::closeStreams()
92{
93 if (traceStream != NULL)
94 delete traceStream;
95}
96
64CommMonitor*
65CommMonitorParams::create()
66{
67 return new CommMonitor(this);
68}
69
70void
71CommMonitor::init()

--- 77 unchanged lines hidden (view full) ---

149 bool successful = masterPort.sendTimingReq(pkt);
150
151 // If not successful, restore the sender state
152 if (!successful && needsResponse && !stats.disableLatencyHists) {
153 delete pkt->senderState;
154 pkt->senderState = senderState;
155 }
156
97CommMonitor*
98CommMonitorParams::create()
99{
100 return new CommMonitor(this);
101}
102
103void
104CommMonitor::init()

--- 77 unchanged lines hidden (view full) ---

182 bool successful = masterPort.sendTimingReq(pkt);
183
184 // If not successful, restore the sender state
185 if (!successful && needsResponse && !stats.disableLatencyHists) {
186 delete pkt->senderState;
187 pkt->senderState = senderState;
188 }
189
190 if (successful && traceStream != NULL) {
191 // Create a protobuf message representing the
192 // packet. Currently we do not preserve the flags in the
193 // trace.
194 Message::Packet pkt_msg;
195 pkt_msg.set_tick(curTick());
196 pkt_msg.set_cmd(pkt->cmdToIndex());
197 pkt_msg.set_addr(pkt->getAddr());
198 pkt_msg.set_size(pkt->getSize());
199
200 traceStream->write(pkt_msg);
201 }
202
157 if (successful && isRead) {
158 DPRINTF(CommMonitor, "Forwarded read request\n");
159
160 // Increment number of observed read transactions
161 if (!stats.disableTransactionHists) {
162 ++stats.readTrans;
163 }
164

--- 377 unchanged lines hidden ---
203 if (successful && isRead) {
204 DPRINTF(CommMonitor, "Forwarded read request\n");
205
206 // Increment number of observed read transactions
207 if (!stats.disableTransactionHists) {
208 ++stats.readTrans;
209 }
210

--- 377 unchanged lines hidden ---