abstractaccelerator/opene906/demo/sim/Makefile

81 lines
2.4 KiB
Makefile
Raw Permalink Normal View History

2022-02-22 14:44:45 +08:00
export CODE_BASE_PATH = ${PWD}/../../E906_RTL_FACTORY
GCC_PREFIX = /opt/riscv/bin/riscv32-unknown-elf
GDB_PREFIX = /opt/riscv/bin/riscv32-unknown-elf-gdb
FILELIST = -F ../../smart_run/logical/filelists/soc.fl -F ./dpi/jtag.fl
ABI = -mabi=ilp32 -march=rv32imc
DEMODIR = ${PWD}
BUILD_DIR = ${DEMODIR}/build
TEST = sim
LINK = $(DEMODIR)/link.ld
# CFLAGS for verilator generated Makefiles. Without -std=c++11 it complains for `auto` variables
CFLAGS += "-std=c++11"
# Optimization for better performance; alternative is nothing for slower runtime (faster compiles)
# -O2 for faster runtime (slower compiles), or -O for balance.
VERILATOR_MAKE_FLAGS = OPT_FAST="-Os"
# Targets
all: clean verilator
clean:
rm -rf build obj_dir
##################### Verilog Builds #####################################
verilator-build:
verilator --cc -CFLAGS ${CFLAGS} \
-Wno-UNOPTFLAT \
-Wno-STMTDLY \
-Wno-MULTIDRIVEN \
-Wno-CASEINCOMPLETE \
-Wno-COMBDLY \
-Wno-LATCH \
-Wno-WIDTH \
-Wno-IMPLICIT \
${FILELIST} \
soc_sim.v \
--trace \
--top-module soc_sim -exe test_soc_sim.cpp --autoflush
cp ${DEMODIR}/test_soc_sim.cpp obj_dir
$(MAKE) -j -C obj_dir/ -f Vsoc_sim.mk $(VERILATOR_MAKE_FLAGS)
##################### Simulation Runs #####################################
verilator: program.hex verilator-build
cd build && ../obj_dir/Vsoc_sim
##################### Test hex Build #####################################
program.hex: $(TEST).o $(LINK)
@echo Building $(TEST)
$(GCC_PREFIX)-gcc $(ABI) -Wl,-Map=$(BUILD_DIR)/$(TEST).map -lgcc -T$(LINK) -o $(BUILD_DIR)/$(TEST).bin $(BUILD_DIR)/$(TEST).o -nostartfiles $(TEST_LIBS)
$(GCC_PREFIX)-objcopy -O verilog $(BUILD_DIR)/$(TEST).bin $(BUILD_DIR)/program.hex
$(GCC_PREFIX)-objdump -S $(BUILD_DIR)/$(TEST).bin > $(BUILD_DIR)/$(TEST).dis
@echo Completed building $(TEST)
%.o : %.s
@mkdir -p build
$(GCC_PREFIX)-cpp -g -I${BUILD_DIR} $< > $(BUILD_DIR)/$*.cpp.s
$(GCC_PREFIX)-as -g $(ABI) $(BUILD_DIR)/$*.cpp.s -o $(BUILD_DIR)/$@
##################### openocd #####################################
openocd:
openocd -f riscv.cfg
2022-02-24 11:18:07 +08:00
# openocd -f riscv.cfg -d3
2022-02-22 14:44:45 +08:00
gdb:
2022-02-25 20:24:03 +08:00
# $(GDB_PREFIX) -x gdbinit ./build/$(TEST).bin
$(GDB_PREFIX) -x gdbinit ./work/debug.elf
2022-02-22 14:44:45 +08:00
help:
@echo Possible targets: verilator help clean all verilator-build program.hex
.PHONY: help clean verilator