]> rtime.felk.cvut.cz Git - fpga/spartan2/qcounter.git/blob - Makefile
Component instances replaced by entity instances.
[fpga/spartan2/qcounter.git] / 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 # SEARCH_DIRS   - Directories to search when searching for netlists (.ngc, ...).
10 #                 See NGDBUILD manual.
11 # JTAG_POS      - Position of device in JTAG chain. Used when downloading bit stream.
12 # INTSTYLE      - Style of screen output. (ise | xflow | silent)
13
14
15 TOP             = top_counter
16 DEVICE          = xc2s100-pq208
17
18 PRJ             = top_counter.prj
19
20 BMM             = 
21 ELF             = 
22
23 SEARCH_DIRS     = 
24
25 NGDBUILG_FLAGS  = -aul      # Allow Unmatched LOCs
26
27
28 JTAG_POS        = 2
29 INTSTYLE        = xflow
30
31 # NOTICE: Impact when using in batch mode won't download bitfile to the
32 # FPGA. Solution I found is to call 'program -p 1' at the end of the
33 # procedure. See 'download' target.
34
35 ifneq (${strip ${BMM}},)
36   BITFILE = ${TOP}_rp.bit
37 else
38   BITFILE = ${TOP}.bit
39 endif
40
41 #===============================================================================
42
43 .PHONY: all synth ngdbuild map implement download clean
44
45 all: clean implement
46
47 implement: ${BITFILE}
48
49 #===============================================================================
50
51 synth ${TOP}.ngc: ${PRJ}
52         echo " \
53                 run \
54                 ${addprefix -ifn ,${PRJ}} \
55                 -ifmt mixed \
56                 -ofn ${TOP}.ngc \
57                 -ofmt NGC \
58                 -top ${TOP} \
59                 -p ${DEVICE} \
60                 -opt_mode Speed \
61                 -opt_level 1" \
62         | xst
63
64
65 ngdbuild ${TOP}.ngd: ${TOP}.ngc ${BMM} ${TOP}.ucf
66         ngdbuild \
67                 ${addprefix -bm ,${BMM}} \
68                 -intstyle ${INTSTYLE} \
69                 -aul \
70                 -p ${DEVICE} \
71                 -uc ${TOP}.ucf \
72                 ${addprefix -sd ,${SEARCH_DIRS}} \
73                 ${TOP}.ngc \
74                 ${TOP}.ngd
75
76
77 map ${TOP}.ncd: ${TOP}.ngd
78         map \
79                 -p ${DEVICE} \
80                 -intstyle ${INTSTYLE} \
81                 ${TOP}.ngd \
82                 ${TOP}.pcf
83         par \
84                 -w ${TOP}.ncd \
85                 -intstyle ${INTSTYLE} \
86                 ${TOP}.ncd \
87                 ${TOP}.pcf
88
89
90 ${TOP}.bit: ${TOP}.ncd
91         bitgen -w ${TOP}.ncd ${TOP}.bit ${TOP}.pcf
92
93 ${TOP}_rp.bit: ${TOP}.bit ${ELF}
94         data2mem -bm ${basename ${BMM}}_bd.bmm -bd ${ELF} -bt ${TOP}.bit -o b ${TOP}_rp.bit
95
96 download: ${BITFILE}
97         /bin/echo -e "\
98         setMode -bscan \n\
99         cleancablelock \n\
100         setCable -port auto \n\
101         identify \n\
102         assignFile -p ${JTAG_POS} -file ${BITFILE} \n\
103         program -p ${JTAG_POS} \n\
104         program -p 1 \n\
105         exit" | impact -batch
106
107 #===============================================================================
108
109 clean:
110         rm -f _impactbatch.log
111         rm -f ${basename ${BMM}}_bd.bmm
112         rm -f netlist.lst
113         rm -f ${TOP}.bgn
114         rm -f ${TOP}.bit
115         rm -f ${TOP}.bld
116         rm -f ${TOP}.d
117         rm -f ${TOP}.drc
118         rm -f ${TOP}.lso
119         rm -f ${TOP}.map
120         rm -f ${TOP}.mrp
121         rm -f ${TOP}.ncd
122         rm -f ${TOP}.ngc
123         rm -f ${TOP}.ngd
124         rm -f ${TOP}.ngm
125         rm -f ${TOP}.pad
126         rm -f ${TOP}_pad.csv
127         rm -f ${TOP}_pad.txt
128         rm -f ${TOP}.par
129         rm -f ${TOP}.pcf
130         rm -f ${TOP}_rp.bit
131         rm -f ${TOP}_summary.xml
132         rm -f ${TOP}.unroutes
133         rm -f ${TOP}_usage.xml
134         rm -f ${TOP}.xpi
135         rm -rf xst
136
137 #===============================================================================
138
139 %.d: %.prj
140         sed -e 's/#.*//' \
141         -e 's/[ \t][ \t]*/ /g' \
142         -e 's/"//g' \
143         -e 's/^ //' -e 's/ $$//' \
144         -e 's|\(.*\) \(.*\) \(.*\)|$<: \3|' \
145         <$< >$@
146
147 %.prj:
148         touch $@
149
150 include ${PRJ:.prj=.d}
151