OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
BusTracker Class Reference

#include <BusTracker.hh>

Inheritance diagram for BusTracker:
Inheritance graph
Collaboration diagram for BusTracker:
Collaboration graph

Public Member Functions

 BusTracker (SimulatorFrontend &frontend, std::ostream *traceStream)
 
 BusTracker (SimulatorFrontend &frontend, std::ostream &traceStream)
 
virtual ~BusTracker ()
 
virtual void handleEvent ()
 
- Public Member Functions inherited from Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void handleEvent (int event)
 

Private Attributes

SimulatorFrontendfrontend_
 the simulator frontend used to access simulation data
 
bool ownsTraceStream_
 
std::ostream * traceStream_
 

Static Private Attributes

static const int COLUMN_WIDTH
 
static const std::string COLUMN_SEPARATOR = ","
 

Detailed Description

Tracks the bus activity.

Stores bus data as hexadecimal numbers in a bus trace file in CSV format.

Definition at line 53 of file BusTracker.hh.

Constructor & Destructor Documentation

◆ BusTracker() [1/2]

BusTracker::BusTracker ( SimulatorFrontend frontend,
std::ostream *  traceStream 
)

Constructor.

Parameters
frontendThe SimulationFrontend which is used to access simulation data.
traceStreamOutput stream where the trace data is written to. Takes ownership of the stream.

Definition at line 63 of file BusTracker.cc.

65 :
66 Listener(), frontend_(frontend),ownsTraceStream_(true),
67 traceStream_(traceStream) {
68 // write the trace data at the end of simulation clock cycle
71}
bool ownsTraceStream_
Definition BusTracker.hh:70
SimulatorFrontend & frontend_
the simulator frontend used to access simulation data
Definition BusTracker.hh:69
std::ostream * traceStream_
Definition BusTracker.hh:71
virtual bool registerListener(int event, Listener *listener)
Definition Informer.cc:87
@ SE_CYCLE_END
Generated before advancing the simulator clock at the end of a simulation cycle.
SimulationEventHandler & eventHandler()

References SimulatorFrontend::eventHandler(), Informer::registerListener(), and SimulationEventHandler::SE_CYCLE_END.

Here is the call graph for this function:

◆ BusTracker() [2/2]

BusTracker::BusTracker ( SimulatorFrontend frontend,
std::ostream &  traceStream 
)

Constructor.

Parameters
frontendThe SimulationFrontend which is used to access simulation data.
traceStreamOutput stream where the trace data is written to.

Definition at line 80 of file BusTracker.cc.

83 : Listener(), frontend_(frontend),ownsTraceStream_(false),
84 traceStream_(&traceStream) {
87}

References SimulatorFrontend::eventHandler(), Informer::registerListener(), and SimulationEventHandler::SE_CYCLE_END.

Here is the call graph for this function:

◆ ~BusTracker()

BusTracker::~BusTracker ( )
virtual

Destructor.

Definition at line 92 of file BusTracker.cc.

92 {
95 traceStream_->flush();
96 if (ownsTraceStream_) {
97 delete traceStream_;
98 }
99}
virtual bool unregisterListener(int event, Listener *listener)
Definition Informer.cc:104

References SimulatorFrontend::eventHandler(), frontend_, ownsTraceStream_, SimulationEventHandler::SE_CYCLE_END, traceStream_, and Informer::unregisterListener().

Here is the call graph for this function:

Member Function Documentation

◆ handleEvent()

void BusTracker::handleEvent ( )
virtual

Writes bus trace data to the trace stream.

If any error happens while writing the data, aborts program with an error message.

Reimplemented from Listener.

Definition at line 108 of file BusTracker.cc.

108 {
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}
bool isSquashed() const
Definition BusState.cc:88
int width() const
Definition BusState.cc:96
static const std::string COLUMN_SEPARATOR
Definition BusTracker.hh:67
BusState & busState(const std::string &name)
virtual const SimValue & value() const
TCEString hexValue(bool noHexIdentifier=false) const
Definition SimValue.cc:1150
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

References TTAMachine::Machine::busNavigator(), MachineState::busState(), COLUMN_SEPARATOR, TTAMachine::Machine::Navigator< ComponentType >::count(), SimulatorFrontend::cycleCount(), frontend_, SimValue::hexValue(), BusState::isSquashed(), TTAMachine::Machine::Navigator< ComponentType >::item(), SimulatorFrontend::machine(), SimulatorFrontend::machineState(), traceStream_, RegisterState::value(), and BusState::width().

Here is the call graph for this function:

Member Data Documentation

◆ COLUMN_SEPARATOR

const std::string BusTracker::COLUMN_SEPARATOR = ","
staticprivate

Definition at line 67 of file BusTracker.hh.

Referenced by handleEvent().

◆ COLUMN_WIDTH

const int BusTracker::COLUMN_WIDTH
staticprivate

Definition at line 66 of file BusTracker.hh.

◆ frontend_

SimulatorFrontend& BusTracker::frontend_
private

the simulator frontend used to access simulation data

Definition at line 69 of file BusTracker.hh.

Referenced by handleEvent(), and ~BusTracker().

◆ ownsTraceStream_

bool BusTracker::ownsTraceStream_
private

Definition at line 70 of file BusTracker.hh.

Referenced by ~BusTracker().

◆ traceStream_

std::ostream* BusTracker::traceStream_
private

Definition at line 71 of file BusTracker.hh.

Referenced by handleEvent(), and ~BusTracker().


The documentation for this class was generated from the following files: