1 # TOP - Name of the top-level module
2 # PRJ - Name of .prj file with names of all source files. See XST manual.
3 # UCF - Name of the user constraints file
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 # JTAG_POS - Position of device in JTAG chain. Used when downloading bit stream.
8 # SRC - Path to the source directory. All other paths are relative to this.
10 # Makefile is interconnected with Ocera-makefile system by the following properties
13 # APP - application name
14 # SW_SRC - directory name within $(SRC) dir where OC-makefile is called.
15 # By default it's software/$(ARCH)-$(BOARD)-$(APP)
16 # ELF - File containing initialization data of memories described by
17 # previously defined .bmm file. Format can be .elf or .mem.
20 # Targets desctiption:
21 # - project : Creates ISE project file, which can be opened in ISE IDE. HDL
22 # source files are added according to the $PRJ variable content.
23 # Configuration of project is moved to the config.tcl script file.
24 # All parameters which can be configured in IDE are accessible
25 # from this TCL script file. For more information execute 'xtclsh'
27 # - synthesize : Synthesize all VHDL and Verilog source files, libraries, etc.
28 # defined in PRJ files and produces NGC file.
29 # - implment : Translate all netlist files (.ngc, ...) into the NGD file,
30 # where the design is described in terms of deneral logic elements
31 # such as (RAM, flip-flop, XOR, ...).
32 # Map the general logic from NGD file to the components in the
33 # target FPGA and produces NCD_MAP file.
34 # PAR stands for Plase & Route. This procedure takes NCD_MAP file,
35 # places all components and makes routes between them (depending
36 # on the chosen optimization mode) and produces NCD file.
37 # - bitlife : Transfer placed and routed NCD file into the bit file, which can
38 # be then used to configure particular FPGA. When ELF and BMM is
39 # specified, this procedure fills in location constraints of all
40 # memories in BMM and initialize them with data from ELF.
41 # - download : Download bitfile to the target FPGA (by using Impact).
42 # - clean : Clean build directory, dependency (*.d) files and call
43 # 'make clean' in the directory of ELF file.
44 # - all : Do 'implement' target.
46 # Dependicies are handled, so in most cases only 'download' target is called.
59 SW_SRC = software/$(ARCH)-$(BOARD)-$(APP)
60 ELF = $(SW_SRC)/_compiled/bin/$(APP)
66 #===============================================================================
67 # Abbreviations of frequently used file names.
69 ifneq ($(strip $(APP)),)
70 BITFILE = $(TOP)_elf.bit
75 BMM_LOCAL = $(notdir $(BMM))
76 BMM_LOCAL_BD = $(basename $(BMM_LOCAL))_bd$(suffix $(BMM))
82 NCD_MAP = $(TOP)_map.ncd
85 SRCPRJ = $(addprefix $(SRC),/$(PRJ))
87 #===============================================================================
89 .PHONY: all project synthesize implement bitfile download download-only clean
94 #===============================================================================
97 $(ISE): $(SRCPRJ) config.tcl
98 ifneq ($(strip $(BMM)),)
99 ln -sf $(SRC)/$(BMM) $(BMM_LOCAL)
101 rm -f *.ise* *.restore
102 xtclsh create.tcl $(ISE) $(SRCPRJ)
103 xtclsh config.tcl $(ISE)
106 re-synthesize $(NGC): $(ISE) $(SRC)/$(UCF) $(BMM_LOCAL)
107 xtclsh process.tcl $(ISE) "Synthesize - XST"
111 $(NCD): $(ISE) $(SRC)/$(UCF) $(BMM_LOCAL)
112 xtclsh process.tcl $(ISE) "Implement Design"
116 $(TOP).bit $(BMM_LOCAL_BD): $(NCD)
117 bitgen -ise $(ISE) $(INSTYLE) -w $(NCD) $(TOP).bit $(PCF)
119 $(TOP)_elf.bit: $(TOP).bit $(BMM_LOCAL_BD) $(SRC)/$(ELF)
120 data2mem -bm $(BMM_LOCAL_BD) -bd $(SRC)/$(ELF) -bt $(TOP).bit -o b $(TOP)_elf.bit
122 .PHONY: $(SRC)/$(ELF)
124 make -C $(SRC)/$(SW_SRC)
125 ln -sf $(notdir $(ELF)) $(SRC)/$(ELF).elf
127 download: $(BITFILE) download-only
132 setCable -port auto \n\
134 assignFile -p $(JTAG_POS) -file $(BITFILE) \n\
135 program -p $(JTAG_POS) \n\
136 exit" | impact -batch
138 #===============================================================================
141 ls | grep -v ^Makefile$$ | grep -v .tcl$$ | xargs rm -rf
142 rm -f $(SRCPRJ:.prj=.d)
143 make -C $(SRC)/$(SW_SRC) distclean
145 #===============================================================================
150 -include $(SRCPRJ:.prj=.d)
152 #===============================================================================
156 -e 's/[ \t][ \t]*/ /g' \
157 -e 's/^ //' -e 's/ $$//' \
160 -e 's|\(.*\) \(.*\) \(.*\)|$(NGC) $(NCD): $(dir $<)\3\n$(dir $<)\3:\n|' \