Implement isFullCycle, alignAtNext functions in utils and add tests
This commit is contained in:
@@ -86,4 +86,14 @@ void setUpDummy(tlm_generic_payload &payload, uint64_t channelPayloadID, Rank ra
|
||||
ArbiterExtension::setExtension(payload, Thread(UINT_MAX), Channel(0), 0, SC_ZERO_TIME);
|
||||
}
|
||||
|
||||
bool isFullCycle(sc_core::sc_time time, sc_core::sc_time cycleTime)
|
||||
{
|
||||
return alignAtNext(time, cycleTime) == time;
|
||||
}
|
||||
|
||||
sc_time alignAtNext(sc_time time, sc_time alignment)
|
||||
{
|
||||
return std::ceil(time / alignment) * alignment;
|
||||
}
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -69,6 +69,9 @@ std::string getPhaseName(const tlm::tlm_phase &phase);
|
||||
void setUpDummy(tlm::tlm_generic_payload &payload, uint64_t channelPayloadID,
|
||||
Rank rank = Rank(0), BankGroup bankGroup = BankGroup(0), Bank bank = Bank(0));
|
||||
|
||||
bool isFullCycle(sc_core::sc_time time, sc_core::sc_time cycleTime);
|
||||
sc_core::sc_time alignAtNext(sc_core::sc_time time, sc_core::sc_time alignment);
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
#endif // UTILS_H
|
||||
|
||||
@@ -258,7 +258,7 @@ Controller::Controller(const sc_module_name& name, const Configuration& config,
|
||||
|
||||
void Controller::controllerMethod()
|
||||
{
|
||||
if (isFullCycle(sc_time_stamp()))
|
||||
if (isFullCycle(sc_time_stamp(), memSpec.tCK))
|
||||
{
|
||||
// (1) Finish last response (END_RESP) and start new response (BEGIN_RESP)
|
||||
manageResponses();
|
||||
@@ -685,10 +685,4 @@ void Controller::createChildTranses(tlm::tlm_generic_payload& parentTrans)
|
||||
ParentExtension::setExtension(parentTrans, std::move(childTranses));
|
||||
}
|
||||
|
||||
bool Controller::isFullCycle(const sc_core::sc_time& time) const
|
||||
{
|
||||
sc_time alignedAtHalfCycle = std::floor((time * 2 / memSpec.tCK + 0.5)) / 2 * memSpec.tCK;
|
||||
return sc_time::from_value(alignedAtHalfCycle.value() % memSpec.tCK.value()) == SC_ZERO_TIME;
|
||||
}
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -106,8 +106,6 @@ private:
|
||||
void manageResponses();
|
||||
void manageRequests(const sc_core::sc_time& delay);
|
||||
|
||||
bool isFullCycle(const sc_core::sc_time& time) const;
|
||||
|
||||
sc_core::sc_event beginReqEvent, endRespEvent, controllerEvent, dataResponseEvent;
|
||||
|
||||
const unsigned minBytesPerBurst;
|
||||
|
||||
Reference in New Issue
Block a user