Added support to single-line comments in STL files (issue#45).

Lines which start with '#' will be ignored by trace players.

From IP_GFRBM.pdf:
STL syntax supports only single line comments. A single-line comment is
everything on a line following but not including the first occurrence of the #
character and up to, but not including the end of the line. For example:

 # this is a comment

Comments should always begin in a new line.
This commit is contained in:
Éder F. Zulian
2016-02-17 13:24:10 -02:00
parent 6d8a31a904
commit 636ff65a38
3 changed files with 31 additions and 38 deletions

View File

@@ -109,7 +109,7 @@ void Simulation::setupTlmRecorders(const string &traceName, const string &pathTo
void Simulation::instantiateModules(const string &traceName, const string &pathToResources, const std::vector<Device> &devices)
{
// The first call to getInstance() creates the Temperature Controller.
// The same instance will can be accessed by all other modules.
// The same instance will be accessed by all other modules.
TemperatureController::getInstance();
for (size_t i = 0; i < Configuration::getInstance().NumberOfTracePlayers; i++) {

View File

@@ -49,18 +49,21 @@ template<unsigned int BUSWIDTH = 128>
struct StlDataPlayer: public TracePlayer<BUSWIDTH>
{
public:
StlDataPlayer(sc_module_name /*name*/, string pathToTrace, unsigned int clkMhz,
TracePlayerListener* listener);
StlDataPlayer(sc_module_name /*name*/, string pathToTrace, unsigned int clkMhz, TracePlayerListener* listener);
virtual void nextPayload() override
{
string line;
while(line.empty() && file)
{
std::string line;
while (line.empty() && file) {
std::getline(file, line);
// Ignore lines which begin with '#' (commented lines)
if (!line.empty() && line.at(0) == '#') {
line.clear();
}
}
if(!file)
{
if(!file) {
this->terminate();
return;
}
@@ -118,26 +121,19 @@ public:
dataElement[i] = std::stoi(byteString.c_str(), 0, 16);
}
}
}
else
{
SC_REPORT_FATAL(0,
(string("Corrupted tracefile, command ") + command + string(" unknown")).c_str());
} else {
SC_REPORT_FATAL(0, (string("Corrupted tracefile, command ") + command + string(" unknown")).c_str());
}
sc_time sendingTime = std::stoull(time.c_str())*clk;
if (sendingTime <= sc_time_stamp())
{
if (sendingTime <= sc_time_stamp()) {
this->payloadEventQueue.notify(*payload, BEGIN_REQ, SC_ZERO_TIME);
}
else
{
} else {
this->payloadEventQueue.notify(*payload, BEGIN_REQ, sendingTime - sc_time_stamp());
}
}
private:
ifstream file;
unsigned int burstlength;
@@ -164,3 +160,4 @@ StlDataPlayer<BUSWIDTH>::StlDataPlayer(sc_module_name /*name*/, string pathToTra
}
#endif // STLDATAPLAYER_H

View File

@@ -49,23 +49,25 @@ template<unsigned int BUSWIDTH = 128>
struct StlPlayer: public TracePlayer<BUSWIDTH>
{
public:
StlPlayer(sc_module_name /*name*/, string pathToTrace, unsigned int clkMhz,
TracePlayerListener* listener);
StlPlayer(sc_module_name /*name*/, string pathToTrace, unsigned int clkMhz, TracePlayerListener *listener);
virtual void nextPayload() override
{
string line;
while(line.empty() && file)
{
std::string line;
while (line.empty() && file) {
std::getline(file, line);
// Ignore lines which begin with '#' (commented lines)
if (!line.empty() && line.at(0) == '#') {
line.clear();
}
}
if(!file)
{
if(!file) {
this->terminate();
return;
}
std::istringstream iss(line);
string time, command, address;
iss >> time >> command >> address;
@@ -105,26 +107,19 @@ public:
dataElement[i] = std::stoi(byteString.c_str(), 0, 16);
}
}
}
else
{
SC_REPORT_FATAL(0,
(string("Corrupted tracefile, command ") + command + string(" unknown")).c_str());
} else {
SC_REPORT_FATAL(0, (string("Corrupted tracefile, command ") + command + string(" unknown")).c_str());
}
sc_time sendingTime = std::stoull(time.c_str())*clk;
if (sendingTime <= sc_time_stamp())
{
if (sendingTime <= sc_time_stamp()) {
this->payloadEventQueue.notify(*payload, BEGIN_REQ, SC_ZERO_TIME);
}
else
{
} else {
this->payloadEventQueue.notify(*payload, BEGIN_REQ, sendingTime - sc_time_stamp());
}
}
private:
ifstream file;
unsigned int burstlength;
@@ -151,3 +146,4 @@ StlPlayer<BUSWIDTH>::StlPlayer(sc_module_name /*name*/, string pathToTrace, unsi
}
#endif // STLPLAYER_H