Skip to content

Commit 17a6a5d

Browse files
committed
added DFF_MAP_FILE flow variable to map DFF's
tclfmt fixes Signed-off-by: Jeff Ng <[email protected]>
1 parent 1be034e commit 17a6a5d

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

docs/user/FlowVariables.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ configuration file.
128128
| <a name="DETAILED_ROUTE_ARGS"></a>DETAILED_ROUTE_ARGS| Add additional arguments for debugging purposes during detail route.| |
129129
| <a name="DETAILED_ROUTE_END_ITERATION"></a>DETAILED_ROUTE_END_ITERATION| Maximum number of iterations.| 64|
130130
| <a name="DFF_LIB_FILES"></a>DFF_LIB_FILES| Technology mapping liberty files for flip-flops.| |
131+
| <a name="DFF_MAP_FILE"></a>DFF_MAP_FILE| List of D flip flops treated as a black box by Yosys.| |
131132
| <a name="DIE_AREA"></a>DIE_AREA| The die area specified as a list of lower-left and upper-right corners in microns (X1 Y1 X2 Y2).| |
132133
| <a name="DONT_BUFFER_PORTS"></a>DONT_BUFFER_PORTS| Do not buffer input/output ports during floorplanning.| 0|
133134
| <a name="DONT_USE_CELLS"></a>DONT_USE_CELLS| Dont use cells eases pin access in detailed routing.| |
@@ -276,6 +277,7 @@ configuration file.
276277
- [ABC_LOAD_IN_FF](#ABC_LOAD_IN_FF)
277278
- [ADDER_MAP_FILE](#ADDER_MAP_FILE)
278279
- [CLKGATE_MAP_FILE](#CLKGATE_MAP_FILE)
280+
- [DFF_MAP_FILE](#DFF_MAP_FILE)
279281
- [LATCH_MAP_FILE](#LATCH_MAP_FILE)
280282
- [MIN_BUF_CELL_AND_PORTS](#MIN_BUF_CELL_AND_PORTS)
281283
- [SDC_FILE](#SDC_FILE)

flow/scripts/synth.tcl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
#
2+
# Extracts and returns module names from Verilog file
3+
#
4+
proc get_module_names { file_path } {
5+
set module_list [list]
6+
if { [catch { set fid [open $file_path r] } err] } {
7+
error "Failed to open file $file_path: $err"
8+
}
9+
10+
set regex {^[ \t]*module[ \t]+([A-Za-z_$][A-Za-z0-9_$]*)}
11+
12+
while { [gets $fid line] >= 0 } {
13+
if { [regexp -nocase $regex $line match_all module_name] } {
14+
lappend module_list $module_name
15+
}
16+
}
17+
18+
close $fid
19+
return $module_list
20+
}
21+
22+
#
23+
# Builds dfflegalize arg list
24+
#
25+
proc get_dfflegalize_args { file_path } {
26+
set legalize_args [list]
27+
set module_names [get_module_names $file_path]
28+
foreach module_name $module_names {
29+
lappend legalize_args -cell $module_name x
30+
}
31+
return $legalize_args
32+
}
33+
134
source $::env(SCRIPTS_DIR)/synth_preamble.tcl
235
read_checkpoint $::env(RESULTS_DIR)/1_1_yosys_canonicalize.rtlil
336

@@ -143,6 +176,10 @@ if { [env_var_exists_and_non_empty LATCH_MAP_FILE] } {
143176
# dfflibmap only supports one liberty file
144177
if { [env_var_exists_and_non_empty DFF_LIB_FILE] } {
145178
dfflibmap -liberty $::env(DFF_LIB_FILE) {*}$lib_dont_use_args
179+
} elseif { [env_var_exists_and_non_empty DFF_MAP_FILE] } {
180+
set legalize_args [get_dfflegalize_args $::env(DFF_MAP_FILE)]
181+
dfflegalize {*}$legalize_args
182+
techmap -map $::env(DFF_MAP_FILE)
146183
} else {
147184
dfflibmap {*}$lib_args {*}$lib_dont_use_args
148185
}

flow/scripts/variables.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ SYNTH_RETIME_MODULES:
292292
optimal distribution of registers on long pipelines. See OR discussion #8080.
293293
stages:
294294
- synth
295+
DFF_MAP_FILE:
296+
description: |
297+
List of D flip flops treated as a black box by Yosys.
298+
stages:
299+
- synth
295300
LATCH_MAP_FILE:
296301
description: |
297302
List of latches treated as a black box by Yosys.

0 commit comments

Comments
 (0)