1
0

Add missing changes to emulator/Makefile

This commit is contained in:
Henry Cook 2015-07-29 17:57:02 -07:00
parent d21ffa4dba
commit ee531dc97e

View File

@ -1,85 +1,77 @@
default: all
base_dir = $(abspath ..) base_dir = $(abspath ..)
generated_dir = $(abspath ./generated-src)
sim_dir = . sim_dir = .
output_dir = $(sim_dir)/output output_dir = $(sim_dir)/output
PROJECT = rocketchip
BACKEND = c
CONFIG ?= DefaultCPPConfig CONFIG ?= DefaultCPPConfig
SHELL=/bin/bash
all: emulator-$(CONFIG)
debug: emulator-$(CONFIG)-debug
include $(base_dir)/Makefrag include $(base_dir)/Makefrag
-include generated-src/Makefrag-tests.$(CONFIG) -include $(generated_dir)/$(MODEL).$(CONFIG).d
CXXFLAGS := $(CXXFLAGS) -std=c++11 -I$(RISCV)/include
CXXSRCS := emulator mm mm_dramsim2 CXXSRCS := emulator mm mm_dramsim2
CXXFLAGS := $(CXXFLAGS) -I$(base_dir)/csrc -I$(base_dir)/dramsim2 CXXFLAGS := $(CXXFLAGS) -std=c++11 -I$(RISCV)/include -I$(base_dir)/csrc -I$(base_dir)/dramsim2
LDFLAGS := $(LDFLAGS) -L$(RISCV)/lib -Wl,-rpath,$(RISCV)/lib -L. -ldramsim -lfesvr -lpthread LDFLAGS := $(LDFLAGS) -L$(RISCV)/lib -Wl,-rpath,$(RISCV)/lib -L. -ldramsim -lfesvr -lpthread
OBJS := $(addsuffix .o,$(CXXSRCS) $(MODEL).$(CONFIG)) 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 $(MODEL).$(CONFIG).o: %.o: $(generated_dir)/%.h
CHISEL_ARGS_DEBUG := $(CHISEL_ARGS)-debug --debug --vcd --ioDebug $(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 $@
generated-src/$(MODEL).$(CONFIG).h: $(chisel_srcs) $(generated_dir)/%.o: $(generated_dir)/%.cpp $(generated_dir)/%.h
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS)" $(CXX) $(CXXFLAGS) -I$(generated_dir) -c -o $@ $<
generated-src-debug/$(MODEL).$(CONFIG).h: $(chisel_srcs) $(addsuffix .o,$(CXXSRCS)): %.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h $(generated_dir)/$(MODEL).$(CONFIG).h
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS_DEBUG)" $(CXX) $(CXXFLAGS) -include $(generated_dir)/$(MODEL).$(CONFIG).h -I$(generated_dir) -c -o $@ $<
$(MODEL).$(CONFIG).o: %.o: generated-src/%.h $(generated_dir)/nodebug.d $(generated_dir)/$(MODEL).$(CONFIG).d : $(chisel_srcs)
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls generated-src/$(MODEL).$(CONFIG)-*.cpp)) rm -f $(generated_dir)/debug.d $(shell ls $(generated_dir)/$(MODEL).$(CONFIG)*)
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls generated-src/$(MODEL).$(CONFIG)-*.cpp)) -o $@ cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS) --noIoDebug"
touch $(generated_dir)/nodebug.d
$(MODEL).$(CONFIG).debug.o: %.debug.o: generated-src-debug/%.h $(generated_dir)/debug.d : $(chisel_srcs)
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls generated-src-debug/$(MODEL).$(CONFIG)-*.cpp)) rm -f $(generated_dir)/nodebug.d $(shell ls $(generated_dir)/$(MODEL).$(CONFIG)*)
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls generated-src-debug/$(MODEL).$(CONFIG)-*.cpp)) -o $@ cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS) --debug --vcd --ioDebug"
touch $(generated_dir)/debug.d
generated-src/%.o: generated-src/%.cpp generated-src/$(MODEL).$(CONFIG).h emu = emulator-$(MODEL)-$(CONFIG)
$(CXX) $(CXXFLAGS) -Igenerated-src -c -o $@ $< $(emu): $(generated_dir)/nodebug.d $(OBJS) libdramsim.a
generated-src-debug/%.o: generated-src-debug/%.cpp generated-src-debug/$(MODEL).$(CONFIG).h
$(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 $@ $<
$(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 $@ $<
emulator-$(CONFIG): $(OBJS) libdramsim.a
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)
emulator-$(CONFIG)-debug: $(DEBUG_OBJS) libdramsim.a emu_debug = emulator-$(MODEL)-$(CONFIG)-debug
$(CXX) $(CXXFLAGS) -o $@ $(DEBUG_OBJS) $(LDFLAGS) $(emu_debug): $(generated_dir)/debug.d $(OBJS) libdramsim.a
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)
all: $(emu)
debug: $(emu_debug)
clean: clean:
rm -rf *.o *.a emulator-* emulator-*-debug generated-src generated-src-debug DVEfiles $(output_dir) rm -rf *.o *.a emulator-* $(generated_dir) DVEfiles $(output_dir)
test: test:
cd $(base_dir) && $(SBT) "~make $(CURDIR) run-fast $(CHISEL_ARGS)" cd $(base_dir) && $(SBT) "~make $(CURDIR) run-fast $(CHISEL_ARGS)"
.PHONY: default all debug clean test
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Run assembly tests and benchmarks # Run assembly tests and benchmarks
#-------------------------------------------------------------------- #--------------------------------------------------------------------
$(output_dir)/%.run: $(output_dir)/%.hex emulator-$(CONFIG) $(output_dir)/%.run: $(output_dir)/%.hex emulator-$(MODEL)-$(CONFIG)
./emulator-$(CONFIG) +dramsim +max-cycles=$(timeout_cycles) +loadmem=$< none 2> /dev/null 2> $@ && [ $$PIPESTATUS -eq 0 ] ./$(emu) +dramsim +max-cycles=$(timeout_cycles) +loadmem=$< none 2> /dev/null 2> $@ && [ $$PIPESTATUS -eq 0 ]
$(output_dir)/%.out: $(output_dir)/%.hex emulator-$(CONFIG) $(output_dir)/%.out: $(output_dir)/%.hex emulator-$(MODEL)-$(CONFIG)
./emulator-$(CONFIG) +dramsim +max-cycles=$(timeout_cycles) +verbose +loadmem=$< none $(disasm) $@ && [ $$PIPESTATUS -eq 0 ] ./$(emu) +dramsim +max-cycles=$(timeout_cycles) +verbose +loadmem=$< none $(disasm) $@ && [ $$PIPESTATUS -eq 0 ]
$(output_dir)/%.vcd: $(output_dir)/%.hex emulator-$(CONFIG)-debug $(output_dir)/%.vcd: $(output_dir)/%.hex emulator-$(MODEL)-$(CONFIG)-debug
./emulator-$(CONFIG)-debug +dramsim +max-cycles=$(timeout_cycles) +verbose -v$@ +loadmem=$< none $(disasm) $(patsubst %.vcd,%.out,$@) && [ $$PIPESTATUS -eq 0 ] ./$(emu_debug) +dramsim +max-cycles=$(timeout_cycles) +verbose -v$@ +loadmem=$< none $(disasm) $(patsubst %.vcd,%.out,$@) && [ $$PIPESTATUS -eq 0 ]
$(output_dir)/%.vpd: $(output_dir)/%.hex emulator-$(CONFIG)-debug $(output_dir)/%.vpd: $(output_dir)/%.hex emulator-$(MODEL)-$(CONFIG)-debug
rm -rf $@.vcd && mkfifo $@.vcd rm -rf $@.vcd && mkfifo $@.vcd
vcd2vpd $@.vcd $@ > /dev/null & vcd2vpd $@.vcd $@ > /dev/null &
./emulator-$(CONFIG)-debug +dramsim +max-cycles=$(timeout_cycles) +verbose -v$@.vcd +loadmem=$< none $(disasm) $(patsubst %.vpd,%.out,$@) && [ $$PIPESTATUS -eq 0 ] ./$(emu_debug) +dramsim +max-cycles=$(timeout_cycles) +verbose -v$@.vcd +loadmem=$< none $(disasm) $(patsubst %.vpd,%.out,$@) && [ $$PIPESTATUS -eq 0 ]
run: run-asm-tests run-bmark-tests run: run-asm-tests run-bmark-tests
run-debug: run-asm-tests-debug run-bmark-tests-debug run-debug: run-asm-tests-debug run-bmark-tests-debug