提交 360f082f 编写于 作者: Y Yinan Xu

Makefile: use --savable only when EMU_SNAPSHOT

上级 43bccba1
......@@ -52,14 +52,22 @@ EMU_VSRC_DIR = $(abspath ./src/test/vsrc)
EMU_CXXFILES = $(shell find $(EMU_CSRC_DIR) -name "*.cpp")
EMU_VFILES = $(shell find $(EMU_VSRC_DIR) -name "*.v" -or -name "*.sv")
EMU_CXXFLAGS = -std=c++11 -static -Wall -I$(EMU_CSRC_DIR)
EMU_CXXFLAGS += -std=c++11 -static -Wall -I$(EMU_CSRC_DIR)
EMU_CXXFLAGS += -DVERILATOR -Wno-maybe-uninitialized
EMU_LDFLAGS = -lpthread -lSDL2 -ldl
EMU_THREADS = 1
ifeq ($(EMU_THREADS), 1)
VTHREAD_FLAGS = --threads 1
else
VTHREAD_FLAGS = --threads $(EMU_THREADS) --threads-dpi none
# Verilator trace support
VEXTRA_FLAGS = --trace
# Verilator multi-thread support
EMU_THREADS ?= 1
VEXTRA_FLAGS += --threads $(EMU_THREADS) --threads-dpi none
# Verilator savable
EMU_SNAPSHOT ?= 0
ifeq ($(EMU_SNAPSHOT),1)
VEXTRA_FLAGS += --savable
EMU_CXXFLAGS += -DVM_SAVABLE
endif
# --trace
......@@ -68,10 +76,8 @@ VERILATOR_FLAGS = --top-module $(SIM_TOP) \
+define+PRINTF_COND=1 \
+define+RANDOMIZE_REG_INIT \
+define+RANDOMIZE_MEM_INIT \
$(VTHREAD_FLAGS) \
--trace \
$(VEXTRA_FLAGS) \
--assert \
--savable \
--stats-vars \
--output-split 5000 \
--output-split-cfuncs 5000 \
......@@ -108,7 +114,6 @@ SEED ?= $(shell shuf -i 1-10000 -n 1)
B ?= 0
E ?= -1
SNAPSHOT ?=
ENABLESNAPSHOT ?= 0
# enable this runtime option if you want to generate a vcd file
# use 'emu -h' to see more details
......@@ -121,10 +126,6 @@ SNAPSHOT_OPTION = --load-snapshot=$(SNAPSHOT)
endif
ifeq ($(ENABLESNAPSHOT),1)
EMU_CXXFLAGS += -D__ENABLESNAPSHOT__
endif
EMU_FLAGS = -s $(SEED) -b $(B) -e $(E) $(SNAPSHOT_OPTION) $(WAVEFORM)
emu: $(EMU)
......
......@@ -107,7 +107,7 @@ Emulator::Emulator(int argc, const char *argv[]):
enable_waveform = false;
#endif
#ifdef __ENABLESNAPSHOT__
#ifdef VM_SAVABLE
if (args.snapshot_path != NULL) {
printf("loading from snapshot `%s`...\n", args.snapshot_path);
snapshot_load(args.snapshot_path);
......@@ -122,7 +122,7 @@ Emulator::Emulator(int argc, const char *argv[]):
}
Emulator::~Emulator() {
#ifdef __ENABLESNAPSHOT__
#ifdef VM_SAVABLE
snapshot_slot[0].save();
snapshot_slot[1].save();
printf("Please remove unused snapshots manually\n");
......@@ -281,7 +281,7 @@ uint64_t Emulator::execute(uint64_t n) {
poll_event();
lasttime_poll = t;
}
#ifdef __ENABLESNAPSHOT__
#ifdef VM_SAVABLE
static int snapshot_count = 0;
if (trapCode != STATE_GOODTRAP && t - lasttime_snapshot > 1000 * SNAPSHOT_INTERVAL) {
// save snapshot every 10s
......@@ -314,7 +314,7 @@ inline char* Emulator::timestamp_filename(time_t t, char *buf) {
return buf + len;
}
#ifdef __ENABLESNAPSHOT__
#ifdef VM_SAVABLE
inline char* Emulator::snapshot_filename(time_t t) {
static char buf[1024];
char *p = timestamp_filename(t, buf);
......@@ -355,7 +355,7 @@ void Emulator::display_trapinfo() {
instrCnt, cycleCnt, ipc);
}
#ifdef __ENABLESNAPSHOT__
#ifdef VM_SAVABLE
void Emulator::snapshot_save(const char *filename) {
static int last_slot = 0;
VerilatedSaveMem &stream = snapshot_slot[last_slot];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册