ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | Friends | List of all members
etiss::VirtualStruct Class Reference

abstract representation of an module of a simulation which could be a embedded device of the cpu of an embedded device. More...

#include <VirtualStruct.h>

Inheritance diagram for etiss::VirtualStruct:
Inheritance graph
[legend]
Collaboration diagram for etiss::VirtualStruct:
Collaboration graph
[legend]

Classes

class  Field
 a Field instance represents e.g. More...
 
class  FieldT
 

Public Member Functions

virtual ~VirtualStruct ()
 
bool addField (Field *f, bool noerrorprint=false)
 
template<typename structT , typename retT , retT structT::* field>
bool addField (const std::string &name, const std::string &prettyname="", bool noerrorprint=false)
 add a structure field to this VirtualStructure
 
template<typename T >
bool addField (const std::string &name, const std::string &prettyname, std::function< T()> read, std::function< void(T)> write, bool supportsListener=false, bool noerrorprint=false)
 
std::shared_ptr< FieldfindName (const std::string &name) const
 
std::shared_ptr< FieldfindPrettyName (const std::string &name) const
 
void foreachField (const std::function< void(std::shared_ptr< Field >)> &func)
 
bool mountStruct (const std::string &name, const std::shared_ptr< VirtualStruct > vs)
 
std::shared_ptr< VirtualStructfindStruct (const std::string &name)
 
void foreachStruct (const std::function< void(const std::string &name, VirtualStruct &vs)> &func)
 
void close ()
 
bool isClosed ()
 
virtual std::list< std::string > listFields ()
 list all fields directly reachable by this injector
 
virtual std::list< std::string > listSubInjectors ()
 list all sub injectors.
 
virtual std::shared_ptr< etiss::fault::InjectorgetSubInjector (const std::string &name)
 get a sub injector.
 
virtual std::shared_ptr< etiss::fault::InjectorgetParentInjector ()
 get a the parent injector (root returns 0).
 
virtual bool acceleratedTrigger (const etiss::fault::Trigger &, int32_t fault_id)
 
std::shared_ptr< VirtualStructgetVirtualStruct (const std::string &path)
 
std::shared_ptr< VirtualStruct::FieldgetResolvedField (const std::string &path)
 
- Public Member Functions inherited from etiss::fault::Injector
 Injector ()
 
virtual ~Injector ()
 
virtual bool needsCallbacks ()
 
virtual bool cycleAccurateCallback (uint64_t time_ps)
 
virtual bool instructionAccurateCallback (uint64_t time_ps)
 
virtual void freeFastFieldAccessPtr (void *)
 MUST be called to cleanup a pointer acquired with fastFieldAccessPtr() default implementation is nop.
 
virtual std::string getInjectorPath ()
 returns the path of the current object.
 
void addTrigger (const Trigger &t, int32_t fault_id)
 TODO specialized lists. e.g. time triggers should be sorted and only the earliest time should be checked.
 
void removeTrigger (const Trigger &t, int32_t fault_id)
 

Static Public Member Functions

static std::shared_ptr< VirtualStructallocate (void *structure, std::function< void(Field *)> delete_)
 
static std::shared_ptr< VirtualStructroot ()
 
static std::shared_ptr< VirtualStructallocateFromC (void *handle, VirtualStruct_names names, VirtualStruct_prettyNames prettyNames_optional, VirtualStruct_read read_recommended, VirtualStruct_write write_optional, VirtualStruct_setListenerCallback setListenerCallback_optional, std::function< void(void *handle)> cleanup)
 implemented in CVirtualStruct.cpp
 
- Static Public Member Functions inherited from etiss::fault::Injector
static ptr get (const std::string &injectorPath)
 

Public Attributes

std::function< bool(const etiss::fault::Fault &, const etiss::fault::Action &, std::string &)> applyCustomAction
 set this function to handle custom commands passed by etiss::fault::Action of the type etiss::fault::Action::COMMAND
 
void *const structure_
 
std::function< bool(const etiss::fault::Trigger &, int32_t)> acceleratedTrigger_
 

