]> rtime.felk.cvut.cz Git - fpga/virtex2/msp_motion.git/blob - build/Makefile
bf7d0f769fe03e14dbd5a89b8e7f76f3bc30cd6b
[fpga/virtex2/msp_motion.git] / build / Makefile
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, ...).
9 #                 See NGDBUILD manual.
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.
13
14 # Makefile is interconnected with Ocera-makefile system by the following properties
15 # ARCH
16 # BOARD
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.
22
23
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' 
30 #                 and type 'help'.
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.
49
50 # Dependicies are handled, so in most cases only 'download' target is called.
51
52
53 TOP             = msp_motion
54 DEVICE          = xc2v1000-fg456
55
56 PRJ             = $(TOP).prj
57 UCF             = $(TOP).ucf
58
59 ARCH            = msp430
60 BOARD           = virtex2
61 APP             = motion
62
63 BMM             = memory.bmm
64 SW_SRC          = software/$(ARCH)-$(BOARD)-$(APP)
65 ELF             = $(SW_SRC)/_compiled/bin/$(APP)
66
67 SEARCH_DIRS     = 
68
69 JTAG_POS        = 2
70 INTSTYLE        = xflow
71
72 SRC             = ..
73
74 #===============================================================================
75 # Abbreviations of frequently used file names.
76
77 ifneq ($(strip $(APP)),)
78   BITFILE = $(TOP)_elf.bit
79 else
80   BITFILE = $(TOP).bit
81 endif
82
83 BMM_LOCAL       = $(notdir $(BMM))
84 BMM_LOCAL_BD    = $(basename $(BMM_LOCAL))_bd$(suffix $(BMM))
85
86 ISE             = $(TOP).ise
87 NGC             = $(TOP).ngc
88 NGD             = $(TOP).ngd
89 PCF             = $(TOP).pcf
90 NCD_MAP         = $(TOP)_map.ncd
91 NCD             = $(TOP).ncd
92
93 SRCPRJ          = $(addprefix $(SRC),/$(PRJ))
94
95 #===============================================================================
96
97 .PHONY: all synthesize translate map par implement download download-only clean
98 .PHONY: re-synthesize re-translate re-map re-par
99
100 implement: $(BITFILE)
101
102 all: clean implement
103
104 #===============================================================================
105
106 project: $(ISE)
107 $(ISE): $(SRCPRJ) config.tcl
108 ifneq ($(strip $(BMM)),)
109         ln -sf $(SRC)/$(BMM) $(BMM_LOCAL)
110 endif
111         rm -f *.ise* *.restore
112         xtclsh create.tcl $(ISE) $(SRCPRJ)
113         xtclsh config.tcl $(ISE)
114
115
116 synthesize: $(NGC)
117 re-synthesize $(NGC): $(addprefix $(SRC)/,$(PRJ))
118         echo " \
119           run \
120           $(addprefix -ifn $(SRC)/,$(PRJ)) \
121           -ifmt mixed \
122           -ofn $(TOP).ngc \
123           -ofmt NGC \
124           -top $(TOP) \
125           -p $(DEVICE) \
126           -opt_mode Speed \
127           -keep_hierarchy soft \
128           -opt_level 1" | xst | tee xst.log
129
130
131 translate: $(NGD)
132 re-translate $(NGD): $(NGC) $(SRC)/$(BMM) $(SRC)/$(UCF)
133 ifneq ($(strip $(BMM)),)
134         ln -s -f $(SRC)/$(BMM) $(BMM_LOCAL)
135 endif
136         ngdbuild -intstyle $(INTSTYLE) -p $(DEVICE) -uc $(SRC)/$(UCF) \
137           $(addprefix -bm ,$(BMM_LOCAL)) \
138           $(addprefix -sd $(SRC)/,$(SEARCH_DIRS)) \
139           $(NGC) \
140           $(NGD)
141
142 map: $(NCD_MAP) $(PCF)
143 re-map $(NCD_MAP) $(PCF): $(NGD)
144         map -intstyle $(INTSTYLE) -o $(NCD_MAP) $(NGD) $(PCF)
145
146 par: $(NCD)
147 re-par $(NCD): $(NCD_MAP) $(PCF)
148         par -intstyle $(INTSTYLE) $(NCD_MAP) -w $(NCD) $(PCF)
149
150 $(TOP).bit $(BMM_LOCAL_BD): $(NCD)
151         bitgen -w $(NCD) $(TOP).bit $(PCF)
152
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
155
156 .PHONY: $(SRC)/$(ELF)
157 $(SRC)/$(ELF):
158         make -C $(SRC)/$(SW_SRC)
159         ln -sf $(notdir $(ELF)) $(SRC)/$(ELF).elf
160
161 download: $(BITFILE) download-only
162 download-only:
163         /bin/echo -e "\
164         setMode -bscan \n\
165         cleancablelock \n\
166         setCable -port auto \n\
167         identify \n\
168         assignFile -p $(JTAG_POS) -file $(BITFILE) \n\
169         program -p $(JTAG_POS) \n\
170         exit" | impact -batch
171
172 #===============================================================================
173
174 clean:
175         ls | grep -v ^Makefile$$ | grep -v .tcl$$ | xargs rm -rf
176         rm -f $(SRCPRJ:.prj=.d)
177         make -C $(SRC)/$(SW_SRC) distclean
178
179 #===============================================================================
180
181 %.d: %.prj
182         @$(MAKEDEPEND)
183
184 %.prj:
185         touch $@
186
187 -include $(addprefix $(SRC)/,$(PRJ:.prj=.d))
188
189 #===============================================================================
190
191 MAKEDEPEND = sed \
192   -e 's/\#.*//' \
193   -e 's/[ \t][ \t]*/ /g' \
194   -e 's/^ //' -e 's/ $$//' \
195   -e '/"/d' \
196   -e '/^$$/d' \
197   -e 's|\(.*\) \(.*\) \(.*\)|$<: $(dir $<)\3\n$(dir $<)\3:\n|' \
198   <$< >$@
199