1############################################################################ 2## BSD 3-Clause License 3## 4## Copyright (c) 2021, The Regents of the University of California 5## All rights reserved. 6## 7## Redistribution and use in source and binary forms, with or without 8## modification, are permitted provided that the following conditions are met: 9## 10## * Redistributions of source code must retain the above copyright notice, this 11## list of conditions and the following disclaimer. 12## 13## * Redistributions in binary form must reproduce the above copyright notice, 14## this list of conditions and the following disclaimer in the documentation 15## and/or other materials provided with the distribution. 16## 17## * Neither the name of the copyright holder nor the names of its 18## contributors may be used to endorse or promote products derived from 19## this software without specific prior written permission. 20## 21## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24## ARE 25## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29## CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32############################################################################ 33 34sta::define_cmd_args "rtl_macro_placer" { -config_file config_file \ 35 [-report_directory report_file] \ 36 -report_file report_file \ 37 } 38proc rtl_macro_placer { args } { 39 sta::parse_key_args "rtl_macro_placer" args keys { -config_file 40 -report_directory -report_file } flag { } 41 42 if { ![info exists keys(-config_file)] } { 43 utl::error MPL 2 "rtl_macro_placer -config_file config_file" 44 } 45 46 if { ![info exists keys(-report_file)] } { 47 utl::error MPL 3 "missing mandatory argument -report_file" 48 } 49 50 set config_file $keys(-config_file) 51 set report_file $keys(-report_file) 52 set report_directory "rtl_mp" 53 54 if { [info exists keys(-report_directory)] } { 55 set report_directory $keys(-report_directory) 56 } 57 58 if {![mpl2::rtl_macro_placer_cmd $config_file $report_directory $report_file]} { 59 return 60 } 61 62 set block [ord::get_db_block] 63 set units [$block getDefUnits] 64 set macro_placement_file "./${report_directory}/macro_placement.cfg" 65 66 set ch [open $macro_placement_file] 67 68 while {![eof $ch]} { 69 set line [gets $ch] 70 if {[llength $line] == 0} {continue} 71 72 set inst_name [lindex $line 0] 73 set orientation [lindex $line 1] 74 set x [expr round([lindex $line 2] * $units)] 75 set y [expr round([lindex $line 3] * $units)] 76 77 if {[set inst [$block findInst $inst_name]] == "NULL"} { 78 utl::error MPL 4 "Cannot find instance $inst_name" 79 } 80 81 $inst setOrient $orientation 82 $inst setOrigin $x $y 83 $inst setPlacementStatus FIRM 84 } 85 86 close $ch 87} 88