diff --git a/DRAMSys/simulator/StlPlayer.cpp b/DRAMSys/simulator/StlPlayer.cpp index 4a471931..4aa918ec 100644 --- a/DRAMSys/simulator/StlPlayer.cpp +++ b/DRAMSys/simulator/StlPlayer.cpp @@ -103,16 +103,16 @@ void StlPlayer::nextPayload() if (!relative) { - // Send the transaction directly or schedule it to be sent in the future. if (lineIterator->sendingTime <= sc_time_stamp()) - payloadEventQueue.notify(*payload, tlm::BEGIN_REQ, SC_ZERO_TIME); + sendToTarget(*payload, BEGIN_REQ, SC_ZERO_TIME); else - payloadEventQueue.notify(*payload, tlm::BEGIN_REQ, - lineIterator->sendingTime - sc_time_stamp()); + sendToTarget(*payload, BEGIN_REQ, lineIterator->sendingTime - sc_time_stamp()); } else - payloadEventQueue.notify(*payload, tlm::BEGIN_REQ, lineIterator->sendingTime); + sendToTarget(*payload, BEGIN_REQ, lineIterator->sendingTime); + transactionsSent++; + PRINTDEBUGMESSAGE(name(), "Performing request #" + std::to_string(transactionsSent)); lineIterator++; } diff --git a/DRAMSys/simulator/TracePlayer.cpp b/DRAMSys/simulator/TracePlayer.cpp index a87a5947..69e8b16a 100644 --- a/DRAMSys/simulator/TracePlayer.cpp +++ b/DRAMSys/simulator/TracePlayer.cpp @@ -46,6 +46,7 @@ TracePlayer::TracePlayer(sc_module_name name, TraceSetup *setup) : payloadEventQueue(this, &TracePlayer::peqCallback), setup(setup) { + SC_METHOD(nextPayload); iSocket.register_nb_transport_bw(this, &TracePlayer::nb_transport_bw); if (Configuration::getInstance().storeMode == "NoStorage") @@ -75,13 +76,7 @@ tlm_sync_enum TracePlayer::nb_transport_bw(tlm_generic_payload &payload, void TracePlayer::peqCallback(tlm_generic_payload &payload, const tlm_phase &phase) { - if (phase == BEGIN_REQ) - { - sendToTarget(payload, phase, SC_ZERO_TIME); - transactionsSent++; - PRINTDEBUGMESSAGE(name(), "Performing request #" + std::to_string(transactionsSent)); - } - else if (phase == END_REQ) + if (phase == END_REQ) { nextPayload(); } @@ -97,10 +92,6 @@ void TracePlayer::peqCallback(tlm_generic_payload &payload, // If all answers were received: if (finished == true && numberOfTransactions == transactionsReceived) this->terminate(); - - } - else if (phase == END_RESP) - { } else { diff --git a/DRAMSys/simulator/TracePlayer.h b/DRAMSys/simulator/TracePlayer.h index d00bbadc..998929c9 100644 --- a/DRAMSys/simulator/TracePlayer.h +++ b/DRAMSys/simulator/TracePlayer.h @@ -55,6 +55,7 @@ class TracePlayer : public sc_module public: tlm_utils::simple_initiator_socket iSocket; TracePlayer(sc_module_name name, TraceSetup *setup); + SC_HAS_PROCESS(TracePlayer); virtual void nextPayload() = 0; unsigned int getNumberOfLines(std::string pathToTrace); @@ -62,17 +63,17 @@ protected: tlm_utils::peq_with_cb_and_phase payloadEventQueue; void finish(); void terminate(); - unsigned int numberOfTransactions = 0; bool storageEnabled = false; TraceSetup *setup; + void sendToTarget(tlm::tlm_generic_payload &payload, const tlm::tlm_phase &phase, + const sc_time &delay); + unsigned int numberOfTransactions = 0; + unsigned int transactionsSent = 0; private: tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &payload, tlm::tlm_phase &phase, sc_time &bwDelay); void peqCallback(tlm::tlm_generic_payload &payload, const tlm::tlm_phase &phase); - void sendToTarget(tlm::tlm_generic_payload &payload, const tlm::tlm_phase &phase, - const sc_time &delay); - unsigned int transactionsSent = 0; unsigned int transactionsReceived = 0; bool finished = false; }; diff --git a/DRAMSys/simulator/main.cpp b/DRAMSys/simulator/main.cpp index 1a0d5a0c..8d26d245 100644 --- a/DRAMSys/simulator/main.cpp +++ b/DRAMSys/simulator/main.cpp @@ -132,10 +132,6 @@ int sc_main(int argc, char **argv) // Store the starting of the simulation in wallclock time: auto start = std::chrono::high_resolution_clock::now(); - // Kickstart the players: - for (auto &p : players) - p->nextPayload(); - // Start SystemC Simulation: sc_set_stop_mode(SC_STOP_FINISH_DELTA); sc_start();