simulavr
1.1.0
|
#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, const void *shadow=NULL) | |
Generate a new unitialized trace value of width bits. More... | |
virtual | ~TraceValue () |
size_t | bits () const |
Give number of bits for this value. Max 32. More... | |
unsigned | value () const |
Gives the saved shadow value for this trace value. More... | |
std::string | name () const |
Give name (fully qualified), including the index appended if it is >=0. More... | |
std::string | barename () const |
Gives the name without the index. More... | |
int | index () const |
Gives the index of this member in a memory field (or -1) More... | |
bool | enabled () const |
void | enable () |
Enable tracing. More... | |
void | change (unsigned val) |
Log a change on this value. More... | |
void | change (unsigned val, unsigned mask) |
void | write (unsigned val) |
Log a write access on this value. More... | |
void | read () |
Log a read access. More... | |
bool | written () const |
void | set_written () |
void | set_written (unsigned val) |
Atype | flags () const |
Gives the current set of flag readings. More... | |
virtual void | cycle () |
Called at least once for each cycle if this trace value is activated. More... | |
virtual void | dump (Dumper &d) |
virtual char | VcdBit (int bitNo) const |
Protected Member Functions | |
void | clear_flags () |
Clear all access flags. More... | |
Private Attributes | |
std::string | _name |
int | _index |
const unsigned | b |
number of bits More... | |
const void * | shadow |
shadow reg, if used More... | |
unsigned | v |
The value itself. More... | |
int | f |
accesses since last dump/clearflagsd More... | |
bool | _written |
bool | _enabled |
Tracing of this value enabled at all? More... | |
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.
Enumerator | |
---|---|
READ | |
WRITE | |
CHANGE |
Definition at line 131 of file traceval.h.
TraceValue::TraceValue | ( | size_t | bits, |
const std::string & | _name, | ||
const int | __index = -1 , |
||
const void * | shadow = NULL |
||
) |
Generate a new unitialized trace value of width bits.
Definition at line 37 of file traceval.cpp.
|
inlinevirtual |
Definition at line 110 of file traceval.h.
References barename(), bits(), index(), name(), shadow, and value().
std::string TraceValue::barename | ( | ) | const |
Gives the name without the index.
Definition at line 58 of file traceval.cpp.
References _name.
Referenced by DumpManager::save(), and ~TraceValue().
size_t TraceValue::bits | ( | ) | const |
Give number of bits for this value. Max 32.
Definition at line 50 of file traceval.cpp.
References b.
Referenced by DumpVCD::valout(), and ~TraceValue().
void TraceValue::change | ( | unsigned | val | ) |
Log a change on this value.
Definition at line 68 of file traceval.cpp.
References _written, CHANGE, f, and v.
Referenced by HWPort::CalcOutputs(), BasicTimerUnit::CountTimer(), HWTimerTinyX5::DeadTimePrescalerMux(), IOReg< HWTimer8_0C >::hardwareChange(), IOSpecialReg::hardwareChange(), IOSpecialReg::hardwareChangeMask(), HWTimerTinyX5::PrescalerMux(), BasicTimerUnit::SetCounter(), HWPort::SetPinBit(), and HWTimerTinyX5::TimerCounter().
void TraceValue::change | ( | unsigned | val, |
unsigned | mask | ||
) |
|
protected |
Clear all access flags.
|
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 110 of file traceval.cpp.
References _written, avr_error, b, CHANGE, f, shadow, and v.
|
virtual |
Dump the state or state change somewhere. This also resets the current flags.
Definition at line 134 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 64 of file traceval.cpp.
References _enabled.
Referenced by Dumper::~Dumper().
TraceValue::Atype TraceValue::flags | ( | ) | const |
int TraceValue::index | ( | ) | const |
Gives the index of this member in a memory field (or -1)
Definition at line 60 of file traceval.cpp.
References _index.
Referenced by name(), TraceValueCoreRegister::RegisterTraceSetValue(), DumpManager::save(), and ~TraceValue().
std::string TraceValue::name | ( | ) | const |
Give name (fully qualified), including the index appended if it is >=0.
Definition at line 52 of file traceval.cpp.
References _name, index(), and int2str().
Referenced by IOReg< HWTimer8_0C >::clear_bit(), IOReg< HWTimer8_0C >::get(), TraceValueRegister::GetScopeName(), WarnUnknown::markReadUnknown(), TraceValueRegister::RegisterTraceValue(), IOReg< HWTimer8_0C >::set(), IOReg< HWTimer8_0C >::set_bit(), TraceValueRegister::UnregisterTraceValue(), and ~TraceValue().
void TraceValue::read | ( | ) |
Log a read access.
Definition at line 93 of file traceval.cpp.
Referenced by RWMemoryMember::operator unsigned char(), and RWMemoryMember::operator=().
void TraceValue::set_written | ( | ) |
Just set the written flag for tracevalues which are automatically initialized (IO registers etc.)
Definition at line 99 of file traceval.cpp.
References _written.
Referenced by BasicTimerUnit::BasicTimerUnit(), HWIrqSystem::HWIrqSystem(), HWPort::HWPort(), HWTimerTinyX5::HWTimerTinyX5(), IOReg< HWTimer8_0C >::IOReg(), and IOSpecialReg::Reset().
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 103 of file traceval.cpp.
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 62 of file traceval.cpp.
References v.
Referenced by TraceValueOutput::VcdBit(), and ~TraceValue().
|
virtual |
Give back VCD coding of a bit
Reimplemented in TraceValueOutput.
Definition at line 149 of file traceval.cpp.
Referenced by TraceValueOutput::TraceValueOutput(), and DumpVCD::valout().
void TraceValue::write | ( | unsigned | val | ) |
Log a write access on this value.
Definition at line 84 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 97 of file traceval.cpp.
References _written.
Referenced by TraceValueOutput::VcdBit().
|
friend |
Definition at line 187 of file traceval.h.
|
private |
Tracing of this value enabled at all?
Note that it must additionally be enabled in the particular Dumper.
Definition at line 211 of file traceval.h.
|
private |
Definition at line 192 of file traceval.h.
Referenced by index().
|
private |
Definition at line 190 of file traceval.h.
Referenced by barename(), and name().
|
private |
Initialized to zero upon creation and any logged write will make this true.
Definition at line 206 of file traceval.h.
Referenced by change(), cycle(), dump(), set_written(), VcdBit(), write(), and written().
|
private |
|
private |
|
private |
shadow reg, if used
Definition at line 198 of file traceval.h.
Referenced by cycle(), and ~TraceValue().
|
private |
The value itself.
Definition at line 201 of file traceval.h.
Referenced by TraceValueRegister::_tvr_registerTraceValues(), change(), cycle(), TraceValueRegister::RegisterTraceValue(), set_written(), value(), VcdBit(), and write().