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 # UCF - Name of the user constraints file
5 # BMM - If design contains initialized memories, softcore MCU, etc., this
6 # file describes mapping of .elf file to these memories. Only one
7 # .bmm file can be used.
8 # SEARCH_DIRS - Directories to search when searching for netlists (.ngc, ...).
10 # JTAG_POS - Position of device in JTAG chain. Used when downloading bit stream.
11 # INTSTYLE - Style of screen output. (ise | xflow | silent)
12 # SRC - Path to the source directory. All other paths are relative to this.
14 # Makefile is interconnected with Ocera-makefile system by the following properties
17 # APP - application name
18 # SW_SRC - directory name within $(SRC) dir where OC-makefile is called.
19 # By default it's software/$(ARCH)-$(BOARD)-$(APP)
20 # ELF - File containing initialization data of memories described by
21 # previously defined .bmm file. Format can be .elf or .mem.
24 # Targets desctiption:
25 # - project : Creates ISE project file, which can be opened in ISE IDE. HDL
26 # source files are added according to the $PRJ variable content.
27 # Configuration of project is moved to the config.tcl script file.
28 # All parameters which can be configured in IDE are accessible
29 # from this TCL script file. For more information execute 'xtclsh'
31 # - synthesize : Synthesize all VHDL and Verilog source files, libraries, etc.
32 # defined in PRJ files and produces NGC file.
33 # - translate : Translate all netlist files (.ngc, ...) into the NGD file,
34 # where the design is described in terms of deneral logic elements
35 # such as (RAM, flip-flop, XOR, ...).
36 # - map : Map the general logic from NGD file to the components in the
37 # target FPGA and produces NCD_MAP file.
38 # - par : PAR stands for Plase & Route. This procedure takes NCD_MAP file,
39 # places all components and makes routes between them (depending
40 # on the chosen optimization mode) and produces NCD file.
41 # - implement : Transfer placed and routed NCD file into the bit file, which can
42 # be then used to configure particular FPGA. When ELF and BMM is
43 # specified, this procedure fills in location constraints of all
44 # memories in BMM and initialize them with data from ELF.
45 # - download : Download bitfile to the target FPGA (by using Impact).
46 # - clean : Clean build directory, dependency (*.d) files and call
47 # 'make clean' in the directory of ELF file.
48 # - all : Do 'clean' and 'implement' targets.
50 # Dependicies are handled, so in most cases only 'download' target is called.
54 DEVICE = xc2v1000-fg456
64 SW_SRC = software/$(ARCH)-$(BOARD)-$(APP)
65 ELF = $(SW_SRC)/_compiled/bin/$(APP)
74 #===============================================================================
75 # Abbreviations of frequently used file names.
77 ifneq ($(strip $(APP)),)
78 BITFILE = $(TOP)_elf.bit
83 BMM_LOCAL = $(notdir $(BMM))
84 BMM_LOCAL_BD = $(basename $(BMM_LOCAL))_bd$(suffix $(BMM))
90 NCD_MAP = $(TOP)_map.ncd
93 SRCPRJ = $(addprefix $(SRC),/$(PRJ))
95 #===============================================================================
97 .PHONY: all synthesize translate map par implement download download-only clean
98 .PHONY: re-synthesize re-translate re-map re-par
100 implement: $(BITFILE)
104 #===============================================================================
107 $(ISE): $(SRCPRJ) config.tcl
108 ifneq ($(strip $(BMM)),)
109 ln -sf $(SRC)/$(BMM) $(BMM_LOCAL)
111 rm -f *.ise* *.restore
112 xtclsh create.tcl $(ISE) $(SRCPRJ)
113 xtclsh config.tcl $(ISE)
117 re-synthesize $(NGC): $(addprefix $(SRC)/,$(PRJ))
120 $(addprefix -ifn $(SRC)/,$(PRJ)) \
127 -keep_hierarchy soft \
128 -opt_level 1" | xst | tee xst.log
132 re-translate $(NGD): $(NGC) $(SRC)/$(BMM) $(SRC)/$(UCF)
133 ifneq ($(strip $(BMM)),)
134 ln -s -f $(SRC)/$(BMM) $(BMM_LOCAL)
136 ngdbuild -intstyle $(INTSTYLE) -p $(DEVICE) -uc $(SRC)/$(UCF) \
137 $(addprefix -bm ,$(BMM_LOCAL)) \
138 $(addprefix -sd $(SRC)/,$(SEARCH_DIRS)) \
142 map: $(NCD_MAP) $(PCF)
143 re-map $(NCD_MAP) $(PCF): $(NGD)
144 map -intstyle $(INTSTYLE) -o $(NCD_MAP) $(NGD) $(PCF)
147 re-par $(NCD): $(NCD_MAP) $(PCF)
148 par -intstyle $(INTSTYLE) $(NCD_MAP) -w $(NCD) $(PCF)
150 $(TOP).bit $(BMM_LOCAL_BD): $(NCD)
151 bitgen -w $(NCD) $(TOP).bit $(PCF)
153 $(TOP)_elf.bit: $(TOP).bit $(BMM_LOCAL_BD) $(SRC)/$(ELF)
154 data2mem -bm $(BMM_LOCAL_BD) -bd $(SRC)/$(ELF) -bt $(TOP).bit -o b $(TOP)_elf.bit
156 .PHONY: $(SRC)/$(ELF)
158 make -C $(SRC)/$(SW_SRC)
159 ln -sf $(notdir $(ELF)) $(SRC)/$(ELF).elf
161 download: $(BITFILE) download-only
166 setCable -port auto \n\
168 assignFile -p $(JTAG_POS) -file $(BITFILE) \n\
169 program -p $(JTAG_POS) \n\
170 exit" | impact -batch
172 #===============================================================================
175 ls | grep -v ^Makefile$$ | grep -v .tcl$$ | xargs rm -rf
176 rm -f $(SRCPRJ:.prj=.d)
177 make -C $(SRC)/$(SW_SRC) distclean
179 #===============================================================================
187 -include $(addprefix $(SRC)/,$(PRJ:.prj=.d))
189 #===============================================================================
193 -e 's/[ \t][ \t]*/ /g' \
194 -e 's/^ //' -e 's/ $$//' \
197 -e 's|\(.*\) \(.*\) \(.*\)|$<: $(dir $<)\3\n$(dir $<)\3:\n|' \