Protected Member Functions

 VirtualStruct (void *structure, std::function< void(Field *)> dtor=[](Field *f) { delete f;})
 
virtual void * fastFieldAccessPtr (const std::string &name, std::string &errormsg)
 
virtual bool readField (void *fastfieldaccessptr, uint64_t &val, std::string &errormsg)
 read the value of a field
 
virtual bool applyAction (const etiss::fault::Fault &fault, const etiss::fault::Action &action, std::string &errormsg)
 
virtual bool update_field_access_rights (const etiss::fault::Action &action, std::string &errormsg)
 Update the field of injector with access rights to allow action (used to get type of action).
 

Private Attributes

std::list< Field * > fields_
 
std::map< std::string, Field * > fieldNames_
 
std::map< std::string, Field * > fieldPrettyNames_
 
std::map< std::string, std::weak_ptr< VirtualStruct > > subStructs_
 
std::function< void(Field *)> dtor_
 
bool closed
 
std::shared_ptr< VirtualStructparent_
 

Friends

class VSSync
 

Additional Inherited Members

- Public Types inherited from etiss::fault::Injector
typedef Injectorptr
 

Detailed Description

abstract representation of an module of a simulation which could be a embedded device of the cpu of an embedded device.

it is recommended to model and address the full hardware hierachy. e.g.

 device1
            -> cpu
                -> cache
            -> bus
            -> memory
                -> bank1
                -> bank2

        example address: "device1::cpu::cache"
    

To resolve a path to a VirtualStruct use VirtualStruct::root()->getVirtualStruct("device1::cpu::cache");

Fields of a VirtualStruct can be addressed by appending ".FIELDNAME" to the pass and pass it to getResolvedField(). e.g. VirtualStruct::root()->getResolvedField("device1::cpu::cache.tag1");

Syntax (Wirth syntax notation):

    module_path_to_field:   module_path "." { ASCII-character }
    module_path:            module_name { "::" module_name } .
    module_name:            letter { digit | letter } .
    letter:                 "a" | "A" | "b" | "B" | ... | "z" | "Z" .
    digit:                  "0" | "1" | "2" | "3" | "4" | "5" | "6" | 7" | "8" |
"9" .

    module_path_to_field is the full path to a field.
    module_path is always relative to the current module

EXTENSION for absolute paths:

    absolute_module_path_to_field:  "::" module_path_to_field
    absolute_module_path:           "::" module_path .

    absolute module path will NOT use root()!
        it will traverse from the current module upward until no parent exists
and then the path will be resolved


the tree of modules uses weak/shared pointers to create a tree that will clean itself up as soon as possible depending on the lifetime of the virtual structs that were associated with said module.

weak reference: –> ( x holds a weak reference to y [x.weak_ptr = y]) strong reference: x -> y ( x holds a strong reference to y [x.shared_ptr = y])

Relations:

    VirtualStruct
        --> <- VirtualStruct
            --> <- VirtualStruct

    VirtualStruct holds a weak reference to child VirtualStructs and a child VirtualStruct holds a strong reference to
VirtualStruct. Module holds a weak reference to a child Module and a child Module holds a strong reference to parent
Module VirtualStructs are deleted if the original shared_ptr is deleted, there is no child and there is no shared_ptr to
a field




Attention
: while VirtualStruct won't throw exceptions by itself, VirtualStruct::Field will throw exception upon invalid access or if the associated VirtualStruct has been closed

Definition at line 101 of file VirtualStruct.h.

Constructor & Destructor Documentation

◆ VirtualStruct()

etiss::VirtualStruct::VirtualStruct ( void *  structure,
std::function< void(Field *)>  dtor = [](Field *f) { delete f; } 
)
protected

Definition at line 236 of file VirtualStruct.cpp.

◆ ~VirtualStruct()

etiss::VirtualStruct::~VirtualStruct ( )
virtual

Definition at line 240 of file VirtualStruct.cpp.

References close(), dtor_, etiss::ERROR, fields_, and etiss::log().

