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
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}: ${SRC}/${PRJ}
90 ${addprefix -ifn ${SRC}/,${PRJ}} \
102 re-translate ${NGD}: ${NGC} ${SRC}/${BMM} ${SRC}/${UCF}
103 ifneq (${strip ${BMM}},)
104 ln -s -f ${SRC}/${BMM} ${BMM_LOCAL}
106 ngdbuild -intstyle ${INTSTYLE} -p ${DEVICE} -uc ${SRC}/${UCF} \
107 ${addprefix -bm ,${BMM_LOCAL}} \
108 ${addprefix -sd ${SRC}/,${SEARCH_DIRS}} \
112 map: ${NCD_MAP} ${PCF}
113 re-map ${NCD_MAP} ${PCF}: ${NGD}
114 map -intstyle ${INTSTYLE} -o ${NCD_MAP} ${NGD} ${PCF}
117 re-par ${NCD}: ${NCD_MAP} ${PCF}
118 par -intstyle ${INTSTYLE} ${NCD_MAP} ${NCD} ${PCF}
120 ${TOP}.bit ${BMM_LOCAL_BD}: ${NCD}
121 bitgen -w ${NCD} ${TOP}.bit ${PCF}
123 ${TOP}_elf.bit: ${TOP}.bit ${BMM_LOCAL_BD} ${SRC}/${ELF}
124 data2mem -bm ${BMM_LOCAL_BD} -bd ${SRC}/${ELF} -bt ${TOP}.bit -o b ${TOP}_elf.bit
126 .PHONY: ${SRC}/${ELF}
130 download: ${BITFILE} download-only
135 setCable -port auto \n\
137 assignFile -p ${JTAG_POS} -file ${BITFILE} \n\
138 program -p ${JTAG_POS} \n\
139 exit" | impact -batch
141 #===============================================================================
144 ls | grep -v ^Makefile$$ | xargs rm -rf
145 rm -f ${addprefix ${SRC}/,${PRJ:.prj=.d}}
146 make -C ${SRC}/${dir ${ELF}} clean
148 #===============================================================================
152 -e 's/[ \t][ \t]*/ /g' \
153 -e 's/^ //' -e 's/ $$//' \
156 -e 's|\(.*\) \(.*\) \(.*\)|$<: ${dir $<}\3|' \
162 include ${addprefix ${SRC}/,${PRJ:.prj=.d}}