Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcs: add dramsim on emu run #302

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion palladium.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ PLDM_MACRO_FLAGS += $(PLDM_EXTRA_MACRO)
ifeq ($(WORKLOAD_SWITCH),1)
PLDM_MACRO_FLAGS += +define+ENABLE_WORKLOAD_SWITCH
endif
ifeq ($(WITH_DRAMSIM3),1)
PLDM_MACRO_FLAGS += +define+WITH_DRAMSIM3
endif

# UA Args
IXCOM_FLAGS = -clean -64 -ua +sv +ignoreSimVerCheck +xe_alt_xlm
Expand Down Expand Up @@ -79,6 +82,10 @@ PLDM_CXXFILES = $(SIM_CXXFILES) $(shell find $(PLDM_CSRC_DIR) -name "*.cpp")
PLDM_CXXFLAGS = -m64 -c -fPIC -g -std=c++11 -I$(PLDM_IXCOM) -I$(PLDM_SIMTOOL)
PLDM_CXXFLAGS += $(SIM_CXXFLAGS) -I$(PLDM_CSRC_DIR) -DNUM_CORES=$(NUM_CORES)

ifeq ($(WITH_DRAMSIM3),1)
PLDM_LD_LIB = -L $(DRAMSIM3_HOME)/ -ldramsim3 -Wl,-rpath-link=$(DRAMSIM3_HOME)/libdramsim3.so
endif

# XMSIM Flags
XMSIM_FLAGS = --xmsim -64 +xcprof -profile -PROFTHREAD
ifneq ($(SYNTHESIS), 1)
Expand Down Expand Up @@ -111,7 +118,7 @@ pldm-build: $(PLDM_BUILD_DIR) $(PLDM_VFILELIST) $(PLDM_CC_OBJ_DIR)
ixcom $(IXCOM_FLAGS) -l $(PLDM_BUILD_DIR)/ixcom.log && \
cd $(PLDM_CC_OBJ_DIR) && \
$(CC) $(PLDM_CXXFLAGS) $(PLDM_CXXFILES) && \
$(CC) -o $(DPILIB_EMU) -m64 -shared *.o
$(CC) -o $(DPILIB_EMU) -m64 -shared *.o $(PLDM_LD_LIB)
endif

pldm-run: $(PLDM_BUILD_DIR)
Expand Down
7 changes: 7 additions & 0 deletions src/test/csrc/common/ram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,19 @@ void dramsim3_init() {
}

void dramsim3_step() {
if (dram == NULL)
return;
dram->tick();
}

void dramsim3_finish() {
delete dram;
dram = NULL;
}

uint64_t memory_response(bool isWrite) {
if (dram == NULL)
return 0;
auto response = (isWrite) ? dram->check_write_response() : dram->check_read_response();
if (response) {
auto meta = static_cast<dramsim3_meta *>(response->req->meta);
Expand All @@ -464,6 +469,8 @@ uint64_t memory_response(bool isWrite) {
}

bool memory_request(uint64_t address, uint32_t id, bool isWrite) {
if (dram == NULL)
return false;
if (dram->will_accept(address, isWrite)) {
auto req = new CoDRAMRequest();
auto meta = new dramsim3_meta;
Expand Down
6 changes: 6 additions & 0 deletions src/test/csrc/vcs/vcs_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ void difftest_deferred_result(uint8_t result) {
}
#endif // CONFIG_DIFFTEST_DEFERRED_RESULT

#ifdef WITH_DRAMSIM3
extern "C" void simv_tick() {
dramsim3_step();
}
#endif

void simv_finish() {
common_finish();
flash_finish();
Expand Down
8 changes: 8 additions & 0 deletions src/test/vsrc/vcs/top.v
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import "DPI-C" function void set_diff_ref_so(string diff_so);
import "DPI-C" function void set_no_diff();
import "DPI-C" function byte simv_init();
import "DPI-C" function void set_max_instrs(longint mc);
`ifdef WITH_DRAMSIM3
import "DPI-C" function void simv_tick();
`endif // WITH_DRAMSIM3
`ifdef ENABLE_WORKLOAD_SWITCH
import "DPI-C" function void set_workload_list(string path);
`endif // ENABLE_WORKLOAD_SWITCH
Expand Down Expand Up @@ -256,6 +259,11 @@ always @(posedge clock) begin
end

`ifndef TB_NO_DPIC
`ifdef WITH_DRAMSIM3
if (n_cycles) begin
simv_tick();
end
`endif // WITH_DRAMSIM3
// difftest
if (!n_cycles) begin
if (simv_init()) begin
Expand Down