Here is the call graph for this function:

Member Function Documentation

◆ acceleratedTrigger()

bool etiss::VirtualStruct::acceleratedTrigger ( const etiss::fault::Trigger t,
int32_t  fault_id 
)
virtual

Reimplemented from etiss::fault::Injector.

Definition at line 345 of file VirtualStruct.cpp.

References acceleratedTrigger_.

◆ addField() [1/3]

template<typename T >
bool etiss::VirtualStruct::addField ( const std::string &  name,
const std::string &  prettyname,
std::function< T()>  read,
std::function< void(T)>  write,
bool  supportsListener = false,
bool  noerrorprint = false 
)
inline

Definition at line 303 of file VirtualStruct.h.

References addField(), etiss::VirtualStruct::Field::L, etiss::VirtualStruct::Field::R, uint64_t, v, and etiss::VirtualStruct::Field::W.

Here is the call graph for this function:

◆ addField() [2/3]

template<typename structT , typename retT , retT structT::* field>
bool etiss::VirtualStruct::addField ( const std::string &  name,
const std::string &  prettyname = "",
bool  noerrorprint = false 
)
inline

add a structure field to this VirtualStructure

Definition at line 288 of file VirtualStruct.h.

References addField().

Here is the call graph for this function:

◆ addField() [3/3]

bool etiss::VirtualStruct::addField ( VirtualStruct::Field f,
bool  noerrorprint = false 
)

Definition at line 268 of file VirtualStruct.cpp.

References etiss::ERROR, ETISS_SRCLOC, fieldNames_, fieldPrettyNames_, fields_, etiss::log(), etiss::VirtualStruct::Field::name_, etiss::VirtualStruct::Field::prettyname_, and etiss::VERBOSE.

Referenced by addField(), and addField().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ allocate()

std::shared_ptr< VirtualStruct > etiss::VirtualStruct::allocate ( void *  structure,
std::function< void(Field *)>  delete_ 
)
static

Definition at line 647 of file VirtualStruct.cpp.

Referenced by allocateFromC(), etiss::MemoryManipulationSystem::getStruct(), RV32IMACFDArch::getVirtualStruct(), RV64IMACFDArch::getVirtualStruct(), and root().

Here is the caller graph for this function:

◆ allocateFromC()

std::shared_ptr< VirtualStruct > etiss::VirtualStruct::allocateFromC ( void *  handle,
VirtualStruct_names  names,
VirtualStruct_prettyNames  prettyNames_optional,
VirtualStruct_read  read_recommended,
VirtualStruct_write  write_optional,
VirtualStruct_setListenerCallback  setListenerCallback_optional,
std::function< void(void *handle)>  cleanup 
)
static

◆ applyAction()

bool etiss::VirtualStruct::applyAction ( const etiss::fault::Fault fault,
const etiss::fault::Action action,
std::string &  errormsg 
)
protectedvirtual
Returns
true if action could be applied
Attention
MUST NOT be called from without the callback functions cycleAccurateCallback() and instructionAccurateCallback(). The assumption of a singlethreaded access/use of these functions MUST hold.

Implements etiss::fault::Injector.

Definition at line 470 of file VirtualStruct.cpp.

References etiss::VirtualStruct::Field::A, etiss::VirtualStruct::Field::applyAction(), applyCustomAction, etiss::VirtualStruct::Field::F, fieldNames_, fieldPrettyNames_, etiss::VirtualStruct::Field::flags_, etiss::fault::Injector::getInjectorPath(), etiss::fault::Action::getTargetField(), and etiss::fault::Action::getType().

Here is the call graph for this function:

◆ close()

void etiss::VirtualStruct::close ( )

Definition at line 400 of file VirtualStruct.cpp.

References closed.

Referenced by ~VirtualStruct().

Here is the caller graph for this function:

◆ fastFieldAccessPtr()

