]> rtime.felk.cvut.cz Git - fpga/virtex2/plasma.git/blob - build/Makefile
401fe882a2cdaa08b93f6b6a62598dcc669e42c9
[fpga/virtex2/plasma.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             = top_plasma
42 DEVICE          = xc2v1000-fg456
43
44 PRJ             = ${TOP}.prj
45 UCF             = ${TOP}.ucf
46
47 BMM             = 
48 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_BD          = ${basename ${BMM}}_bd.bmm
67
68 NGC             = ${TOP}.ngc
69 NGD             = ${TOP}.ngd
70 PCF             = ${TOP}.pcf
71 NCD_MAP         = ${TOP}_map.ncd
72 NCD             = ${TOP}.ncd
73
74 #===============================================================================
75
76 .PHONY: all synthesize translate map par implement download download-only clean
77 .PHONY: re-synthesize re-translate re-map re-par
78
79 implement: ${BITFILE}
80
81 all: clean implement
82
83 #===============================================================================
84
85 synthesize: ${NGC}
86 re-synthesize ${NGC}: ${SRC}/${PRJ}
87         echo " \
88                 run \
89                 ${addprefix -ifn ${SRC}/,${PRJ}} \
90                 -ifmt mixed \
91                 -ofn ${TOP}.ngc \
92                 -ofmt NGC \
93                 -top ${TOP} \
94                 -p ${DEVICE} \
95                 -opt_mode Speed \
96                 -opt_level 1" \
97         | 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}
104 endif
105         ngdbuild -intstyle ${INTSTYLE} -p ${DEVICE} -uc ${SRC}/${UCF} \
106           ${addprefix -bm ,${BMM}} \
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} ${NCD} ${PCF}
118
119 ${TOP}.bit ${BMM_BD}: ${NCD}
120         bitgen -w ${NCD} ${TOP}.bit ${PCF}
121
122 ${TOP}_elf.bit: ${TOP}.bit ${BMM_BD} ${SRC}/${ELF}
123         data2mem -bm ${BMM_BD} -bd ${SRC}/${ELF} -bt ${TOP}.bit -o b ${TOP}_elf.bit
124
125 .PHONY: ${SRC}/${ELF}
126 ${SRC}/${ELF}:
127         make -C ${dir $@} ${nodir $@}
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