OpenASIP  2.0
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 More...
 
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
69  frontend.eventHandler().registerListener(
71 }

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) {
85  frontend.eventHandler().registerListener(
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 }

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 }

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:
BusState::width
int width() const
Definition: BusState.cc:96
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
BusState
Definition: BusState.hh:48
BusState::isSquashed
bool isSquashed() const
Definition: BusState.cc:88
TTAMachine::Machine::Navigator::count
int count() const
BusTracker::ownsTraceStream_
bool ownsTraceStream_
Definition: BusTracker.hh:70
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
Informer::unregisterListener
virtual bool unregisterListener(int event, Listener *listener)
Definition: Informer.cc:104
MachineState::busState
BusState & busState(const std::string &name)
Definition: MachineState.cc:116
SimulationEventHandler::SE_CYCLE_END
@ SE_CYCLE_END
Generated before advancing the simulator clock at the end of a simulation cycle.
Definition: SimulationEventHandler.hh:50
Informer::registerListener
virtual bool registerListener(int event, Listener *listener)
Definition: Informer.cc:87
SimValue::hexValue
TCEString hexValue(bool noHexIdentifier=false) const
Definition: SimValue.cc:1150
SimulatorFrontend::cycleCount
ClockCycleCount cycleCount() const
Definition: SimulatorFrontend.cc:1194
SimulatorFrontend::eventHandler
SimulationEventHandler & eventHandler()
Definition: SimulatorFrontend.cc:2260
BusTracker::traceStream_
std::ostream * traceStream_
Definition: BusTracker.hh:71
SimulatorFrontend::machineState
MachineState & machineState(int core=-1)
Definition: SimulatorFrontend.cc:2138
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
Listener::Listener
Listener()
Definition: Listener.cc:40
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
BusTracker::COLUMN_SEPARATOR
static const std::string COLUMN_SEPARATOR
Definition: BusTracker.hh:67
BusTracker::frontend_
SimulatorFrontend & frontend_
the simulator frontend used to access simulation data
Definition: BusTracker.hh:69