ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
|
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>
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 More... | |
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< Field > | findName (const std::string &name) const |
std::shared_ptr< Field > | findPrettyName (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< VirtualStruct > | findStruct (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 More... | |
virtual std::list< std::string > | listSubInjectors () |
list all sub injectors. More... | |
virtual std::shared_ptr< etiss::fault::Injector > | getSubInjector (const std::string &name) |
get a sub injector. More... | |
virtual std::shared_ptr< etiss::fault::Injector > | getParentInjector () |
get a the parent injector (root returns 0). More... | |
virtual bool | acceleratedTrigger (const etiss::fault::Trigger &, int32_t fault_id) |
std::shared_ptr< VirtualStruct > | getVirtualStruct (const std::string &path) |
std::shared_ptr< VirtualStruct::Field > | getResolvedField (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. More... | |
virtual std::string | getInjectorPath () |
returns the path of the current object. More... | |
void | addTrigger (const Trigger &t, int32_t fault_id) |
> Triggers to look at in callbacks More... | |
Static Public Member Functions | |
static std::shared_ptr< VirtualStruct > | allocate (void *structure, std::function< void(Field *)> delete_) |
static std::shared_ptr< VirtualStruct > | root () |
static std::shared_ptr< 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) |
implemented in CVirtualStruct.cpp More... | |
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 More... | |
void *const | structure_ |
std::function< bool(const etiss::fault::Trigger &, int32_t)> | acceleratedTrigger_ |
Protected Member Functions | |
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 More... | |
virtual bool | applyAction (const etiss::fault::Fault &fault, const etiss::fault::Action &action, std::string &errormsg) |
Private Member Functions | |
VirtualStruct (void *structure, std::function< void(Field *)> dtor=[](Field *f) { delete f;}) | |
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< VirtualStruct > | parent_ |
Friends | |
class | VSSync |
Additional Inherited Members | |
Public Types inherited from etiss::fault::Injector | |
typedef Injector * | ptr |
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 hirachy. 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
Definition at line 139 of file VirtualStruct.h.
|
private |
Definition at line 232 of file VirtualStruct.cpp.
Referenced by allocate().
|
virtual |
Definition at line 236 of file VirtualStruct.cpp.
References close(), dtor_, etiss::ERROR, fields_, and etiss::log().
|
virtual |
Reimplemented from etiss::fault::Injector.
Definition at line 341 of file VirtualStruct.cpp.
References acceleratedTrigger_.
|
inline |
Definition at line 328 of file VirtualStruct.h.
References addField(), etiss::VirtualStruct::Field::L, etiss::VirtualStruct::Field::R, uint64_t, v, and etiss::VirtualStruct::Field::W.
|
inline |
add a structure field to this VirtualStructure
Definition at line 313 of file VirtualStruct.h.
References addField().
bool etiss::VirtualStruct::addField | ( | VirtualStruct::Field * | f, |
bool | noerrorprint = false |
||
) |
Definition at line 264 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().
|
static |
Definition at line 596 of file VirtualStruct.cpp.
References VirtualStruct().
Referenced by allocateFromC(), RV32IMACFDArch::getVirtualStruct(), RV64IMACFDArch::getVirtualStruct(), and root().
|
static |
implemented in CVirtualStruct.cpp
TODO
Definition at line 69 of file CVirtualStruct.cpp.
References allocate(), etiss::ERROR, etiss::VirtualStruct::Field::L, etiss::log(), etiss::VirtualStruct::Field::P, etiss::parseName(), etiss::VirtualStruct::Field::R, and etiss::VirtualStruct::Field::W.
|
protectedvirtual |
Implements etiss::fault::Injector.
Definition at line 464 of file VirtualStruct.cpp.
References etiss::VirtualStruct::Field::A, etiss::VirtualStruct::Field::applyAction(), etiss::VirtualStruct::Field::applyBitflip(), applyCustomAction, etiss::fault::Action::BITFLIP, etiss::fault::Action::COMMAND, etiss::VirtualStruct::Field::F, fieldNames_, fieldPrettyNames_, etiss::VirtualStruct::Field::flags_, etiss::fault::Injector::getInjectorPath(), etiss::fault::Action::getTargetBit(), etiss::fault::Action::getTargetField(), etiss::fault::Action::getType(), and etiss::fault::Fault::id_.
void etiss::VirtualStruct::close | ( | ) |
Definition at line 396 of file VirtualStruct.cpp.
References closed.
Referenced by ~VirtualStruct().
|
protectedvirtual |
Implements etiss::fault::Injector.
Definition at line 433 of file VirtualStruct.cpp.
References fieldNames_, and fieldPrettyNames_.
std::shared_ptr< VirtualStruct::Field > etiss::VirtualStruct::findName | ( | const std::string & | name | ) | const |
Definition at line 303 of file VirtualStruct.cpp.
References closed, and fieldNames_.
Referenced by etiss::copy().
std::shared_ptr< VirtualStruct::Field > etiss::VirtualStruct::findPrettyName | ( | const std::string & | name | ) | const |
Definition at line 317 of file VirtualStruct.cpp.
References closed, and fieldPrettyNames_.
std::shared_ptr< VirtualStruct > etiss::VirtualStruct::findStruct | ( | const std::string & | name | ) |
Definition at line 374 of file VirtualStruct.cpp.
References subStructs_.
Referenced by getSubInjector().
void etiss::VirtualStruct::foreachField | ( | const std::function< void(std::shared_ptr< Field >)> & | func | ) |
Definition at line 330 of file VirtualStruct.cpp.
References closed, and fields_.
Referenced by etiss::copy(), and listFields().
void etiss::VirtualStruct::foreachStruct | ( | const std::function< void(const std::string &name, VirtualStruct &vs)> & | func | ) |
Definition at line 382 of file VirtualStruct.cpp.
References subStructs_.
Referenced by listSubInjectors().
|
virtual |
get a the parent injector (root returns 0).
in case of c++11 this function returns a smart pointer (std::shared_ptr<Injector>)
Implements etiss::fault::Injector.
Definition at line 428 of file VirtualStruct.cpp.
References parent_.
std::shared_ptr< VirtualStruct::Field > etiss::VirtualStruct::getResolvedField | ( | const std::string & | path | ) |
Definition at line 660 of file VirtualStruct.cpp.
References getVirtualStruct().
|
virtual |
get a sub injector.
in case of c++11 this function returns a smart pointer (std::shared_ptr<Injector>)
Implements etiss::fault::Injector.
Definition at line 424 of file VirtualStruct.cpp.
References findStruct().
std::shared_ptr< VirtualStruct > etiss::VirtualStruct::getVirtualStruct | ( | const std::string & | path | ) |
Definition at line 609 of file VirtualStruct.cpp.
References parent_, and subStructs_.
Referenced by getResolvedField().
bool etiss::VirtualStruct::isClosed | ( | ) |
Definition at line 402 of file VirtualStruct.cpp.
References closed.
|
virtual |
list all fields directly reachable by this injector
Implements etiss::fault::Injector.
Definition at line 408 of file VirtualStruct.cpp.
References foreachField().
|
virtual |
list all sub injectors.
Implements etiss::fault::Injector.
Definition at line 417 of file VirtualStruct.cpp.
References foreachStruct().
bool etiss::VirtualStruct::mountStruct | ( | const std::string & | name, |
const std::shared_ptr< VirtualStruct > | vs | ||
) |
Definition at line 352 of file VirtualStruct.cpp.
References subStructs_.
|
protectedvirtual |
read the value of a field
Implements etiss::fault::Injector.
Definition at line 448 of file VirtualStruct.cpp.
References etiss::VirtualStruct::Field::flags_, etiss::VirtualStruct::Field::R, and etiss::VirtualStruct::Field::read().
|
static |
Definition at line 603 of file VirtualStruct.cpp.
References allocate().
Referenced by etiss::fault::Injector::get(), and main().
|
friend |
Definition at line 141 of file VirtualStruct.h.
std::function<bool(const etiss::fault::Trigger &, int32_t)> etiss::VirtualStruct::acceleratedTrigger_ |
Definition at line 380 of file VirtualStruct.h.
Referenced by acceleratedTrigger().
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 376 of file VirtualStruct.h.
Referenced by applyAction().
|
private |
Definition at line 388 of file VirtualStruct.h.
Referenced by close(), findName(), findPrettyName(), foreachField(), and isClosed().
|
private |
Definition at line 387 of file VirtualStruct.h.
Referenced by ~VirtualStruct().
|
private |
Definition at line 384 of file VirtualStruct.h.
Referenced by addField(), applyAction(), fastFieldAccessPtr(), and findName().
|
private |
Definition at line 385 of file VirtualStruct.h.
Referenced by addField(), applyAction(), fastFieldAccessPtr(), and findPrettyName().
|
private |
Definition at line 383 of file VirtualStruct.h.
Referenced by addField(), foreachField(), and ~VirtualStruct().
|
private |
Definition at line 391 of file VirtualStruct.h.
Referenced by getParentInjector(), and getVirtualStruct().
void* const etiss::VirtualStruct::structure_ |
Definition at line 379 of file VirtualStruct.h.
Referenced by RegField_RV32IMACFD::_read(), pcField_RV32IMACFD::_read(), RegField_RV64IMACFD::_read(), pcField_RV64IMACFD::_read(), etiss::VirtualStruct::FieldT< structT, retT, field >::_read(), RegField_RV32IMACFD::_write(), pcField_RV32IMACFD::_write(), RegField_RV64IMACFD::_write(), pcField_RV64IMACFD::_write(), and etiss::VirtualStruct::FieldT< structT, retT, field >::_write().
|
private |
Definition at line 386 of file VirtualStruct.h.
Referenced by findStruct(), foreachStruct(), getVirtualStruct(), and mountStruct().