]> rtime.felk.cvut.cz Git - fpga/virtex2/blink.git/blob - Makefile
+ Top level design
[fpga/virtex2/blink.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             = openMSP430_fpga
16 DEVICE          = xc2v1000-fg456
17
18 PRJ                                                     = openMSP430_fpga.prj
19
20 BMM             = memory.bmm
21 ELF             = software/leds.elf
22
23 SEARCH_DIRS     = coregen
24
25 JTAG_POS        = 2
26 INTSTYLE        = xflow
27
28
29 ifneq (${strip ${BMM}},)
30         BITFILE = ${TOP}_rp.bit
31 else
32   BITFILE = ${TOP}.bit
33 endif
34
35 #===============================================================================
36
37 .PHONY: all synth ngdbuild map implement download clean
38
39 all: clean implement
40
41 implement: ${BITFILE}
42
43 #===============================================================================
44
45 synth ${TOP}.ngc: ${PRJ}
46         echo " \
47                 run \
48                 ${addprefix -ifn ,${PRJ}} \
49                 -ifmt mixed \
50                 -ofn ${TOP}.ngc \
51                 -ofmt NGC \
52                 -top ${TOP} \
53                 -p ${DEVICE} \
54                 -opt_mode Speed \
55                 -opt_level 1" \
56         | xst
57
58
59 ngdbuild ${TOP}.ngd: ${TOP}.ngc ${BMM} ${TOP}.ucf
60         ngdbuild \
61                 ${addprefix -bm ,${BMM}} \
62                 -intstyle ${INTSTYLE} \
63                 -p ${DEVICE} \
64                 -uc ${TOP}.ucf \
65                 ${addprefix -sd ,${SEARCH_DIRS}} \
66                 ${TOP}.ngc \
67                 ${TOP}.ngd
68
69
70 map ${TOP}.ncd: ${TOP}.ngd
71         map \
72                 -p ${DEVICE} \
73                 -intstyle ${INTSTYLE} \
74                 ${TOP}.ngd \
75                 ${TOP}.pcf
76         par \
77                 -w ${TOP}.ncd \
78                 -intstyle ${INTSTYLE} \
79                 ${TOP}.ncd \
80                 ${TOP}.pcf
81
82
83 ${TOP}.bit: ${TOP}.ncd
84         bitgen -w ${TOP}.ncd ${TOP}.bit ${TOP}.pcf
85
86 ${TOP}_rp.bit: ${TOP}.bit ${ELF}
87         data2mem -bm ${basename ${BMM}}_bd.bmm -bd ${ELF} -bt ${TOP}.bit -o b ${TOP}_rp.bit
88
89 download: ${BITFILE}
90         /bin/echo -e "\
91         setMode -bscan \n\
92         cleancablelock \n\
93         setCable -port auto \n\
94         identify \n\
95         assignFile -p ${JTAG_POS} -file ${BITFILE} \n\
96         program -p ${JTAG_POS} \n\
97         exit" | impact -batch
98
99 #===============================================================================
100
101 clean:
102         rm -f _impactbatch.log
103         rm -f ${basename ${BMM}}_bd.bmm
104         rm -f netlist.lst
105         rm -f ${TOP}.bgn
106         rm -f ${TOP}.bit
107         rm -f ${TOP}.bld
108         rm -f ${TOP}.d
109         rm -f ${TOP}.drc
110         rm -f ${TOP}.lso
111         rm -f ${TOP}.map
112         rm -f ${TOP}.mrp
113         rm -f ${TOP}.ncd
114         rm -f ${TOP}.ngc
115         rm -f ${TOP}.ngd
116         rm -f ${TOP}.ngm
117         rm -f ${TOP}.pad
118         rm -f ${TOP}_pad.csv
119         rm -f ${TOP}_pad.txt
120         rm -f ${TOP}.par
121         rm -f ${TOP}.pcf
122         rm -f ${TOP}_rp.bit
123         rm -f ${TOP}_summary.xml
124         rm -f ${TOP}.unroutes
125         rm -f ${TOP}_usage.xml
126         rm -f ${TOP}.xpi
127         rm -rf xst
128
129 #===============================================================================
130
131 %.d: %.prj
132         sed -e 's/#.*//' \
133                         -e 's/[ \t][ \t]*/ /g' \
134                         -e 's/^ //' -e 's/ $$//' \
135                         -e 's|\(.*\) \(.*\) \(.*\)|$<: \3|' \
136                         <$< >$@
137
138 %.prj:
139         touch $@
140
141 include ${PRJ:.prj=.d}
142