1
0
rocket-chip/emulator/Makefile

91 lines
3.9 KiB
Makefile
Raw Normal View History

2014-09-01 05:26:55 +02:00
base_dir = $(abspath ..)
2013-05-01 11:58:53 +02:00
sim_dir = .
2014-09-01 05:26:55 +02:00
output_dir = $(sim_dir)/output
PROJECT = rocketchip
CONFIG ?= DefaultCPPConfig
SHELL=/bin/bash
2013-05-01 11:58:53 +02:00
all: emulator-$(CONFIG)
debug: emulator-$(CONFIG)-debug
2013-05-01 11:58:53 +02:00
include $(base_dir)/Makefrag
-include generated-src/Makefrag-tests.$(CONFIG)
2012-10-02 04:30:11 +02:00
CXXFLAGS := $(CXXFLAGS) -std=c++11 -I$(RISCV)/include
2012-10-02 04:30:11 +02:00
2014-09-01 05:26:55 +02:00
CXXSRCS := emulator mm mm_dramsim2
CXXFLAGS := $(CXXFLAGS) -I$(base_dir)/csrc -I$(base_dir)/dramsim2
2012-10-02 04:30:11 +02:00
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))
CHISEL_ARGS := $(MODEL) --W0W --noIoDebug --backend c --configInstance $(PROJECT).$(CONFIG) --compileInitializationUnoptimized --targetDir emulator/generated-src
2012-11-25 13:40:46 +01:00
CHISEL_ARGS_DEBUG := $(CHISEL_ARGS)-debug --debug --vcd --ioDebug
generated-src/$(MODEL).$(CONFIG).h: $(chisel_srcs)
cd $(base_dir) && $(SBT) "project $(PROJECT)" "elaborate $(CHISEL_ARGS)"
2012-10-02 04:30:11 +02:00
generated-src-debug/$(MODEL).$(CONFIG).h: $(chisel_srcs)
cd $(base_dir) && $(SBT) "project $(PROJECT)" "elaborate $(CHISEL_ARGS_DEBUG)"
2012-10-02 04:30:11 +02:00
$(MODEL).$(CONFIG).o: %.o: generated-src/%.h
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls generated-src/$(MODEL).$(CONFIG)-*.cpp))
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls generated-src/$(MODEL).$(CONFIG)-*.cpp)) -o $@
2014-01-31 21:25:19 +01:00
$(MODEL).$(CONFIG).debug.o: %.debug.o: generated-src-debug/%.h
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls generated-src-debug/$(MODEL).$(CONFIG)-*.cpp))
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls generated-src-debug/$(MODEL).$(CONFIG)-*.cpp)) -o $@
2014-01-31 21:25:19 +01:00
generated-src/%.o: generated-src/%.cpp generated-src/$(MODEL).$(CONFIG).h
2012-10-02 04:30:11 +02:00
$(CXX) $(CXXFLAGS) -Igenerated-src -c -o $@ $<
generated-src-debug/%.o: generated-src-debug/%.cpp generated-src-debug/$(MODEL).$(CONFIG).h
2012-10-02 04:30:11 +02:00
$(CXX) $(CXXFLAGS) -Igenerated-src-debug -c -o $@ $<
$(addsuffix .o,$(CXXSRCS)): %.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h generated-src/$(MODEL).$(CONFIG).h
$(CXX) $(CXXFLAGS) -include generated-src/$(MODEL).$(CONFIG).h -Igenerated-src -c -o $@ $<
2012-10-02 04:30:11 +02:00
$(addsuffix .debug.o,$(CXXSRCS)): %.debug.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h generated-src-debug/$(MODEL).$(CONFIG).h
$(CXX) $(CXXFLAGS) -include generated-src-debug/$(MODEL).$(CONFIG).h -Igenerated-src-debug -c -o $@ $<
2012-10-02 04:30:11 +02:00
emulator-$(CONFIG): $(OBJS) libdramsim.a
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)
2012-10-02 04:30:11 +02:00
emulator-$(CONFIG)-debug: $(DEBUG_OBJS) libdramsim.a
$(CXX) $(CXXFLAGS) -o $@ $(DEBUG_OBJS) $(LDFLAGS)
2012-10-02 04:30:11 +02:00
clean:
rm -rf *.o *.a emulator-* emulator-*-debug generated-src generated-src-debug DVEfiles $(output_dir)
test:
cd $(base_dir) && $(SBT) "~make $(CURDIR) run-fast $(CHISEL_ARGS)"
2012-10-02 04:30:11 +02:00
#--------------------------------------------------------------------
# Run assembly tests and benchmarks
#--------------------------------------------------------------------
$(output_dir)/%.run: $(output_dir)/%.hex emulator-$(CONFIG)
./emulator-$(CONFIG) +dramsim +max-cycles=$(timeout_cycles) +loadmem=$< none 2> /dev/null 2> $@ && [ $$PIPESTATUS -eq 0 ]
2012-10-02 04:30:11 +02:00
$(output_dir)/%.out: $(output_dir)/%.hex emulator-$(CONFIG)
./emulator-$(CONFIG) +dramsim +max-cycles=$(timeout_cycles) +verbose +loadmem=$< none $(disasm) $@ && [ $$PIPESTATUS -eq 0 ]
2012-10-02 04:30:11 +02:00
$(output_dir)/%.vcd: $(output_dir)/%.hex emulator-$(CONFIG)-debug
./emulator-$(CONFIG)-debug +dramsim +max-cycles=$(timeout_cycles) +verbose -v$@ +loadmem=$< none $(disasm) $(patsubst %.vcd,%.out,$@) && [ $$PIPESTATUS -eq 0 ]
2012-10-02 04:30:11 +02:00
$(output_dir)/%.vpd: $(output_dir)/%.hex emulator-$(CONFIG)-debug
rm -rf $@.vcd && mkfifo $@.vcd
2013-03-26 01:01:13 +01:00
vcd2vpd $@.vcd $@ > /dev/null &
./emulator-$(CONFIG)-debug +dramsim +max-cycles=$(timeout_cycles) +verbose -v$@.vcd +loadmem=$< none $(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