From 1ad928cfe2117f96ec001020bab0e3c70a40dac8 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 18 Oct 2012 18:59:37 -0700 Subject: [PATCH] directly integrate dramsim build also, build it as a static library to simplify dependencies --- README | 8 -------- emulator/.gitignore | 1 + emulator/Makefile | 26 ++++++++++++++------------ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/README b/README index 0b827521..af5e7382 100644 --- a/README +++ b/README @@ -26,19 +26,11 @@ BUILDING THE TOOLCHAIN: cd riscv-asmtests-bmarks/riscv-bmarks/ make - To build dramsim2 (tagged version 2.1): - - cd dramsim2/ - git checkout v2.1 - make libdramsim.so - - BUILDING THE PROJECT: To build the C simulator: cd emulator - make dramsim2 (if DRAMSim2 is not installed and in your path) make To build the VCS simulator: diff --git a/emulator/.gitignore b/emulator/.gitignore index 928c1ccd..0dbfd5c7 100644 --- a/emulator/.gitignore +++ b/emulator/.gitignore @@ -1,5 +1,6 @@ *~ *.o +*.a *.out *.vcd *.vpd diff --git a/emulator/Makefile b/emulator/Makefile index dea78bb7..fb03bd1b 100644 --- a/emulator/Makefile +++ b/emulator/Makefile @@ -7,17 +7,16 @@ CXXFLAGS := -O1 all: emulator CXXSRCS := emulator disasm -CXXFLAGS := $(CXXFLAGS) -Itestbench -I$(basedir)/chisel/csrc +CXXFLAGS := $(CXXFLAGS) -Itestbench -I$(basedir)/chisel/csrc -I../dramsim2 -DRAMSIM2_PATH := ../dramsim2/ -CXXFLAGS := $(CXXFLAGS) -I$(DRAMSIM2_PATH) -L$(DRAMSIM2_PATH) -ldramsim -Wl,-rpath=$(DRAMSIM2_PATH) -DRAMSIM2_LIB := libdramsim.so +OBJS := $(addsuffix .o,$(CXXSRCS) $(MODEL)) +DEBUG_OBJS := $(addsuffix -debug.o,$(CXXSRCS) $(MODEL)) generated-src/$(MODEL).cpp: $(basedir)/riscv-rocket/src/*.scala $(basedir)/riscv-hwacha/src/*.scala $(basedir)/chisel/src/main/scala/* $(basedir)/uncore/src/*.scala - cd $(basedir)/sbt && $(SBT) "project referencechip" "run ReferenceChip.Top --backend c --noIoDebug --targetDir ../emulator/generated-src" + cd $(basedir)/sbt && $(SBT) "project referencechip" "run ReferenceChip.$(MODEL) --backend c --noIoDebug --targetDir ../emulator/generated-src" generated-src-debug/$(MODEL).cpp: $(basedir)/riscv-rocket/src/*.scala $(basedir)/riscv-hwacha/src/*.scala $(basedir)/chisel/src/main/scala/* $(basedir)/uncore/src/*.scala - cd $(basedir)/sbt && $(SBT) "project referencechip" "run ReferenceChip.Top --backend c --debug --vcd --targetDir ../emulator/generated-src-debug" + cd $(basedir)/sbt && $(SBT) "project referencechip" "run ReferenceChip.$(MODEL) --backend c --debug --vcd --targetDir ../emulator/generated-src-debug" $(MODEL).o: %.o: generated-src/%.cpp $(CXX) $(CXXFLAGS) -Igenerated-src -c -o $@ $< @@ -31,14 +30,17 @@ $(addsuffix .o,$(CXXSRCS)): %.o: testbench/%.cc testbench/* generated-src/$(MODE $(addsuffix -debug.o,$(CXXSRCS)): %-debug.o: testbench/%.cc testbench/* generated-src-debug/$(MODEL).cpp $(CXX) $(CXXFLAGS) -Igenerated-src-debug -c -o $@ $< -emulator: $(addsuffix .o,$(CXXSRCS)) $(MODEL).o - $(CXX) $(CXXFLAGS) -o $@ $^ +DRAMSIM_OBJS := $(patsubst %.cpp,%.o,$(wildcard ../dramsim2/*.cpp)) +$(DRAMSIM_OBJS): %.o: %.cpp + $(CXX) $(CXXFLAGS) -DNO_STORAGE -Dmain=nomain -c -o $@ $< +libdramsim.a: $(DRAMSIM_OBJS) + ar rcs $@ $^ -emulator-debug: $(addsuffix -debug.o,$(CXXSRCS)) $(MODEL)-debug.o - $(CXX) $(CXXFLAGS) -o $@ $^ +emulator: $(OBJS) libdramsim.a + $(CXX) $(CXXFLAGS) -o $@ $(OBJS) -L. -ldramsim -dramsim2: - cd $(DRAMSIM2_PATH) ; make $(DRAMSIM2_LIB) +emulator-debug: $(DEBUG_OBJS) libdramsim.a + $(CXX) $(CXXFLAGS) -o $@ $(DEBUG_OBJS) -L. -ldramsim all: emulator