Skip to content

Commit 7689986

Browse files
committed
Fix bug in TLM recorder and for single device addressing.
1 parent a549044 commit 7689986

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

src/libdramsys/DRAMSys/common/TlmRecorder.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ namespace DRAMSys
5454

5555
TlmRecorder::TlmRecorder(const std::string& name,
5656
const Configuration& config,
57-
const std::string& dbName) :
57+
const std::string& dbName,
58+
std::string mcconfig,
59+
std::string memspec,
60+
std::string traces) :
5861
name(name),
5962
config(config),
6063
memSpec(*config.memSpec),
@@ -76,7 +79,7 @@ TlmRecorder::TlmRecorder(const std::string& name,
7679
executeInitialSqlCommand();
7780
prepareSqlStatements();
7881

79-
insertGeneralInfo();
82+
insertGeneralInfo(mcconfig, memspec, traces);
8083
insertCommandLengths();
8184

8285
PRINTDEBUGMESSAGE(name, "Starting new database transaction");
@@ -432,7 +435,7 @@ void TlmRecorder::insertDebugMessageInDB(const std::string& message, const sc_ti
432435
executeSqlStatement(insertDebugMessageStatement);
433436
}
434437

435-
void TlmRecorder::insertGeneralInfo()
438+
void TlmRecorder::insertGeneralInfo(std::string mcconfig, std::string memspec, std::string traces)
436439
{
437440
sqlite3_bind_int(
438441
insertGeneralInfoStatement, 1, static_cast<int>(config.memSpec->ranksPerChannel));

src/libdramsys/DRAMSys/common/TlmRecorder.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,18 @@ namespace DRAMSys
6262
class TlmRecorder
6363
{
6464
public:
65-
TlmRecorder(const std::string& name, const Configuration& config, const std::string& dbName);
65+
TlmRecorder(const std::string& name,
66+
const Configuration& config,
67+
const std::string& dbName,
68+
std::string mcconfig,
69+
std::string memspec,
70+
std::string traces);
6671
TlmRecorder(const TlmRecorder&) = delete;
6772
TlmRecorder(TlmRecorder&&) = default;
6873
TlmRecorder& operator=(const TlmRecorder&) = delete;
6974
TlmRecorder& operator=(TlmRecorder&&) = delete;
7075
~TlmRecorder() = default;
7176

72-
void recordMcConfig(std::string _mcconfig) { mcconfig = std::move(_mcconfig); }
73-
74-
void recordMemspec(std::string _memspec) { memspec = std::move(_memspec); }
75-
76-
void recordTraceNames(std::string _traces) { traces = std::move(_traces); }
77-
7877
void recordPhase(tlm::tlm_generic_payload& trans,
7978
const tlm::tlm_phase& phase,
8079
const sc_core::sc_time& delay);
@@ -157,8 +156,6 @@ class TlmRecorder
157156
std::vector<Phase> recordedPhases;
158157
};
159158

160-
std::string mcconfig, memspec, traces;
161-
162159
void prepareSqlStatements();
163160
void executeInitialSqlCommand();
164161
static void executeSqlStatement(sqlite3_stmt* statement);
@@ -171,7 +168,7 @@ class TlmRecorder
171168

172169
void terminateRemainingTransactions();
173170
void commitRecordedDataToDB();
174-
void insertGeneralInfo();
171+
void insertGeneralInfo(std::string mcconfig, std::string memspec, std::string traces);
175172
void insertCommandLengths();
176173
void insertTransactionInDB(const Transaction& recordingData);
177174
void insertRangeInDB(uint64_t id, const sc_core::sc_time& begin, const sc_core::sc_time& end);

src/libdramsys/DRAMSys/simulation/AddressDecoder.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,17 @@ AddressDecoder::AddressDecoder(const DRAMSys::Config::AddressMapping& addressMap
125125
SC_REPORT_FATAL("AddressDecoder", "Not all address bits occur exactly once");
126126
}
127127

128-
unsigned highestByteBit = *std::max_element(vByteBits.begin(), vByteBits.end());
128+
int highestByteBit = -1;
129129

130-
for (unsigned bitPosition = 0; bitPosition <= highestByteBit; bitPosition++)
130+
if (!vByteBits.empty())
131131
{
132-
if (std::find(vByteBits.begin(), vByteBits.end(), bitPosition) == vByteBits.end())
133-
SC_REPORT_FATAL("AddressDecoder", "Byte bits are not continuous starting from 0");
132+
highestByteBit = static_cast<int>(*std::max_element(vByteBits.begin(), vByteBits.end()));
133+
134+
for (unsigned bitPosition = 0; bitPosition <= highestByteBit; bitPosition++)
135+
{
136+
if (std::find(vByteBits.begin(), vByteBits.end(), bitPosition) == vByteBits.end())
137+
SC_REPORT_FATAL("AddressDecoder", "Byte bits are not continuous starting from 0");
138+
}
134139
}
135140

136141
auto maxBurstLengthBits = static_cast<unsigned>(std::log2(memSpec.maxBurstLength));

src/libdramsys/DRAMSys/simulation/DRAMSysRecordable.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,8 @@ void DRAMSysRecordable::setupTlmRecorders(const std::string& traceName,
118118
mcconfig[Config::McConfig::KEY] = configLib.mcconfig;
119119
memspec[Config::MemSpec::KEY] = configLib.memspec;
120120

121-
tlmRecorders.emplace_back(recorderName, config, dbName);
122-
tlmRecorders.back().recordMcConfig(mcconfig.dump());
123-
tlmRecorders.back().recordMemspec(memspec.dump());
124-
tlmRecorders.back().recordTraceNames(config.simulationName);
121+
tlmRecorders.emplace_back(
122+
recorderName, config, dbName, mcconfig.dump(), memspec.dump(), config.simulationName);
125123
}
126124
}
127125

0 commit comments

Comments
 (0)