2012-12-04 16:04:26 +01:00
|
|
|
all: emulator
|
|
|
|
|
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
|
2014-09-02 22:51:57 +02:00
|
|
|
PROJECT = rocketchip
|
2014-08-02 03:09:37 +02:00
|
|
|
CONFIG = DefaultCPPConfig
|
2013-05-01 11:58:53 +02:00
|
|
|
|
|
|
|
include $(base_dir)/Makefrag
|
2012-10-02 04:30:11 +02:00
|
|
|
|
2013-06-14 09:27:52 +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
|
2013-08-20 04:54:41 +02:00
|
|
|
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
|
2013-01-25 08:56:45 +01:00
|
|
|
|
2012-10-19 03:59:37 +02:00
|
|
|
OBJS := $(addsuffix .o,$(CXXSRCS) $(MODEL))
|
|
|
|
DEBUG_OBJS := $(addsuffix -debug.o,$(CXXSRCS) $(MODEL))
|
2012-10-14 23:06:28 +02:00
|
|
|
|
2014-08-12 19:35:39 +02:00
|
|
|
CHISEL_ARGS := $(MODEL) --noIoDebug --backend c --configInstance $(PROJECT).$(CONFIG) --targetDir emulator/generated-src
|
2012-11-25 13:40:46 +01:00
|
|
|
CHISEL_ARGS_DEBUG := $(CHISEL_ARGS)-debug --debug --vcd --ioDebug
|
2012-11-18 04:58:18 +01:00
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
generated-src/$(MODEL).h: $(chisel_srcs)
|
2014-08-02 03:09:37 +02:00
|
|
|
cd $(base_dir) && $(SBT) "project $(PROJECT)" "elaborate $(CHISEL_ARGS)"
|
2012-10-02 04:30:11 +02:00
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
generated-src-debug/$(MODEL).h: $(chisel_srcs)
|
2014-08-02 03:09:37 +02:00
|
|
|
cd $(base_dir) && $(SBT) "project $(PROJECT)" "elaborate $(CHISEL_ARGS_DEBUG)"
|
2012-10-02 04:30:11 +02:00
|
|
|
|
2014-01-31 21:25:19 +01:00
|
|
|
$(MODEL).o: %.o: generated-src/%.h
|
|
|
|
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls generated-src/$(MODEL)-*.cpp))
|
|
|
|
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls generated-src/$(MODEL)-*.cpp)) -o $@
|
|
|
|
|
|
|
|
$(MODEL)-debug.o: %-debug.o: generated-src-debug/%.h
|
|
|
|
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls generated-src-debug/$(MODEL)-*.cpp))
|
|
|
|
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls generated-src-debug/$(MODEL)-*.cpp)) -o $@
|
|
|
|
|
|
|
|
$(wildcard generated-src/*.o): %.o: %.cpp generated-src/$(MODEL).h
|
2012-10-02 04:30:11 +02:00
|
|
|
$(CXX) $(CXXFLAGS) -Igenerated-src -c -o $@ $<
|
|
|
|
|
2014-01-31 21:25:19 +01:00
|
|
|
$(wildcard generated-src-debug/*.o): %.o: %.cpp generated-src-debug/$(MODEL).h
|
2012-10-02 04:30:11 +02:00
|
|
|
$(CXX) $(CXXFLAGS) -Igenerated-src-debug -c -o $@ $<
|
|
|
|
|
2014-01-31 21:25:19 +01:00
|
|
|
$(addsuffix .o,$(CXXSRCS)): %.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h generated-src/$(MODEL).h
|
2012-10-02 04:30:11 +02:00
|
|
|
$(CXX) $(CXXFLAGS) -Igenerated-src -c -o $@ $<
|
|
|
|
|
2014-01-31 21:25:19 +01:00
|
|
|
$(addsuffix -debug.o,$(CXXSRCS)): %-debug.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h generated-src-debug/$(MODEL).h
|
2012-10-02 04:30:11 +02:00
|
|
|
$(CXX) $(CXXFLAGS) -Igenerated-src-debug -c -o $@ $<
|
|
|
|
|
2012-10-19 03:59:37 +02:00
|
|
|
emulator: $(OBJS) libdramsim.a
|
2013-01-25 08:56:45 +01:00
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)
|
2012-10-02 04:30:11 +02:00
|
|
|
|
2012-10-19 03:59:37 +02:00
|
|
|
emulator-debug: $(DEBUG_OBJS) libdramsim.a
|
2013-01-25 08:56:45 +01:00
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(DEBUG_OBJS) $(LDFLAGS)
|
2012-10-02 04:30:11 +02:00
|
|
|
|
|
|
|
clean:
|
2014-09-01 05:26:55 +02:00
|
|
|
rm -rf *.o *.a emulator emulator-debug generated-src generated-src-debug DVEfiles $(output_dir)
|
2012-10-19 13:09:07 +02:00
|
|
|
|
|
|
|
test:
|
2013-08-20 04:54:41 +02:00
|
|
|
cd $(base_dir) && $(SBT) "~make $(CURDIR) run-fast $(CHISEL_ARGS)"
|
2012-10-02 04:30:11 +02:00
|
|
|
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
# Run assembly tests and benchmarks
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
$(output_dir)/%.run: $(output_dir)/%.hex emulator
|
|
|
|
./emulator +dramsim +max-cycles=$(timeout_cycles) +loadmem=$< none 2> /dev/null 2> $@ && [ $$PIPESTATUS -eq 0 ]
|
2012-10-02 04:30:11 +02:00
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
$(output_dir)/%.out: $(output_dir)/%.hex emulator
|
|
|
|
./emulator +dramsim +max-cycles=$(timeout_cycles) +verbose +loadmem=$< none $(disasm) $@ && [ $$PIPESTATUS -eq 0 ]
|
2012-10-02 04:30:11 +02:00
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
$(output_dir)/%.vcd: $(output_dir)/%.hex emulator-debug
|
|
|
|
./emulator-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
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
$(output_dir)/%.vpd: $(output_dir)/%.hex emulator-debug
|
2013-03-26 00:19:19 +01:00
|
|
|
rm -rf $@.vcd && mkfifo $@.vcd
|
2013-03-26 01:01:13 +01:00
|
|
|
vcd2vpd $@.vcd $@ > /dev/null &
|
2014-09-01 05:26:55 +02:00
|
|
|
./emulator-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
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
run-asm-tests: $(addprefix $(output_dir)/, $(addsuffix .out, $(asm_p_tests) $(asm_v_tests)))
|
2012-10-19 13:09:07 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $^; echo;
|
2014-09-01 05:26:55 +02:00
|
|
|
run-vecasm-tests: $(addprefix $(output_dir)/, $(addsuffix .out, $(vecasm_p_tests) $(vecasm_v_tests)))
|
2012-10-19 13:09:07 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $^; echo;
|
2014-09-01 05:26:55 +02:00
|
|
|
run-vecasm-timer-tests: $(addprefix $(output_dir)/, $(addsuffix .out, $(vecasm_pt_tests)))
|
2012-10-19 13:09:07 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $^; echo;
|
2014-09-01 05:26:55 +02:00
|
|
|
run-bmarks-test: $(addprefix $(output_dir)/, $(addsuffix .out, $(bmarks)))
|
2012-10-19 13:09:07 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $^; echo;
|
2014-09-01 05:26:55 +02:00
|
|
|
run-mt-tests: $(addprefix $(output_dir)/, $(addsuffix .out, $(mt_bmarks)))
|
2013-06-14 00:34:15 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $^; echo;
|
2012-10-19 13:09:07 +02:00
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
run-asm-tests-debug: $(addprefix $(output_dir)/, $(addsuffix .vpd, $(asm_p_tests) $(asm_v_tests)))
|
2012-10-19 13:09:07 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $(patsubst %.vpd,%.out,$^); echo;
|
2014-09-01 05:26:55 +02:00
|
|
|
run-vecasm-tests-debug: $(addprefix $(output_dir)/, $(addsuffix .vpd, $(vecasm_p_tests) $(vecasm_v_tests)))
|
2012-10-19 13:09:07 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $(patsubst %.vpd,%.out,$^); echo;
|
2014-09-01 05:26:55 +02:00
|
|
|
run-vecasm-timer-tests-debug: $(addprefix $(output_dir)/, $(addsuffix .vpd, $(vecasm_pt_tests)))
|
2012-10-19 13:09:07 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $(patsubst %.vpd,%.out,$^); echo;
|
2014-09-01 05:26:55 +02:00
|
|
|
run-bmarks-test-debug: $(addprefix $(output_dir)/, $(addsuffix .vpd, $(bmarks)))
|
2012-10-19 13:09:07 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $(patsubst %.vpd,%.out,$^); echo;
|
2014-09-01 05:26:55 +02:00
|
|
|
run-mt-tests-debug: $(addprefix $(output_dir)/, $(addsuffix .vpd, $(mt_bmarks)))
|
2013-06-14 00:34:15 +02:00
|
|
|
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $(patsubst %.vpd,%.out,$^); echo;
|
2012-10-02 04:30:11 +02:00
|
|
|
|
2013-09-13 02:03:38 +02:00
|
|
|
run: run-asm-tests run-bmarks-test #run-vecasm-tests run-vecasm-timer-tests
|
|
|
|
run-debug: run-asm-tests-debug run-bmarks-test-debug #run-vecasm-tests-debug run-vecasm-timer-tests-debug
|
2014-09-01 05:26:55 +02:00
|
|
|
run-fast: $(addprefix $(output_dir)/, $(addsuffix .run, $(asm_p_tests) $(asm_v_tests) $(bmarks)))
|