ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
|
CPUCore is responsible for the simulation of a CPU core in ETISS. More...
#include <CPUCore.h>
Classes | |
class | InterruptVectorWrapper |
Public Member Functions | |
~CPUCore () | |
void | reset (etiss::uint64 *startindex) |
Reset the CPU state. More... | |
ETISS_CPU * | getState () |
Get the CPU state structure containing instruction pointer, frequency, etc. More... | |
virtual std::shared_ptr< VirtualStruct > | getStruct () |
Get the virtual structure of this CPUCore instance. More... | |
virtual std::shared_ptr< etiss::mm::MMU > | getMMU () |
Get the Memory Management Unit(MMU) of this CPUCore instance. More... | |
etiss::InterruptVector * | getInterruptVector () |
Get the interrupt vector of simulated CPU. More... | |
etiss::InterruptEnable * | getInterruptEnable () |
std::shared_ptr< etiss::CPUArch > | getArch () |
Get the CPU architecture. More... | |
void | set (std::shared_ptr< etiss::JIT > jit) |
Set the JIT plug-in used for execution. More... | |
void | setTimer (bool on) |
Enable or disable the timer of the CPU. More... | |
void | addPlugin (std::shared_ptr< etiss::Plugin > plugin) |
Adds a plug-in to the core simulator. More... | |
void | removePlugin (std::shared_ptr< etiss::Plugin > plugin) |
Remove a plug-in from the core simulator. More... | |
void | removePlugins () |
Remove all plug-ins from the core simulator. More... | |
void | setBlockChainCount (unsigned bcc) |
Set the number of blocks jumps in between the coroutines are not executed. More... | |
etiss::int32 | execute (ETISS_System &system) |
Start the simulation of the CPU core for the system model. More... | |
etiss::int32 | execute (etiss::System &system) |
Start the simulation of the CPU core for the system model. More... | |
const std::string & | getName () |
Get the name of the CPUCore instance. More... | |
const int & | getID () |
Get the ID of the CPUCore instance. More... | |
std::string | getJITName () |
Get the name of the JIT plug-in used by the CPUCore instance. More... | |
std::shared_ptr< etiss::JIT > | getJIT () |
Get a reference to the JIT plugin. More... | |
const std::string & | toString () const |
Get a string representation of the object. More... | |
std::shared_ptr< Plugin > | getPlugin (std::string name) |
returns the plugin with the given name. More... | |
std::list< std::shared_ptr< Plugin > > const * | getPlugins () |
returns the list of all plugins. More... | |
Public Member Functions inherited from etiss::VirtualStructSupport | |
virtual | ~VirtualStructSupport () |
Public Member Functions inherited from etiss::ToString | |
ToString () | |
virtual | ~ToString () |
Static Public Member Functions | |
static std::shared_ptr< CPUCore > | create (std::string archname, std::string instancename="", std::map< std::string, std::string > archoptions=std::map< std::string, std::string >()) |
Create a CPUCore instance. More... | |
static int | getNextID () |
static std::list< std::string > | list () |
returns a list of currently present CPU cores More... | |
Public Attributes | |
uint64_t | instrcounter |
Private Member Functions | |
CPUCore (std::shared_ptr< etiss::CPUArch > arch) | |
Private constructor of CPUCore. More... | |
Private Attributes | |
std::shared_ptr< etiss::CPUArch > | arch_ |
std::string | name_ |
cpu architecture of this cpu core. may never be 0 or changed More... | |
const int | id_ |
name of the cpu core More... | |
ETISS_CPU * | cpu_ |
ID of the cpu core. More... | |
std::shared_ptr< etiss::VirtualStruct > | vcpu_ |
cpu state structure allocated by arch_ More... | |
etiss::InterruptVector * | intvector_ |
InterruptVectorWrapper * | intwrapper_ |
cpu interrupt vector derived from cpu_ and allocated by arch_ More... | |
etiss::InterruptEnable * | intenable_ |
wrapped interrupt vector to allow interrupt listening More... | |
bool | timer_enabled_ |
std::shared_ptr< etiss::JIT > | jit_ |
if true the a timer plugin allocated by arch_ will be added in CPUCore::execute More... | |
std::mutex | mu_ |
JIT instance to use. may be 0 (etiss::getDefaultJIT() will be used in that case) More... | |
std::list< std::shared_ptr< Plugin > > | plugins |
mutex to lock the configuration of this cpu core. More... | |
unsigned | bcc_ |
list of all plugins More... | |
unsigned | blockCounter |
unsigned | exception_skip_count_ |
int | blockCacheLimit_ |
bool | mmu_enabled_ |
TODO: possibility to limit the cache size. More... | |
std::shared_ptr< etiss::mm::MMU > | mmu_ |
Static Private Attributes | |
static std::mutex | instances_mu_ |
this field is always present to maintain API compatibility but it is only used if ETISS_CPUCORE_DBG_APPROXIMATE_INSTRUCTION_COUNTER is set to 1 More... | |
static std::list< std::weak_ptr< CPUCore > > | instances_ |
mutext for access to a list of cpu core instances More... | |
Friends | |
class | CPUArchRegListenerInterface |
class | InterruptVectorWrapper |
CPUCore is responsible for the simulation of a CPU core in ETISS.
CPUCore is responsible for the simulation of a CPU core in ETISS. An instance of CPUCore is always tied to a single CPU architecture. If plug-ins should be active during the simulation they need to be added to the CPUCore instance. Before the simulation can be start a JIT compilier must be present if the default JIT plug-in should not be used (etiss::getDefaultJIT()). A JIT plug-in must be specified with CPUCore::set(). To start the simulation of a system model with a CPUCore instance call CPUCore::execute().
|
private |
Private constructor of CPUCore.
To create a new instance of CPUCore use the CPUCore::create().
name | The name of the CPUCore instance. |
arch | Pointer to the CPU architecture used by the CPU core simulator. |
Definition at line 139 of file CPUCore.cpp.
References arch_, bcc_, blockCacheLimit_, blockCounter, cpu_, exception_skip_count_, instrcounter, ETISS_CPU::instructionPointer, InterruptVectorWrapper, intvector_, intwrapper_, etiss::VirtualStruct::Field::P, etiss::VirtualStruct::Field::R, timer_enabled_, uint64_t, v, vcpu_, and etiss::VirtualStruct::Field::W.
Referenced by create().
CPUCore::~CPUCore | ( | ) |
Definition at line 294 of file CPUCore.cpp.
References arch_, cpu_, intvector_, intwrapper_, and vcpu_.
void CPUCore::addPlugin | ( | std::shared_ptr< etiss::Plugin > | plugin | ) |
Adds a plug-in to the core simulator.
See the different plug-in classes, for information on how the plug-in influences the simulation.
plugin | Pointer to the plug-in that shall be added. |
Definition at line 191 of file CPUCore.cpp.
References getName(), etiss::log(), mu_, plugins, and etiss::WARNING.
|
static |
Create a CPUCore instance.
This is the factory method to create a new CPUCore instance for a specific CPU architecture.
archname | The name of a CPUArch plug-in. This plug-in must be present in ETISS in order to create the CPUCore instance. |
instancename | A descriptive name for the new instance. |
archoptions | A key value map with options for the CPUArch plug-in. |
archoptions | obsolet: now defined by ID - "core[ID]" |
Definition at line 250 of file CPUCore.cpp.
References CPUCore(), etiss::FATALERROR, etiss::forceInitialization(), etiss::getCPUArch(), instances_, instances_mu_, and etiss::log().
Referenced by main().
|
inline |
Start the simulation of the CPU core for the system model.
This method works the same as execute(ETISS_System & system), but uses the etiss::System interface to access the model.
Definition at line 287 of file CPUCore.h.
References execute(), and etiss::wrap().
etiss::int32 CPUCore::execute | ( | ETISS_System & | system | ) |
Start the simulation of the CPU core for the system model.
This method starts the simulation of the CPU core for the provided system model. It uses the C-structure interface to access the system model. This method is (like any other methods of this class) thread-safe. However if any method of this class including this one is called while this method is running, it will block until this method is finished returns.
Definition at line 504 of file CPUCore.cpp.
References ETISS_CPU::_etiss_private_handle_, arch_, bcc_, c, etiss::cfg(), clock(), coverage_map, cpu_, ETISS_CPU::cpuCycleTime_ps, ETISS_CPU::cpuTime_ps, ETISS_CPU::cycles, double, etiss::BlockLink::end, etiss::ERROR, etiss_CPUCore_handleException(), ETISS_MAX_RESOURCES, ETISS_System_isvalid(), etiss::BlockLink::execBlock, etiss::FATALERROR, float, etiss::Configuration::get(), etiss::Translation::getBlockFast(), etiss::Plugin::getPluginName(), ETISS_System::handle, etiss::INFO, etiss::Translation::init(), instrcounter, ETISS_CPU::instructionPointer, etiss::Configuration::isSet(), jit_, likely, etiss::log(), max(), mmu_, mmu_enabled_, mu_, name_, etiss::mm::NOERROR, plugins, ETISS_CPU::resources, ETISS_CPU::resourceUsages, ETISS_System::syncTime, timer_enabled_, etiss::toString(), uint64_t, unlikely, vcpu_, verifyJITPragmaPack(), verifyJITSizeOf(), etiss::WARNING, and etiss::mm::X_ACCESS.
Referenced by execute().
|
inline |
|
inline |
|
inline |
Definition at line 190 of file CPUCore.h.
References intenable_.
|
inline |
Get the interrupt vector of simulated CPU.
Definition at line 188 of file CPUCore.h.
References intwrapper_.
|
inline |
|
inline |
|
inlinevirtual |
Get the Memory Management Unit(MMU) of this CPUCore instance.
MMU is responsible to translate virtual address to physical address, which is essential to support multi-taking operationg systems, such as Linux
Definition at line 181 of file CPUCore.h.
References mmu_.
Referenced by ETISS_SIGNAL_MMU().
|
inline |
Get the name of the CPUCore instance.
Definition at line 301 of file CPUCore.h.
References name_.
Referenced by addPlugin().
|
static |
Definition at line 135 of file CPUCore.cpp.
References currID.
Referenced by etiss::CPUArch::CPUArch().
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Get the virtual structure of this CPUCore instance.
The virtual structure allows the to access the fields of the CPU structure and sub structures (e.g. plug-ins) used by CPUCore.
Implements etiss::VirtualStructSupport.
Definition at line 170 of file CPUCore.h.
References vcpu_.
Referenced by etiss::plugin::InstructionAccurateCallback::call(), etiss::plugin::errorInjection::BlockAccurateHandler::execute(), etiss::plugin::VariableValueLogger::finalizeInstrSet(), etiss::plugin::gdb::Server::handlePacket(), etiss::CPUArchRegListenerInterface::signalChangedRegisterValue(), and etiss::plugin::VariableValueLogger::writeValue().
|
static |
returns a list of currently present CPU cores
Definition at line 276 of file CPUCore.cpp.
References instances_, and instances_mu_.
Referenced by etiss::shutdown().
void CPUCore::removePlugin | ( | std::shared_ptr< etiss::Plugin > | plugin | ) |
Remove a plug-in from the core simulator.
plugin | Pointer to the plug-in that shall be removed. |
Definition at line 223 of file CPUCore.cpp.
References mu_, etiss::Plugin::plugin_core_, plugins, and etiss::Plugin::removedFromCPUCore().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Enable or disable the timer of the CPU.
on | true to enable the timer / false to disable the timer |
Definition at line 220 of file CPUCore.h.
References mu_, and timer_enabled_.
|
inline |
|
friend |
|
friend |
|
private |
|
private |
list of all plugins
Definition at line 399 of file CPUCore.h.
Referenced by CPUCore(), execute(), and setBlockChainCount().
|
private |
|
private |
|
private |
ID of the cpu core.
Definition at line 388 of file CPUCore.h.
Referenced by CPUCore(), execute(), getState(), reset(), and ~CPUCore().
|
private |
|
private |
|
staticprivate |
|
staticprivate |
uint64_t etiss::CPUCore::instrcounter |
|
private |
wrapped interrupt vector to allow interrupt listening
Definition at line 392 of file CPUCore.h.
Referenced by getInterruptEnable().
|
private |
Definition at line 390 of file CPUCore.h.
Referenced by CPUCore(), and ~CPUCore().
|
private |
cpu interrupt vector derived from cpu_ and allocated by arch_
Definition at line 391 of file CPUCore.h.
Referenced by CPUCore(), getInterruptVector(), and ~CPUCore().
|
private |
if true the a timer plugin allocated by arch_ will be added in CPUCore::execute
Definition at line 395 of file CPUCore.h.
Referenced by execute(), getJIT(), getJITName(), and set().
|
private |
|
private |
|
private |
JIT instance to use. may be 0 (etiss::getDefaultJIT() will be used in that case)
Definition at line 396 of file CPUCore.h.
Referenced by addPlugin(), execute(), removePlugin(), removePlugins(), and setTimer().
|
private |
cpu architecture of this cpu core. may never be 0 or changed
Definition at line 386 of file CPUCore.h.
Referenced by execute(), getName(), and toString().
|
private |
mutex to lock the configuration of this cpu core.
etiss::CPUCore::execution holds this lock during execution
Definition at line 398 of file CPUCore.h.
Referenced by addPlugin(), execute(), getPlugin(), getPlugins(), removePlugin(), and removePlugins().
|
private |
Definition at line 393 of file CPUCore.h.
Referenced by CPUCore(), execute(), and setTimer().
|
private |
cpu state structure allocated by arch_
Definition at line 389 of file CPUCore.h.
Referenced by CPUCore(), execute(), getStruct(), and ~CPUCore().