Skip to content

Commit 4049776

Browse files
committed
synth: Add SYNTH_USE_SLANG option
Add option to read the design via yosys-slang. Reorder read_liberty ahead of design read-in so that Liberty cell definitions are available when elaborating. Signed-off-by: Martin Povišer <[email protected]>
1 parent fa14b47 commit 4049776

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

flow/scripts/synth.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set ::env(VERILOG_FILES) $::env(RESULTS_DIR)/1_synth.rtlil
1+
set ::env(RTLIL_FILE) $::env(RESULTS_DIR)/1_synth.rtlil
22

33
source $::env(SCRIPTS_DIR)/synth_preamble.tcl
44

flow/scripts/synth_preamble.tcl

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,52 @@ if {[env_var_exists_and_non_empty SYNTH_NETLIST_FILES]} {
2121
exit
2222
}
2323

24-
# Setup verilog include directories
25-
set vIdirsArgs ""
26-
if {[env_var_exists_and_non_empty VERILOG_INCLUDE_DIRS]} {
27-
foreach dir $::env(VERILOG_INCLUDE_DIRS) {
28-
lappend vIdirsArgs "-I$dir"
29-
}
30-
set vIdirsArgs [join $vIdirsArgs]
31-
}
32-
33-
34-
# Read verilog files
35-
foreach file $::env(VERILOG_FILES) {
36-
if {[file extension $file] == ".rtlil"} {
37-
read_rtlil $file
38-
} elseif {[file extension $file] == ".json"} {
24+
# Read design
25+
if {[env_var_exists_and_non_empty RTLIL_FILE]} {
26+
# We are reading a Yosys checkpoint
27+
set file $env(RTLIL_FILE)
28+
if {[file extension $file] == ".json"} {
3929
read_json $file
4030
} else {
41-
read_verilog -defer -sv {*}$vIdirsArgs $file
31+
read_rtlil $file
32+
}
33+
} else {
34+
# We are reading Verilog sources
35+
source $::env(SCRIPTS_DIR)/synth_stdcells.tcl
36+
37+
# Setup verilog include directories
38+
set vIdirsArgs ""
39+
if {[env_var_exists_and_non_empty VERILOG_INCLUDE_DIRS]} {
40+
foreach dir $::env(VERILOG_INCLUDE_DIRS) {
41+
lappend vIdirsArgs "-I$dir"
42+
}
43+
set vIdirsArgs [join $vIdirsArgs]
4244
}
43-
}
4445

45-
source $::env(SCRIPTS_DIR)/synth_stdcells.tcl
46+
if {[env_var_exists_and_non_empty SYNTH_USE_SLANG]} {
47+
# slang requires all files at once
48+
plugin -i slang
49+
yosys read_slang -D SYNTHESIS --keep-hierarchy --compat=vcs \
50+
--ignore-assertions --top $::env(DESIGN_NAME) \
51+
{*}$vIdirsArgs {*}$::env(VERILOG_FILES) {*}$::env(VERILOG_DEFINES)
52+
# Workaround for yosys-slang#119
53+
setattr -unset init
54+
} else {
55+
foreach file $::env(VERILOG_FILES) {
56+
read_verilog -defer -sv {*}$vIdirsArgs $file
57+
}
58+
}
4659

47-
# Read platform specific mapfile for OPENROAD_CLKGATE cells
48-
if {[env_var_exists_and_non_empty CLKGATE_MAP_FILE]} {
49-
read_verilog -defer $::env(CLKGATE_MAP_FILE)
50-
}
60+
# Read platform specific mapfile for OPENROAD_CLKGATE cells
61+
if {[env_var_exists_and_non_empty CLKGATE_MAP_FILE]} {
62+
read_verilog -defer $::env(CLKGATE_MAP_FILE)
63+
}
5164

52-
if {[env_var_exists_and_non_empty SYNTH_BLACKBOXES]} {
53-
hierarchy -check -top $::env(DESIGN_NAME)
54-
foreach m $::env(SYNTH_BLACKBOXES) {
55-
blackbox $m
65+
if {[env_var_exists_and_non_empty SYNTH_BLACKBOXES]} {
66+
hierarchy -check -top $::env(DESIGN_NAME)
67+
foreach m $::env(SYNTH_BLACKBOXES) {
68+
blackbox $m
69+
}
5670
}
5771
}
5872

flow/scripts/variables.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ SYNTH_MEMORY_MAX_BITS:
169169
default: 4096
170170
stages:
171171
- synth
172+
SYNTH_USE_SLANG:
173+
description: >
174+
Use yosys-slang for read-in of SystemVerilog design.
172175
SYNTH_BLACKBOXES:
173176
description: >
174177
List of cells treated as a black box by Yosys. With Bazel, this can be used
@@ -569,8 +572,7 @@ DESIGN_NAME:
569572
VERILOG_FILES:
570573
required: true
571574
description: >
572-
The path to the design Verilog files or JSON files providing a description
573-
of modules (check `yosys -h write_json` for more details).
575+
The path to the design Verilog files providing a description of modules.
574576
stages:
575577
- synth
576578
SDC_FILE:

0 commit comments

Comments
 (0)