2014-09-11 02:38:21 -07:00
|
|
|
# check RISCV environment variable
|
|
|
|
ifndef RISCV
|
|
|
|
$(error Please set environment variable RISCV. Please take a look at README)
|
|
|
|
endif
|
|
|
|
|
2012-10-18 17:51:41 -07:00
|
|
|
MODEL := Top
|
2012-10-01 19:30:11 -07:00
|
|
|
CXX := g++
|
2014-01-31 12:25:19 -08:00
|
|
|
CXXFLAGS := -O1
|
2012-10-01 19:30:11 -07:00
|
|
|
|
2012-11-20 05:39:48 -08:00
|
|
|
SBT := java -Xmx2048M -Xss8M -XX:MaxPermSize=128M -jar sbt-launch.jar
|
2015-06-25 23:17:35 -07:00
|
|
|
SHELL := /bin/bash
|
2012-10-01 19:30:11 -07:00
|
|
|
|
2014-08-31 20:26:55 -07:00
|
|
|
src_path = src/main/scala
|
2014-09-09 20:49:28 -07:00
|
|
|
chisel_srcs = $(base_dir)/$(src_path)/*.scala $(base_dir)/rocket/$(src_path)/*.scala $(base_dir)/uncore/$(src_path)/*.scala $(SRC_EXTENSION)
|
2014-08-31 20:26:55 -07:00
|
|
|
|
|
|
|
disasm := 2>
|
2015-06-25 23:17:35 -07:00
|
|
|
which_disasm := $(shell which spike-dasm)
|
2014-08-31 20:26:55 -07:00
|
|
|
ifneq ($(which_disasm),)
|
2014-09-09 20:49:28 -07:00
|
|
|
disasm := 3>&1 1>&2 2>&3 | $(which_disasm) $(DISASM_EXTENSION) >
|
2014-08-31 20:26:55 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
timeout_cycles = 100000000
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
# Verilog Generation
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
|
2014-09-11 22:11:58 -07:00
|
|
|
$(generated_dir)/$(MODEL).$(CONFIG).v: $(chisel_srcs)
|
2015-07-07 20:38:47 -07:00
|
|
|
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate $(MODEL) --backend $(BACKEND) --targetDir $(generated_dir) --W0W --configDump --noInlineMem --configInstance rocketchip.$(CONFIG)"
|
2014-08-31 20:26:55 -07:00
|
|
|
cd $(generated_dir) && \
|
2014-09-11 22:11:58 -07:00
|
|
|
if [ -a $(MODEL).$(CONFIG).conf ]; then \
|
|
|
|
$(mem_gen) $(generated_dir)/$(MODEL).$(CONFIG).conf >> $(generated_dir)/$(MODEL).$(CONFIG).v; \
|
2014-08-31 20:26:55 -07:00
|
|
|
fi
|
|
|
|
|
2014-09-11 22:11:58 -07:00
|
|
|
$(generated_dir)/consts.$(CONFIG).vh: $(generated_dir)/$(MODEL).$(CONFIG).v
|
2014-09-10 17:14:55 -07:00
|
|
|
echo "\`ifndef CONST_VH" > $@
|
|
|
|
echo "\`define CONST_VH" >> $@
|
2014-09-11 22:11:58 -07:00
|
|
|
sed -r 's/\(([A-Za-z0-9_]+),([A-Za-z0-9_]+)\)/`define \1 \2/' $(patsubst %.v,%.prm,$<) >> $@
|
2014-09-10 17:14:55 -07:00
|
|
|
echo "\`endif // CONST_VH" >> $@
|
|
|
|
|
2014-09-11 22:11:58 -07:00
|
|
|
$(generated_dir)/memdessertMemDessert.$(CONFIG).v: $(base_dir)/$(src_path)/*.scala $(base_dir)/uncore/$(src_path)/*.scala
|
2015-07-07 20:38:47 -07:00
|
|
|
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate MemDessert --backend v --targetDir $(generated_dir) --W0W --moduleNamePrefix memdessert --configInstance rocketchip.$(CONFIG)"
|
2014-08-31 20:26:55 -07:00
|
|
|
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
# DRAMSim2
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
|
2013-05-01 02:58:53 -07:00
|
|
|
DRAMSIM_OBJS := $(patsubst %.cpp,%.o,$(wildcard $(base_dir)/dramsim2/*.cpp))
|
2012-12-04 07:04:26 -08:00
|
|
|
$(DRAMSIM_OBJS): %.o: %.cpp
|
|
|
|
$(CXX) $(CXXFLAGS) -DNO_STORAGE -DNO_OUTPUT -Dmain=nomain -c -o $@ $<
|
2013-05-01 02:58:53 -07:00
|
|
|
$(sim_dir)/libdramsim.a: $(DRAMSIM_OBJS)
|
2012-12-04 07:04:26 -08:00
|
|
|
ar rcs $@ $^
|
|
|
|
|
2014-08-31 20:26:55 -07:00
|
|
|
#--------------------------------------------------------------------
|
|
|
|
# Build Tests
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
|
|
|
|
%.hex:
|
|
|
|
$(MAKE) -C $(dir $@) $(notdir $@)
|
|
|
|
|
|
|
|
%.riscv.hex: %
|
|
|
|
$(MAKE) -C $(dir $@) $(notdir $@)
|