From 3c476f4925bd615da127ef1a246d22979258d8d3 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Wed, 5 May 2021 15:43:52 +0200 Subject: [PATCH 1/2] Simpler clock sync calculation in arbiter. --- DRAMSys/library/src/simulation/Arbiter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DRAMSys/library/src/simulation/Arbiter.cpp b/DRAMSys/library/src/simulation/Arbiter.cpp index 500f098b..753af435 100644 --- a/DRAMSys/library/src/simulation/Arbiter.cpp +++ b/DRAMSys/library/src/simulation/Arbiter.cpp @@ -126,7 +126,8 @@ void ArbiterReorder::end_of_elaboration() tlm_sync_enum Arbiter::nb_transport_fw(int id, tlm_generic_payload &payload, tlm_phase &phase, sc_time &fwDelay) { - sc_time notDelay = std::ceil((sc_time_stamp() + fwDelay) / tCK) * tCK - sc_time_stamp(); + sc_time clockOffset = (sc_time_stamp() + fwDelay) % tCK; + sc_time notDelay = (clockOffset == SC_ZERO_TIME) ? fwDelay : (fwDelay + tCK - clockOffset); if (phase == BEGIN_REQ) { From 9b7e2611ef385ea0941c98473746ad6778349bd3 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Wed, 5 May 2021 15:55:06 +0200 Subject: [PATCH 2/2] Fix clock sync in STL player. --- DRAMSys/simulator/StlPlayer.cpp | 10 +++++----- DRAMSys/simulator/TracePlayer.cpp | 3 --- DRAMSys/simulator/TracePlayer.h | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/DRAMSys/simulator/StlPlayer.cpp b/DRAMSys/simulator/StlPlayer.cpp index 4880b5b0..8ff71bb0 100644 --- a/DRAMSys/simulator/StlPlayer.cpp +++ b/DRAMSys/simulator/StlPlayer.cpp @@ -101,18 +101,18 @@ void StlPlayer::nextPayload() payload->set_command(lineIterator->cmd); std::copy(lineIterator->data.begin(), lineIterator->data.end(), payload->get_data_ptr()); - sc_time sendingOffset; sc_time sendingTime; + sc_time sendingOffset; - if (lastEndReq == sc_time_stamp()) - sendingOffset = playerClk; - else + if (numberOfTransactions == 1) sendingOffset = SC_ZERO_TIME; + else + sendingOffset = playerClk - (sc_time_stamp() % playerClk); if (!relative) sendingTime = std::max(sc_time_stamp() + sendingOffset, lineIterator->sendingTime); else - sendingTime = sc_time_stamp() + std::max(sendingOffset, lineIterator->sendingTime); + sendingTime = sc_time_stamp() + sendingOffset + lineIterator->sendingTime; sendToTarget(*payload, BEGIN_REQ, sendingTime - sc_time_stamp()); diff --git a/DRAMSys/simulator/TracePlayer.cpp b/DRAMSys/simulator/TracePlayer.cpp index 4c588668..dd45e3e6 100644 --- a/DRAMSys/simulator/TracePlayer.cpp +++ b/DRAMSys/simulator/TracePlayer.cpp @@ -72,10 +72,7 @@ void TracePlayer::peqCallback(tlm_generic_payload &payload, const tlm_phase &phase) { if (phase == END_REQ) - { - lastEndReq = sc_time_stamp(); nextPayload(); - } else if (phase == BEGIN_RESP) { payload.release(); diff --git a/DRAMSys/simulator/TracePlayer.h b/DRAMSys/simulator/TracePlayer.h index 7144c95a..7fc4df35 100644 --- a/DRAMSys/simulator/TracePlayer.h +++ b/DRAMSys/simulator/TracePlayer.h @@ -69,7 +69,6 @@ protected: uint64_t numberOfTransactions = 0; uint64_t transactionsSent = 0; bool finished = false; - sc_time lastEndReq = sc_max_time(); private: tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &payload, tlm::tlm_phase &phase,