Browse Source

build: Define symbol matching the board config being built

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Sylvain Munaut 6 years ago
parent
commit
015dea82ef
1 changed files with 5 additions and 1 deletions
  1. 5 1
      build/project-rules.mk

+ 5 - 1
build/project-rules.mk

@@ -48,8 +48,12 @@ include $(BUILD_TMP)/proj-deps.mk
 PROJ_RTL_SRCS := $(abspath $(PROJ_RTL_SRCS))
 PROJ_TOP_SRC  := $(abspath $(PROJ_TOP_SRC))
 
+# Board config
 PIN_DEF ?= $(abspath data/$(PROJ_TOP_MOD)-$(BOARD).pcf)
 
+BOARD_DEFINE=BOARD_$(shell echo $(BOARD) | tr a-z A-Z)
+YOSYS_READ_ARGS += -D$(BOARD_DEFINE)=1
+
 # Add those to the list
 PROJ_ALL_RTL_SRCS += $(PROJ_RTL_SRCS)
 PROJ_ALL_SIM_SRCS += $(PROJ_SIM_SRCS)
@@ -85,7 +89,7 @@ $(BUILD_TMP)/$(PROJ).pnr.rpt $(BUILD_TMP)/$(PROJ).asc: $(BUILD_TMP)/$(PROJ).json
 
 # Simulation
 $(BUILD_TMP)/%_tb: sim/%_tb.v $(ICE40_LIBS) $(PROJ_ALL_PREREQ) $(PROJ_ALL_RTL_SRCS) $(PROJ_ALL_SIM_SRCS)
-	iverilog -Wall -DSIM=1 -o $@ \
+	iverilog -Wall -DSIM=1 -D$(BOARD_DEFINE)=1 -o $@ \
 		$(PROJ_SYNTH_INCLUDES) $(PROJ_SIM_INCLUDES) \
 		$(addprefix -l, $(ICE40_LIBS) $(PROJ_ALL_RTL_SRCS) $(PROJ_ALL_SIM_SRCS)) \
 		$<