1
0
rocket-chip/emulator/Makefile

97 lines
4.1 KiB
Makefile
Raw Normal View History

default: all
2014-09-01 05:26:55 +02:00
base_dir = $(abspath ..)
generated_dir = $(abspath ./generated-src)
generated_dir_debug = $(abspath ./generated-src-debug)
2013-05-01 11:58:53 +02:00
sim_dir = .
2014-09-01 05:26:55 +02:00
output_dir = $(sim_dir)/output
BACKEND = c
2016-05-25 20:08:11 +02:00
CONFIG ?= DefaultConfig
2013-05-01 11:58:53 +02:00
include $(base_dir)/Makefrag
2012-10-02 04:30:11 +02:00
2014-09-01 05:26:55 +02:00
CXXSRCS := emulator mm mm_dramsim2
CXXFLAGS := $(CXXFLAGS) -std=c++11 -I$(RISCV)/include -I$(base_dir)/csrc -I$(base_dir)/dramsim2
2014-01-28 12:50:07 +01:00
LDFLAGS := $(LDFLAGS) -L$(RISCV)/lib -Wl,-rpath,$(RISCV)/lib -L. -ldramsim -lfesvr -lpthread
OBJS := $(addsuffix .o,$(CXXSRCS) $(MODEL).$(CONFIG))
DEBUG_OBJS := $(addsuffix .debug.o,$(CXXSRCS) $(MODEL).$(CONFIG))
model_header = $(generated_dir)/$(MODEL).$(CONFIG).h
model_header_debug = $(generated_dir_debug)/$(MODEL).$(CONFIG).h
$(MODEL).$(CONFIG).o: %.o: $(generated_dir)/%.h
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls $(generated_dir)/$(MODEL).$(CONFIG)-*.cpp))
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls $(generated_dir)/$(MODEL).$(CONFIG)-*.cpp)) -o $@
$(MODEL).$(CONFIG).debug.o: %.debug.o: $(generated_dir_debug)/%.h
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls $(generated_dir_debug)/$(MODEL).$(CONFIG)-*.cpp))
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls $(generated_dir_debug)/$(MODEL).$(CONFIG)-*.cpp)) -o $@
$(generated_dir)/%.o: $(generated_dir)/%.cpp $(generated_dir)/%.h
$(CXX) $(CXXFLAGS) -I$(generated_dir) -c -o $@ $<
2012-10-02 04:30:11 +02:00
$(generated_dir_debug)/%.o: $(generated_dir_debug)/%.cpp $(generated_dir_debug)/%.h
$(CXX) $(CXXFLAGS) -I$(generated_dir_debug) -c -o $@ $<
$(addsuffix .o,$(CXXSRCS)): %.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h $(model_header) $(consts_header)
$(CXX) $(CXXFLAGS) -include $(scr_header) -include $(model_header) -include $(consts_header) -I$(generated_dir) -c -o $@ $<
2012-10-02 04:30:11 +02:00
$(addsuffix .debug.o,$(CXXSRCS)): %.debug.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h $(model_header_debug) $(consts_header_debug)
2016-02-20 08:13:57 +01:00
$(CXX) $(CXXFLAGS) -include $(scr_header_debug) -include $(model_header_debug) -include $(consts_header_debug) -I$(generated_dir_debug) -c -o $@ $<
$(generated_dir)/$(MODEL).$(CONFIG).d $(model_header) $(params_file): $(chisel_srcs)
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS) --noIoDebug"
2014-01-31 21:25:19 +01:00
$(model_header_debug) $(params_file_debug): $(chisel_srcs)
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS)-debug --debug --vcd --ioDebug"
2014-01-31 21:25:19 +01:00
emu = emulator-$(MODEL)-$(CONFIG)
$(emu): $(model_header) $(OBJS) libdramsim.a
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)
2012-10-02 04:30:11 +02:00
emu_debug = emulator-$(MODEL)-$(CONFIG)-debug
$(emu_debug): $(generated_dir)/$(MODEL).$(CONFIG).d $(model_header_debug) $(DEBUG_OBJS) libdramsim.a
$(CXX) $(CXXFLAGS) -o $@ $(DEBUG_OBJS) $(LDFLAGS)
all: $(emu)
debug: $(emu_debug)
2012-10-02 04:30:11 +02:00
clean:
rm -rf *.o *.a emulator-* $(generated_dir) $(generated_dir_debug) DVEfiles $(output_dir)
test:
cd $(base_dir) && $(SBT) "~make $(CURDIR) run-fast $(CHISEL_ARGS)"
2012-10-02 04:30:11 +02:00
.PHONY: default all debug clean test
2012-10-02 04:30:11 +02:00
#--------------------------------------------------------------------
# Run assembly tests and benchmarks
#--------------------------------------------------------------------
ifneq ($(MAKECMDGOALS),clean)
-include $(generated_dir)/$(MODEL).$(CONFIG).d
endif
2016-05-01 05:59:36 +02:00
$(output_dir)/%.run: $(output_dir)/% emulator-$(MODEL)-$(CONFIG)
./$(emu) +dramsim +max-cycles=$(timeout_cycles) $< 2> /dev/null 2> $@ && [ $$PIPESTATUS -eq 0 ]
2012-10-02 04:30:11 +02:00
2016-05-01 05:59:36 +02:00
$(output_dir)/%.out: $(output_dir)/% emulator-$(MODEL)-$(CONFIG)
./$(emu) +dramsim +max-cycles=$(timeout_cycles) +verbose $< $(disasm) $@ && [ $$PIPESTATUS -eq 0 ]
2012-10-02 04:30:11 +02:00
2016-05-01 05:59:36 +02:00
$(output_dir)/%.vcd: $(output_dir)/% emulator-$(MODEL)-$(CONFIG)-debug
./$(emu_debug) +dramsim +max-cycles=$(timeout_cycles) +verbose -v$@ $< $(disasm) $(patsubst %.vcd,%.out,$@) && [ $$PIPESTATUS -eq 0 ]
2012-10-02 04:30:11 +02:00
2016-05-01 05:59:36 +02:00
$(output_dir)/%.vpd: $(output_dir)/% emulator-$(MODEL)-$(CONFIG)-debug
rm -rf $@.vcd && mkfifo $@.vcd
2013-03-26 01:01:13 +01:00
vcd2vpd $@.vcd $@ > /dev/null &
2016-05-01 05:59:36 +02:00
./$(emu_debug) +dramsim +max-cycles=$(timeout_cycles) +verbose -v$@.vcd $< $(disasm) $(patsubst %.vpd,%.out,$@) && [ $$PIPESTATUS -eq 0 ]
2012-10-02 04:30:11 +02:00
2015-07-13 23:54:26 +02:00
run: run-asm-tests run-bmark-tests
run-debug: run-asm-tests-debug run-bmark-tests-debug
run-fast: run-asm-tests-fast run-bmark-tests-fast
.PHONY: run-asm-tests run-bmarks-test
.PHONY: run-asm-tests-debug run-bmark-tests-debug
.PHONY: run run-debug run-fast