44#include "DRAMSim2/MultiChannelMemorySystem.h"
62 const std::string& system_file,
63 const std::string& working_dir,
64 const std::string& trace_file,
65 unsigned int memory_size_mb,
67 dramsim(new
DRAMSim::MultiChannelMemorySystem(config_file, system_file,
68 working_dir, trace_file,
69 memory_size_mb, NULL, NULL)),
70 _clockPeriod(0.0), _queueSize(0), _burstSize(0)
82 working_dir +
'/' + config_file);
85 fatal(
"DRAMSim2 wrapper failed to get clock\n");
90 working_dir +
'/' + system_file);
93 fatal(
"DRAMSim2 wrapper failed to get queue size\n");
98 unsigned int dataBusBits =
100 working_dir +
'/' + system_file);
101 unsigned int burstLength =
104 if (!dataBusBits || !burstLength)
105 fatal(
"DRAMSim22 wrapper failed to get burst size\n");
118 const std::string& file_name)
const
120 std::ifstream file_stream(file_name.c_str(), ios::in);
122 if (!file_stream.good())
123 fatal(
"DRAMSim2 wrapper could not open %s for reading\n", file_name);
128 while (!found && file_stream) {
129 getline(file_stream, line);
130 if (line.substr(0, field_name.size()) == field_name) {
132 istringstream
iss(line.substr(field_name.size()));
140 fatal(
"DRAMSim2 wrapper could not find %s in %s\n", field_name,
154 DRAMSim::TransactionCompleteCB* write_callback)
157 dramsim->RegisterCallbacks(read_callback, write_callback, NULL);
163 return dramsim->willAcceptTransaction();
169 [[maybe_unused]]
bool success =
dramsim->addTransaction(is_write,
addr);
void enqueue(bool is_write, uint64_t addr)
Enqueue a packet.
void printStats()
Print the stats gathered in DRAMsim2.
double clockPeriod() const
Get the internal clock period used by DRAMSim2, specified in ns.
unsigned int queueSize() const
Get the transaction queue size used by DRAMSim2.
unsigned int burstSize() const
Get the burst size in bytes used by DRAMSim2.
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...
bool canAccept() const
Determine if the controller can accept a new packet or not.
T extractConfig(const std::string &field_name, const std::string &file_name) const
void setCallbacks(DRAMSim::TransactionCompleteCB *read_callback, DRAMSim::TransactionCompleteCB *write_callback)
Set the callbacks to use for read and write completion.
void tick()
Progress the memory controller one cycle.
DRAMSim::MultiChannelMemorySystem * dramsim
int SHOW_SIM_OUTPUT
DRAMSim2 requires SHOW_SIM_OUTPUT to be defined (declared extern in the DRAMSim2 print macros),...
DRAMSim2Wrapper declaration.
#define fatal(...)
This implements a cprintf based fatal() function.
Forward declaration to avoid includes.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.