void * etiss::VirtualStruct::fastFieldAccessPtr ( const std::string &  name,
std::string &  errormsg 
)
protectedvirtual
Attention
MUST NOT be called from without the callback functions cycleAccurateCallback() and instructionAccurateCallback(). The assumption of a singlethreaded access/use of these functions MUST hold.
Returns
0 in case of failure. otherwise an internal pointer shall be retuned that allows to access a field in a quick manner. freefastFieldAccessPtr MUST be called after use.

Implements etiss::fault::Injector.

Definition at line 439 of file VirtualStruct.cpp.

References fieldNames_, and fieldPrettyNames_.

◆ findName()

std::shared_ptr< VirtualStruct::Field > etiss::VirtualStruct::findName ( const std::string &  name) const

Definition at line 307 of file VirtualStruct.cpp.

References closed, and fieldNames_.

Referenced by etiss::copy().

Here is the caller graph for this function:

◆ findPrettyName()

std::shared_ptr< VirtualStruct::Field > etiss::VirtualStruct::findPrettyName ( const std::string &  name) const

Definition at line 321 of file VirtualStruct.cpp.

References closed, and fieldPrettyNames_.

◆ findStruct()

std::shared_ptr< VirtualStruct > etiss::VirtualStruct::findStruct ( const std::string &  name)

Definition at line 378 of file VirtualStruct.cpp.

References subStructs_.

Referenced by getSubInjector().

Here is the caller graph for this function:

◆ foreachField()

void etiss::VirtualStruct::foreachField ( const std::function< void(std::shared_ptr< Field >)> &  func)

Definition at line 334 of file VirtualStruct.cpp.

References closed, and fields_.

Referenced by etiss::copy(), and listFields().

Here is the caller graph for this function:

◆ foreachStruct()

void etiss::VirtualStruct::foreachStruct ( const std::function< void(const std::string &name, VirtualStruct &vs)> &  func)

Definition at line 386 of file VirtualStruct.cpp.

References subStructs_.

Referenced by listSubInjectors().

Here is the caller graph for this function:

◆ getParentInjector()

std::shared_ptr< etiss::fault::Injector > etiss::VirtualStruct::getParentInjector ( )
virtual

get a the parent injector (root returns 0).

in case of c++11 this function returns a smart pointer (std::shared_ptr<Injector>)

See also
etiss::VirtualStruct for example implemention

Implements etiss::fault::Injector.

Definition at line 434 of file VirtualStruct.cpp.

References parent_.

◆ getResolvedField()

std::shared_ptr< VirtualStruct::Field > etiss::VirtualStruct::getResolvedField ( const std::string &  path)

Definition at line 711 of file VirtualStruct.cpp.

References getVirtualStruct().

Here is the call graph for this function:

◆ getSubInjector()

std::shared_ptr< etiss::fault::Injector > etiss::VirtualStruct::getSubInjector ( const std::string &  name)
virtual

get a sub injector.

in case of c++11 this function returns a smart pointer (std::shared_ptr<Injector>)

See also
etiss::VirtualStruct for example implemention

Implements etiss::fault::Injector.

Definition at line 430 of file VirtualStruct.cpp.

References findStruct().

Here is the call graph for this function:

◆ getVirtualStruct()

std::shared_ptr< VirtualStruct > etiss::VirtualStruct::getVirtualStruct ( const std::string &  path)

Definition at line 660 of file VirtualStruct.cpp.

References parent_, and subStructs_.

Referenced by getResolvedField().

Here is the caller graph for this function:

◆ isClosed()

bool etiss::VirtualStruct::isClosed ( )

Definition at line 406 of file VirtualStruct.cpp.

References closed.

◆ listFields()

std::list< std::string > etiss::VirtualStruct::listFields ( )
virtual

list all fields directly reachable by this injector

See also
etiss::VirtualStruct for example implemention

Implements etiss::fault::Injector.

Definition at line 412 of file VirtualStruct.cpp.

References foreachField().

Here is the call graph for this function:

◆ listSubInjectors()

std::list< std::string > etiss::VirtualStruct::listSubInjectors ( )
virtual

list all sub injectors.

See also
etiss::VirtualStruct for example implemention

Implements etiss::fault::Injector.

