Add detection of TOPLEVEL_LANG based on *_SOURCES if not specified
@@ -111,6 +111,17 @@ $(SIM_BUILD):
.PHONY: regression
regression: $(COCOTB_RESULTS_FILE)
+# Attempt to detect TOPLEVEL_LANG based on available sources if not set
+ifeq ($(TOPLEVEL_LANG),)
+
+ifneq ($(and $(VHDL_SOURCES),$(if $(VERILOG_SOURCES),,1),)
+ TOPLEVEL_LANG := vhdl
+else ifneq ($(and $(VERILOG_SOURCES),$(if $(VHDL_SOURCES),,1),)
+ TOPLEVEL_LANG := verilog
+endif
+
+endif
+
else
$(warning Including Makefile.inc from a user makefile is a no-op and deprecated. Remove the Makefile.inc inclusion from your makefile, and only leave the Makefile.sim include.)
endif # COCOTB_MAKEFILE_INC_INCLUDED
