From 87906da06bbee270456af2d28829d73f5c00d9d1 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Thu, 14 Jan 2021 14:27:18 +0100 Subject: [PATCH] Adapt simple arbiter and STL player to new protocol. --- DRAMSys/library/src/simulation/Arbiter.cpp | 20 +++++++++++--------- DRAMSys/library/src/simulation/Arbiter.h | 1 + DRAMSys/simulator/StlPlayer.cpp | 20 ++++++++++++-------- DRAMSys/simulator/StlPlayer.h | 1 + DRAMSys/simulator/TraceGenerator.cpp | 1 + 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/DRAMSys/library/src/simulation/Arbiter.cpp b/DRAMSys/library/src/simulation/Arbiter.cpp index 3b87fa98..68f77dcc 100644 --- a/DRAMSys/library/src/simulation/Arbiter.cpp +++ b/DRAMSys/library/src/simulation/Arbiter.cpp @@ -45,7 +45,8 @@ using namespace tlm; Arbiter::Arbiter(sc_module_name name, std::string pathToAddressMapping) : sc_module(name), payloadEventQueue(this, &Arbiter::peqCallback), maxActiveTransactions(Configuration::getInstance().maxActiveTransactions), - tCK(Configuration::getInstance().memSpec->tCK) + tCK(Configuration::getInstance().memSpec->tCK), + arbitrationDelay(Configuration::getInstance().arbitrationDelay) { iSocket.register_nb_transport_bw(this, &Arbiter::nb_transport_bw); tSocket.register_nb_transport_fw(this, &Arbiter::nb_transport_fw); @@ -117,11 +118,12 @@ 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 notDelay = fwDelay; if (phase == BEGIN_REQ) { + notDelay = std::ceil((sc_time_stamp() + fwDelay) / tCK) * tCK - sc_time_stamp(); + // TODO: do not adjust address permanently // adjust address offset: uint64_t adjustedAddress = payload.get_address() - Configuration::getInstance().addressOffset; @@ -135,8 +137,6 @@ tlm_sync_enum Arbiter::nb_transport_fw(int id, tlm_generic_payload &payload, payload.get_streaming_width(), 0, 0); payload.acquire(); } - else if (phase == END_RESP) - notDelay += tCK; PRINTDEBUGMESSAGE(name(), "[fw] " + getPhaseName(phase) + " notification in " + notDelay.to_string()); @@ -197,7 +197,8 @@ void ArbiterSimple::peqCallback(tlm_generic_payload &cbPayload, const tlm_phase tlm_generic_payload &tPayload = *pendingRequests[channelId].front(); pendingRequests[channelId].pop(); tlm_phase tPhase = BEGIN_REQ; - sc_time tDelay = SC_ZERO_TIME; + // do not send two requests in the same cycle + sc_time tDelay = tCK; iSocket[static_cast(channelId)]->nb_transport_fw(tPayload, tPhase, tDelay); } else @@ -231,7 +232,8 @@ void ArbiterSimple::peqCallback(tlm_generic_payload &cbPayload, const tlm_phase tlm_generic_payload &tPayload = *pendingResponses[threadId].front(); pendingResponses[threadId].pop(); tlm_phase tPhase = BEGIN_RESP; - sc_time tDelay = SC_ZERO_TIME; + // do not send two responses in the same cycle + sc_time tDelay = tCK; tlm_sync_enum returnValue = tSocket[static_cast(threadId)]->nb_transport_bw(tPayload, tPhase, tDelay); if (returnValue == TLM_UPDATED) payloadEventQueue.notify(tPayload, tPhase, tDelay); @@ -266,7 +268,7 @@ void ArbiterFifo::peqCallback(tlm_generic_payload &cbPayload, const tlm_phase &c outstandingEndReq[threadId] = &cbPayload; } - pendingRequests[channelId].push(&cbPayload); + pendingRequests[channelId].push(&cbPayload); // TODO: wrong, only insert when END_REQ has been sent if (!channelIsBusy[channelId]) { @@ -275,7 +277,7 @@ void ArbiterFifo::peqCallback(tlm_generic_payload &cbPayload, const tlm_phase &c tlm_generic_payload *tPayload = pendingRequests[channelId].front(); pendingRequests[channelId].pop(); tlm_phase tPhase = BEGIN_REQ; - sc_time tDelay = tCK; + sc_time tDelay = tCK; // TODO: SC_ZERO_TIME iSocket[static_cast(channelId)]->nb_transport_fw(*tPayload, tPhase, tDelay); } diff --git a/DRAMSys/library/src/simulation/Arbiter.h b/DRAMSys/library/src/simulation/Arbiter.h index c3185e2b..580665f4 100644 --- a/DRAMSys/library/src/simulation/Arbiter.h +++ b/DRAMSys/library/src/simulation/Arbiter.h @@ -90,6 +90,7 @@ protected: unsigned int transport_dbg(int /*id*/, tlm::tlm_generic_payload &trans); sc_time tCK; + sc_time arbitrationDelay; }; class ArbiterSimple final : public Arbiter diff --git a/DRAMSys/simulator/StlPlayer.cpp b/DRAMSys/simulator/StlPlayer.cpp index 6c2ea4fb..3777c21c 100644 --- a/DRAMSys/simulator/StlPlayer.cpp +++ b/DRAMSys/simulator/StlPlayer.cpp @@ -101,15 +101,19 @@ void StlPlayer::nextPayload() payload->set_command(lineIterator->cmd); std::copy(lineIterator->data.begin(), lineIterator->data.end(), payload->get_data_ptr()); - if (!relative) - { - if (lineIterator->sendingTime <= sc_time_stamp()) - sendToTarget(*payload, BEGIN_REQ, SC_ZERO_TIME); - else - sendToTarget(*payload, BEGIN_REQ, lineIterator->sendingTime - sc_time_stamp()); - } + sc_time sendingOffset; + + if (lastSendingTime == sc_time_stamp()) + sendingOffset = playerClk; else - sendToTarget(*payload, BEGIN_REQ, lineIterator->sendingTime); + sendingOffset = SC_ZERO_TIME; + + if (!relative) + lastSendingTime = std::max(sc_time_stamp() + sendingOffset, lineIterator->sendingTime); + else + lastSendingTime = sc_time_stamp() + std::max(sendingOffset, lineIterator->sendingTime); + + sendToTarget(*payload, BEGIN_REQ, lastSendingTime - sc_time_stamp()); transactionsSent++; PRINTDEBUGMESSAGE(name(), "Performing request #" + std::to_string(transactionsSent)); diff --git a/DRAMSys/simulator/StlPlayer.h b/DRAMSys/simulator/StlPlayer.h index 27081d41..f305ae5e 100644 --- a/DRAMSys/simulator/StlPlayer.h +++ b/DRAMSys/simulator/StlPlayer.h @@ -78,6 +78,7 @@ private: unsigned int burstlength; unsigned int dataLength; sc_time playerClk; // May be different from the memory clock! + sc_time lastSendingTime = sc_max_time(); static constexpr unsigned lineBufferSize = 10000; diff --git a/DRAMSys/simulator/TraceGenerator.cpp b/DRAMSys/simulator/TraceGenerator.cpp index 3a3069ff..b08080ee 100644 --- a/DRAMSys/simulator/TraceGenerator.cpp +++ b/DRAMSys/simulator/TraceGenerator.cpp @@ -69,6 +69,7 @@ void TraceGenerator::nextPayload() payload->set_command(tlm::TLM_READ_COMMAND); transCounter++; + // TODO: do not send two requests in the same cycle sendToTarget(*payload, tlm::BEGIN_REQ, SC_ZERO_TIME); transactionsSent++; PRINTDEBUGMESSAGE(name(), "Performing request #" + std::to_string(transactionsSent));