ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
CSRCounters.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
6
7#include <cstdint>
8#include "etiss/CPUArch.h"
9#include "etiss/jit/CPU.h"
10#include "etiss/CPUCore.h"
11#include "etiss/ETISS.h"
12#include <chrono>
13
14using namespace etiss;
15
16extern "C"
17{
18
19 uint64 etiss_get_cycles(ETISS_CPU *const cpu, ETISS_System *const system, void *const *const plugin_pointers)
20 {
21 return cpu->cpuTime_ps / cpu->cpuCycleTime_ps;
22 }
23
25 {
26 auto steady_now = std::chrono::system_clock::now().time_since_epoch();
27 auto us = std::chrono::duration_cast<std::chrono::microseconds>(steady_now);
28 return (uint64)us.count();
29 }
30
31 uint64 etiss_get_instret(ETISS_CPU *const cpu, ETISS_System *const system, void *const *const plugin_pointers)
32 {
33 return cpu->cpuTime_ps / cpu->cpuCycleTime_ps;
34 }
35}
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)
uint64 etiss_get_cycles(ETISS_CPU *const cpu, ETISS_System *const system, void *const *const plugin_pointers)
uint64 etiss_get_time()
Header file of the ETISS library.
forwards: include/jit/*
Definition Benchmark.h:17
basic cpu state structure needed for execution of any cpu architecture.
Definition CPU.h:51
etiss_uint64 cpuCycleTime_ps
frequency of the cpu. use to allign e.g. memory delays
Definition CPU.h:67
etiss_uint64 cpuTime_ps
simulation time of cpu
Definition CPU.h:59
memory access and time synchronization functions.
Definition System.h:40