ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
etiss::VirtualStruct::Field Class Reference

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

#include <VirtualStruct.h>

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

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...
 
FieldsetDeleteP (std::function< void(Field *)> del)
 
FieldsetDelete (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

VirtualStructparent_
 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_comparelisteners
 

Detailed Description

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.

Member Enumeration Documentation

◆ AccessMode

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.

Constructor & Destructor Documentation

◆ Field() [1/2]

etiss::VirtualStruct::Field::Field ( VirtualStruct parent,
const std::string &  name,
const std::string &  prettyname,
int  flags,
size_t  width,
size_t  bitwidth = 0 
)
Parameters
widthwidth of the field in bytes. rounded up in case of bitwidth missmatch
bitwidthwidth of the field in bits. if 0 then width*8 will be used for bitwidth_

Definition at line 50 of file VirtualStruct.cpp.

◆ Field() [2/2]

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.

◆ ~Field()

etiss::VirtualStruct::Field::~Field ( )
virtual

Definition at line 77 of file VirtualStruct.cpp.

Member Function Documentation

◆ _applyAction()

bool etiss::VirtualStruct::Field::_applyAction ( const etiss::fault::Fault f,
const etiss::fault::Action a,
std::string &  errormsg 
)
protectedvirtual

override this function to implement advanced action handling

Definition at line 214 of file VirtualStruct.cpp.

◆ _applyBitflip()

bool etiss::VirtualStruct::Field::_applyBitflip ( unsigned  position,
uint64_t  fault_id 
)
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.

Here is the call graph for this function:

◆ _read()

uint64_t etiss::VirtualStruct::Field::_read ( ) const
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.

◆ _write()

void etiss::VirtualStruct::Field::_write ( uint64_t  )
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.

◆ addListener()

bool etiss::VirtualStruct::Field::addListener ( Listener listener,
std::shared_ptr< Listener ref = nullptr 
)
Parameters
refoptional reference that is stored alongside the pointer

Definition at line 220 of file VirtualStruct.cpp.

References L.

◆ applyAction()

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

Here is the caller graph for this function:

◆ applyBitflip()

bool etiss::VirtualStruct::Field::applyBitflip ( unsigned  position,
uint64_t  fault_id 
)

function to write a bitflip to a field

Definition at line 163 of file VirtualStruct.cpp.

Referenced by etiss::VirtualStruct::applyAction().

Here is the caller graph for this function:

◆ read()

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

Here is the caller graph for this function:

◆ removeListener()

void etiss::VirtualStruct::Field::removeListener ( Listener listener,
std::shared_ptr< Listener ref = nullptr 
)
Parameters
refis 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.

◆ setDelete()

Field& etiss::VirtualStruct::Field::setDelete ( std::function< void(Field *)>  del)
inline

Definition at line 266 of file VirtualStruct.h.

References delete_.

◆ setDeleteP()

Field* etiss::VirtualStruct::Field::setDeleteP ( std::function< void(Field *)>  del)
inline

Definition at line 261 of file VirtualStruct.h.

References delete_.

◆ signalWrite()

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.

◆ write()

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

Here is the caller graph for this function:

Member Data Documentation

◆ A

const int etiss::VirtualStruct::Field::A = 16
static

supports advanced fault injection/tracing with the applyAction function

Definition at line 196 of file VirtualStruct.h.

Referenced by etiss::VirtualStruct::applyAction().

◆ accessMode_

const AccessMode etiss::VirtualStruct::Field::accessMode_

Definition at line 223 of file VirtualStruct.h.

◆ bitwidth_

const size_t etiss::VirtualStruct::Field::bitwidth_

width in bits

Definition at line 222 of file VirtualStruct.h.

◆ delete_

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

Definition at line 260 of file VirtualStruct.h.

Referenced by setDelete(), and setDeleteP().

◆ F

const int etiss::VirtualStruct::Field::F = 8
static

supports fault injection/tracing

Definition at line 195 of file VirtualStruct.h.

Referenced by etiss::VirtualStruct::applyAction().

◆ flags_

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

◆ L

const int etiss::VirtualStruct::Field::L = 4
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().

◆ lapplyBitflip

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.

◆ listeners

std::set<std::pair<Listener *, std::shared_ptr<Listener> >, listener_pair_compare> etiss::VirtualStruct::Field::listeners
private

Definition at line 284 of file VirtualStruct.h.

◆ lread

std::function<uint64_t()> etiss::VirtualStruct::Field::lread
protected

set this function for reads in case of AccessMode::LAMBDA / AccessMode::PREFER_LAMBDA

Definition at line 250 of file VirtualStruct.h.

◆ lwrite

std::function<void(uint64_t)> etiss::VirtualStruct::Field::lwrite
protected

set this function for writes in case of AccessMode::LAMBDA / AccessMode::PREFER_LAMBDA

Definition at line 253 of file VirtualStruct.h.

◆ name_

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

◆ P

const int etiss::VirtualStruct::Field::P = 32
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().

◆ parent_

VirtualStruct& etiss::VirtualStruct::Field::parent_

◆ prettyname_

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

◆ R

const int etiss::VirtualStruct::Field::R = 1
static

◆ RW

const int etiss::VirtualStruct::Field::RW = R | W
static

flags to signal that a field supports read and write operations

Definition at line 192 of file VirtualStruct.h.

◆ W

const int etiss::VirtualStruct::Field::W = 2
static

◆ width_

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


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