OpenCores
URL https://opencores.org/ocsvn/System09/System09/trunk

Subversion Repositories System09

[/] [System09/] [trunk/] [mkfiles/] [xilinx_rules.mk] - Blame information for rev 182

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 59 davidgb
#-----------------------------------------------------------------
2
# File:    xilinx_rules.mk
3
# Author:  David Burnette
4
# Date:    April 7, 2008
5
#
6
# Description:
7
#
8
# Usage:
9
#  This make file fragment contains translate rules for synthesizing
10
#  Xilinx designs.
11
#
12
# This work was based on the Xilinx Makefile by Dave Vanden Bout
13
# from XESS Corp. Several major differences exist between his
14
# implementation and mine. This Makefile does not require PERL
15
# (though it does require AWK).
16
#
17
# Dependencies:
18
#  Depends on 'def_rules.mk' fragment.
19
#
20
# Revision History:
21
#   dgb 2008-04-07   Original version
22
#
23
#-----------------------------------------------------------------
24
 
25
 
26
include $(MKFRAGS)/def_rules.mk
27
 
28 70 davidgb
# Determine Xilinx ISE location
29
ifeq "$(XILINX)" ""
30
  $(error The XILINX environment variable must be set to use this makefile)
31
endif
32
XILINX_NORMAL := $(subst \,/,$(XILINX))
33
 
34 127 davidgb
MY_OS := $(shell /bin/uname -s)
35 70 davidgb
ifeq "$(findstring CYGWIN_NT,$(MY_OS))" "CYGWIN_NT"
36
  ifeq "$(findstring WOW64,$(MY_OS))" "WOW64"
37
    XILINX_PLAT = nt64
38
  else
39
    XILINX_PLAT = nt
40
  endif
41
else
42
  ifeq "$(MY_OS)" "Linux"
43
    XILINX_PLAT = lin
44
  else
45
    $(error Could not determine OS type for locating XILINX applications)
46
  endif
47
endif
48
 
49 71 davidgb
# Determine XILINX ISE version
50
XILINX_FILESET := $(XILINX_NORMAL)/fileset.txt
51
XILINX_VER := $(shell $(AWK) 'BEGIN { FS = "=" } /version/ { printf("%s",$$2) }'  $(XILINX_FILESET))
52
XILINX_MAJOR_VER := $(basename $(XILINX_VER))
53 70 davidgb
 
54 59 davidgb
# Xilinx tools
55 70 davidgb
XST        := $(XILINX_NORMAL)/bin/$(XILINX_PLAT)/xst
56
NGDBUILD   := $(XILINX_NORMAL)/bin/$(XILINX_PLAT)/ngdbuild
57
MAP        := $(XILINX_NORMAL)/bin/$(XILINX_PLAT)/map
58
PAR        := $(XILINX_NORMAL)/bin/$(XILINX_PLAT)/par
59
BITGEN     := $(XILINX_NORMAL)/bin/$(XILINX_PLAT)/bitgen
60
PROMGEN    := $(XILINX_NORMAL)/bin/$(XILINX_PLAT)/promgen
61
TRCE       := $(XILINX_NORMAL)/bin/$(XILINX_PLAT)/trce
62
IMPACT     := $(XILINX_NORMAL)/bin/$(XILINX_PLAT)/impact
63 59 davidgb
 
