ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
CSRCounters.cpp
Go to the documentation of this file.
1 #include <cstdint>
2 #include "etiss/CPUArch.h"
3 #include "etiss/jit/CPU.h"
4 #include "etiss/CPUCore.h"
5 #include "etiss/ETISS.h"
6 #include <chrono>
7 
8 using namespace etiss;
9 
10 extern "C"
11 {
12 
13  uint64 etiss_get_cycles(ETISS_CPU * const cpu, ETISS_System * const system, void * const * const plugin_pointers)
14  {
15  return cpu->cpuTime_ps / cpu->cpuCycleTime_ps;
16  }
17 
19  {
20  auto steady_now = std::chrono::system_clock::now().time_since_epoch();
21  auto us = std::chrono::duration_cast<std::chrono::microseconds>(steady_now);
22  return (uint64)us.count();
23  }
24 
25 
26  uint64 etiss_get_instret(ETISS_CPU * const cpu, ETISS_System * const system, void * const * const plugin_pointers)
27  {
28  return cpu->cpuTime_ps / cpu->cpuCycleTime_ps;
29  }
30 
31 }
etiss_uint64 uint64
Definition: 386-GCC.h:82
contains neccesary interfaces for instruction translation.
defines main cpu core interface
uint64 etiss_get_instret(ETISS_CPU *const cpu, ETISS_System *const system, void *const *const plugin_pointers)
Definition: CSRCounters.cpp:26
uint64 etiss_get_cycles(ETISS_CPU *const cpu, ETISS_System *const system, void *const *const plugin_pointers)
Definition: CSRCounters.cpp:13
uint64 etiss_get_time()
Definition: CSRCounters.cpp:18
Header file of the ETISS library.
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition: Benchmark.h:53
basic cpu state structure needed for execution of any cpu architecture.
Definition: CPU.h:89
etiss_uint64 cpuCycleTime_ps
frequency of the cpu. use to allign e.g. memory delays
Definition: CPU.h:105
etiss_uint64 cpuTime_ps
simulation time of cpu
Definition: CPU.h:97
memory access and time synchronization functions.
Definition: System.h:78