remlocated methods from utils.h in core to dramextension and new header Timingcalculation. Moved getExecutionTime there also

This commit is contained in:
robert
2014-04-11 15:56:29 +02:00
parent 82395b21bf
commit 4a9c68aeea
29 changed files with 155 additions and 167 deletions

View File

@@ -2,6 +2,7 @@
#include <string>
#include <tlm.h>
#include <fstream>
#include "dramExtension.h"
using namespace std;
using namespace tinyxml2;
@@ -139,3 +140,15 @@ string loadTextFileContents(string filename)
return "";
}
}
void setUpDummy(tlm::tlm_generic_payload& payload, Bank& bank)
{
payload.set_address(bank.getStartAddress());
payload.set_command(tlm::TLM_READ_COMMAND);
payload.set_data_length(0);
payload.set_response_status(tlm::TLM_OK_RESPONSE);
payload.set_dmi_allowed(false);
payload.set_byte_enable_length(0);
payload.set_streaming_width(0);
payload.set_extension(new DramExtension(Thread(0), bank, bank.getBankGroup(), Row(0), Column(0))); //payload takes ownership
}

View File

@@ -13,7 +13,7 @@
#include <string>
#include <ostream>
#include <tlm.h>
#include "dramExtension.h"
#include "third_party/tinyxml2.h"
template<typename Key, typename Val>
@@ -49,4 +49,6 @@ std::string queryStringParameter(tinyxml2::XMLElement* node, std::string name);
bool queryBoolParameter(tinyxml2::XMLElement* node, std::string name);
double queryDoubleParameter(tinyxml2::XMLElement* node, std::string name);
void setUpDummy(tlm::tlm_generic_payload& payload, Bank& bank);
#endif /* UTILS_COMMON_H_ */

View File