64
# Extract info from Xilinx ISE project for use with command line tools
65
XST_FILE := $(DESIGN_NAME).xst
66 147 davidgb
PRJ_FILE := $(shell $(AWK) '/^-ifn/ { printf("%s",$$2) }'  $(XST_FILE) | tr -d "\r")
67 59 davidgb
HDL_FILES := $(subst ",,$(shell $(AWK) '{ print $$3} ' $(PRJ_FILE)))
68 147 davidgb
PART := $(shell $(AWK) '/^-p / { printf("%s",$$2) }' $(XST_FILE) | tr -d "\r")
69 59 davidgb
DEVICE_tmp := $(shell $(AWK) -F - '/^-p / { printf("%s",$$2) }' $(XST_FILE))
70
DEVICE := $(subst p ,,$(DEVICE_tmp))
71
SPEED := $(shell $(AWK) -F - '/^-p / { printf("%s",$$3) }' $(XST_FILE))
72 147 davidgb
PACKAGE := $(shell $(AWK) -F - '/^-p / { printf("%s",$$4) }' $(XST_FILE) | tr -d "\r")
73 59 davidgb
BSD_FILE := $(XILINX)/$(FAMILY)/data/$(DEVICE).bsd
74
 
75 147 davidgb
XSTHDPDIR1 := $(shell $(AWK) '/^set -xsthdpdir / { printf("%s",$$3) }'  $(XST_FILE) | tr -d "\r")
76 59 davidgb
XSTHDPDIR := $(subst ",,$(XSTHDPDIR1))
77 147 davidgb
TMPDIR1 := $(shell $(AWK) '/^set -tmpdir / { printf("%s",$$3) }'  $(XST_FILE) | tr -d "\r")
78 59 davidgb
TMPDIR := $(subst ",,$(TMPDIR1))
79
 
80
INTSTYLE         ?= -intstyle silent      # call Xilinx tools in silent mode
81
INTSTYLE :=
82
XST_FLAGS        ?= $(INTSTYLE)           # most synthesis flags are specified in the .xst file
83
NGDBUILD_FLAGS   ?= $(INTSTYLE) -dd _ngo  # ngdbuild flags
84
NGDBUILD_FLAGS += $(if $(UCF_FILE),-uc,) $(UCF_FILE)
85 124 davidgb
 
86
# Brute force determination of need for -k 4 option
87
ifeq "$(XILINX_MAJOR_VER)" "7"
88
K4_OPT := -k 4
89 71 davidgb
endif
90 124 davidgb
ifeq "$(XILINX_MAJOR_VER)" "8"
91
K4_OPT := -k 4
92
endif
93
ifeq "$(XILINX_MAJOR_VER)" "9"
94
K4_OPT := -k 4
95
endif
96
ifeq "$(XILINX_MAJOR_VER)" "10"
97
K4_OPT := -k 4
98
endif
99 151 davidgb
ifeq "$(FAMILY)" "spartan6"
100
MAP_FLAGS        ?= $(INTSTYLE) $(COVER_MODE) -pr b $(K4_OPT) -c 100 -t 1
101
PAR_FLAGS        ?= $(INTSTYLE) -w -ol std
102
else
103 124 davidgb
MAP_FLAGS        ?= $(INTSTYLE) -cm area -pr b $(K4_OPT) -c 100 -tx off
104 59 davidgb
PAR_FLAGS        ?= $(INTSTYLE) -w -ol std -t 1
105 151 davidgb
endif
106
 
107 59 davidgb
TRCE_FLAGS       ?= $(INTSTYLE) -e 3 -l 3
108
BITGEN_FLAGS     ?= $(INTSTYLE)           # most bitgen flags are specified in the .ut file
109
PROMGEN_FLAGS    ?= -u 0                  # flags that control the MCS/EXO file generation
110
 
111
BITGEN_OPTIONS_FILE   ?= $(DESIGN_NAME).ut
112
 
113
#===================================================================
114
# Debug variable settings
115
debug_vars:
116
        @$(ECHO) "XST_FILE    = '$(XST_FILE)'"
117
        @$(ECHO) "PRJ_FILE    = '$(PRJ_FILE)'"
118
        @$(ECHO) "HDL_FILES   = '$(HDL_FILES)'"
119
        @$(ECHO) "PART        = '$(PART)'"
120
        @$(ECHO) "DEVICE      = '$(DEVICE)'"
121
        @$(ECHO) "SPEED       = '$(SPEED)'"
122
        @$(ECHO) "PACKAGE     = '$(PACKAGE)'"
123
        @$(ECHO) "UCF_FILE    = '$(UCF_FILE)'"
124
        @$(ECHO) "BSD_FILE    = '$(BSD_FILE)'"
125
        @$(ECHO) "XSTHDPDIR   = '$(XSTHDPDIR)'"
126
        @$(ECHO) "TMPDIR      = '$(TMPDIR)'"
127
 
128
#===================================================================
129
# Make sure tmpdirs are created
130
xst_tmp_dirs:
131 164 davidgb
        @$(MKDIR) -p $(XSTHDPDIR)
132
        @$(MKDIR) -p $(TMPDIR)
133 59 davidgb
        touch $@
134
 
135
#===================================================================
136
# Define dependencies
137
 
138
$(DESIGN_NAME).ngc: $(XST_FILE) $(PRJ_FILE) xst_tmp_dirs $(HDL_FILES) $(DESIGN_NAME).lso
139
 
140
$(DESIGN_NAME).ngd: $(DESIGN_NAME).ngc $(UCF_FILE)
141
 
142
$(DESIGN_NAME).bit: $(DESIGN_NAME).ncd $(BITGEN_OPTIONS_FILE)
143
 
144
$(DESIGN_NAME).mcs: $(DESIGN_NAME).bit
145
 
146
#===================================================================
147
# Rule to make impact cmd file
148
 
149
$(DESIGN_NAME)_impact.cmd:
150
        @$(ECHO)
151
        @$(ECHO) "======= Generating Impact command file ============"
152
        -@$(RM) $(DESIGN_NAME)_impact.cmd
153
        @$(ECHO) "setMode -ss" >>$@
154
        @$(ECHO) "setMode -sm" >>$@
155
        @$(ECHO) "setMode -hw140" >>$@
156
        @$(ECHO) "setMode -spi" >>$@
157
        @$(ECHO) "setMode -acecf" >>$@
158
        @$(ECHO) "setMode -acempm" >>$@
159
        @$(ECHO) "setMode -pff" >>$@
160
        @$(ECHO) "setMode -bs" >>$@
161
        @$(ECHO) "setMode -bscan" >>$@
162
        @$(ECHO) "setCable -p auto" >>$@
163
        @$(ECHO) "addDevice -p 1 -file $(BSD_FILE)" >>$@
164
        @$(ECHO) "Identify" >>$@
165
        @$(ECHO) "identifyMPM" >>$@
166
        @$(ECHO) "assignFile -p 1 -file $(DESIGN_NAME).bit" >>$@
167
        @$(ECHO) "program -p 1" >>$@
168
        @$(ECHO) "quit" >>$@
169
        @$(CAT) $@
170
 
171
.PHONY: do_impact
172 155 davidgb
do_impact: $(DESIGN_NAME).bit $(DESIGN_NAME)_impact.cmd
173 59 davidgb
        @$(ECHO)
174 164 davidgb
        @$(ECHO) "======= Downloading bitstream using Impact ============"
175 59 davidgb
        $(IMPACT) -batch $(DESIGN_NAME)_impact.cmd
176
 
177
#===================================================================
178
# TRANSLATE RULES
179
 
180
#   RULE: .xst => .ngc
181
# Synthesize the HDL files into an NGC file.  This rule is triggered if
182
# any of the HDL files are changed or the synthesis options are changed.
183
%.ngc: %.xst
184
        @$(ECHO)
185
        @$(ECHO) "======= Synthesis - XST ============================"
186
        $(XST) $(XST_FLAGS) -ifn $(XST_FILE) -ofn $(DESIGN_NAME).syr
187
 
188
#   RULE: .ngc => .ngd
189
# Take the output of the synthesizer and create the NGD file.  This rule
190
# will also be triggered if constraints file is changed.
191
%.ngd: %.ngc
192
        @$(ECHO)
193
        @$(ECHO) "======= Synthesis - NGDBUILD ======================="
194
        $(NGDBUILD) $(NGDBUILD_FLAGS) -p $(PART) $*.ngc $*.ngd
195
 
196
#   RULE: .ngd => _map.ncd and .pcf
197
# Map the NGD file and physical-constraints to the FPGA to create the mapped NCD file.
198
%_map.ncd %.pcf: %.ngd
199
        @$(ECHO)
200
        @$(ECHO) "======= Synthesis - MAP ============================"
201
        $(MAP) $(MAP_FLAGS) -p $(PART) -o $*_map.ncd $*.ngd $*.pcf
202
 
203
#   RULE: _map.ncd and .pcf => .ncd
204
# Place & route the mapped NCD file to create the final NCD file.
205
%.ncd: %_map.ncd %.pcf
206
        @$(ECHO)
207
        @$(ECHO) "======= Synthesis - PAR ============================"
208
        $(PAR) $(PAR_FLAGS) $*_map.ncd $*.ncd $*.pcf
209
 
210
#   RULE: .ncd => .bit
211
# Take the final NCD file and create an FPGA bitstream file.  This rule will also be
212
# triggered if the bit generation options file is changed.
213
%.bit: %.ncd $(BITGEN_OPTIONS_FILE)
214
        @$(ECHO)
215
        @$(ECHO) "======= Generating bitstream ======================="
216
        $(BITGEN) $(BITGEN_FLAGS) -f $(BITGEN_OPTIONS_FILE) $*.ncd
217
 
218
#   RULE: .bit => .mcs
219
# Convert a bitstream file into an MCS hex file that can be stored into Flash memory.
220
%.mcs: %.bit
221
        @$(ECHO)
222
        @$(ECHO) "======= Generating MCS prom ========================"
223
        $(PROMGEN) $(PROMGEN_FLAGS) $*.bit -p mcs -w
224
 
225
#   RULE: .bit => .exo
226
# Convert a bitstream file into an EXO hex file that can be stored into Flash memory.
227
%.exo: %.bit
228
        @$(ECHO)
229
        @$(ECHO) "======= Generating EXO prom ========================"
230
        $(PROMGEN) $(PROMGEN_FLAGS) $*.bit -p exo
231
 
232
# Create the FPGA timing report after place & route.
233
%.twr: %.ncd %.pcf
234
        @$(ECHO)
235
        @$(ECHO) "======= Generating Timing Report ==================="
236
        $(TRCE) $(TRCE_FLAGS) $*.ncd -o $*.twr $*.pcf
237
 
238
# Preserve intermediate files.
239
.PRECIOUS: %.ngc %.ngd %_map.ncd %.ncd %.twr %.vm6 %.jed
240
 
241
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.