13#ifndef ETISS_INCLUDE_CPUCORE_H_
14#define ETISS_INCLUDE_CPUCORE_H_
29#define ETISS_CPUCORE_DBG_APPROXIMATE_INSTRUCTION_COUNTER 0
78 CPUCore(std::shared_ptr<etiss::CPUArch> arch, std::string
const &name);
79 CPUCore(std::shared_ptr<etiss::CPUArch> arch);
84 std::list<etiss::InterruptListenerPlugin *>
plugins_;
89 virtual void setBit(
unsigned bit,
bool state);
90 virtual bool getBit(
unsigned bit)
const;
91 virtual unsigned width()
const;
105 void reset(etiss::uint64 *startindex);
133 virtual inline std::shared_ptr<etiss::mm::MMU>
getMMU() {
return mmu_; }
163 inline void set(std::shared_ptr<etiss::JIT> jit) {
jit_ = jit; }
174 std::lock_guard<std::mutex> lock(
mu_);
192 void addPlugin(std::shared_ptr<etiss::Plugin> plugin);
199 void removePlugin(std::shared_ptr<etiss::Plugin> plugin);
206 std::lock_guard<std::mutex> lock(
mu_);
275 std::shared_ptr<Plugin>
getPlugin(std::string name);
298 static std::shared_ptr<CPUCore>
create(
299 std::string archname,
300 std::string instancename =
"",
301 std::map<std::string, std::string> archoptions = std::map<std::string, std::string>());
308 static std::list<std::string>
list();
311 std::shared_ptr<etiss::CPUArch>
arch_;
315 std::shared_ptr<etiss::VirtualStruct>
vcpu_;
320 std::shared_ptr<etiss::JIT>
330 std::shared_ptr<etiss::mm::MMU>
mmu_;
338 static std::list<std::weak_ptr<CPUCore>>
defines a general interface to set interrupt bits
general configuration and logging
static __inline__ uint64_t
allows to inform plugins about changes to a register that is present in the cpu structure.
virtual void setBit(unsigned bit, bool state)
set the bit of an interrupt line to state (true = raised)
virtual unsigned width() const
number of interrupt bits
virtual bool getBit(unsigned bit) const
get the bit of an interrupt line
virtual bool isActive() const
std::list< etiss::InterruptListenerPlugin * > plugins_
virtual void clear()
sets every bit to false
CPUCore is responsible for the simulation of a CPU core in ETISS.
std::shared_ptr< etiss::mm::MMU > mmu_
void removePlugins()
Remove all plug-ins from the core simulator.
ETISS_CPU * getState()
Get the CPU state structure containing instruction pointer, frequency, etc.
std::mutex mu_
JIT instance to use. may be 0 (etiss::getDefaultJIT() will be used in that case)
const int & getID()
Get the ID of the CPUCore instance.
const int id_
name of the cpu core
const std::string & toString() const
Get a string representation of the object.
std::string getJITName()
Get the name of the JIT plug-in used by the CPUCore instance.
void setBlockChainCount(unsigned bcc)
Set the number of blocks jumps in between the coroutines are not executed.
etiss::InterruptVector * intvector_
std::list< std::shared_ptr< Plugin > > plugins
mutex to lock the configuration of this cpu core.
unsigned exception_skip_count_
etiss::int32 execute(ETISS_System &system)
Start the simulation of the CPU core for the system model.
static std::mutex instances_mu_
this field is always present to maintain API compatibility but it is only used if ETISS_CPUCORE_DBG_A...
std::list< std::shared_ptr< Plugin > > const * getPlugins()
returns the list of all plugins.
bool mmu_enabled_
TODO: possibility to limit the cache size.
std::shared_ptr< etiss::JIT > jit_
if true the a timer plugin allocated by arch_ will be added in CPUCore::execute
static std::list< std::string > list()
returns a list of currently present CPU cores
virtual std::shared_ptr< etiss::mm::MMU > getMMU()
Get the Memory Management Unit(MMU) of this CPUCore instance.
std::shared_ptr< etiss::CPUArch > arch_
InterruptVectorWrapper * intwrapper_
cpu interrupt vector derived from cpu_ and allocated by arch_
void reset(etiss::uint64 *startindex)
Reset the CPU state.
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.
unsigned bcc_
list of all plugins
std::shared_ptr< etiss::JIT > getJIT()
Get a reference to the JIT plugin.
std::string name_
cpu architecture of this cpu core. may never be 0 or changed
ETISS_CPU * cpu_
ID of the cpu core.
void addPlugin(std::shared_ptr< etiss::Plugin > plugin)
Adds a plug-in to the core simulator.
void set(std::shared_ptr< etiss::JIT > jit)
Set the JIT plug-in used for execution.
std::shared_ptr< Plugin > getPlugin(std::string name)
returns the plugin with the given name.
std::shared_ptr< etiss::CPUArch > getArch()
Get the CPU architecture.
std::shared_ptr< etiss::VirtualStruct > vcpu_
cpu state structure allocated by arch_
static std::list< std::weak_ptr< CPUCore > > instances_
mutext for access to a list of cpu core instances
void removePlugin(std::shared_ptr< etiss::Plugin > plugin)
Remove a plug-in from the core simulator.
virtual std::shared_ptr< VirtualStruct > getStruct()
Get the virtual structure of this CPUCore instance.
etiss::InterruptEnable * getInterruptEnable()
const std::string & getName()
Get the name of the CPUCore instance.
etiss::InterruptVector * getInterruptVector()
Get the interrupt vector of simulated CPU.
etiss::InterruptEnable * intenable_
wrapped interrupt vector to allow interrupt listening
void setTimer(bool on)
Enable or disable the timer of the CPU.
interface to set interrupt bits
System Interface for the basic system IO operations and time synchronization.
Marker interface for toString() support.
basic cpu state structure needed for execution of any cpu architecture.
memory access and time synchronization functions.