@@ -7,7 +7,7 @@
#include "ControllerState.h"
#include <algorithm>
#include "utils/Utils.h"
#include "TimingCalculation.h"
namespace core {

View File

@@ -6,7 +6,7 @@
*/
#include "Slots.h"
#include "utils/Utils.h"
#include "TimingCalculation.h"
namespace core {

View File

@@ -0,0 +1,117 @@
/*
* Utils.cpp
*
* Created on: Mar 12, 2014
* Author: jonny
*/
#include "TimingCalculation.h"
#include "configuration/TimingConfiguration.h"
#include "ControllerCore.h"
#include "../common/DebugManager.h"
#include "configuration/Configuration.h"
#include "../common/Utils.h"
namespace core {
sc_time getDistance(sc_time a, sc_time b)
{
if (a > b)
return a - b;
else
return b - a;
}
sc_time getDelayToMeetConstraint(sc_time previous, sc_time start, sc_time constraint)
{
if (previous + constraint > start)
return previous + constraint - start;
else
return SC_ZERO_TIME;
}
const sc_time clkAlign(sc_time time, Alignment alignment)
{
sc_time clk = Configuration::getInstance().Timings.clk;
if (alignment == UP)
return ceil(time / clk) * clk;
else
return floor(time / clk) * clk;
}
sc_time getExecutionTime(Command command,tlm::tlm_generic_payload& payload)
{
TimingConfiguration& config = Configuration::getInstance().Timings;
if(command == Command::Precharge || command == Command::PrechargeAll)
{
return config.tRP;
}
else if(command == Command::Activate)
{
return config.tRCD;
}
else if(command == Command::Read)
{
return config.tRL + getBurstLengthOnDataStrobe(payload.get_streaming_width());
}
else if(command == Command::ReadA)
{
return getBurstLengthOnDataStrobe(payload.get_streaming_width())
+ max(config.tRP, config.tRL);
}
else if(command == Command::Write || command == Command::WriteA)
{
sc_time lengthOnDataStrobe = getBurstLengthOnDataStrobe(payload.get_streaming_width());
if(Configuration::getInstance().DataRate == 1)
lengthOnDataStrobe -= Configuration::getInstance().Timings.clk;
if (command == Command::Write)
{
return config.tWL + lengthOnDataStrobe;
}
else
{
return config.tWL + lengthOnDataStrobe + config.tWR;
}
}
else if(command == Command::PrechargeAll)
{
return config.tRP;
}
else if(command == Command::AutoRefresh)
{
return getElementFromMap(config.refreshTimings, DramExtension::getExtension(payload).getBank()).tRFC;
}
else
{
SC_REPORT_FATAL("getExecutionTime", "unkown command");
return SC_ZERO_TIME;
}
}
bool isClkAligned(sc_time time, sc_time clk)
{
return !((time / clk) - ceil(time / clk));
}
bool TimeInterval::timeIsInInterval(sc_time time)
{
return (start < time && time < end);
}
bool TimeInterval::intersects(TimeInterval other)
{
return other.timeIsInInterval(this->start) || this->timeIsInInterval(other.start);
}
sc_time getBurstLengthOnDataStrobe(unsigned int burstlength)
{
Configuration& config = Configuration::getInstance();
sc_assert((burstlength / config.DataRate) > 0);
return config.Timings.clk * (burstlength / config.DataRate);
}
}

View File

@@ -10,11 +10,11 @@
#include <systemc.h>
#include <tlm.h>
#include "../../common/dramExtension.h"
#include "../common/dramExtension.h"
#include "Command.h"
namespace core
{
unsigned int getStartAddress(const Bank& bank);
sc_time getDistance(sc_time a, sc_time b);
struct TimeInterval
@@ -28,16 +28,14 @@ struct TimeInterval
bool intersects(TimeInterval other);
};
sc_time getExecutionTime(Command command, tlm::tlm_generic_payload& payload);
sc_time getBurstLengthOnDataStrobe(unsigned int burstlength);
struct TimingConfiguration;
sc_time getDelayToMeetConstraint(sc_time previous, sc_time start, sc_time constraint);
enum Alignment {UP, DOWN};
const sc_time clkAlign(sc_time time, Alignment alignment = UP);
bool isClkAligned(sc_time time, sc_time clk);
void setUpDummy(tlm::tlm_generic_payload& payload, Bank& bank);
};
#endif /* UTILS_H_ */

View File

@@ -9,9 +9,8 @@
#define TIMINGS_H_
#include <systemc.h>
#include "../utils/Utils.h"
#include <map>
#include "../../common/dramExtension.h"
namespace core{
struct RefreshTiming

View File

@@ -8,7 +8,7 @@
#include "PowerDownManager.h"
#include "../ControllerCore.h"
#include "../../common/Utils.h"
#include "../utils/Utils.h"
#include "../TimingCalculation.h"
using namespace tlm;

View File

@@ -9,7 +9,7 @@
#include <string>
#include "PowerDownManagerGrouped.h"
#include "../ControllerCore.h"
#include "../utils/Utils.h"
#include "../TimingCalculation.h"
#include "../../common/DebugManager.h"
#include <algorithm>

View File

@@ -7,7 +7,8 @@
#include "RefreshManager.h"
#include "../ControllerCore.h"
#include "../utils/Utils.h"
#include "../TimingCalculation.h"
#include "../../common/Utils.h"
using namespace tlm;
namespace core {

View File

@@ -7,7 +7,8 @@
#include "RefreshManagerBankwise.h"
#include "../ControllerCore.h"
#include "../utils/Utils.h"
#include "../TimingCalculation.h"
#include "../../common/Utils.h"
using namespace std;

View File

@@ -8,6 +8,7 @@
#include "CommandSequenceScheduler.h"
#include "../ControllerCore.h"
#include "../../common/DebugManager.h"
#include "../TimingCalculation.h"
namespace core {
@@ -22,7 +23,7 @@ CommandSchedule CommandSequenceScheduler::schedule(CommandSequence commands, sc_
ICommandChecker& checker = controller.getCommandChecker(cmd);
sc_time executionTime = checker.getExecutionTime(transaction, cmd);
sc_time executionTime = getExecutionTime(cmd,transaction);
ScheduledCommand& scheduledCommand = schedule.add(cmd, start, executionTime);
checker.delayToSatisfyConstraints(scheduledCommand);

View File

@@ -5,7 +5,7 @@
* Author: robert
*/
#include "ScheduledCommand.h"
#include "../utils/Utils.h"
#include "../TimingCalculation.h"
#include "../../common/Utils.h"
#include "../configuration/Configuration.h"

View File

@@ -13,7 +13,7 @@
#include "../Command.h"
#include "../../common/dramExtension.h"
#include "../../common/TlmRecorder.h"
#include "../utils/Utils.h"
#include "../TimingCalculation.h"
namespace core {

View File

@@ -8,7 +8,7 @@
#include <algorithm>
#include <set>
#include "ActivateChecker.h"
#include "../../utils/Utils.h"
#include "../../TimingCalculation.h"
#include "../../../common/DebugManager.h"
#include "../../Command.h"
#include "../../../common/Utils.h"
@@ -53,13 +53,6 @@ void ActivateChecker::delayToSatisfyConstraints(ScheduledCommand& command) const
}
sc_time ActivateChecker::getExecutionTime(const tlm::tlm_generic_payload& transaction,
Command command) const
{
assert(command == Command::Activate);
return config.Timings.tRCD;
}
void ActivateChecker::delay_to_satisfy_activateToActivate_sameBank(ScheduledCommand& command) const
{
ScheduledCommand lastActivateOnBank = state.getLastCommand(Command::Activate,

View File

@@ -22,8 +22,6 @@ public:
virtual ~ActivateChecker(){}
virtual void delayToSatisfyConstraints(ScheduledCommand& command) const override;
virtual sc_time getExecutionTime(const tlm::tlm_generic_payload& payload, Command command) const override;
private:
const Configuration& config;
ControllerState& state;//TODO make const

View File

@@ -17,9 +17,7 @@ class ICommandChecker
{
public:
virtual ~ICommandChecker() {}
virtual void delayToSatisfyConstraints(ScheduledCommand& command) const = 0;
virtual sc_time getExecutionTime(const tlm::tlm_generic_payload& payload, Command command) const = 0;
};
} /* namespace controller */

View File

@@ -49,11 +49,4 @@ void PrechargeAllChecker::delayToSatisfyConstraints(ScheduledCommand& command) c
state.bus.moveCommandToNextFreeSlot(command);
}
sc_time PrechargeAllChecker::getExecutionTime(const tlm::tlm_generic_payload& payload,
Command command) const
{
sc_assert(command == Command::PrechargeAll);
return config.Timings.tRP;
}
} /* namespace core */

View File

@@ -26,8 +26,6 @@ public:
}
virtual void delayToSatisfyConstraints(ScheduledCommand& command) const override;
virtual sc_time getExecutionTime(const tlm::tlm_generic_payload& payload, Command command) const
override;
private:
const Configuration& config;

View File

@@ -41,11 +41,4 @@ void PrechargeChecker::delayToSatisfyConstraints(ScheduledCommand& command) cons
state.bus.moveCommandToNextFreeSlot(command);
}
sc_time PrechargeChecker::getExecutionTime(const tlm::tlm_generic_payload& payload,
Command command) const
{
sc_assert(command == Command::Precharge || command == Command::PrechargeAll);
return config.Timings.tRP;
}
} /* namespace controller */

View File

@@ -19,9 +19,8 @@ class PrechargeChecker: public core::ICommandChecker
public:
PrechargeChecker(const Configuration& config, ControllerState& state) : config(config), state(state) {}
virtual ~PrechargeChecker() {}
virtual void delayToSatisfyConstraints(ScheduledCommand& command) const override;
virtual sc_time getExecutionTime(const tlm::tlm_generic_payload& payload, Command command) const override;
private:
const Configuration& config;
ControllerState& state;

View File

@@ -6,7 +6,7 @@
*/
#include "ReadChecker.h"
#include "../../utils/Utils.h"
#include "../../TimingCalculation.h"
#include "../../../common/Utils.h"
namespace core {
@@ -53,20 +53,6 @@ bool ReadChecker::collidesOnDataStrobe(ScheduledCommand& read) const
return false;
}
sc_time ReadChecker::getExecutionTime(const tlm::tlm_generic_payload& payload,
Command command) const
{
if (command == Command::Read)
{
return config.Timings.tRL + getBurstLengthOnDataStrobe(payload.get_streaming_width());
}
else
{
return getBurstLengthOnDataStrobe(payload.get_streaming_width())
+ max(config.Timings.tRP, config.Timings.tRL);
}
}
bool ReadChecker::collidesWithStrobeCommand(ScheduledCommand& read,
ScheduledCommand& strobeCommand) const
{

View File

@@ -21,7 +21,6 @@ public:
virtual ~ReadChecker() {}
virtual void delayToSatisfyConstraints(ScheduledCommand& command) const override;
virtual sc_time getExecutionTime(const tlm::tlm_generic_payload& payload, Command command) const override;
private:
const Configuration& config;

View File

@@ -6,7 +6,7 @@
*/
#include "WriteChecker.h"
#include "../../utils/Utils.h"
#include "../../TimingCalculation.h"
#include "../../../common/Utils.h"
namespace core {
@@ -43,26 +43,6 @@ void WriteChecker::delayToSatisfyConstraints(ScheduledCommand& command) const
}
}
sc_time WriteChecker::getExecutionTime(const tlm::tlm_generic_payload& payload,
Command command) const
{
assert(command == Command::Write || command == Command::WriteA);
sc_time lengthOnDataStrobe = getBurstLengthOnDataStrobe(payload.get_streaming_width());
if(Configuration::getInstance().DataRate == 1)
lengthOnDataStrobe -= Configuration::getInstance().Timings.clk;
if (command == Command::Write)
{
return config.Timings.tWL + lengthOnDataStrobe;
}
else
{
return config.Timings.tWL + lengthOnDataStrobe + config.Timings.tWR;
}
}
bool WriteChecker::collidesOnDataStrobe(ScheduledCommand& write) const
{
for (ScheduledCommand& strobeCommand : state.lastDataStrobeCommands)

View File

@@ -21,7 +21,6 @@ public:
virtual ~WriteChecker() {}
virtual void delayToSatisfyConstraints(ScheduledCommand& command) const override;
virtual sc_time getExecutionTime(const tlm::tlm_generic_payload& payload, Command command) const override;
private:
bool collidesOnDataStrobe(ScheduledCommand& write) const;
bool collidesWithStrobeCommand(ScheduledCommand& write, ScheduledCommand& strobeCommand) const;

View File

@@ -1,79 +0,0 @@
/*
* Utils.cpp
*
* Created on: Mar 12, 2014
* Author: jonny
*/
#include "Utils.h"
#include "../configuration/TimingConfiguration.h"
#include "../ControllerCore.h"
#include "../../common/DebugManager.h"
#include "../configuration/Configuration.h"
namespace core {
sc_time getDistance(sc_time a, sc_time b)
{
if (a > b)
return a - b;
else
return b - a;
}
sc_time getDelayToMeetConstraint(sc_time previous, sc_time start, sc_time constraint)
{
if (previous + constraint > start)
return previous + constraint - start;
else
return SC_ZERO_TIME;
}
const sc_time clkAlign(sc_time time, Alignment alignment)
{
sc_time clk = Configuration::getInstance().Timings.clk;
if (alignment == UP)
return ceil(time / clk) * clk;
else
return floor(time / clk) * clk;
}
bool isClkAligned(sc_time time, sc_time clk)
{
return !((time / clk) - ceil(time / clk));
}
bool TimeInterval::timeIsInInterval(sc_time time)
{
return (start < time && time < end);
}
bool TimeInterval::intersects(TimeInterval other)
{
return other.timeIsInInterval(this->start) || this->timeIsInInterval(other.start);
}
sc_time getBurstLengthOnDataStrobe(unsigned int burstlength)
{
Configuration& config = Configuration::getInstance();
sc_assert((burstlength / config.DataRate) > 0);
return config.Timings.clk * (burstlength / config.DataRate);
}
void setUpDummy(tlm::tlm_generic_payload& payload, Bank& bank)
{
payload.set_address(bank.getStartAddress());
payload.set_command(tlm::TLM_READ_COMMAND);
payload.set_data_length(0);
payload.set_response_status(tlm::TLM_OK_RESPONSE);
payload.set_dmi_allowed(false);
payload.set_byte_enable_length(0);
payload.set_streaming_width(0);
payload.set_extension(new DramExtension(Thread(0), bank, bank.getBankGroup(), Row(0), Column(0))); //payload takes ownership
}
}

View File

@@ -17,7 +17,7 @@
#include <tlm_utils/peq_with_cb_and_phase.h>
#include "../common/xmlAddressdecoder.h"
#include "../common/dramExtension.h"
#include "../core/utils/Utils.h"
#include "../core/TimingCalculation.h"
#include <iostream>

View File

@@ -99,7 +99,6 @@ int sc_main(int argc, char **argv)
string trace2 = "empty.stl";
string trace1 = "chstone-jpeg_32.stl";
trace1 = "trace.stl";
if (runSimulation(resources, traceName, setup, { Device(trace1), Device(trace2) }))
startTraceAnalyzer(traceName);

View File

@@ -6,7 +6,7 @@
*/
#include <gtest/gtest.h>
#include "core/utils/Utils.h"
#include "core/TimingCalculation.h"
#include "core/utils/RingBuffer.h"
//using namespace testing;