Removed namespace std.

This commit is contained in:
Lukas Steiner
2020-03-27 16:32:52 +01:00
parent b1efbb8721
commit bcffb0c55b
23 changed files with 93 additions and 120 deletions

View File

@@ -39,14 +39,13 @@
#ifdef DEBUGGING
#include "../configuration/Configuration.h"
using namespace std;
void DebugManager::printDebugMessage(string sender, string message)
void DebugManager::printDebugMessage(std::string sender, std::string message)
{
if (Configuration::getInstance().Debug) {
if (writeToConsole)
cout << " at " << sc_time_stamp() << "\t in " << sender << "\t: " << message <<
endl;
std::cout << " at " << sc_time_stamp() << "\t in " << sender << "\t: " << message <<
std::endl;
if (writeToFile && debugFile)
debugFile << " at " << sc_time_stamp() << " in " << sender << "\t: " << message
@@ -54,13 +53,13 @@ void DebugManager::printDebugMessage(string sender, string message)
}
}
void DebugManager::printMessage(string sender, string message)
void DebugManager::printMessage(std::string sender, std::string message)
{
cout << " at " << sc_time_stamp() << "\t in " << sender << "\t: " << message <<
endl;
std::cout << " at " << sc_time_stamp() << "\t in " << sender << "\t: " << message <<
std::endl;
}
void DebugManager::openDebugFile(string filename)
void DebugManager::openDebugFile(std::string filename)
{
if (debugFile)
debugFile.close();

View File

@@ -100,7 +100,7 @@ void TlmRecorder::recordPhase(tlm_generic_payload &trans,
std::string phaseBeginPrefix = "BEGIN_";
std::string phaseEndPrefix = "END_";
if (phaseName.find(phaseBeginPrefix) != string::npos) {
if (phaseName.find(phaseBeginPrefix) != std::string::npos) {
phaseName.erase(0, phaseBeginPrefix.length());
assert(currentTransactionsInSystem.count(&trans) != 0);
currentTransactionsInSystem[&trans].insertPhase(phaseName, time);
@@ -439,7 +439,7 @@ void TlmRecorder::executeSqlStatement(sqlite3_stmt *statement)
int errorCode = sqlite3_step(statement);
if (errorCode != SQLITE_DONE) {
reportFatal("Error in TraceRecorder",
string("Could not execute statement. Error code: ") + to_string(errorCode));
std::string("Could not execute statement. Error code: ") + std::to_string(errorCode));
}
sqlite3_reset(statement);
}

View File

@@ -53,7 +53,7 @@ void XmlAddressDecoder::setConfiguration(std::string addressConfigURI)
tinyxml2::XMLDocument doc;
loadXML(addressConfigURI, doc);
tinyxml2::XMLElement *addressMap = doc.RootElement();
string xmlNodeName(addressMap->Name());
std::string xmlNodeName(addressMap->Name());
if (xmlNodeName != "addressmapping")
reportFatal("AddressDecorder", "addressmap node expected");

View File

@@ -42,7 +42,6 @@
#include "dramExtensions.h"
#include <sstream>
using namespace std;
using namespace tinyxml2;
using namespace tlm;
@@ -78,7 +77,7 @@ std::string phaseNameToString(tlm_phase phase)
return str;
}
unsigned int queryUIntParameter(XMLElement *node, string name)
unsigned int queryUIntParameter(XMLElement *node, std::string name)
{
int result = 0;
XMLElement *element;
@@ -109,7 +108,7 @@ bool parameterExists(tinyxml2::XMLElement *node, std::string name)
return false;
}
double queryDoubleParameter(XMLElement *node, string name)
double queryDoubleParameter(XMLElement *node, std::string name)
{
double result = 0;
XMLElement *element;
@@ -128,7 +127,7 @@ double queryDoubleParameter(XMLElement *node, string name)
return 0;
}
bool queryBoolParameter(XMLElement *node, string name)
bool queryBoolParameter(XMLElement *node, std::string name)
{
bool result = false;
XMLElement *element;// = node->FirstChildElement("parameter");
@@ -147,7 +146,7 @@ bool queryBoolParameter(XMLElement *node, string name)
return 0;
}
string queryStringParameter(XMLElement *node, string name)
std::string queryStringParameter(XMLElement *node, std::string name)
{
XMLElement *element;
for (element = node->FirstChildElement("parameter"); element != NULL;
@@ -161,7 +160,7 @@ string queryStringParameter(XMLElement *node, string name)
return 0;
}
string errorToString(XMLError error)
std::string errorToString(XMLError error)
{
switch (error) {
case XML_NO_ERROR:
@@ -209,7 +208,7 @@ string errorToString(XMLError error)
}
}
void loadXML(string uri, XMLDocument &doc)
void loadXML(std::string uri, XMLDocument &doc)
{
XMLError error = doc.LoadFile(uri.c_str());
@@ -219,12 +218,12 @@ void loadXML(string uri, XMLDocument &doc)
}
}
string loadTextFileContents(string filename)
std::string loadTextFileContents(std::string filename)
{
ifstream in(filename.c_str(), ios::in | ios::binary);
if (in) {
string contents;
std::string contents;
in.seekg(0, ios::end);
contents.resize(in.tellg());
in.seekg(0, ios::beg);

View File

@@ -42,12 +42,10 @@
#include "ConfigurationLoader.h"
#include "../common/XmlAddressDecoder.h"
using namespace std;
std::string Configuration::memspecUri = "";
std::string Configuration::mcconfigUri = "";
string Configuration::memspecUri = "";
string Configuration::mcconfigUri = "";
enum sc_time_unit string2TimeUnit(string s)
enum sc_time_unit string2TimeUnit(std::string s)
{
if (s == "s")
return SC_SEC;

View File

@@ -48,10 +48,9 @@
#include "memspec/MemSpecGDDR6.h"
using namespace tinyxml2;
using namespace std;
void ConfigurationLoader::loadSimConfig(Configuration &config,
string simconfigUri)
std::string simconfigUri)
{
tinyxml2::XMLDocument doc;
@@ -65,7 +64,7 @@ void ConfigurationLoader::loadSimConfig(Configuration &config,
{
if (simconfig->Attribute("src")) {
XMLDocument doc;
string src(simconfig->Attribute("src"));
std::string src(simconfig->Attribute("src"));
loadXML(src, doc);
loadSimConfig(config, doc.FirstChildElement("simconfig"));
}
@@ -111,7 +110,7 @@ void ConfigurationLoader::loadConfigFromUri(Configuration &config,
}
void ConfigurationLoader::loadMCConfig(Configuration &config,
string mcconfigUri)
std::string mcconfigUri)
{
tinyxml2::XMLDocument doc;
config.mcconfigUri = mcconfigUri;
@@ -126,7 +125,7 @@ void ConfigurationLoader::loadMCConfig(Configuration &config,
if (mcconfig->Attribute("src"))
{
XMLDocument doc;
string src(mcconfig->Attribute("src"));
std::string src(mcconfig->Attribute("src"));
config.mcconfigUri = src;
loadXML(src, doc);
loadMCConfig(config, doc.FirstChildElement("mcconfig"));
@@ -135,7 +134,7 @@ void ConfigurationLoader::loadMCConfig(Configuration &config,
loadConfig(config, mcconfig);
}
void ConfigurationLoader::loadMemSpec(Configuration &config, string memspecUri)
void ConfigurationLoader::loadMemSpec(Configuration &config, std::string memspecUri)
{
tinyxml2::XMLDocument doc;
config.memspecUri = memspecUri;
@@ -147,7 +146,7 @@ void ConfigurationLoader::loadMemSpec(Configuration &config, string memspecUri)
void ConfigurationLoader::loadMemSpec(Configuration &config,
XMLElement *memspec)
{
string memoryType = queryStringParameter(memspec, "memoryType");
std::string memoryType = queryStringParameter(memspec, "memoryType");
if (memoryType == "DDR4")
{
Configuration::getInstance().memSpec = new MemSpecDDR4();

View File

@@ -11,7 +11,6 @@
#include "../common/XmlAddressDecoder.h"
#include "../common/DebugManager.h"
using namespace std;
using namespace tlm;
class ECCBaseClass : sc_module
@@ -23,7 +22,7 @@ public:
};
private:
map<unsigned char *, DataStruct> m_mDataPointer;
std::map<unsigned char *, DataStruct> m_mDataPointer;
public:
// Function prototype for calculated the size of memory needed for saving the encoded data

View File

@@ -37,7 +37,6 @@
#include "Arbiter.h"
using namespace std;
using namespace tlm;
Arbiter::Arbiter(sc_module_name name) :
@@ -51,7 +50,7 @@ Arbiter::Arbiter(sc_module_name name) :
for (size_t i = 0; i < Configuration::getInstance().numberOfMemChannels; ++i)
{
channelIsFree.push_back(true);
pendingRequests.push_back(queue<tlm_generic_payload *>());
pendingRequests.push_back(std::queue<tlm_generic_payload *>());
nextPayloadID.push_back(0);
}

View File

@@ -50,7 +50,6 @@
#include "../common/dramExtensions.h"
#include "../configuration/ConfigurationLoader.h"
using namespace std;
using namespace tlm;
class Arbiter : public sc_module
@@ -65,14 +64,14 @@ public:
private:
tlm_utils::peq_with_cb_and_phase<Arbiter> payloadEventQueue;
vector<bool> channelIsFree;
std::vector<bool> channelIsFree;
// used to account for the request_accept_delay in the dram controllers
// This is a queue of new transactions. The phase of a new request is BEGIN_REQ.
vector<queue<tlm_generic_payload *>> pendingRequests;
std::vector<std::queue<tlm_generic_payload *>> pendingRequests;
// used to account for the response_accept_delay in the initiators (traceplayer, core etc.)
// This is a queue of responses comming from the memory side. The phase of these transactions is BEGIN_RESP.
std::map<unsigned int, queue<tlm_generic_payload *>> receivedResponses;
std::map<unsigned int, std::queue<tlm_generic_payload *>> receivedResponses;
// Initiated by initiator side
// This function is called when an arbiter's target socket receives a transaction from a device
@@ -84,7 +83,7 @@ private:
tlm_sync_enum nb_transport_bw(int channelId, tlm_generic_payload &payload,
tlm_phase &phase, sc_time &bwDelay);
virtual unsigned int transport_dbg(int /*id*/, tlm::tlm_generic_payload &trans);
virtual unsigned int transport_dbg(int /*id*/, tlm_generic_payload &trans);
void peqCallback(tlm_generic_payload &payload, const tlm_phase &phase);

View File

@@ -65,11 +65,9 @@
#include "../controller/Controller.h"
#include "../controller/ControllerRecordable.h"
using namespace std;
DRAMSys::DRAMSys(sc_module_name name,
string simulationToRun,
string pathToResources) : sc_module(name), tSocket("DRAMSys_tSocket")
std::string simulationToRun,
std::string pathToResources) : sc_module(name), tSocket("DRAMSys_tSocket")
{
// Initialize ecc pointer
ecc = nullptr;
@@ -77,11 +75,11 @@ DRAMSys::DRAMSys(sc_module_name name,
logo();
// Read Configuration Setup:
string memspec;
string mcconfig;
string amconfig;
string simconfig;
string thermalconfig;
std::string memspec;
std::string mcconfig;
std::string amconfig;
std::string simconfig;
std::string thermalconfig;
// TODO: Setup never used?
Setup setup(simulationToRun,
@@ -165,22 +163,22 @@ DRAMSys::DRAMSys(sc_module_name name,
void DRAMSys::logo()
{
#define REDTXT(s) string(("\033[0;31m"+string((s))+"\033[0m"))
#define BOLDBLUETXT(s) string(("\033[1;34m"+string((s))+"\033[0m"))
cout << endl;
cout << REDTXT(" |||") << endl;
cout << REDTXT(" +---+ Microelectronic Systems") << endl;
cout << REDTXT("=| |= Design Research Group") << endl;
cout << REDTXT("=| |= ") << BOLDBLUETXT("University of Kaiserslautern")
<< endl;
cout << REDTXT(" +---+ ") << endl;
cout << REDTXT(" ||| ") << "DRAMSys v4.0" << endl;
cout << endl;
#define REDTXT(s) std::string("\033[0;31m"+std::string(s)+"\033[0m")
#define BOLDBLUETXT(s) std::string("\033[1;34m"+std::string(s)+"\033[0m")
std::cout << std::endl;
std::cout << REDTXT(" |||") << std::endl;
std::cout << REDTXT(" +---+ Microelectronic Systems") << std::endl;
std::cout << REDTXT("=| |= Design Research Group") << std::endl;
std::cout << REDTXT("=| |= ") << BOLDBLUETXT("University of Kaiserslautern")
<< std::endl;
std::cout << REDTXT(" +---+ ") << std::endl;
std::cout << REDTXT(" ||| ") << "DRAMSys v4.0" << std::endl;
std::cout << std::endl;
#undef REDTXT
#undef BOLDBLUETXT
}
void DRAMSys::setupDebugManager(const string &traceName __attribute__((unused)))
void DRAMSys::setupDebugManager(const std::string &traceName __attribute__((unused)))
{
#ifdef DEBUGGING
auto &dbg = DebugManager::getInstance();
@@ -191,18 +189,18 @@ void DRAMSys::setupDebugManager(const string &traceName __attribute__((unused)))
#endif
}
void DRAMSys::setupTlmRecorders(const string &traceName,
const string &pathToResources)
void DRAMSys::setupTlmRecorders(const std::string &traceName,
const std::string &pathToResources)
{
// Create TLM Recorders, one per channel.
for (size_t i = 0;
i < Configuration::getInstance().numberOfMemChannels;
i++) {
std::string sqlScriptURI = pathToResources
+ string("scripts/createTraceDB.sql");
+ std::string("scripts/createTraceDB.sql");
std::string dbName = traceName
+ string("_ch")
+ std::string("_ch")
+ std::to_string(i)
+ ".tdb";
@@ -220,8 +218,8 @@ void DRAMSys::setupTlmRecorders(const string &traceName,
}
}
void DRAMSys::instantiateModules(const string &traceName,
const string &pathToResources)
void DRAMSys::instantiateModules(const std::string &traceName,
const std::string &pathToResources)
{
// The first call to getInstance() creates the Temperature Controller.
// The same instance will be accessed by all other modules.
@@ -401,8 +399,8 @@ DRAMSys::~DRAMSys()
}
}
void DRAMSys::report(string message)
void DRAMSys::report(std::string message)
{
PRINTDEBUGMESSAGE(name(), message);
cout << message << endl;
std::cout << message << std::endl;
}

View File

@@ -66,8 +66,8 @@ public:
SC_HAS_PROCESS(DRAMSys);
DRAMSys(sc_module_name name,
string simulationToRun,
string pathToResources);
std::string simulationToRun,
std::string pathToResources);
~DRAMSys();
@@ -100,12 +100,12 @@ private:
std::vector<TlmRecorder *> tlmRecorders;
void report(std::string message);
void setupTlmRecorders(const string &traceName,
const string &pathToResources);
void instantiateModules(const string &traceName,
const string &pathToResources);
void setupTlmRecorders(const std::string &traceName,
const std::string &pathToResources);
void instantiateModules(const std::string &traceName,
const std::string &pathToResources);
void bindSockets();
void setupDebugManager(const string &traceName);
void setupDebugManager(const std::string &traceName);
};
#endif // DRAMSYS_H

View File

@@ -8,8 +8,6 @@
#include "../common/dramExtensions.h"
#include "TracePlayer.h"
using namespace std;
struct ExampleInitiator : sc_module
{
// TLM-2 socket, defaults to 32-bits wide, base protocol

View File

@@ -46,7 +46,6 @@
#include <tlm_utils/multi_passthrough_initiator_socket.h>
#include "../configuration/ConfigurationLoader.h"
using namespace std;
using namespace tlm;
struct IArbiter : public sc_module

View File

@@ -39,12 +39,7 @@
#include "../configuration/Configuration.h"
#include <iostream>
using namespace std;
MemoryManager::MemoryManager(): numberOfAllocations(0), numberOfFrees(0)
{
}
MemoryManager::MemoryManager(): numberOfAllocations(0), numberOfFrees(0) {}
MemoryManager::~MemoryManager()
{

View File

@@ -42,7 +42,6 @@
#include <systemc.h>
#include <set>
using namespace std;
using namespace tlm;
struct ReorderBuffer: public sc_module {
@@ -61,7 +60,7 @@ public:
private:
tlm_utils::peq_with_cb_and_phase<ReorderBuffer> payloadEventQueue;
deque<tlm_generic_payload *> pendingRequestsInOrder;
set<tlm_generic_payload *> receivedResponses;
std::set<tlm_generic_payload *> receivedResponses;
bool responseIsPendingInInitator;

View File

@@ -40,9 +40,7 @@
#include "IArbiter.h"
#include "../common/XmlAddressDecoder.h"
#include "../common/dramExtensions.h"
#include "../controller/core/timingCalculations.h"
using namespace std;
using namespace tlm;
// Annotated References [X,Y] --> Please refer to TLM AT Cheat Sheet on README

View File

@@ -43,7 +43,6 @@
#include "../common/XmlAddressDecoder.h"
#include "TracePlayer.h"
using namespace std;
using namespace tlm;
template<bool relative>
@@ -51,14 +50,14 @@ class StlPlayer : public TracePlayer
{
public:
StlPlayer(sc_module_name name,
string pathToTrace,
std::string pathToTrace,
sc_time playerClk,
TracePlayerListener *listener) :
TracePlayer(name, listener),
file(pathToTrace)
{
if (!file.is_open())
SC_REPORT_FATAL(0, (string("Could not open trace ") + pathToTrace).c_str());
SC_REPORT_FATAL(0, (std::string("Could not open trace ") + pathToTrace).c_str());
this->playerClk = playerClk;
this->burstlength = Configuration::getInstance().memSpec->BurstLength;
@@ -93,10 +92,10 @@ public:
// Trace files MUST provide timestamp, command and address for every
// transaction. The data information depends on the storage mode
// configuration.
string time;
string command;
string address;
string dataStr;
std::string time;
std::string command;
std::string address;
std::string dataStr;
std::istringstream iss(line);
@@ -104,7 +103,7 @@ public:
iss >> time;
if (time.empty())
SC_REPORT_FATAL("StlPlayer",
("Malformed trace file. Timestamp could not be found (line " + to_string(
("Malformed trace file. Timestamp could not be found (line " + std::to_string(
lineCnt) + ").").c_str());
sc_time sendingTime = std::stoull(time.c_str()) * playerClk;
@@ -112,7 +111,7 @@ public:
iss >> command;
if (command.empty())
SC_REPORT_FATAL("StlPlayer",
("Malformed trace file. Command could not be found (line " + to_string(
("Malformed trace file. Command could not be found (line " + std::to_string(
lineCnt) + ").").c_str());
enum tlm_command cmd;
if (command == "read") {
@@ -121,15 +120,15 @@ public:
cmd = TLM_WRITE_COMMAND;
} else {
SC_REPORT_FATAL("StlPlayer",
(string("Corrupted tracefile, command ") + command +
string(" unknown")).c_str());
(std::string("Corrupted tracefile, command ") + command +
std::string(" unknown")).c_str());
}
// Get the address.
iss >> address;
if (address.empty())
SC_REPORT_FATAL("StlPlayer",
("Malformed trace file. Address could not be found (line " + to_string(
("Malformed trace file. Address could not be found (line " + std::to_string(
lineCnt) + ").").c_str());
unsigned long long addr = std::stoull(address.c_str(), 0, 16);
@@ -140,13 +139,13 @@ public:
iss >> dataStr;
if (dataStr.empty())
SC_REPORT_FATAL("StlPlayer",
("Malformed trace file. Data information could not be found (line " + to_string(
("Malformed trace file. Data information could not be found (line " + std::to_string(
lineCnt) + ").").c_str());
// Check if data length in the trace file is correct. We need two characters to represent 1 byte in hexadecimal.
if (dataStr.length() != (dataLength * 2))
SC_REPORT_FATAL("StlPlayer",
("Data in the trace file has an invalid length (line " + to_string(
("Data in the trace file has an invalid length (line " + std::to_string(
lineCnt) + ").").c_str());
// Set data
@@ -178,7 +177,7 @@ public:
}
private:
ifstream file;
std::ifstream file;
unsigned int lineCnt;
unsigned int burstlength;

View File

@@ -40,7 +40,6 @@
#include "TracePlayer.h"
using namespace std;
using namespace tlm;
struct TraceGenerator : public TracePlayer

View File

@@ -112,7 +112,7 @@ void TracePlayer::setNumberOfTransactions(unsigned int n)
numberOfTransactions = n;
}
unsigned int TracePlayer::getNumberOfLines(string pathToTrace)
unsigned int TracePlayer::getNumberOfLines(std::string pathToTrace)
{
// Reference: http://stackoverflow.com/questions/3482064/counting-the-number-of-lines-in-a-text-file
ifstream newFile;

View File

@@ -52,7 +52,6 @@
#include "../common/XmlAddressDecoder.h"
#include "TracePlayerListener.h"
using namespace std;
using namespace tlm;
struct TracePlayer : public sc_module
@@ -61,7 +60,7 @@ public:
tlm_utils::simple_initiator_socket<TracePlayer> iSocket;
TracePlayer(sc_module_name name, TracePlayerListener *listener);
virtual void nextPayload() = 0;
unsigned int getNumberOfLines(string pathToTrace);
unsigned int getNumberOfLines(std::string pathToTrace);
protected:
gp *allocatePayload();

View File

@@ -79,7 +79,7 @@ traceSetup::traceSetup(std::string uri,
std::string ext = name.substr(pos + 1);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
std::string stlFile = pathToResources + string("traces/") + name;
std::string stlFile = pathToResources + std::string("traces/") + name;
std::string moduleName = name;
// replace all '.' to '_'
@@ -120,6 +120,6 @@ void traceSetup::transactionFinished()
loadbar(totalTransactions - remainingTransactions, totalTransactions);
if (remainingTransactions == 0) {
cout << endl;
std::cout << std::endl;
}
}

View File

@@ -48,7 +48,6 @@
#include "../../configuration/memspec/MemSpec.h"
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
using namespace std;
using namespace tlm;
using namespace DRAMPower;

View File

@@ -44,11 +44,9 @@
#include "DRAMSys.h"
#include "TraceSetup.h"
using namespace std;
std::string resources;
string resources;
string pathOfFile(string file)
std::string pathOfFile(std::string file)
{
return file.substr(0, file.find_last_of('/'));
}
@@ -63,19 +61,19 @@ int sc_main(int argc, char **argv)
sc_set_time_resolution(1, SC_PS);
string SimulationXML;
std::string SimulationXML;
// Run only with default config (ddr-example.xml):
if (argc == 1) {
// Get path of resources:
resources = pathOfFile(argv[0])
+ string("/../DRAMSys/library/resources/");
+ std::string("/../DRAMSys/library/resources/");
SimulationXML = resources + "simulations/ddr3-example.xml";
}
// Run with specific config but default resource folders:
else if (argc == 2) {
// Get path of resources:
resources = pathOfFile(argv[0])
+ string("/../DRAMSys/library/resources/");
+ std::string("/../DRAMSys/library/resources/");
SimulationXML = argv[1];
}
// Run with spefific config and specific resource folder:
@@ -96,7 +94,7 @@ int sc_main(int argc, char **argv)
for (size_t i = 0; i < players.size(); i++) {
if(Configuration::getInstance().checkTLM2Protocol)
{
string str = "TLMCheckerPlayer" + std::to_string(i);
std::string str = "TLMCheckerPlayer" + std::to_string(i);
tlm_utils::tlm2_base_protocol_checker<> *playerTlmChecker =
new tlm_utils::tlm2_base_protocol_checker<>(str.c_str());
dramSys->playersTlmCheckers.push_back(playerTlmChecker);