aboutsummaryrefslogtreecommitdiffstats
path: root/fpga/usrp3/top/b2xxmini/Makefile
blob: 247e0b314ea2d4fa0bad0fe440d4715199e8237c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#
# Copyright 2015 Ettus Research LLC
#

# NOTE: All comments prefixed with a "##" will be displayed as a part of the "make help" target
##-------------------
##USRP B2XXXmini FPGA Help
##-------------------
##Usage:
## make <Targets> <Options>
##
##Output:
## build/usrp_<product>_fpga.bit:    Configuration bitstream with header
## build/usrp_<product>_fpga.bin:    Configuration bitstream without header
## build/usrp_<product>_fpga.syr:    Xilinx synthesis report
## build/usrp_<product>_fpga.twr:    Xilinx timing report
## build/usrp_<product>_fpga.rpt:    Utilization and timing summary report

export_report = \
	echo "========================================================================" > $(2); \
	cat $(1)/b205.syr | grep "Device utilization summary:" -A 31 >> $(2); \
	echo "========================================================================" >> $(2); \
	echo "Timing Summary:\n" >> $(2); \
	cat $(1)/b205.twr | grep constraint | grep met | grep -v "*" >> $(2); \
	echo "========================================================================" >> $(2);

# pre_build($1=Device)
ifeq ($(EXPORT_ONLY),1)
	pre_build = @test -s build-$(1)/b205.bit || { echo "EXPORT_ONLY requires the project in build-$(1) to be fully built."; false; }
else
	pre_build = @echo "ISE Version: $(shell xtclsh -h | head -n1)"
endif

# ise_build($1=Device, $2=Definitions)
ifeq ($(PROJECT_ONLY),1)
	ise_build = make -f Makefile.b205.inc proj NAME=$@ DEVICE=$1
else ifeq ($(EXPORT_ONLY),1)
	ise_build = @echo "Skipping ISE build and exporting pre-built files.";
else
	ise_build = make -f Makefile.b205.inc bin NAME=$@ DEVICE=$1
endif

# post_build($1=Device)
ifeq ($(PROJECT_ONLY),1)
	post_build = \
		@echo "Generated $(shell pwd)/build-$(1)/b205.xise"; \
		echo "\nProject Generation DONE ... $(1)\n";
else
	post_build = \
		@$(call export_report,build-$(1),build-$(1)/b205.rpt) \
		cat build-$(1)/b205.rpt; \
		mkdir -p build; \
		echo "Exporting bitstream files..."; \
		cp build-$(1)/b205.bin build/usrp_`echo $(1) | tr A-Z a-z`_fpga.bin; \
		cp build-$(1)/b205.bit build/usrp_`echo $(1) | tr A-Z a-z`_fpga.bit; \
		echo "Exporting logs..."; \
		cp build-$(1)/b205.syr build/usrp_`echo $(1) | tr A-Z a-z`_fpga.syr; \
		cp build-$(1)/b205.twr build/usrp_`echo $(1) | tr A-Z a-z`_fpga.twr; \
		cp build-$(1)/b205.rpt build/usrp_`echo $(1) | tr A-Z a-z`_fpga.rpt; \
		echo "\nBuild DONE ... $(1)\n";
endif

##
##Supported Targets
##-----------------

all:      B200mini B205mini  ##(Default target)

B200mini: ##Build USRP B200mini design.
	$(call pre_build,B200mini)
	$(call ise_build,XC6SLX75)
	$(call post_build,B200mini)

B205mini: ##Build USRP B205mini design.
	$(call pre_build,B205mini)
	$(call ise_build,XC6SLX150)
	$(call post_build,B205mini)

clean:    ##Clean up all build output.
	rm -rf build-*
	rm -rf build

help:    ## Show this help message.
	@grep -h "##" Makefile | grep -v "\"##\"" | sed -e 's/\\$$//' | sed -e 's/##//'

##
##Supported Options
##-----------------
##PROJECT_ONLY=1   Only create a Xilinx project for the specified target(s).
##                 Useful for use with the ISE GUI.
##EXPORT_ONLY=1    Export build targets from a GUI build to the build directory.
##                 Requires the project in build-*_* to be built.

.PHONY: all clean help B200mini B205mini