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

Subversion Repositories System09

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

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

powered by: WebSVN 2.1.0

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