2018-09-11 00:44:54 +08:00
|
|
|
/*!
|
2020-06-02 19:08:38 +08:00
|
|
|
\file Performance.h
|
|
|
|
\brief Class to store performance of CPU
|
|
|
|
\author Màrius Montón
|
|
|
|
\date Aug 2018
|
|
|
|
*/
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2018-09-11 00:44:54 +08:00
|
|
|
|
|
|
|
#ifndef PERFORMANCE_H
|
|
|
|
#define PERFORMANCE_H
|
|
|
|
|
|
|
|
#define SC_INCLUDE_DYNAMIC_PROCESSES
|
|
|
|
|
|
|
|
#include "systemc"
|
|
|
|
|
|
|
|
#include "tlm.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Performance indicators class
|
|
|
|
*
|
|
|
|
* Singleton class to be shared among all other classes
|
|
|
|
*/
|
2020-06-02 19:08:38 +08:00
|
|
|
class Performance {
|
2018-09-11 00:44:54 +08:00
|
|
|
public:
|
|
|
|
|
2020-06-02 19:08:38 +08:00
|
|
|
/**
|
|
|
|
* @brief Get an instance of the class
|
|
|
|
* @return pointer to Performance class
|
|
|
|
*/
|
|
|
|
static Performance* getInstance();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Increment data memory read counter
|
|
|
|
*/
|
|
|
|
inline void dataMemoryRead() {
|
|
|
|
data_memory_read++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Increment data memory write counter
|
|
|
|
*/
|
|
|
|
inline void dataMemoryWrite() {
|
|
|
|
data_memory_write++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Increment code memory read counter
|
|
|
|
*/
|
|
|
|
inline void codeMemoryRead() {
|
|
|
|
code_memory_read++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Increment code memory write counter
|
|
|
|
*/
|
|
|
|
inline void codeMemoryWrite() {
|
|
|
|
code_memory_write++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Increment register read counter
|
|
|
|
*/
|
|
|
|
inline void registerRead() {
|
|
|
|
register_read++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Increment register write counter
|
|
|
|
*/
|
|
|
|
inline void registerWrite() {
|
|
|
|
register_write++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Increment instructions executed counter
|
|
|
|
*/
|
|
|
|
inline void instructionsInc() {
|
|
|
|
instructions_executed++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Dump counters to cout
|
|
|
|
*/
|
2021-01-23 18:44:10 +08:00
|
|
|
void dump() const;
|
2018-09-11 00:44:54 +08:00
|
|
|
|
|
|
|
private:
|
2020-06-02 19:08:38 +08:00
|
|
|
static Performance *instance;
|
|
|
|
Performance();
|
|
|
|
|
2021-01-15 16:09:52 +08:00
|
|
|
uint_fast64_t data_memory_read;
|
|
|
|
uint_fast64_t data_memory_write;
|
|
|
|
uint_fast64_t code_memory_read;
|
|
|
|
uint_fast64_t code_memory_write;
|
|
|
|
uint_fast64_t register_read;
|
|
|
|
uint_fast64_t register_write;
|
|
|
|
uint_fast64_t instructions_executed;
|
2018-09-11 00:44:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|