]> rtime.felk.cvut.cz Git - fpga/virtex2/plasma.git/blob - build/Makefile
Add map of Plasma MIPS RAMs.
[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             = ram_xilinx.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_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}: ${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" \
98         | xst
99
100
101 translate: ${NGD}
102 re-translate ${NGD}: ${NGC} ${SRC}/${BMM} ${SRC}/${UCF}
103 ifneq (${strip ${BMM}},)
104         ln -s -f ${SRC}/${BMM} ${BMM_LOCAL}
105 endif
106         ngdbuild -intstyle ${INTSTYLE} -p ${DEVICE} -uc ${SRC}/${UCF} \
107           ${addprefix -bm ,${BMM_LOCAL}} \
108           ${addprefix -sd ${SRC}/,${SEARCH_DIRS}} \
109           ${NGC} \
110           ${NGD}
111
112 map: ${NCD_MAP} ${PCF}
113 re-map ${NCD_MAP} ${PCF}: ${NGD}
114         map -intstyle ${INTSTYLE} -o ${NCD_MAP} ${NGD} ${PCF}
115
116 par: ${NCD}
117 re-par ${NCD}: ${NCD_MAP} ${PCF}
118         par -intstyle ${INTSTYLE} ${NCD_MAP} ${NCD} ${PCF}
119
120 ${TOP}.bit ${BMM_LOCAL_BD}: ${NCD}
121         bitgen -w ${NCD} ${TOP}.bit ${PCF}
122
123 ${TOP}_elf.bit: ${TOP}.bit ${BMM_LOCAL_BD} ${SRC}/${ELF}
124         data2mem -bm ${BMM_LOCAL_BD} -bd ${SRC}/${ELF} -bt ${TOP}.bit -o b ${TOP}_elf.bit
125
126 .PHONY: ${SRC}/${ELF}
127 ${SRC}/${ELF}:
128         make -C ${@D} ${@F}
129
130 download: ${BITFILE} download-only
131 download-only:
132         /bin/echo -e "\
133         setMode -bscan \n\
134         cleancablelock \n\
135         setCable -port auto \n\
136         identify \n\
137         assignFile -p ${JTAG_POS} -file ${BITFILE} \n\
138         program -p ${JTAG_POS} \n\
139         exit" | impact -batch
140
141 #===============================================================================
142
143 clean:
144         ls | grep -v ^Makefile$$ | xargs rm -rf
145         rm -f ${addprefix ${SRC}/,${PRJ:.prj=.d}}
146         make -C ${SRC}/${dir ${ELF}} clean
147
148 #===============================================================================
149
150 %.d: %.prj
151         @sed -e 's/#.*//' \
152              -e 's/[ \t][ \t]*/ /g' \
153              -e 's/^ //' -e 's/ $$//' \
154              -e '/"/d' \
155              -e '/^$$/d' \
156              -e 's|\(.*\) \(.*\) \(.*\)|$<: ${dir $<}\3|' \
157              <$< >$@
158
159 %.prj:
160         touch $@
161
162 include ${addprefix ${SRC}/,${PRJ:.prj=.d}}
163