OpenASIP 2.2
Loading...
Searching...
No Matches
BusTracker.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file BusTracker.cc
26 *
27 * Definition of BusTracker class.
28 *
29 * @author Pekka J��skel�inen 2005 (pjaaskel-no.spam-cs.tut.fi)
30 * @author Henry Linjamäki 2017 (henry.linjamaki-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34#include "BusTracker.hh"
35#include "Application.hh"
37#include "SimulatorToolbox.hh"
39#include "SimulatorFrontend.hh"
40#include "MachineState.hh"
41#include "Machine.hh"
42#include "MathTools.hh"
43#include "Conversion.hh"
44
45#include <algorithm>
46#include <vector>
47#include <string>
48#include <iostream>
49#include <iomanip>
50#include <locale>
51#include <functional>
52
53const std::string BusTracker::COLUMN_SEPARATOR = ",";
54
55/**
56 * Constructor.
57 *
58 * @param frontend The SimulationFrontend which is used to access simulation
59 * data.
60 * @param traceStream Output stream where the trace data is written to. Takes
61 * ownership of the stream.
62 */
64 SimulatorFrontend& frontend,
65 std::ostream* traceStream) :
66 Listener(), frontend_(frontend),ownsTraceStream_(true),
67 traceStream_(traceStream) {
68 // write the trace data at the end of simulation clock cycle
71}
72
73/**
74 * Constructor.
75 *
76 * @param frontend The SimulationFrontend which is used to access simulation
77 * data.
78 * @param traceStream Output stream where the trace data is written to.
79 */
81 SimulatorFrontend& frontend,
82 std::ostream& traceStream)
83 : Listener(), frontend_(frontend),ownsTraceStream_(false),
84 traceStream_(&traceStream) {
87}
88
89/**
90 * Destructor.
91 */
100
101/**
102 * Writes bus trace data to the trace stream.
103 *
104 * If any error happens while writing the data, aborts program with
105 * an error message.
106 */
107void
109
112
114
115 for (int i = 0; i < navigator.count(); ++i) {
116 const std::string busName = navigator.item(i)->name();
117
118 BusState& bus = frontend_.machineState(0).busState(busName);
119 int columnWidth = (bus.width()+3)/4;
120
122 if (!bus.isSquashed()) {
123 *traceStream_ << bus.value().hexValue(true);
124 } else {
125 // Squashed values are displayed as zeros.
126 *traceStream_ << std::string(columnWidth, '0');
127 }
128 }
129 *traceStream_ << "\n";
130}
find Finds info of the inner loops in the false
bool isSquashed() const
Definition BusState.cc:88
int width() const
Definition BusState.cc:96
static const std::string COLUMN_SEPARATOR
Definition BusTracker.hh:67
virtual ~BusTracker()
Definition BusTracker.cc:92
bool ownsTraceStream_
Definition BusTracker.hh:70
SimulatorFrontend & frontend_
the simulator frontend used to access simulation data
Definition BusTracker.hh:69
virtual void handleEvent()
std::ostream * traceStream_
Definition BusTracker.hh:71
BusTracker(SimulatorFrontend &frontend, std::ostream *traceStream)
Definition BusTracker.cc:63
virtual bool unregisterListener(int event, Listener *listener)
Definition Informer.cc:104
virtual bool registerListener(int event, Listener *listener)
Definition Informer.cc:87
BusState & busState(const std::string &name)
virtual const SimValue & value() const
TCEString hexValue(bool noHexIdentifier=false) const
Definition SimValue.cc:1150
@ SE_CYCLE_END
Generated before advancing the simulator clock at the end of a simulation cycle.
SimulationEventHandler & eventHandler()
const TTAMachine::Machine & machine() const
ClockCycleCount cycleCount() const
MachineState & machineState(int core=-1)
ComponentType * item(int index) const
virtual BusNavigator busNavigator() const
Definition Machine.cc:356