CIRCT  19.0.0git
Public Member Functions | Private Attributes | List of all members
circt::llhd::sim::Signal Class Reference

The simulator's internal representation of a signal. More...

#include <State.h>

Collaboration diagram for circt::llhd::sim::Signal:
Collaboration graph
[legend]

Public Member Functions

 Signal (std::string name, std::string owner)
 Construct an "empty" signal. More...
 
 Signal (std::string name, std::string owner, uint8_t *value, uint64_t size)
 Construct a signal with the given name, owner and initial value. More...
 
 Signal (Signal &&)=default
 Default move constructor. More...
 
 ~Signal ()
 Free 'value' since it is allocated using 'malloc' in the LLVM code generated by LLHDToLLVM. More...
 
bool operator== (const Signal &rhs) const
 Returns true if the signals match in name, owner, size and value. More...
 
bool operator< (const Signal &rhs) const
 Returns true if the owner name is lexically smaller than rhs's owner, or the name is lexically smaller than rhs's name, in case they share the same owner. More...
 
bool isOwner (const std::string &rhs) const
 
std::string getOwner () const
 
bool isValidSigName () const
 
std::string getName () const
 
uint64_t getSize () const
 
uint8_t * getValue () const
 
const std::vector< unsigned > & getTriggeredInstanceIndices () const
 
void pushInstanceIndex (unsigned i)
 
bool hasElement () const
 
size_t getElementSize () const
 
void pushElement (std::pair< unsigned, unsigned > val)
 
void store (uint8_t *v, uint64_t s)
 Store JIT allocated signal pointer and size. More...
 
bool updateWhenChanged (const uint64_t *v)
 Update signal value when it is changed, the width of incoming signal value and the stored signal value are identical. More...
 
std::string toHexString () const
 Return the value of the signal in hexadecimal string format. More...
 
std::string toHexString (unsigned) const
 Return the value of the i-th element of the signal in hexadecimal string format. More...
 

Private Attributes

std::string name
 
std::string owner
 
std::vector< unsigned > instanceIndices
 
uint64_t size
 
uint8_t * value
 
std::vector< std::pair< unsigned, unsigned > > elements
 

Detailed Description

The simulator's internal representation of a signal.

Definition at line 76 of file State.h.

Constructor & Destructor Documentation

◆ Signal() [1/3]

circt::llhd::sim::Signal::Signal ( std::string  name,
std::string  owner 
)
inline

Construct an "empty" signal.

Definition at line 79 of file State.h.

◆ Signal() [2/3]

circt::llhd::sim::Signal::Signal ( std::string  name,
std::string  owner,
uint8_t *  value,
uint64_t  size 
)
inline

Construct a signal with the given name, owner and initial value.

Definition at line 83 of file State.h.

◆ Signal() [3/3]

circt::llhd::sim::Signal::Signal ( Signal &&  )
default

Default move constructor.

◆ ~Signal()

Signal::~Signal ( )

Free 'value' since it is allocated using 'malloc' in the LLVM code generated by LLHDToLLVM.

Definition at line 60 of file State.cpp.

Member Function Documentation

◆ getElementSize()

size_t circt::llhd::sim::Signal::getElementSize ( ) const
inline

Definition at line 129 of file State.h.

References elements.

◆ getName()

std::string circt::llhd::sim::Signal::getName ( ) const
inline

Definition at line 115 of file State.h.

References name.

◆ getOwner()

std::string circt::llhd::sim::Signal::getOwner ( ) const
inline

Definition at line 109 of file State.h.

References owner.

◆ getSize()

uint64_t circt::llhd::sim::Signal::getSize ( ) const
inline

Definition at line 117 of file State.h.

References size.

◆ getTriggeredInstanceIndices()

const std::vector<unsigned>& circt::llhd::sim::Signal::getTriggeredInstanceIndices ( ) const
inline

Definition at line 121 of file State.h.

References instanceIndices.

◆ getValue()

uint8_t* circt::llhd::sim::Signal::getValue ( ) const
inline

Definition at line 119 of file State.h.

References value.

◆ hasElement()

bool circt::llhd::sim::Signal::hasElement ( ) const
inline

Definition at line 127 of file State.h.

References elements.

◆ isOwner()

bool circt::llhd::sim::Signal::isOwner ( const std::string &  rhs) const
inline

Definition at line 107 of file State.h.

References owner.

◆ isValidSigName()

bool circt::llhd::sim::Signal::isValidSigName ( ) const
inline

Definition at line 111 of file State.h.

References name.

◆ operator<()

bool circt::llhd::sim::Signal::operator< ( const Signal rhs) const
inline

Returns true if the owner name is lexically smaller than rhs's owner, or the name is lexically smaller than rhs's name, in case they share the same owner.

Definition at line 103 of file State.h.

References name, and owner.

◆ operator==()

bool circt::llhd::sim::Signal::operator== ( const Signal rhs) const
inline

Returns true if the signals match in name, owner, size and value.

Definition at line 94 of file State.h.

References name, owner, size, and value.

◆ pushElement()

void circt::llhd::sim::Signal::pushElement ( std::pair< unsigned, unsigned >  val)
inline

Definition at line 131 of file State.h.

References elements.

◆ pushInstanceIndex()

void circt::llhd::sim::Signal::pushInstanceIndex ( unsigned  i)
inline

Definition at line 125 of file State.h.

References instanceIndices.

◆ store()

void circt::llhd::sim::Signal::store ( uint8_t *  v,
uint64_t  s 
)
inline

Store JIT allocated signal pointer and size.

Definition at line 136 of file State.h.

References size, and value.

◆ toHexString() [1/2]

std::string Signal::toHexString ( ) const

Return the value of the signal in hexadecimal string format.

Definition at line 37 of file State.cpp.

◆ toHexString() [2/2]

std::string Signal::toHexString ( unsigned  elemIndex) const

Return the value of the i-th element of the signal in hexadecimal string format.

Definition at line 47 of file State.cpp.

References assert().

◆ updateWhenChanged()

bool circt::llhd::sim::Signal::updateWhenChanged ( const uint64_t *  v)
inline

Update signal value when it is changed, the width of incoming signal value and the stored signal value are identical.

As majority signals are smaller than 64 bits, this implementation is much faster as it avoided memcpy in most cases.

Parameters
vPointer to signal value
Returns
true when signal is updated, false when not

Definition at line 147 of file State.h.

References size, and value.

Member Data Documentation

◆ elements

std::vector<std::pair<unsigned, unsigned> > circt::llhd::sim::Signal::elements
private

Definition at line 201 of file State.h.

Referenced by getElementSize(), hasElement(), and pushElement().

◆ instanceIndices

std::vector<unsigned> circt::llhd::sim::Signal::instanceIndices
private

Definition at line 198 of file State.h.

Referenced by getTriggeredInstanceIndices(), and pushInstanceIndex().

◆ name

std::string circt::llhd::sim::Signal::name
private

Definition at line 195 of file State.h.

Referenced by getName(), isValidSigName(), operator<(), and operator==().

◆ owner

std::string circt::llhd::sim::Signal::owner
private

Definition at line 196 of file State.h.

Referenced by getOwner(), isOwner(), operator<(), and operator==().

◆ size

uint64_t circt::llhd::sim::Signal::size
private

◆ value

uint8_t* circt::llhd::sim::Signal::value
private

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