Skip to content

Commit b952f43

Browse files
committed
Add option of synthesis using 'syn'
Signed-off-by: Martin Povišer <povik@cutebit.org>
1 parent d90873f commit b952f43

6 files changed

Lines changed: 119 additions & 12 deletions

File tree

docs/user/FlowVariables.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ configuration file.
311311
| <a name="SYNTH_RETIME_MODULES"></a>SYNTH_RETIME_MODULES| *This is an experimental option and may cause adverse effects.* *No effort has been made to check if the retimed RTL is logically equivalent to the non-retimed RTL.* List of modules to apply automatic retiming to. These modules must not get dissolved and as such they should either be the top module or be included in SYNTH_KEEP_MODULES. The main use case is to quickly identify if performance can be improved by manually retiming the input RTL. Retiming will treat module ports like register endpoints/startpoints. The objective function of retiming isn't informed by SDC, even the clock period is ignored. As such, retiming will optimize for best delay at potentially high register number cost. Automatic retiming can produce suboptimal results as its timing model is crude and it doesn't find the optimal distribution of registers on long pipelines. See OR discussion # 8080.| |
312312
| <a name="SYNTH_SKIP_KEEP"></a>SYNTH_SKIP_KEEP| Only meaningful together with SYNTH_CHECKPOINT. When set, signals that the supplied checkpoint is still canonical RTLIL (coarse synth and `keep_hierarchy` have not been run yet), so synth.tcl runs the full coarse+fine synthesis flattened. When unset and SYNTH_CHECKPOINT is used, synth.tcl assumes the checkpoint already has coarse synth + `keep_hierarchy` done and resumes from `coarse:fine`.| 0|
313313
| <a name="SYNTH_SLANG_ARGS"></a>SYNTH_SLANG_ARGS| Additional arguments passed to the slang frontend during synthesis.| |
314+
| <a name="SYNTH_USE_SYN"></a>SYNTH_USE_SYN| If set to 1, run synthesis using the "syn" tool built into OpenROAD (the synth_syn.tcl flow) instead of the default Yosys-based flow. Defaults to 0 (Yosys flow).| 0|
314315
| <a name="SYNTH_WRAPPED_ADDERS"></a>SYNTH_WRAPPED_ADDERS| Specify the adder modules that can be used for synthesis, separated by commas. The default adder module is determined by the first element of this variable.| |
315316
| <a name="SYNTH_WRAPPED_MULTIPLIERS"></a>SYNTH_WRAPPED_MULTIPLIERS| Specify the multiplier modules that can be used for synthesis, separated by commas. The default multiplier module is determined by the first element of this variable.| |
316317
| <a name="SYNTH_WRAPPED_OPERATORS"></a>SYNTH_WRAPPED_OPERATORS| Synthesize multiple architectural options for each arithmetic operator in the design. These options are available for switching among in later stages of the flow.| |
@@ -349,6 +350,7 @@ configuration file.
349350
- [PRE_SYNTH_TCL](#PRE_SYNTH_TCL)
350351
- [SDC_FILE](#SDC_FILE)
351352
- [SDC_GUT](#SDC_GUT)
353+
- [SKIP_REPORT_METRICS](#SKIP_REPORT_METRICS)
352354
- [SLANG_PLUGIN_PATH](#SLANG_PLUGIN_PATH)
353355
- [SYNTH_ARGS](#SYNTH_ARGS)
354356
- [SYNTH_BLACKBOXES](#SYNTH_BLACKBOXES)
@@ -371,6 +373,7 @@ configuration file.
371373
- [SYNTH_RETIME_MODULES](#SYNTH_RETIME_MODULES)
372374
- [SYNTH_SKIP_KEEP](#SYNTH_SKIP_KEEP)
373375
- [SYNTH_SLANG_ARGS](#SYNTH_SLANG_ARGS)
376+
- [SYNTH_USE_SYN](#SYNTH_USE_SYN)
374377
- [SYNTH_WRAPPED_ADDERS](#SYNTH_WRAPPED_ADDERS)
375378
- [SYNTH_WRAPPED_MULTIPLIERS](#SYNTH_WRAPPED_MULTIPLIERS)
376379
- [TIEHI_CELL_AND_PORT](#TIEHI_CELL_AND_PORT)

flow/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,11 @@ floorplan_to_place: $(RESULTS_DIR)/1_synth.odb $(RESULTS_DIR)/1_synth.sdc
404404

405405
# ==============================================================================
406406

407+
ifeq ($(SYNTH_USE_SYN),1)
408+
$(eval $(call do-step,1_synth,$(VERILOG_FILES) $(SDC_FILE) $(TECH_LEF) $(SC_LEF) $(ADDITIONAL_LEFS) $(LIB_FILES),synth_syn))
409+
else
407410
$(eval $(call do-step,1_synth,$(RESULTS_DIR)/1_2_yosys.v $(RESULTS_DIR)/1_2_yosys.sdc $(TECH_LEF) $(SC_LEF) $(ADDITIONAL_LEFS) $(LIB_FILES),synth_odb))
411+
endif
408412

409413
$(RESULTS_DIR)/1_synth.sdc: $(RESULTS_DIR)/1_synth.odb
410414

flow/scripts/synth_syn.tcl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
utl::set_metrics_stage "synth__{}"
2+
source $::env(SCRIPTS_DIR)/load.tcl
3+
erase_non_stage_variables synth
4+
5+
source_env_var_if_exists PLATFORM_TCL
6+
source $::env(SCRIPTS_DIR)/read_liberty.tcl
7+
8+
read_lef $::env(TECH_LEF)
9+
read_lef $::env(SC_LEF)
10+
if { [env_var_exists_and_non_empty ADDITIONAL_LEFS] } {
11+
foreach lef $::env(ADDITIONAL_LEFS) {
12+
read_lef $lef
13+
}
14+
}
15+
if { [env_var_exists_and_non_empty DONT_USE_CELLS] } {
16+
set_dont_use $::env(DONT_USE_CELLS)
17+
}
18+
19+
# Setup verilog include directories
20+
set vIdirsArgs ""
21+
if { [env_var_exists_and_non_empty VERILOG_INCLUDE_DIRS] } {
22+
foreach dir $::env(VERILOG_INCLUDE_DIRS) {
23+
lappend vIdirsArgs "-I$dir"
24+
}
25+
set vIdirsArgs [join $vIdirsArgs]
26+
}
27+
28+
set elaborate_args [list \
29+
-D SYNTHESIS --compat=vcs --ignore-assertions --no-implicit-memories --top $::env(DESIGN_NAME) \
30+
{*}$vIdirsArgs {*}[env_var_or_empty VERILOG_DEFINES]]
31+
32+
lappend elaborate_args {*}$::env(VERILOG_FILES)
33+
34+
# Apply top-level parameters
35+
dict for {key value} [env_var_or_empty VERILOG_TOP_PARAMS] {
36+
lappend elaborate_args -G "$key=$value"
37+
}
38+
39+
# Apply module blackboxing based on module names as they appear
40+
# in the input, that is before any module name mangling done
41+
# by elaboration and synthesis
42+
if { [env_var_exists_and_non_empty SYNTH_BLACKBOXES] } {
43+
foreach m $::env(SYNTH_BLACKBOXES) {
44+
lappend elaborate_args --blackboxed-module "$m"
45+
}
46+
}
47+
48+
lappend elaborate_args {*}$::env(SYNTH_SLANG_ARGS)
49+
50+
# If the sources are solely .v files, enable Verilog compatibility
51+
set has_non_v_files false
52+
foreach fn $::env(VERILOG_FILES) {
53+
if { [file extension [string trim $fn]] != ".v" } {
54+
set has_non_v_files true
55+
}
56+
}
57+
if { !$has_non_v_files } {
58+
lappend elaborate_args --std=1364-2005
59+
}
60+
61+
sv_elaborate {*}$elaborate_args
62+
syn::stats
63+
64+
synthesize
65+
66+
read_sdc $::env(SDC_FILE)
67+
repair_design -pre_placement
68+
69+
report_metrics 1 "synth" false false
70+
71+
orfs_write_db $::env(RESULTS_DIR)/1_synth.odb
72+
# Canonicalize 1_synth.sdc. The original SDC_FILE provided by
73+
# the user could have dependencies, such as sourcing util.tcl,
74+
# which are read in here and a canonicalized version is written
75+
# out by OpenSTA that has no dependencies.
76+
orfs_write_sdc $::env(RESULTS_DIR)/1_synth.sdc

flow/scripts/variables.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flow/scripts/variables.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ SKIP_REPORT_METRICS:
115115
If set to 1, then metrics, report_metrics does nothing. Useful to speed up
116116
builds.
117117
stages:
118+
- synth
118119
- floorplan
119120
- place
120121
- cts
@@ -180,6 +181,14 @@ SYNTH_HIERARCHICAL:
180181
stages:
181182
- synth
182183
default: 0
184+
SYNTH_USE_SYN:
185+
description: >
186+
If set to 1, run synthesis using the "syn" tool built into OpenROAD
187+
(the synth_syn.tcl flow) instead of the default Yosys-based flow.
188+
Defaults to 0 (Yosys flow).
189+
stages:
190+
- synth
191+
default: 0
183192
SYNTH_MEMORY_MAX_BITS:
184193
description: >
185194
Maximum number of bits for memory synthesis.

flow/util/genMetrics.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def merge_jsons(root_path, output, files):
209209
with open(path, "r") as file:
210210
data = json.load(file)
211211
output.update(data)
212+
return len(paths) != 0
212213

213214

214215
def extract_metrics(
@@ -246,21 +247,26 @@ def extract_metrics(
246247
# Synthesis
247248
# =========================================================================
248249

250+
# Try sourcing metrics from OpenROAD's syn flow first, fall back to parsing
251+
# Yosys reports otherwise
252+
found_synthesis_json = merge_jsons(logPath, metrics_dict, "1_*.json")
253+
249254
# The new format (>= 0.57) with -hierarchy is:
250255
# <count> <area> <local_count> <local_area> cells
251-
extractTagFromFile(
252-
"synth__design__instance__count__stdcell",
253-
metrics_dict,
254-
"^\\s+(\\d+)\\s+[-0-9.]+\\s+\\S+\\s+\\S+\\s+cells$",
255-
rptPath + "/synth_stat.txt",
256-
)
256+
if not found_synthesis_json:
257+
extractTagFromFile(
258+
"synth__design__instance__count__stdcell",
259+
metrics_dict,
260+
"^\\s+(\\d+)\\s+[-0-9.]+\\s+\\S+\\s+\\S+\\s+cells$",
261+
rptPath + "/synth_stat.txt",
262+
)
257263

258-
extractTagFromFile(
259-
"synth__design__instance__area__stdcell",
260-
metrics_dict,
261-
"Chip area for (?:top )?module.*: +(\\S+)",
262-
rptPath + "/synth_stat.txt",
263-
)
264+
extractTagFromFile(
265+
"synth__design__instance__area__stdcell",
266+
metrics_dict,
267+
"Chip area for (?:top )?module.*: +(\\S+)",
268+
rptPath + "/synth_stat.txt",
269+
)
264270

265271
# Netlist hashes: fingerprints of the canonical RTLIL (pre-ABC) and
266272
# the final post-synthesis Verilog so the rules-base.json check
@@ -271,6 +277,7 @@ def extract_metrics(
271277
)
272278
metrics_dict["synth__netlist__hash"] = file_sha1(resultPath + "/1_2_yosys.v")
273279

280+
274281
# Clocks
275282
# =========================================================================
276283
clk_list = read_sdc(resultPath + "/2_floorplan.sdc")

0 commit comments

Comments
 (0)