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