1 |
408 |
julius |
#
|
2 |
|
|
# Makefile for synthesis
|
3 |
|
|
#
|
4 |
|
|
# To generate the EDIF, just do "# make all"
|
5 |
|
|
#
|
6 |
|
|
# To synthesize for older ORSoC board with A3P1000, do:
|
7 |
|
|
# # make clean all FPGA_FAMILY=ProASIC3 FPGA_PART=A3P1000
|
8 |
|
|
#
|
9 |
|
|
# Note: correct pll model must be linked in backend path.
|
10 |
|
|
#
|
11 |
|
|
|
12 |
|
|
# Name of the directory we're currently in
|
13 |
|
|
CUR_DIR=$(shell pwd)
|
14 |
|
|
|
15 |
542 |
julius |
# The root path of the whole project
|
16 |
|
|
BOARD_ROOT ?=$(CUR_DIR)/../../..
|
17 |
|
|
# Makefile fragment with most of the setup
|
18 |
|
|
include $(BOARD_ROOT)/Makefile.inc
|
19 |
408 |
julius |
|
20 |
|
|
|
21 |
|
|
# Tool settings
|
22 |
|
|
# For Linux, the Actel licenses only support Synplify Pro
|
23 |
|
|
SYN_WORK_DIR ?=synplify_work
|
24 |
|
|
SYN_SCRIPT ?=synplify.prj # We will generate this
|
25 |
|
|
SYN_LOG ?=syn.log
|
26 |
|
|
SYN_TOOL ?=synplify_pro # Name of the executable to call
|
27 |
|
|
# Options passed after the executable.
|
28 |
439 |
julius |
SYN_LICENSE_OPTS ?=-licensetype synplifypro_actel
|
29 |
408 |
julius |
SYN_TOOL_OPTS ?=$(SYN_SCRIPT) $(SYN_LICENSE_OPTS) -batch -log $(SYN_LOG)
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
SYN_PROJ_NAME ?= $(DESIGN_NAME)
|
33 |
|
|
RTL_TOP ?= $(DESIGN_NAME)_top
|
34 |
|
|
EDIF_FILE ?=$(RTL_TOP).edn
|
35 |
|
|
EDIF_FILE_OUT ?= ../out/$(EDIF_FILE)
|
36 |
411 |
julius |
VLOG_NETLIST_FILE ?=$(RTL_TOP).vm
|
37 |
|
|
VLOG_NETLIST_FILE_OUT ?= ../out/$(VLOG_NETLIST_FILE)
|
38 |
408 |
julius |
# Synthesis params
|
39 |
|
|
#FREQ ?= 50.0000
|
40 |
|
|
FREQ ?= 125.000
|
41 |
|
|
FPGA_FAMILY ?=ProASIC3E
|
42 |
|
|
#FPGA_PART ?=A3P1000
|
43 |
|
|
FPGA_PART ?=A3PE1500
|
44 |
|
|
FPGA_PACKAGE ?=PQFP208
|
45 |
|
|
#FPGA_SPEED_GRADE ?=-2
|
46 |
|
|
FPGA_SPEED_GRADE ?=Std
|
47 |
|
|
MAXFAN ?=50
|
48 |
|
|
MAXFAN_HARD ?=0
|
49 |
|
|
RETIMING ?=1
|
50 |
|
|
GLOBALTHRESH ?=50
|
51 |
|
|
DISABLE_IO_INSERTION ?= 0
|
52 |
|
|
RESOURCE_SHARING ?=1
|
53 |
|
|
|
54 |
|
|
# Time reporting variable
|
55 |
|
|
NUM_PATHS=50
|
56 |
|
|
NUM_ENDPOINTS=50
|
57 |
|
|
|
58 |
|
|
SDC_FILE=$(DESIGN_NAME)_top.sdc
|
59 |
|
|
|
60 |
|
|
# Rule to print out current config of current session
|
61 |
|
|
print-config:
|
62 |
|
|
@echo; echo "\t### Synthesis make configuration ###"; echo
|
63 |
|
|
@echo "\tRTL_TOP="$(RTL_TOP)
|
64 |
|
|
@echo "\tFPGA_FAMILY="$(FPGA_FAMILY)
|
65 |
|
|
@echo "\tFPGA_PART="$(FPGA_PART)
|
66 |
|
|
@echo "\tFPGA_PACKAGE="$(FPGA_PACKAGE)
|
67 |
|
|
@echo "\tFPGA_SPEED_GRADE="$(FPGA_SPEED_GRADE)
|
68 |
|
|
@echo "\tFREQ="$(FREQ)
|
69 |
|
|
@echo "\tMAXFAN="$(MAXFAN)
|
70 |
|
|
@echo "\tMAXFAN_HARD="$(MAXFAN_HARD)
|
71 |
|
|
@echo "\tRETIMING="$(RETIMING)
|
72 |
|
|
@echo "\tGLOBALTHRESH="$(GLOBALTHRESH)
|
73 |
|
|
@echo "\tDISABLE_IO_INSERTION="$(DISABLE_IO_INSERTION)
|
74 |
|
|
@echo "\tRESOURCE_SHARING="$(RESOURCE_SHARING)
|
75 |
|
|
@echo
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
411 |
julius |
all: print-config $(EDIF_FILE_OUT) $(VLOG_NETLIST_FILE_OUT)
|
80 |
408 |
julius |
|
81 |
|
|
#create the work dir
|
82 |
|
|
$(SYN_WORK_DIR):
|
83 |
|
|
mkdir $(SYN_WORK_DIR)
|
84 |
|
|
|
85 |
|
|
#
|
86 |
|
|
# Dynamically created files included by different parts of the defines
|
87 |
|
|
#
|
88 |
|
|
|
89 |
|
|
SYNDIR_BOOTROM_VERILOG=$(SYN_WORK_DIR)/$(BOOTROM_FILE)
|
90 |
|
|
$(SYNDIR_BOOTROM_VERILOG): $(BOOTROM_VERILOG)
|
91 |
|
|
cp $^ $@
|
92 |
|
|
|
93 |
|
|
TIMESCALE_FILE=timescale.v
|
94 |
|
|
SYNDIR_TIMESCALE_FILE=$(SYN_WORK_DIR)/$(TIMESCALE_FILE)
|
95 |
|
|
$(SYNDIR_TIMESCALE_FILE):
|
96 |
|
|
$(Q)echo "" > $@
|
97 |
|
|
|
98 |
|
|
SYN_VERILOG_DEFINES=synthesis-defines.v
|
99 |
|
|
SYNDIR_SYN_VERILOG_DEFINES=$(SYN_WORK_DIR)/$(SYN_VERILOG_DEFINES)
|
100 |
|
|
$(SYNDIR_SYN_VERILOG_DEFINES):
|
101 |
|
|
$(Q)echo "\`define SYNTHESIS" > $@
|
102 |
|
|
$(Q)echo "\`define ACTEL" >> $@
|
103 |
|
|
$(Q)echo "" >> $@
|
104 |
|
|
|
105 |
|
|
GENERATED_DEFINES = $(SYNDIR_BOOTROM_VERILOG)
|
106 |
|
|
GENERATED_DEFINES += $(SYNDIR_TIMESCALE_FILE)
|
107 |
|
|
GENERATED_DEFINES += $(SYNDIR_SYN_VERILOG_DEFINES)
|
108 |
|
|
|
109 |
|
|
# Generate the prj file
|
110 |
|
|
.PHONY: $(SYN_WORK_DIR)/$(SYN_SCRIPT)
|
111 |
|
|
$(SYN_WORK_DIR)/$(SYN_SCRIPT): $(SYN_WORK_DIR) $(RTL_VERILOG_SRC) $(RTL_VERILOG_INCLUDES) $(GENERATED_DEFINES) $(SYN_WORK_DIR)/$(SDC_FILE)
|
112 |
|
|
$(Q)echo; echo "\t### Generating Synplify project file ###"; echo
|
113 |
|
|
$(Q)echo -n "# Autogenerated synthesis script " > $@
|
114 |
|
|
$(Q)date >> $@
|
115 |
|
|
$(Q)for file in $(RTL_VERILOG_SRC); do \
|
116 |
|
|
echo "add_file -verilog "$$file >> $@; \
|
117 |
|
|
done
|
118 |
|
|
$(Q)for file in $(RTL_VHDL_SRC); do \
|
119 |
|
|
echo "add_file -vhdl "$$file >> $@; \
|
120 |
|
|
done
|
121 |
542 |
julius |
$(Q)for file in $(BOARD_BACKEND_VERILOG_SRC); do \
|
122 |
|
|
echo "add_file -verilog "$$file >> $@; \
|
123 |
|
|
done
|
124 |
408 |
julius |
$(Q)echo "add_file -constraint "$(SDC_FILE) >> $@
|
125 |
|
|
$(Q)echo "set_option -include_path "$(BOARD_RTL_VERILOG_INCLUDE_DIR) >> $@
|
126 |
|
|
$(Q)echo "set_option -include_path ." >> $@
|
127 |
|
|
$(Q)echo "impl -add "$(SYN_PROJ_NAME)" -type fpga" >> $@
|
128 |
|
|
$(Q)echo "set_option -technology "$(FPGA_FAMILY) >> $@
|
129 |
|
|
$(Q)echo "set_option -part "$(FPGA_PART) >> $@
|
130 |
|
|
$(Q)echo "set_option -package "$(FPGA_PACKAGE) >> $@
|
131 |
|
|
$(Q)echo "set_option -speed_grade "$(FPGA_SPEED_GRADE) >> $@
|
132 |
|
|
$(Q)echo "set_option -part_companion \"\"" >> $@
|
133 |
|
|
$(Q)echo "set_option -use_fsm_explorer 0" >> $@
|
134 |
|
|
$(Q)echo "set_option -top_module \""$(RTL_TOP)"\"" >> $@
|
135 |
|
|
$(Q)echo "set_option -symbolic_fsm_compiler 1" >> $@
|
136 |
|
|
$(Q)echo "set_option -compiler_compatible 0" >> $@
|
137 |
|
|
$(Q)echo "set_option -resource_sharing "$(RESOURCE_SHARING) >> $@
|
138 |
|
|
$(Q)echo "set_option -frequency "$(FREQ) >> $@
|
139 |
|
|
$(Q)echo "set_option -write_verilog 1" >> $@
|
140 |
|
|
$(Q)echo "set_option -write_vhdl 0" >> $@
|
141 |
|
|
$(Q)echo "set_option -run_prop_extract 1" >> $@
|
142 |
|
|
$(Q)echo "set_option -maxfan "$(MAXFAN) >> $@
|
143 |
|
|
$(Q)echo "set_option -maxfan_hard "$(MAXFAN_HARD) >> $@
|
144 |
|
|
$(Q)echo "set_option -disable_io_insertion "$(DISABLE_IO_INSERTION) >> $@
|
145 |
|
|
$(Q)echo "set_option -retiming "$(RETIMING) >> $@
|
146 |
|
|
$(Q)echo "set_option -report_path 4000" >> $@
|
147 |
|
|
$(Q)echo "set_option -opcond COMWC" >> $@
|
148 |
|
|
$(Q)echo "set_option -update_models_cp 0" >> $@
|
149 |
|
|
$(Q)echo "set_option -preserve_registers 0" >> $@
|
150 |
|
|
$(Q)echo "set_option -globalthreshold "$(GLOBALTHRESH) >> $@
|
151 |
|
|
$(Q)echo "set_option -syn_global_buffers 18" >> $@
|
152 |
|
|
$(Q)echo "set_option -reporting_filter {-from {*} -to {*}}" >> $@
|
153 |
|
|
$(Q)echo "set_option -reporting_filename "$(RTL_TOP)".ta" >> $@
|
154 |
|
|
$(Q)echo "set_option -reporting_output_srm 0" >> $@
|
155 |
|
|
$(Q)echo "set_option -write_apr_constraint 1" >> $@
|
156 |
|
|
$(Q)echo "project -result_format \"edif\"" >> $@
|
157 |
|
|
$(Q)echo "project -result_file \""$(EDIF_FILE)"\"" >> $@
|
158 |
|
|
$(Q)echo "set_option -vlog_std v2001" >> $@
|
159 |
|
|
$(Q)echo "set_option -num_startend_points "$(NUM_ENDPOINTS) >> $@
|
160 |
|
|
$(Q)echo "set_option -num_critical_paths "$(NUM_PATHS) >> $@
|
161 |
|
|
$(Q)echo "set_option -project_relative_includes 1" >> $@
|
162 |
|
|
$(Q)echo "impl -active \""$(SYN_PROJ_NAME)"\"" >> $@
|
163 |
|
|
|
164 |
|
|
#
|
165 |
|
|
# Constraint script generation
|
166 |
|
|
#
|
167 |
|
|
IN_CLK_PERIOD_NS = 15.625 # 64 MHz
|
168 |
|
|
WB_CLK_PERIOD_NS = 31.25 # 32 MHz
|
169 |
|
|
#
|
170 |
|
|
# Timing (SDC)
|
171 |
|
|
#
|
172 |
|
|
# I can't figure out how to get these constraints into synplify properly..
|
173 |
|
|
# but doesn't really appear to matter, we simply overconstrain the whole
|
174 |
|
|
# thing to fastest frequency we need, which is currently:
|
175 |
|
|
# SMII @ 125MHz
|
176 |
|
|
#
|
177 |
|
|
$(SYN_WORK_DIR)/$(SDC_FILE):
|
178 |
|
|
$(Q)echo; echo "\t### Generating SDC file ###"; echo
|
179 |
|
|
$(Q)rm -f $@
|
180 |
|
|
$(Q)echo >> $@
|
181 |
|
|
# $(Q)echo "create_clock -name { sys_clk } -period "$(IN_CLK_PERIOD_NS)" { p:sys_clk } " >> $@
|
182 |
|
|
# $(Q)echo "create_clock -name { tck_pad_i } -period 100.000 -waveform { 0.000 50.000 } { p:tck_pad_i } " >> $@
|
183 |
|
|
# $(Q)echo "create_generated_clock -name { clkgen0/pll0/Core:GLA } -divide_by 72 -multiply_by 36 -source { clkgen0/pll0/Core:CLKA } { clkgen0/pll0/Core:GLA }" >> $@
|
184 |
|
|
# $(Q)echo "create_generated_clock -name { clkgen0/pll0/Core:GLB } -divide_by 36 -multiply_by 36 -source { clkgen0/pll0/Core:CLKA } { clkgen0/pll0/Core:GLB } " >> $@
|
185 |
|
|
# $(Q)echo "create_generated_clock -name { clkgen0.pll0.wb_clk_i } -divide_by 72 -multiply_by 36 -source { t:clkgen0.pll0.wb_clk_i } { t:clkgen0.pll0.wb_clk_i }" >> $@
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
# change into work dir, call synplify, hopefully create the edif
|
189 |
|
|
$(SYN_WORK_DIR)/$(SYN_PROJ_NAME)/$(EDIF_FILE): $(SYN_WORK_DIR)/$(SYN_SCRIPT)
|
190 |
|
|
cd $(SYN_WORK_DIR) && time $(SYN_TOOL) $(SYN_TOOL_OPTS)
|
191 |
|
|
|
192 |
|
|
##
|
193 |
|
|
# Generate a report for each module, and for whole thing
|
194 |
|
|
##
|
195 |
530 |
julius |
MODULES ?= or1200_top
|
196 |
408 |
julius |
MODULES_SRR=$(shell for mod in $(MODULES); do echo $(SYN_WORK_DIR)"/"$(SYN_PROJ_NAME)"/"$$mod".srr"; done)
|
197 |
|
|
|
198 |
|
|
syn-report: $(MODULES_SRR)
|
199 |
|
|
rm -f $@
|
200 |
|
|
for srrfile in $^; do \
|
201 |
|
|
echo `echo $$srrfile | xargs basename | cut -d '.' -f 1`>> $@; \
|
202 |
|
|
grep "Core Cells" $$srrfile >> $@; \
|
203 |
|
|
grep "Block Rams" $$srrfile >> $@; \
|
204 |
|
|
grep -B 1 -A 5 "Starting Clock" $$srrfile >> $@; \
|
205 |
|
|
echo >> $@; echo >> $@; \
|
206 |
|
|
done
|
207 |
|
|
|
208 |
|
|
%.srr:
|
209 |
|
|
@echo; echo "\tGenerating "$@; echo
|
210 |
|
|
export RTL_TOP=$(shell echo $@ | xargs basename | cut -d '.' -f 1); \
|
211 |
|
|
$(MAKE) $(SYN_WORK_DIR)/$(SYN_PROJ_NAME)/$$RTL_TOP.edn
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
$(EDIF_FILE_OUT): $(SYN_WORK_DIR)/$(SYN_PROJ_NAME)/$(EDIF_FILE)
|
215 |
|
|
cp $^ $@
|
216 |
|
|
|
217 |
411 |
julius |
$(VLOG_NETLIST_FILE_OUT): $(SYN_WORK_DIR)/$(SYN_PROJ_NAME)/$(VLOG_NETLIST_FILE)
|
218 |
|
|
cp $^ $@
|
219 |
|
|
|
220 |
542 |
julius |
distclean: clean-sw clean clean-bootrom clean-edifs
|
221 |
408 |
julius |
|
222 |
|
|
clean-sw:
|
223 |
449 |
julius |
$(MAKE) -C $(PROJECT_ROOT)/sw/lib distclean
|
224 |
408 |
julius |
|
225 |
|
|
clean: clean-build
|
226 |
|
|
|
227 |
|
|
clean-edifs:
|
228 |
|
|
rm -f *.edn ../out/*
|
229 |
|
|
|
230 |
|
|
clean-build:
|
231 |
|
|
rm -rf $(SYN_WORK_DIR) *.edn
|
232 |
|
|
|
233 |
|
|
clean-srr:
|
234 |
|
|
rm $(MODULES_SRR)
|