# Project config
PROJ=xmas-snoopy

PROJ_DEPS :=  no2ice40 no2misc no2usb
PROJ_RTL_SRCS := $(addprefix rtl/, \
	led_ctrl.v \
	picorv32_ice40_regs.v \
	picorv32.v \
	pmu.v \
	soc_bram.v \
	soc_picorv32_base.v \
	soc_picorv32_bridge.v \
	soc_spram.v \
	soc_usb_buf_bridge.v \
	sysmgr_1.v \
	xclk_cnt.v \
	xclk_pulse.v \
)

PROJ_SIM_SRCS := $(addprefix sim/, \
	spiflash.v \
	sysmgr_sim.v \
)
PROJ_SIM_SRCS += rtl/top.v

PROJ_TESTBENCHES=\
	led_ctrl_tb \
	top_tb \
	$(NULL)
PROJ_PREREQ = \
	$(BUILD_TMP)/boot.hex \
	$(NULL)
PROJ_TOP_SRC := rtl/top.v
PROJ_TOP_MOD := top

# Target config
BOARD ?= xmas-snoopy
DEVICE := up5k
PACKAGE := sg48

# Toolchain options
YOSYS_SYNTH_ARGS := -dsp -dffe_min_ce_use 4
NEXTPNR_SEED ?= 1
NEXTPNR_ARGS := --no-promote-globals --seed $(NEXTPNR_SEED) --pre-pack data/clocks.py
ICEPACK_ARGS :=

# Include default rules
NO2BUILD_DIR ?= build
include $(NO2BUILD_DIR)/project-rules.mk

# Custom rules
fw_boot_build:

../firmware/boot/boot.hex: fw_boot_build
	make -C ../firmware/boot boot.hex

$(BUILD_TMP)/boot.hex: ../firmware/boot/boot.hex
	cp $< $@

.PHONY: fw_boot_build
