]> rtime.felk.cvut.cz Git - fpga/virtex2/msp_motion.git/blob - build/Makefile
HDL Makefile added
[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 #  - synthesize : Synthesize all VHDL and Verilog source files, libraries, etc.
26 #                 defined in PRJ files and produces NGC file.
27 #  - translate  : Translate all netlist files (.ngc, ...) into the NGD file,
28 #                 where the design is described in terms of deneral logic elements
29 #                 such as (RAM, flip-flop, XOR, ...).
30 #  - map        : Map the general logic from NGD file to the components in the
31 #                 target FPGA and produces NCD_MAP file.
32 #  - par        : PAR stands for Plase & Route. This procedure takes NCD_MAP file,
33 #                 places all components and makes routes between them (depending
34 #                 on the chosen optimization mode) and produces NCD file.
35 #  - implement  : Transfer placed and routed NCD file into the bit file, which can
36 #                 be then used to configure particular FPGA. When ELF and BMM is
37 #                 specified, this procedure fills in location constraints of all
38 #                 memories in BMM and initialize them with data from ELF.
39 #  - download   : Download bitfile to the target FPGA (by using Impact).
40 #  - clean      : Clean build directory, dependency (*.d) files and call
41 #                 'make clean' in the directory of ELF file.
42 #  - all        : Do 'clean' and 'implement' targets.
43
44 # Dependicies are handled, so in most cases only 'download' target is called.
45
46
47 TOP             = msp_motion
48 DEVICE          = xc2v1000-fg456
49
50 PRJ             = $(TOP).prj
51 UCF             = $(TOP).ucf
52
53 ARCH            = msp430
54 BOARD           = virtex2
55 APP             = 
56
57 BMM             = memory.bmm
58 SW_SRC          = software/$(ARCH)-$(BOARD)-$(APP)
59 ELF             = $(SW_SRC)/_compiled/bin/$(APP)
60
61 SEARCH_DIRS     = 
62
63 JTAG_POS        = 2
64 INTSTYLE        = xflow
65
66 SRC             = ..
67
68 #===============================================================================
69 # Abbreviations of frequently used file names.
70
71 ifneq ($(strip $(APP)),)
72   BITFILE = $(TOP)_elf.bit
73 else
74   BITFILE = $(TOP).bit
75 endif
76
77 BMM_LOCAL       = $(notdir $(BMM))
78 BMM_LOCAL_BD    = $(basename $(BMM_LOCAL))_bd$(suffix $(BMM))
79
80 NGC             = $(TOP).ngc
81 NGD             = $(TOP).ngd
82 PCF             = $(TOP).pcf
83 NCD_MAP         = $(TOP)_map.ncd
84 NCD             = $(TOP).ncd
85
86 #===============================================================================
87
88 .PHONY: all synthesize translate map par implement download download-only clean
89 .PHONY: re-synthesize re-translate re-map re-par
90
91 implement: $(BITFILE)
92
93 all: clean implement
94
95 #===============================================================================
96
97 synthesize: $(NGC)
98 re-synthesize $(NGC): $(addrefix $(SRC)/,$(PRJ))
99         echo " \
100           run \
101           $(addprefix -ifn $(SRC)/,$(PRJ)) \
102           -ifmt mixed \
103           -ofn $(TOP).ngc \
104           -ofmt NGC \
105           -top $(TOP) \
106           -p $(DEVICE) \
107           -opt_mode Speed \
108           -opt_level 1" | xst
109
110
111 translate: $(NGD)
112 re-translate $(NGD): $(NGC) $(SRC)/$(BMM) $(SRC)/$(UCF)
113 ifneq ($(strip $(BMM)),)
114         ln -s -f $(SRC)/$(BMM) $(BMM_LOCAL)
115 endif
116         ngdbuild -intstyle $(INTSTYLE) -p $(DEVICE) -uc $(SRC)/$(UCF) \
117           $(addprefix -bm ,$(BMM_LOCAL)) \
118           $(addprefix -sd $(SRC)/,$(SEARCH_DIRS)) \
119           $(NGC) \
120           $(NGD)
121
122 map: $(NCD_MAP) $(PCF)
123 re-map $(NCD_MAP) $(PCF): $(NGD)
124         map -intstyle $(INTSTYLE) -o $(NCD_MAP) $(NGD) $(PCF)
125
126 par: $(NCD)
127 re-par $(NCD): $(NCD_MAP) $(PCF)
128         par -intstyle $(INTSTYLE) $(NCD_MAP) -w $(NCD) $(PCF)
129
130 $(TOP).bit $(BMM_LOCAL_BD): $(NCD)
131         bitgen -w $(NCD) $(TOP).bit $(PCF)
132
133 $(TOP)_elf.bit: $(TOP).bit $(BMM_LOCAL_BD) $(SRC)/$(ELF)
134         data2mem -bm $(BMM_LOCAL_BD) -bd $(SRC)/$(ELF) -bt $(TOP).bit -o b $(TOP)_elf.bit
135
136 .PHONY: $(SRC)/$(ELF)
137 $(SRC)/$(ELF):
138         make -C $(SRC)/$(SW_SRC)
139         ln -sf $(notdir $(ELF)) $(SRC)/$(ELF).elf
140
141 download: $(BITFILE) download-only
142 download-only:
143         /bin/echo -e "\
144         setMode -bscan \n\
145         cleancablelock \n\
146         setCable -port auto \n\
147         identify \n\
148         assignFile -p $(JTAG_POS) -file $(BITFILE) \n\
149         program -p $(JTAG_POS) \n\
150         exit" | impact -batch
151
152 #===============================================================================
153
154 clean:
155         ls | grep -v ^Makefile$$ | xargs rm -rf
156         rm -f $(addprefix $(SRC)/,$(PRJ:.prj=.d))
157         make -C $(SRC)/$(SW_SRC) distclean
158
159 #===============================================================================
160
161 %.d: %.prj
162         @sed -e 's/#.*//' \
163              -e 's/[ \t][ \t]*/ /g' \
164              -e 's/^ //' -e 's/ $$//' \
165              -e '/"/d' \
166              -e '/^$$/d' \
167              -e 's|\(.*\) \(.*\) \(.*\)|$<: $(dir $<)\3|' \
168              <$< >$@
169
170 %.prj:
171         touch $@
172
173 include $(addprefix $(SRC)/,$(PRJ:.prj=.d))
174