Files
DRAMSys/dram/src/common/TlmRecorder.h
2014-03-29 00:26:21 +01:00

70 lines
2.4 KiB
C++
Executable File

#ifndef TLMPHASERECORDER_H
#define TLMPHASERECORDER_H
#include <iostream>
#include <ostream>
#include <string>
#include <map>
#include <algorithm>
#include <sqlite3.h>
#include <fstream>
#include <cerrno>
#include <tlm.h>
#include <systemc.h>
#include "xmlAddressdecoder.h"
#include "DebugManager.h"
using namespace std;
class TlmRecorder
{
public:
TlmRecorder(std::string dbName, std::string sqlScriptURI);
~TlmRecorder();
void recordPhase(tlm::tlm_generic_payload &trans, tlm::tlm_phase phase, sc_time time);
void recordPhase(tlm::tlm_generic_payload &trans, std::string name, sc_time begin, sc_time end);
void recordDebugMessage(std::string message, sc_time time);
void introduceNewTransactionToSystem(const sc_time& time, tlm::tlm_generic_payload& trans);
void removeTransactionFromSystem(const sc_time& time, tlm::tlm_generic_payload& trans);
void closeConnection();
private:
std::string dbName;
std::string phaseToString(tlm::tlm_phase phase);
std::string getFileContents(std::string filename);
void executeSqlCommand(std::string command);
void executeSqlStatement(sqlite3_stmt* statement);
void prepareSqlStatements();
void openDB(std::string name);
void setUpTransactionTerminatingPhases();
void createTables(std::string pathToURI);
void insertGeneralInfo();
void insertTransactionInDB(unsigned int transactionID, tlm::tlm_generic_payload& trans);
void insertRangeInDB(unsigned int transactionID, const sc_time& time);
void insertPhaseInDB(string phaseName, const sc_time& begin, const sc_time& end, unsigned int id);
void updatePhaseEndInDB(string phaseName, const sc_time& time, tlm::tlm_generic_payload& trans);
void insertDebugMessageInDB(string message, const sc_time& time);
void printDebugMessage(std::string message, Importance importance = Importance::Info);
static const int transactionCommitRate = 10000;
map<tlm::tlm_generic_payload*, unsigned int> currentTransactionsInSystem;
unsigned int transactionIDCounter;
sc_time recordingEndTime;
std::vector<tlm::tlm_phase> transactionTerminatingPhases;
sqlite3 *db;
sqlite3_stmt *insertTransactionStatement, *insertRangeStatement, *updateRangeStatement,
*insertPhaseStatement, *updatePhaseStatement, *insertGeneralInfoStatement, *insertDebugMessageStatement;
std::string insertTransactionString, insertRangeString, updateRangeString, insertPhaseString, updatePhaseString, insertGeneralInfoString,
insertDebugMessageString;
};
#endif