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

Subversion Repositories System09

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

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
PRJ_FILE := $(shell $(AWK) '/^-ifn/ { printf("%s",$$2) }'  $(XST_FILE))
67
HDL_FILES := $(subst ",,$(shell $(AWK) '{ print $$3} ' $(PRJ_FILE)))
68
PART := $(shell $(AWK) '/^-p / { printf("%s",$$2) }' $(XST_FILE))
69
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
PACKAGE := $(shell $(AWK) -F - '/^-p / { printf("%s",$$4) }' $(XST_FILE))
73
BSD_FILE := $(XILINX)/$(FAMILY)/data/$(DEVICE).bsd
74
 
75
XSTHDPDIR1 := $(shell $(AWK) '/^set -xsthdpdir / { printf("%s",$$3) }'  $(XST_FILE))
76
XSTHDPDIR := $(subst ",,$(XSTHDPDIR1))
77
TMPDIR1 := $(shell $(AWK) '/^set -tmpdir / { printf("%s",$$3) }'  $(XST_FILE))
78
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
 
100
MAP_FLAGS        ?= $(INTSTYLE) -cm area -pr b $(K4_OPT) -c 100 -tx off
101 59 davidgb
PAR_FLAGS        ?= $(INTSTYLE) -w -ol std -t 1
102
TRCE_FLAGS       ?= $(INTSTYLE) -e 3 -l 3
103
BITGEN_FLAGS     ?= $(INTSTYLE)           # most bitgen flags are specified in the .ut file
104
PROMGEN_FLAGS    ?= -u 0                  # flags that control the MCS/EXO file generation
105
 
106
BITGEN_OPTIONS_FILE   ?= $(DESIGN_NAME).ut
107
 
108
#===================================================================
109
# Debug variable settings
110
debug_vars:
111
        @$(ECHO) "XST_FILE    = '$(XST_FILE)'"
112
        @$(ECHO) "PRJ_FILE    = '$(PRJ_FILE)'"
113
        @$(ECHO) "HDL_FILES   = '$(HDL_FILES)'"
114
        @$(ECHO) "PART        = '$(PART)'"
115
        @$(ECHO) "DEVICE      = '$(DEVICE)'"
116
        @$(ECHO) "SPEED       = '$(SPEED)'"
117
        @$(ECHO) "PACKAGE     = '$(PACKAGE)'"
118
        @$(ECHO) "UCF_FILE    = '$(UCF_FILE)'"
119
        @$(ECHO) "BSD_FILE    = '$(BSD_FILE)'"
120
        @$(ECHO) "XSTHDPDIR   = '$(XSTHDPDIR)'"
121
        @$(ECHO) "TMPDIR      = '$(TMPDIR)'"
122
 
123
#===================================================================
124
# Make sure tmpdirs are created
125
xst_tmp_dirs:
126
        @$(MKDIR) $(XSTHDPDIR)
127
        @$(MKDIR) $(TMPDIR)
128
        touch $@
129
 
130
#===================================================================
131
# Define dependencies
132
 
133
$(DESIGN_NAME).ngc: $(XST_FILE) $(PRJ_FILE) xst_tmp_dirs $(HDL_FILES) $(DESIGN_NAME).lso
134
 
135
$(DESIGN_NAME).ngd: $(DESIGN_NAME).ngc $(UCF_FILE)
136
 
137
$(DESIGN_NAME).bit: $(DESIGN_NAME).ncd $(BITGEN_OPTIONS_FILE)
138
 
139
$(DESIGN_NAME).mcs: $(DESIGN_NAME).bit
140
 
141
#===================================================================
142
# Rule to make impact cmd file
143
 
144
$(DESIGN_NAME)_impact.cmd:
145
        @$(ECHO)
146
        @$(ECHO) "======= Generating Impact command file ============"
147
        -@$(RM) $(DESIGN_NAME)_impact.cmd
148
        @$(ECHO) "setMode -ss" >>$@
149
        @$(ECHO) "setMode -sm" >>$@
150
        @$(ECHO) "setMode -hw140" >>$@
151
        @$(ECHO) "setMode -spi" >>$@
152
        @$(ECHO) "setMode -acecf" >>$@
153
        @$(ECHO) "setMode -acempm" >>$@
154
        @$(ECHO) "setMode -pff" >>$@
155
        @$(ECHO) "setMode -bs" >>$@
156
        @$(ECHO) "setMode -bscan" >>$@
157
        @$(ECHO) "setCable -p auto" >>$@
158
        @$(ECHO) "addDevice -p 1 -file $(BSD_FILE)" >>$@
159
        @$(ECHO) "Identify" >>$@
160
        @$(ECHO) "identifyMPM" >>$@
161
        @$(ECHO) "assignFile -p 1 -file $(DESIGN_NAME).bit" >>$@
162
        @$(ECHO) "program -p 1" >>$@
163
        @$(ECHO) "quit" >>$@
164
        @$(CAT) $@
165
 
166
.PHONY: do_impact
167
do_impact: $(DESIGN_NAME).bit $(DESIGN_NAME).ngc $(DESIGN_NAME)_impact.cmd
168
        @$(ECHO)
169
        @$(ECHO) "======= Downloading bitstream to XSA-3S1000 using Impact ============"
170
        $(IMPACT) -batch $(DESIGN_NAME)_impact.cmd
171
 
172
#===================================================================
173
# TRANSLATE RULES
174
 
175
#   RULE: .xst => .ngc
176
# Synthesize the HDL files into an NGC file.  This rule is triggered if
177
# any of the HDL files are changed or the synthesis options are changed.
178
%.ngc: %.xst
179
        @$(ECHO)
180
        @$(ECHO) "======= Synthesis - XST ============================"
181
        $(XST) $(XST_FLAGS) -ifn $(XST_FILE) -ofn $(DESIGN_NAME).syr
182
 
183
#   RULE: .ngc => .ngd
184
# Take the output of the synthesizer and create the NGD file.  This rule
185
# will also be triggered if constraints file is changed.
186
%.ngd: %.ngc
187
        @$(ECHO)
188
        @$(ECHO) "======= Synthesis - NGDBUILD ======================="
189
        $(NGDBUILD) $(NGDBUILD_FLAGS) -p $(PART) $*.ngc $*.ngd
190
 
191
#   RULE: .ngd => _map.ncd and .pcf
192
# Map the NGD file and physical-constraints to the FPGA to create the mapped NCD file.
193
%_map.ncd %.pcf: %.ngd
194
        @$(ECHO)
195
        @$(ECHO) "======= Synthesis - MAP ============================"
196
        $(MAP) $(MAP_FLAGS) -p $(PART) -o $*_map.ncd $*.ngd $*.pcf
197
 
198
#   RULE: _map.ncd and .pcf => .ncd
199
# Place & route the mapped NCD file to create the final NCD file.
200
%.ncd: %_map.ncd %.pcf
201
        @$(ECHO)
202
        @$(ECHO) "======= Synthesis - PAR ============================"
203
        $(PAR) $(PAR_FLAGS) $*_map.ncd $*.ncd $*.pcf
204
 
205
#   RULE: .ncd => .bit
206
# Take the final NCD file and create an FPGA bitstream file.  This rule will also be
207
# triggered if the bit generation options file is changed.
208
%.bit: %.ncd $(BITGEN_OPTIONS_FILE)
209
        @$(ECHO)
210
        @$(ECHO) "======= Generating bitstream ======================="
211
        $(BITGEN) $(BITGEN_FLAGS) -f $(BITGEN_OPTIONS_FILE) $*.ncd
212
 
213
#   RULE: .bit => .mcs
214
# Convert a bitstream file into an MCS hex file that can be stored into Flash memory.
215
%.mcs: %.bit
216
        @$(ECHO)
217
        @$(ECHO) "======= Generating MCS prom ========================"
218
        $(PROMGEN) $(PROMGEN_FLAGS) $*.bit -p mcs -w
219
 
220
#   RULE: .bit => .exo
221
# Convert a bitstream file into an EXO hex file that can be stored into Flash memory.
222
%.exo: %.bit
223
        @$(ECHO)
224
        @$(ECHO) "======= Generating EXO prom ========================"
225
        $(PROMGEN) $(PROMGEN_FLAGS) $*.bit -p exo
226
 
227
# Create the FPGA timing report after place & route.
228
%.twr: %.ncd %.pcf
229
        @$(ECHO)
230
        @$(ECHO) "======= Generating Timing Report ==================="
231
        $(TRCE) $(TRCE_FLAGS) $*.ncd -o $*.twr $*.pcf
232
 
233
# Preserve intermediate files.
234
.PRECIOUS: %.ngc %.ngd %_map.ncd %.ncd %.twr %.vm6 %.jed
235
 
236
 

powered by: WebSVN 2.1.0

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