using ramulator dram simulator
This commit is contained in:
@@ -5,8 +5,6 @@ CXXFLAGS += -std=c++11 -O2 -DNDEBUG -Wall -Wextra -pedantic -Wfatal-errors
|
||||
|
||||
CXXFLAGS += -I../include -I../common -I../../hw -I$(RTLSIM_DIR) -I$(RTLSIM_DIR)/../common
|
||||
|
||||
LDFLAGS += $(RTLSIM_DIR)/librtlsim.a
|
||||
|
||||
# Position independent code
|
||||
CXXFLAGS += -fPIC
|
||||
|
||||
@@ -17,6 +15,7 @@ CXXFLAGS += $(CONFIGS)
|
||||
CXXFLAGS += -DDUMP_PERF_STATS
|
||||
|
||||
LDFLAGS += -shared -pthread
|
||||
LDFLAGS += -L. -lrtlsim
|
||||
|
||||
SRCS = vortex.cpp ../common/vx_utils.cpp
|
||||
|
||||
@@ -30,9 +29,9 @@ PROJECT = libvortex.so
|
||||
all: $(PROJECT)
|
||||
|
||||
$(PROJECT): $(SRCS)
|
||||
$(MAKE) -C $(RTLSIM_DIR) static
|
||||
DESTDIR=../../driver/rtlsim $(MAKE) -C $(RTLSIM_DIR) ../../driver/rtlsim/librtlsim.so
|
||||
$(CXX) $(CXXFLAGS) $(SRCS) $(LDFLAGS) -o $(PROJECT)
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(RTLSIM_DIR) clean-static
|
||||
DESTDIR=../../driver/rtlsim $(MAKE) -C $(RTLSIM_DIR) clean
|
||||
rm -rf $(PROJECT) *.o
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include <future>
|
||||
#include <list>
|
||||
#include <chrono>
|
||||
|
||||
#include <vortex.h>
|
||||
@@ -11,7 +12,7 @@
|
||||
#include <VX_config.h>
|
||||
#include <mem.h>
|
||||
#include <util.h>
|
||||
#include <simulator.h>
|
||||
#include <processor.h>
|
||||
|
||||
#define RAM_PAGE_SIZE 4096
|
||||
|
||||
@@ -60,7 +61,9 @@ public:
|
||||
vx_device()
|
||||
: ram_(RAM_PAGE_SIZE)
|
||||
, mem_allocation_(ALLOC_BASE_ADDR)
|
||||
{}
|
||||
{
|
||||
processor_.attach_ram(&ram_);
|
||||
}
|
||||
|
||||
~vx_device() {
|
||||
if (future_.valid()) {
|
||||
@@ -121,12 +124,9 @@ public:
|
||||
future_.wait();
|
||||
}
|
||||
// start new run
|
||||
simulator_.attach_ram(&ram_);
|
||||
future_ = std::async(std::launch::async, [&]{
|
||||
simulator_.reset();
|
||||
while (simulator_.is_busy()) {
|
||||
simulator_.step();
|
||||
}
|
||||
processor_.reset();
|
||||
processor_.run();
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
private:
|
||||
|
||||
RAM ram_;
|
||||
Simulator simulator_;
|
||||
Processor processor_;
|
||||
uint64_t mem_allocation_;
|
||||
std::future<void> future_;
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ CXXFLAGS += $(CONFIGS)
|
||||
CXXFLAGS += -DDUMP_PERF_STATS
|
||||
|
||||
LDFLAGS += -shared -pthread
|
||||
LDFLAGS += $(SIMX_DIR)/libsimx.a
|
||||
LDFLAGS += -L. -lsimx
|
||||
|
||||
SRCS = vortex.cpp ../common/vx_utils.cpp
|
||||
|
||||
@@ -18,9 +18,9 @@ PROJECT = libvortex.so
|
||||
all: $(PROJECT)
|
||||
|
||||
$(PROJECT): $(SRCS)
|
||||
$(MAKE) -C $(SIMX_DIR) static
|
||||
DESTDIR=../../driver/simx $(MAKE) -C $(SIMX_DIR) ../../driver/simx/libsimx.so
|
||||
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(SIMX_DIR) clean-static
|
||||
rm -rf $(PROJECT) *.o
|
||||
DESTDIR=../../driver/simx $(MAKE) -C $(SIMX_DIR) clean
|
||||
rm -rf libsimx.so $(PROJECT) *.o
|
||||
@@ -60,7 +60,13 @@ public:
|
||||
: arch_("rv32i", NUM_CORES * NUM_CLUSTERS, NUM_WARPS, NUM_THREADS)
|
||||
, ram_(RAM_PAGE_SIZE)
|
||||
, mem_allocation_(ALLOC_BASE_ADDR)
|
||||
{}
|
||||
{
|
||||
// setup memory simulator
|
||||
memsim_ = MemSim::Create(MemSim::Config{
|
||||
DRAM_CHANNELS,
|
||||
arch_.num_cores()
|
||||
});
|
||||
}
|
||||
|
||||
~vx_device() {
|
||||
if (future_.valid()) {
|
||||
@@ -113,13 +119,33 @@ public:
|
||||
if (future_.valid()) {
|
||||
future_.wait();
|
||||
}
|
||||
|
||||
// start new run
|
||||
SimPlatform::instance().flush();
|
||||
processor_ = std::make_shared<Processor>(arch_);
|
||||
processor_->attach_ram(&ram_);
|
||||
future_ = std::async(std::launch::async, [&]{
|
||||
processor_->run();
|
||||
if (processor_) {
|
||||
// release current processor instance
|
||||
processor_->MemReqPort.unbind();
|
||||
memsim_->MemRspPort.unbind();
|
||||
SimPlatform::instance().release_object(processor_);
|
||||
}
|
||||
|
||||
// create new processor instance
|
||||
processor_ = Processor::Create(arch_);
|
||||
processor_->MemReqPort.bind(&memsim_->MemReqPort);
|
||||
memsim_->MemRspPort.bind(&processor_->MemRspPort);
|
||||
|
||||
// attach memory object
|
||||
processor_->attach_ram(&ram_);
|
||||
|
||||
// run simulation
|
||||
int exitcode;
|
||||
for (;;) {
|
||||
SimPlatform::instance().step();
|
||||
if (processor_->check_exit(&exitcode))
|
||||
break;
|
||||
};
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -141,6 +167,7 @@ public:
|
||||
private:
|
||||
ArchDef arch_;
|
||||
RAM ram_;
|
||||
MemSim::Ptr memsim_;
|
||||
Processor::Ptr processor_;
|
||||
uint64_t mem_allocation_;
|
||||
std::future<void> future_;
|
||||
|
||||
@@ -9,8 +9,6 @@ CXXFLAGS += -std=c++11 -O2 -DNDEBUG -Wall -Wextra -pedantic -Wfatal-errors
|
||||
|
||||
CXXFLAGS += -I. -I../include -I../../hw -I$(VLSIM_DIR)
|
||||
|
||||
LDFLAGS += $(VLSIM_DIR)/libopae-c-vlsim.a
|
||||
|
||||
# Position independent code
|
||||
CXXFLAGS += -fPIC
|
||||
|
||||
@@ -21,6 +19,7 @@ CXXFLAGS += $(CONFIGS)
|
||||
CXXFLAGS += -DDUMP_PERF_STATS
|
||||
|
||||
LDFLAGS += -shared -pthread
|
||||
LDFLAGS += -L. -lopae-c-vlsim
|
||||
|
||||
SRCS = ../common/opae.cpp ../common/vx_utils.cpp
|
||||
|
||||
@@ -47,9 +46,9 @@ scope-defs.h: $(SCRIPT_DIR)/scope.json
|
||||
scope: scope-defs.h
|
||||
|
||||
$(PROJECT): $(SRCS) $(SCOPE_H)
|
||||
$(SCOPE_ENABLE) $(PERF_ENABLE) $(MAKE) -C $(VLSIM_DIR) static
|
||||
DESTDIR=../../driver/vlsim $(MAKE) -C $(VLSIM_DIR) ../../driver/vlsim/libopae-c-vlsim.so
|
||||
$(CXX) $(CXXFLAGS) -DUSE_VLSIM $(SRCS) $(LDFLAGS) -o $(PROJECT)
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(VLSIM_DIR) clean-static
|
||||
rm -rf $(PROJECT) *.o scope-defs.h
|
||||
DESTDIR=../../driver/vlsim $(MAKE) -C $(VLSIM_DIR) clean
|
||||
rm -rf libopae-c-vlsim.so $(PROJECT) *.o scope-defs.h
|
||||
Reference in New Issue
Block a user