Created
April 9, 2020 03:14
-
-
Save PyroAVR/ffe6a67784a783f3b6184afdef34e2d1 to your computer and use it in GitHub Desktop.
GHDL makefile with xilinx ip support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setup variables | |
src := src | |
out := build | |
test := test | |
ip := lab_uart.srcs/sources_1/ip | |
std := 93 | |
search_dirs := ../unisim_ghdl/xilinx-vivado/unisim/v93 ../unisim_ghdl/xilinx-vivado/secureip/v93 | |
# source lists | |
main_sources := math uart_rx uart_tx axi_tx axi_rx baudgen uart | |
ip_sources := axis_data_fifo | |
test_sources := uart_tb axi_tb | |
# macros | |
obj_out = $(out)/$(1).o | |
#convenience functions | |
source = $(foreach x,$(1),$(call obj_out,$(x))) | |
ghdl_search = $(foreach x,$(1),-P$(x)) | |
# ghdl functions | |
analyze := ghdl -a --std=$(std) --workdir=$(out) | |
import := ghdl -i --std=$(std) --workdir=$(out) | |
elaborate := ghdl -e --std=$(std) --workdir=$(out) | |
# run testbench | |
.PHONY: test | |
test: uarttb axitb | |
#./build/axi_tb --vcd=axi.vcd --expect-failure | |
./build/uart_tb --vcd=uart.vcd --expect-failure | |
# actual targets | |
rxtb: init $(call source,$(main_sources)) $(call source,$(test_sources)) $(call source,$(ip_sources)) | |
$(analyze) $(call ghdl_search,$(search_dirs)) $(test)/rx_tb.vhd | |
$(elaborate) $(call ghdl_search,$(search_dirs)) -o $(out)/rx_tb rx_tb | |
uarttb: init $(call source,$(main_sources)) $(call source,$(test_sources)) $(call source,$(ip_sources)) | |
$(analyze) $(call ghdl_search,$(search_dirs)) $(test)/uart_tb.vhd | |
ghdl -e $(call ghdl_search,$(search_dirs)) -fexplicit --workdir=build -o $(out)/uart_tb uart_tb | |
axitb: init $(call source,$(main_sources)) $(call source,$(test_sources)) $(call source,$(ip_sources)) | |
$(analyze) $(call ghdl_search,$(search_dirs)) $(test)/axi_tb.vhd | |
$(elaborate) $(call ghdl_search,$(search_dirs)) -o $(out)/axi_tb axi_tb | |
# formulae | |
.PHONY: init clean | |
init: | |
-@mkdir $(out) | |
clean: | |
rm -Rf $(out)/* | |
$(out)/%.o: $(src)/%.vhd | |
$(analyze) $(call ghdl_search,$(search_dirs)) $< | |
#$(import) $< | |
$(out)/%.o: $(test)/%.vhd | |
$(analyze) $(call ghdl_search,$(search_dirs)) $< | |
#$(import) $< | |
$(out)/%.o: $(ip)/% | |
$(analyze) $(call ghdl_search,$(search_dirs)) -fexplicit -frelaxed-rules $</$(basename $(notdir $<))_sim_netlist.vhdl | |
#$(out)/%: %_tb.vhd | |
#$(elaborate) -o $(out)/$< $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment