2024-01-01 05:29:52 +00:00
|
|
|
NVBOARD_HOME ?= $(abspath ../nvboard)
|
2023-12-23 11:41:15 +00:00
|
|
|
PREFIX ?= build
|
2023-12-23 09:29:41 +00:00
|
|
|
OBJDIR := $(PREFIX)/obj
|
2024-01-01 05:29:52 +00:00
|
|
|
|
|
|
|
VSRC := $(wildcard vsrc/*.v)
|
|
|
|
SRC_AUTO_BIND := $(abspath $(PREFIX)/auto_bind.cpp)
|
|
|
|
CPPSRCS := $(addprefix $(PWD)/,$(wildcard csrc/*.cpp))
|
|
|
|
NXDC_FILES = $(abspath constr/top.nxdc)
|
2023-12-23 12:12:41 +00:00
|
|
|
SUBMAKE := $(OBJDIR)/Vexample.mk
|
2024-01-01 05:29:52 +00:00
|
|
|
|
2023-12-23 12:10:23 +00:00
|
|
|
VERILATOR_FLAGS := --cc --exe
|
2024-01-01 05:29:52 +00:00
|
|
|
LDFLAGS += $(shell sdl2-config --libs) -lSDL2_image
|
2023-12-23 09:27:29 +00:00
|
|
|
|
2024-01-01 05:42:14 +00:00
|
|
|
all: sim
|
2023-12-23 09:27:29 +00:00
|
|
|
|
2024-01-01 05:29:52 +00:00
|
|
|
sim: VERILATOR_FLAGS += --trace
|
|
|
|
sim: $(VSRC) $(CPPSRCS) $(OBJDIR)/Vexample git_trace
|
2023-12-23 11:41:35 +00:00
|
|
|
@echo "Running" $(OBJDIR)/Vexample "..."
|
|
|
|
@echo "================================"
|
2023-12-23 12:12:41 +00:00
|
|
|
@$(OBJDIR)/Vexample
|
2023-12-23 10:28:18 +00:00
|
|
|
|
2023-12-23 12:20:35 +00:00
|
|
|
$(OBJDIR)/Vexample: $(SUBMAKE)
|
2023-12-23 12:20:56 +00:00
|
|
|
$(MAKE) -C $(OBJDIR) -f $(notdir $(SUBMAKE)) Vexample
|
2023-12-23 12:20:35 +00:00
|
|
|
|
2024-01-01 05:29:52 +00:00
|
|
|
$(SUBMAKE): $(VSRC) $(CPPSRCS) $(OBJDIR)
|
|
|
|
verilator $(VERILATOR_FLAGS) $(addprefix -CFLAGS , $(CXXFLAGS)) $(addprefix -LDFLAGS , $(LDFLAGS)) --Mdir $(abspath $(OBJDIR)) $(VSRC) $(CPPSRCS)
|
2023-12-23 09:27:29 +00:00
|
|
|
|
2023-12-23 12:17:34 +00:00
|
|
|
$(OBJDIR):
|
2023-12-23 09:33:03 +00:00
|
|
|
mkdir -p $(OBJDIR)
|
2023-12-23 09:27:29 +00:00
|
|
|
|
2024-01-01 05:29:52 +00:00
|
|
|
$(SRC_AUTO_BIND): $(NXDC_FILES) $(OBJDIR)
|
|
|
|
NVBOARD_HOME=$(NVBOARD_HOME) python3 $(NVBOARD_HOME)/scripts/auto_pin_bind.py $< $@
|
|
|
|
|
|
|
|
ifneq (,$(wildcard ../Makefile))
|
2023-12-23 09:27:29 +00:00
|
|
|
include ../Makefile
|
2024-01-01 05:42:14 +00:00
|
|
|
else
|
|
|
|
define git_commit # not in ICS subfolder, no tracing
|
2024-01-01 05:29:52 +00:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
git_trace:
|
|
|
|
$(call git_commit, "sim RTL")
|
|
|
|
|
2023-12-23 09:33:39 +00:00
|
|
|
|
2024-01-01 05:42:14 +00:00
|
|
|
.PHONY: clean nvboard
|
|
|
|
|
|
|
|
nvboard: OBJDIR := $(PREFIX)/nvobj
|
2024-01-01 05:43:44 +00:00
|
|
|
# TODO: fix this awkward way to find nvboard.a
|
2024-01-01 05:42:14 +00:00
|
|
|
nvboard: CPPSRCS := $(addprefix $(PWD)/,$(wildcard csrc_nvboard/*.cpp)) $(SRC_AUTO_BIND) $(NVBOARD_HOME)/build/nvboard.a
|
|
|
|
nvboard: CXXFLAGS += -I$(NVBOARD_HOME)/include $(shell sdl2-config --cflags) -g
|
|
|
|
nvboard: $(VSRC) $(CPPSRCS) $(OBJDIR)/Vexample
|
|
|
|
@NVBOARD_HOME=$(NVBOARD_HOME) $(OBJDIR)/Vexample
|
2023-12-23 09:33:39 +00:00
|
|
|
|
|
|
|
clean:
|
2024-01-01 05:29:52 +00:00
|
|
|
$(RM) -r $(PREFIX)
|