simulavr  1.1.0
TraceValue Class Reference

#include <traceval.h>

Inheritance diagram for TraceValue:

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
 

Detailed Description

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.

Member Enumeration Documentation

◆ Atype

Possible access types for a trace value.

Enumerator
READ 
WRITE 
CHANGE 

Definition at line 131 of file traceval.h.

Constructor & Destructor Documentation

◆ TraceValue()

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.

◆ ~TraceValue()

virtual TraceValue::~TraceValue ( )
inlinevirtual

Definition at line 110 of file traceval.h.

References barename(), bits(), index(), name(), shadow, and value().

Member Function Documentation

◆ barename()

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().

◆ bits()

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().

◆ change() [1/2]

◆ change() [2/2]

void TraceValue::change ( unsigned  val,
unsigned  mask 
)

Definition at line 76 of file traceval.cpp.

References _written, CHANGE, f, and v.

◆ clear_flags()

void TraceValue::clear_flags ( )
protected

Clear all access flags.

◆ cycle()

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 110 of file traceval.cpp.

References _written, avr_error, b, CHANGE, f, shadow, and v.

◆ dump()

void TraceValue::dump ( Dumper d)
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.

◆ enable()

void TraceValue::enable ( )

Enable tracing.

Definition at line 66 of file traceval.cpp.

References _enabled.

◆ enabled()

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().

◆ flags()

TraceValue::Atype TraceValue::flags ( ) const

Gives the current set of flag readings.

Definition at line 108 of file traceval.cpp.

References f.

◆ index()

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().

◆ name()

◆ read()

void TraceValue::read ( )

Log a read access.

Definition at line 93 of file traceval.cpp.

References f, and READ.

Referenced by RWMemoryMember::operator unsigned char(), and RWMemoryMember::operator=().

◆ set_written() [1/2]

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().

◆ set_written() [2/2]

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.

References _written, and v.

◆ value()

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().

◆ VcdBit()

char TraceValue::VcdBit ( int  bitNo) const
virtual

Give back VCD coding of a bit

Reimplemented in TraceValueOutput.

Definition at line 149 of file traceval.cpp.

References _written, and v.

Referenced by TraceValueOutput::TraceValueOutput(), and DumpVCD::valout().

◆ write()

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=().

◆ written()

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().

Friends And Related Function Documentation

◆ TraceKeeper

friend class TraceKeeper
friend

Definition at line 187 of file traceval.h.

Member Data Documentation

◆ _enabled

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 211 of file traceval.h.

Referenced by enable(), and enabled().

◆ _index

int TraceValue::_index
private

Definition at line 192 of file traceval.h.

Referenced by index().

◆ _name

std::string TraceValue::_name
private

Definition at line 190 of file traceval.h.

Referenced by barename(), and name().

◆ _written

bool TraceValue::_written
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().

◆ b

const unsigned TraceValue::b
private

number of bits

Definition at line 195 of file traceval.h.

Referenced by bits(), and cycle().

◆ f

int TraceValue::f
private

accesses since last dump/clearflagsd

Definition at line 203 of file traceval.h.

Referenced by change(), cycle(), dump(), flags(), read(), and write().

◆ shadow

const void* TraceValue::shadow
private

shadow reg, if used

Definition at line 198 of file traceval.h.

Referenced by cycle(), and ~TraceValue().

◆ v

unsigned TraceValue::v
private

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