]> rtime.felk.cvut.cz Git - fpga/spartan2/qcounter.git/blobdiff - Makefile
Complete design added.
[fpga/spartan2/qcounter.git] / Makefile
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..947398a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,151 @@
+# TOP           - Name of the top-level module
+# DEVICE        - Name of the FPGA device (device-package-speed)
+# PRJ           - Name of .prj file with names of all source files. See XST manual.
+# BMM           - If design contains initialized memories, softcore MCU, etc., this
+#                 file describes mapping of .elf file to these memories. Only one
+#                 .bmm file can be used.
+# ELF           - File containing initialization data of memories described by
+#                 previously defined .bmm file. Format can be .elf or .mem.
+# SEARCH_DIRS   - Directories to search when searching for netlists (.ngc, ...).
+#                 See NGDBUILD manual.
+# JTAG_POS      - Position of device in JTAG chain. Used when downloading bit stream.
+# INTSTYLE      - Style of screen output. (ise | xflow | silent)
+
+
+TOP             = top_counter
+DEVICE          = xc2s100-pq208
+
+PRJ            = top_counter.prj
+
+BMM             = 
+ELF             = 
+
+SEARCH_DIRS     = 
+
+NGDBUILG_FLAGS  = -aul      # Allow Unmatched LOCs
+
+
+JTAG_POS        = 2
+INTSTYLE        = xflow
+
+# NOTICE: Impact when using in batch mode won't download bitfile to the
+# FPGA. Solution I found is to call 'program -p 1' at the end of the
+# procedure. See 'download' target.
+
+ifneq (${strip ${BMM}},)
+  BITFILE = ${TOP}_rp.bit
+else
+  BITFILE = ${TOP}.bit
+endif
+
+#===============================================================================
+
+.PHONY: all synth ngdbuild map implement download clean
+
+all: clean implement
+
+implement: ${BITFILE}
+
+#===============================================================================
+
+synth ${TOP}.ngc: ${PRJ}
+       echo " \
+               run \
+               ${addprefix -ifn ,${PRJ}} \
+               -ifmt mixed \
+               -ofn ${TOP}.ngc \
+               -ofmt NGC \
+               -top ${TOP} \
+               -p ${DEVICE} \
+               -opt_mode Speed \
+               -opt_level 1" \
+       | xst
+
+
+ngdbuild ${TOP}.ngd: ${TOP}.ngc ${BMM} ${TOP}.ucf
+       ngdbuild \
+               ${addprefix -bm ,${BMM}} \
+               -intstyle ${INTSTYLE} \
+               -aul \
+               -p ${DEVICE} \
+               -uc ${TOP}.ucf \
+               ${addprefix -sd ,${SEARCH_DIRS}} \
+               ${TOP}.ngc \
+               ${TOP}.ngd
+
+
+map ${TOP}.ncd: ${TOP}.ngd
+       map \
+               -p ${DEVICE} \
+               -intstyle ${INTSTYLE} \
+               ${TOP}.ngd \
+               ${TOP}.pcf
+       par \
+               -w ${TOP}.ncd \
+               -intstyle ${INTSTYLE} \
+               ${TOP}.ncd \
+               ${TOP}.pcf
+
+
+${TOP}.bit: ${TOP}.ncd
+       bitgen -w ${TOP}.ncd ${TOP}.bit ${TOP}.pcf
+
+${TOP}_rp.bit: ${TOP}.bit ${ELF}
+       data2mem -bm ${basename ${BMM}}_bd.bmm -bd ${ELF} -bt ${TOP}.bit -o b ${TOP}_rp.bit
+
+download: ${BITFILE}
+       /bin/echo -e "\
+       setMode -bscan \n\
+       cleancablelock \n\
+       setCable -port auto \n\
+       identify \n\
+       assignFile -p ${JTAG_POS} -file ${BITFILE} \n\
+       program -p ${JTAG_POS} \n\
+       program -p 1 \n\
+       exit" | impact -batch
+
+#===============================================================================
+
+clean:
+       rm -f _impactbatch.log
+       rm -f ${basename ${BMM}}_bd.bmm
+       rm -f netlist.lst
+       rm -f ${TOP}.bgn
+       rm -f ${TOP}.bit
+       rm -f ${TOP}.bld
+       rm -f ${TOP}.d
+       rm -f ${TOP}.drc
+       rm -f ${TOP}.lso
+       rm -f ${TOP}.map
+       rm -f ${TOP}.mrp
+       rm -f ${TOP}.ncd
+       rm -f ${TOP}.ngc
+       rm -f ${TOP}.ngd
+       rm -f ${TOP}.ngm
+       rm -f ${TOP}.pad
+       rm -f ${TOP}_pad.csv
+       rm -f ${TOP}_pad.txt
+       rm -f ${TOP}.par
+       rm -f ${TOP}.pcf
+       rm -f ${TOP}_rp.bit
+       rm -f ${TOP}_summary.xml
+       rm -f ${TOP}.unroutes
+       rm -f ${TOP}_usage.xml
+       rm -f ${TOP}.xpi
+       rm -rf xst
+
+#===============================================================================
+
+%.d: %.prj
+       sed -e 's/#.*//' \
+       -e 's/[ \t][ \t]*/ /g' \
+       -e 's/"//g' \
+       -e 's/^ //' -e 's/ $$//' \
+       -e 's|\(.*\) \(.*\) \(.*\)|$<: \3|' \
+       <$< >$@
+
+%.prj:
+       touch $@
+
+include ${PRJ:.prj=.d}
+