Skip to content

Commit

Permalink
Replace get_violations_count with something a bit more straightforward
Browse files Browse the repository at this point in the history
  • Loading branch information
donn committed Dec 11, 2023
1 parent fe23099 commit 621f3ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
14 changes: 7 additions & 7 deletions scripts/klayout/xml_drc_report_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# 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.

import json

from klayout.rdb import ReportDatabase
Expand All @@ -26,17 +25,18 @@ def cli(xml_file, json_file):
database = ReportDatabase("Database")
json_database = {}
database.load(xml_file)
total = 0
for category in database.each_category():
num_items = category.num_items()
category_name = category.name()
json_database[category_name] = num_items
total += num_items

json_database = dict(sorted(json_database.items(), key=lambda item: item[1]))
json_database["total"] = total

with open(json_file, "w") as f:
f.write(
json.dumps(
dict(sorted(json_database.items(), key=lambda item: item[1])), indent=4
)
)
with open(json_file, "w", encoding="utf8") as f:
json.dump(json_database, f)


if __name__ == "__main__":
Expand Down
19 changes: 2 additions & 17 deletions scripts/tcl_commands/checkers.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -387,24 +387,9 @@ proc quit_on_unconnected_pdn_nodes {args} {
}
}

proc get_violations_count {report_file} {
package require json

set total_violations_count 0

set fp [open $report_file r]
set violations_json [read $fp]
close $fp

set violations_dict [json::json2dict $violations_json]
foreach count [dict values $violations_dict] {
set total_violations_count [expr $total_violations_count + $count]
}
return $total_violations_count
}

proc quit_on_klayout_drc {report_file} {
set violations_count [get_violations_count $report_file]
set violations_dict [json::json2dict [cat $report_file]]
set violations_count [dict get $violations_dict "total"]
if { $::env(QUIT_ON_KLAYOUT_DRC) && $violations_count != 0} {
puts_err "There are violations in the design after KLayout DRC."
puts_err "Total Number of violations is $violations_count"
Expand Down

0 comments on commit 621f3ca

Please sign in to comment.