Skip to content

Commit

Permalink
vcs: add dramsim on emu run
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokamikami committed Mar 7, 2024
1 parent 666a1ec commit c58f10e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ endif
# co-simulation with DRAMsim3
ifeq ($(WITH_DRAMSIM3),1)
SIM_CXXFLAGS += -I$(DRAMSIM3_HOME)/src
SIM_CXXFLAGS += -DWITH_DRAMSIM3 -DDRAMSIM3_CONFIG=\\\"$(DRAMSIM3_HOME)/configs/XiangShan.ini\\\" -DDRAMSIM3_OUTDIR=\\\"$(BUILD_DIR)\\\"
SYSTEM_VAR = $(shell uname -a)
ifeq ($(findstring "Ubuntu",$(SYSTEM_VAR)),)
SIM_CXXFLAGS += -DWITH_DRAMSIM3 -DDRAMSIM3_CONFIG=\\\"$(DRAMSIM3_HOME)/configs/XiangShan.ini\\\" -DDRAMSIM3_OUTDIR=\\\"$(BUILD_DIR)\\\"
else
SIM_CXXFLAGS += -DWITH_DRAMSIM3 -DDRAMSIM3_CONFIG=\"$(DRAMSIM3_HOME)/configs/XiangShan.ini\" -DDRAMSIM3_OUTDIR=\"$(BUILD_DIR)\"
endif
SIM_LDFLAGS += $(DRAMSIM3_HOME)/build/libdramsim3.a
endif

Expand Down
9 changes: 8 additions & 1 deletion palladium.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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 @@ -76,6 +79,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 @@ -108,7 +115,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
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
6 changes: 6 additions & 0 deletions src/test/vsrc/vcs/top.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import "DPI-C" function void set_workload_list(string path);
`endif // ENABLE_WORKLOAD_SWITCH
`ifndef CONFIG_DIFFTEST_DEFERRED_RESULT
import "DPI-C" function byte simv_nstep(byte step);
`ifdef WITH_DRAMSIM3
import "DPI-C" function void simv_tick();
`endif // WITH_DRAMSIM3
`endif // CONFIG_DIFFTEST_DEFERRED_RESULT
`endif // TB_NO_DPIC

Expand Down Expand Up @@ -256,6 +259,9 @@ always @(posedge clock) begin
end

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

0 comments on commit c58f10e

Please sign in to comment.