diff options
| author | Alejandro Soto <alejandro@34project.org> | 2024-02-12 16:18:03 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2024-02-20 11:11:18 -0600 |
| commit | bf5cece51a20eb4773d196ec650fb3af574afa17 (patch) | |
| tree | 8abd33c815b38a3dee673ea345f106d4ddcae9ab /mk/cocotb.mk | |
| parent | 691a441bfeb90642840d2869cb04ec146e274a1e (diff) | |
mk: initial commit
This is a complete overhaul of the build system. This new
implementations upports many new features and is very extensible.
Diffstat (limited to 'mk/cocotb.mk')
| -rw-r--r-- | mk/cocotb.mk | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/mk/cocotb.mk b/mk/cocotb.mk new file mode 100644 index 0000000..ca95389 --- /dev/null +++ b/mk/cocotb.mk @@ -0,0 +1,44 @@ +targets += test + +target/test/prepare = $(prepare_verilator_target) + +cocotb_modules = $(call per_target,cocotb_modules) + +define target/test/setup + $(setup_verilator_target) + + $$(call target_var,cocotb_modules) := $$(strip $$(core_info/$$(rule_top)/cocotb_modules)) + + ifeq (,$$(cocotb_modules)) + $$(error core '$$(rule_top)' has no cocotb test modules) + endif + + $$(call target_var,vl_main) = $$(cocotb_share)/lib/verilator/verilator.cpp + $$(call target_var,vl_flags) += --vpi --public-flat-rw + $$(call target_var,vl_ldflags) += \ + -Wl,-rpath,$$(cocotb_libdir),-rpath,$$(dir $$(cocotb_libpython)) -L$$(cocotb_libdir) \ + -lcocotbvpi_verilator -lgpi -lcocotb -lgpilog -lcocotbutils $$(cocotb_libpython) +endef + +define target/test/rules + $(verilator_target_rules) + + cocotb_outs := $$(addprefix $$(obj)/,results.xml log.txt) + + .PHONY: $$(rule_top_path)/test + $$(rule_top_path)/test: $$(obj)/results.xml + + $$(cocotb_outs) &: $$(vtop_exe) | $$(obj) + $$(call run_no_err,COCOTB) cd $$(obj) && \ + LIBPYTHON_LOC=$$(cocotb_libpython) COCOTB_RESULTS_FILE=results.xml \ + PYTHONPATH="$$(subst $$(space),:,$$(strip $$(cocotb_pythonpath) $$$$PYTHONPATH))" \ + MODULE=$$(subst $$(space),$$(comma),$$(cocotb_modules)) \ + $$(src)/$$< >log.txt + + $(call target_entrypoint,$$(cocotb_outs)) +endef + +cocotb_pythonpath = \ + $(addprefix $(src)/, \ + $(foreach dep,$(dep_tree/$(rule_top)), \ + $(call core_paths,$(dep),cocotb_paths))) |
