ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
etiss::CPUArch Class Referenceabstract

the interface to translate instructions of and processor architecture More...

#include <CPUArch.h>

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

Public Member Functions

 CPUArch (std::string archname)
 
virtual ~CPUArch ()
 
std::string getArchName () const
 returns the name of this architecture. More...
 
std::string getName () const
 returns the name of this architecture. More...
 
virtual ETISS_CPUnewCPU ()=0
 allocate new cpu structure More...
 
virtual void resetCPU (ETISS_CPU *cpu, etiss::uint64 *startpointer)=0
 reset cpu (structure) More...
 
virtual void deleteCPU (ETISS_CPU *)=0
 delete cpu structure More...
 
virtual unsigned getMaximumInstructionSizeInBytes ()=0
 used for variable instruction size and delay slots More...
 
virtual unsigned getMaximumInstructionsPerMetaInstruction ()
 maximum number of instructions in a meta instruction More...
 
virtual unsigned getInstructionSizeInBytes ()=0
 size of one instruction/ smalest data unit for instructions of variable length More...
 
virtual unsigned getSuperInstructionCount ()
 fixed number of sub instructions per instruction (e.g. More...
 
virtual std::string getBlockGlobalCode ()
 get c++ code snippet that is placed at the top of a translated block More...
 
virtual bool unlikelyInstruction (etiss::uint8 *instr, unsigned length, bool &ismetainstruction)
 return true if the given data is unlikely to be an instruction. More...
 
virtual const std::set< std::string > & getHeaders () const =0
 set of code header files e.g. More...
 
virtual etiss::int32 handleException (etiss::int32 code, ETISS_CPU *cpu)
 translate/process exceptions that occur at runtime More...
 
virtual etiss::InterruptVectorcreateInterruptVector (ETISS_CPU *cpu)
 allocate a new interrupt vector object for the given cpu More...
 
virtual void deleteInterruptVector (etiss::InterruptVector *vec, ETISS_CPU *cpu)
 delete an allocated interrupt vector object More...
 
virtual etiss::InterruptEnablecreateInterruptEnable (ETISS_CPU *cpu)
 
virtual void deleteInterruptEnable (etiss::InterruptEnable *en, ETISS_CPU *cpu)
 
virtual etiss::plugin::gdb::GDBCoregetGDBCore ()
 returns arch dependent gdb functions. More...
 
virtual std::string getIncludePath ()
 returns a path that will be used to look up header files More...
 
virtual void finalizeInstrSet (etiss::instr::ModedInstructionSet &) const
 the default behavior of this function of a cpu arch is to add "cpu->cpuTime_ps += cpu->cpuCycleTime_ps;" if the cpu time update group is not in use More...
 
virtual void compensateEndianess (ETISS_CPU *cpu, etiss::instr::BitArray &ba) const
 this function should compensate for any endianess on a BitArray so that bit 0 is always the LSB. More...
 
virtual etiss::mm::MMUnewMMU (ETISS_CPU *cpu)
 It is an interface to instanciate a Memory Management Unit. More...
 
- Public Member Functions inherited from etiss::CPUArchRegListenerInterface
virtual ~CPUArchRegListenerInterface ()
 
virtual const std::set< std::string > & getListenerSupportedRegisters ()=0
 
- Public Member Functions inherited from etiss::CPUArchCPUManipulation
virtual ~CPUArchCPUManipulation ()
 
virtual std::shared_ptr< etiss::VirtualStructgetVirtualStruct (ETISS_CPU *cpu)=0
 this function must return a valid pointer to a virtual struct More...
 
- Public Member Functions inherited from etiss::CPUArchDefaultPlugins
virtual ~CPUArchDefaultPlugins ()
 
virtual etiss::PluginnewTimer (ETISS_CPU *cpu)
 create a simple default timer implementaion instance for this architecture. More...
 
virtual void deleteTimer (etiss::Plugin *timer)
 delete timer instance More...
 
- Public Member Functions inherited from etiss::TranslationPlugin
 TranslationPlugin ()
 
virtual ~TranslationPlugin ()
 
virtual void initInstrSet (etiss::instr::ModedInstructionSet &) const
 called to add instructions to the instruction set More...
 
virtual void initCodeBlock (etiss::CodeBlock &) const
 called before instructions are translated for the code block More...
 
virtual void finalizeCodeBlock (etiss::CodeBlock &) const
 called after all instructions have been translated for the code block More...
 
virtual void * getPluginHandle ()
 called to get the handle that is available in translated code via getPoinerCode(). [default: this] More...
 
- Public Member Functions inherited from etiss::Plugin
virtual ~Plugin ()
 
unsigned getType ()
 
InterruptListenerPlugingetInterruptListenerPlugin ()
 
CoroutinePlugingetCoroutinePlugin ()
 
SystemWrapperPlugingetSystemWrapperPlugin ()
 
RegisterDevicePlugingetRegisterDevicePlugin ()
 
TranslationPlugingetTranslationPlugin ()
 
std::string getPluginName () const
 
const std::string & getLastAssignedCoreName ()
 
std::string toString () const
 
- Public Member Functions inherited from etiss::ToString
 ToString ()
 
virtual ~ToString ()
 

Protected Member Functions

virtual std::string _getPluginName () const
 do not override. maps to getName(). More...
 
- Protected Member Functions inherited from etiss::TranslationPlugin
std::string getPointerCode () const
 returns a C code expression that allows to get or assign a pointer to the variable assigned to this translation plugin. More...
 
- Protected Member Functions inherited from etiss::Plugin
 Plugin (unsigned type=0)
 
virtual void init (ETISS_CPU *cpu, ETISS_System *system, CPUArch *arch)
 this function is called before the plugin is used in the cpu execution loop (etiss::CPUCore::execute). More...
 
virtual void cleanup ()
 this function is called after cpu execution loop (etiss::CPUCore::execute) finished. More...
 
void setCorrespondingCPUCoreName (std::string name)
 
virtual void addedToCPUCore (etiss::CPUCore *core)
 called as soon a plugin has been added to its CPUCore. More...
 
virtual void removedFromCPUCore (etiss::CPUCore *core)
 called as soon a plugin has been removed from its CPUCore. More...
 

Private Attributes

etiss::plugin::gdb::GDBCore gdbcore_
 
std::string archname_
 

Friends

class LibraryInterface
 

Additional Inherited Members

- Static Public Member Functions inherited from etiss::CPUArchRegListenerInterface
static void signalChangedRegisterValue (ETISS_CPU *cpu, const char *registerName)
 call this function to inform RegisterDevicePlugins about changed special register values. More...
 
- Static Public Attributes inherited from etiss::Plugin
static const unsigned INTERRUPTLISTENER = 1 << 0
 access to translated code More...
 
static const unsigned COROUTINE = 1 << 1
 callback after execution of each translated block More...
 
static const unsigned SYSTEMWRAPPER = 1 << 2
 can wrap/change ETISS_System structure at execution start More...
 
static const unsigned REGISTERDEVICE
 gets noticed of changes to special registers (e.g. mmu register etc. [depends on architecture]) More...
 
static const unsigned TRANSLATION
 access to translated code during translation phase or when instruction tree is built More...
 
- Protected Attributes inherited from etiss::Plugin
ETISS_CPUplugin_cpu_
 holds a pointer to the cpu structure. will be set before init call and after cleanup call More...
 
ETISS_Systemplugin_system_
 holds a pointer to the system structure. More...
 
CPUArchplugin_arch_
 holds a pointer to the CPUArch instance. will be set before init call and after cleanup call More...
 
CPUCoreplugin_core_
 holds a pointer to the associated CPUCore instance. More...
 

Detailed Description

the interface to translate instructions of and processor architecture

Definition at line 158 of file CPUArch.h.

Constructor & Destructor Documentation

◆ CPUArch()

CPUArch::CPUArch ( std::string  archname)
Parameters
archnamemust match the returned string of LibraryInterface::nameCPUArch(unsigned)/YOURLIBRARY_nameCPUArch(unsigned)

Definition at line 74 of file CPUArch.cpp.

References etiss::CPUCore::getNextID(), and etiss::Plugin::setCorrespondingCPUCoreName().

Here is the call graph for this function:

◆ ~CPUArch()

CPUArch::~CPUArch ( )
virtual

Definition at line 79 of file CPUArch.cpp.

Member Function Documentation

◆ _getPluginName()

std::string CPUArch::_getPluginName ( ) const
protectedvirtual

do not override. maps to getName().

Implements etiss::Plugin.

Definition at line 155 of file CPUArch.cpp.

References getName().

Here is the call graph for this function:

◆ compensateEndianess()

void CPUArch::compensateEndianess ( ETISS_CPU cpu,
etiss::instr::BitArray ba 
) const
virtual

this function should compensate for any endianess on a BitArray so that bit 0 is always the LSB.

the function etiss::instr::BitArray::recoverFromEndianness() can be used or the operation can be performed directly on th byte array with etiss::instr::BitArray::internalBuffer() by default bigendian aligned to 4 bytes is assumed

Reimplemented in RV64IMACFDArch, and RV32IMACFDArch.

Definition at line 188 of file CPUArch.cpp.

References etiss::_BIG_ENDIAN_, etiss::instr::Buffer::data(), etiss::instr::BitArray::intCount(), etiss::instr::Buffer::recoverFromEndianness(), and etiss::instr::BitArray::set_value().

Referenced by etiss::Translation::translateBlock().

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

◆ createInterruptEnable()

etiss::InterruptEnable * CPUArch::createInterruptEnable ( ETISS_CPU cpu)
virtual

Reimplemented in RV64IMACFDArch, and RV32IMACFDArch.

Definition at line 138 of file CPUArch.cpp.

◆ createInterruptVector()

etiss::InterruptVector * CPUArch::createInterruptVector ( ETISS_CPU cpu)
virtual

allocate a new interrupt vector object for the given cpu

Reimplemented in RV64IMACFDArch, and RV32IMACFDArch.

Definition at line 128 of file CPUArch.cpp.

◆ deleteCPU()

virtual void etiss::CPUArch::deleteCPU ( ETISS_CPU )
pure virtual

delete cpu structure

Implemented in RV64IMACFDArch, and RV32IMACFDArch.

◆ deleteInterruptEnable()

void CPUArch::deleteInterruptEnable ( etiss::InterruptEnable en,
ETISS_CPU cpu 
)
virtual

Reimplemented in RV64IMACFDArch, and RV32IMACFDArch.

Definition at line 141 of file CPUArch.cpp.

◆ deleteInterruptVector()

void CPUArch::deleteInterruptVector ( etiss::InterruptVector vec,
ETISS_CPU cpu 
)
virtual

delete an allocated interrupt vector object

Reimplemented in RV64IMACFDArch, and RV32IMACFDArch.

Definition at line 132 of file CPUArch.cpp.

◆ finalizeInstrSet()

void CPUArch::finalizeInstrSet ( etiss::instr::ModedInstructionSet mis) const
virtual

the default behavior of this function of a cpu arch is to add "cpu->cpuTime_ps += cpu->cpuCycleTime_ps;" if the cpu time update group is not in use

Reimplemented from etiss::TranslationPlugin.

Definition at line 181 of file CPUArch.cpp.

References CPUArch_finalizeInstrSet(), etiss::instr::VariableInstructionSet::foreach(), and etiss::instr::ModedInstructionSet::foreach().

Here is the call graph for this function:

◆ getArchName()

std::string CPUArch::getArchName ( ) const

returns the name of this architecture.

this name was passed to the constructor and must match the returned string of LibraryInterface::nameCPUArch(unsigned)/YOURLIBRARY_nameCPUArch(unsigned)

Deprecated:

Definition at line 81 of file CPUArch.cpp.

References archname_.

Referenced by getName().

Here is the caller graph for this function:

◆ getBlockGlobalCode()

std::string CPUArch::getBlockGlobalCode ( )
virtual

get c++ code snippet that is placed at the top of a translated block

Definition at line 107 of file CPUArch.cpp.

◆ getGDBCore()

etiss::plugin::gdb::GDBCore & CPUArch::getGDBCore ( )
virtual

returns arch dependent gdb functions.

althought not required it is strongly recommended to implement this

Reimplemented in RV64IMACFDArch, and RV32IMACFDArch.

Definition at line 145 of file CPUArch.cpp.

References gdbcore_.

Referenced by etiss::plugin::gdb::Server::handlePacket(), and etiss::plugin::gdb::Server::preInstructionCallback().

Here is the caller graph for this function:

◆ getHeaders()

virtual const std::set<std::string>& etiss::CPUArch::getHeaders ( ) const
pure virtual

set of code header files e.g.

CustomCPU.h containing a cpu register structure needed to compile the generated code

Implemented in RV64IMACFDArch, and RV32IMACFDArch.

◆ getIncludePath()

std::string CPUArch::getIncludePath ( )
virtual

returns a path that will be used to look up header files

Definition at line 150 of file CPUArch.cpp.

References etiss::cfg(), etiss::Configuration::get(), and getName().

Referenced by etiss::Translation::getBlock().

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

◆ getInstructionSizeInBytes()

virtual unsigned etiss::CPUArch::getInstructionSizeInBytes ( )
pure virtual

size of one instruction/ smalest data unit for instructions of variable length

Implemented in RV64IMACFDArch, and RV32IMACFDArch.

Referenced by getMaximumInstructionsPerMetaInstruction().

Here is the caller graph for this function:

◆ getMaximumInstructionSizeInBytes()

virtual unsigned etiss::CPUArch::getMaximumInstructionSizeInBytes ( )
pure virtual

used for variable instruction size and delay slots

Deprecated:
use getMaximumInstructionsPerMetaInstruction()

Implemented in RV64IMACFDArch, and RV32IMACFDArch.

Referenced by getMaximumInstructionsPerMetaInstruction().

Here is the caller graph for this function:

◆ getMaximumInstructionsPerMetaInstruction()

unsigned CPUArch::getMaximumInstructionsPerMetaInstruction ( )
virtual

maximum number of instructions in a meta instruction

TODO update to remove deprecated function

Definition at line 112 of file CPUArch.cpp.

References getInstructionSizeInBytes(), and getMaximumInstructionSizeInBytes().

Here is the call graph for this function:

◆ getName()

std::string etiss::CPUArch::getName ( ) const
inline

returns the name of this architecture.

this name was passed to the constructor and must match the returned string of LibraryInterface::nameCPUArch(unsigned)/YOURLIBRARY_nameCPUArch(unsigned)

Definition at line 184 of file CPUArch.h.

References getArchName().

Referenced by _getPluginName(), etiss::errorMessage(), getIncludePath(), and etiss::Translation::init().

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

◆ getSuperInstructionCount()

unsigned CPUArch::getSuperInstructionCount ( )
virtual

fixed number of sub instructions per instruction (e.g.

thumb -> 2 16bit instructions per 1 32bit instruction)

Definition at line 118 of file CPUArch.cpp.

◆ handleException()

etiss::int32 CPUArch::handleException ( etiss::int32  code,
ETISS_CPU cpu 
)
virtual

translate/process exceptions that occur at runtime

Reimplemented in RV64IMACFDArch, and RV32IMACFDArch.

Definition at line 123 of file CPUArch.cpp.

Referenced by etiss_CPUCore_handleException().

Here is the caller graph for this function:

◆ newCPU()

virtual ETISS_CPU* etiss::CPUArch::newCPU ( )
pure virtual

allocate new cpu structure

Implemented in RV64IMACFDArch, and RV32IMACFDArch.

◆ newMMU()

virtual etiss::mm::MMU* etiss::CPUArch::newMMU ( ETISS_CPU cpu)
inlinevirtual

It is an interface to instanciate a Memory Management Unit.

Definition at line 268 of file CPUArch.h.

◆ resetCPU()

virtual void etiss::CPUArch::resetCPU ( ETISS_CPU cpu,
etiss::uint64 startpointer 
)
pure virtual

reset cpu (structure)

Implemented in RV64IMACFDArch, and RV32IMACFDArch.

◆ unlikelyInstruction()

bool CPUArch::unlikelyInstruction ( etiss::uint8 instr,
unsigned  length,
bool ismetainstruction 
)
virtual

return true if the given data is unlikely to be an instruction.

used for precompilation. default implementation returns true if data is all zeros

Definition at line 86 of file CPUArch.cpp.

References length().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ LibraryInterface

friend class LibraryInterface
friend

Definition at line 163 of file CPUArch.h.

Member Data Documentation

◆ archname_

std::string etiss::CPUArch::archname_
private

Definition at line 276 of file CPUArch.h.

Referenced by getArchName().

◆ gdbcore_

etiss::plugin::gdb::GDBCore etiss::CPUArch::gdbcore_
private

Definition at line 275 of file CPUArch.h.

Referenced by getGDBCore().


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