Skip to content

Commit

Permalink
write_verilog from a DEF file (The-OpenROAD-Project#1622)
Browse files Browse the repository at this point in the history
+ Allow `write_verilog` to have an input def file 
+ Allow reading in DEF/LEF as an option for OpenROAD scripts


Co-authored-by: Donn <me@donn.website>
  • Loading branch information
kareefardi and donn authored Jan 18, 2023
1 parent 03bbd57 commit 3689e7a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
18 changes: 15 additions & 3 deletions scripts/openroad/common/io.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,21 @@ proc read {args} {
keys {-override_libs}\
flags {-multi_corner_libs}

if {[catch {read_db $::env(CURRENT_ODB)} errmsg]} {
puts stderr $errmsg
exit 1
if { [info exists ::env(IO_READ_DEF)] && $::env(IO_READ_DEF) } {
if { [ catch {read_lef $::env(MERGED_LEF)} errmsg ]} {
puts stderr $errmsg
exit 1
}
if { [ catch {read_def $::env(CURRENT_DEF)} errmsg ]} {
puts stderr $errmsg
exit 1
}
} else {
puts "\[INFO\]: Reading ODB at '$::env(CURRENT_ODB)'..."
if { [ catch {read_db $::env(CURRENT_ODB)} errmsg ]} {
puts stderr $errmsg
exit 1
}
}

set read_libs_args [list]
Expand Down
16 changes: 10 additions & 6 deletions scripts/tcl_commands/all.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,6 @@ proc write_verilog {args} {
set flags {}
parse_key_args "write_verilog" args arg_values $options flags_map $flags

set_if_unset arg_values(-def) $::env(CURRENT_DEF)
set_if_unset arg_values(-indexed_log) /dev/null

increment_index
Expand All @@ -1163,16 +1162,21 @@ proc write_verilog {args} {

set save_arg "odb=/dev/null,netlist=$filename"

set current_def_backup $::env(CURRENT_DEF)
set ::env(CURRENT_DEF) $arg_values(-def)

if { [info exists arg_values(-powered_to)] } {
set save_arg "$save_arg,powered_netlist=$arg_values(-powered_to)"
}

set arg_list [list]
lappend arg_list -indexed_log $arg_values(-indexed_log)
lappend arg_list -save $save_arg
set current_def_backup $::env(CURRENT_DEF)
if { [info exists arg_values(-def)] } {
set ::env(CURRENT_DEF) $arg_values(-def)
lappend arg_list -def_in
}

run_openroad_script $::env(SCRIPTS_DIR)/openroad/write_views.tcl\
-indexed_log $arg_values(-indexed_log)\
-save $save_arg
{*}$arg_list

set $::env(CURRENT_DEF) $current_def_backup

Expand Down
10 changes: 9 additions & 1 deletion scripts/utils/utils.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ proc run_tcl_script {args} {
# -def_in: Specify that the input is CURRENT_DEF and not the ODB file.
# -gui: Launch the GUI (OpenROAD Only)
# -no_update_current: See '-save'
set flags {-netlist_in -gui -no_update_current}
set flags {-def_in -netlist_in -gui -no_update_current}

parse_key_args "run_tcl_script" args arg_values $options flag_map $flags

Expand All @@ -486,6 +486,10 @@ proc run_tcl_script {args} {
set index 1
set name $::env(DESIGN_NAME)

if { [info exists flag_map(-def_in)] } {
set ::env(IO_READ_DEF) 1
}

set saved_values [split $arg_values(-save) ","]

# C-style for loop because Tcl foreach cannot handle the list being
Expand Down Expand Up @@ -644,6 +648,10 @@ proc run_tcl_script {args} {
}
}

if { [info exists arg_values(-def_in)] } {
unset ::env(IO_READ_DEF)
}

if { ![info exist flag_map(-no_update_current)]} {
foreach {element value} $save_list {
set cap [string toupper $element]
Expand Down

0 comments on commit 3689e7a

Please sign in to comment.