#include <traceval.h>
Public Types | |
enum | Atype { READ = 1, WRITE = 2, CHANGE = 4 } |
Possible access types for a trace value. More... | |
Public Member Functions | |
TraceValue (size_t bits, const std::string &_name, const int __index=-1, void *shadow=0) | |
Generate a new unitialized trace value of width bits. | |
size_t | bits () const |
Give number of bits for this value. Max 32. | |
unsigned | value () const |
Gives the saved shadow value for this trace value. | |
std::string | name () const |
Give name (fully qualified), including the index appended if it is >=0. | |
std::string | barename () const |
Gives the name without the index. | |
int | index () const |
Gives the index of this member in a memory field (or -1). | |
bool | enabled () const |
void | enable () |
Enable tracing. | |
void | change (unsigned val) |
Log a change on this value. | |
void | change (unsigned val, unsigned mask) |
void | write (unsigned val) |
Log a write access on this value. | |
void | read () |
Log a read access. | |
bool | written () const |
void | set_written () |
void | set_written (unsigned val) |
Atype | flags () const |
Gives the current set of flag readings. | |
virtual void | cycle () |
Called at least once for each cycle if this trace value is activated. | |
virtual void | dump (Dumper &d) |
Protected Member Functions | |
void | clear_flags () |
Clear all access flags. | |
Private Attributes | |
std::string | _name |
int | _index |
const unsigned | b |
number of bits | |
void * | shadow |
shadow reg, if used | |
unsigned | v |
The value itself. | |
int | f |
accesses since last dump/clearflagsd | |
bool | _written |
bool | _enabled |
Tracing of this value enabled at all? | |
Friends | |
class | TraceKeeper |
Abstract interface for traceable values. Traced values can be written (marking it with a WRITE flag and if the value changed also a CHANGE flag. If the traced value has been written once, it is marked 'written()' for the whole simulation. They can also be read, marking the READ flag.
For values where no accessors for read and write can be intercepted, it is also possible to use the cycle() method (activated when the traceval is initialized with a shadow ptr !=0), which will then simply update the state of the value during the cycle() method by comparing it with the internal state. This does not allow to trace read and write accesses, but all state changes will still be represented in the output file. This is helpful for e.g. tracing the hidden shadow states in various parts of the AVR hardware, such as the timer double buffers.
Definition at line 102 of file traceval.h.
enum TraceValue::Atype |
Possible access types for a trace value.
Definition at line 130 of file traceval.h.
TraceValue::TraceValue | ( | size_t | bits, | |
const std::string & | _name, | |||
const int | __index = -1 , |
|||
void * | shadow = 0 | |||
) |
Generate a new unitialized trace value of width bits.
Definition at line 36 of file traceval.cpp.
std::string TraceValue::barename | ( | ) | const |
Gives the name without the index.
Definition at line 57 of file traceval.cpp.
References _name.
Referenced by DumpManager::save().
size_t TraceValue::bits | ( | ) | const |
Give number of bits for this value. Max 32.
Definition at line 49 of file traceval.cpp.
References b.
Referenced by DumpVCD::valout().
void TraceValue::change | ( | unsigned | val, | |
unsigned | mask | |||
) |
void TraceValue::change | ( | unsigned | val | ) |
Log a change on this value.
Definition at line 67 of file traceval.cpp.
References _written, CHANGE, f, and v.
Referenced by BasicTimerUnit::CountTimer(), TwiceTV::cycle(), IOSpecialReg::hardwareChange(), IOReg< HWTimer8_0C >::hardwareChange(), IOSpecialReg::hardwareChangeMask(), BasicTimerUnit::SetCounter(), and RWSreg::trigger_change().
void TraceValue::clear_flags | ( | ) | [protected] |
Clear all access flags.
void TraceValue::cycle | ( | ) | [virtual] |
Called at least once for each cycle if this trace value is activated.
This may check for updates to an underlying referenced value etc. and update the flags accordingly.
Reimplemented in TwiceTV.
Definition at line 109 of file traceval.cpp.
References _written, avr_error, b, CHANGE, f, shadow, and v.
void TraceValue::dump | ( | Dumper & | d | ) | [virtual] |
Dump the state or state change somewhere. This also resets the current flags.
Definition at line 132 of file traceval.cpp.
References _written, CHANGE, f, Dumper::markChange(), Dumper::markRead(), Dumper::markReadUnknown(), Dumper::markWrite(), READ, and WRITE.
void TraceValue::enable | ( | ) |
bool TraceValue::enabled | ( | ) | const |
Enabled? All operations should be skipped if a trace value is not enabled.
Definition at line 63 of file traceval.cpp.
References _enabled.
TraceValue::Atype TraceValue::flags | ( | ) | const |
int TraceValue::index | ( | ) | const |
Gives the index of this member in a memory field (or -1).
Definition at line 59 of file traceval.cpp.
References _index.
Referenced by name(), TraceValueCoreRegister::RegisterTraceSetValue(), and DumpManager::save().
std::string TraceValue::name | ( | ) | const |
Give name (fully qualified), including the index appended if it is >=0.
Definition at line 51 of file traceval.cpp.
References _name, index(), and int2str().
Referenced by IOReg< HWTimer8_0C >::get(), WarnUnknown::markReadUnknown(), TraceValueRegister::RegisterTraceValue(), IOReg< HWTimer8_0C >::set(), and TraceValueRegister::UnregisterTraceValue().
void TraceValue::read | ( | ) |
Log a read access.
Definition at line 92 of file traceval.cpp.
Referenced by RWMemoryMember::operator unsigned char(), and RWMemoryMember::operator=().
void TraceValue::set_written | ( | unsigned | val | ) |
Just set the written flag for tracevalues which are automatically initialized (IO registers etc.)
This method sets not only the _written flag, it set's also the saved value for detecting changes.
Definition at line 102 of file traceval.cpp.
void TraceValue::set_written | ( | ) |
Just set the written flag for tracevalues which are automatically initialized (IO registers etc.)
Definition at line 98 of file traceval.cpp.
References _written.
Referenced by BasicTimerUnit::BasicTimerUnit(), TwiceTV::cycle(), HWIrqSystem::HWIrqSystem(), IOReg< HWTimer8_0C >::IOReg(), and IOSpecialReg::Reset().
unsigned TraceValue::value | ( | ) | const |
Gives the saved shadow value for this trace value.
Note that the shadow value does not necessarily reflect the *current* value of the traced variable.
Definition at line 61 of file traceval.cpp.
References v.
Referenced by TwiceTV::cycle(), and DumpVCD::valout().
void TraceValue::write | ( | unsigned | val | ) |
Log a write access on this value.
Definition at line 83 of file traceval.cpp.
References _written, CHANGE, f, v, and WRITE.
Referenced by RWMemoryMember::operator=().
bool TraceValue::written | ( | ) | const |
Gives true if this value has been written at one point during the simulation.
Definition at line 96 of file traceval.cpp.
References _written.
Referenced by DumpVCD::valout().
friend class TraceKeeper [friend] |
Definition at line 183 of file traceval.h.
bool TraceValue::_enabled [private] |
Tracing of this value enabled at all?
Note that it must additionally be enabled in the particular Dumper.
Definition at line 207 of file traceval.h.
int TraceValue::_index [private] |
Definition at line 188 of file traceval.h.
Referenced by index().
std::string TraceValue::_name [private] |
Definition at line 186 of file traceval.h.
Referenced by barename(), and name().
bool TraceValue::_written [private] |
Initialized to zero upon creation and any logged write will make this true.
Definition at line 202 of file traceval.h.
Referenced by change(), cycle(), dump(), set_written(), write(), and written().
const unsigned TraceValue::b [private] |
int TraceValue::f [private] |
void* TraceValue::shadow [private] |
unsigned TraceValue::v [private] |
The value itself.
Definition at line 197 of file traceval.h.
Referenced by change(), cycle(), set_written(), value(), and write().