55 #include "DRAMSim2/MultiChannelMemorySystem.h"
67 const std::string& system_file,
68 const std::string& working_dir,
69 const std::string& trace_file,
70 unsigned int memory_size_mb,
72 dramsim(new DRAMSim::MultiChannelMemorySystem(config_file, system_file,
73 working_dir, trace_file,
74 memory_size_mb, NULL, NULL)),
75 _clockPeriod(0.0), _queueSize(0), _burstSize(0)
87 working_dir +
'/' + config_file);
90 fatal(
"DRAMSim2 wrapper failed to get clock\n");
94 _queueSize = extractConfig<unsigned int>(
"TRANS_QUEUE_DEPTH=",
95 working_dir +
'/' + system_file);
98 fatal(
"DRAMSim2 wrapper failed to get queue size\n");
103 unsigned int dataBusBits =
104 extractConfig<unsigned int>(
"JEDEC_DATA_BUS_BITS=",
105 working_dir +
'/' + system_file);
106 unsigned int burstLength =
107 extractConfig<unsigned int>(
"BL=", working_dir +
'/' + config_file);
109 if (!dataBusBits || !burstLength)
110 fatal(
"DRAMSim22 wrapper failed to get burst size\n");
120 template <
typename T>
123 const std::string& file_name)
const
125 std::ifstream file_stream(file_name.c_str(), ios::in);
127 if (!file_stream.good())
128 fatal(
"DRAMSim2 wrapper could not open %s for reading\n", file_name);
133 while (!found && file_stream) {
134 getline(file_stream, line);
135 if (line.substr(0, field_name.size()) == field_name) {
137 istringstream iss(line.substr(field_name.size()));
145 fatal(
"DRAMSim2 wrapper could not find %s in %s\n", field_name,
159 DRAMSim::TransactionCompleteCB* write_callback)
162 dramsim->RegisterCallbacks(read_callback, write_callback, NULL);
168 return dramsim->willAcceptTransaction();
void printStats()
Print the stats gathered in DRAMsim2.
void enqueue(bool is_write, uint64_t addr)
Enqueue a packet.
DRAMSim::MultiChannelMemorySystem * dramsim
int SHOW_SIM_OUTPUT
When building the debug binary, we need to undo the command-line definition of DEBUG not to clash wit...
double clockPeriod() const
Get the internal clock period used by DRAMSim2, specified in ns.
DRAMSim2Wrapper declaration.
void setCallbacks(DRAMSim::TransactionCompleteCB *read_callback, DRAMSim::TransactionCompleteCB *write_callback)
Set the callbacks to use for read and write completion.
unsigned int queueSize() const
Get the transaction queue size used by DRAMSim2.
static const int NumArgumentRegs M5_VAR_USED
bool canAccept() const
Determine if the controller can accept a new packet or not.
DRAMSim2Wrapper(const std::string &config_file, const std::string &system_file, const std::string &working_dir, const std::string &trace_file, unsigned int memory_size_mb, bool enable_debug)
Create an instance of the DRAMSim2 multi-channel memory controller using a specific config and system...
unsigned int burstSize() const
Get the burst size in bytes used by DRAMSim2.
void tick()
Progress the memory controller one cycle.
T extractConfig(const std::string &field_name, const std::string &file_name) const