ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
|
a Field instance represents e.g. More...
#include <VirtualStruct.h>
Classes | |
class | Listener |
NOTE: etiss::CPUArch should implement support for Listeners by either using the etiss::VirtualStruct::Field instance to write to listener supported field or it should call the signalWrite() functions of a Field. More... | |
struct | listener_pair_compare |
Public Types | |
enum | AccessMode { VIRTUAL , LAMBDA , PREFER_LAMBDA } |
defines how a field should perform reads/writes. More... | |
Public Member Functions | |
Field (VirtualStruct &parent, const std::string &name, const std::string &prettyname, int flags, size_t width, size_t bitwidth=0) | |
Field (VirtualStruct &parent, const std::string &name, const std::string &prettyname, int flags, size_t width, bool virtual_enabled, std::function< uint64_t()> lread, std::function< void(uint64_t)> lwrite, size_t bitwidth=0) | |
virtual | ~Field () |
uint64_t | read () const |
function to read bits/a value from the Field. More... | |
void | write (uint64_t) |
function to write bits/a value to the Field. More... | |
bool | applyBitflip (unsigned position, uint64_t fault_id) |
function to write a bitflip to a field More... | |
bool | applyAction (const etiss::fault::Fault &f, const etiss::fault::Action &a, std::string &errormsg) |
advanced fault injection. Field must have the A flag to use this. More... | |
void | signalWrite () |
this function should be called if the listener flag is set and the field changed without using the write() function. More... | |
Field * | setDeleteP (std::function< void(Field *)> del) |
Field & | setDelete (std::function< void(Field *)> del) |
bool | addListener (Listener *listener, std::shared_ptr< Listener > ref=nullptr) |
void | removeListener (Listener *listener, std::shared_ptr< Listener > ref=nullptr) |
Public Attributes | |
VirtualStruct & | parent_ |
reference to parent virtual struct More... | |
const std::string | name_ |
name of the field. More... | |
const std::string | prettyname_ |
alternative/human readable name of the field. More... | |
const int | flags_ |
read write flags as specified by the static const int parameters of Field: R,W,L More... | |
const size_t | width_ |
width in bytes (rounded up if neccessary) More... | |
const size_t | bitwidth_ |
width in bits More... | |
const AccessMode | accessMode_ |
std::function< bool(unsigned position, uint64_t fault_id)> | lapplyBitflip |
if this function is set the the default implementation of applyBitflip will use it More... | |
std::function< void(Field *)> | delete_ |
Static Public Attributes | |
static const int | R = 1 |
read flag More... | |
static const int | W = 2 |
write flag More... | |
static const int | RW = R | W |
flags to signal that a field supports read and write operations More... | |
static const int | L = 4 |
supports listener plugins; used for etiss::RegisterDevicePlugins to determine access to a variable/field More... | |
static const int | F = 8 |
supports fault injection/tracing More... | |
static const int | A = 16 |
supports advanced fault injection/tracing with the applyAction function More... | |
static const int | P = 32 |
private field: this flag indicates that this field is an implementation specific field that e.g. More... | |
Protected Member Functions | |
virtual uint64_t | _read () const |
override this function to implement reads in case of AccessMode::VIRTUAL / AccessMode::PREFER_LAMBDA More... | |
virtual void | _write (uint64_t) |
override this function to implement writes in case of AccessMode::VIRTUAL / AccessMode::PREFER_LAMBDA More... | |
virtual bool | _applyBitflip (unsigned position, uint64_t fault_id) |
override this function to implement bitflip applying to a field More... | |
virtual bool | _applyAction (const etiss::fault::Fault &f, const etiss::fault::Action &a, std::string &errormsg) |
override this function to implement advanced action handling More... | |
Protected Attributes | |
std::function< uint64_t()> | lread |
set this function for reads in case of AccessMode::LAMBDA / AccessMode::PREFER_LAMBDA More... | |
std::function< void(uint64_t)> | lwrite |
set this function for writes in case of AccessMode::LAMBDA / AccessMode::PREFER_LAMBDA More... | |
Private Attributes | |
std::set< std::pair< Listener *, std::shared_ptr< Listener > >, listener_pair_compare > | listeners |
a Field instance represents e.g.
a field in a structure, a variable/register in a model or anything that can be represented as a sequence of up to 64 bits
Definition at line 148 of file VirtualStruct.h.
defines how a field should perform reads/writes.
default: PREFER_LAMBDA
Enumerator | |
---|---|
VIRTUAL | uses the virtual _read() / _write functions |
LAMBDA | uses the lread,lwrite functions |
PREFER_LAMBDA | tries to use the lread,lwrite functions and falls back to virtual functions |
Definition at line 178 of file VirtualStruct.h.
etiss::VirtualStruct::Field::Field | ( | VirtualStruct & | parent, |
const std::string & | name, | ||
const std::string & | prettyname, | ||
int | flags, | ||
size_t | width, | ||
size_t | bitwidth = 0 |
||
) |
width | width of the field in bytes. rounded up in case of bitwidth missmatch |
bitwidth | width of the field in bits. if 0 then width*8 will be used for bitwidth_ |
Definition at line 50 of file VirtualStruct.cpp.
etiss::VirtualStruct::Field::Field | ( | VirtualStruct & | parent, |
const std::string & | name, | ||
const std::string & | prettyname, | ||
int | flags, | ||
size_t | width, | ||
bool | virtual_enabled, | ||
std::function< uint64_t()> | lread, | ||
std::function< void(uint64_t)> | lwrite, | ||
size_t | bitwidth = 0 |
||
) |
Definition at line 62 of file VirtualStruct.cpp.
|
virtual |
Definition at line 77 of file VirtualStruct.cpp.
|
protectedvirtual |
override this function to implement advanced action handling
Definition at line 214 of file VirtualStruct.cpp.
|
protectedvirtual |
override this function to implement bitflip applying to a field
Definition at line 197 of file VirtualStruct.cpp.
References etiss::INFO, etiss::log(), and uint64_t.
|
protectedvirtual |
override this function to implement reads in case of AccessMode::VIRTUAL / AccessMode::PREFER_LAMBDA
Reimplemented in etiss::VirtualStruct::FieldT< structT, retT, field >, pcField_RV64IMACFD, RegField_RV64IMACFD, pcField_RV32IMACFD, and RegField_RV32IMACFD.
Definition at line 189 of file VirtualStruct.cpp.
|
protectedvirtual |
override this function to implement writes in case of AccessMode::VIRTUAL / AccessMode::PREFER_LAMBDA
Reimplemented in etiss::VirtualStruct::FieldT< structT, retT, field >, pcField_RV64IMACFD, RegField_RV64IMACFD, pcField_RV32IMACFD, and RegField_RV32IMACFD.
Definition at line 193 of file VirtualStruct.cpp.
bool etiss::VirtualStruct::Field::addListener | ( | Listener * | listener, |
std::shared_ptr< Listener > | ref = nullptr |
||
) |
ref | optional reference that is stored alongside the pointer |
Definition at line 220 of file VirtualStruct.cpp.
References L.
bool etiss::VirtualStruct::Field::applyAction | ( | const etiss::fault::Fault & | f, |
const etiss::fault::Action & | a, | ||
std::string & | errormsg | ||
) |
advanced fault injection. Field must have the A flag to use this.
Definition at line 178 of file VirtualStruct.cpp.
Referenced by etiss::VirtualStruct::applyAction().
function to write a bitflip to a field
Definition at line 163 of file VirtualStruct.cpp.
Referenced by etiss::VirtualStruct::applyAction().
uint64_t etiss::VirtualStruct::Field::read | ( | ) | const |
function to read bits/a value from the Field.
may only be called if the R flag is set. in case of less than 64 bit values the msb should be extended according to the default c++ conversion behavior. e.g. int32_t read_value = X; return (uint64_t)read_value;
Definition at line 79 of file VirtualStruct.cpp.
References uint64_t.
Referenced by etiss::plugin::VirtualStructMemory::read(), etiss::VirtualStruct::readField(), and etiss::plugin::VirtualStructMemory::write().
void etiss::VirtualStruct::Field::removeListener | ( | Listener * | listener, |
std::shared_ptr< Listener > | ref = nullptr |
||
) |
ref | is ignored and can therfore be null. NEVER write new std::shared_ptr<Listener>(YOURPOINTER) after a shared pointer was already created |
Definition at line 227 of file VirtualStruct.cpp.
Definition at line 266 of file VirtualStruct.h.
References delete_.
Definition at line 261 of file VirtualStruct.h.
References delete_.
void etiss::VirtualStruct::Field::signalWrite | ( | ) |
this function should be called if the listener flag is set and the field changed without using the write() function.
write() will automatically call this function if the listener flag is set.
Definition at line 152 of file VirtualStruct.cpp.
void etiss::VirtualStruct::Field::write | ( | uint64_t | val | ) |
function to write bits/a value to the Field.
may only be called if the W flag is set. additional bits are silently discarded if the targt field has less than 64 bits. e.g. int64_t write_target = (int32_t) write_uint64_t;
Definition at line 115 of file VirtualStruct.cpp.
Referenced by etiss::plugin::VirtualStructMemory::write().
|
static |
supports advanced fault injection/tracing with the applyAction function
Definition at line 196 of file VirtualStruct.h.
Referenced by etiss::VirtualStruct::applyAction().
const AccessMode etiss::VirtualStruct::Field::accessMode_ |
Definition at line 223 of file VirtualStruct.h.
const size_t etiss::VirtualStruct::Field::bitwidth_ |
width in bits
Definition at line 222 of file VirtualStruct.h.
std::function<void(Field *)> etiss::VirtualStruct::Field::delete_ |
Definition at line 260 of file VirtualStruct.h.
Referenced by setDelete(), and setDeleteP().
|
static |
supports fault injection/tracing
Definition at line 195 of file VirtualStruct.h.
Referenced by etiss::VirtualStruct::applyAction().
const int etiss::VirtualStruct::Field::flags_ |
read write flags as specified by the static const int parameters of Field: R,W,L
Definition at line 220 of file VirtualStruct.h.
Referenced by etiss::VirtualStruct::applyAction(), and etiss::VirtualStruct::readField().
|
static |
supports listener plugins; used for etiss::RegisterDevicePlugins to determine access to a variable/field
Definition at line 193 of file VirtualStruct.h.
Referenced by etiss::VirtualStruct::addField(), addListener(), etiss::VirtualStruct::allocateFromC(), and etiss::CPUArchRegListenerInterface::signalChangedRegisterValue().
std::function<bool(unsigned position, uint64_t fault_id)> etiss::VirtualStruct::Field::lapplyBitflip |
if this function is set the the default implementation of applyBitflip will use it
Definition at line 257 of file VirtualStruct.h.
|
private |
Definition at line 284 of file VirtualStruct.h.
|
protected |
set this function for reads in case of AccessMode::LAMBDA / AccessMode::PREFER_LAMBDA
Definition at line 250 of file VirtualStruct.h.
|
protected |
set this function for writes in case of AccessMode::LAMBDA / AccessMode::PREFER_LAMBDA
Definition at line 253 of file VirtualStruct.h.
const std::string etiss::VirtualStruct::Field::name_ |
name of the field.
should be a simple/easy to parse name. e.g. representing the "SR" OR1K CPU register: SPR[0][17]
Definition at line 216 of file VirtualStruct.h.
Referenced by RegField_RV32IMACFD::_write(), pcField_RV32IMACFD::_write(), RegField_RV64IMACFD::_write(), pcField_RV64IMACFD::_write(), etiss::VirtualStruct::addField(), etiss::plugin::VirtualStructMemory::write(), and LegacyRegisterDevicePluginListener::write().
|
static |
private field: this flag indicates that this field is an implementation specific field that e.g.
is not to be copied by etiss::copy()
Definition at line 197 of file VirtualStruct.h.
Referenced by etiss::VirtualStruct::allocateFromC(), etiss::copy(), etiss::CPUCore::CPUCore(), and etiss::parseName().
VirtualStruct& etiss::VirtualStruct::Field::parent_ |
reference to parent virtual struct
Definition at line 215 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().
const std::string etiss::VirtualStruct::Field::prettyname_ |
alternative/human readable name of the field.
e.g. representing the "SR" OR1K CPU register: "SR" or "SupervisorRegister"
Definition at line 218 of file VirtualStruct.h.
Referenced by etiss::VirtualStruct::addField(), and etiss::plugin::VirtualStructMemory::write().
|
static |
read flag
Definition at line 190 of file VirtualStruct.h.
Referenced by etiss::VirtualStruct::addField(), etiss::VirtualStruct::allocateFromC(), etiss::CPUCore::CPUCore(), and etiss::VirtualStruct::readField().
flags to signal that a field supports read and write operations
Definition at line 192 of file VirtualStruct.h.
|
static |
write flag
Definition at line 191 of file VirtualStruct.h.
Referenced by etiss::VirtualStruct::addField(), etiss::VirtualStruct::allocateFromC(), etiss::copy(), and etiss::CPUCore::CPUCore().
const size_t etiss::VirtualStruct::Field::width_ |
width in bytes (rounded up if neccessary)
Definition at line 221 of file VirtualStruct.h.
Referenced by etiss::plugin::VirtualStructMemory::VirtualStructMemory().