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

Subversion Repositories System09

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

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
# Xilinx tools
29
XST        := xst
30
NGDBUILD   := ngdbuild
31
MAP        := map
32
PAR        := par
33
BITGEN     := bitgen
34
PROMGEN    := promgen
35
TRCE       := trce
36
IMPACT     := impact
37
 
38
# Extract info from Xilinx ISE project for use with command line tools
39
XST_FILE := $(DESIGN_NAME).xst
40
PRJ_FILE := $(shell $(AWK) '/^-ifn/ { printf("%s",$$2) }'  $(XST_FILE))
41
HDL_FILES := $(subst ",,$(shell $(AWK) '{ print $$3} ' $(PRJ_FILE)))
42
PART := $(shell $(AWK) '/^-p / { printf("%s",$$2) }' $(XST_FILE))
43
DEVICE_tmp := $(shell $(AWK) -F - '/^-p / { printf("%s",$$2) }' $(XST_FILE))
44
DEVICE := $(subst p ,,$(DEVICE_tmp))
45
SPEED := $(shell $(AWK) -F - '/^-p / { printf("%s",$$3) }' $(XST_FILE))
46
PACKAGE := $(shell $(AWK) -F - '/^-p / { printf("%s",$$4) }' $(XST_FILE))
47
BSD_FILE := $(XILINX)/$(FAMILY)/data/$(DEVICE).bsd
48
 
49
XSTHDPDIR1 := $(shell $(AWK) '/^set -xsthdpdir / { printf("%s",$$3) }'  $(XST_FILE))
50
XSTHDPDIR := $(subst ",,$(XSTHDPDIR1))
51
TMPDIR1 := $(shell $(AWK) '/^set -tmpdir / { printf("%s",$$3) }'  $(XST_FILE))
52
TMPDIR := $(subst ",,$(TMPDIR1))
53
 
54
INTSTYLE         ?= -intstyle silent      # call Xilinx tools in silent mode
55
INTSTYLE :=
56
XST_FLAGS        ?= $(INTSTYLE)           # most synthesis flags are specified in the .xst file
57
NGDBUILD_FLAGS   ?= $(INTSTYLE) -dd _ngo  # ngdbuild flags
58
NGDBUILD_FLAGS += $(if $(UCF_FILE),-uc,) $(UCF_FILE)
59
MAP_FLAGS        ?= $(INTSTYLE) -cm area -pr b -k 4 -c 100 -tx off
60
PAR_FLAGS        ?= $(INTSTYLE) -w -ol std -t 1
61
TRCE_FLAGS       ?= $(INTSTYLE) -e 3 -l 3
62
BITGEN_FLAGS     ?= $(INTSTYLE)           # most bitgen flags are specified in the .ut file
63
PROMGEN_FLAGS    ?= -u 0                  # flags that control the MCS/EXO file generation
64
 
65
BITGEN_OPTIONS_FILE   ?= $(DESIGN_NAME).ut
66
 
67
#===================================================================
68
# Debug variable settings
69
debug_vars:
70
        @$(ECHO) "XST_FILE    = '$(XST_FILE)'"
71
        @$(ECHO) "PRJ_FILE    = '$(PRJ_FILE)'"
72
        @$(ECHO) "HDL_FILES   = '$(HDL_FILES)'"
73
        @$(ECHO) "PART        = '$(PART)'"
74
        @$(ECHO) "DEVICE      = '$(DEVICE)'"
75
        @$(ECHO) "SPEED       = '$(SPEED)'"
76
        @$(ECHO) "PACKAGE     = '$(PACKAGE)'"
77
        @$(ECHO) "UCF_FILE    = '$(UCF_FILE)'"
78
        @$(ECHO) "BSD_FILE    = '$(BSD_FILE)'"
79
        @$(ECHO) "XSTHDPDIR   = '$(XSTHDPDIR)'"
80
        @$(ECHO) "TMPDIR      = '$(TMPDIR)'"
81
 
82
#===================================================================
83
# Make sure tmpdirs are created
84
xst_tmp_dirs:
85
        @$(MKDIR) $(XSTHDPDIR)
86
        @$(MKDIR) $(TMPDIR)
87
        touch $@
88
 
89
#===================================================================
90
# Define dependencies
91
 
92
$(DESIGN_NAME).ngc: $(XST_FILE) $(PRJ_FILE) xst_tmp_dirs $(HDL_FILES) $(DESIGN_NAME).lso
93
 
94
$(DESIGN_NAME).ngd: $(DESIGN_NAME).ngc $(UCF_FILE)
95
 
96
$(DESIGN_NAME).bit: $(DESIGN_NAME).ncd $(BITGEN_OPTIONS_FILE)
97
 
98
$(DESIGN_NAME).mcs: $(DESIGN_NAME).bit
99
 
100
#===================================================================
101
# Rule to make impact cmd file
102
 
103
$(DESIGN_NAME)_impact.cmd:
104
        @$(ECHO)
105
        @$(ECHO) "======= Generating Impact command file ============"
106
        -@$(RM) $(DESIGN_NAME)_impact.cmd
107
        @$(ECHO) "setMode -ss" >>$@
108
        @$(ECHO) "setMode -sm" >>$@
109
        @$(ECHO) "setMode -hw140" >>$@
110
        @$(ECHO) "setMode -spi" >>$@
111
        @$(ECHO) "setMode -acecf" >>$@
112
        @$(ECHO) "setMode -acempm" >>$@
113
        @$(ECHO) "setMode -pff" >>$@
114
        @$(ECHO) "setMode -bs" >>$@
115
        @$(ECHO) "deleteDevice -position 1" >>$@
116
        @$(ECHO) "deleteDevice -position 1" >>$@
117
        @$(ECHO) "setMode -bscan" >>$@
118
        @$(ECHO) "setCable -p auto" >>$@
119
        @$(ECHO) "addDevice -p 1 -file $(BSD_FILE)" >>$@
120
        @$(ECHO) "Identify" >>$@
121
        @$(ECHO) "identifyMPM" >>$@
122
        @$(ECHO) "assignFile -p 1 -file $(DESIGN_NAME).bit" >>$@
123
        @$(ECHO) "program -p 1" >>$@
124
        @$(ECHO) "quit" >>$@
125
        @$(CAT) $@
126
 
127
.PHONY: do_impact
128
do_impact: $(DESIGN_NAME).bit $(DESIGN_NAME).ngc $(DESIGN_NAME)_impact.cmd
129
        @$(ECHO)
130
        @$(ECHO) "======= Downloading bitstream to XSA-3S1000 using Impact ============"
131
        $(IMPACT) -batch $(DESIGN_NAME)_impact.cmd
132
 
133
#===================================================================
134
# TRANSLATE RULES
135
 
136
#   RULE: .xst => .ngc
137
# Synthesize the HDL files into an NGC file.  This rule is triggered if
138
# any of the HDL files are changed or the synthesis options are changed.
139
%.ngc: %.xst
140
        @$(ECHO)
141
        @$(ECHO) "======= Synthesis - XST ============================"
142
        $(XST) $(XST_FLAGS) -ifn $(XST_FILE) -ofn $(DESIGN_NAME).syr
143
 
144
#   RULE: .ngc => .ngd
145
# Take the output of the synthesizer and create the NGD file.  This rule
146
# will also be triggered if constraints file is changed.
147
%.ngd: %.ngc
148
        @$(ECHO)
149
        @$(ECHO) "======= Synthesis - NGDBUILD ======================="
150
        $(NGDBUILD) $(NGDBUILD_FLAGS) -p $(PART) $*.ngc $*.ngd
151
 
152
#   RULE: .ngd => _map.ncd and .pcf
153
# Map the NGD file and physical-constraints to the FPGA to create the mapped NCD file.
154
%_map.ncd %.pcf: %.ngd
155
        @$(ECHO)
156
        @$(ECHO) "======= Synthesis - MAP ============================"
157
        $(MAP) $(MAP_FLAGS) -p $(PART) -o $*_map.ncd $*.ngd $*.pcf
158
 
159
#   RULE: _map.ncd and .pcf => .ncd
160
# Place & route the mapped NCD file to create the final NCD file.
161
%.ncd: %_map.ncd %.pcf
162
        @$(ECHO)
163
        @$(ECHO) "======= Synthesis - PAR ============================"
164
        $(PAR) $(PAR_FLAGS) $*_map.ncd $*.ncd $*.pcf
165
 
166
#   RULE: .ncd => .bit
167
# Take the final NCD file and create an FPGA bitstream file.  This rule will also be
168
# triggered if the bit generation options file is changed.
169
%.bit: %.ncd $(BITGEN_OPTIONS_FILE)
170
        @$(ECHO)
171
        @$(ECHO) "======= Generating bitstream ======================="
172
        $(BITGEN) $(BITGEN_FLAGS) -f $(BITGEN_OPTIONS_FILE) $*.ncd
173
 
174
#   RULE: .bit => .mcs
175
# Convert a bitstream file into an MCS hex file that can be stored into Flash memory.
176
%.mcs: %.bit
177
        @$(ECHO)
178
        @$(ECHO) "======= Generating MCS prom ========================"
179
        $(PROMGEN) $(PROMGEN_FLAGS) $*.bit -p mcs -w
180
 
181
#   RULE: .bit => .exo
182
# Convert a bitstream file into an EXO hex file that can be stored into Flash memory.
183
%.exo: %.bit
184
        @$(ECHO)
185
        @$(ECHO) "======= Generating EXO prom ========================"
186
        $(PROMGEN) $(PROMGEN_FLAGS) $*.bit -p exo
187
 
188
# Create the FPGA timing report after place & route.
189
%.twr: %.ncd %.pcf
190
        @$(ECHO)
191
        @$(ECHO) "======= Generating Timing Report ==================="
192
        $(TRCE) $(TRCE_FLAGS) $*.ncd -o $*.twr $*.pcf
193
 
194
# Preserve intermediate files.
195
.PRECIOUS: %.ngc %.ngd %_map.ncd %.ncd %.twr %.vm6 %.jed
196
 
197
 

powered by: WebSVN 2.1.0

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