]> rtime.felk.cvut.cz Git - fpga/virtex2/msp_motion.git/blob - build/Makefile
Whole "make process" with use of ISE project
[fpga/virtex2/msp_motion.git] / build / Makefile
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.
9
10 # Makefile is interconnected with Ocera-makefile system by the following properties
11 # ARCH
12 # BOARD
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.
18
19
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' 
26 #                 and type 'help'.
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.
45
46 # Dependicies are handled, so in most cases only 'download' target is called.
47
48
49 TOP             = msp_motion
50
51 PRJ             = $(TOP).prj
52 UCF             = $(TOP).ucf
53
54 ARCH            = msp430
55 BOARD           = virtex2
56 APP             = motion
57
58 BMM             = memory.bmm
59 SW_SRC          = software/$(ARCH)-$(BOARD)-$(APP)
60 ELF             = $(SW_SRC)/_compiled/bin/$(APP)
61
62 JTAG_POS        = 2
63
64 SRC             = ..
65
66 #===============================================================================
67 # Abbreviations of frequently used file names.
68
69 ifneq ($(strip $(APP)),)
70   BITFILE = $(TOP)_elf.bit
71 else
72   BITFILE = $(TOP).bit
73 endif
74
75 BMM_LOCAL       = $(notdir $(BMM))
76 BMM_LOCAL_BD    = $(basename $(BMM_LOCAL))_bd$(suffix $(BMM))
77
78 ISE             = $(TOP).ise
79 NGC             = $(TOP).ngc
80 NGD             = $(TOP).ngd
81 PCF             = $(TOP).pcf
82 NCD_MAP         = $(TOP)_map.ncd
83 NCD             = $(TOP).ncd
84
85 SRCPRJ          = $(addprefix $(SRC),/$(PRJ))
86
87 #===============================================================================
88
89 .PHONY: all project synthesize implement bitfile download download-only clean
90 .PHONY: re-synthesize
91
92 all: implement
93
94 #===============================================================================
95
96 project: $(ISE)
97 $(ISE): $(SRCPRJ) config.tcl
98 ifneq ($(strip $(BMM)),)
99         ln -sf $(SRC)/$(BMM) $(BMM_LOCAL)
100 endif
101         rm -f *.ise* *.restore
102         xtclsh create.tcl $(ISE) $(SRCPRJ)
103         xtclsh config.tcl $(ISE)
104
105 synthesize: $(NGC)
106 re-synthesize $(NGC): $(ISE) $(SRC)/$(UCF) $(BMM_LOCAL)
107         xtclsh process.tcl $(ISE) "Synthesize - XST"
108         @touch $(NGC)
109
110 implement: $(NCD)
111 $(NCD): $(ISE) $(SRC)/$(UCF) $(BMM_LOCAL)
112         xtclsh process.tcl $(ISE) "Implement Design"
113         @touch $(NCD)
114
115 bitfile: $(BITFILE)
116 $(TOP).bit $(BMM_LOCAL_BD): $(NCD)
117         bitgen -ise $(ISE) $(INSTYLE) -w $(NCD) $(TOP).bit $(PCF)
118
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
121
122 .PHONY: $(SRC)/$(ELF)
123 $(SRC)/$(ELF):
124         make -C $(SRC)/$(SW_SRC)
125         ln -sf $(notdir $(ELF)) $(SRC)/$(ELF).elf
126
127 download: $(BITFILE) download-only
128 download-only:
129         /bin/echo -e "\
130         setMode -bscan \n\
131         cleancablelock \n\
132         setCable -port auto \n\
133         identify \n\
134         assignFile -p $(JTAG_POS) -file $(BITFILE) \n\
135         program -p $(JTAG_POS) \n\
136         exit" | impact -batch
137
138 #===============================================================================
139
140 clean:
141         ls | grep -v ^Makefile$$ | grep -v .tcl$$ | xargs rm -rf
142         rm -f $(SRCPRJ:.prj=.d)
143         make -C $(SRC)/$(SW_SRC) distclean
144
145 #===============================================================================
146
147 %.d: %.prj
148         @$(MAKEDEPEND)
149
150 -include $(SRCPRJ:.prj=.d)
151
152 #===============================================================================
153
154 MAKEDEPEND = sed \
155   -e 's/\#.*//' \
156   -e 's/[ \t][ \t]*/ /g' \
157   -e 's/^ //' -e 's/ $$//' \
158   -e '/"/d' \
159   -e '/^$$/d' \
160   -e 's|\(.*\) \(.*\) \(.*\)|$(NGC) $(NCD): $(dir $<)\3\n$(dir $<)\3:\n|' \
161   <$< >$@
162