This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
forked from efabless/OpenLane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deflef_utils.tcl
executable file
·186 lines (157 loc) · 6.45 KB
/
deflef_utils.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Copyright 2020-2022 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
proc remove_empty_nets {args} {
set options {{-input required}}
set flags {}
parse_key_args "remove_empty_nets" args arg_values $options flags_map $flags
try_catch $::env(OPENROAD_BIN) -python $::env(SCRIPTS_DIR)/defutil.py remove_nets\
--empty-only\
--input-lef $::env(MERGED_LEF)\
--output $arg_values(-input)\
$arg_values(-input)
}
proc resize_die {args} {
set options {\
{-def required} \
{-area required}
}
set flags {}
parse_key_args "resize_die" args arg_values $options flags_map $flags
set llx [expr {[lindex $arg_values(-area) 0] * $::env(DEF_UNITS_PER_MICRON)}]
set lly [expr {[lindex $arg_values(-area) 1] * $::env(DEF_UNITS_PER_MICRON)}]
set urx [expr {[lindex $arg_values(-area) 2] * $::env(DEF_UNITS_PER_MICRON)}]
set ury [expr {[lindex $arg_values(-area) 3] * $::env(DEF_UNITS_PER_MICRON)}]
puts_info "Resizing Die to $arg_values(-area)"
try_catch sed -i -E "0,/^DIEAREA.*$/{s/^DIEAREA.*$/DIEAREA ( $llx $lly ) ( $urx $ury ) ;/}" $arg_values(-def)
}
proc get_instance_position {args} {
set options {\
{-instance required}\
{-def optional}
}
set flags {}
parse_key_args "get_instance_position" args arg_values $options flags_map $flags
set instance $arg_values(-instance)
if { [info exists arg_values(-def)] } {
set def $arg_values(-def)
} elseif { [info exists ::env(CURRENT_DEF)] } {
set def $::env(CURRENT_DEF)
} else {
puts_err "No DEF specified"
return -code error
}
puts $instance
set pos [exec sed -E -n "s/^\s*-\s+$instance.*\( (\[\[:digit:\]\]+) (\[\[:digit:\]\]+) \).*;$/\1 \2/p" $arg_values(-def)]
return $pos
}
proc add_lefs {args} {
set options {{-src required} \
\
}
set flags {}
parse_key_args "add_lefs" args arg_values $options flags_map $flags
puts_info "Merging $arg_values(-src)"
if { $::env(WIDEN_SITE) == 1 && $::env(WIDEN_SITE_IS_FACTOR) == 1 } {
try_catch $::env(SCRIPTS_DIR)/mergeLef.py -i $::env(MERGED_LEF) {*}$arg_values(-src) -o $::env(MERGED_LEF).new
try_catch $::env(SCRIPTS_DIR)/mergeLef.py -i $::env(MERGED_LEF_UNPADDED) {*}$arg_values(-src) -o $::env(MERGED_LEF_UNPADDED).new
try_catch mv $::env(MERGED_LEF).new $::env(MERGED_LEF)
try_catch mv $::env(MERGED_LEF_UNPADDED).new $::env(MERGED_LEF_UNPADDED)
} else {
# The original lef
try_catch $::env(SCRIPTS_DIR)/mergeLef.py -i $::env(MERGED_LEF_ORIGINAL) {*}$arg_values(-src) -o $::env(MERGED_LEF_ORIGINAL).new
try_catch $::env(SCRIPTS_DIR)/mergeLef.py -i $::env(MERGED_LEF_UNPADDED_ORIGINAL) {*}$arg_values(-src) -o $::env(MERGED_LEF_UNPADDED_ORIGINAL).new
try_catch mv $::env(MERGED_LEF_ORIGINAL).new $::env(MERGED_LEF_ORIGINAL)
try_catch mv $::env(MERGED_LEF_UNPADDED_ORIGINAL).new $::env(MERGED_LEF_UNPADDED_ORIGINAL)
# The modified lef
try_catch $::env(SCRIPTS_DIR)/mergeLef.py -i $::env(MERGED_LEF_WIDENED) {*}$arg_values(-src) -o $::env(MERGED_LEF_WIDENED).new
try_catch $::env(SCRIPTS_DIR)/mergeLef.py -i $::env(MERGED_LEF_UNPADDED_WIDENED) {*}$arg_values(-src) -o $::env(MERGED_LEF_UNPADDED_WIDENED).new
try_catch mv $::env(MERGED_LEF_WIDENED).new $::env(MERGED_LEF_WIDENED)
try_catch mv $::env(MERGED_LEF_UNPADDED_WIDENED).new $::env(MERGED_LEF_UNPADDED_WIDENED)
}
}
proc merge_components {args} {
set options {{-input1 required} \
{-input2 required} \
{-output required} \
}
set flags {}
parse_key_args "merge_components" args arg_values $options flags_map $flags
try_catch $::env(OPENROAD_BIN) -python $::env(SCRIPTS_DIR)/defutils.py\
merge_components\
--input-lef $::env(MERGED_LEF)\
--output $arg_values(-output)\
$arg_values(-input1) $arg_values(-input2)
}
proc move_pins {args} {
# To be precise, this REPLACES pins in to with the ones in from.
set options {{-from required} \
{-to required} \
}
set flags {}
parse_key_args "move_pins" args arg_values $options flags_map $flags
try_catch $::env(OPENROAD_BIN) -python $::env(SCRIPTS_DIR)/defutil.py replace_pins\
--output $arg_values(-to)\
--input-lef $::env(MERGED_LEF)\
$arg_values(-from) $arg_values(-to)
}
proc zeroize_origin_lef {args} {
set options {{-file required} \
}
set flags {}
parse_key_args "zeroize_origin_lef" args arg_values $options flags_map $flags
exec cp $arg_values(-file) $arg_values(-file).original
try_catch python3 $::env(SCRIPTS_DIR)/zeroize_origin_lef.py < $arg_values(-file) > $arg_values(-file).zeroized
exec mv $arg_values(-file).zeroized $arg_values(-file)
}
proc remove_pins {args} {
set options {{-input required}}
set flags {}
parse_key_args "remove_pins" args arg_values $options flags_map $flags
try_catch $::env(OPENROAD_BIN) -python $::env(SCRIPTS_DIR)/defutil.py remove_pins\
--input-lef $::env(MERGED_LEF)\
--output $arg_values(-input)\
$arg_values(-input)
}
proc remove_nets {args} {
set options {{-input required}}
set flags {}
parse_key_args "remove_nets" args arg_values $options flags_map $flags
try_catch $::env(OPENROAD_BIN) -python $::env(SCRIPTS_DIR)/defutil.py remove_nets\
--input-lef $::env(MERGED_LEF)\
--output $arg_values(-input)\
$arg_values(-input)
}
proc remove_components {args} {
set options {{-input required}}
set flags {}
parse_key_args "remove_components" args arg_values $options flags_map $flags
try_catch $::env(OPENROAD_BIN) -python $::env(SCRIPTS_DIR)/defutil.py remove_components\
--input-lef $::env(MERGED_LEF)\
--output $arg_values(-input)\
$arg_values(-input)
}
proc remove_component {args} {
set options {
{-input required}
{-instance_name required}
}
set flags {}
parse_key_args "remove_component" args arg_values $options flags_map $flags
try_catch $::env(OPENROAD_BIN) -python $::env(SCRIPTS_DIR)/defutil.py remove_components\
--input-lef $::env(MERGED_LEF)\
--instance-name $arg_values(-instance_name) --not-rx\
--output $arg_values(-input)\
$arg_values(-input)
}
package provide openlane_utils 0.9