Definition at line 423 of file VirtualStruct.cpp.

References foreachStruct().

Here is the call graph for this function:

◆ mountStruct()

bool etiss::VirtualStruct::mountStruct ( const std::string &  name,
const std::shared_ptr< VirtualStruct vs 
)

Definition at line 356 of file VirtualStruct.cpp.

References subStructs_.

◆ readField()

bool etiss::VirtualStruct::readField ( void *  fastfieldaccessptr,
uint64_t val,
std::string &  errormsg 
)
protectedvirtual

read the value of a field

Returns
true if read succeded
Attention
MUST NOT be called from outside the callback functions cycleAccurateCallback() and instructionAccurateCallback(). The assumption of a singlethreaded access/use of these functions MUST hold.

Implements etiss::fault::Injector.

Definition at line 454 of file VirtualStruct.cpp.

References etiss::VirtualStruct::Field::flags_, etiss::VirtualStruct::Field::R, and etiss::VirtualStruct::Field::read().

Here is the call graph for this function:

◆ root()

std::shared_ptr< VirtualStruct > etiss::VirtualStruct::root ( )
static

Definition at line 654 of file VirtualStruct.cpp.

References allocate().

Referenced by etiss::fault::Injector::get(), and etiss::initialize_virtualstruct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_field_access_rights()

bool etiss::VirtualStruct::update_field_access_rights ( const etiss::fault::Action action,
std::string &  errormsg 
)
protectedvirtual

Update the field of injector with access rights to allow action (used to get type of action).

For example, if action is of etiss::fault::Action::BITFLIP, field requires F flag set

Implements etiss::fault::Injector.

Definition at line 526 of file VirtualStruct.cpp.

References etiss::VirtualStruct::Field::F, fieldNames_, fieldPrettyNames_, etiss::VirtualStruct::Field::flags_, etiss::fault::Action::getTargetField(), and etiss::fault::Action::getType().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ VSSync

friend class VSSync
friend

Definition at line 103 of file VirtualStruct.h.

Member Data Documentation

◆ acceleratedTrigger_

std::function<bool(const etiss::fault::Trigger &, int32_t)> etiss::VirtualStruct::acceleratedTrigger_

Definition at line 357 of file VirtualStruct.h.

Referenced by acceleratedTrigger().

◆ applyCustomAction

std::function<bool(const etiss::fault::Fault &, const etiss::fault::Action &, std::string & )> etiss::VirtualStruct::applyCustomAction

set this function to handle custom commands passed by etiss::fault::Action of the type etiss::fault::Action::COMMAND

Definition at line 353 of file VirtualStruct.h.

Referenced by applyAction().

◆ closed

bool etiss::VirtualStruct::closed
private

Definition at line 365 of file VirtualStruct.h.

Referenced by close(), findName(), findPrettyName(), foreachField(), and isClosed().

◆ dtor_

std::function<void(Field *)> etiss::VirtualStruct::dtor_
private

Definition at line 364 of file VirtualStruct.h.

Referenced by ~VirtualStruct().

◆ fieldNames_

std::map<std::string, Field *> etiss::VirtualStruct::fieldNames_
private

◆ fieldPrettyNames_

std::map<std::string, Field *> etiss::VirtualStruct::fieldPrettyNames_
private

◆ fields_

std::list<Field *> etiss::VirtualStruct::fields_
private

Definition at line 360 of file VirtualStruct.h.

Referenced by addField(), foreachField(), and ~VirtualStruct().

◆ parent_

std::shared_ptr<VirtualStruct> etiss::VirtualStruct::parent_
private

Definition at line 368 of file VirtualStruct.h.

Referenced by getParentInjector(), and getVirtualStruct().

◆ structure_

void* const etiss::VirtualStruct::structure_

◆ subStructs_

std::map<std::string, std::weak_ptr<VirtualStruct> > etiss::VirtualStruct::subStructs_
private

Definition at line 363 of file VirtualStruct.h.

Referenced by findStruct(), foreachStruct(), getVirtualStruct(), and mountStruct().


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