1 # TOP - Name of the top-level module
2 # DEVICE - Name of the FPGA device (device-package-speed)
3 # PRJ - Name of .prj file with names of all source files. See XST manual.
4 # BMM - If design contains initialized memories, softcore MCU, etc., this
5 # file describes mapping of .elf file to these memories. Only one
6 # .bmm file can be used.
7 # ELF - File containing initialization data of memories described by
8 # previously defined .bmm file. Format can be .elf or .mem.
9 # When the file does not exist, make is called in ELF directory with
10 # ELF file name as a target.
11 # SEARCH_DIRS - Directories to search when searching for netlists (.ngc, ...).
12 # See NGDBUILD manual.
13 # JTAG_POS - Position of device in JTAG chain. Used when downloading bit stream.
14 # INTSTYLE - Style of screen output. (ise | xflow | silent)
15 # SRC - Path to the source directory. All other paths are relative to this.
18 # Targets desctiption:
19 # - synthesize : Synthesize all VHDL and Verilog source files, libraries, etc.
20 # defined in PRJ files and produces NGC file.
21 # - translate : Translate all netlist files (.ngc, ...) into the NGD file,
22 # where the design is described in terms of deneral logic elements
23 # such as (RAM, flip-flop, XOR, ...).
24 # - map : Map the general logic from NGD file to the components in the
25 # target FPGA and produces NCD_MAP file.
26 # - par : PAR stands for Plase & Route. This procedure takes NCD_MAP file,
27 # places all components and makes routes between them (depending
28 # on the chosen optimization mode) and produces NCD file.
29 # - implement : Transfer placed and routed NCD file into the bit file, which can
30 # be then used to configure particular FPGA. When ELF and BMM is
31 # specified, this procedure fills in location constraints of all
32 # memories in BMM and initialize them with data from ELF.
33 # - download : Download bitfile to the target FPGA (by using Impact).
34 # - clean : Clean build directory, dependency (*.d) files and call
35 # 'make clean' in the directory of ELF file.
36 # - all : Do 'clean' and 'implement' targets.
38 # Dependicies are handled, so in most cases only 'download' target is called.
42 DEVICE = xc2v1000-fg456
48 ELF = software/ta_uart.elf
57 #===============================================================================
58 # Abbreviations of frequently used file names.
60 ifneq ($(strip $(ELF)),)
61 BITFILE = $(TOP)_elf.bit
66 BMM_LOCAL = $(notdir $(BMM))
67 BMM_LOCAL_BD = $(basename $(BMM_LOCAL))_bd$(suffix $(BMM))
72 NCD_MAP = $(TOP)_map.ncd
75 #===============================================================================
77 .PHONY: all synthesize translate map par implement download download-only clean
78 .PHONY: re-synthesize re-translate re-map re-par
84 #===============================================================================
87 re-synthesize $(NGC): $(addrefix $(SRC)/,$(PRJ))
90 $(addprefix -ifn $(SRC)/,$(PRJ)) \
101 re-translate $(NGD): $(NGC) $(SRC)/$(BMM) $(SRC)/$(UCF)
102 ifneq ($(strip $(BMM)),)
103 ln -s -f $(SRC)/$(BMM) $(BMM_LOCAL)
105 ngdbuild -intstyle $(INTSTYLE) -p $(DEVICE) -uc $(SRC)/$(UCF) \
106 $(addprefix -bm ,$(BMM_LOCAL)) \
107 $(addprefix -sd $(SRC)/,$(SEARCH_DIRS)) \
111 map: $(NCD_MAP) $(PCF)
112 re-map $(NCD_MAP) $(PCF): $(NGD)
113 map -intstyle $(INTSTYLE) -o $(NCD_MAP) $(NGD) $(PCF)
116 re-par $(NCD): $(NCD_MAP) $(PCF)
117 par -intstyle $(INTSTYLE) $(NCD_MAP) -w $(NCD) $(PCF)
119 $(TOP).bit $(BMM_LOCAL_BD): $(NCD)
120 bitgen -w $(NCD) $(TOP).bit $(PCF)
122 $(TOP)_elf.bit: $(TOP).bit $(BMM_LOCAL_BD) $(SRC)/$(ELF)
123 data2mem -bm $(BMM_LOCAL_BD) -bd $(SRC)/$(ELF) -bt $(TOP).bit -o b $(TOP)_elf.bit
125 .PHONY: $(SRC)/$(ELF)
129 download: $(BITFILE) download-only
134 setCable -port auto \n\
136 assignFile -p $(JTAG_POS) -file $(BITFILE) \n\
137 program -p $(JTAG_POS) \n\
138 exit" | impact -batch
140 #===============================================================================
143 ls | grep -v ^Makefile$$ | xargs rm -rf
144 rm -f $(addprefix $(SRC)/,$(PRJ:.prj=.d))
145 make -C $(SRC)/$(dir $(ELF)) clean
147 #===============================================================================
151 -e 's/[ \t][ \t]*/ /g' \
152 -e 's/^ //' -e 's/ $$//' \
155 -e 's|\(.*\) \(.*\) \(.*\)|$<: $(dir $<)\3|' \
161 include $(addprefix $(SRC)/,$(PRJ:.prj=.d))