From 9492fd23d02577e7c19e1e7da3a3d50f0385f188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Tue, 30 Jul 2024 07:25:07 +0200 Subject: [PATCH 1/2] python: ran black . MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Øyvind Harboe --- docs/conf.py | 121 ++-- docs/getMessages.py | 24 +- docs/getPatch.py | 85 ++- docs/revert-links.py | 9 +- docs/src/scripts/extract_utils.py | 93 +-- docs/src/scripts/manpage.py | 71 ++- docs/src/scripts/md_roff_compat.py | 83 ++- docs/src/test/make_messages.py | 15 +- docs/src/test/man_tcl_params.py | 49 +- docs/src/test/readme_check.py | 6 +- docs/src/test/translator.py | 4 +- etc/deltaDebug.py | 185 +++--- etc/find_messages.py | 79 ++- etc/test_deltaDebug.py | 106 ++-- src/ant/test/ant_man_tcl_check.py | 46 +- src/ant/test/ant_readme_msgs_check.py | 7 +- src/ant/test/ant_report.py | 1 + src/cts/test/balance_levels.py | 25 +- src/cts/test/check_buffers.py | 27 +- src/cts/test/check_charBuf.py | 11 +- src/cts/test/check_wire_rc_cts.py | 25 +- src/cts/test/cts_aux.py | 50 +- src/cts/test/cts_helpers.py | 4 +- src/cts/test/cts_man_tcl_check.py | 46 +- src/cts/test/cts_readme_msgs_check.py | 7 +- src/cts/test/find_clock.py | 13 +- src/cts/test/max_cap.py | 17 +- src/cts/test/no_clocks.py | 11 +- src/cts/test/no_sinks.py | 12 +- src/cts/test/simple_test.py | 13 +- src/cts/test/simple_test_clustered.py | 23 +- src/cts/test/simple_test_clustered_max_cap.py | 19 +- src/dft/test/dft_man_tcl_check.py | 46 +- src/dft/test/dft_readme_msgs_check.py | 7 +- src/dpl/test/dpl_man_tcl_check.py | 46 +- src/dpl/test/dpl_readme_msgs_check.py | 7 +- src/dpl/test/fillers3.py | 2 +- src/dpl/test/fillers4.py | 2 +- src/dpl/test/ibex.py | 1 - src/drt/test/aes_nangate45.py | 13 +- src/drt/test/drt_aux.py | 84 ++- src/drt/test/drt_man_tcl_check.py | 46 +- src/drt/test/drt_readme_msgs_check.py | 7 +- src/drt/test/ispd18_sample.py | 12 +- src/drt/test/run-ispd.py | 77 +-- src/drt/test/single_step.py | 14 +- src/drt/test/top_level_term.py | 7 +- src/drt/test/top_level_term2.py | 7 +- src/fin/test/fin_man_tcl_check.py | 46 +- src/fin/test/fin_readme_msgs_check.py | 7 +- src/gpl/test/ar01.py | 4 +- src/gpl/test/ar02.py | 4 +- src/gpl/test/convergence01.py | 10 +- src/gpl/test/core01.py | 4 +- src/gpl/test/error01.py | 6 +- src/gpl/test/gpl_aux.py | 72 ++- src/gpl/test/gpl_man_tcl_check.py | 46 +- src/gpl/test/gpl_readme_msgs_check.py | 7 +- src/gpl/test/simple01-obs.py | 6 +- src/gpl/test/simple01-ref.py | 4 +- src/gpl/test/simple01-td-tune.py | 6 +- src/gpl/test/simple01-uniform.py | 4 +- src/gpl/test/simple02.py | 4 +- src/grt/test/clock_route.py | 7 +- src/grt/test/congestion1.py | 2 +- src/grt/test/critical_nets_percentage.py | 4 +- src/grt/test/gcd_flute.py | 2 +- src/grt/test/grt_aux.py | 66 ++- src/grt/test/grt_man_tcl_check.py | 46 +- src/grt/test/grt_readme_msgs_check.py | 7 +- src/grt/test/ndr_1w_3s.py | 12 +- src/grt/test/pd1.py | 4 +- src/grt/test/pin_access1.py | 8 +- src/grt/test/pre_routed1.py | 4 +- src/grt/test/region_adjustment.py | 2 +- src/gui/test/gui_man_tcl_check.py | 46 +- src/gui/test/gui_readme_msgs_check.py | 7 +- src/ifp/test/ifp_helpers.py | 18 +- src/ifp/test/ifp_man_tcl_check.py | 46 +- src/ifp/test/ifp_readme_msgs_check.py | 7 +- src/ifp/test/init_floorplan1.py | 10 +- src/ifp/test/init_floorplan2.py | 7 +- src/ifp/test/init_floorplan3.py | 7 +- src/ifp/test/init_floorplan4.py | 2 +- src/ifp/test/init_floorplan5.py | 2 +- src/ifp/test/init_floorplan6.py | 13 +- src/ifp/test/init_floorplan7.py | 6 +- src/ifp/test/init_floorplan8.py | 4 +- src/ifp/test/init_floorplan9.py | 5 +- src/ifp/test/make_tracks1.py | 10 +- src/ifp/test/make_tracks2.py | 10 +- src/ifp/test/make_tracks3.py | 14 +- src/ifp/test/make_tracks4.py | 16 +- src/ifp/test/make_tracks5.py | 14 +- src/ifp/test/make_tracks6.py | 10 +- src/ifp/test/placement_blockage1.py | 10 +- src/ifp/test/placement_blockage2.py | 10 +- src/ifp/test/tiecells.py | 12 +- src/mpl/test/east_west2.py | 2 +- src/mpl/test/mpl_aux.py | 37 +- src/mpl/test/mpl_man_tcl_check.py | 46 +- src/mpl/test/mpl_readme_msgs_check.py | 7 +- src/mpl2/test/mpl2_man_tcl_check.py | 46 +- src/mpl2/test/mpl2_readme_msgs_check.py | 7 +- src/odb/src/codeGenerator/gen.py | 34 +- src/odb/src/codeGenerator/helper.py | 1 - src/odb/test/odb_man_tcl_check.py | 46 +- src/odb/test/odb_readme_msgs_check.py | 7 +- src/odb/test/unitTestsPython/TestBTerm.py | 32 +- src/odb/test/unitTestsPython/TestBlock.py | 169 +++--- src/odb/test/unitTestsPython/TestDestroy.py | 88 ++- src/odb/test/unitTestsPython/TestGroup.py | 56 +- src/odb/test/unitTestsPython/TestITerm.py | 79 ++- src/odb/test/unitTestsPython/TestInst.py | 36 +- src/odb/test/unitTestsPython/TestModule.py | 40 +- src/odb/test/unitTestsPython/TestNet.py | 69 ++- src/odb/test/unitTestsPython/TestWireCodec.py | 60 +- src/odb/test/unitTestsPython/helper.py | 100 ++-- src/odb/test/unitTestsPython/odbUnitTest.py | 21 +- src/pad/test/pad_man_tcl_check.py | 46 +- src/pad/test/pad_readme_msgs_check.py | 7 +- src/par/test/par_aux.py | 183 +++--- src/par/test/par_man_tcl_check.py | 46 +- src/par/test/par_readme_msgs_check.py | 7 +- src/par/test/partition_gcd.py | 6 +- src/pdn/test/asap7_taper.py | 16 +- src/pdn/test/core_grid.py | 2 +- src/pdn/test/core_grid_with_rings.py | 18 +- .../core_grid_with_routing_obstructions.py | 26 +- src/pdn/test/existing.py | 4 +- src/pdn/test/macros.py | 37 +- src/pdn/test/max_width.py | 7 +- src/pdn/test/min_width.py | 12 +- src/pdn/test/offgrid.py | 10 +- src/pdn/test/pdn_aux.py | 560 +++++++++++------- src/pdn/test/pdn_man_tcl_check.py | 46 +- src/pdn/test/pdn_readme_msgs_check.py | 7 +- src/pdn/test/power_switch.py | 28 +- src/pdn/test/report.py | 35 +- src/pdn/test/reset.py | 2 +- src/pdn/test/widthtable.py | 2 +- src/ppl/test/add_constraint1.py | 9 +- src/ppl/test/add_constraint10.py | 21 +- src/ppl/test/add_constraint2.py | 9 +- src/ppl/test/add_constraint3.py | 9 +- src/ppl/test/add_constraint4.py | 9 +- src/ppl/test/add_constraint7.py | 6 +- src/ppl/test/add_constraint8.py | 4 +- src/ppl/test/add_constraint9.py | 13 +- src/ppl/test/exclude1.py | 11 +- src/ppl/test/exclude2.py | 11 +- src/ppl/test/exclude3.py | 11 +- src/ppl/test/gcd.py | 12 +- src/ppl/test/group_pins1.py | 19 +- src/ppl/test/group_pins2.py | 17 +- src/ppl/test/group_pins3.py | 44 +- src/ppl/test/group_pins7.py | 100 ++-- src/ppl/test/group_pins8.py | 22 +- src/ppl/test/group_pins9.py | 29 +- src/ppl/test/min_dist_in_tracks1.py | 12 +- src/ppl/test/multi_layers.py | 10 +- src/ppl/test/multiple_calls.py | 20 +- src/ppl/test/place_pin1.py | 14 +- src/ppl/test/place_pin2.py | 22 +- src/ppl/test/ppl_aux.py | 206 +++++-- src/ppl/test/ppl_man_tcl_check.py | 46 +- src/ppl/test/ppl_readme_msgs_check.py | 7 +- src/ppl/test/random2.py | 5 +- src/ppl/test/random3.py | 3 +- src/ppl/test/random4.py | 13 +- src/ppl/test/random7.py | 9 +- src/ppl/test/top_layer1.py | 15 +- src/ppl/test/top_layer2.py | 17 +- src/ppl/test/top_layer3.py | 26 +- src/psm/test/gcd_em_test_vdd.py | 5 +- src/psm/test/gcd_test_vdd.py | 10 +- src/psm/test/gcd_write_sp_test_vdd.py | 5 +- src/psm/test/pdnsim_aux.py | 70 +-- src/psm/test/psm_man_tcl_check.py | 46 +- src/psm/test/psm_readme_msgs_check.py | 7 +- src/rcx/test/45_gcd.py | 5 +- src/rcx/test/ext_pattern.py | 10 +- src/rcx/test/gcd.py | 5 +- src/rcx/test/rcx_aux.py | 109 ++-- src/rcx/test/rcx_man_tcl_check.py | 46 +- src/rcx/test/rcx_readme_msgs_check.py | 7 +- src/rcx/test/via_45_resistance.py | 1 + src/rmp/test/blif_reader.py | 8 +- src/rmp/test/const_cell_removal.py | 10 +- src/rmp/test/gcd_restructure.py | 12 +- src/rmp/test/rmp_aux.py | 43 +- src/rmp/test/rmp_man_tcl_check.py | 46 +- src/rmp/test/rmp_readme_msgs_check.py | 7 +- src/rsz/test/rsz_man_tcl_check.py | 46 +- src/rsz/test/rsz_readme_msgs_check.py | 7 +- src/stt/test/check.py | 28 +- src/stt/test/flute1.py | 11 +- src/stt/test/flute_gcd.py | 1 + src/stt/test/pd1.py | 33 +- src/stt/test/pd2.py | 94 +-- src/stt/test/pd_gcd.py | 1 + src/stt/test/stt_aux.py | 1 + src/stt/test/stt_man_tcl_check.py | 46 +- src/stt/test/stt_readme_msgs_check.py | 7 +- src/tap/test/avoid_overlap.py | 8 +- src/tap/test/boundary_macros.py | 22 +- src/tap/test/gcd_fakeram.py | 2 +- src/tap/test/gcd_nangate45.py | 4 +- src/tap/test/gcd_prefix.py | 8 +- src/tap/test/gcd_ripup.py | 2 +- src/tap/test/gcd_sky130.py | 4 +- src/tap/test/multiple_calls.py | 6 +- src/tap/test/no_endcap.py | 2 +- src/tap/test/symmetry.py | 4 +- src/tap/test/tap_man_tcl_check.py | 46 +- src/tap/test/tap_readme_msgs_check.py | 7 +- src/upf/test/upf_man_tcl_check.py | 46 +- src/upf/test/upf_readme_msgs_check.py | 7 +- src/utl/test/utl_man_tcl_check.py | 46 +- src/utl/test/utl_readme_msgs_check.py | 7 +- test/helpers.py | 10 +- test/timing_api.py | 19 +- test/timing_api_2.py | 35 +- test/timing_api_3.py | 34 +- test/timing_api_4.py | 23 +- test/two_designs.py | 8 +- 226 files changed, 3707 insertions(+), 2586 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 9ab51b2ae12..126b848014a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,9 +14,9 @@ # -- Project information ----------------------------------------------------- -project = 'OpenROAD' -copyright = 'The Regents of the University of California, 2021' -author = 'OpenROAD Team' +project = "OpenROAD" +copyright = "The Regents of the University of California, 2021" +author = "OpenROAD Team" # -- General configuration --------------------------------------------------- @@ -25,77 +25,85 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.ifconfig', - 'sphinx.ext.mathjax', - 'sphinx.ext.napoleon', - 'sphinx.ext.todo', - 'sphinx_external_toc', - 'sphinx_copybutton', - 'myst_parser', - 'sphinxcontrib.mermaid' + "sphinx.ext.autodoc", + "sphinx.ext.ifconfig", + "sphinx.ext.mathjax", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx_external_toc", + "sphinx_copybutton", + "myst_parser", + "sphinxcontrib.mermaid", ] myst_enable_extensions = [ - 'amsmath', - 'colon_fence', - 'deflist', - 'dollarmath', - 'html_admonition', - 'html_image', - 'replacements', - 'smartquotes', - 'substitution', - 'tasklist', - 'html_image', + "amsmath", + "colon_fence", + "deflist", + "dollarmath", + "html_admonition", + "html_image", + "replacements", + "smartquotes", + "substitution", + "tasklist", + "html_image", ] -external_toc_path = 'toc.yml' +external_toc_path = "toc.yml" # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = ['.md'] +source_suffix = [".md"] # The master toctree document. -master_doc = 'index' +master_doc = "index" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [ - '_build', - 'Thumbs.db', - '.DS_Store', - '**/LICENSE', - '**/LICENSE.md', - 'README.md', - 'misc/NewToolDocExample.md', - 'docs/releases/PostAlpha2.1BranchMethodology.md', - 'main/src/odb/src/def/README.md', - 'main/src/odb/src/def/doc/README.md', - 'main/src/odb/src/lef/README.md', - 'main/docs', - 'md', # manpage dir - 'man', # manpage dir - 'cat', # manpage dir - 'html' # manpage dir + "_build", + "Thumbs.db", + ".DS_Store", + "**/LICENSE", + "**/LICENSE.md", + "README.md", + "misc/NewToolDocExample.md", + "docs/releases/PostAlpha2.1BranchMethodology.md", + "main/src/odb/src/def/README.md", + "main/src/odb/src/def/doc/README.md", + "main/src/odb/src/lef/README.md", + "main/docs", + "md", # manpage dir + "man", # manpage dir + "cat", # manpage dir + "html", # manpage dir ] # The name of the Pygments (syntax highlighting) style to use. pygments_style = None # Mermaid related args -mermaid_output_format = 'svg' -mermaid_params = ['-p', 'puppeteer-config.json', - '--theme', 'forest', - '--width', '200', - '--backgroundColor', 'transparent'] -mermaid_init_js = "mermaid.initialize({startOnLoad:true, flowchart:{useMaxWidth:false}})" +mermaid_output_format = "svg" +mermaid_params = [ + "-p", + "puppeteer-config.json", + "--theme", + "forest", + "--width", + "200", + "--backgroundColor", + "transparent", +] +mermaid_init_js = ( + "mermaid.initialize({startOnLoad:true, flowchart:{useMaxWidth:false}})" +) mermaid_verbose = True # -- Options for HTML output ------------------------------------------------- @@ -112,7 +120,6 @@ "use_issues_button": True, # "use_repository_button": True, "use_download_button": True, - # list for more fine-grained ordering of icons "icon_links": [ { @@ -141,7 +148,7 @@ "icon": "https://img.shields.io/github/stars/The-OpenROAD-Project/OpenROAD", "type": "url", }, - ], + ], } # Add any paths that contain custom static files (such as style sheets) here, @@ -151,21 +158,21 @@ def swap_prefix(file, old, new): - with open(file, 'r') as f: + with open(file, "r") as f: lines = f.read() lines = lines.replace(old, new) - with open(file, 'wt') as f: + with open(file, "wt") as f: f.write(lines) def setup(app): import os - if not os.path.exists('./main'): - os.symlink('..', './main') + if not os.path.exists("./main"): + os.symlink("..", "./main") # these prefix swaps will be reverted and is needed for sphinx compilation. - swap_prefix('../README.md', '(docs/', '(../') - swap_prefix('../README.md', '```mermaid', '```{mermaid}\n:align: center\n') + swap_prefix("../README.md", "(docs/", "(../") + swap_prefix("../README.md", "```mermaid", "```{mermaid}\n:align: center\n") # for populating OR Messages page. command = "python getMessages.py" diff --git a/docs/getMessages.py b/docs/getMessages.py index 2bb9e921851..6ff1a5306d2 100644 --- a/docs/getMessages.py +++ b/docs/getMessages.py @@ -6,18 +6,21 @@ command = "python ../etc/find_messages.py -d ../src" output = os.popen(command).read() -with open('user/MessagesFinal.md', 'w') as f: +with open("user/MessagesFinal.md", "w") as f: f.write("# OpenROAD Messages Glossary\n") - f.write("Listed below are the OpenROAD warning/errors you may encounter while using the application.\n") + f.write( + "Listed below are the OpenROAD warning/errors you may encounter while using the application.\n" + ) f.write("\n") f.write("| Tool | Code | Filename:Line Number | Type | Information |\n") f.write("| ---- | ---- | -------------------- | ---- | ----------------------- |\n") - lines = output.split('\n') + lines = output.split("\n") for line in lines: columns = line.split() - if not columns: continue - ant = columns[0] + if not columns: + continue + ant = columns[0] num = columns[1] fileLineNum = f"[{columns[2]}]({columns[-1]})" msgType = columns[-2] @@ -25,16 +28,19 @@ try: # aim is to match all level1 header and their corresponding text. message = open(f"../src/{tool}/doc/messages/{num}.md").read() - pattern = re.compile(r'#\s*(?P[^\n]+)\n*(?P.*?)(?=\n#|$)', re.DOTALL) + pattern = re.compile( + r"#\s*(?P[^\n]+)\n*(?P.*?)(?=\n#|$)", re.DOTALL + ) matches = pattern.finditer(message) m = [] for match in matches: - header1 = match.group('header1') - body_text = match.group('body_text').strip() + header1 = match.group("header1") + body_text = match.group("body_text").strip() m.append(f"{header1}-{body_text}") message = " ".join(x for x in m) except OSError as e: message = "-" - if not message: message = "-" + if not message: + message = "-" f.write(f"| {ant} | {num} | {fileLineNum} | {msgType} |{message} |\n") diff --git a/docs/getPatch.py b/docs/getPatch.py index 26a8ce85986..0209d3f8ba1 100644 --- a/docs/getPatch.py +++ b/docs/getPatch.py @@ -1,53 +1,78 @@ #!/usr/bin/env python3 import os + def swap_prefix(file, old, new): - with open(file, 'r') as f: + with open(file, "r") as f: lines = f.read() lines = lines.replace(old, new) - with open(file, 'wt') as f: + with open(file, "wt") as f: f.write(lines) + # modify ../include/ord/OpenROAD.hh -swap_prefix('../include/ord/OpenRoad.hh', 'namespace dft {\nclass Dft;\n}', - 'namespace dft {\nclass Dft;\n}\n\nnamespace tool{\nclass Tool;\n}') +swap_prefix( + "../include/ord/OpenRoad.hh", + "namespace dft {\nclass Dft;\n}", + "namespace dft {\nclass Dft;\n}\n\nnamespace tool{\nclass Tool;\n}", +) -swap_prefix('../include/ord/OpenRoad.hh', 'dft::Dft* getDft() { return dft_; }', - 'dft::Dft* getDft() { return dft_; }\n tool::Tool* getTool() { return tool_; }') +swap_prefix( + "../include/ord/OpenRoad.hh", + "dft::Dft* getDft() { return dft_; }", + "dft::Dft* getDft() { return dft_; }\n tool::Tool* getTool() { return tool_; }", +) -swap_prefix('../include/ord/OpenRoad.hh', 'dft::Dft* dft_ = nullptr;', - 'dft::Dft* dft_ = nullptr;\n tool::Tool* tool_ = nullptr;') +swap_prefix( + "../include/ord/OpenRoad.hh", + "dft::Dft* dft_ = nullptr;", + "dft::Dft* dft_ = nullptr;\n tool::Tool* tool_ = nullptr;", +) # modify ../src/CMakeLists.txt -swap_prefix('../src/CMakeLists.txt', 'add_subdirectory(dft)', - 'add_subdirectory(dft)\nadd_subdirectory(tool)') +swap_prefix( + "../src/CMakeLists.txt", + "add_subdirectory(dft)", + "add_subdirectory(dft)\nadd_subdirectory(tool)", +) -swap_prefix('../src/CMakeLists.txt', 'pdn\n dft', 'pdn\n dft\n tool') +swap_prefix("../src/CMakeLists.txt", "pdn\n dft", "pdn\n dft\n tool") # modify ../src/OpenROAD.cc -swap_prefix('../src/OpenRoad.cc', '#include "utl/MakeLogger.h"', - '#include "utl/MakeLogger.h"\n#include "tool/MakeTool.hh"') +swap_prefix( + "../src/OpenRoad.cc", + '#include "utl/MakeLogger.h"', + '#include "utl/MakeLogger.h"\n#include "tool/MakeTool.hh"', +) -swap_prefix('../src/OpenRoad.cc', 'dft_ = dft::makeDft();', - 'dft_ = dft::makeDft();\n tool_ = makeTool();') +swap_prefix( + "../src/OpenRoad.cc", + "dft_ = dft::makeDft();", + "dft_ = dft::makeDft();\n tool_ = makeTool();", +) -swap_prefix('../src/OpenRoad.cc', 'dft::deleteDft(dft_);', - 'dft::deleteDft(dft_);\n deleteTool(tool_);') +swap_prefix( + "../src/OpenRoad.cc", + "dft::deleteDft(dft_);", + "dft::deleteDft(dft_);\n deleteTool(tool_);", +) -swap_prefix('../src/OpenRoad.cc', 'dft::initDft(this);', - 'dft::initDft(this);\n initTool(this);') +swap_prefix( + "../src/OpenRoad.cc", + "dft::initDft(this);", + "dft::initDft(this);\n initTool(this);", +) # create a patch file -_ = os.popen('git add ../include/ord/OpenRoad.hh').read() -_ = os.popen('git add ../src/CMakeLists.txt').read() -_ = os.popen('git add ../src/OpenRoad.cc').read() -_ = os.popen('git diff --cached > misc/AddTool.patch').read() +_ = os.popen("git add ../include/ord/OpenRoad.hh").read() +_ = os.popen("git add ../src/CMakeLists.txt").read() +_ = os.popen("git add ../src/OpenRoad.cc").read() +_ = os.popen("git diff --cached > misc/AddTool.patch").read() # restore all changes except patch -_ = os.popen('git reset ../include/ord/OpenRoad.hh').read() -_ = os.popen('git reset ../src/CMakeLists.txt').read() -_ = os.popen('git reset ../src/OpenRoad.cc').read() -_ = os.popen('git restore ../include/ord/OpenRoad.hh').read() -_ = os.popen('git restore ../src/CMakeLists.txt').read() -_ = os.popen('git restore ../src/OpenRoad.cc').read() - +_ = os.popen("git reset ../include/ord/OpenRoad.hh").read() +_ = os.popen("git reset ../src/CMakeLists.txt").read() +_ = os.popen("git reset ../src/OpenRoad.cc").read() +_ = os.popen("git restore ../include/ord/OpenRoad.hh").read() +_ = os.popen("git restore ../src/CMakeLists.txt").read() +_ = os.popen("git restore ../src/OpenRoad.cc").read() diff --git a/docs/revert-links.py b/docs/revert-links.py index 192aca8fc7a..8d190479e31 100755 --- a/docs/revert-links.py +++ b/docs/revert-links.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 + def swap_prefix(file, old, new): - with open(file, 'r') as f: + with open(file, "r") as f: lines = f.read() lines = lines.replace(old, new) - with open(file, 'wt') as f: + with open(file, "wt") as f: f.write(lines) -swap_prefix('../README.md', '(../', '(docs/') -swap_prefix('../README.md', '```{mermaid}\n:align: center\n', '```mermaid') +swap_prefix("../README.md", "(../", "(docs/") +swap_prefix("../README.md", "```{mermaid}\n:align: center\n", "```mermaid") diff --git a/docs/src/scripts/extract_utils.py b/docs/src/scripts/extract_utils.py index ee4643b9a06..c5036a05149 100644 --- a/docs/src/scripts/extract_utils.py +++ b/docs/src/scripts/extract_utils.py @@ -37,59 +37,68 @@ import re -def extract_headers(text, level = 1): + +def extract_headers(text, level=1): assert isinstance(level, int) and level >= 1 - pattern = r'^#{%d}\s+(.*)$' % level + pattern = r"^#{%d}\s+(.*)$" % level headers = re.findall(pattern, text, flags=re.MULTILINE) # TODO: Handle developer commands - #if "Useful Developer Commands" in headers: headers.remove("Useful Developer Commands") + # if "Useful Developer Commands" in headers: headers.remove("Useful Developer Commands") return headers + def extract_tcl_command(text): # objective is to extract tcl command from the synopsis - pattern = r'```tcl\s*(.*?)\s' + pattern = r"```tcl\s*(.*?)\s" headers = re.findall(pattern, text, flags=re.MULTILINE) return headers + def extract_description(text): # this is so that it always tries to match the longer headers first, to disambiguate - sorted_headers = sorted(extract_headers(text,3), key=len, reverse=True) + sorted_headers = sorted(extract_headers(text, 3), key=len, reverse=True) headers = "|".join(re.escape(x) for x in sorted_headers) - pattern = rf'### ({headers})(.*?)```tcl' + pattern = rf"### ({headers})(.*?)```tcl" custom_strings = re.findall(pattern, text, flags=re.DOTALL) return [custom_string[1].strip() for custom_string in custom_strings] + def extract_tcl_code(text): - pattern = r'```tcl\s+(.*?)```' + pattern = r"```tcl\s+(.*?)```" tcl_code_matches = re.findall(pattern, text, flags=re.DOTALL) # remove the last tcl match tcl_code_matches = [x for x in tcl_code_matches if "./test/gcd.tcl" not in x] return tcl_code_matches + def extract_arguments(text): # Goal is to extract all the text from the end of tcl code to the next ### header. # Returns options and arguments. level2 = extract_headers(text, 2) level3 = extract_headers(text, 3) - # form these 2 regex styles. + # form these 2 regex styles. # ### Header 1 {text} ### Header2; ### Header n-2 {text} ### Header n-1 # ### Header n {text} ## closest_level2_header - first = [rf'### ({level3[i]})(.*?)### ({level3[i+1]})' for i in range(len(level3) - 1)] + first = [ + rf"### ({level3[i]})(.*?)### ({level3[i+1]})" for i in range(len(level3) - 1) + ] # find the next closest level2 header to the last level3 header. - closest_level2 = [text.find(f"## {x}") - text.find(f"### {level3[-1]}") for x in level2] + closest_level2 = [ + text.find(f"## {x}") - text.find(f"### {level3[-1]}") for x in level2 + ] closest_level2_idx = [idx for idx, x in enumerate(closest_level2) if x > 0][0] # This will disambiguate cases where different level headers share the same name. second = [rf"### ({level3[-1]})(.*?)## ({level2[closest_level2_idx]})"] final_options, final_args = [], [] for idx, regex in enumerate(first + second): - match = re.findall(regex, text, flags = re.DOTALL) - #print(regex) + match = re.findall(regex, text, flags=re.DOTALL) + # print(regex) # get text until the next header - a = match[0][1] - a = a[a.find("#"):] + a = match[0][1] + a = a[a.find("#") :] options = a.split("####")[1:] if not options: final_options.append([]) @@ -103,15 +112,16 @@ def extract_arguments(text): final_args.append(tmp_arg) return final_options, final_args + def extract_tables(text): # Find all lines that start with "|" - table_pattern = r'^\s*\|.*$' + table_pattern = r"^\s*\|.*$" table_matches = re.findall(table_pattern, text, flags=re.MULTILINE) # Exclude matches containing HTML tags - table_matches = [table for table in table_matches if not re.search(r'<.*?>', table)] + table_matches = [table for table in table_matches if not re.search(r"<.*?>", table)] - # Remove text containing switch + # Remove text containing switch table_matches = [table for table in table_matches if "Switch Name" not in table] # Remove text containing "---" @@ -119,63 +129,76 @@ def extract_tables(text): return table_matches + def extract_help(text): # Logic now captures everything between { to earliest "proc" - help_pattern = re.compile(r''' + help_pattern = re.compile( + r""" sta::define_cmd_args\s+ "(.*?)"\s* (.*?)proc\s - ''', - re.VERBOSE | re.DOTALL) + """, + re.VERBOSE | re.DOTALL, + ) matches = re.findall(help_pattern, text) - + # remove nodocs (usually dev commands) - matches = [tup for tup in matches if ";#checkeroff" not in tup[1].replace(" ","")] + matches = [tup for tup in matches if ";#checkeroff" not in tup[1].replace(" ", "")] return matches + def extract_proc(text): - proc_pattern = re.compile(r''' + proc_pattern = re.compile( + r""" sta::parse_key_args\s+ "(.*?)"\s* args\s* (.*?keys.*?}) (.*?flags.*?}) (\s*;\s*\#\s*checker\s*off)? - ''', - re.VERBOSE | re.DOTALL) - + """, + re.VERBOSE | re.DOTALL, + ) + matches = re.findall(proc_pattern, text) # remove nodocs (usually dev commands) - matches = [tup for tup in matches if not tup[3].replace(" ","") == ";#checkeroff"] + matches = [tup for tup in matches if not tup[3].replace(" ", "") == ";#checkeroff"] return matches + def parse_switch(text): # Find the index of the 1nd and last occurrence of "|". Since some content might contain "|" switch_name = text.split("|")[1] switch_name = switch_name.replace("`", "").strip() second_pipe_index = text.find("|", text.find("|") + 1) last_pipe_index = text.rfind("|") - switch_description = text[second_pipe_index+1: last_pipe_index-1] + switch_description = text[second_pipe_index + 1 : last_pipe_index - 1] return switch_name, switch_description + def clean_whitespaces(text): tmp = text.strip().replace("\\", "").replace("\n", "") return " ".join(tmp.split()) + def clean_parse_syntax(text): - tmp = text.replace("keys", "").replace("flags", "")\ - .replace("{", "").replace("}", "") - return ' '.join([f'[{option}]' for option in tmp.split()]) + tmp = ( + text.replace("keys", "").replace("flags", "").replace("{", "").replace("}", "") + ) + return " ".join([f"[{option}]" for option in tmp.split()]) + def check_function_signatures(text1, text2): - set1 = set(re.findall(r'-\w+', text1)) - set2 = set(re.findall(r'-\w+', text2)) - if set1 == set2: return True + set1 = set(re.findall(r"-\w+", text1)) + set2 = set(re.findall(r"-\w+", text2)) + if set1 == set2: + return True print(sorted(list(set1))) print(sorted(list(set2))) return False + if __name__ == "__main__": - pass \ No newline at end of file + pass diff --git a/docs/src/scripts/manpage.py b/docs/src/scripts/manpage.py index c993d2969e8..935e4b9c779 100644 --- a/docs/src/scripts/manpage.py +++ b/docs/src/scripts/manpage.py @@ -33,16 +33,17 @@ ## ############################################################################### -# This code describes the ManPage class, which consists of the data classes +# This code describes the ManPage class, which consists of the data classes # as well as the code needed to write the roff-compatible manpage file. import io import datetime -# identify key section and stored in ManPage class. -class ManPage(): - def __init__(self, man_level = 2): - assert man_level in [2,3], "only writable for man2/man3" + +# identify key section and stored in ManPage class. +class ManPage: + def __init__(self, man_level=2): + assert man_level in [2, 3], "only writable for man2/man3" self.name = "" self.desc = "" self.synopsis = "" @@ -51,12 +52,12 @@ def __init__(self, man_level = 2): self.datetime = datetime.datetime.now().strftime("%y/%m/%d") self.man_level = f"man{man_level}" - def write_roff_file(self, dst_dir = './md/man2'): + def write_roff_file(self, dst_dir="./md/man2"): assert self.name, print("func name not set") assert self.desc, print("func desc not set") assert self.synopsis, print("func synopsis not set") # it is okay for a function to have no switches. - #assert self.switches, print("func switches not set") + # assert self.switches, print("func switches not set") filepath = f"{dst_dir}/{self.name}.md" with open(filepath, "w") as f: self.write_header(f) @@ -65,11 +66,12 @@ def write_roff_file(self, dst_dir = './md/man2'): self.write_description(f) self.write_options(f) self.write_arguments(f) - self.write_placeholder(f) #TODO. - + self.write_placeholder(f) # TODO. + def write_header(self, f): - assert isinstance(f, io.TextIOBase) and\ - f.writable(), "File pointer is not open for writing." + assert ( + isinstance(f, io.TextIOBase) and f.writable() + ), "File pointer is not open for writing." f.write(f"---\n") f.write(f"title: {self.name}({self.man_level[-1]})\n") @@ -77,29 +79,33 @@ def write_header(self, f): f.write(f"---\n") def write_name(self, f): - assert isinstance(f, io.TextIOBase) and\ - f.writable(), "File pointer is not open for writing." + assert ( + isinstance(f, io.TextIOBase) and f.writable() + ), "File pointer is not open for writing." f.write(f"\n# NAME\n\n") f.write(f"{self.name} - {' '.join(self.name.split('_'))}\n") def write_synopsis(self, f): - assert isinstance(f, io.TextIOBase) and\ - f.writable(), "File pointer is not open for writing." + assert ( + isinstance(f, io.TextIOBase) and f.writable() + ), "File pointer is not open for writing." f.write(f"\n# SYNOPSIS\n\n") f.write(f"{self.synopsis}\n") def write_description(self, f): - assert isinstance(f, io.TextIOBase) and\ - f.writable(), "File pointer is not open for writing." + assert ( + isinstance(f, io.TextIOBase) and f.writable() + ), "File pointer is not open for writing." f.write(f"\n# DESCRIPTION\n\n") f.write(f"{self.desc}\n") def write_options(self, f): - assert isinstance(f, io.TextIOBase) and\ - f.writable(), "File pointer is not open for writing." + assert ( + isinstance(f, io.TextIOBase) and f.writable() + ), "File pointer is not open for writing." f.write(f"\n# OPTIONS\n") if not self.switches: @@ -108,8 +114,9 @@ def write_options(self, f): f.write(f"\n`{key}`: {val}\n") def write_arguments(self, f): - assert isinstance(f, io.TextIOBase) and\ - f.writable(), "File pointer is not open for writing." + assert ( + isinstance(f, io.TextIOBase) and f.writable() + ), "File pointer is not open for writing." f.write(f"\n# ARGUMENTS\n") if not self.args: @@ -117,23 +124,27 @@ def write_arguments(self, f): for key, val in self.args.items(): f.write(f"\n`{key}`: {val}\n") - def write_placeholder(self, f): - assert isinstance(f, io.TextIOBase) and\ - f.writable(), "File pointer is not open for writing." + assert ( + isinstance(f, io.TextIOBase) and f.writable() + ), "File pointer is not open for writing." - # TODO: these are all not populated currently, not parseable from docs. - # TODO: Arguments can actually be parsed, but you need to preprocess the synopsis further. + # TODO: these are all not populated currently, not parseable from docs. + # TODO: Arguments can actually be parsed, but you need to preprocess the synopsis further. sections = ["EXAMPLES", "SEE ALSO"] for s in sections: f.write(f"\n# {s}\n") def write_copyright(self, f): - assert isinstance(f, io.TextIOBase) and\ - f.writable(), "File pointer is not open for writing." + assert ( + isinstance(f, io.TextIOBase) and f.writable() + ), "File pointer is not open for writing." f.write(f"\n# COPYRIGHT\n\n") - f.write(f"Copyright (c) 2024, The Regents of the University of California. All rights reserved.\n") + f.write( + f"Copyright (c) 2024, The Regents of the University of California. All rights reserved.\n" + ) + if __name__ == "__main__": - pass \ No newline at end of file + pass diff --git a/docs/src/scripts/md_roff_compat.py b/docs/src/scripts/md_roff_compat.py index f980e805947..a7d6c18cd3b 100644 --- a/docs/src/scripts/md_roff_compat.py +++ b/docs/src/scripts/md_roff_compat.py @@ -34,7 +34,7 @@ ############################################################################### # This code contains the scripts to convert the individual module READMEs -# into individual functions for man2 and man3 level. +# into individual functions for man2 and man3 level. import os from manpage import ManPage @@ -44,12 +44,39 @@ # Undocumented manpages. # sta: documentation is hosted elsewhere. (not currently in RTD also.) -# odb: documentation is hosted on doxygen. - -tools = ["ant", "cts", "dbSta", "dft", "dpl", "dpo", "drt",\ - "dst", "fin", "gpl", "grt", "gui", "ifp", "mpl",\ - "mpl2", "odb", "pad", "par", "pdn", "ppl", "psm",\ - "rcx", "rmp", "rsz", "sta", "stt", "tap", "upf", "utl"] +# odb: documentation is hosted on doxygen. + +tools = [ + "ant", + "cts", + "dbSta", + "dft", + "dpl", + "dpo", + "drt", + "dst", + "fin", + "gpl", + "grt", + "gui", + "ifp", + "mpl", + "mpl2", + "odb", + "pad", + "par", + "pdn", + "ppl", + "psm", + "rcx", + "rmp", + "rsz", + "sta", + "stt", + "tap", + "upf", + "utl", +] # Process man2 (except odb and sta) DEST_DIR2 = SRC_DIR = "./md/man2" @@ -59,10 +86,13 @@ # Process man3 (add extra path for ORD messages) SRC_DIR = "../src" DEST_DIR3 = "./md/man3" -exclude = ["sta"] #sta excluded because its format is different, and no severity level. +exclude = [ + "sta" +] # sta excluded because its format is different, and no severity level. docs3 = [f"{SRC_DIR}/{tool}/messages.txt" for tool in tools if tool not in exclude] docs3.append("../messages.txt") + def man2(path=DEST_DIR2): for doc in docs2: if not os.path.exists(doc): @@ -70,6 +100,7 @@ def man2(path=DEST_DIR2): continue man2_translate(doc, path) + def man2_translate(doc, path): with open(doc) as f: text = f.read() @@ -87,14 +118,21 @@ def man2_translate(doc, path): # arguments func_options, func_args = extract_arguments(text) - print(f'{os.path.basename(doc)}') - print(f'''Names: {len(func_names)},\ + print(f"{os.path.basename(doc)}") + print( + f"""Names: {len(func_names)},\ Desc: {len(func_descs)},\ Syn: {len(func_synopsis)},\ Options: {len(func_options)},\ - Args: {len(func_args)}''') - assert len(func_names) == len(func_descs) == len(func_synopsis) == len(func_options) == len(func_args),\ - f"""Counts for all 5 categories must match up.\n + Args: {len(func_args)}""" + ) + assert ( + len(func_names) + == len(func_descs) + == len(func_synopsis) + == len(func_options) + == len(func_args) + ), f"""Counts for all 5 categories must match up.\n {func_names}\n {func_descs}\n {func_synopsis}\n @@ -108,7 +146,7 @@ def man2_translate(doc, path): manpage.desc = func_descs[func_id] manpage.synopsis = func_synopsis[func_id] if func_options[func_id]: - # convert it to dict + # convert it to dict # TODO change this into a function. Or subsume under option/args parsing. switches_dict = {} for line in func_options[func_id]: @@ -127,6 +165,7 @@ def man2_translate(doc, path): manpage.write_roff_file(path) print("Man2 successfully compiled.") + def man3(path=DEST_DIR3): for doc in docs3: print(f"Processing {doc}") @@ -135,21 +174,29 @@ def man3(path=DEST_DIR3): continue man3_translate(doc, path) + def man3_translate(doc, path): with open(doc) as f: for line in f: parts = line.split() - module, num, message, level = parts[0], parts[1],\ - " ".join(parts[3:-2]), parts[-2] + module, num, message, level = ( + parts[0], + parts[1], + " ".join(parts[3:-2]), + parts[-2], + ) manpage = ManPage() manpage.name = f"{module}-{num}" - if "with-total" in manpage.name: print(parts); exit() + if "with-total" in manpage.name: + print(parts) + exit() manpage.synopsis = "N/A." manpage.desc = f"Type: {level}\n\n{message}" manpage.write_roff_file(path) print("Man3 successfully compiled.") + if __name__ == "__main__": man2() - man3() \ No newline at end of file + man3() diff --git a/docs/src/test/make_messages.py b/docs/src/test/make_messages.py index 6ca9399a040..900fc56c446 100644 --- a/docs/src/test/make_messages.py +++ b/docs/src/test/make_messages.py @@ -2,15 +2,20 @@ # Ensure path in OR root folder. current_path = os.path.abspath(__file__) -os.chdir(os.path.dirname(os.path.dirname(os.path.dirname((os.path.dirname(current_path)))))) +os.chdir( + os.path.dirname(os.path.dirname(os.path.dirname((os.path.dirname(current_path))))) +) # First run for OR local files. print("Writing OR local messages.") os.system("python3 ./etc/find_messages.py -d ./src -l > ./messages.txt") # List folders in ./src -for tool in os.listdir('./src'): - if os.path.isdir(os.path.join('./src', tool)): - if tool == 'sta': continue +for tool in os.listdir("./src"): + if os.path.isdir(os.path.join("./src", tool)): + if tool == "sta": + continue print(f"Writing {tool} local messages.") - os.system(f"python3 ./etc/find_messages.py -d ./src/{tool} > src/{tool}/messages.txt") \ No newline at end of file + os.system( + f"python3 ./etc/find_messages.py -d ./src/{tool} > src/{tool}/messages.txt" + ) diff --git a/docs/src/test/man_tcl_params.py b/docs/src/test/man_tcl_params.py index f7dc2cf9137..21ad8d01205 100644 --- a/docs/src/test/man_tcl_params.py +++ b/docs/src/test/man_tcl_params.py @@ -2,12 +2,16 @@ import glob import re from extract_utils import extract_tcl_code, extract_help, extract_proc -from extract_utils import clean_whitespaces, clean_parse_syntax, check_function_signatures +from extract_utils import ( + clean_whitespaces, + clean_parse_syntax, + check_function_signatures, +) # Test objective: Make sure similar output in all three: help, proc, and readme # Store results -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -16,18 +20,22 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns content = f.read() matches = extract_help(content) - + for match in matches: cmd, rest = match[0], match[1] cmd, rest = clean_whitespaces(cmd), clean_whitespaces(rest) @@ -43,7 +51,8 @@ proc_dict[cmd] = rest for path in glob.glob("./src/*/README.md"): - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -59,19 +68,29 @@ print("----------") print(cmd) isValid = True - if cmd not in help_dict: print("command not parsed in help_dict"); isValid = False - if cmd not in proc_dict: print("command not parsed in proc_dict"); isValid = False - if cmd not in readme_dict: print("command not parsed in readme_dict"); isValid = False + if cmd not in help_dict: + print("command not parsed in help_dict") + isValid = False + if cmd not in proc_dict: + print("command not parsed in proc_dict") + isValid = False + if cmd not in readme_dict: + print("command not parsed in readme_dict") + isValid = False # If invalid, don't need to test further. assert isValid, "Keys/flags are missing in one of Help/Proc/Readme." # Test switches here s1, s2, s3 = help_dict[cmd], proc_dict[cmd], readme_dict[cmd] - res1, res2, res3 = check_function_signatures(s1,s2), \ - check_function_signatures(s1,s3), \ - check_function_signatures(s2,s3) - assert res1 and res2 and res3, print(f"Help/Proc: {res1}\nHelp/Rdme: {res2}\nProc/Rdme: {res3}") + res1, res2, res3 = ( + check_function_signatures(s1, s2), + check_function_signatures(s1, s3), + check_function_signatures(s2, s3), + ) + assert res1 and res2 and res3, print( + f"Help/Proc: {res1}\nHelp/Rdme: {res2}\nProc/Rdme: {res3}" + ) succeeded += 1 print("Success.") diff --git a/docs/src/test/readme_check.py b/docs/src/test/readme_check.py index 9ee38371486..0ce3d709017 100644 --- a/docs/src/test/readme_check.py +++ b/docs/src/test/readme_check.py @@ -3,9 +3,9 @@ from md_roff_compat import man2, man3 # Test objective: if the translator script can run without errors for all the docs. -# goal is to return an error if the header cannot be extracted. +# goal is to return an error if the header cannot be extracted. -# check man2 +# check man2 SRC_BASE_PATH = "../src" DEST_BASE_PATH = "./md/man2" @@ -30,4 +30,4 @@ print(f"ERROR: README.md not found in {full_module_path}") # Run man2 command -man2() \ No newline at end of file +man2() diff --git a/docs/src/test/translator.py b/docs/src/test/translator.py index a60b9759c71..1a7152bc6fa 100644 --- a/docs/src/test/translator.py +++ b/docs/src/test/translator.py @@ -3,6 +3,6 @@ # Test objective: if the translator functionality works. res_dir = os.path.join(os.getcwd(), "results/docs") -os.makedirs(res_dir, exist_ok = True) +os.makedirs(res_dir, exist_ok=True) man2_translate("translator.md", res_dir) -man3_translate("translator.txt", res_dir) \ No newline at end of file +man3_translate("translator.txt", res_dir) diff --git a/etc/deltaDebug.py b/etc/deltaDebug.py index a0694d40ab9..10e88f2076f 100644 --- a/etc/deltaDebug.py +++ b/etc/deltaDebug.py @@ -35,47 +35,54 @@ persistence_range = [1, 2, 3, 4, 5, 6] cut_multiple = range(1, 128) -parser = argparse.ArgumentParser('Arguments for delta debugging') -parser.add_argument('--base_db_path', - type=str, - help='Path to the db file to perform the step on') -parser.add_argument('--error_string', - type=str, - help='The output that indicates target error has occurred') -parser.add_argument('--step', - type=str, - help='Command used to perform step on the input odb file') +parser = argparse.ArgumentParser("Arguments for delta debugging") parser.add_argument( - '--timeout', + "--base_db_path", type=str, help="Path to the db file to perform the step on" +) +parser.add_argument( + "--error_string", + type=str, + help="The output that indicates target error has occurred", +) +parser.add_argument( + "--step", type=str, help="Command used to perform step on the input odb file" +) +parser.add_argument( + "--timeout", type=int, default=None, - help='Specify initial timeout in seconds, default is to measure it') -parser.add_argument('--multiplier', - type=int, - default=cut_multiple[0], - choices=cut_multiple, - help='Multiply number of cuts with this number') -parser.add_argument('--persistence', - type=int, - default=persistence_range[0], - choices=persistence_range, - help='Indicates maximum input fragmentation; ' - 'fragments = 2^persistence; value in ' + - ', '.join(map(str, persistence_range))) + help="Specify initial timeout in seconds, default is to measure it", +) parser.add_argument( - '--use_stdout', - action='store_true', - help='Enables reading the error string from standard output') + "--multiplier", + type=int, + default=cut_multiple[0], + choices=cut_multiple, + help="Multiply number of cuts with this number", +) parser.add_argument( - '--exit_early_on_error', - action='store_true', - help= - 'Exit early on unrelated errors to speed things up, but risks exiting on false negatives.' + "--persistence", + type=int, + default=persistence_range[0], + choices=persistence_range, + help="Indicates maximum input fragmentation; " + "fragments = 2^persistence; value in " + ", ".join(map(str, persistence_range)), ) parser.add_argument( - '--dump_def', - action='store_true', - help='Determines whether to dumb def at each step in addition to the odb') + "--use_stdout", + action="store_true", + help="Enables reading the error string from standard output", +) +parser.add_argument( + "--exit_early_on_error", + action="store_true", + help="Exit early on unrelated errors to speed things up, but risks exiting on false negatives.", +) +parser.add_argument( + "--dump_def", + action="store_true", + help="Determines whether to dumb def at each step in addition to the odb", +) class cutLevel(enum.Enum): @@ -84,11 +91,11 @@ class cutLevel(enum.Enum): class deltaDebugger: - def __init__(self, opt): if not os.path.exists(opt.base_db_path): - raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), - opt.base_db_path) + raise FileNotFoundError( + errno.ENOENT, os.strerror(errno.ENOENT), opt.base_db_path + ) base_db_directory = os.path.dirname(opt.base_db_path) base_db_name = os.path.basename(opt.base_db_path) @@ -107,19 +114,22 @@ def __init__(self, opt): # Temporary file names to hold the original base_db file across the run self.original_base_db_file = os.path.join( - base_db_directory, f"deltaDebug_base_original_{base_db_name}") + base_db_directory, f"deltaDebug_base_original_{base_db_name}" + ) # Temporary file used to hold current base_db to ensure its integrity across cuts self.temp_base_db_file = os.path.join( - base_db_directory, f"deltaDebug_base_temp_{base_db_name}") + base_db_directory, f"deltaDebug_base_temp_{base_db_name}" + ) # The name of the result file after running deltaDebug self.deltaDebug_result_base_file = os.path.join( - base_db_directory, f"deltaDebug_base_result_{base_db_name}") + base_db_directory, f"deltaDebug_base_result_{base_db_name}" + ) # This determines whether design def shall be dumped or not self.dump_def = opt.dump_def - if (self.dump_def != 0): + if self.dump_def != 0: self.base_def_file = self.base_db_file[:-3] + "def" # A variable to hold the base_db @@ -156,7 +166,7 @@ def debug(self): sys.exit(1) for self.cut_level in (cutLevel.Insts, cutLevel.Nets): - while (True): + while True: err = None self.n = 2 # Initial Number of cuts @@ -168,7 +178,7 @@ def debug(self): while j == 0 or j < cuts: current_err, cuts = self.perform_step(cut_index=j) self.step_count += 1 - if (current_err is not None): + if current_err is not None: # Found the target error with the cut DB # # This is a suitable level of detail to look @@ -178,7 +188,7 @@ def debug(self): self.prepare_new_step() j += 1 - if (error_in_range is None): + if error_in_range is None: # Increase the granularity of the cut in case target # error not found self.n *= 2 @@ -216,21 +226,20 @@ def perform_step(self, cut_index=-1): # Cut the block with the given step index. # if cut index of -1 is provided it means # that no cut will be made. - if (cut_index != -1): + if cut_index != -1: self.cut_block(index=cut_index) # Write DB odb.write_db(self.base_db, self.base_db_file) - if (self.dump_def != 0): + if self.dump_def != 0: print("Writing def file") - odb.write_def(self.base_db.getChip().getBlock(), - self.base_def_file) + odb.write_def(self.base_db.getChip().getBlock(), self.base_def_file) cuts = self.get_cuts() if cut_index != -1 else None # Destroy the DB in memory to avoid being out-of-memory when # the step code is running - if (self.base_db is not None): + if self.base_db is not None: self.base_db.destroy(self.base_db) self.base_db = None @@ -242,7 +251,7 @@ def perform_step(self, cut_index=-1): # Handling timeout so as not to run the code for time # that is more than the original buggy code or a # buggy cut. - if (error_string is not None): + if error_string is not None: self.timeout = max(120, 1.2 * (end_time - start_time)) print(f"Error Code found: {error_string}") @@ -250,21 +259,25 @@ def perform_step(self, cut_index=-1): def run_command(self, command): poll_obj = select.poll() - if (self.use_stdout == 0): - process = subprocess.Popen(command, - shell=True, - stdout=subprocess.DEVNULL, - stderr=subprocess.PIPE, - encoding='utf-8', - preexec_fn=os.setsid) + if self.use_stdout == 0: + process = subprocess.Popen( + command, + shell=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE, + encoding="utf-8", + preexec_fn=os.setsid, + ) poll_obj.register(process.stderr, select.POLLIN) else: - process = subprocess.Popen(command, - shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - encoding='utf-8', - preexec_fn=os.setsid) + process = subprocess.Popen( + command, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding="utf-8", + preexec_fn=os.setsid, + ) poll_obj.register(process.stdout, select.POLLIN) start_time = time.time() @@ -278,32 +291,32 @@ def run_command(self, command): pass def poll(self, process, poll_obj, start_time): - output = '' + output = "" error_string = None # None for any error code other than self.error_string while True: # polling on the output of the process with a timeout of 1 second # to avoid busywaiting if poll_obj.poll(1): - if (self.use_stdout == 0): + if self.use_stdout == 0: output = process.stderr.readline() else: output = process.stdout.readline() - if (output.find(self.error_string) != -1): + if output.find(self.error_string) != -1: # found the error code that we are searching for. error_string = self.error_string break - elif (self.exit_early_on_error and output.find("ERROR") != -1): + elif self.exit_early_on_error and output.find("ERROR") != -1: # Found different error (bad cut) so we can just # terminate early and ignore this cut. break curr_time = time.time() - if ((curr_time - start_time) > self.timeout): + if (curr_time - start_time) > self.timeout: print(f"Step {self.step_count} timed out!", flush=True) break - if (process.poll() is not None): + if process.poll() is not None: break return error_string @@ -313,7 +326,7 @@ def poll(self, process, poll_obj, start_time): # cutting on it. def prepare_new_step(self): # Delete the old temporary db file - if (os.path.exists(self.temp_base_db_file)): + if os.path.exists(self.temp_base_db_file): os.remove(self.temp_base_db_file) # Rename the new base db file to the temp name to keep it from overwriting across the two steps cut if os.path.exists(self.base_db_file): @@ -350,27 +363,26 @@ def get_cuts(self): # whether to cut Insts or Nets. def cut_block(self, index=0): message = [f"Step {self.step_count}"] - if (self.cut_level == cutLevel.Insts): # Insts cut level + if self.cut_level == cutLevel.Insts: # Insts cut level elms = self.get_insts() message += ["Insts level debugging"] - elif (self.cut_level == cutLevel.Nets): # Nets cut level + elif self.cut_level == cutLevel.Nets: # Nets cut level elms = self.get_nets() message += ["Nets level debugging"] - message += [ - f"Insts {len(self.get_insts())}", f"Nets {len(self.get_nets())}" - ] + message += [f"Insts {len(self.get_insts())}", f"Nets {len(self.get_nets())}"] num_elms = len(elms) - assert (num_elms > 0) + assert num_elms > 0 cuts = self.get_cuts() start = num_elms * index // cuts end = num_elms * (index + 1) // cuts - cut_position_string = '#' * cuts - cut_position_string = (cut_position_string[:index] + 'C' + - cut_position_string[index + 1:]) + cut_position_string = "#" * cuts + cut_position_string = ( + cut_position_string[:index] + "C" + cut_position_string[index + 1 :] + ) message += [f"cut elements {end-start}"] message += [f"timeout {ceil(self.timeout/60.0)} minutes"] self.cut_elements(start, end) @@ -381,9 +393,9 @@ def cut_block(self, index=0): def cut_elements(self, start, end): block = self.base_db.getChip().getBlock() - if (self.cut_level == cutLevel.Insts): # Insts cut level + if self.cut_level == cutLevel.Insts: # Insts cut level elms = block.getInsts() - elif (self.cut_level == cutLevel.Nets): # Nets cut level + elif self.cut_level == cutLevel.Nets: # Nets cut level elms = block.getNets() for i in range(start, end): @@ -404,17 +416,18 @@ def remove_unused_masters(self): print(f"Removed {unused} masters.") odb.write_db(self.base_db, self.temp_base_db_file) - if (self.dump_def != 0): + if self.dump_def != 0: print("Writing def file") - odb.write_def(self.base_db.getChip().getBlock(), - self.temp_base_db_file[:-3] + "def") + odb.write_def( + self.base_db.getChip().getBlock(), self.temp_base_db_file[:-3] + "def" + ) - if (self.base_db is not None): + if self.base_db is not None: self.base_db.destroy(self.base_db) self.base_db = None -if __name__ == '__main__': +if __name__ == "__main__": opt = parser.parse_args() debugger = deltaDebugger(opt) debugger.debug() diff --git a/etc/find_messages.py b/etc/find_messages.py index 9416eb65d6a..5d854b2830f 100755 --- a/etc/find_messages.py +++ b/etc/find_messages.py @@ -46,33 +46,35 @@ import sys from collections import defaultdict + def parse_args(): parser = argparse.ArgumentParser( description=""" Find logger calls and report sorted message IDs. Also checks for duplicate message IDs. """, - formatter_class=argparse.ArgumentDefaultsHelpFormatter + formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) parser.add_argument( "-d", "--dir", default=os.getcwd(), - help="Directory to start the search for messages from" + help="Directory to start the search for messages from", ) parser.add_argument( "-l", "--local", - action='store_true', - help="Look only at the local files and don't recurse" + action="store_true", + help="Look only at the local files and don't recurse", ) args = parser.parse_args() return args + # The three capture groups are tool, id, and message. -warn_regexp_c = \ - re.compile(r''' +warn_regexp_c = re.compile( + r""" (?:->|\.) # deref (?Pinfo|warn|fileWarn|error|fileError|critical) # type \s*\(\s* # ( @@ -81,11 +83,13 @@ def parse_args(): (?P\d+) # id \s*,\s* # , (?P("((?:[^"\\]|\\.)+?\s*)+" )) # message - ''', re.VERBOSE | re.MULTILINE) + """, + re.VERBOSE | re.MULTILINE, +) -warn_regexp_tcl = \ - re.compile(r''' +warn_regexp_tcl = re.compile( + r""" (?Pinfo|warn|error|critical) # type \s+ # white-space (?P[A-Z]{3}|"[A-Z]{3}") # tool @@ -93,52 +97,58 @@ def parse_args(): (?P\d+) # id \s+ # white-space (?P"(?:[^"\\]|\\.)+?") # message - ''', re.VERBOSE | re.MULTILINE) + """, + re.VERBOSE | re.MULTILINE, +) + def scan_file(path, file_name, msgs): # Grab the file contents as a single string - with open(os.path.join(path, file_name), encoding='utf-8') as file_handle: + with open(os.path.join(path, file_name), encoding="utf-8") as file_handle: lines = file_handle.read() - warn_regexp = warn_regexp_tcl if file_name.endswith('tcl') \ - else warn_regexp_c + warn_regexp = warn_regexp_tcl if file_name.endswith("tcl") else warn_regexp_c - for match in re.finditer(warn_regexp, lines): - tool = match.group('tool').strip('"') - msg_id = int(match.group('id')) - key = '{} {:04d}'.format(tool, msg_id) + for match in re.finditer(warn_regexp, lines): + tool = match.group("tool").strip('"') + msg_id = int(match.group("id")) + key = "{} {:04d}".format(tool, msg_id) # remove quotes and join strings - message = match.group('message') + message = match.group("message") message = message.replace("\n", "") message = message.rstrip()[1:-1] - message = re.sub(r'"\s*"', '', message) - message_type = match.group('type').upper() + message = re.sub(r'"\s*"', "", message) + message_type = match.group("type").upper() # Count the newlines before the match starts - line_num = lines[0:match.start()].count('\n') + 1 - position = '{}:{}'.format(file_name, line_num) - file_link = os.path.join(path, file_name).strip('../').replace('\\','/') - file_link = 'https://github.com/The-OpenROAD-Project/OpenROAD/tree/master/{}#L{}'.format( - file_link, line_num) - value = '{:25} {} {} {}'.format(position, message, message_type, file_link) + line_num = lines[0 : match.start()].count("\n") + 1 + position = "{}:{}".format(file_name, line_num) + file_link = os.path.join(path, file_name).strip("../").replace("\\", "/") + file_link = "https://github.com/The-OpenROAD-Project/OpenROAD/tree/master/{}#L{}".format( + file_link, line_num + ) + value = "{:25} {} {} {}".format(position, message, message_type, file_link) msgs[key].add(value) + def scan_dir(path, files, msgs): for file_name in files: - if re.search(r'\.(c|cc|cpp|cxx|h|hh|yy|ll|i|tcl)$', file_name): + if re.search(r"\.(c|cc|cpp|cxx|h|hh|yy|ll|i|tcl)$", file_name): scan_file(path, file_name, msgs) + def main(): args = parse_args() # "tool id" -> "file:line message" msgs = defaultdict(set) - if args.local: # no recursion - files = [os.path.basename(file) - for file in glob.glob(os.path.join(args.dir, '*'))] + if args.local: # no recursion + files = [ + os.path.basename(file) for file in glob.glob(os.path.join(args.dir, "*")) + ] scan_dir(args.dir, files, msgs) else: for path, _, files in os.walk(args.dir): @@ -158,8 +168,12 @@ def main(): next_free_integer = int(number) + 1 while next_free_integer in set_numbers[set_name]: next_free_integer += 1 - print('Error: {} used {} times, next free message id is {}'.format(key, count, next_free_integer), - file=sys.stderr) + print( + "Error: {} used {} times, next free message id is {}".format( + key, count, next_free_integer + ), + file=sys.stderr, + ) has_error = True for key in sorted(msgs): @@ -169,5 +183,6 @@ def main(): if has_error: sys.exit(1) + if __name__ == "__main__": main() diff --git a/etc/test_deltaDebug.py b/etc/test_deltaDebug.py index 2e8d1a42020..6d88aa4f00f 100644 --- a/etc/test_deltaDebug.py +++ b/etc/test_deltaDebug.py @@ -4,22 +4,24 @@ from unittest.mock import patch, MagicMock odb = MagicMock() -sys.modules['odb'] = odb +sys.modules["odb"] = odb openroad = MagicMock() -sys.modules['openroad'] = openroad +sys.modules["openroad"] = openroad import deltaDebug -default_args = argparse.Namespace(persistence=4, - use_stdout=True, - error_string="Iter: 100", - base_db_path="/dummy/path/base.db", - base_db_file=None, - original_db_file=None, - step="dummy_step", - timeout=100, - multiplier=1, - exit_early_on_error=True, - dump_def=True) +default_args = argparse.Namespace( + persistence=4, + use_stdout=True, + error_string="Iter: 100", + base_db_path="/dummy/path/base.db", + base_db_file=None, + original_db_file=None, + step="dummy_step", + timeout=100, + multiplier=1, + exit_early_on_error=True, + dump_def=True, +) def mock_get_insts(mock_self): @@ -50,7 +52,11 @@ def mock_perform_step(mock_self, cut_index=-1): def mock_cut_elements(mock_self, start, end): mock_self.insts_saved = list(mock_self.insts) mock_self.nets_saved = list(mock_self.nets) - elements = mock_self.insts if mock_self.cut_level == deltaDebug.cutLevel.Insts else mock_self.nets + elements = ( + mock_self.insts + if mock_self.cut_level == deltaDebug.cutLevel.Insts + else mock_self.nets + ) del elements[start:end] @@ -59,29 +65,30 @@ def mock_prepare_new_step(mock_self): class TestDeltaDebug(TestCase): - - @patch('os.path.exists', lambda x: True) + @patch("os.path.exists", lambda x: True) def setUp(self): args = default_args - self.perform_step_patch = patch.object(deltaDebug.deltaDebugger, - 'perform_step', - wraps=mock_perform_step, - autospec=True) - self.get_insts_patch = patch.object(deltaDebug.deltaDebugger, - 'get_insts', - autospec=True) - self.get_nets_patch = patch.object(deltaDebug.deltaDebugger, - 'get_nets', - autospec=True) - self.cut_elements = patch.object(deltaDebug.deltaDebugger, - 'cut_elements', - autospec=True) - self.prepare_new_step = patch.object(deltaDebug.deltaDebugger, - 'prepare_new_step', - autospec=True) - self.shutil_copy_patch = patch('shutil.copy') - self.os_rename_patch = patch('os.rename') + self.perform_step_patch = patch.object( + deltaDebug.deltaDebugger, + "perform_step", + wraps=mock_perform_step, + autospec=True, + ) + self.get_insts_patch = patch.object( + deltaDebug.deltaDebugger, "get_insts", autospec=True + ) + self.get_nets_patch = patch.object( + deltaDebug.deltaDebugger, "get_nets", autospec=True + ) + self.cut_elements = patch.object( + deltaDebug.deltaDebugger, "cut_elements", autospec=True + ) + self.prepare_new_step = patch.object( + deltaDebug.deltaDebugger, "prepare_new_step", autospec=True + ) + self.shutil_copy_patch = patch("shutil.copy") + self.os_rename_patch = patch("os.rename") self.mock_perform_step = self.perform_step_patch.start() self.mock_get_insts = self.get_insts_patch.start() @@ -114,8 +121,9 @@ def test_pruned_to_one(self): error_nets = [7] def check_error(insts, nets): - return (any(map(lambda x: x in error_insts, insts)) - and any(map(lambda x: x in error_nets, nets))) + return any(map(lambda x: x in error_insts, insts)) and any( + map(lambda x: x in error_nets, nets) + ) self.debugger.check_error = check_error self.debugger.persistence = 4 @@ -130,8 +138,9 @@ def test_lots_down_to_one(self): error_nets = set(range(70000, 80000)) def check_error(insts, nets): - return (any(map(lambda x: x in error_insts, insts)) - and any(map(lambda x: x in error_nets, nets))) + return any(map(lambda x: x in error_insts, insts)) and any( + map(lambda x: x in error_nets, nets) + ) self.debugger.check_error = check_error self.debugger.persistence = 4 @@ -146,10 +155,12 @@ def test_minimum_errors(self): error_nets = set(range(700, 751)) def check_error(insts, nets): - return (any(map(lambda x: x in error_insts, insts)) - and len(insts) >= 100 - and any(map(lambda x: x in error_nets, nets)) - and len(nets) >= 75) + return ( + any(map(lambda x: x in error_insts, insts)) + and len(insts) >= 100 + and any(map(lambda x: x in error_nets, nets)) + and len(nets) >= 75 + ) self.debugger.check_error = check_error self.debugger.persistence = 6 @@ -164,8 +175,9 @@ def test_all_in_a_range(self): error_nets = set(range(70, 90)) def check_error(insts, nets): - return (all(map(lambda x: x in insts, error_insts)) - and all(map(lambda x: x in nets, error_nets))) + return all(map(lambda x: x in insts, error_insts)) and all( + map(lambda x: x in nets, error_nets) + ) self.debugger.check_error = check_error self.debugger.persistence = 6 @@ -179,8 +191,7 @@ def test_no_insts(self): error_nets = set(range(70, 90)) def check_error(insts, nets): - return (len(insts) >= 0 - and all(map(lambda x: x in nets, error_nets))) + return len(insts) >= 0 and all(map(lambda x: x in nets, error_nets)) self.debugger.check_error = check_error self.debugger.persistence = 6 @@ -194,8 +205,7 @@ def test_no_nets(self): error_insts = set(range(70, 90)) def check_error(insts, nets): - return (len(nets) >= 0 - and all(map(lambda x: x in insts, error_insts))) + return len(nets) >= 0 and all(map(lambda x: x in insts, error_insts)) self.debugger.check_error = check_error self.debugger.persistence = 6 diff --git a/src/ant/test/ant_man_tcl_check.py b/src/ant/test/ant_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/ant/test/ant_man_tcl_check.py +++ b/src/ant/test/ant_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/ant/test/ant_readme_msgs_check.py b/src/ant/test/ant_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/ant/test/ant_readme_msgs_check.py +++ b/src/ant/test/ant_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/ant/test/ant_report.py b/src/ant/test/ant_report.py index 0094bab534e..ddd4cfe1ce5 100644 --- a/src/ant/test/ant_report.py +++ b/src/ant/test/ant_report.py @@ -1,4 +1,5 @@ import helpers + # A minimal LEF file that has been modified to include particular # antenna values for testing from openroad import Design, Tech diff --git a/src/cts/test/balance_levels.py b/src/cts/test/balance_levels.py index c285c0505f2..cd6426d8754 100644 --- a/src/cts/test/balance_levels.py +++ b/src/cts/test/balance_levels.py @@ -14,18 +14,19 @@ design.evalTclString("create_clock -period 5 clk") design.evalTclString("set_wire_rc -clock -layer metal5") -cts_aux.clock_tree_synthesis(design, - root_buf="CLKBUF_X3", - buf_list="CLKBUF_X3", - wire_unit=20, - sink_clustering_enable=True, - distance_between_buffers=100.0, - sink_clustering_size=5, - sink_clustering_max_diameter=60.0, - balance_levels=True, - num_static_layers=1, - obstruction_aware=True - ) +cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + wire_unit=20, + sink_clustering_enable=True, + distance_between_buffers=100.0, + sink_clustering_size=5, + sink_clustering_max_diameter=60.0, + balance_levels=True, + num_static_layers=1, + obstruction_aware=True, +) def_file = helpers.make_result_file("balance_levels.def") design.writeDef(def_file) diff --git a/src/cts/test/check_buffers.py b/src/cts/test/check_buffers.py index 76c0103a383..af03e152214 100644 --- a/src/cts/test/check_buffers.py +++ b/src/cts/test/check_buffers.py @@ -13,20 +13,21 @@ design.evalTclString("create_clock -period 5 clk") design.evalTclString("set_wire_rc -clock -layer metal5") -cts_aux.clock_tree_synthesis(design, - root_buf="CLKBUF_X3", - buf_list="CLKBUF_X3", - wire_unit=20, - sink_clustering_enable=True, - distance_between_buffers=100.0, - sink_clustering_size=10, - sink_clustering_max_diameter=60.0, - num_static_layers=1, - obstruction_aware=True - ) +cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + wire_unit=20, + sink_clustering_enable=True, + distance_between_buffers=100.0, + sink_clustering_size=10, + sink_clustering_max_diameter=60.0, + num_static_layers=1, + obstruction_aware=True, +) # This is only for checking clock tree results and not testing per se -cmd_block = ''' +cmd_block = """ set unconnected_buffers 0 foreach buf [get_cells clkbuf_*_clk] { set buf_name [get_name $buf] @@ -37,5 +38,5 @@ } } puts "Found $unconnected_buffers unconnected buffers." -''' +""" design.evalTclString(cmd_block) diff --git a/src/cts/test/check_charBuf.py b/src/cts/test/check_charBuf.py index ced8311601b..30a91b126e4 100644 --- a/src/cts/test/check_charBuf.py +++ b/src/cts/test/check_charBuf.py @@ -12,7 +12,10 @@ design.evalTclString("create_clock -period 5 clk") design.evalTclString("set_wire_rc -clock -layer metal3") -cts_aux.clock_tree_synthesis(design, root_buf="CLKBUF_X3", - buf_list="CLKBUF_X3 CLKBUF_X2 BUF_X4 CLKBUF_X1", - wire_unit=20, - obstruction_aware=True) +cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3 CLKBUF_X2 BUF_X4 CLKBUF_X1", + wire_unit=20, + obstruction_aware=True, +) diff --git a/src/cts/test/check_wire_rc_cts.py b/src/cts/test/check_wire_rc_cts.py index d77dc2ded7b..e14acffe84e 100644 --- a/src/cts/test/check_wire_rc_cts.py +++ b/src/cts/test/check_wire_rc_cts.py @@ -13,19 +13,20 @@ design.evalTclString("create_clock -period 5 clk") design.evalTclString("set_wire_rc -clock -layer metal5") -cts_aux.clock_tree_synthesis(design, - root_buf="CLKBUF_X3", - buf_list="CLKBUF_X3", - sink_clustering_enable=True, - distance_between_buffers=100.0, - sink_clustering_size=10, - sink_clustering_max_diameter=60.0, - num_static_layers=1, - obstruction_aware=True - ) +cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + sink_clustering_enable=True, + distance_between_buffers=100.0, + sink_clustering_size=10, + sink_clustering_max_diameter=60.0, + num_static_layers=1, + obstruction_aware=True, +) # This is only for checking clock tree results and not testing per se -cmd_block = ''' +cmd_block = """ set unconnected_buffers 0 foreach buf [get_cells clkbuf_*_clk] { set buf_name [get_name $buf] @@ -36,5 +37,5 @@ } } puts "#unconnected buffers: $unconnected_buffers" -''' +""" design.evalTclString(cmd_block) diff --git a/src/cts/test/cts_aux.py b/src/cts/test/cts_aux.py index 2b2fd7b6a58..058eda0712b 100644 --- a/src/cts/test/cts_aux.py +++ b/src/cts/test/cts_aux.py @@ -34,27 +34,29 @@ ############################################################################### from openroad import Design, Tech -def clock_tree_synthesis(design, *, - wire_unit=None, - buf_list=None, - root_buf=None, - clk_nets=None, - tree_buf=None, - distance_between_buffers=None, - branching_point_buffers_distance=None, - clustering_exponent=None, - clustering_unbalance_ratio=None, - sink_clustering_size=None, - sink_clustering_max_diameter=None, - sink_clustering_enable=False, - balance_levels=False, - sink_clustering_levels=None, - num_static_layers=None, - sink_clustering_buffer=None, - obstruction_aware=False, - apply_ndr=False - ): +def clock_tree_synthesis( + design, + *, + wire_unit=None, + buf_list=None, + root_buf=None, + clk_nets=None, + tree_buf=None, + distance_between_buffers=None, + branching_point_buffers_distance=None, + clustering_exponent=None, + clustering_unbalance_ratio=None, + sink_clustering_size=None, + sink_clustering_max_diameter=None, + sink_clustering_enable=False, + balance_levels=False, + sink_clustering_levels=None, + num_static_layers=None, + sink_clustering_buffer=None, + obstruction_aware=False, + apply_ndr=False, +): cts = design.getTritonCts() parms = cts.getParms() @@ -63,7 +65,7 @@ def clock_tree_synthesis(design, *, parms.setBalanceLevels(balance_levels) parms.setObstructionAware(obstruction_aware) parms.setApplyNDR(apply_ndr) - + if is_pos_int(sink_clustering_size): parms.setSinkClusteringSize(sink_clustering_size) @@ -82,7 +84,9 @@ def clock_tree_synthesis(design, *, if is_pos_float(branching_point_buffers_distance): parms.setVertexBuffersEnabled(True) - parms.setVertexBufferDistance(design.micronToDBU(branching_point_buffers_distance)) + parms.setVertexBufferDistance( + design.micronToDBU(branching_point_buffers_distance) + ) if is_pos_int(clustering_exponent): parms.setClusteringPower(clustering_exponent) @@ -132,7 +136,7 @@ def report_cts(design, out_file=None): def is_pos_int(x): if x == None: return False - elif isinstance(x, int) and x > 0 : + elif isinstance(x, int) and x > 0: return True else: utl.error(utl.CTS, 605, f"TypeError: {x} is not a postive integer") diff --git a/src/cts/test/cts_helpers.py b/src/cts/test/cts_helpers.py index 113666475bb..e3df61ac097 100644 --- a/src/cts/test/cts_helpers.py +++ b/src/cts/test/cts_helpers.py @@ -2,7 +2,7 @@ # Make an array of FF and connect all their clocks to a single # top level terminal -make_array = ''' +make_array = """ proc make_array { sinks { width 200000 } { height 200000 } \ { clock_gate -1 } } { set db [ord::get_db] @@ -63,4 +63,4 @@ } return $block } -''' +""" diff --git a/src/cts/test/cts_man_tcl_check.py b/src/cts/test/cts_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/cts/test/cts_man_tcl_check.py +++ b/src/cts/test/cts_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/cts/test/cts_readme_msgs_check.py b/src/cts/test/cts_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/cts/test/cts_readme_msgs_check.py +++ b/src/cts/test/cts_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/cts/test/find_clock.py b/src/cts/test/find_clock.py index 79e258dea92..e983b169867 100644 --- a/src/cts/test/find_clock.py +++ b/src/cts/test/find_clock.py @@ -10,9 +10,12 @@ design.readDef("16sinks.def") design.evalTclString("create_clock -period 5 clk") -#design.evalTclString("set_wire_rc -clock -layer metal5") +# design.evalTclString("set_wire_rc -clock -layer metal5") -cts_aux.clock_tree_synthesis(design, root_buf="CLKBUF_X3", - buf_list="CLKBUF_X3", - wire_unit=20, - obstruction_aware=True) +cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + wire_unit=20, + obstruction_aware=True, +) diff --git a/src/cts/test/max_cap.py b/src/cts/test/max_cap.py index 425e1b29b8b..56010761778 100644 --- a/src/cts/test/max_cap.py +++ b/src/cts/test/max_cap.py @@ -23,19 +23,22 @@ design.readDef(def_file) os.remove(def_file) -tcl_strg2 = '''create_clock -period 5 clk1 +tcl_strg2 = """create_clock -period 5 clk1 source "sky130hs/sky130hs.rc" set_wire_rc -signal -layer met2 -set_wire_rc -clock -layer met3''' +set_wire_rc -clock -layer met3""" design.evalTclString(tcl_strg2) -cts_aux.clock_tree_synthesis(design, root_buf="sky130_fd_sc_hs__clkbuf_1", - buf_list="sky130_fd_sc_hs__clkbuf_1", - obstruction_aware=True) +cts_aux.clock_tree_synthesis( + design, + root_buf="sky130_fd_sc_hs__clkbuf_1", + buf_list="sky130_fd_sc_hs__clkbuf_1", + obstruction_aware=True, +) -tcl_strg3 = '''set_propagated_clock clk1 +tcl_strg3 = """set_propagated_clock clk1 estimate_parasitics -placement -report_check_types -max_cap -max_slew -net [get_net -of_object [get_pin r1/CLK]]''' +report_check_types -max_cap -max_slew -net [get_net -of_object [get_pin r1/CLK]]""" design.evalTclString(tcl_strg3) diff --git a/src/cts/test/no_clocks.py b/src/cts/test/no_clocks.py index ff0a59cc79f..701e7da3ffd 100644 --- a/src/cts/test/no_clocks.py +++ b/src/cts/test/no_clocks.py @@ -12,9 +12,14 @@ design.evalTclString("set_wire_rc -clock -layer metal5") try: - cts_aux.clock_tree_synthesis(design, root_buf="CLKBUF_X3", buf_list="CLKBUF_X3", - wire_unit=20, obstruction_aware=True) + cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + wire_unit=20, + obstruction_aware=True, + ) except Exception as inst: print(inst.args[0]) -print("") # so we match, tcl prints out extra line, +print("") # so we match, tcl prints out extra line, diff --git a/src/cts/test/no_sinks.py b/src/cts/test/no_sinks.py index fa1af893954..cbd2c1508ec 100644 --- a/src/cts/test/no_sinks.py +++ b/src/cts/test/no_sinks.py @@ -13,9 +13,15 @@ design.evalTclString("set_wire_rc -clock -layer metal5") try: - cts_aux.clock_tree_synthesis(design, root_buf="CLKBUF_X3", buf_list="CLKBUF_X3", - wire_unit=20, clk_nets="clk", obstruction_aware=True) + cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + wire_unit=20, + clk_nets="clk", + obstruction_aware=True, + ) except Exception as inst: print(inst.args[0]) -print("") # so we match, tcl prints out extra line, +print("") # so we match, tcl prints out extra line, diff --git a/src/cts/test/simple_test.py b/src/cts/test/simple_test.py index f00c3ae04aa..d40432bbad2 100644 --- a/src/cts/test/simple_test.py +++ b/src/cts/test/simple_test.py @@ -12,12 +12,15 @@ design.evalTclString("create_clock -period 5 clk") design.evalTclString("set_wire_rc -clock -layer metal3") -cts_aux.clock_tree_synthesis(design, root_buf="CLKBUF_X3", buf_list="CLKBUF_X3", - wire_unit=20, obstruction_aware=True, apply_ndr=True) +cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + wire_unit=20, + obstruction_aware=True, + apply_ndr=True, +) def_file = helpers.make_result_file("simple_test_out.def") design.writeDef(def_file) helpers.diff_files(def_file, "simple_test_out.defok") - - - diff --git a/src/cts/test/simple_test_clustered.py b/src/cts/test/simple_test_clustered.py index 0bcab47d9db..06117b0e0f1 100644 --- a/src/cts/test/simple_test_clustered.py +++ b/src/cts/test/simple_test_clustered.py @@ -14,14 +14,15 @@ design.evalTclString("create_clock -period 5 clk") design.evalTclString("set_wire_rc -clock -layer metal5") -cts_aux.clock_tree_synthesis(design, - root_buf="CLKBUF_X3", - buf_list="CLKBUF_X3", - wire_unit=20, - sink_clustering_enable=True, - distance_between_buffers=100.0, - sink_clustering_size=10, - sink_clustering_max_diameter=60.0, - num_static_layers=1, - obstruction_aware=True - ) +cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + wire_unit=20, + sink_clustering_enable=True, + distance_between_buffers=100.0, + sink_clustering_size=10, + sink_clustering_max_diameter=60.0, + num_static_layers=1, + obstruction_aware=True, +) diff --git a/src/cts/test/simple_test_clustered_max_cap.py b/src/cts/test/simple_test_clustered_max_cap.py index bd2db84b9f7..bf11da54b06 100644 --- a/src/cts/test/simple_test_clustered_max_cap.py +++ b/src/cts/test/simple_test_clustered_max_cap.py @@ -15,12 +15,13 @@ design.evalTclString("set_wire_rc -signal -layer metal3") design.evalTclString("set_wire_rc -clock -layer metal5") -cts_aux.clock_tree_synthesis(design, - root_buf="CLKBUF_X3", - buf_list="CLKBUF_X3", - wire_unit=20, - sink_clustering_enable=True, - distance_between_buffers=100.0, - num_static_layers=1, - obstruction_aware=True - ) +cts_aux.clock_tree_synthesis( + design, + root_buf="CLKBUF_X3", + buf_list="CLKBUF_X3", + wire_unit=20, + sink_clustering_enable=True, + distance_between_buffers=100.0, + num_static_layers=1, + obstruction_aware=True, +) diff --git a/src/dft/test/dft_man_tcl_check.py b/src/dft/test/dft_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/dft/test/dft_man_tcl_check.py +++ b/src/dft/test/dft_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/dft/test/dft_readme_msgs_check.py b/src/dft/test/dft_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/dft/test/dft_readme_msgs_check.py +++ b/src/dft/test/dft_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/dpl/test/dpl_man_tcl_check.py b/src/dpl/test/dpl_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/dpl/test/dpl_man_tcl_check.py +++ b/src/dpl/test/dpl_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/dpl/test/dpl_readme_msgs_check.py b/src/dpl/test/dpl_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/dpl/test/dpl_readme_msgs_check.py +++ b/src/dpl/test/dpl_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/dpl/test/fillers3.py b/src/dpl/test/fillers3.py index 2786379673e..b6d7483876e 100644 --- a/src/dpl/test/fillers3.py +++ b/src/dpl/test/fillers3.py @@ -8,6 +8,6 @@ design.readDef("simple01.def") dpl_aux.detailed_placement(design) -masters=["FILLCELL_X1", "FILLCELL_X2"] +masters = ["FILLCELL_X1", "FILLCELL_X2"] dpl_aux.filler_placement(design, masters=masters) design.getOpendp().checkPlacement(False) diff --git a/src/dpl/test/fillers4.py b/src/dpl/test/fillers4.py index 18e1ee02fb2..8051b197118 100644 --- a/src/dpl/test/fillers4.py +++ b/src/dpl/test/fillers4.py @@ -9,6 +9,6 @@ design.readDef("fillers4.def") dpl_aux.detailed_placement(design, disallow_one_site_gaps=True) -masters=["FILLCELL_X2", "FILLCELL_X3", "FILLCELL_X4", "FILLCELL_X8"] +masters = ["FILLCELL_X2", "FILLCELL_X3", "FILLCELL_X4", "FILLCELL_X8"] dpl_aux.filler_placement(design, masters=masters) design.getOpendp().checkPlacement(False) diff --git a/src/dpl/test/ibex.py b/src/dpl/test/ibex.py index e27d7e62633..b666a307fbd 100644 --- a/src/dpl/test/ibex.py +++ b/src/dpl/test/ibex.py @@ -1,4 +1,3 @@ - from openroad import Design, Tech import helpers import dpl_aux diff --git a/src/drt/test/aes_nangate45.py b/src/drt/test/aes_nangate45.py index b9dc494c1b2..1664b2eb9d6 100644 --- a/src/drt/test/aes_nangate45.py +++ b/src/drt/test/aes_nangate45.py @@ -1,7 +1,7 @@ -# Since aes_nangate45 is not in the regressions that are run (no ok or defok +# Since aes_nangate45 is not in the regressions that are run (no ok or defok # file, and multiple places is code where they print run dependent info # directly to stdout without going through the logging interface) this Python -# regression is here as an example only (note the use of the global router +# regression is here as an example only (note the use of the global router # for reading in the guide file and also using tech to set the number of # threads for multi-threaded execution) from openroad import Design, Tech, set_thread_count @@ -20,9 +20,12 @@ gr.readGuides("aes_nangate45.route_guide") set_thread_count(4) -drt_aux.detailed_route(design, output_drc="results/aes_nangate45.output.drc-py.rpt", - output_maze="results/aes_nangate45.output.maze-py.log", - verbose=1) +drt_aux.detailed_route( + design, + output_drc="results/aes_nangate45.output.drc-py.rpt", + output_maze="results/aes_nangate45.output.maze-py.log", + verbose=1, +) def_file = helpers.make_result_file("aes_nangate45.def") design.writeDef(def_file) diff --git a/src/drt/test/drt_aux.py b/src/drt/test/drt_aux.py index 377cdf4a623..e140654feb8 100644 --- a/src/drt/test/drt_aux.py +++ b/src/drt/test/drt_aux.py @@ -1,35 +1,38 @@ import drt import utl + # NOTE: currently no error checking is done on the inputs as it is # done for the tcl version of detailed_route. If we want to use this # as a basis for a Python api, we will have to add that here -def detailed_route(design, *, - output_maze="", - output_drc="", - output_cmap="", - output_guide_coverage="", - db_process_node="", - disable_via_gen=False, - droute_end_iter=-1, - via_in_pin_bottom_layer="", - via_in_pin_top_layer="", - or_seed=-1, - or_k=0, - bottom_routing_layer="", - top_routing_layer="", - verbose=1, - distributed=False, - remote_host=None, - remote_port=None, - shared_volume=None, - cloud_size=None, - clean_patches=False, - no_pin_access=False, - single_step_dr=False, - min_access_points=-1, - save_guide_updates=False): - +def detailed_route( + design, + *, + output_maze="", + output_drc="", + output_cmap="", + output_guide_coverage="", + db_process_node="", + disable_via_gen=False, + droute_end_iter=-1, + via_in_pin_bottom_layer="", + via_in_pin_top_layer="", + or_seed=-1, + or_k=0, + bottom_routing_layer="", + top_routing_layer="", + verbose=1, + distributed=False, + remote_host=None, + remote_port=None, + shared_volume=None, + cloud_size=None, + clean_patches=False, + no_pin_access=False, + single_step_dr=False, + min_access_points=-1, + save_guide_updates=False +): router = design.getTritonRoute() params = drt.ParamStruct() params.outputMazeFile = output_maze @@ -56,13 +59,30 @@ def detailed_route(design, *, router.main() -def step_dr(design, size, offset, mazeEndIter, workerDRCCost, - workerMarkerCost, workerFixedShapeCost, - workerMarkerDecay, ripupMode, followGuide): +def step_dr( + design, + size, + offset, + mazeEndIter, + workerDRCCost, + workerMarkerCost, + workerFixedShapeCost, + workerMarkerDecay, + ripupMode, + followGuide, +): router = design.getTritonRoute() - router.stepDR(size, offset, mazeEndIter, workerDRCCost, - workerMarkerCost, workerFixedShapeCost, - workerMarkerDecay, ripupMode, followGuide) + router.stepDR( + size, + offset, + mazeEndIter, + workerDRCCost, + workerMarkerCost, + workerFixedShapeCost, + workerMarkerDecay, + ripupMode, + followGuide, + ) def step_end(design): diff --git a/src/drt/test/drt_man_tcl_check.py b/src/drt/test/drt_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/drt/test/drt_man_tcl_check.py +++ b/src/drt/test/drt_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/drt/test/drt_readme_msgs_check.py b/src/drt/test/drt_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/drt/test/drt_readme_msgs_check.py +++ b/src/drt/test/drt_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/drt/test/ispd18_sample.py b/src/drt/test/ispd18_sample.py index fd01951e5e2..8295327f776 100644 --- a/src/drt/test/ispd18_sample.py +++ b/src/drt/test/ispd18_sample.py @@ -10,11 +10,13 @@ gr = design.getGlobalRouter() gr.readGuides("testcase/ispd18_sample/ispd18_sample.input.guide") -drt_aux.detailed_route(design, - output_drc="results/ispd18_sample.output.drc.rpt", - output_maze="results/ispd18_sample.output.maze.log", - output_guide_coverage="results/ispd18_sample.coverage.csv", - verbose=0) +drt_aux.detailed_route( + design, + output_drc="results/ispd18_sample.output.drc.rpt", + output_maze="results/ispd18_sample.output.maze.log", + output_guide_coverage="results/ispd18_sample.coverage.csv", + verbose=0, +) def_file = helpers.make_result_file("ispd18_sample.def") design.writeDef(def_file) diff --git a/src/drt/test/run-ispd.py b/src/drt/test/run-ispd.py index 2155d991475..1710aa95f72 100755 --- a/src/drt/test/run-ispd.py +++ b/src/drt/test/run-ispd.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -''' +""" This runs the ISPD 18 & 19 routing benchmarks. GNU Parallel is used for parallelism over many designs. This is used by Jenkins for nightly OpenROAD testing. -''' +""" import argparse import fnmatch @@ -18,41 +18,32 @@ parser = argparse.ArgumentParser( prog="run-ispd", description="Run the ISPD routing benchamrks.", - formatter_class=argparse.ArgumentDefaultsHelpFormatter + formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) parser.add_argument( "-d", "--dir", - default=os.path.expanduser('~/ispd'), - help="Root directory to run under " - "(must have a tests subdir with benchmarks)" + default=os.path.expanduser("~/ispd"), + help="Root directory to run under " "(must have a tests subdir with benchmarks)", ) parser.add_argument( "-t", "--tests", nargs="*", default="*", - help="The tests to run. Matched to designs by glob" + help="The tests to run. Matched to designs by glob", ) parser.add_argument( - "-j", - "--jobs", - default=4, - type=int, - help="Number of jobs to run concurrently" + "-j", "--jobs", default=4, type=int, help="Number of jobs to run concurrently" ) parser.add_argument( - "-p", - "--program", - default=shutil.which('openroad'), - help="Path to openroad to test" + "-p", "--program", default=shutil.which("openroad"), help="Path to openroad to test" ) parser.add_argument( "-w", "--workspace", - default=os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'results'), - help="Workspace directory to create the run scripts and save output files" + default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "results"), + help="Workspace directory to create the run scripts and save output files", ) args = parser.parse_args() @@ -67,7 +58,7 @@ def gen_files(work_dir, ispd_year, design, drv_min, drv_max): - ''' host setup ''' + """host setup""" bench_dir = os.path.join(args.dir, "tests") if not os.path.exists(os.path.join(bench_dir, design)): raise Exception("Missing test {}".format(design)) @@ -98,7 +89,7 @@ def gen_files(work_dir, ispd_year, design, drv_min, drv_max): exit 2 }} """ - with open(os.path.join(design_dir, "run.tcl"), 'w') as tcl_file: + with open(os.path.join(design_dir, "run.tcl"), "w") as tcl_file: print(textwrap.dedent(script), file=tcl_file) print(f"Create run shell script for {design}") @@ -116,14 +107,14 @@ def gen_files(work_dir, ispd_year, design, drv_min, drv_max): | grep -v WARNING | grep -v ERROR echo """ - with open(run_sh, 'w') as script_file: + with open(run_sh, "w") as script_file: print(textwrap.dedent(script), file=script_file) file_st = os.stat(run_sh) os.chmod(run_sh, file_st.st_mode | stat.S_IXUSR | stat.S_IXGRP) def test_enabled(design, patterns): - ''' check if test is enabled ''' + """check if test is enabled""" for pattern in patterns: if fnmatch.fnmatch(design, pattern): return True @@ -157,30 +148,44 @@ def test_enabled(design, patterns): os.makedirs(args.workspace, exist_ok=True) running_tests = set() -for (design_name, drv_min, drv_max) in design_list_ispd18: +for design_name, drv_min, drv_max in design_list_ispd18: if test_enabled(design_name, args.tests): gen_files(args.workspace, 18, design_name, drv_min, drv_max) running_tests.add(design_name) -for (design_name, drv_min, drv_max) in design_list_ispd19: +for design_name, drv_min, drv_max in design_list_ispd19: if test_enabled(design_name, args.tests): gen_files(args.workspace, 19, design_name, drv_min, drv_max) running_tests.add(design_name) -status = subprocess.run(['parallel', - '-j', str(args.jobs), - '--halt', 'never', - '--joblog', f"{args.workspace}/ispd-parallel.log", - 'bash', os.path.join(args.workspace, '{}/run.sh'), - ':::', *list(running_tests)], - check=True) +status = subprocess.run( + [ + "parallel", + "-j", + str(args.jobs), + "--halt", + "never", + "--joblog", + f"{args.workspace}/ispd-parallel.log", + "bash", + os.path.join(args.workspace, "{}/run.sh"), + ":::", + *list(running_tests), + ], + check=True, +) for design_name in running_tests: - subprocess.run(['tar', 'czvf', - f"{args.workspace}/{design_name}.tar.gz", - f"{args.workspace}/{design_name}"], - check=True) + subprocess.run( + [ + "tar", + "czvf", + f"{args.workspace}/{design_name}.tar.gz", + f"{args.workspace}/{design_name}", + ], + check=True, + ) print("=======================") if status.returncode: diff --git a/src/drt/test/single_step.py b/src/drt/test/single_step.py index b6b13cf6eb3..bdb62f1fd66 100644 --- a/src/drt/test/single_step.py +++ b/src/drt/test/single_step.py @@ -10,13 +10,15 @@ gr = design.getGlobalRouter() gr.readGuides("testcase/ispd18_sample/ispd18_sample.input.guide") -drt_aux.detailed_route(design, - output_drc="results/single_step.output.drc.rpt", - output_maze="results/single_step.output.maze.log", - verbose=0, - single_step_dr=True) +drt_aux.detailed_route( + design, + output_drc="results/single_step.output.drc.rpt", + output_maze="results/single_step.output.maze.log", + verbose=0, + single_step_dr=True, +) -drt_aux.step_dr(design, 7, 0, 3, 8, 0, 8, 0.95, 1, True) +drt_aux.step_dr(design, 7, 0, 3, 8, 0, 8, 0.95, 1, True) drt_aux.step_dr(design, 7, -2, 3, 8, 8, 8, 0.95, 1, True) drt_aux.step_dr(design, 7, -5, 3, 8, 8, 8, 0.95, 1, True) drt_aux.step_end(design) diff --git a/src/drt/test/top_level_term.py b/src/drt/test/top_level_term.py index 713190f65ba..7bf5336a177 100644 --- a/src/drt/test/top_level_term.py +++ b/src/drt/test/top_level_term.py @@ -11,10 +11,9 @@ gr = design.getGlobalRouter() gr.readGuides("top_level_term.guide") -drt_aux.detailed_route(design, - bottom_routing_layer="met1", - top_routing_layer="met3", - verbose=0) +drt_aux.detailed_route( + design, bottom_routing_layer="met1", top_routing_layer="met3", verbose=0 +) def_file = helpers.make_result_file("top_level_term.def") design.writeDef(def_file) diff --git a/src/drt/test/top_level_term2.py b/src/drt/test/top_level_term2.py index d1debdad160..3a59192b2a3 100644 --- a/src/drt/test/top_level_term2.py +++ b/src/drt/test/top_level_term2.py @@ -11,10 +11,9 @@ gr = design.getGlobalRouter() gr.readGuides("top_level_term2.guide") -drt_aux.detailed_route(design, - bottom_routing_layer="met1", - top_routing_layer="met3", - verbose=0) +drt_aux.detailed_route( + design, bottom_routing_layer="met1", top_routing_layer="met3", verbose=0 +) def_file = helpers.make_result_file("top_level_term2.def") design.writeDef(def_file) diff --git a/src/fin/test/fin_man_tcl_check.py b/src/fin/test/fin_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/fin/test/fin_man_tcl_check.py +++ b/src/fin/test/fin_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/fin/test/fin_readme_msgs_check.py b/src/fin/test/fin_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/fin/test/fin_readme_msgs_check.py +++ b/src/fin/test/fin_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/gpl/test/ar01.py b/src/gpl/test/ar01.py index f4ddf840110..92ce18155fa 100644 --- a/src/gpl/test/ar01.py +++ b/src/gpl/test/ar01.py @@ -7,7 +7,9 @@ design = Design(tech) design.readDef("./ar01.def") -gpl_aux.global_placement(design, density=0.6, init_density_penalty=0.01, skip_initial_place=True) +gpl_aux.global_placement( + design, density=0.6, init_density_penalty=0.01, skip_initial_place=True +) def_file = helpers.make_result_file("ar01.def") design.writeDef(def_file) diff --git a/src/gpl/test/ar02.py b/src/gpl/test/ar02.py index 21a6e029949..6251d999713 100644 --- a/src/gpl/test/ar02.py +++ b/src/gpl/test/ar02.py @@ -7,7 +7,9 @@ design = Design(tech) design.readDef("./ar02.def") -gpl_aux.global_placement(design, density=0.6, init_density_penalty=0.01, skip_initial_place=True) +gpl_aux.global_placement( + design, density=0.6, init_density_penalty=0.01, skip_initial_place=True +) def_file = helpers.make_result_file("ar02.def") design.writeDef(def_file) diff --git a/src/gpl/test/convergence01.py b/src/gpl/test/convergence01.py index 200b1bed060..00f8401c9a8 100644 --- a/src/gpl/test/convergence01.py +++ b/src/gpl/test/convergence01.py @@ -4,6 +4,7 @@ from openroad import Design, Tech import helpers import gpl_aux + tech = Tech() tech.readLiberty("asap7/asap7sc7p5t_AO_RVT_FF_nldm_211120.lib.gz") @@ -18,12 +19,13 @@ design = Design(tech) design.readDef("convergence01.def") -design.evalTclString('read_sdc convergence01.sdc') +design.evalTclString("read_sdc convergence01.sdc") -design.evalTclString('source asap7/setRC.tcl') +design.evalTclString("source asap7/setRC.tcl") -gpl_aux.global_placement(design, density=0.5, timing_driven=True, - pad_left=2, pad_right=2) +gpl_aux.global_placement( + design, density=0.5, timing_driven=True, pad_left=2, pad_right=2 +) def_file = helpers.make_result_file("convergence01.def") design.writeDef(def_file) diff --git a/src/gpl/test/core01.py b/src/gpl/test/core01.py index bac168b641e..39989ab8d09 100644 --- a/src/gpl/test/core01.py +++ b/src/gpl/test/core01.py @@ -7,7 +7,9 @@ design = Design(tech) design.readDef("./core01.def") -gpl_aux.global_placement(design, density=0.6, init_density_penalty=0.01, skip_initial_place=True) +gpl_aux.global_placement( + design, density=0.6, init_density_penalty=0.01, skip_initial_place=True +) def_file = helpers.make_result_file("core01.def") design.writeDef(def_file) diff --git a/src/gpl/test/error01.py b/src/gpl/test/error01.py index c506e4d6aef..841fe7b2389 100644 --- a/src/gpl/test/error01.py +++ b/src/gpl/test/error01.py @@ -8,8 +8,8 @@ design.readDef("./error01.def") try: - gpl_aux.global_placement(design, init_density_penalty=0.01, - skip_initial_place=True, density=0.001) + gpl_aux.global_placement( + design, init_density_penalty=0.01, skip_initial_place=True, density=0.001 + ) except Exception as inst: print(inst.args[0]) - diff --git a/src/gpl/test/gpl_aux.py b/src/gpl/test/gpl_aux.py index 9b39894c1d1..66725bae375 100644 --- a/src/gpl/test/gpl_aux.py +++ b/src/gpl/test/gpl_aux.py @@ -4,39 +4,41 @@ DEFAULT_TARGET_DENSITY = 0.7 -# Besides design, there are no positional args here. General strategy is that +# Besides design, there are no positional args here. General strategy is that # when an arg is None, we just skip setting it, otherwise we will set the # parameter after a quick type check. -def global_placement(design, *, +def global_placement( + design, + *, skip_initial_place=False, skip_nesterov_place=False, timing_driven=False, routability_driven=False, incremental=False, skip_io=False, - bin_grid_count=None, # positive int, default 0 - density=None, # 'uniform' or 0.0 < d < 1.0 default 0.7 - init_density_penalty=None, # positive float default 0.00008 - init_wirelength_coef=None, # positive float default 0.25 - min_phi_coef=None, # positive float default 0.95 - max_phi_coef=None, # positive float default 1.05 - reference_hpwl=None, # positive int default 446000000 - overflow=None, # positive float - initial_place_max_iter=None, # positive int, default 20 - initial_place_max_fanout=None, # positive int, default 200 - routability_check_overflow=None, # positive float - routability_max_density=None, # positive float default 0.99 - routability_max_bloat_iter=None, # positive int default 1 - routability_max_inflation_iter=None, # positive int default 4 - routability_target_rc_metric=None, # positive float - routability_inflation_ratio_coef=None, # positive float - routability_max_inflation_ratio=None, # positive float - routability_rc_coefficients=None, # a list of four floats - timing_driven_net_reweight_overflow=None, # list of ints - timing_driven_net_weight_max=None, # float - timing_driven_nets_percentage=None, # float - pad_left=None, # positive int - pad_right=None # positive int + bin_grid_count=None, # positive int, default 0 + density=None, # 'uniform' or 0.0 < d < 1.0 default 0.7 + init_density_penalty=None, # positive float default 0.00008 + init_wirelength_coef=None, # positive float default 0.25 + min_phi_coef=None, # positive float default 0.95 + max_phi_coef=None, # positive float default 1.05 + reference_hpwl=None, # positive int default 446000000 + overflow=None, # positive float + initial_place_max_iter=None, # positive int, default 20 + initial_place_max_fanout=None, # positive int, default 200 + routability_check_overflow=None, # positive float + routability_max_density=None, # positive float default 0.99 + routability_max_bloat_iter=None, # positive int default 1 + routability_max_inflation_iter=None, # positive int default 4 + routability_target_rc_metric=None, # positive float + routability_inflation_ratio_coef=None, # positive float + routability_max_inflation_ratio=None, # positive float + routability_rc_coefficients=None, # a list of four floats + timing_driven_net_reweight_overflow=None, # list of ints + timing_driven_net_weight_max=None, # float + timing_driven_nets_percentage=None, # float + pad_left=None, # positive int + pad_right=None, # positive int ): gpl = design.getReplace() @@ -47,12 +49,12 @@ def global_placement(design, *, gpl.setSkipIoMode(skip_io) if skip_io: - gpl.setInitialPlaceMaxIter(0) + gpl.setInitialPlaceMaxIter(0) gpl.setTimingDrivenMode(timing_driven) if timing_driven: - if design.evalTclString('get_libs -quiet "*"') == '': + if design.evalTclString('get_libs -quiet "*"') == "": utl.error(utl.GPL, 502, "No liberty libraries found.") if skip_io: @@ -63,7 +65,7 @@ def global_placement(design, *, overflow_list = timing_driven_net_reweight_overflow else: overflow_list = [79, 64, 49, 29, 21, 15] - + for ov in overflow_list: gpl.addTimingNetWeightOverflow(ov) @@ -71,7 +73,9 @@ def global_placement(design, *, gpl.setTimingNetWeightMax(timing_driven_net_weight_max) if is_pos_float(timing_driven_nets_percentage): - design.evalTclString(f"rsz::set_worst_slack_nets_percent {timing_driven_nets_percentage}") + design.evalTclString( + f"rsz::set_worst_slack_nets_percent {timing_driven_nets_percentage}" + ) gpl.setRoutabilityDrivenMode(routability_driven) @@ -88,7 +92,7 @@ def global_placement(design, *, if density != None: target_density = density - else: + else: target_density = DEFAULT_TARGET_DENSITY if target_density == "uniform": @@ -161,13 +165,17 @@ def global_placement(design, *, gpl.doNesterovPlace(1) gpl.reset() else: - utl.error(utl.GPL, 506, "No rows defined in design. Use initialize_floorplan to add rows.") + utl.error( + utl.GPL, + 506, + "No rows defined in design. Use initialize_floorplan to add rows.", + ) def is_pos_int(x): if x == None: return False - elif isinstance(x, int) and x > 0 : + elif isinstance(x, int) and x > 0: return True else: utl.error(utl.GPL, 507, f"TypeError: {x} is not a postive integer") diff --git a/src/gpl/test/gpl_man_tcl_check.py b/src/gpl/test/gpl_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/gpl/test/gpl_man_tcl_check.py +++ b/src/gpl/test/gpl_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/gpl/test/gpl_readme_msgs_check.py b/src/gpl/test/gpl_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/gpl/test/gpl_readme_msgs_check.py +++ b/src/gpl/test/gpl_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/gpl/test/simple01-obs.py b/src/gpl/test/simple01-obs.py index c3963505f42..7abb67b010a 100644 --- a/src/gpl/test/simple01-obs.py +++ b/src/gpl/test/simple01-obs.py @@ -7,8 +7,10 @@ design = Design(tech) design.readDef("./simple01-obs.def") -#design.evalTclString("global_placement -init_density_penalty 0.01 -skip_initial_place -density 0.8") -gpl_aux.global_placement(design, init_density_penalty=0.01, skip_initial_place=True, density=0.8) +# design.evalTclString("global_placement -init_density_penalty 0.01 -skip_initial_place -density 0.8") +gpl_aux.global_placement( + design, init_density_penalty=0.01, skip_initial_place=True, density=0.8 +) def_file = helpers.make_result_file("simple01-obs.def") design.writeDef(def_file) helpers.diff_files(def_file, "simple01-obs.defok") diff --git a/src/gpl/test/simple01-ref.py b/src/gpl/test/simple01-ref.py index 4854ba30b2d..6b4bddeb6b4 100644 --- a/src/gpl/test/simple01-ref.py +++ b/src/gpl/test/simple01-ref.py @@ -7,7 +7,9 @@ design = Design(tech) design.readDef("./simple01-ref.def") -gpl_aux.global_placement(design, init_density_penalty=0.01, skip_initial_place=True, reference_hpwl=384000.0) +gpl_aux.global_placement( + design, init_density_penalty=0.01, skip_initial_place=True, reference_hpwl=384000.0 +) def_file = helpers.make_result_file("simple01-ref.def") design.writeDef(def_file) diff --git a/src/gpl/test/simple01-td-tune.py b/src/gpl/test/simple01-td-tune.py index 48d164f1ea8..cb662dbd10a 100644 --- a/src/gpl/test/simple01-td-tune.py +++ b/src/gpl/test/simple01-td-tune.py @@ -12,7 +12,11 @@ design.evalTclString("set_wire_rc -signal -layer metal3") design.evalTclString("set_wire_rc -clock -layer metal5") -gpl_aux.global_placement(design, timing_driven=True, timing_driven_net_reweight_overflow=[80, 70, 60, 50, 40, 30, 20]) +gpl_aux.global_placement( + design, + timing_driven=True, + timing_driven_net_reweight_overflow=[80, 70, 60, 50, 40, 30, 20], +) design.evalTclString("estimate_parasitics -placement") design.evalTclString("report_worst_slack") diff --git a/src/gpl/test/simple01-uniform.py b/src/gpl/test/simple01-uniform.py index 5cd70e9d705..83264ee46d2 100644 --- a/src/gpl/test/simple01-uniform.py +++ b/src/gpl/test/simple01-uniform.py @@ -7,7 +7,9 @@ design = Design(tech) design.readDef("./simple01.def") -gpl_aux.global_placement(design, init_density_penalty=0.01, skip_initial_place=True, density="uniform") +gpl_aux.global_placement( + design, init_density_penalty=0.01, skip_initial_place=True, density="uniform" +) def_file = helpers.make_result_file("simple01-uniform.def") design.writeDef(def_file) diff --git a/src/gpl/test/simple02.py b/src/gpl/test/simple02.py index 1a75eb62a73..85faefd0a91 100644 --- a/src/gpl/test/simple02.py +++ b/src/gpl/test/simple02.py @@ -7,7 +7,9 @@ design = Design(tech) design.readDef("./simple02.def") -gpl_aux.global_placement(design, density=0.6, init_density_penalty=0.01, skip_initial_place=True) +gpl_aux.global_placement( + design, density=0.6, init_density_penalty=0.01, skip_initial_place=True +) def_file = helpers.make_result_file("simple02.def") design.writeDef(def_file) diff --git a/src/grt/test/clock_route.py b/src/grt/test/clock_route.py index 55629a81352..58327d80117 100644 --- a/src/grt/test/clock_route.py +++ b/src/grt/test/clock_route.py @@ -12,9 +12,11 @@ gr = design.getGlobalRouter() # layer range for clock nets. def file from the openroad-flow (modified gcd_sky130hs) -#source "helpers.tcl" +# source "helpers.tcl" -design.evalTclString("create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]") +design.evalTclString( + "create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]" +) design.evalTclString("set_propagated_clock [get_clocks {core_clock}]") gfile = helpers.make_result_file("clock_route.guide") @@ -31,4 +33,3 @@ design.getBlock().writeGuides(gfile) helpers.diff_files("clock_route.guideok", gfile) - diff --git a/src/grt/test/congestion1.py b/src/grt/test/congestion1.py index 48c587dc178..572d3ff86c2 100644 --- a/src/grt/test/congestion1.py +++ b/src/grt/test/congestion1.py @@ -22,7 +22,7 @@ gr.setVerbose(True) gr.setAllowCongestion(True) -gr.globalRoute(True) # save_guides = True +gr.globalRoute(True) # save_guides = True design.getBlock().writeGuides(guideFile) diff --git a/src/grt/test/critical_nets_percentage.py b/src/grt/test/critical_nets_percentage.py index bf6657e2554..65bea1aa495 100644 --- a/src/grt/test/critical_nets_percentage.py +++ b/src/grt/test/critical_nets_percentage.py @@ -22,8 +22,8 @@ design.evalTclString('source "sky130hs/sky130hs.rc"') design.evalTclString('set_wire_rc -signal -layer "met2"') design.evalTclString('set_wire_rc -clock -layer "met5"') -design.evalTclString('set_propagated_clock [all_clocks]') -design.evalTclString('estimate_parasitics -placement') +design.evalTclString("set_propagated_clock [all_clocks]") +design.evalTclString("estimate_parasitics -placement") guideFile = helpers.make_result_file("critical_nets_percentage.guide") diff --git a/src/grt/test/gcd_flute.py b/src/grt/test/gcd_flute.py index 67348aaad1d..1e8e38ed4dd 100644 --- a/src/grt/test/gcd_flute.py +++ b/src/grt/test/gcd_flute.py @@ -17,7 +17,7 @@ design.evalTclString("set_routing_alpha 0.0") gr.setVerbose(True) -gr.globalRoute(True) # save_guides = True +gr.globalRoute(True) # save_guides = True design.getBlock().writeGuides(guideFile) diff --git a/src/grt/test/grt_aux.py b/src/grt/test/grt_aux.py index c6313a16b48..7ad05faf07e 100644 --- a/src/grt/test/grt_aux.py +++ b/src/grt/test/grt_aux.py @@ -3,7 +3,7 @@ def get_layer_idx(design, layer_name): - """ Given a layer name and a technology, return the layer index""" + """Given a layer name and a technology, return the layer index""" mt = design.getTech().getDB().getTech() if mt == None: utl.error(utl.GRT, 500, "No technology has been read.") @@ -36,37 +36,45 @@ def check_routing_layer_by_index(design, layer_idx): # number of routing layers max_routing_layer = rtech.getRoutingLayerCount() tech_layer = rtech.findRoutingLayer(layer_idx) - + # NOTE: the tcl version uses 1 instead of 0, which is incorrect. min_tech_layer = rtech.findRoutingLayer(0) max_tech_layer = rtech.findRoutingLayer(max_routing_layer) if layer_idx > max_routing_layer: - utl.error(utl.GRT, 505, f"Layer {tech_layer.getConstName()} is greater " - f"than the max routing layer " - f"({max_tech_layer.getConstName()}).") - + utl.error( + utl.GRT, + 505, + f"Layer {tech_layer.getConstName()} is greater " + f"than the max routing layer " + f"({max_tech_layer.getConstName()}).", + ) + if layer_idx < 0: - utl.error(utl.GRT, 506, f"Layer {tech_layer.getConstName()} is less " - f"than the min routing layer " - f"({min_tech_layer.getConstName()}).") + utl.error( + utl.GRT, + 506, + f"Layer {tech_layer.getConstName()} is less " + f"than the min routing layer " + f"({min_tech_layer.getConstName()}).", + ) def set_global_routing_layer_adjustment(design, layer, adj): """In design "design", set the global layer adjustment for "layer". - layer can be a named layer or range specified as layer1-layer2, - where layer1 < layer2. The adjustment "adj" must be > 0.0""" + layer can be a named layer or range specified as layer1-layer2, + where layer1 < layer2. The adjustment "adj" must be > 0.0""" gr = design.getGlobalRouter() - + if adj <= 0.0: utl.error(utl.GRT, 507, "Layer adjustment must be positive") if layer == "*": gr.setAdjustment(adj) - + elif layer.rfind("-") > 0: first_layer, last_layer = get_layer_range(design, layer) - for l in range(first_layer,last_layer+1): + for l in range(first_layer, last_layer + 1): check_routing_layer_by_index(design, l) gr.addLayerAdjustment(l, adj) @@ -75,7 +83,7 @@ def set_global_routing_layer_adjustment(design, layer, adj): check_routing_layer_by_index(design, layer_idx) gr.addLayerAdjustment(layer_idx, adj) - + class Orient(Enum): HORZ = 0 VERT = 1 @@ -84,10 +92,10 @@ class Orient(Enum): def layer_has_tracks(design, layer, *, orient=Orient.HORZ): if layer == None: return False - + if design.getBlock() == None: utl.error(utl.GRT, 991, "Design has no block") - + trackGrid = design.getBlock().findTrackGrid(layer) if trackGrid == None: @@ -110,12 +118,13 @@ def define_layer_range(design, layers): design.getGlobalRouter().setMaxRoutingLayer(lmax) rtech = design.getTech().getDB().getTech() - for layer in range(lmin, lmax+1): + for layer in range(lmin, lmax + 1): db_layer = rtech.findRoutingLayer(layer) - if (not layer_has_tracks(design, db_layer, orient=Orient.HORZ) and - not layer_has_tracks(design, db_layer, orient=Orient.VERT)): - layer_name = db_layer.getName() - utl.error(utl.GRT, 509, f"Missing track structure for layer {layer_name}.") + if not layer_has_tracks( + design, db_layer, orient=Orient.HORZ + ) and not layer_has_tracks(design, db_layer, orient=Orient.VERT): + layer_name = db_layer.getName() + utl.error(utl.GRT, 509, f"Missing track structure for layer {layer_name}.") def define_clock_layer_range(design, layers): @@ -124,10 +133,14 @@ def define_clock_layer_range(design, layers): check_routing_layer_by_index(design, maxcl) if mincl < maxcl: - design.getGlobalRouter().setMinLayerForClock(mincl); - design.getGlobalRouter().setMaxLayerForClock(maxcl); + design.getGlobalRouter().setMinLayerForClock(mincl) + design.getGlobalRouter().setMaxLayerForClock(maxcl) else: - utl.error(utl.GRT, 510, "In setting clock layers, min routing layer is greater than max routing layer.") + utl.error( + utl.GRT, + 510, + "In setting clock layers, min routing layer is greater than max routing layer.", + ) # Force keyword only args @@ -138,9 +151,11 @@ def set_routing_layers(design, *, signal=None, clock=None): if clock != None: define_clock_layer_range(design, clock) + def create_ndr(design): pass + # The -all_clocks flag is not (yet) supported def assign_ndr(design, *, ndrName="", netName=""): ndr = design.getBlock().findNonDefaultRule(ndrName) @@ -154,4 +169,3 @@ def assign_ndr(design, *, ndrName="", netName=""): net.setNonDefaultRule(ndr) else: utl.error(utl.GRT, 513, f"No net name specified for ndr.") - diff --git a/src/grt/test/grt_man_tcl_check.py b/src/grt/test/grt_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/grt/test/grt_man_tcl_check.py +++ b/src/grt/test/grt_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/grt/test/grt_readme_msgs_check.py b/src/grt/test/grt_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/grt/test/grt_readme_msgs_check.py +++ b/src/grt/test/grt_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/grt/test/ndr_1w_3s.py b/src/grt/test/ndr_1w_3s.py index 65b36ed18ef..0879e73d041 100644 --- a/src/grt/test/ndr_1w_3s.py +++ b/src/grt/test/ndr_1w_3s.py @@ -11,14 +11,18 @@ design.readDef("clock_route.def") gr = design.getGlobalRouter() -design.evalTclString("create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]") +design.evalTclString( + "create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]" +) design.evalTclString("set_propagated_clock [get_clocks {core_clock}]") clk = design.getBlock().findNet("clk") -design.evalTclString("create_ndr -name NDR " + - "-spacing { li1 0.51 met1 0.42 met2 0.42 met3 0.9 met4 0.9 met5 4.8 } " + - "-width { li1 0.17 met1 0.14 met2 0.14 met3 0.3 met4 0.3 met5 1.6 }") +design.evalTclString( + "create_ndr -name NDR " + + "-spacing { li1 0.51 met1 0.42 met2 0.42 met3 0.9 met4 0.9 met5 4.8 } " + + "-width { li1 0.17 met1 0.14 met2 0.14 met3 0.3 met4 0.3 met5 1.6 }" +) grt_aux.assign_ndr(design, ndrName="NDR", netName="clk") grt_aux.assign_ndr(design, ndrName="NDR", netName="clknet_0_clk") diff --git a/src/grt/test/pd1.py b/src/grt/test/pd1.py index e941cd6ff46..e6774671745 100644 --- a/src/grt/test/pd1.py +++ b/src/grt/test/pd1.py @@ -11,7 +11,9 @@ design = Design(tech) design.readDef("clock_route.def") -design.evalTclString("create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]") +design.evalTclString( + "create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]" +) design.evalTclString("set_propagated_clock [get_clocks {core_clock}]") design.evalTclString("set_routing_alpha 0.5") diff --git a/src/grt/test/pin_access1.py b/src/grt/test/pin_access1.py index 763583e5114..209f9972371 100644 --- a/src/grt/test/pin_access1.py +++ b/src/grt/test/pin_access1.py @@ -12,7 +12,9 @@ design.readDef("clock_route.def") gr = design.getGlobalRouter() -design.evalTclString("create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]") +design.evalTclString( + "create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]" +) design.evalTclString("set_propagated_clock [get_clocks {core_clock}]") guide_file = helpers.make_result_file("pin_access1.guide") @@ -23,7 +25,9 @@ grt_aux.set_routing_layers(design, signal="met1-met5", clock="met3-met5") -design.evalTclString("pin_access -bottom_routing_layer met1 -top_routing_layer met5 -verbose 0") +design.evalTclString( + "pin_access -bottom_routing_layer met1 -top_routing_layer met5 -verbose 0" +) gr.setVerbose(True) gr.globalRoute(True) diff --git a/src/grt/test/pre_routed1.py b/src/grt/test/pre_routed1.py index a50057260da..f3d4eb13c76 100644 --- a/src/grt/test/pre_routed1.py +++ b/src/grt/test/pre_routed1.py @@ -12,7 +12,9 @@ design.readDef("pre_routed1.def") gr = design.getGlobalRouter() -design.evalTclString("create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]") +design.evalTclString( + "create_clock -name core_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clk}]" +) design.evalTclString("set_propagated_clock [get_clocks {core_clock}]") guide_file = helpers.make_result_file("pre_routed1.guide") diff --git a/src/grt/test/region_adjustment.py b/src/grt/test/region_adjustment.py index edf910b44b1..8028abdb984 100644 --- a/src/grt/test/region_adjustment.py +++ b/src/grt/test/region_adjustment.py @@ -21,7 +21,7 @@ guideFile = helpers.make_result_file("region_adjustment.guide") gr.setVerbose(True) -gr.globalRoute(True) # save_guides = True +gr.globalRoute(True) # save_guides = True design.getBlock().writeGuides(guideFile) diff --git a/src/gui/test/gui_man_tcl_check.py b/src/gui/test/gui_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/gui/test/gui_man_tcl_check.py +++ b/src/gui/test/gui_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/gui/test/gui_readme_msgs_check.py b/src/gui/test/gui_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/gui/test/gui_readme_msgs_check.py +++ b/src/gui/test/gui_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/ifp/test/ifp_helpers.py b/src/ifp/test/ifp_helpers.py index 8e6e950c816..00670f77cc1 100644 --- a/src/ifp/test/ifp_helpers.py +++ b/src/ifp/test/ifp_helpers.py @@ -35,23 +35,27 @@ import openroad as ord import odb + class IFPError(Exception): def __init__(self, msg): print(msg) + # To be removed once we have UPF support def create_voltage_domain(domain_name, area): # which flavor of error reporting should be used here? if len(area) != 4: raise IFPError("utl::error ODB 315 '-area is a list of 4 coordinates'") - - db = ord.get_db() + + db = ord.get_db() chip = db.getChip() if chip == None: - raise IFPError("utl::error ODB 317 'please load the design before trying to use this command'") + raise IFPError( + "utl::error ODB 317 'please load the design before trying to use this command'" + ) - block = chip.getBlock() + block = chip.getBlock() region = odb.dbRegion_create(block, domain_name) if region == None: @@ -74,13 +78,13 @@ def insert_tiecells(floorplan, args, prefix=None): master = None db = ord.get_db() - + for lib in db.getLibs(): master = lib.findMaster(tie_cell) - if master != None: + if master != None: break - if master == None: + if master == None: raise IFPError(f"IFP 31 Unable to find master: {tie_cell}") mterm = master.findMTerm(port) diff --git a/src/ifp/test/ifp_man_tcl_check.py b/src/ifp/test/ifp_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/ifp/test/ifp_man_tcl_check.py +++ b/src/ifp/test/ifp_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/ifp/test/ifp_readme_msgs_check.py b/src/ifp/test/ifp_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/ifp/test/ifp_readme_msgs_check.py +++ b/src/ifp/test/ifp_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/ifp/test/init_floorplan1.py b/src/ifp/test/init_floorplan1.py index 9bd57c0024f..750a9dfdc6d 100644 --- a/src/ifp/test/init_floorplan1.py +++ b/src/ifp/test/init_floorplan1.py @@ -11,10 +11,12 @@ floorplan = design.getFloorplan() site = floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O") -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 1000, 1000), - helpers.make_rect(design, 100, 100, 900, 900), - site) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 1000, 1000), + helpers.make_rect(design, 100, 100, 900, 900), + site, +) def_file = helpers.make_result_file("init_floorplan1.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan1.defok', def_file) +helpers.diff_files("init_floorplan1.defok", def_file) diff --git a/src/ifp/test/init_floorplan2.py b/src/ifp/test/init_floorplan2.py index d114e8bd9f0..9e811a1b15e 100644 --- a/src/ifp/test/init_floorplan2.py +++ b/src/ifp/test/init_floorplan2.py @@ -13,11 +13,8 @@ floorplan = design.getFloorplan() site = floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O") -floorplan.initFloorplan(30, - 0.5, - space, space, space, space, - site) +floorplan.initFloorplan(30, 0.5, space, space, space, space, site) def_file = helpers.make_result_file("init_floorplan2.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan2.defok', def_file) +helpers.diff_files("init_floorplan2.defok", def_file) diff --git a/src/ifp/test/init_floorplan3.py b/src/ifp/test/init_floorplan3.py index 2671251de1f..52ae20d6748 100644 --- a/src/ifp/test/init_floorplan3.py +++ b/src/ifp/test/init_floorplan3.py @@ -13,11 +13,8 @@ floorplan = design.getFloorplan() site = floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O") -floorplan.initFloorplan(30, - 0.5, - space, space, space, space, - site) +floorplan.initFloorplan(30, 0.5, space, space, space, space, site) def_file = helpers.make_result_file("init_floorplan3.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan3.defok', def_file) +helpers.diff_files("init_floorplan3.defok", def_file) diff --git a/src/ifp/test/init_floorplan4.py b/src/ifp/test/init_floorplan4.py index a5aa377cecf..cff7c829609 100644 --- a/src/ifp/test/init_floorplan4.py +++ b/src/ifp/test/init_floorplan4.py @@ -18,4 +18,4 @@ def_file = helpers.make_result_file("init_floorplan4.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan4.defok', def_file) +helpers.diff_files("init_floorplan4.defok", def_file) diff --git a/src/ifp/test/init_floorplan5.py b/src/ifp/test/init_floorplan5.py index 088a62459d4..4fc38b7c98c 100644 --- a/src/ifp/test/init_floorplan5.py +++ b/src/ifp/test/init_floorplan5.py @@ -16,4 +16,4 @@ def_file = helpers.make_result_file("init_floorplan5.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan5.defok', def_file) +helpers.diff_files("init_floorplan5.defok", def_file) diff --git a/src/ifp/test/init_floorplan6.py b/src/ifp/test/init_floorplan6.py index 7ccac19a3da..44f4122c990 100644 --- a/src/ifp/test/init_floorplan6.py +++ b/src/ifp/test/init_floorplan6.py @@ -10,17 +10,14 @@ design.link("top") bottom = design.micronToDBU(100) -top = design.micronToDBU(150) -left = design.micronToDBU(200) -right = design.micronToDBU(300) +top = design.micronToDBU(150) +left = design.micronToDBU(200) +right = design.micronToDBU(300) floorplan = design.getFloorplan() site = floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O") -floorplan.initFloorplan(30, - 0.5, - bottom, top, left, right, - site) +floorplan.initFloorplan(30, 0.5, bottom, top, left, right, site) def_file = helpers.make_result_file("init_floorplan6.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan6.defok', def_file) +helpers.diff_files("init_floorplan6.defok", def_file) diff --git a/src/ifp/test/init_floorplan7.py b/src/ifp/test/init_floorplan7.py index f09312d5c6e..3d9763f8871 100644 --- a/src/ifp/test/init_floorplan7.py +++ b/src/ifp/test/init_floorplan7.py @@ -11,9 +11,9 @@ design.readVerilog("reg1.v") design.link("top") -die1 = helpers.make_rect(design, 0, 0, 1000, 1000) +die1 = helpers.make_rect(design, 0, 0, 1000, 1000) core1 = helpers.make_rect(design, 100, 100, 900, 900) -die2 = helpers.make_rect(design, 100, 100, 1100, 1100) +die2 = helpers.make_rect(design, 100, 100, 1100, 1100) core2 = helpers.make_rect(design, 200, 200, 800, 800) floorplan = design.getFloorplan() @@ -23,4 +23,4 @@ def_file = helpers.make_result_file("init_floorplan7.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan7.defok', def_file) +helpers.diff_files("init_floorplan7.defok", def_file) diff --git a/src/ifp/test/init_floorplan8.py b/src/ifp/test/init_floorplan8.py index aebece9d133..6cd5cb11d25 100644 --- a/src/ifp/test/init_floorplan8.py +++ b/src/ifp/test/init_floorplan8.py @@ -11,7 +11,7 @@ design.readVerilog("reg1.v") design.link("top") -die = helpers.make_rect(design, 0, 0, 150, 150) +die = helpers.make_rect(design, 0, 0, 150, 150) core = helpers.make_rect(design, 20, 20, 130, 130) l = design.micronToDBU(27) @@ -25,4 +25,4 @@ def_file = helpers.make_result_file("init_floorplan8.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan8.defok', def_file) +helpers.diff_files("init_floorplan8.defok", def_file) diff --git a/src/ifp/test/init_floorplan9.py b/src/ifp/test/init_floorplan9.py index 1f77c1ff042..687c97363d1 100644 --- a/src/ifp/test/init_floorplan9.py +++ b/src/ifp/test/init_floorplan9.py @@ -11,7 +11,7 @@ design.readVerilog("reg2.v") design.link("top") -die = helpers.make_rect(design, 0, 0, 155.48, 146.88) +die = helpers.make_rect(design, 0, 0, 155.48, 146.88) core = helpers.make_rect(design, 18.4, 16.32, 137.08, 130.56) floorplan = design.getFloorplan() @@ -27,5 +27,4 @@ def_file = helpers.make_result_file("init_floorplan9.def") design.writeDef(def_file) -helpers.diff_files('init_floorplan9.defok', def_file) - +helpers.diff_files("init_floorplan9.defok", def_file) diff --git a/src/ifp/test/make_tracks1.py b/src/ifp/test/make_tracks1.py index 7d6ea619d5b..de3ddad4fcd 100644 --- a/src/ifp/test/make_tracks1.py +++ b/src/ifp/test/make_tracks1.py @@ -10,12 +10,14 @@ design.link("top") floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 1000, 1000), - helpers.make_rect(design, 100, 100, 900, 900), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 1000, 1000), + helpers.make_rect(design, 100, 100, 900, 900), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) floorplan.makeTracks() def_file = helpers.make_result_file("make_tracks1.def") design.writeDef(def_file) -helpers.diff_files('make_tracks1.defok', def_file) +helpers.diff_files("make_tracks1.defok", def_file) diff --git a/src/ifp/test/make_tracks2.py b/src/ifp/test/make_tracks2.py index 75766ad3277..19ee66dc221 100644 --- a/src/ifp/test/make_tracks2.py +++ b/src/ifp/test/make_tracks2.py @@ -12,9 +12,11 @@ design.link("top") floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 1000, 1000), - helpers.make_rect(design, 100, 100, 900, 900), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 1000, 1000), + helpers.make_rect(design, 100, 100, 900, 900), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) db_tech = ord.get_db_tech() m1 = db_tech.findLayer("metal1") @@ -28,4 +30,4 @@ def_file = helpers.make_result_file("make_tracks2.def") design.writeDef(def_file) -helpers.diff_files('make_tracks2.defok', def_file) +helpers.diff_files("make_tracks2.defok", def_file) diff --git a/src/ifp/test/make_tracks3.py b/src/ifp/test/make_tracks3.py index ccb803c05c8..a95002bdf50 100644 --- a/src/ifp/test/make_tracks3.py +++ b/src/ifp/test/make_tracks3.py @@ -12,22 +12,24 @@ design.link("top") floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 10, 20, 1010, 1020), - helpers.make_rect(design, 110, 120, 910, 920), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 10, 20, 1010, 1020), + helpers.make_rect(design, 110, 120, 910, 920), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) db_tech = ord.get_db_tech() m1 = db_tech.findLayer("metal1") m2 = db_tech.findLayer("metal2") x_offset = design.micronToDBU(0.1) -x_pitch = design.micronToDBU(0.2) +x_pitch = design.micronToDBU(0.2) y_offset = design.micronToDBU(0.1) -y_pitch = design.micronToDBU(0.2) +y_pitch = design.micronToDBU(0.2) floorplan.makeTracks(m1, x_offset, x_pitch, y_offset, y_pitch) floorplan.makeTracks(m2, x_offset, x_pitch, y_offset, y_pitch) def_file = helpers.make_result_file("make_tracks3.def") design.writeDef(def_file) -helpers.diff_files('make_tracks3.defok', def_file) +helpers.diff_files("make_tracks3.defok", def_file) diff --git a/src/ifp/test/make_tracks4.py b/src/ifp/test/make_tracks4.py index 9b5ade2a3ec..e70bb4e93f3 100644 --- a/src/ifp/test/make_tracks4.py +++ b/src/ifp/test/make_tracks4.py @@ -12,21 +12,23 @@ design.link("top") floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 200, 200), - helpers.make_rect(design, 10, 10, 190, 190), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 200, 200), + helpers.make_rect(design, 10, 10, 190, 190), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) db_tech = ord.get_db_tech() m2 = db_tech.findLayer("metal2") x_offset = design.micronToDBU(300) -x_pitch = design.micronToDBU(0.2) +x_pitch = design.micronToDBU(0.2) y_offset = design.micronToDBU(0.1) -y_pitch = design.micronToDBU(0.2) +y_pitch = design.micronToDBU(0.2) floorplan.makeTracks(m2, x_offset, x_pitch, y_offset, y_pitch) x_offset = design.micronToDBU(0.1) -x_pitch = design.micronToDBU(0.2) +x_pitch = design.micronToDBU(0.2) y_offset = design.micronToDBU(300) -y_pitch = design.micronToDBU(0.2) +y_pitch = design.micronToDBU(0.2) floorplan.makeTracks(m2, x_offset, x_pitch, y_offset, y_pitch) diff --git a/src/ifp/test/make_tracks5.py b/src/ifp/test/make_tracks5.py index d51f867d7a6..153cf2dbfc0 100644 --- a/src/ifp/test/make_tracks5.py +++ b/src/ifp/test/make_tracks5.py @@ -12,17 +12,19 @@ design.link("top") floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 1000, 1000), - helpers.make_rect(design, 100, 100, 900, 900), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 1000, 1000), + helpers.make_rect(design, 100, 100, 900, 900), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) db_tech = ord.get_db_tech() m1 = db_tech.findLayer("metal1") x_offset = design.micronToDBU(0.1) -x_pitch = design.micronToDBU(0.2) +x_pitch = design.micronToDBU(0.2) y_offset = design.micronToDBU(0.1) -y_pitch = design.micronToDBU(0.2) +y_pitch = design.micronToDBU(0.2) floorplan.makeTracks(m1, x_offset, x_pitch, y_offset, y_pitch) @@ -33,4 +35,4 @@ def_file = helpers.make_result_file("make_tracks5.def") design.writeDef(def_file) -helpers.diff_files('make_tracks5.defok', def_file) +helpers.diff_files("make_tracks5.defok", def_file) diff --git a/src/ifp/test/make_tracks6.py b/src/ifp/test/make_tracks6.py index 7e375afb41b..b3adc9c0324 100644 --- a/src/ifp/test/make_tracks6.py +++ b/src/ifp/test/make_tracks6.py @@ -11,12 +11,14 @@ design.link("top") floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 1000, 1000), - helpers.make_rect(design, 100, 100, 900, 900), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 1000, 1000), + helpers.make_rect(design, 100, 100, 900, 900), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) floorplan.makeTracks() def_file = helpers.make_result_file("make_tracks6.def") design.writeDef(def_file) -helpers.diff_files('make_tracks6.defok', def_file) +helpers.diff_files("make_tracks6.defok", def_file) diff --git a/src/ifp/test/placement_blockage1.py b/src/ifp/test/placement_blockage1.py index 59504e7c01c..93ce12723be 100644 --- a/src/ifp/test/placement_blockage1.py +++ b/src/ifp/test/placement_blockage1.py @@ -15,10 +15,12 @@ odb.dbBlockage_create(ord.get_db_block(), 0, 508400, 1000000, 708400) floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 1000, 1000), - helpers.make_rect(design, 100, 100, 900, 900), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 1000, 1000), + helpers.make_rect(design, 100, 100, 900, 900), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) def_file = helpers.make_result_file("placement_blockage1.def") design.writeDef(def_file) -helpers.diff_files('placement_blockage1.defok', def_file) +helpers.diff_files("placement_blockage1.defok", def_file) diff --git a/src/ifp/test/placement_blockage2.py b/src/ifp/test/placement_blockage2.py index c13d47ca840..2c4a4ef9dda 100644 --- a/src/ifp/test/placement_blockage2.py +++ b/src/ifp/test/placement_blockage2.py @@ -14,10 +14,12 @@ odb.dbBlockage_create(ord.get_db_block(), 0, 0, 2000000, 208400) floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 1000, 1000), - helpers.make_rect(design, 100, 100, 900, 900), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 1000, 1000), + helpers.make_rect(design, 100, 100, 900, 900), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) def_file = helpers.make_result_file("placement_blockage2.def") design.writeDef(def_file) -helpers.diff_files('placement_blockage2.defok', def_file) +helpers.diff_files("placement_blockage2.defok", def_file) diff --git a/src/ifp/test/tiecells.py b/src/ifp/test/tiecells.py index 143a381cd21..c33c580723d 100644 --- a/src/ifp/test/tiecells.py +++ b/src/ifp/test/tiecells.py @@ -12,14 +12,16 @@ design.link("top") floorplan = design.getFloorplan() -floorplan.initFloorplan(helpers.make_rect(design, 0, 0, 1000, 1000), - helpers.make_rect(design, 100, 100, 900, 900), - floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")) +floorplan.initFloorplan( + helpers.make_rect(design, 0, 0, 1000, 1000), + helpers.make_rect(design, 100, 100, 900, 900), + floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O"), +) + - ifp_helpers.insert_tiecells(floorplan, "LOGIC0_X1/Z", "TIE_ZERO_") ifp_helpers.insert_tiecells(floorplan, "LOGIC1_X1/Z") def_file = helpers.make_result_file("tiecells.def") design.writeDef(def_file) -helpers.diff_files('tiecells.defok', def_file) +helpers.diff_files("tiecells.defok", def_file) diff --git a/src/mpl/test/east_west2.py b/src/mpl/test/east_west2.py index 63bb9cdfa59..0ccbce8f4dc 100644 --- a/src/mpl/test/east_west2.py +++ b/src/mpl/test/east_west2.py @@ -14,7 +14,7 @@ # This appears to be the only difference from east_west1, ie, we do not # read in the sdc file -#design.evalTclString('read_sdc "gcd.sdc"') +# design.evalTclString('read_sdc "gcd.sdc"') mpl_aux.macro_placement(design, style="corner_min_wl", halo=[0.5, 0.5]) diff --git a/src/mpl/test/mpl_aux.py b/src/mpl/test/mpl_aux.py index 067463f4bad..63d27bdca73 100644 --- a/src/mpl/test/mpl_aux.py +++ b/src/mpl/test/mpl_aux.py @@ -33,17 +33,26 @@ ############################################################################# import utl -def macro_placement(design, *, halo=None, channel=None, fence_region=None, snap_layer=None, style=None): + +def macro_placement( + design, *, halo=None, channel=None, fence_region=None, snap_layer=None, style=None +): if halo != None: if len(halo) != 2: - utl.error(utl.MPL, 192, f"halo receives a list with 2 values, {len(halo)} given.") + utl.error( + utl.MPL, 192, f"halo receives a list with 2 values, {len(halo)} given." + ) halo_x, halo_y = halo if is_pos_float(halo_x) and is_pos_float(halo_y): design.getMacroPlacer().setHalo(halo_x, halo_y) if channel != None: if length(channel) != 2: - utl.error(utl.MPL, 193, f"channel receives a list with 2 values, {len(channel)} given.") + utl.error( + utl.MPL, + 193, + f"channel receives a list with 2 values, {len(channel)} given.", + ) channel_x, channel_y = channel if is_pos_float(channel_x) and is_pos_float(channel_y): @@ -61,12 +70,18 @@ def macro_placement(design, *, halo=None, channel=None, fence_region=None, snap_ if fence_region != None: if len(fence_region) != 4: - utl.error(utl.MPL, 194, f"fence_region receives a list with 4 values, {len(fence_region)} given.") + utl.error( + utl.MPL, + 194, + f"fence_region receives a list with 4 values, {len(fence_region)} given.", + ) lx, ly, ux, uy = fence_region if lx < core_lx or ly < core_ly or ux > core_ux or uy > core_uy: - utl.warn(utl.MPL, 185, "fence_region outside of core area. Using core area.") + utl.warn( + utl.MPL, 185, "fence_region outside of core area. Using core area." + ) design.getMacroPlacer().setFenceRegion(core_lx, core_ly, core_ux, core_uy) else: design.getMacroPlacer().setFenceRegion(lx, ly, ux, uy) @@ -92,23 +107,27 @@ def macro_placement(design, *, halo=None, channel=None, fence_region=None, snap_ elif style == "corner_min_wl": design.getMacroPlacer().placeMacrosCornerMinWL() else: - utl.error(utl.MPL, 196, "Unknown placement style. Use one of 'corner_max_wl' or 'corner_min_wl'.") + utl.error( + utl.MPL, + 196, + "Unknown placement style. Use one of 'corner_max_wl' or 'corner_min_wl'.", + ) def is_pos_int(x): if x == None: return False - elif isinstance(x, int) and x > 0 : + elif isinstance(x, int) and x > 0: return True else: utl.error(utl.GPL, 507, f"TypeError: {x} is not a positive integer") return False - + def is_pos_float(x): if x == None: return False - elif isinstance(x, float) and x >= 0 : + elif isinstance(x, float) and x >= 0: return True else: utl.error(utl.MPL, 202, f"TypeError: {x} is not a positive float") diff --git a/src/mpl/test/mpl_man_tcl_check.py b/src/mpl/test/mpl_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/mpl/test/mpl_man_tcl_check.py +++ b/src/mpl/test/mpl_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/mpl/test/mpl_readme_msgs_check.py b/src/mpl/test/mpl_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/mpl/test/mpl_readme_msgs_check.py +++ b/src/mpl/test/mpl_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/mpl2/test/mpl2_man_tcl_check.py b/src/mpl2/test/mpl2_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/mpl2/test/mpl2_man_tcl_check.py +++ b/src/mpl2/test/mpl2_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/mpl2/test/mpl2_readme_msgs_check.py b/src/mpl2/test/mpl2_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/mpl2/test/mpl2_readme_msgs_check.py +++ b/src/mpl2/test/mpl2_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/odb/src/codeGenerator/gen.py b/src/odb/src/codeGenerator/gen.py index ebae9b7d37b..75bde6016f2 100755 --- a/src/odb/src/codeGenerator/gen.py +++ b/src/odb/src/codeGenerator/gen.py @@ -25,14 +25,16 @@ std, ) + def get_json_files(directory): json_files = [] for root, _, files in os.walk(directory): for file in files: - if file.endswith('.json'): + if file.endswith(".json"): json_files.append(os.path.join(root, file)) return json_files + parser = argparse.ArgumentParser(description="Code generator") parser.add_argument("--json", action="store", required=True) parser.add_argument("--src_dir", action="store", required=True) @@ -54,7 +56,7 @@ def get_json_files(directory): numeric_level = getattr(logging, loglevel.upper(), None) if not isinstance(numeric_level, int): - raise ValueError('Invalid log level: %s' % loglevel) + raise ValueError("Invalid log level: %s" % loglevel) logging.basicConfig(level=numeric_level) with open(src, encoding="ascii") as file: @@ -74,7 +76,7 @@ def get_json_files(directory): print("###################Code Generation Begin###################") add_once_to_dict(["classes", "iterators", "relations"], schema) -for file_path in get_json_files(schema['classes_dir']): +for file_path in get_json_files(schema["classes_dir"]): with open(file_path, encoding="ascii") as file: klass = json.load(file) schema["classes"].append(klass) @@ -125,7 +127,9 @@ def get_json_files(directory): inParentField["table"] = True inParentField["dbSetGetter"] = True inParentField["components"] = [inParentField["name"]] - inParentField["flags"] = ["cmp", "serial", "diff", "no-set", "get"] + relation.get("flags", []) + inParentField["flags"] = ["cmp", "serial", "diff", "no-set", "get"] + relation.get( + "flags", [] + ) if "schema" in relation: inParentField["schema"] = relation["schema"] @@ -157,11 +161,14 @@ def get_json_files(directory): inChildNextEntry["type"] = "dbId<_" + relation["second"] + ">" inChildNextEntry["flags"] = ["cmp", "serial", "diff", "private", "no-deep"] schema["classes"][child]["fields"].append(inChildNextEntry) - logging.debug(f"Add hash field {inParentHashField['name']} to {relation['first']}") - logging.debug(f"Add hash field {inChildNextEntry['name']} to {relation['second']}") + logging.debug( + f"Add hash field {inParentHashField['name']} to {relation['first']}" + ) + logging.debug( + f"Add hash field {inChildNextEntry['name']} to {relation['second']}" + ) for klass in schema["classes"]: - # Adding functional name to fields and extracting field components struct = {"name": f"{klass['name']}Flags", "fields": [], "flags": ["no-serializer"]} klass["hasTables"] = False @@ -216,7 +223,8 @@ def get_json_files(directory): and template_class_name not in std and "no-template" not in field["flags"] and klass["name"] != template_class_name[1:] - and klass["name"]+"::" != template_class_name[0:len(klass["name"])+2] + and klass["name"] + "::" + != template_class_name[0 : len(klass["name"]) + 2] ): klass["classes"].append(template_class_name) #### @@ -265,7 +273,11 @@ def get_json_files(directory): field["setterArgumentType"] = field["getterReturnType"] = field["type"] # For fields that we need to free/destroy in the destructor - if field["name"] == '_name' and 'no-destruct' not in field["flags"] or "table" in field: + if ( + field["name"] == "_name" + and "no-destruct" not in field["flags"] + or "table" in field + ): klass["needs_non_default_destructor"] = True klass["fields"] = [field for field in klass["fields"] if "bits" not in field] @@ -286,7 +298,6 @@ def get_json_files(directory): struct["fields"].append(spare_bits_field) if len(struct["fields"]) > 0: - struct["in_class"] = True struct["in_class_name"] = "flags_" klass["structs"].insert(0, struct) @@ -361,8 +372,7 @@ def get_json_files(directory): p.parse_source_code(os.path.join("generated", item)) p.write_in_file(os.path.join(dr, item), keep_empty) else: - shutil.copy(os.path.join("generated", item), - os.path.join(dr, item)) + shutil.copy(os.path.join("generated", item), os.path.join(dr, item)) if item != "CMakeLists.txt": cf = ["clang-format", "-i", os.path.join(dr, item)] retcode = call(cf) diff --git a/src/odb/src/codeGenerator/helper.py b/src/odb/src/codeGenerator/helper.py index a83edef1605..97a64d6d299 100644 --- a/src/odb/src/codeGenerator/helper.py +++ b/src/odb/src/codeGenerator/helper.py @@ -152,7 +152,6 @@ def get_template_type(type_name): open_bracket = type_name.find("<") for i in range(open_bracket + 1, len(type_name)): - if type_name[i] == "<": num_brackets += 1 elif type_name[i] == ">": diff --git a/src/odb/test/odb_man_tcl_check.py b/src/odb/test/odb_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/odb/test/odb_man_tcl_check.py +++ b/src/odb/test/odb_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/odb/test/odb_readme_msgs_check.py b/src/odb/test/odb_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/odb/test/odb_readme_msgs_check.py +++ b/src/odb/test/odb_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/odb/test/unitTestsPython/TestBTerm.py b/src/odb/test/unitTestsPython/TestBTerm.py index 197d496d426..c5c114afc21 100644 --- a/src/odb/test/unitTestsPython/TestBTerm.py +++ b/src/odb/test/unitTestsPython/TestBTerm.py @@ -2,39 +2,43 @@ import helper import odbUnitTest + class TestBTerm(odbUnitTest.TestCase): def setUp(self): self.db, self.lib = helper.createSimpleDB() - blockName = '1LevelBlock' + blockName = "1LevelBlock" self.block = odb.dbBlock_create(self.db.getChip(), blockName) - self.and2 = self.lib.findMaster('and2') + self.and2 = self.lib.findMaster("and2") self.inst = odb.dbInst.create(self.block, self.and2, "inst") - self.iterm_a = self.inst.findITerm('a') - self.n_a = odb.dbNet.create(self.block, 'na') - self.n_b = odb.dbNet.create(self.block, 'nb') - self.bterm_a = odb.dbBTerm.create(self.n_a, 'IN_a') - + self.iterm_a = self.inst.findITerm("a") + self.n_a = odb.dbNet.create(self.block, "na") + self.n_b = odb.dbNet.create(self.block, "nb") + self.bterm_a = odb.dbBTerm.create(self.n_a, "IN_a") + def tearDown(self): self.db.destroy(self.db) + def test_idle(self): - self.assertEqual(self.bterm_a.getNet().getName(), 'na') + self.assertEqual(self.bterm_a.getNet().getName(), "na") self.assertEqual(self.n_a.getBTermCount(), 1) - self.assertEqual(self.n_a.getBTerms()[0].getName(), 'IN_a') + self.assertEqual(self.n_a.getBTerms()[0].getName(), "IN_a") self.assertEqual(self.n_b.getBTermCount(), 0) + def test_connect(self): self.bterm_a.connect(self.n_b) - self.assertEqual(self.bterm_a.getNet().getName(), 'nb') + self.assertEqual(self.bterm_a.getNet().getName(), "nb") self.assertEqual(self.n_a.getBTermCount(), 0) self.assertEqual(self.n_a.getBTerms(), []) self.assertEqual(self.n_b.getBTermCount(), 1) - self.assertEqual(self.n_b.getBTerms()[0].getName(), 'IN_a') + self.assertEqual(self.n_b.getBTerms()[0].getName(), "IN_a") + def test_disconnect(self): self.bterm_a.disconnect() self.assertIsNone(self.bterm_a.getNet()) self.assertEqual(self.n_a.getBTermCount(), 0) self.assertEqual(self.n_a.getBTerms(), []) - -if __name__=='__main__': + + +if __name__ == "__main__": odbUnitTest.mainParallel(TestBTerm) # odbUnitTest.main() - \ No newline at end of file diff --git a/src/odb/test/unitTestsPython/TestBlock.py b/src/odb/test/unitTestsPython/TestBlock.py index a109729e88b..6cc7431eca9 100644 --- a/src/odb/test/unitTestsPython/TestBlock.py +++ b/src/odb/test/unitTestsPython/TestBlock.py @@ -2,110 +2,147 @@ import helper import odbUnitTest + def placeInst(inst, x, y): inst.setLocation(x, y) - inst.setPlacementStatus('PLACED') - + inst.setPlacementStatus("PLACED") + + def placeBPin(bpin, layer, x1, y1, x2, y2): odb.dbBox_create(bpin, layer, x1, y1, x2, y2) - bpin.setPlacementStatus('PLACED') - + bpin.setPlacementStatus("PLACED") + + class TestBlock(odbUnitTest.TestCase): def setUp(self): self.db, self.lib = helper.createSimpleDB() - self.parentBlock = odb.dbBlock_create(self.db.getChip(), 'Parent') + self.parentBlock = odb.dbBlock_create(self.db.getChip(), "Parent") self.block = helper.create2LevelBlock(self.db, self.lib, self.parentBlock) self.block.setCornerCount(4) self.extcornerblock = self.block.createExtCornerBlock(1) - odb.dbTechNonDefaultRule_create(self.block, 'non_default_1') - self.parentRegion = odb.dbRegion_create(self.block, 'parentRegion') - self.childRegion = odb.dbRegion_create(self.parentRegion, 'childRegion') - + odb.dbTechNonDefaultRule_create(self.block, "non_default_1") + self.parentRegion = odb.dbRegion_create(self.block, "parentRegion") + self.childRegion = odb.dbRegion_create(self.parentRegion, "childRegion") def tearDown(self): self.db.destroy(self.db) + def test_find(self): - #bterm - self.assertEqual(self.block.findBTerm('IN1').getName(), 'IN1') - self.assertIsNone(self.block.findBTerm('in1')) - #child - self.assertEqual(self.parentBlock.findChild('2LevelBlock').getName(), '2LevelBlock') - self.assertIsNone(self.parentBlock.findChild('1LevelBlock')) - #inst - self.assertEqual(self.block.findInst('i3').getName(), 'i3') - self.assertIsNone(self.parentBlock.findInst('i3')) - #net - self.assertEqual(self.block.findNet('n2').getName(), 'n2') - self.assertIsNone(self.block.findNet('a')) - #iterm - self.assertEqual(self.block.findITerm('i1,o').getInst().getName(), 'i1') - self.assertEqual(self.block.findITerm('i1,o').getMTerm().getName(), 'o') - self.assertIsNone(self.block.findITerm('i1\o')) - #extcornerblock - self.assertEqual(self.block.findExtCornerBlock(1).getName(), 'extCornerBlock__1') + # bterm + self.assertEqual(self.block.findBTerm("IN1").getName(), "IN1") + self.assertIsNone(self.block.findBTerm("in1")) + # child + self.assertEqual( + self.parentBlock.findChild("2LevelBlock").getName(), "2LevelBlock" + ) + self.assertIsNone(self.parentBlock.findChild("1LevelBlock")) + # inst + self.assertEqual(self.block.findInst("i3").getName(), "i3") + self.assertIsNone(self.parentBlock.findInst("i3")) + # net + self.assertEqual(self.block.findNet("n2").getName(), "n2") + self.assertIsNone(self.block.findNet("a")) + # iterm + self.assertEqual(self.block.findITerm("i1,o").getInst().getName(), "i1") + self.assertEqual(self.block.findITerm("i1,o").getMTerm().getName(), "o") + self.assertIsNone(self.block.findITerm("i1\o")) + # extcornerblock + self.assertEqual( + self.block.findExtCornerBlock(1).getName(), "extCornerBlock__1" + ) self.assertIsNone(self.block.findExtCornerBlock(0)) - #nondefaultrule - self.assertEqual(self.block.findNonDefaultRule('non_default_1').getName(), 'non_default_1') - self.assertIsNone(self.block.findNonDefaultRule('non_default_2')) - #region - self.assertEqual(self.block.findRegion('parentRegion').getName(), 'parentRegion') - self.assertEqual(self.block.findRegion('childRegion').getName(), 'childRegion') - self.assertEqual(self.block.findRegion('childRegion').getParent().getName(), 'parentRegion') - - + # nondefaultrule + self.assertEqual( + self.block.findNonDefaultRule("non_default_1").getName(), "non_default_1" + ) + self.assertIsNone(self.block.findNonDefaultRule("non_default_2")) + # region + self.assertEqual( + self.block.findRegion("parentRegion").getName(), "parentRegion" + ) + self.assertEqual(self.block.findRegion("childRegion").getName(), "childRegion") + self.assertEqual( + self.block.findRegion("childRegion").getParent().getName(), "parentRegion" + ) + def check_box_rect(self, min_x, min_y, max_x, max_y): box = self.block.getBBox() self.assertEqual(box.xMin(), min_x) self.assertEqual(box.xMax(), max_x) self.assertEqual(box.yMin(), min_y) self.assertEqual(box.yMax(), max_y) - + def block_placement(self, test_num, flag): - if( (flag and test_num==1) or (not flag and test_num>=1) ): - if(flag): + if (flag and test_num == 1) or (not flag and test_num >= 1): + if flag: print("here") - placeInst(self.block.findInst('i1'), 0, 3000) - placeInst(self.block.findInst('i2'), -1000, 0) - placeInst(self.block.findInst('i3'), 2000, -1000) - if((flag and test_num==2) or (not flag and test_num>=2)): - placeBPin(self.block.findBTerm('OUT').getBPins()[0], self.lib.getTech().findLayer('L1'), 2500, -1000, 2550, -950) - if((flag and test_num==3) or (not flag and test_num>=3)): - odb.dbObstruction_create(self.block, self.lib.getTech().findLayer('L1'), -1500, 0, -1580, 50) - if((flag and test_num==4) or (not flag and test_num>=4)): - n_s = odb.dbNet_create(self.block, 'n_s') - swire = odb.dbSWire_create(n_s, 'NONE') - odb.dbSBox_create(swire, self.lib.getTech().findLayer('L1'), 0, 4000, 100, 4100, 'NONE') - if((flag and test_num==5) or (not flag and test_num>=5)): + placeInst(self.block.findInst("i1"), 0, 3000) + placeInst(self.block.findInst("i2"), -1000, 0) + placeInst(self.block.findInst("i3"), 2000, -1000) + if (flag and test_num == 2) or (not flag and test_num >= 2): + placeBPin( + self.block.findBTerm("OUT").getBPins()[0], + self.lib.getTech().findLayer("L1"), + 2500, + -1000, + 2550, + -950, + ) + if (flag and test_num == 3) or (not flag and test_num >= 3): + odb.dbObstruction_create( + self.block, self.lib.getTech().findLayer("L1"), -1500, 0, -1580, 50 + ) + if (flag and test_num == 4) or (not flag and test_num >= 4): + n_s = odb.dbNet_create(self.block, "n_s") + swire = odb.dbSWire_create(n_s, "NONE") + odb.dbSBox_create( + swire, self.lib.getTech().findLayer("L1"), 0, 4000, 100, 4100, "NONE" + ) + if (flag and test_num == 5) or (not flag and test_num >= 5): pass - #TODO ADD WIRE - + # TODO ADD WIRE + def test_bbox0(self): box = self.block.getBBox() self.check_box_rect(0, 0, 0, 0) + def test_bbox1(self): box = self.block.getBBox() - self.block_placement(1,False) + self.block_placement(1, False) self.check_box_rect(-1000, -1000, 2500, 4000) + def test_bbox2(self): box = self.block.getBBox() - self.block_placement(2,False) + self.block_placement(2, False) self.check_box_rect(-1000, -1000, 2550, 4000) + def test_bbox3(self): -# self.block_placement(2,False) -# box = self.block.getBBox() -# self.block_placement(3,True) - placeInst(self.block.findInst('i1'), 0, 3000) - placeInst(self.block.findInst('i2'), -1000, 0) - placeInst(self.block.findInst('i3'), 2000, -1000) - placeBPin(self.block.findBTerm('OUT').getBPins()[0], self.lib.getTech().findLayer('L1'), 2500, -1000, 2550, -950) + # self.block_placement(2,False) + # box = self.block.getBBox() + # self.block_placement(3,True) + placeInst(self.block.findInst("i1"), 0, 3000) + placeInst(self.block.findInst("i2"), -1000, 0) + placeInst(self.block.findInst("i3"), 2000, -1000) + placeBPin( + self.block.findBTerm("OUT").getBPins()[0], + self.lib.getTech().findLayer("L1"), + 2500, + -1000, + 2550, + -950, + ) box = self.block.getBBox() - odb.dbObstruction_create(self.block, self.lib.getTech().findLayer('L1'), -1500, 0, -1580, 50) + odb.dbObstruction_create( + self.block, self.lib.getTech().findLayer("L1"), -1500, 0, -1580, 50 + ) self.check_box_rect(-1580, -1000, 2550, 4000) + def test_bbox4(self): box = self.block.getBBox() - self.block_placement(4,False) + self.block_placement(4, False) self.check_box_rect(-1580, -1000, 2550, 4100) -if __name__=='__main__': + + +if __name__ == "__main__": odbUnitTest.mainParallel(TestBlock) # odbUnitTest.main() - diff --git a/src/odb/test/unitTestsPython/TestDestroy.py b/src/odb/test/unitTestsPython/TestDestroy.py index 99b25d877da..911941f5b70 100644 --- a/src/odb/test/unitTestsPython/TestDestroy.py +++ b/src/odb/test/unitTestsPython/TestDestroy.py @@ -8,21 +8,20 @@ class TestDestroy(odbUnitTest.TestCase): - def setUp(self): self.db, lib = helper.createSimpleDB() - self.parentBlock = odb.dbBlock_create(self.db.getChip(), 'Parent') + self.parentBlock = odb.dbBlock_create(self.db.getChip(), "Parent") self.block = helper.create2LevelBlock(self.db, lib, self.parentBlock) - self.i1 = self.block.findInst('i1') - self.i2 = self.block.findInst('i2') - self.i3 = self.block.findInst('i3') - self.n1 = self.i1.findITerm('a').getNet() - self.n2 = self.i1.findITerm('b').getNet() - self.n3 = self.i2.findITerm('a').getNet() - self.n4 = self.i2.findITerm('b').getNet() - self.n5 = self.i3.findITerm('a').getNet() - self.n6 = self.i3.findITerm('b').getNet() - self.n7 = self.i3.findITerm('o').getNet() + self.i1 = self.block.findInst("i1") + self.i2 = self.block.findInst("i2") + self.i3 = self.block.findInst("i3") + self.n1 = self.i1.findITerm("a").getNet() + self.n2 = self.i1.findITerm("b").getNet() + self.n3 = self.i2.findITerm("a").getNet() + self.n4 = self.i2.findITerm("b").getNet() + self.n5 = self.i3.findITerm("a").getNet() + self.n6 = self.i3.findITerm("b").getNet() + self.n7 = self.i3.findITerm("o").getNet() def tearDown(self): self.db.destroy(self.db) @@ -30,73 +29,73 @@ def tearDown(self): def test_destroy_net(self): self.n1.destroy(self.n1) # check for Inst - self.assertIsNone(self.i1.findITerm('a').getNet()) + self.assertIsNone(self.i1.findITerm("a").getNet()) # check for Iterms for iterm in self.block.getITerms(): - if (iterm.getNet() is None): - self.assertEqual(iterm.getInst().getName(), 'i1') - self.assertEqual(iterm.getMTerm().getName(), 'a') + if iterm.getNet() is None: + self.assertEqual(iterm.getInst().getName(), "i1") + self.assertEqual(iterm.getMTerm().getName(), "a") else: - self.assertNotEqual(iterm.getNet().getName(), 'n1') + self.assertNotEqual(iterm.getNet().getName(), "n1") # check for block and BTerms nets = self.block.getNets() for net in nets: - self.assertNotEqual(net.getName(), 'n1') + self.assertNotEqual(net.getName(), "n1") bterms = self.block.getBTerms() self.assertEqual(len(bterms), 4) for bterm in bterms: - self.assertNotEqual(bterm.getName(), 'IN1') - self.assertNotEqual(bterm.getNet().getName(), 'n1') - self.assertIsNone(self.block.findBTerm('IN1')) - self.assertIsNone(self.block.findNet('n1')) + self.assertNotEqual(bterm.getName(), "IN1") + self.assertNotEqual(bterm.getNet().getName(), "n1") + self.assertIsNone(self.block.findBTerm("IN1")) + self.assertIsNone(self.block.findNet("n1")) def test_destroy_inst(self): self.i1.destroy(self.i1) # check for block - self.assertIsNone(self.block.findInst('i1')) + self.assertIsNone(self.block.findInst("i1")) for inst in self.block.getInsts(): - self.assertNotEqual(inst.getName(), 'i1') + self.assertNotEqual(inst.getName(), "i1") self.assertEqual(len(self.block.getITerms()), 6) # check for Iterms for iterm in self.block.getITerms(): - self.assertNotIn(iterm.getNet().getName(), ['n1', 'n2']) - self.assertNotEqual(iterm.getInst().getName(), 'i1') + self.assertNotIn(iterm.getNet().getName(), ["n1", "n2"]) + self.assertNotEqual(iterm.getInst().getName(), "i1") # check for BTERMS - IN1 = self.block.findBTerm('IN1') + IN1 = self.block.findBTerm("IN1") self.assertIsNone(IN1.getITerm()) - IN2 = self.block.findBTerm('IN2') + IN2 = self.block.findBTerm("IN2") self.assertIsNone(IN2.getITerm()) # check for nets self.assertEqual(self.n1.getITermCount(), 0) self.assertEqual(self.n2.getITermCount(), 0) self.assertEqual(self.n5.getITermCount(), 1) - self.assertNotEqual(self.n5.getITerms()[0].getInst().getName(), 'i1') + self.assertNotEqual(self.n5.getITerms()[0].getInst().getName(), "i1") def test_destroy_bterm(self): - IN1 = self.block.findBTerm('IN1') + IN1 = self.block.findBTerm("IN1") IN1.destroy(IN1) # check for block and BTerms - self.assertIsNone(self.block.findBTerm('IN1')) + self.assertIsNone(self.block.findBTerm("IN1")) bterms = self.block.getBTerms() self.assertEqual(len(bterms), 4) for bterm in bterms: - self.assertNotEqual(bterm.getName(), 'IN1') + self.assertNotEqual(bterm.getName(), "IN1") # check for n1 self.assertEqual(self.n1.getBTermCount(), 0) self.assertEqual(self.n1.getBTerms(), []) def test_destroy_block(self): # creating a child block to parent block - _block = helper.create1LevelBlock(self.db, - self.db.getLibs()[0], - self.parentBlock) + _block = helper.create1LevelBlock( + self.db, self.db.getLibs()[0], self.parentBlock + ) self.assertEqual(len(self.parentBlock.getChildren()), 2) _block.destroy(_block) self.assertEqual(len(self.parentBlock.getChildren()), 1) odb.dbBlock_destroy(self.parentBlock) def test_destroy_bpin(self): - IN1 = self.block.findBTerm('IN1') + IN1 = self.block.findBTerm("IN1") self.assertEqual(len(IN1.getBPins()), 1) P1 = IN1.getBPins()[0] P1.destroy(P1) @@ -136,7 +135,7 @@ def test_destroy_lib(self): self.assertEqual(self.db.getLibs(), []) def test_destroy_swire(self): - swire = odb.dbSWire_create(self.n4, 'ROUTED') + swire = odb.dbSWire_create(self.n4, "ROUTED") self.assertNotEqual(self.n4.getSWires(), []) self.assertEqual(swire.getNet().getName(), self.n4.getName()) swire.destroy(swire) @@ -151,8 +150,8 @@ def test_destroy_obstruction(self): self.assertEqual(len(self.block.getObstructions()), 0) def setup_regions(self): - parentRegion = odb.dbRegion_create(self.block, 'parentRegion') - childRegion = odb.dbRegion_create(parentRegion, 'childRegion') + parentRegion = odb.dbRegion_create(self.block, "parentRegion") + childRegion = odb.dbRegion_create(parentRegion, "childRegion") childRegion.addInst(self.i1) return parentRegion, childRegion @@ -161,12 +160,10 @@ def test_create_regions(self): self.assertEqual(self.i1.getRegion().getName(), childRegion.getName()) self.assertEqual(len(parentRegion.getChildren()), 1) self.assertEqual(len(childRegion.getChildren()), 0) - self.assertEqual(parentRegion.getChildren()[0].getName(), - childRegion.getName()) + self.assertEqual(parentRegion.getChildren()[0].getName(), childRegion.getName()) self.assertEqual(len(self.block.getRegions()), 2) self.assertEqual(self.i1.getRegion().getName(), childRegion.getName()) - self.assertEqual(childRegion.getParent().getName(), - parentRegion.getName()) + self.assertEqual(childRegion.getParent().getName(), parentRegion.getName()) self.assertIsNone(parentRegion.getParent()) def test_destroy_region_child(self): @@ -175,8 +172,7 @@ def test_destroy_region_child(self): self.assertIsNone(self.i1.getRegion()) self.assertEqual(len(parentRegion.getChildren()), 0) self.assertEqual(len(self.block.getRegions()), 1) - self.assertEqual(self.block.getRegions()[0].getName(), - parentRegion.getName()) + self.assertEqual(self.block.getRegions()[0].getName(), parentRegion.getName()) def test_destroy_region_parent(self): parentRegion, childRegion = self.setup_regions() @@ -192,6 +188,6 @@ def test_destroy_trackgrid(self): self.assertIsNotNone(odb.dbTrackGrid_create(self.block, L1)) -if __name__=='__main__': +if __name__ == "__main__": odbUnitTest.mainParallel(TestDestroy) # odbUnitTest.main() diff --git a/src/odb/test/unitTestsPython/TestGroup.py b/src/odb/test/unitTestsPython/TestGroup.py index 3c60eb0aa7e..872a6b7114c 100644 --- a/src/odb/test/unitTestsPython/TestGroup.py +++ b/src/odb/test/unitTestsPython/TestGroup.py @@ -1,6 +1,8 @@ import opendbpy as odb import helper import odbUnitTest + + ################## ## ## This test is intended for testing swig wrap @@ -8,43 +10,47 @@ ################## class TestModule(odbUnitTest.TestCase): def setUp(self): - self.db, self.lib = helper.createSimpleDB() - self.block = helper.create1LevelBlock(self.db, self.lib, self.db.getChip()) - self.group = odb.dbGroup_create(self.block,"group") - self.domain = odb.dbGroup_create(self.block,"domain",0,0,100,100) - self.child = odb.dbGroup_create(self.block,"child") - self.master_mod = odb.dbModule_create(self.block,"master_mod") - self.parent_mod = odb.dbModule_create(self.block,"parent_mod") - self.i1 = odb.dbModInst_create(self.parent_mod,self.master_mod,"i1") - self.inst1 = self.block.findInst("inst") - self.n1 = self.block.findNet("n1") + self.db, self.lib = helper.createSimpleDB() + self.block = helper.create1LevelBlock(self.db, self.lib, self.db.getChip()) + self.group = odb.dbGroup_create(self.block, "group") + self.domain = odb.dbGroup_create(self.block, "domain", 0, 0, 100, 100) + self.child = odb.dbGroup_create(self.block, "child") + self.master_mod = odb.dbModule_create(self.block, "master_mod") + self.parent_mod = odb.dbModule_create(self.block, "parent_mod") + self.i1 = odb.dbModInst_create(self.parent_mod, self.master_mod, "i1") + self.inst1 = self.block.findInst("inst") + self.n1 = self.block.findNet("n1") + def tearDown(self): self.db.destroy(self.db) + def test_default(self): - self.check(self.group,"getName","group") + self.check(self.group, "getName", "group") print("") - self.assertEqual(self.block.findGroup("group").getName(),"group") - self.assertEqual(len(self.block.getGroups()),3) - self.assertEqual(self.domain.getBox().xMax(),100) + self.assertEqual(self.block.findGroup("group").getName(), "group") + self.assertEqual(len(self.block.getGroups()), 3) + self.assertEqual(self.domain.getBox().xMax(), 100) self.group.addModInst(self.i1) - self.assertEqual(self.group.getModInsts()[0].getName(),"i1") - self.assertEqual(self.i1.getGroup().getName(),"group") + self.assertEqual(self.group.getModInsts()[0].getName(), "i1") + self.assertEqual(self.i1.getGroup().getName(), "group") self.group.removeModInst(self.i1) self.group.addInst(self.inst1) - self.assertEqual(self.group.getInsts()[0].getName(),"inst") - self.assertEqual(self.inst1.getGroup().getName(),"group") + self.assertEqual(self.group.getInsts()[0].getName(), "inst") + self.assertEqual(self.inst1.getGroup().getName(), "group") self.group.removeInst(self.inst1) self.group.addGroup(self.child) - self.assertEqual(self.group.getGroups()[0].getName(),"child") - self.assertEqual(self.child.getParentGroup().getName(),"group") + self.assertEqual(self.group.getGroups()[0].getName(), "child") + self.assertEqual(self.child.getParentGroup().getName(), "group") self.group.removeGroup(self.child) self.group.addPowerNet(self.n1) - self.assertEqual(self.group.getPowerNets()[0].getName(),"n1") + self.assertEqual(self.group.getPowerNets()[0].getName(), "n1") self.group.addGroundNet(self.n1) - self.assertEqual(self.group.getGroundNets()[0].getName(),"n1") + self.assertEqual(self.group.getGroundNets()[0].getName(), "n1") self.group.removeNet(self.n1) - self.assertEqual(self.group.getType(),"PHYSICAL_CLUSTER") + self.assertEqual(self.group.getType(), "PHYSICAL_CLUSTER") self.group.setType("VOLTAGE_DOMAIN") self.group.destroy(self.group) -if __name__=='__main__': - odbUnitTest.mainParallel(TestModule) + + +if __name__ == "__main__": + odbUnitTest.mainParallel(TestModule) diff --git a/src/odb/test/unitTestsPython/TestITerm.py b/src/odb/test/unitTestsPython/TestITerm.py index 74840278e82..171f680e66f 100644 --- a/src/odb/test/unitTestsPython/TestITerm.py +++ b/src/odb/test/unitTestsPython/TestITerm.py @@ -2,82 +2,97 @@ import helper import odbUnitTest + class TestITerm(odbUnitTest.TestCase): def setUp(self): self.db, self.lib = helper.createSimpleDB() - blockName = '1LevelBlock' + blockName = "1LevelBlock" self.block = odb.dbBlock_create(self.db.getChip(), blockName) - self.and2 = self.lib.findMaster('and2') + self.and2 = self.lib.findMaster("and2") self.inst = odb.dbInst.create(self.block, self.and2, "inst") - self.iterm_a = self.inst.findITerm('a') - + self.iterm_a = self.inst.findITerm("a") + def tearDown(self): self.db.destroy(self.db) + def test_idle(self): self.assertIsNone(self.iterm_a.getNet()) + def test_connection_from_iterm(self): - #Create net and Connect - n = odb.dbNet_create(self.block, 'n1') + # Create net and Connect + n = odb.dbNet_create(self.block, "n1") self.assertEqual(n.getITermCount(), 0) self.assertEqual(n.getITerms(), []) self.iterm_a.connect(self.iterm_a, n) self.iterm_a.setConnected() - self.assertEqual(self.iterm_a.getNet().getName(), 'n1') + self.assertEqual(self.iterm_a.getNet().getName(), "n1") self.assertEqual(n.getITermCount(), 1) - self.assertEqual(n.getITerms()[0].getMTerm().getName(), 'a') + self.assertEqual(n.getITerms()[0].getMTerm().getName(), "a") self.assertTrue(self.iterm_a.isConnected()) - #disconnect + # disconnect self.iterm_a.disconnect(self.iterm_a) self.iterm_a.clearConnected() self.assertEqual(n.getITermCount(), 0) self.assertEqual(n.getITerms(), []) self.assertIsNone(self.iterm_a.getNet()) self.assertFalse(self.iterm_a.isConnected()) + def test_connection_from_inst(self): - #Create net and Connect - n = odb.dbNet_create(self.block, 'n1') + # Create net and Connect + n = odb.dbNet_create(self.block, "n1") self.assertEqual(n.getITermCount(), 0) self.assertEqual(n.getITerms(), []) - self.iterm_a.connect(self.inst, n, self.inst.getMaster().findMTerm('a')) + self.iterm_a.connect(self.inst, n, self.inst.getMaster().findMTerm("a")) self.iterm_a.setConnected() - self.assertEqual(self.iterm_a.getNet().getName(), 'n1') + self.assertEqual(self.iterm_a.getNet().getName(), "n1") self.assertEqual(n.getITermCount(), 1) - self.assertEqual(n.getITerms()[0].getMTerm().getName(), 'a') + self.assertEqual(n.getITerms()[0].getMTerm().getName(), "a") self.assertTrue(self.iterm_a.isConnected()) - #disconnect + # disconnect self.iterm_a.disconnect(self.iterm_a) self.iterm_a.clearConnected() self.assertEqual(n.getITermCount(), 0) self.assertEqual(n.getITerms(), []) self.assertIsNone(self.iterm_a.getNet()) self.assertFalse(self.iterm_a.isConnected()) + def test_avgxy_R0(self): x = odb.new_int(0) y = odb.new_int(0) - self.assertFalse(self.iterm_a.getAvgXY(x, y)) #no mpin to work on - mterm_a = self.and2.findMTerm('a') + self.assertFalse(self.iterm_a.getAvgXY(x, y)) # no mpin to work on + mterm_a = self.and2.findMTerm("a") mpin_a = odb.dbMPin_create(mterm_a) - self.assertFalse(self.iterm_a.getAvgXY(x, y)) #no boxes to work on - geo_box_a_1 = odb.dbBox_create(mpin_a, self.lib.getTech().getLayers()[0], 0, 0, 50, 50) + self.assertFalse(self.iterm_a.getAvgXY(x, y)) # no boxes to work on + geo_box_a_1 = odb.dbBox_create( + mpin_a, self.lib.getTech().getLayers()[0], 0, 0, 50, 50 + ) self.assertTrue(self.iterm_a.getAvgXY(x, y)) - self.assertEqual(odb.get_int(x), int((0+50)/2)) - self.assertEqual(odb.get_int(y), int((0+50)/2)) - geo_box_a_2 = odb.dbBox_create(mpin_a, self.lib.getTech().getLayers()[0], 5, 10, 100, 100) + self.assertEqual(odb.get_int(x), int((0 + 50) / 2)) + self.assertEqual(odb.get_int(y), int((0 + 50) / 2)) + geo_box_a_2 = odb.dbBox_create( + mpin_a, self.lib.getTech().getLayers()[0], 5, 10, 100, 100 + ) self.assertTrue(self.iterm_a.getAvgXY(x, y)) - self.assertEqual(odb.get_int(x), int( ((0+50)+(5+100))/4 ) ) - self.assertEqual(odb.get_int(y), int( ((0+50)+(10+100))/4 ) ) + self.assertEqual(odb.get_int(x), int(((0 + 50) + (5 + 100)) / 4)) + self.assertEqual(odb.get_int(y), int(((0 + 50) + (10 + 100)) / 4)) + def test_avgxy_R90(self): x = odb.new_int(0) y = odb.new_int(0) - mterm_a = self.and2.findMTerm('a') + mterm_a = self.and2.findMTerm("a") mpin_a = odb.dbMPin_create(mterm_a) - geo_box_a_1 = odb.dbBox_create(mpin_a, self.lib.getTech().getLayers()[0], 0, 0, 50, 50) - geo_box_a_2 = odb.dbBox_create(mpin_a, self.lib.getTech().getLayers()[0], 0, 0, 100, 100) - self.inst.setOrient('R90') + geo_box_a_1 = odb.dbBox_create( + mpin_a, self.lib.getTech().getLayers()[0], 0, 0, 50, 50 + ) + geo_box_a_2 = odb.dbBox_create( + mpin_a, self.lib.getTech().getLayers()[0], 0, 0, 100, 100 + ) + self.inst.setOrient("R90") self.assertTrue(self.iterm_a.getAvgXY(x, y)) - self.assertEqual(odb.get_int(x), int( ((0+50)+(0+100))/4 )*-1 ) - self.assertEqual(odb.get_int(y), int( ((0+50)+(0+100))/4 ) ) -if __name__=='__main__': + self.assertEqual(odb.get_int(x), int(((0 + 50) + (0 + 100)) / 4) * -1) + self.assertEqual(odb.get_int(y), int(((0 + 50) + (0 + 100)) / 4)) + + +if __name__ == "__main__": odbUnitTest.mainParallel(TestITerm) # odbUnitTest.main() - \ No newline at end of file diff --git a/src/odb/test/unitTestsPython/TestInst.py b/src/odb/test/unitTestsPython/TestInst.py index ac6a3a54a9a..40acb739aee 100644 --- a/src/odb/test/unitTestsPython/TestInst.py +++ b/src/odb/test/unitTestsPython/TestInst.py @@ -2,36 +2,38 @@ import helper import odbUnitTest + class TestInst(odbUnitTest.TestCase): def setUp(self): self.db, self.lib = helper.createSimpleDB() self.block = helper.create2LevelBlock(self.db, self.lib, self.db.getChip()) - self.i1 = self.block.findInst('i1') - + self.i1 = self.block.findInst("i1") + def tearDown(self): self.db.destroy(self.db) + def test_swap_master(self): - self.assertEqual(self.i1.getMaster().getName(), 'and2') - #testing with a gate with different mterm names - gate = helper.createMaster2X1(self.lib, '_g2', 800, 800, '_a', '_b', '_o') + self.assertEqual(self.i1.getMaster().getName(), "and2") + # testing with a gate with different mterm names + gate = helper.createMaster2X1(self.lib, "_g2", 800, 800, "_a", "_b", "_o") self.assertFalse(self.i1.swapMaster(gate)) - self.assertNotEqual(self.i1.getMaster().getName(), '_g2') + self.assertNotEqual(self.i1.getMaster().getName(), "_g2") for iterm in self.i1.getITerms(): - self.assertNotIn(iterm.getMTerm().getName(), ['_a', '_b', '_o']) - #testing with a gate with different mterms number - gate = helper.createMaster3X1(self.lib, '_g3', 800, 800, '_a', '_b', '_c', '_o') + self.assertNotIn(iterm.getMTerm().getName(), ["_a", "_b", "_o"]) + # testing with a gate with different mterms number + gate = helper.createMaster3X1(self.lib, "_g3", 800, 800, "_a", "_b", "_c", "_o") self.assertFalse(self.i1.swapMaster(gate)) - self.assertNotEqual(self.i1.getMaster().getName(), '_g3') + self.assertNotEqual(self.i1.getMaster().getName(), "_g3") for iterm in self.i1.getITerms(): - self.assertNotIn(iterm.getMTerm().getName(), ['_a', '_b', '_c', '_o']) - #testing with a gate with same mterm names - gate = helper.createMaster2X1(self.lib, 'g2', 800, 800, 'a', 'b', 'o') + self.assertNotIn(iterm.getMTerm().getName(), ["_a", "_b", "_c", "_o"]) + # testing with a gate with same mterm names + gate = helper.createMaster2X1(self.lib, "g2", 800, 800, "a", "b", "o") self.assertTrue(self.i1.swapMaster(gate)) - self.assertEqual(self.i1.getMaster().getName(), 'g2') + self.assertEqual(self.i1.getMaster().getName(), "g2") self.assertEqual(self.i1.getMaster().getWidth(), 800) self.assertEqual(self.i1.getMaster().getHeight(), 800) - -if __name__=='__main__': + + +if __name__ == "__main__": odbUnitTest.mainParallel(TestInst) # odbUnitTest.main() - \ No newline at end of file diff --git a/src/odb/test/unitTestsPython/TestModule.py b/src/odb/test/unitTestsPython/TestModule.py index 685bfe7a4d3..6f697f1b71f 100644 --- a/src/odb/test/unitTestsPython/TestModule.py +++ b/src/odb/test/unitTestsPython/TestModule.py @@ -1,6 +1,8 @@ import opendbpy as odb import helper import odbUnitTest + + ################## ## ## This test is intended for testing swig wrap @@ -10,27 +12,31 @@ class TestModule(odbUnitTest.TestCase): def setUp(self): self.db, self.lib = helper.createSimpleDB() self.block = helper.create1LevelBlock(self.db, self.lib, self.db.getChip()) - self.master_mod = odb.dbModule_create(self.block,"master_mod") - self.parent_mod = odb.dbModule_create(self.block,"parent_mod") - self.i1 = odb.dbModInst_create(self.parent_mod,self.master_mod,"i1") - self.inst1 = self.block.findInst("inst") + self.master_mod = odb.dbModule_create(self.block, "master_mod") + self.parent_mod = odb.dbModule_create(self.block, "parent_mod") + self.i1 = odb.dbModInst_create(self.parent_mod, self.master_mod, "i1") + self.inst1 = self.block.findInst("inst") + def tearDown(self): self.db.destroy(self.db) + def test_default(self): - self.check(self.master_mod,"getName","master_mod") - self.assertEqual(self.block.findModule("parent_mod").getName(),"parent_mod") - self.assertEqual(self.i1.getName(),"i1") - self.assertEqual(self.i1.getParent().getName(),"parent_mod") - self.assertEqual(self.i1.getMaster().getName(),"master_mod") - self.assertEqual(self.master_mod.getModInst().getName(),"i1") - self.assertEqual(self.parent_mod.getChildren()[0].getName(),"i1") - self.assertEqual(self.block.getModInsts()[0].getName(),"i1") + self.check(self.master_mod, "getName", "master_mod") + self.assertEqual(self.block.findModule("parent_mod").getName(), "parent_mod") + self.assertEqual(self.i1.getName(), "i1") + self.assertEqual(self.i1.getParent().getName(), "parent_mod") + self.assertEqual(self.i1.getMaster().getName(), "master_mod") + self.assertEqual(self.master_mod.getModInst().getName(), "i1") + self.assertEqual(self.parent_mod.getChildren()[0].getName(), "i1") + self.assertEqual(self.block.getModInsts()[0].getName(), "i1") self.parent_mod.addInst(self.inst1) - self.assertEqual(self.parent_mod.getInsts()[0].getName(),"inst") - self.assertEqual(self.inst1.getModule().getName(),"parent_mod") + self.assertEqual(self.parent_mod.getInsts()[0].getName(), "inst") + self.assertEqual(self.inst1.getModule().getName(), "parent_mod") self.parent_mod.removeInst(self.inst1) - self.assertEqual(self.parent_mod.findModInst("i1").getName(),"i1") + self.assertEqual(self.parent_mod.findModInst("i1").getName(), "i1") self.i1.destroy(self.i1) self.parent_mod.destroy(self.parent_mod) -if __name__=='__main__': - odbUnitTest.mainParallel(TestModule) \ No newline at end of file + + +if __name__ == "__main__": + odbUnitTest.mainParallel(TestModule) diff --git a/src/odb/test/unitTestsPython/TestNet.py b/src/odb/test/unitTestsPython/TestNet.py index f94a1b60ba7..3cd0ed747a4 100644 --- a/src/odb/test/unitTestsPython/TestNet.py +++ b/src/odb/test/unitTestsPython/TestNet.py @@ -2,48 +2,59 @@ import helper import odbUnitTest -#TestNet: A unit test class for class dbNet -#it inherits from odbunittest.TestCase and has access to the testing functions(asserts) + +# TestNet: A unit test class for class dbNet +# it inherits from odbunittest.TestCase and has access to the testing functions(asserts) class TestNet(odbUnitTest.TestCase): - #This Function is called before each of the test cases defined below - #You should use it to create the instances you need to test (in our case n1, n2, n3) + # This Function is called before each of the test cases defined below + # You should use it to create the instances you need to test (in our case n1, n2, n3) def setUp(self): self.db, lib = helper.createSimpleDB() block = helper.create1LevelBlock(self.db, lib, self.db.getChip()) inst = block.getInsts()[0] - self.n1 = inst.findITerm('a').getNet() - self.n2 = inst.findITerm('b').getNet() - self.n3 = inst.findITerm('o').getNet() - #this function is called after each of the test cases - #you should free up space and destroy unneeded objects(cleanup step) + self.n1 = inst.findITerm("a").getNet() + self.n2 = inst.findITerm("b").getNet() + self.n3 = inst.findITerm("o").getNet() + + # this function is called after each of the test cases + # you should free up space and destroy unneeded objects(cleanup step) def tearDown(self): self.db.destroy(self.db) - - #each test case should start with the name "test" + + # each test case should start with the name "test" def test_naming(self): - self.changeAndTest(self.n1, 'rename', 'getName', '_n1', '_n1') - self.check(self.n1, 'getConstName', '_n1') - self.assertFalse(self.change(self.n1, 'rename', 'n2')) + self.changeAndTest(self.n1, "rename", "getName", "_n1", "_n1") + self.check(self.n1, "getConstName", "_n1") + self.assertFalse(self.change(self.n1, "rename", "n2")) + def test_dbSetterAndGetter(self): - self.changeAndTest(self.n1, 'setRCDisconnected', 'isRCDisconnected', False, False) - self.changeAndTest(self.n1, 'setRCDisconnected', 'isRCDisconnected', True, True) - self.changeAndTest(self.n1, 'setWeight', 'getWeight', 2, 2) - self.changeAndTest(self.n1, 'setSourceType', 'getSourceType', 'NETLIST', 'NETLIST') - self.changeAndTest(self.n1, 'setXTalkClass', 'getXTalkClass', 1, 1) - self.changeAndTest(self.n1, 'setCcAdjustFactor', 'getCcAdjustFactor', 1, 1) - self.changeAndTest(self.n1, 'setSigType', 'getSigType', 'RESET', 'RESET') + self.changeAndTest( + self.n1, "setRCDisconnected", "isRCDisconnected", False, False + ) + self.changeAndTest(self.n1, "setRCDisconnected", "isRCDisconnected", True, True) + self.changeAndTest(self.n1, "setWeight", "getWeight", 2, 2) + self.changeAndTest( + self.n1, "setSourceType", "getSourceType", "NETLIST", "NETLIST" + ) + self.changeAndTest(self.n1, "setXTalkClass", "getXTalkClass", 1, 1) + self.changeAndTest(self.n1, "setCcAdjustFactor", "getCcAdjustFactor", 1, 1) + self.changeAndTest(self.n1, "setSigType", "getSigType", "RESET", "RESET") + def test_dbCc(self): - self.changeAndTest(self.n1, 'setDbCc', 'getDbCc', 2, 2) - self.changeAndTest(self.n1, 'addDbCc', 'getDbCc', 5, 3) + self.changeAndTest(self.n1, "setDbCc", "getDbCc", 2, 2) + self.changeAndTest(self.n1, "addDbCc", "getDbCc", 5, 3) + def test_cc(self): node2 = odb.dbCapNode_create(self.n2, 0, False) node1 = odb.dbCapNode_create(self.n1, 1, False) node1.setInternalFlag() ccseg = odb.dbCCSeg_create(node1, node2) self.n1.calibrateCouplingCap() - self.check(self.n1, 'maxInternalCapNum', 1) - self.check(self.n1, 'groundCC', True, 1) - self.check(self.n2, 'groundCC', False, 1) - self.check(self.n1, 'getCcCount', 1) -if __name__=='__main__': - odbUnitTest.mainParallel(TestNet) \ No newline at end of file + self.check(self.n1, "maxInternalCapNum", 1) + self.check(self.n1, "groundCC", True, 1) + self.check(self.n2, "groundCC", False, 1) + self.check(self.n1, "getCcCount", 1) + + +if __name__ == "__main__": + odbUnitTest.mainParallel(TestNet) diff --git a/src/odb/test/unitTestsPython/TestWireCodec.py b/src/odb/test/unitTestsPython/TestWireCodec.py index c3968347337..01b746d49a7 100644 --- a/src/odb/test/unitTestsPython/TestWireCodec.py +++ b/src/odb/test/unitTestsPython/TestWireCodec.py @@ -4,17 +4,38 @@ class TestWireCodec(odbUnitTest.TestCase): - #This Function is called before each of the test cases defined below + # This Function is called before each of the test cases defined below def setUp(self): - self.db, self.tech, self.m1, self.m2, self.m3, self.v12, self.v23 = helper.createMultiLayerDB() - self.chip = odb.dbChip_create(self.db) + ( + self.db, + self.tech, + self.m1, + self.m2, + self.m3, + self.v12, + self.v23, + ) = helper.createMultiLayerDB() + self.chip = odb.dbChip_create(self.db) self.block = odb.dbBlock_create(self.chip, "chip") - self.net = odb.dbNet_create(self.block, "net") - self.wire = odb.dbWire_create(self.net) - self.pathsEnums = ["PATH", "JUNCTION", "SHORT", "VWIRE", "POINT", "POINT_EXT", "VIA", "TECH_VIA", "RECT", "ITERM", "BTERM", "RULE", "END_DECODE"] - - - #this function is called after each of the test cases + self.net = odb.dbNet_create(self.block, "net") + self.wire = odb.dbWire_create(self.net) + self.pathsEnums = [ + "PATH", + "JUNCTION", + "SHORT", + "VWIRE", + "POINT", + "POINT_EXT", + "VIA", + "TECH_VIA", + "RECT", + "ITERM", + "BTERM", + "RULE", + "END_DECODE", + ] + + # this function is called after each of the test cases def tearDown(self): self.db.destroy(self.db) @@ -40,16 +61,12 @@ def test_decoder(self): encoder.addPoint(3000, 18000, 6000) encoder.end() - - decoder = odb.dbWireDecoder() decoder.begin(self.wire) - # Encoding started with a path nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.PATH - # Check first point nextOp = decoder.next() @@ -57,49 +74,42 @@ def test_decoder(self): point = decoder.getPoint() assert point == [2000, 2000] - # Check second point nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.POINT point = decoder.getPoint() assert point == [10000, 2000] - # Check third point nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.POINT point = decoder.getPoint() assert point == [18000, 2000] - # Check first junction id nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.JUNCTION jid = decoder.getJunctionValue() assert jid == j1 - # Check junction point nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.POINT point = decoder.getPoint() assert point == [10000, 2000] - # Check tech via nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.TECH_VIA tchVia = decoder.getTechVia() assert tchVia.getName() == self.v12.getName() - # Check next point nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.POINT point = decoder.getPoint() assert point == [10000, 10000] - # Check next point nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.POINT @@ -112,35 +122,30 @@ def test_decoder(self): jid = decoder.getJunctionValue() assert jid == j2 - # Check junction point nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.POINT point = decoder.getPoint() assert point == [10000, 10000] - # Check tech via nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.TECH_VIA tchVia = decoder.getTechVia() assert tchVia.getName() == self.v12.getName() - # Check next point nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.POINT_EXT point = decoder.getPoint_ext() assert point == [23000, 10000, 4000] - # Check third junction id nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.JUNCTION jid = decoder.getJunctionValue() assert jid == j3 - # Check junction point nextOp = decoder.next() assert nextOp == odb.dbWireDecoder.POINT @@ -178,6 +183,5 @@ def test_decoder(self): assert point == [3000, 18000, 6000] - -if __name__=='__main__': - odbUnitTest.mainParallel(TestWireCodec) \ No newline at end of file +if __name__ == "__main__": + odbUnitTest.mainParallel(TestWireCodec) diff --git a/src/odb/test/unitTestsPython/helper.py b/src/odb/test/unitTestsPython/helper.py index 2c808a45f8c..6c63e7d392a 100644 --- a/src/odb/test/unitTestsPython/helper.py +++ b/src/odb/test/unitTestsPython/helper.py @@ -4,12 +4,12 @@ def createSimpleDB(): db = odb.dbDatabase.create() tech = odb.dbTech.create(db) - L1 = odb.dbTechLayer_create(tech, 'L1', 'ROUTING') + L1 = odb.dbTechLayer_create(tech, "L1", "ROUTING") lib = odb.dbLib.create(db, "lib") odb.dbChip.create(db) # Creating Master and2 and or2 - and2 = createMaster2X1(lib, 'and2', 1000, 1000, 'a', 'b', 'o') - or2 = createMaster2X1(lib, 'or2', 500, 500, 'a', 'b', 'o') + and2 = createMaster2X1(lib, "and2", 1000, 1000, "a", "b", "o") + or2 = createMaster2X1(lib, "or2", 500, 500, "a", "b", "o") return db, lib @@ -17,11 +17,11 @@ def createMultiLayerDB(): db = odb.dbDatabase.create() tech = odb.dbTech.create(db) - m1 = odb.dbTechLayer_create(tech, "M1", 'ROUTING') + m1 = odb.dbTechLayer_create(tech, "M1", "ROUTING") m1.setWidth(2000) - m2 = odb.dbTechLayer_create(tech, "M2", 'ROUTING') + m2 = odb.dbTechLayer_create(tech, "M2", "ROUTING") m2.setWidth(2000) - m3 = odb.dbTechLayer_create(tech, "M3", 'ROUTING') + m3 = odb.dbTechLayer_create(tech, "M3", "ROUTING") m3.setWidth(2000) v12 = odb.dbTechVia_create(tech, "VIA12") @@ -43,25 +43,25 @@ def createMultiLayerDB(): # IN2--------|b / # +----- def create1LevelBlock(db, lib, parent): - blockName = '1LevelBlock' - block = odb.dbBlock_create(parent, blockName, ',') + blockName = "1LevelBlock" + block = odb.dbBlock_create(parent, blockName, ",") # Creating Master and2 and instance inst - and2 = lib.findMaster('and2') + and2 = lib.findMaster("and2") inst = odb.dbInst.create(block, and2, "inst") # creating our nets n1 = odb.dbNet.create(block, "n1") n2 = odb.dbNet.create(block, "n2") n3 = odb.dbNet.create(block, "n3") - IN1 = odb.dbBTerm.create(n1, 'IN1') - IN1.setIoType('INPUT') - IN2 = odb.dbBTerm.create(n2, 'IN2') - IN2.setIoType('INPUT') - OUT = odb.dbBTerm.create(n3, 'OUT') - OUT.setIoType('OUTPUT') + IN1 = odb.dbBTerm.create(n1, "IN1") + IN1.setIoType("INPUT") + IN2 = odb.dbBTerm.create(n2, "IN2") + IN2.setIoType("INPUT") + OUT = odb.dbBTerm.create(n3, "OUT") + OUT.setIoType("OUTPUT") # connecting nets - odb.dbITerm.connect(inst, n1, inst.getMaster().findMTerm('a')) - odb.dbITerm.connect(inst, n2, inst.getMaster().findMTerm('b')) - odb.dbITerm.connect(inst, n3, inst.getMaster().findMTerm('o')) + odb.dbITerm.connect(inst, n1, inst.getMaster().findMTerm("a")) + odb.dbITerm.connect(inst, n2, inst.getMaster().findMTerm("b")) + odb.dbITerm.connect(inst, n3, inst.getMaster().findMTerm("o")) return block @@ -78,11 +78,11 @@ def create1LevelBlock(db, lib, parent): # IN4--------|b / # +----- def create2LevelBlock(db, lib, parent): - blockName = '2LevelBlock' - block = odb.dbBlock_create(parent, blockName, ',') + blockName = "2LevelBlock" + block = odb.dbBlock_create(parent, blockName, ",") - and2 = lib.findMaster('and2') - or2 = lib.findMaster('or2') + and2 = lib.findMaster("and2") + or2 = lib.findMaster("or2") # creating instances i1 = odb.dbInst.create(block, and2, "i1") i2 = odb.dbInst.create(block, and2, "i2") @@ -96,28 +96,28 @@ def create2LevelBlock(db, lib, parent): n6 = odb.dbNet.create(block, "n6") n7 = odb.dbNet.create(block, "n7") - IN1 = odb.dbBTerm.create(n1, 'IN1') - IN1.setIoType('INPUT') - IN2 = odb.dbBTerm.create(n2, 'IN2') - IN2.setIoType('INPUT') - IN3 = odb.dbBTerm.create(n3, 'IN3') - IN3.setIoType('INPUT') - IN4 = odb.dbBTerm.create(n4, 'IN4') - IN4.setIoType('INPUT') - OUT = odb.dbBTerm.create(n7, 'OUT') - OUT.setIoType('OUTPUT') + IN1 = odb.dbBTerm.create(n1, "IN1") + IN1.setIoType("INPUT") + IN2 = odb.dbBTerm.create(n2, "IN2") + IN2.setIoType("INPUT") + IN3 = odb.dbBTerm.create(n3, "IN3") + IN3.setIoType("INPUT") + IN4 = odb.dbBTerm.create(n4, "IN4") + IN4.setIoType("INPUT") + OUT = odb.dbBTerm.create(n7, "OUT") + OUT.setIoType("OUTPUT") # connecting nets - odb.dbITerm.connect(i1, n1, i1.getMaster().findMTerm('a')) - odb.dbITerm.connect(i1, n2, i1.getMaster().findMTerm('b')) - odb.dbITerm.connect(i1, n5, i1.getMaster().findMTerm('o')) + odb.dbITerm.connect(i1, n1, i1.getMaster().findMTerm("a")) + odb.dbITerm.connect(i1, n2, i1.getMaster().findMTerm("b")) + odb.dbITerm.connect(i1, n5, i1.getMaster().findMTerm("o")) - odb.dbITerm.connect(i2, n3, i2.getMaster().findMTerm('a')) - odb.dbITerm.connect(i2, n4, i2.getMaster().findMTerm('b')) - odb.dbITerm.connect(i2, n6, i2.getMaster().findMTerm('o')) + odb.dbITerm.connect(i2, n3, i2.getMaster().findMTerm("a")) + odb.dbITerm.connect(i2, n4, i2.getMaster().findMTerm("b")) + odb.dbITerm.connect(i2, n6, i2.getMaster().findMTerm("o")) - odb.dbITerm.connect(i3, n5, i3.getMaster().findMTerm('a')) - odb.dbITerm.connect(i3, n6, i3.getMaster().findMTerm('b')) - odb.dbITerm.connect(i3, n7, i3.getMaster().findMTerm('o')) + odb.dbITerm.connect(i3, n5, i3.getMaster().findMTerm("a")) + odb.dbITerm.connect(i3, n6, i3.getMaster().findMTerm("b")) + odb.dbITerm.connect(i3, n7, i3.getMaster().findMTerm("o")) P1 = odb.dbBPin_create(IN1) P2 = odb.dbBPin_create(IN2) @@ -137,10 +137,10 @@ def createMaster2X1(lib, name, width, height, in1, in2, out): master = odb.dbMaster_create(lib, name) master.setWidth(width) master.setHeight(height) - master.setType('CORE') - odb.dbMTerm.create(master, in1, 'INPUT') - odb.dbMTerm.create(master, in2, 'INPUT') - odb.dbMTerm.create(master, out, 'OUTPUT') + master.setType("CORE") + odb.dbMTerm.create(master, in1, "INPUT") + odb.dbMTerm.create(master, in2, "INPUT") + odb.dbMTerm.create(master, out, "OUTPUT") master.setFrozen() return master @@ -149,10 +149,10 @@ def createMaster3X1(lib, name, width, height, in1, in2, in3, out): master = odb.dbMaster_create(lib, name) master.setWidth(width) master.setHeight(height) - master.setType('CORE') - odb.dbMTerm.create(master, in1, 'INPUT') - odb.dbMTerm.create(master, in2, 'INPUT') - odb.dbMTerm.create(master, in3, 'INPUT') - odb.dbMTerm.create(master, out, 'OUTPUT') + master.setType("CORE") + odb.dbMTerm.create(master, in1, "INPUT") + odb.dbMTerm.create(master, in2, "INPUT") + odb.dbMTerm.create(master, in3, "INPUT") + odb.dbMTerm.create(master, out, "OUTPUT") master.setFrozen() return master diff --git a/src/odb/test/unitTestsPython/odbUnitTest.py b/src/odb/test/unitTestsPython/odbUnitTest.py index 8cb849f83eb..1e5ad356596 100644 --- a/src/odb/test/unitTestsPython/odbUnitTest.py +++ b/src/odb/test/unitTestsPython/odbUnitTest.py @@ -5,21 +5,23 @@ class TestCase(unittest.TestCase): # Function to change a value and test the change effect def changeAndTest(self, obj, SetterName, GetterName, expectedVal, *args): - getattr(obj, SetterName)(*args) - self.assertEqual(getattr(obj, GetterName)(), expectedVal) + getattr(obj, SetterName)(*args) + self.assertEqual(getattr(obj, GetterName)(), expectedVal) def check(self, obj, GetterName, expectedVal, *args): - self.assertEqual(getattr(obj, GetterName)(*args), expectedVal) + self.assertEqual(getattr(obj, GetterName)(*args), expectedVal) def change(self, obj, SetterName, *args): - return getattr(obj, SetterName)(*args) + return getattr(obj, SetterName)(*args) class TracingStreamResult(testtools.StreamResult): - def status(self, *args, **kwargs): - tid = kwargs['test_id'].split('.') - if (kwargs['test_status'] in ['success', 'fail']): - print(tid[2], ' : ', kwargs['test_status']) + def status(self, *args, **kwargs): + tid = kwargs["test_id"].split(".") + if kwargs["test_status"] in ["success", "fail"]: + print(tid[2], " : ", kwargs["test_status"]) + + # print('{0[test_id]}: {0[test_status]}'.format(kwargs)) @@ -30,7 +32,8 @@ def main(): def mainParallel(Test): suite = unittest.TestLoader().loadTestsFromTestCase(Test) concurrent_suite = testtools.ConcurrentStreamTestSuite( - lambda: ((case, None) for case in suite)) + lambda: ((case, None) for case in suite) + ) result = TracingStreamResult() result.startTestRun() concurrent_suite.run(result) diff --git a/src/pad/test/pad_man_tcl_check.py b/src/pad/test/pad_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/pad/test/pad_man_tcl_check.py +++ b/src/pad/test/pad_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/pad/test/pad_readme_msgs_check.py b/src/pad/test/pad_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/pad/test/pad_readme_msgs_check.py +++ b/src/pad/test/pad_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/par/test/par_aux.py b/src/par/test/par_aux.py index 4c65b95835b..b6d4ff4b3af 100644 --- a/src/par/test/par_aux.py +++ b/src/par/test/par_aux.py @@ -4,99 +4,102 @@ DEFAULT_TARGET_DENSITY = 0.7 -# Besides design, there are no positional args here. General strategy is that +# Besides design, there are no positional args here. General strategy is that # when an arg is None, we just skip setting it, otherwise we will set the # parameter after a quick type check. -def tritonPartDesign(design, *, - base_balance=[1.0], - scale_factor=[1.0], - num_parts=2, - balance_constraint=1.0, - seed=1, - timing_aware_flag=True, - top_n=1000, - placement_flag=False, - fence_flag =False, - fence_lx =0.0, - fence_ly =0.0, - fence_ux =0.0, - fence_uy =0.0, - fixed_file='', - community_file='', - group_file='', - solution_file='', - net_timing_factor=1.0, - path_timing_factor=1.0, - path_snaking_factor=1.0, - timing_exp_factor=1.0, - extra_delay=1e-9, - guardband_flag=False, - e_wt_factors=[ 1.0 ], - v_wt_factors=[ 1.0 ], - placement_wt_factors=[ 1.0 ], - thr_coarsen_hyperedge_size_skip=1000, - thr_coarsen_vertices=10, - thr_coarsen_hyperedges=50, - coarsening_ratio=1.5, - max_coarsen_iters=30, - adj_diff_ratio=0.0001, - min_num_vertices_each_part=4, - num_initial_solutions=100, - num_best_initial_solutions=10, - refiner_iters=10, - max_moves=100, - early_stop_ratio=0.5, - total_corking_passes=25, - v_cycle_flag=True, - max_num_vcycle=1, - num_coarsen_solutions=4, - num_vertices_threshold_ilp=50, - global_net_threshold=1000): +def tritonPartDesign( + design, + *, + base_balance=[1.0], + scale_factor=[1.0], + num_parts=2, + balance_constraint=1.0, + seed=1, + timing_aware_flag=True, + top_n=1000, + placement_flag=False, + fence_flag=False, + fence_lx=0.0, + fence_ly=0.0, + fence_ux=0.0, + fence_uy=0.0, + fixed_file="", + community_file="", + group_file="", + solution_file="", + net_timing_factor=1.0, + path_timing_factor=1.0, + path_snaking_factor=1.0, + timing_exp_factor=1.0, + extra_delay=1e-9, + guardband_flag=False, + e_wt_factors=[1.0], + v_wt_factors=[1.0], + placement_wt_factors=[1.0], + thr_coarsen_hyperedge_size_skip=1000, + thr_coarsen_vertices=10, + thr_coarsen_hyperedges=50, + coarsening_ratio=1.5, + max_coarsen_iters=30, + adj_diff_ratio=0.0001, + min_num_vertices_each_part=4, + num_initial_solutions=100, + num_best_initial_solutions=10, + refiner_iters=10, + max_moves=100, + early_stop_ratio=0.5, + total_corking_passes=25, + v_cycle_flag=True, + max_num_vcycle=1, + num_coarsen_solutions=4, + num_vertices_threshold_ilp=50, + global_net_threshold=1000 +): mgr = design.getPartitionMgr() mgr.tritonPartDesign( - num_parts, - balance_constraint, - base_balance, - scale_factor, - seed, - timing_aware_flag, - top_n, - placement_flag, - fence_flag , - fence_lx , - fence_ly , - fence_ux , - fence_uy , - fixed_file, - community_file, - group_file, - solution_file, - net_timing_factor, - path_timing_factor, - path_snaking_factor, - timing_exp_factor, - extra_delay, - guardband_flag, - e_wt_factors, - v_wt_factors, - placement_wt_factors, - thr_coarsen_hyperedge_size_skip, - thr_coarsen_vertices, - thr_coarsen_hyperedges, - coarsening_ratio, - max_coarsen_iters, - adj_diff_ratio, - min_num_vertices_each_part, - num_initial_solutions, - num_best_initial_solutions, - refiner_iters, - max_moves, - early_stop_ratio, - total_corking_passes, - v_cycle_flag, - max_num_vcycle, - num_coarsen_solutions, - num_vertices_threshold_ilp, - global_net_threshold + num_parts, + balance_constraint, + base_balance, + scale_factor, + seed, + timing_aware_flag, + top_n, + placement_flag, + fence_flag, + fence_lx, + fence_ly, + fence_ux, + fence_uy, + fixed_file, + community_file, + group_file, + solution_file, + net_timing_factor, + path_timing_factor, + path_snaking_factor, + timing_exp_factor, + extra_delay, + guardband_flag, + e_wt_factors, + v_wt_factors, + placement_wt_factors, + thr_coarsen_hyperedge_size_skip, + thr_coarsen_vertices, + thr_coarsen_hyperedges, + coarsening_ratio, + max_coarsen_iters, + adj_diff_ratio, + min_num_vertices_each_part, + num_initial_solutions, + num_best_initial_solutions, + refiner_iters, + max_moves, + early_stop_ratio, + total_corking_passes, + v_cycle_flag, + max_num_vcycle, + num_coarsen_solutions, + num_vertices_threshold_ilp, + global_net_threshold, ) diff --git a/src/par/test/par_man_tcl_check.py b/src/par/test/par_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/par/test/par_man_tcl_check.py +++ b/src/par/test/par_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/par/test/par_readme_msgs_check.py b/src/par/test/par_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/par/test/par_readme_msgs_check.py +++ b/src/par/test/par_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/par/test/partition_gcd.py b/src/par/test/partition_gcd.py index 7935dc2bd21..70a8abd5930 100644 --- a/src/par/test/partition_gcd.py +++ b/src/par/test/partition_gcd.py @@ -9,7 +9,7 @@ design.readVerilog("gcd.v") design.link("gcd") -design.evalTclString('source flow_helpers.tcl') +design.evalTclString("source flow_helpers.tcl") design.evalTclString('read_sdc "gcd_nangate45.sdc"') part_file = helpers.make_result_file("partition_gcd.part") @@ -21,7 +21,7 @@ design.getPartitionMgr().writePartitionVerilog(v_file) -#helpers.diff_files("partition_gcd.graphok", graph_file) -#helpers.diff_files("partition_gcd.pathsok", paths_file) +# helpers.diff_files("partition_gcd.graphok", graph_file) +# helpers.diff_files("partition_gcd.pathsok", paths_file) helpers.diff_files("partition_gcd.partok", part_file) helpers.diff_files("partition_gcd.vok", v_file) diff --git a/src/pdn/test/asap7_taper.py b/src/pdn/test/asap7_taper.py index 84987891edc..e14502dedf5 100644 --- a/src/pdn/test/asap7_taper.py +++ b/src/pdn/test/asap7_taper.py @@ -16,10 +16,18 @@ pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="top", voltage_domains=["Core"]) -pdn_aux.add_pdn_stripe(design, grid="top", layer="M1", width=0.018, pitch=0.54, offset=0, followpins=True) -pdn_aux.add_pdn_stripe(design, grid="top", layer="M2", width=0.018, pitch=0.54, offset=0, followpins=True) -pdn_aux.add_pdn_stripe(design, grid="top", layer="M5", width=0.12, spacing=0.072, pitch=11.88, offset=0.300) -pdn_aux.add_pdn_stripe(design, grid="top", layer="M6", width=0.288, spacing=0.096, pitch=12.0, offset=0.513) +pdn_aux.add_pdn_stripe( + design, grid="top", layer="M1", width=0.018, pitch=0.54, offset=0, followpins=True +) +pdn_aux.add_pdn_stripe( + design, grid="top", layer="M2", width=0.018, pitch=0.54, offset=0, followpins=True +) +pdn_aux.add_pdn_stripe( + design, grid="top", layer="M5", width=0.12, spacing=0.072, pitch=11.88, offset=0.300 +) +pdn_aux.add_pdn_stripe( + design, grid="top", layer="M6", width=0.288, spacing=0.096, pitch=12.0, offset=0.513 +) pdn_aux.add_pdn_connect(design, grid="top", layers=["M1", "M2"]) pdn_aux.add_pdn_connect(design, grid="top", layers=["M2", "M5"]) diff --git a/src/pdn/test/core_grid.py b/src/pdn/test/core_grid.py index c5d7ef538e8..8a402f62927 100644 --- a/src/pdn/test/core_grid.py +++ b/src/pdn/test/core_grid.py @@ -14,7 +14,7 @@ pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="VDD", power=True) pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="VSS", ground=True) -pdn_aux.set_voltage_domain(design, power='VDD', ground='VSS') +pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="Core") pdn_aux.add_pdn_stripe(design, followpins=True, layer="metal1") diff --git a/src/pdn/test/core_grid_with_rings.py b/src/pdn/test/core_grid_with_rings.py index 8cf741543ca..20202a232de 100644 --- a/src/pdn/test/core_grid_with_rings.py +++ b/src/pdn/test/core_grid_with_rings.py @@ -11,13 +11,21 @@ pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="VDD", power=True) pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="VSS", ground=True) -pdn_aux.set_voltage_domain(design, power='VDD', ground='VSS') +pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="Core") -pdn_aux.add_pdn_stripe(design, followpins=True, layer="metal1", extend_to_core_ring=True) - -pdn_aux.add_pdn_ring(design, grid="Core", layers=["metal5", "metal6"], widths=2*[2.0], - spacings=2*[2.0], core_offsets=4*[2.0]) +pdn_aux.add_pdn_stripe( + design, followpins=True, layer="metal1", extend_to_core_ring=True +) + +pdn_aux.add_pdn_ring( + design, + grid="Core", + layers=["metal5", "metal6"], + widths=2 * [2.0], + spacings=2 * [2.0], + core_offsets=4 * [2.0], +) pdn_aux.add_pdn_connect(design, layers=["metal5", "metal6"]) pdn_aux.add_pdn_connect(design, layers=["metal1", "metal6"]) diff --git a/src/pdn/test/core_grid_with_routing_obstructions.py b/src/pdn/test/core_grid_with_routing_obstructions.py index 264aa8ac192..ab83e15088b 100644 --- a/src/pdn/test/core_grid_with_routing_obstructions.py +++ b/src/pdn/test/core_grid_with_routing_obstructions.py @@ -13,18 +13,26 @@ pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="VDD", power=True) pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="VSS", ground=True) -pdn_aux.set_voltage_domain(design, power='VDD', ground='VSS') +pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="Core", obstructions=["metal5", "metal6"]) -pdn_aux.add_pdn_stripe(design, followpins=True, layer="metal1", - extend_to_core_ring=True) - -pdn_aux.add_pdn_stripe(design, layer="metal4", width=1.0, pitch=5.0, - offset=2.5, extend_to_core_ring=True) - -pdn_aux.add_pdn_ring(design, grid="Core", layers=["metal5", "metal6"], - widths=2*[2.0], spacings=2*[2.0], core_offsets=4*[2.0]) +pdn_aux.add_pdn_stripe( + design, followpins=True, layer="metal1", extend_to_core_ring=True +) + +pdn_aux.add_pdn_stripe( + design, layer="metal4", width=1.0, pitch=5.0, offset=2.5, extend_to_core_ring=True +) + +pdn_aux.add_pdn_ring( + design, + grid="Core", + layers=["metal5", "metal6"], + widths=2 * [2.0], + spacings=2 * [2.0], + core_offsets=4 * [2.0], +) pdn_aux.add_pdn_connect(design, layers=["metal5", "metal6"]) pdn_aux.add_pdn_connect(design, layers=["metal1", "metal6"]) diff --git a/src/pdn/test/existing.py b/src/pdn/test/existing.py index bd6c9dec8d6..637f6fecceb 100644 --- a/src/pdn/test/existing.py +++ b/src/pdn/test/existing.py @@ -10,13 +10,13 @@ design.readDef("nangate_existing/floorplan.def") -pdn_aux.define_pdn_grid_existing(design) +pdn_aux.define_pdn_grid_existing(design) pdn_aux.add_pdn_connect(design, layers=["metal1", "metal4"]) pdn_aux.add_pdn_connect(design, layers=["metal4", "metal7"]) pdn_aux.add_pdn_connect(design, layers=["metal7", "metal8"]) - + pdn_aux.add_pdn_connect(design, layers=["metal4", "metal5"]) pdn_aux.add_pdn_connect(design, layers=["metal5", "metal6"]) pdn_aux.add_pdn_connect(design, layers=["metal6", "metal7"]) diff --git a/src/pdn/test/macros.py b/src/pdn/test/macros.py index 831200996f8..7dbd25d81b5 100644 --- a/src/pdn/test/macros.py +++ b/src/pdn/test/macros.py @@ -10,35 +10,31 @@ design = Design(tech) design.readDef("nangate_macros/floorplan.def") -pdn_aux.add_global_connection(design, net_name="VDD", - pin_pattern="^VDD$", - power=True) +pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="^VDD$", power=True) -pdn_aux.add_global_connection(design, net_name="VDD", - pin_pattern="^VDDPE$") +pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="^VDDPE$") -pdn_aux.add_global_connection(design, net_name="VDD", - pin_pattern="^VDDCE$") +pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="^VDDCE$") -pdn_aux.add_global_connection(design, net_name="VSS", - pin_pattern="^VSS$", - ground=True) +pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="^VSS$", ground=True) -pdn_aux.add_global_connection(design, net_name="VSS", - pin_pattern="^VDDE$") +pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="^VDDE$") -pdn_aux.set_voltage_domain(design, power='VDD', ground='VSS') +pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="Core") pdn_aux.add_pdn_stripe(design, layer="metal1", followpins=True) -pdn_aux.add_pdn_stripe(design, layer="metal4", width=0.48, spacing=4.0, pitch=49.0, offset=2.0) +pdn_aux.add_pdn_stripe( + design, layer="metal4", width=0.48, spacing=4.0, pitch=49.0, offset=2.0 +) pdn_aux.add_pdn_stripe(design, layer="metal7", width=1.4, pitch=40.0, offset=2.0) pdn_aux.add_pdn_connect(design, layers=["metal1", "metal4"]) pdn_aux.add_pdn_connect(design, layers=["metal4", "metal7"]) -pdn_aux.define_pdn_grid_macro(design, name="sram1", - instances=["dcache.data.data_arrays_0.data_arrays_0_ext.mem"]) +pdn_aux.define_pdn_grid_macro( + design, name="sram1", instances=["dcache.data.data_arrays_0.data_arrays_0_ext.mem"] +) pdn_aux.add_pdn_stripe(design, layer="metal5", width=0.93, pitch=10.0, offset=2.0) pdn_aux.add_pdn_stripe(design, layer="metal6", width=0.93, pitch=10.0, offset=2.0) @@ -46,9 +42,12 @@ pdn_aux.add_pdn_connect(design, layers=["metal5", "metal6"]) pdn_aux.add_pdn_connect(design, layers=["metal6", "metal7"]) -pdn_aux.define_pdn_grid_macro(design, name="sram2", - instances=["frontend.icache.data_arrays_0.data_arrays_0_0_ext.mem"], - is_bump=False) +pdn_aux.define_pdn_grid_macro( + design, + name="sram2", + instances=["frontend.icache.data_arrays_0.data_arrays_0_0_ext.mem"], + is_bump=False, +) pdn_aux.add_pdn_stripe(design, layer="metal5", width=0.93, pitch=10.0, offset=2.0) pdn_aux.add_pdn_stripe(design, layer="metal6", width=0.93, pitch=10.0, offset=2.0) diff --git a/src/pdn/test/max_width.py b/src/pdn/test/max_width.py index dd0adb5d9dd..1d00928ee5e 100644 --- a/src/pdn/test/max_width.py +++ b/src/pdn/test/max_width.py @@ -12,12 +12,13 @@ pdngen = design.getPdnGen() pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="^VDD$", power=True) -pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern= "^VSS$", ground=True) +pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="^VSS$", ground=True) pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="Core") try: - pdn_aux.add_pdn_stripe(design, layer="M8", width=4.0, spacing=2.688, - pitch=56.32, offset=6.408) + pdn_aux.add_pdn_stripe( + design, layer="M8", width=4.0, spacing=2.688, pitch=56.32, offset=6.408 + ) except Exception as inst: print(inst.args[0]) diff --git a/src/pdn/test/min_width.py b/src/pdn/test/min_width.py index 3e95eb7b10a..7485088be02 100644 --- a/src/pdn/test/min_width.py +++ b/src/pdn/test/min_width.py @@ -11,12 +11,18 @@ pdngen = design.getPdnGen() pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="VDD", power=True) -pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern= "VSS", ground=True) +pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="VSS", ground=True) pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="Core") try: - pdn_aux.add_pdn_ring(design, grid="Core", layers=["metal5", "metal6"], - widths= 2*[0.1], spacings=2*[2.0], core_offsets=4*[2.0]) + pdn_aux.add_pdn_ring( + design, + grid="Core", + layers=["metal5", "metal6"], + widths=2 * [0.1], + spacings=2 * [2.0], + core_offsets=4 * [2.0], + ) except Exception as inst: print(inst.args[0]) diff --git a/src/pdn/test/offgrid.py b/src/pdn/test/offgrid.py index f0aea96cea4..df507f0027d 100644 --- a/src/pdn/test/offgrid.py +++ b/src/pdn/test/offgrid.py @@ -16,7 +16,13 @@ pdn_aux.define_pdn_grid_real(design, name="Core") try: - pdn_aux.add_pdn_ring(design, grid="Core", layers=["metal5", "metal6"], - widths=2*[2.001], spacings=2*[2.0], core_offsets=4*[2.0]) + pdn_aux.add_pdn_ring( + design, + grid="Core", + layers=["metal5", "metal6"], + widths=2 * [2.001], + spacings=2 * [2.0], + core_offsets=4 * [2.0], + ) except Exception as inst: print(inst.args[0]) diff --git a/src/pdn/test/pdn_aux.py b/src/pdn/test/pdn_aux.py index 20c1cbbcabe..992ef1cfa86 100644 --- a/src/pdn/test/pdn_aux.py +++ b/src/pdn/test/pdn_aux.py @@ -7,23 +7,33 @@ # In tcl land, this lives in OpenRoad.tcl. However, it seems to be only called # in the pdn regression tests so it is defined here instead. -def add_global_connection(design, *, - net_name=None, - inst_pattern=None, - pin_pattern=None, - power=False, - ground=False, - region=None): +def add_global_connection( + design, + *, + net_name=None, + inst_pattern=None, + pin_pattern=None, + power=False, + ground=False, + region=None, +): if net_name is None: - utl.error(utl.PDN, 1501, "The net option for the " + - "add_global_connection command is required.") + utl.error( + utl.PDN, + 1501, + "The net option for the " + "add_global_connection command is required.", + ) if inst_pattern is None: inst_pattern = ".*" if pin_pattern is None: - utl.error(utl.PDN, 1502, "The pin_pattern option for the " + - "add_global_connection command is required.") + utl.error( + utl.PDN, + 1502, + "The pin_pattern option for the " + + "add_global_connection command is required.", + ) net = design.getBlock().findNet(net_name) if net is None: @@ -52,18 +62,24 @@ def check_design_state(design, cmd): utl.error(utl.PDN, 1599, f"Design must be loaded before calling {cmd}.") -def set_voltage_domain(design, *, - name=None, - power=None, - ground=None, - region_name=None, - secondary_power=None, - switched_power_name=None): +def set_voltage_domain( + design, + *, + name=None, + power=None, + ground=None, + region_name=None, + secondary_power=None, + switched_power_name=None, +): pdngen = design.getPdnGen() check_design_state(design, "set_voltage_domain") if design.getBlock() is None: - utl.error(utl.PDN, 1505, "Design must be loaded before calling " + - "set_voltage_domain.") + utl.error( + utl.PDN, + 1505, + "Design must be loaded before calling " + "set_voltage_domain.", + ) if power is None: utl.error(utl.PDN, 1506, "The power argument is required.") @@ -104,27 +120,31 @@ def set_voltage_domain(design, *, switched_power_net_name = switched_power_name switched_power = design.getBlock().findNet(switched_power_net_name) if switched_power is None: - switched_power = odb.dbNet_create(design.getBlock(), - switched_power_net_name) + switched_power = odb.dbNet_create( + design.getBlock(), switched_power_net_name + ) switched_power.setSpecial() switched_power.setSigType("POWER") else: if switched_power.getSigType() != "POWER": - utl.error(utl.PDN, 1512, f"Net {switched_power_net_name} " + - "already exists in the design, but is of signal " + - "type {switched_power.getSigType()}.") + utl.error( + utl.PDN, + 1512, + f"Net {switched_power_net_name} " + + "already exists in the design, but is of signal " + + "type {switched_power.getSigType()}.", + ) if region is None: if bool(name) and name.capitalize() != "Core": - utl.warn(utl.PDN, 1513, "Core voltage domain will be named \"Core\".") - pdngen.setCoreDomain(pwr, - switched_power, - gnd, - secondary) + utl.warn(utl.PDN, 1513, 'Core voltage domain will be named "Core".') + pdngen.setCoreDomain(pwr, switched_power, gnd, secondary) else: - pdngen.makeRegionVoltageDomain(name, pwr, switched_power, gnd, - secondary, region) + pdngen.makeRegionVoltageDomain( + name, pwr, switched_power, gnd, secondary, region + ) + def get_voltage_domains(design, names): pdngen = design.getPdnGen() @@ -132,7 +152,7 @@ def get_voltage_domains(design, names): for name in names: domain = pdngen.findDomain(name) if domain is None: - utl.error( utl.PDN, 1514, f"Unable to find {name} domain.") + utl.error(utl.PDN, 1514, f"Unable to find {name} domain.") domains.append(domain) return domains @@ -158,26 +178,30 @@ def get_obstructions(design, obstructions): return layers -def define_pdn_grid_real(design, *, - name=None, - pins=[], - obstructions=[], - power_control=None, - voltage_domains=None, - power_switch_cell=None, - starts_with_power=False, - grid_over_pg_pins=False, - grid_over_boundary=False, - power_control_network="STAR"): # (STAR|DAISY)]} - +def define_pdn_grid_real( + design, + *, + name=None, + pins=[], + obstructions=[], + power_control=None, + voltage_domains=None, + power_switch_cell=None, + starts_with_power=False, + grid_over_pg_pins=False, + grid_over_boundary=False, + power_control_network="STAR", +): # (STAR|DAISY)]} pdngen = design.getPdnGen() if bool(voltage_domains): domains = get_voltage_domains(design, voltage_domains) else: - domains = [pdngen.findDomain("Core")] - + domains = [pdngen.findDomain("Core")] + if name is None: - utl.error(utl.PDN, 1516, "'name' is a required parameter for define_pdn_grid_real") + utl.error( + utl.PDN, 1516, "'name' is a required parameter for define_pdn_grid_real" + ) if has_grid(design, name): utl.error(utl.PDN, 1517, f"Grid named {name} already defined.") @@ -186,53 +210,72 @@ def define_pdn_grid_real(design, *, if bool(pins): for pin in pins: pin_layers.append(get_layer(design, pin)) - + if bool(obstructions): obstructions = get_obstructions(design, obstructions) - + power_cell = None if power_switch_cell is not None: power_cell = pdngen.findSwitchedPowerCell(power_switch_cell) if power_cell is None: - utl.error(utl.PDN, 1519, f"Switched power cell {power_switch_cell} is not defined.") - + utl.error( + utl.PDN, + 1519, + f"Switched power cell {power_switch_cell} is not defined.", + ) + if not bool(power_control): - utl.error(utl.PDN, 1520, "'power_control' must be specified with 'power_switch_cell'") + utl.error( + utl.PDN, + 1520, + "'power_control' must be specified with 'power_switch_cell'", + ) else: power_control = design.getBlock().findNet(power_control) if power_control is None: - utl.error(utl.PDN, 1521, f"Unable to find power control net: {power_control}") + utl.error( + utl.PDN, 1521, f"Unable to find power control net: {power_control}" + ) starts_with = pdn.POWER if starts_with_power else pdn.GROUND for domain in domains: - pdngen.makeCoreGrid(domain, - name, - starts_with, - pin_layers, - obstructions, - power_cell, - power_control, - power_control_network) - - -def define_pdn_grid_macro(design, *, - name="", - voltage_domains=None, - orient=[], - instances=[], # no regex's supported in this version - cells=None, - halo=[0, 0, 0, 0], - starts_with_power=False, # only POWER or GROUND, no GRID - obstructions=[], # string list of layers - grid_over_pg_pins=False, - grid_over_boundary=False, - default_grid=False, - is_bump=False): + pdngen.makeCoreGrid( + domain, + name, + starts_with, + pin_layers, + obstructions, + power_cell, + power_control, + power_control_network, + ) + + +def define_pdn_grid_macro( + design, + *, + name="", + voltage_domains=None, + orient=[], + instances=[], # no regex's supported in this version + cells=None, + halo=[0, 0, 0, 0], + starts_with_power=False, # only POWER or GROUND, no GRID + obstructions=[], # string list of layers + grid_over_pg_pins=False, + grid_over_boundary=False, + default_grid=False, + is_bump=False, +): pdngen = design.getPdnGen() pg_pins_to_boundary = True if grid_over_pg_pins and grid_over_boundary: - utl.error(utl.PDN, 1522, "Options 'grid_over_pg_pins' and 'grid_over_boundary' " + - "are mutually exclusive.") + utl.error( + utl.PDN, + 1522, + "Options 'grid_over_pg_pins' and 'grid_over_boundary' " + + "are mutually exclusive.", + ) elif grid_over_pg_pins: pg_pins_to_boundary = False @@ -247,16 +290,26 @@ def define_pdn_grid_macro(design, *, exclusive_keys += 1 if exclusive_keys > 1: - utl.error(utl.PDN, 1523, "Options 'instances', 'cells', and 'default_grid' are mutually exclusive.") + utl.error( + utl.PDN, + 1523, + "Options 'instances', 'cells', and 'default_grid' are mutually exclusive.", + ) elif exclusive_keys < 1: - utl.error(utl.PDN, 1524, "One of either 'instances', 'cells', or 'default_grid' must be specified.") - + utl.error( + utl.PDN, + 1524, + "One of either 'instances', 'cells', or 'default_grid' must be specified.", + ) + if default_grid: # set default pattern to .* cells = ".*" if name == "": - utl.error(utl.PDN, 1524, "'name' is a required parameter for define_pdn_grid_macro") + utl.error( + utl.PDN, 1524, "'name' is a required parameter for define_pdn_grid_macro" + ) if has_grid(design, name): utl.error(utl.PDN, 1525, f"Grid named {name} already defined.") @@ -266,11 +319,11 @@ def define_pdn_grid_macro(design, *, if bool(voltage_domains): domains = get_voltage_domains(design, voltage_domains) else: - domains = [pdngen.findDomain("Core")] + domains = [pdngen.findDomain("Core")] - obst_list = get_obstructions(design, obstructions) + obst_list = get_obstructions(design, obstructions) orient_list = get_orientations(orient) - + starts_with = pdn.POWER if starts_with_power else pdn.GROUND if bool(instances): @@ -280,21 +333,23 @@ def define_pdn_grid_macro(design, *, if bool(inst): insts.append(inst) else: - utl.error(utl.PDN, 1526 ,f"Unable to find instance: {inst_name}") - + utl.error(utl.PDN, 1526, f"Unable to find instance: {inst_name}") + for inst in insts: # must match orientation, if provided if not bool(orient_list) or inst.getOrient() in orient_list: for domain in domains: - pdngen.makeInstanceGrid(domain, - name, - starts_with, - inst, - halo, - pg_pins_to_boundary, - default_grid, - obst_list, - is_bump) + pdngen.makeInstanceGrid( + domain, + name, + starts_with, + inst, + halo, + pg_pins_to_boundary, + default_grid, + obst_list, + is_bump, + ) else: cells = [] @@ -312,44 +367,55 @@ def define_pdn_grid_macro(design, *, # must match orientation, if provided if not bool(orient_list) or inst.getOrient() in orient_list: for domain in domains: - pdn.make_instance_grid(domain, - name, - starts_with, - inst, - halo, - pg_pins_to_boundary, - default_grid, - obst_list, - is_bump) - - -def add_pdn_stripe(design, *, - grid="", - layer=None, - width=0, - pitch=0, - spacing=0, - offset=0, - starts_with=None, - number_of_straps=0, - nets=None, - followpins=False, - extend_to_core_ring=False, - extend_to_boundary=False, - snap_to_grid=False): + pdn.make_instance_grid( + domain, + name, + starts_with, + inst, + halo, + pg_pins_to_boundary, + default_grid, + obst_list, + is_bump, + ) + + +def add_pdn_stripe( + design, + *, + grid="", + layer=None, + width=0, + pitch=0, + spacing=0, + offset=0, + starts_with=None, + number_of_straps=0, + nets=None, + followpins=False, + extend_to_core_ring=False, + extend_to_boundary=False, + snap_to_grid=False, +): pdngen = design.getPdnGen() - + if layer is None: utl.error(utl.PDN, 1527, "The 'layer' argument is required.") if not followpins: if width == 0: - utl.error(utl.PDN, 1528, - "The 'width' argument is required when followpins is false.") + utl.error( + utl.PDN, + 1528, + "The 'width' argument is required when followpins is false.", + ) if pitch == 0: - utl.error(utl.PDN, 1529, - "The 'pitch' argument is required when followpins is false.") + utl.error( + utl.PDN, + 1529, + "The 'pitch' argument is required when followpins is false.", + ) nets_list = [] if bool(nets): for net_name in nets: @@ -358,16 +424,20 @@ def add_pdn_stripe(design, *, utl.error(utl.PDN, 1530, f"Unable to find net {net_name}.") nets_list.append(net) - layer = get_layer(design, layer) - width = design.micronToDBU(width) - pitch = design.micronToDBU(pitch) + layer = get_layer(design, layer) + width = design.micronToDBU(width) + pitch = design.micronToDBU(pitch) spacing = design.micronToDBU(spacing) - offset = design.micronToDBU(offset) + offset = design.micronToDBU(offset) extend = pdn.CORE if extend_to_core_ring and extend_to_boundary: - utl.error(utl.PDN, 1531, "Options 'extend_to_core_ring' and " + - "'extend_to_boundary' are mutually exclusive.") + utl.error( + utl.PDN, + 1531, + "Options 'extend_to_core_ring' and " + + "'extend_to_boundary' are mutually exclusive.", + ) elif extend_to_core_ring: extend = pdn.RINGS elif extend_to_boundary: @@ -388,50 +458,67 @@ def add_pdn_stripe(design, *, utl.error(utl.PDN, 607, "Invalid starts_with. Must be POWER or GROUND") for g in pdngen.findGrid(grid): - pdngen.makeStrap(g, - layer, - width, - spacing, - pitch, - offset, - number_of_straps, - snap_to_grid, - starts_with, - extend, - nets_list) + pdngen.makeStrap( + g, + layer, + width, + spacing, + pitch, + offset, + number_of_straps, + snap_to_grid, + starts_with, + extend, + nets_list, + ) valid_orientations = ["R0", "R90", "R180", "R270", "MX", "MY", "MXR90", "MYR90"] -lef_orientations = {"N": "R0", "FN": "MY", "S": "R180", "FS": "MX", "E": "R270", - "FE": "MYR90", "W": "R90", "FW": "MXR90"} +lef_orientations = { + "N": "R0", + "FN": "MY", + "S": "R180", + "FS": "MX", + "E": "R270", + "FE": "MYR90", + "W": "R90", + "FW": "MXR90", +} + def get_orientations(orientations): if orientations == []: return [] checked_orientations = [] for orient in orientations: - if orient in valid_orientations: - checked_orientations.append(orient) - elif orient in lef_orientations: - checked_orientations.append(lef_orientations[orient]) - else: - vld = " ".join(valid_orientations) - utl.error(utl.PDN, 1036, f"Invalid orientation {orient} specified, " + - f"must be one of {vld}") + if orient in valid_orientations: + checked_orientations.append(orient) + elif orient in lef_orientations: + checked_orientations.append(lef_orientations[orient]) + else: + vld = " ".join(valid_orientations) + utl.error( + utl.PDN, + 1036, + f"Invalid orientation {orient} specified, " + f"must be one of {vld}", + ) return checked_orientations -def add_pdn_connect(design, *, - grid="", - layers=None, - cut_pitch=[0, 0], - fixed_vias=[], - max_rows=0, - max_columns=0, - ongrid=[], # list of layer names that should be on grid? - split_cuts={}, # dictionary of layer name to pitch - dont_use_vias=""): +def add_pdn_connect( + design, + *, + grid="", + layers=None, + cut_pitch=[0, 0], + fixed_vias=[], + max_rows=0, + max_columns=0, + ongrid=[], # list of layer names that should be on grid? + split_cuts={}, # dictionary of layer name to pitch + dont_use_vias="", +): pdngen = design.getPdnGen() check_design_state(design, "add_pdn_connect") @@ -445,7 +532,7 @@ def add_pdn_connect(design, *, if len(cut_pitch) != 2: utl.error(utl.PDN, 1539, "The cut_pitch argument must contain two enties.") - + cut_pitch = [design.micronToDBU(l) for l in cut_pitch] fixed_generate_vias = [] @@ -462,15 +549,25 @@ def add_pdn_connect(design, *, ongrid_list = [get_layer(l) for l in ongrid] - split_cuts_layers = [get_layer(l) for l in split_cuts.keys()] + split_cuts_layers = [get_layer(l) for l in split_cuts.keys()] split_cuts_pitches = [design.micronToDBU(x) for x in split_cuts.values()] split_cuts_dict = dict(zip(split_cuts_layers, split_cuts_pitches)) - + for g in pdngen.findGrid(grid): - pdngen.makeConnect(g, l0, l1, cut_pitch[0], cut_pitch[1], - fixed_generate_vias, fixed_tech_vias, - max_rows, max_columns, ongrid_list, - split_cuts_dict, dont_use_vias) + pdngen.makeConnect( + g, + l0, + l1, + cut_pitch[0], + cut_pitch[1], + fixed_generate_vias, + fixed_tech_vias, + max_rows, + max_columns, + ongrid_list, + split_cuts_dict, + dont_use_vias, + ) def pdngen_db(design, failed_via_report="", skip_trim=False, dont_add_pins=False): @@ -484,19 +581,22 @@ def pdngen_db(design, failed_via_report="", skip_trim=False, dont_add_pins=False pdngen.resetShapes() -def add_pdn_ring(design, *, - nets=[], - layers=[], # list of size 2 - widths=[], # list of size 2 - spacings=[], # list of size 2 - grid="", - pad_offsets=[], # array of size 4 - core_offsets=[], # array of size 4 - connect_to_pad_layers=None, - starts_with=None, - add_connect=False, - extend_to_boundary=False, - connect_to_pads=False): +def add_pdn_ring( + design, + *, + nets=[], + layers=[], # list of size 2 + widths=[], # list of size 2 + spacings=[], # list of size 2 + grid="", + pad_offsets=[], # array of size 4 + core_offsets=[], # array of size 4 + connect_to_pad_layers=None, + starts_with=None, + add_connect=False, + extend_to_boundary=False, + connect_to_pads=False, +): pdngen = design.getPdnGen() check_design_state(design, "add_pdn_ring") @@ -508,7 +608,7 @@ def add_pdn_ring(design, *, if not bool(widths) or len(widths) != 2: utl.error(utl.PDN, 1543, "'widths' is a required list of size two.") - widths = [design.micronToDBU(w) for w in widths] + widths = [design.micronToDBU(w) for w in widths] if not bool(spacings) or len(spacings) != 2: utl.error(utl.PDN, 1544, "'spacings' is a required list of size two.") @@ -516,9 +616,15 @@ def add_pdn_ring(design, *, spacings = [design.micronToDBU(s) for s in spacings] if bool(core_offsets) and bool(pad_offsets): - utl.error(utl.PDN, 1545, "Only one of 'pad_offsets' or 'core_offsets' can be specified.") + utl.error( + utl.PDN, + 1545, + "Only one of 'pad_offsets' or 'core_offsets' can be specified.", + ) elif not bool(core_offsets) and not bool(pad_offsets): - utl.error(utl.PDN, 1546, "One of 'pad_offsets' or 'core_offsets' must be specified.") + utl.error( + utl.PDN, 1546, "One of 'pad_offsets' or 'core_offsets' must be specified." + ) if bool(core_offsets): if len(core_offsets) != 4: @@ -541,10 +647,16 @@ def add_pdn_ring(design, *, elif starts_with.upper() == "GROUND": starts_with = pdn.GROUND else: - utl.error(utl.PDN, 608, "Invalid starts_with. Must be unspecified or POWER or GROUND") - + utl.error( + utl.PDN, 608, "Invalid starts_with. Must be unspecified or POWER or GROUND" + ) + if extend_to_boundary and connect_to_pads: - utl.error(utl.PDN, 1547, "Only one of 'pad_offsets' or 'core_offsets' can be specified.") + utl.error( + utl.PDN, + 1547, + "Only one of 'pad_offsets' or 'core_offsets' can be specified.", + ) nets_list = [] if bool(nets): @@ -564,39 +676,52 @@ def add_pdn_ring(design, *, if layer.getType() == "ROUTING": connect_to_pad_layers.append(layer) else: - connect_to_pad_layers = [get_layer(design,l) for l in connect_to_pad_layers] + connect_to_pad_layers = [ + get_layer(design, l) for l in connect_to_pad_layers + ] for g in pdngen.findGrid(grid): - pdngen.makeRing(g, - l0, widths[0], spacings[0], - l1, widths[1], spacings[1], - starts_with, - core_offsets, - pad_offsets, - extend_to_boundary, - connect_to_pad_layers, - nets_list) + pdngen.makeRing( + g, + l0, + widths[0], + spacings[0], + l1, + widths[1], + spacings[1], + starts_with, + core_offsets, + pad_offsets, + extend_to_boundary, + connect_to_pad_layers, + nets_list, + ) if bool(add_connect): add_pdn_connect(design, grid, layers) - -def define_power_switch_cell(design, *, - name=None, - control=None, - acknowledge=None, - power_switchable=None, - power=None, - ground=None): + +def define_power_switch_cell( + design, + *, + name=None, + control=None, + acknowledge=None, + power_switchable=None, + power=None, + ground=None, +): pdngen = design.getPdnGen() - check_design_state(design,"define_power_switch_cell") + check_design_state(design, "define_power_switch_cell") if not bool(name): utl.error(utl.PDN, 31183, "The 'name' argument is required.") else: master = design.getTech().getDB().findMaster(name) if not bool(master): - utl.error(utl.PDN, 31046, f"Unable to find power switch cell master: {name}") + utl.error( + utl.PDN, 31046, f"Unable to find power switch cell master: {name}" + ) if not bool(control): utl.error(utl.PDN, 31184, "The 'control' argument is required.") @@ -632,13 +757,10 @@ def define_power_switch_cell(design, *, ground = master.findMTerm(ground) if not bool(ground): print(utl.PDN, 31188, f"Unable to find {ground} on {master}") - - pdngen.makeSwitchedPowerCell(master, - control, - acknowledge, - power_switchable, - power, - ground) + + pdngen.makeSwitchedPowerCell( + master, control, acknowledge, power_switchable, power, ground + ) def define_pdn_grid_existing(design, *, name="existing_grid", obstructions=[]): @@ -648,6 +770,7 @@ def define_pdn_grid_existing(design, *, name="existing_grid", obstructions=[]): pdngen.makeExistingGrid(name, obstructions) + def repair_pdn_vias(design, *, net=None, all=False): pdngen = design.getPdnGen() if bool(net) and all: @@ -667,6 +790,5 @@ def repair_pdn_vias(design, *, net=None, all=False): for net in design.getBlock().getNets(): if net.getSigType() == "POWER" or net.getSigType() == "GROUND": nets.append(net) - - pdngen.repairVias(nets) + pdngen.repairVias(nets) diff --git a/src/pdn/test/pdn_man_tcl_check.py b/src/pdn/test/pdn_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/pdn/test/pdn_man_tcl_check.py +++ b/src/pdn/test/pdn_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/pdn/test/pdn_readme_msgs_check.py b/src/pdn/test/pdn_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/pdn/test/pdn_readme_msgs_check.py +++ b/src/pdn/test/pdn_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/pdn/test/power_switch.py b/src/pdn/test/power_switch.py index 5ada916b3c1..36dd877ddba 100644 --- a/src/pdn/test/power_switch.py +++ b/src/pdn/test/power_switch.py @@ -12,16 +12,32 @@ design.readDef("sky130_power_switch/floorplan.def") pdn_aux.add_global_connection(design, net_name="VDD", power=True, pin_pattern="^VDDG$") -pdn_aux.add_global_connection(design, net_name="VDD_SW", power=True, pin_pattern="^VPB$") +pdn_aux.add_global_connection( + design, net_name="VDD_SW", power=True, pin_pattern="^VPB$" +) pdn_aux.add_global_connection(design, net_name="VDD_SW", pin_pattern="^VPWR$") pdn_aux.add_global_connection(design, net_name="VSS", power=True, pin_pattern="^VGND$") pdn_aux.add_global_connection(design, net_name="VSS", power=True, pin_pattern="^VNB$") -pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS", switched_power_name="VDD_SW") -pdn_aux.define_power_switch_cell(design, name="POWER_SWITCH", control="SLEEP", acknowledge="SLEEP_OUT", - power_switchable="VPWR", power="VDDG", ground="VGND") -pdn_aux.define_pdn_grid_real(design, name="Core", power_switch_cell="POWER_SWITCH", - power_control="nPWRUP", power_control_network="DAISY") +pdn_aux.set_voltage_domain( + design, power="VDD", ground="VSS", switched_power_name="VDD_SW" +) +pdn_aux.define_power_switch_cell( + design, + name="POWER_SWITCH", + control="SLEEP", + acknowledge="SLEEP_OUT", + power_switchable="VPWR", + power="VDDG", + ground="VGND", +) +pdn_aux.define_pdn_grid_real( + design, + name="Core", + power_switch_cell="POWER_SWITCH", + power_control="nPWRUP", + power_control_network="DAISY", +) pdn_aux.add_pdn_stripe(design, layer="met1", width=0.48, offset=0, followpins=True) pdn_aux.add_pdn_stripe(design, layer="met4", width=1.600, pitch=27.140, offset=13.570) diff --git a/src/pdn/test/report.py b/src/pdn/test/report.py index fd64b32819b..eb9e1b90360 100644 --- a/src/pdn/test/report.py +++ b/src/pdn/test/report.py @@ -17,16 +17,33 @@ pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="^VSSE$") pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") - + pdn_aux.define_pdn_grid_real(design, name="Core") -pdn_aux.add_pdn_ring(design, grid="Core", layers=["metal8", "metal9"], widths=2*[5.0], - spacings=2*[2.0], core_offsets=4*[4.5], connect_to_pads=True) -pdn_aux.add_pdn_stripe(design, followpins=True, layer="metal1", extend_to_core_ring=True) - -pdn_aux.add_pdn_stripe(design, layer="metal4", width=0.48, pitch=56.0, offset=2.0, extend_to_core_ring=True) -pdn_aux.add_pdn_stripe(design, layer="metal7", width=1.40, pitch=40.0, offset=2.0, extend_to_core_ring=True) -pdn_aux.add_pdn_stripe(design, layer="metal8", width=1.40, pitch=40.0, offset=2.0, extend_to_core_ring=True) -pdn_aux.add_pdn_stripe(design, layer="metal9", width=1.40, pitch=40.0, offset=2.0, extend_to_core_ring=True) +pdn_aux.add_pdn_ring( + design, + grid="Core", + layers=["metal8", "metal9"], + widths=2 * [5.0], + spacings=2 * [2.0], + core_offsets=4 * [4.5], + connect_to_pads=True, +) +pdn_aux.add_pdn_stripe( + design, followpins=True, layer="metal1", extend_to_core_ring=True +) + +pdn_aux.add_pdn_stripe( + design, layer="metal4", width=0.48, pitch=56.0, offset=2.0, extend_to_core_ring=True +) +pdn_aux.add_pdn_stripe( + design, layer="metal7", width=1.40, pitch=40.0, offset=2.0, extend_to_core_ring=True +) +pdn_aux.add_pdn_stripe( + design, layer="metal8", width=1.40, pitch=40.0, offset=2.0, extend_to_core_ring=True +) +pdn_aux.add_pdn_stripe( + design, layer="metal9", width=1.40, pitch=40.0, offset=2.0, extend_to_core_ring=True +) pdn_aux.add_pdn_connect(design, layers=["metal1", "metal4"]) pdn_aux.add_pdn_connect(design, layers=["metal4", "metal7"]) diff --git a/src/pdn/test/reset.py b/src/pdn/test/reset.py index fe952cf8c5f..17a11eeaecb 100644 --- a/src/pdn/test/reset.py +++ b/src/pdn/test/reset.py @@ -14,7 +14,7 @@ pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="VDD", power=True) pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="VSS", ground=True) -pdn_aux.set_voltage_domain(design, power='VDD', ground='VSS') +pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="Core") diff --git a/src/pdn/test/widthtable.py b/src/pdn/test/widthtable.py index 256df0efa9d..4b1ad3ece39 100644 --- a/src/pdn/test/widthtable.py +++ b/src/pdn/test/widthtable.py @@ -12,7 +12,7 @@ pdn_aux.add_global_connection(design, net_name="VDD", pin_pattern="^VDD$", power=True) pdn_aux.add_global_connection(design, net_name="VSS", pin_pattern="^VSS$", ground=True) -pdn_aux.set_voltage_domain(design, power='VDD', ground='VSS') +pdn_aux.set_voltage_domain(design, power="VDD", ground="VSS") pdn_aux.define_pdn_grid_real(design, name="Core") pdn_aux.add_pdn_stripe(design, followpins=True, layer="M1", width=0.072) diff --git a/src/ppl/test/add_constraint1.py b/src/ppl/test/add_constraint1.py index 986c73d5f55..37c5c59c589 100644 --- a/src/ppl/test/add_constraint1.py +++ b/src/ppl/test/add_constraint1.py @@ -10,8 +10,13 @@ ppl_aux.set_io_pin_constraint(design, direction="INPUT", region="top:*") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("add_constraint1.def") design.writeDef(def_file) diff --git a/src/ppl/test/add_constraint10.py b/src/ppl/test/add_constraint10.py index 39817b5b041..db260339556 100644 --- a/src/ppl/test/add_constraint10.py +++ b/src/ppl/test/add_constraint10.py @@ -8,12 +8,23 @@ design = Design(tech) design.readDef("gcd.def") -design.evalTclString("set_io_pin_constraint -pin_names {resp_msg[0] resp_msg[1] clk resp_val resp_rdy resp_msg[10] resp_msg[11] resp_msg[12] resp_msg[13]} -region bottom:*") -design.evalTclString("set_io_pin_constraint -pin_names {resp_msg[3] resp_msg[2] resp_msg[14] req_val req_rdy req_msg[10] req_msg[11] req_msg[12] req_msg[13]} -region top:0-18") -design.evalTclString("set_io_pin_constraint -mirrored_pins {resp_msg[0] req_msg[0] resp_msg[1] req_msg[1] resp_msg[2] req_msg[2] resp_msg[3] req_msg[3]}") +design.evalTclString( + "set_io_pin_constraint -pin_names {resp_msg[0] resp_msg[1] clk resp_val resp_rdy resp_msg[10] resp_msg[11] resp_msg[12] resp_msg[13]} -region bottom:*" +) +design.evalTclString( + "set_io_pin_constraint -pin_names {resp_msg[3] resp_msg[2] resp_msg[14] req_val req_rdy req_msg[10] req_msg[11] req_msg[12] req_msg[13]} -region top:0-18" +) +design.evalTclString( + "set_io_pin_constraint -mirrored_pins {resp_msg[0] req_msg[0] resp_msg[1] req_msg[1] resp_msg[2] req_msg[2] resp_msg[3] req_msg[3]}" +) -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("add_constraint10.def") design.writeDef(def_file) diff --git a/src/ppl/test/add_constraint2.py b/src/ppl/test/add_constraint2.py index b60ea2a045f..cf03a354b80 100644 --- a/src/ppl/test/add_constraint2.py +++ b/src/ppl/test/add_constraint2.py @@ -10,8 +10,13 @@ ppl_aux.set_io_pin_constraint(design, direction="INPUT", region="bottom:*") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("add_constraint2.def") design.writeDef(def_file) diff --git a/src/ppl/test/add_constraint3.py b/src/ppl/test/add_constraint3.py index 76bf071e0e5..07419997579 100644 --- a/src/ppl/test/add_constraint3.py +++ b/src/ppl/test/add_constraint3.py @@ -10,8 +10,13 @@ ppl_aux.set_io_pin_constraint(design, direction="INPUT", region="left:*") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("add_constraint3.def") design.writeDef(def_file) diff --git a/src/ppl/test/add_constraint4.py b/src/ppl/test/add_constraint4.py index a34bbc762ea..70c33e2a73f 100644 --- a/src/ppl/test/add_constraint4.py +++ b/src/ppl/test/add_constraint4.py @@ -10,8 +10,13 @@ ppl_aux.set_io_pin_constraint(design, direction="INPUT", region="right:*") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("add_constraint4.def") design.writeDef(def_file) diff --git a/src/ppl/test/add_constraint7.py b/src/ppl/test/add_constraint7.py index 6b5125e6c33..04282c92be4 100644 --- a/src/ppl/test/add_constraint7.py +++ b/src/ppl/test/add_constraint7.py @@ -8,7 +8,11 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.set_io_pin_constraint(design, pin_names="resp_val resp_rdy req_rdy req_val req_msg.* .*msg.*", region="bottom:*") +ppl_aux.set_io_pin_constraint( + design, + pin_names="resp_val resp_rdy req_rdy req_val req_msg.* .*msg.*", + region="bottom:*", +) ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", random=True) def_file = helpers.make_result_file("add_constraint7.def") diff --git a/src/ppl/test/add_constraint8.py b/src/ppl/test/add_constraint8.py index f442b313e4a..af3e62da0d6 100644 --- a/src/ppl/test/add_constraint8.py +++ b/src/ppl/test/add_constraint8.py @@ -9,7 +9,9 @@ design.readDef("gcd.def") design.evalTclString("set_io_pin_constraint -pin_names {req_msg*} -region bottom:0-18") -design.evalTclString("set_io_pin_constraint -pin_names {resp_msg*} -region bottom:10-20") +design.evalTclString( + "set_io_pin_constraint -pin_names {resp_msg*} -region bottom:10-20" +) ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2") diff --git a/src/ppl/test/add_constraint9.py b/src/ppl/test/add_constraint9.py index f29095d3a16..9fbdee76a7d 100644 --- a/src/ppl/test/add_constraint9.py +++ b/src/ppl/test/add_constraint9.py @@ -8,10 +8,17 @@ design = Design(tech) design.readDef("gcd.def") -design.evalTclString("set_io_pin_constraint -mirrored_pins {resp_msg[0] req_msg[0] resp_msg[1] req_msg[1] resp_msg[2] req_msg[2] resp_msg[3] req_msg[3]}") +design.evalTclString( + "set_io_pin_constraint -mirrored_pins {resp_msg[0] req_msg[0] resp_msg[1] req_msg[1] resp_msg[2] req_msg[2] resp_msg[3] req_msg[3]}" +) -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("add_constraint9.def") design.writeDef(def_file) diff --git a/src/ppl/test/exclude1.py b/src/ppl/test/exclude1.py index fc8a34b93e8..1bf3264830d 100644 --- a/src/ppl/test/exclude1.py +++ b/src/ppl/test/exclude1.py @@ -9,9 +9,14 @@ design.readDef("gcd.def") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12, - exclude=["top:*", "bottom:*"]) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, + exclude=["top:*", "bottom:*"], +) def_file = helpers.make_result_file("exclude1.def") design.writeDef(def_file) diff --git a/src/ppl/test/exclude2.py b/src/ppl/test/exclude2.py index ff31a10d227..7eb948cbafa 100644 --- a/src/ppl/test/exclude2.py +++ b/src/ppl/test/exclude2.py @@ -9,9 +9,14 @@ design.readDef("gcd.def") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12, - exclude=["left:*", "right:*"]) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, + exclude=["left:*", "right:*"], +) def_file = helpers.make_result_file("exclude2.def") diff --git a/src/ppl/test/exclude3.py b/src/ppl/test/exclude3.py index b6ce8f0421a..e12bab8338f 100644 --- a/src/ppl/test/exclude3.py +++ b/src/ppl/test/exclude3.py @@ -9,9 +9,14 @@ design.readDef("gcd.def") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12, - exclude=["right:15-95", "bottom:10-70"]) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, + exclude=["right:15-95", "bottom:10-70"], +) def_file = helpers.make_result_file("exclude3.def") design.writeDef(def_file) diff --git a/src/ppl/test/gcd.py b/src/ppl/test/gcd.py index f6b1bd39846..f727378d261 100644 --- a/src/ppl/test/gcd.py +++ b/src/ppl/test/gcd.py @@ -8,11 +8,13 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pins(design, - hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, - min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("gcd.def") design.writeDef(def_file) diff --git a/src/ppl/test/group_pins1.py b/src/ppl/test/group_pins1.py index b1413c6d65d..8fa1328c110 100644 --- a/src/ppl/test/group_pins1.py +++ b/src/ppl/test/group_pins1.py @@ -8,14 +8,17 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pins(design, - hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, - min_distance=0.12, - group_pins=["resp_val resp_rdy req_rdy", - "req_msg[15] req_msg[14] resp_msg[15] resp_msg[14]"] - ) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, + group_pins=[ + "resp_val resp_rdy req_rdy", + "req_msg[15] req_msg[14] resp_msg[15] resp_msg[14]", + ], +) def_file = helpers.make_result_file("group_pins1.def") design.writeDef(def_file) diff --git a/src/ppl/test/group_pins2.py b/src/ppl/test/group_pins2.py index ef2bdb9c6e5..994801c7036 100644 --- a/src/ppl/test/group_pins2.py +++ b/src/ppl/test/group_pins2.py @@ -8,13 +8,16 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pins(design, - hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, - min_distance=0.12, - group_pins=["clk req_msg[31] req_msg[30] req_msg[29] req_msg[28] req_msg[27] req_msg[26] req_msg[25] req_msg[24] req_msg[23] req_msg[22] req_msg[21] req_msg[20]"], - ) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, + group_pins=[ + "clk req_msg[31] req_msg[30] req_msg[29] req_msg[28] req_msg[27] req_msg[26] req_msg[25] req_msg[24] req_msg[23] req_msg[22] req_msg[21] req_msg[20]" + ], +) def_file = helpers.make_result_file("group_pins2.def") design.writeDef(def_file) diff --git a/src/ppl/test/group_pins3.py b/src/ppl/test/group_pins3.py index f679905503c..e7d46aad13a 100644 --- a/src/ppl/test/group_pins3.py +++ b/src/ppl/test/group_pins3.py @@ -8,28 +8,28 @@ design = Design(tech) design.readDef("group_pins3.def") -ppl_aux.place_pins(design, - hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, - min_distance=0.6, - group_pins=["req_msg[10] req_msg[11] req_msg[12] req_msg[13] " + - "req_msg[14] req_msg[15] req_msg[16] req_msg[17] " + - "req_msg[18] req_msg[19] req_msg[20] req_msg[21] " + - "req_msg[22] req_msg[23] req_msg[0] req_msg[1]", - - "req_msg[24] req_msg[25] req_msg[26] req_msg[27] " + - "req_msg[28] req_msg[29] req_msg[2] req_msg[30] " + - "req_msg[31] req_msg[3] req_msg[4] req_msg[5] " + - "req_msg[6] req_msg[7] req_msg[8] req_msg[9]", - - "clk req_rdy req_val reset resp_msg[0] resp_msg[10] " + - "resp_msg[11] resp_msg[12] resp_msg[13] resp_msg[14] " + - "resp_msg[15]", - - "resp_rdy resp_val resp_msg[1] resp_msg[2] resp_msg[3] " + - "resp_msg[4] resp_msg[5] resp_msg[6] resp_msg[7] resp_msg[8] resp_msg[9]"] - ) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.6, + group_pins=[ + "req_msg[10] req_msg[11] req_msg[12] req_msg[13] " + + "req_msg[14] req_msg[15] req_msg[16] req_msg[17] " + + "req_msg[18] req_msg[19] req_msg[20] req_msg[21] " + + "req_msg[22] req_msg[23] req_msg[0] req_msg[1]", + "req_msg[24] req_msg[25] req_msg[26] req_msg[27] " + + "req_msg[28] req_msg[29] req_msg[2] req_msg[30] " + + "req_msg[31] req_msg[3] req_msg[4] req_msg[5] " + + "req_msg[6] req_msg[7] req_msg[8] req_msg[9]", + "clk req_rdy req_val reset resp_msg[0] resp_msg[10] " + + "resp_msg[11] resp_msg[12] resp_msg[13] resp_msg[14] " + + "resp_msg[15]", + "resp_rdy resp_val resp_msg[1] resp_msg[2] resp_msg[3] " + + "resp_msg[4] resp_msg[5] resp_msg[6] resp_msg[7] resp_msg[8] resp_msg[9]", + ], +) def_file = helpers.make_result_file("group_pins3.def") design.writeDef(def_file) diff --git a/src/ppl/test/group_pins7.py b/src/ppl/test/group_pins7.py index c340fbd020f..b1b70262941 100644 --- a/src/ppl/test/group_pins7.py +++ b/src/ppl/test/group_pins7.py @@ -9,57 +9,65 @@ design.readDef("group_pins3.def") -ppl_aux.set_io_pin_constraint(design, - pin_names="req_msg\[10\] req_msg\[11\] req_msg\[12\] req_msg\[13\] " + - "req_msg\[14\] req_msg\[15\] req_msg\[16\] req_msg\[17\] " + - "req_msg\[18\] req_msg\[19\] req_msg\[20\] req_msg\[21\] " + - "req_msg\[22\] req_msg\[23\] req_msg\[0\] req_msg\[1\]", - region="left:*") +ppl_aux.set_io_pin_constraint( + design, + pin_names="req_msg\[10\] req_msg\[11\] req_msg\[12\] req_msg\[13\] " + + "req_msg\[14\] req_msg\[15\] req_msg\[16\] req_msg\[17\] " + + "req_msg\[18\] req_msg\[19\] req_msg\[20\] req_msg\[21\] " + + "req_msg\[22\] req_msg\[23\] req_msg\[0\] req_msg\[1\]", + region="left:*", +) -ppl_aux.set_io_pin_constraint(design, - pin_names="req_msg\[24\] req_msg\[25\] req_msg\[26\] " + - "req_msg\[27\] req_msg\[28\] req_msg\[29\] req_msg\[2\] " + - "req_msg\[30\] req_msg\[31\] req_msg\[3\] req_msg\[4\] " + - "req_msg\[5\] req_msg\[6\] req_msg\[7\] req_msg\[8\] req_msg\[9\]", - region="bottom:*") +ppl_aux.set_io_pin_constraint( + design, + pin_names="req_msg\[24\] req_msg\[25\] req_msg\[26\] " + + "req_msg\[27\] req_msg\[28\] req_msg\[29\] req_msg\[2\] " + + "req_msg\[30\] req_msg\[31\] req_msg\[3\] req_msg\[4\] " + + "req_msg\[5\] req_msg\[6\] req_msg\[7\] req_msg\[8\] req_msg\[9\]", + region="bottom:*", +) -ppl_aux.set_io_pin_constraint(design, - pin_names="clk req_rdy req_val reset resp_msg\[0\] " + - "resp_msg\[10\] resp_msg\[11\] resp_msg\[12\] " + - "resp_msg\[13\] resp_msg\[14\] resp_msg\[15\]", - region="top:*") +ppl_aux.set_io_pin_constraint( + design, + pin_names="clk req_rdy req_val reset resp_msg\[0\] " + + "resp_msg\[10\] resp_msg\[11\] resp_msg\[12\] " + + "resp_msg\[13\] resp_msg\[14\] resp_msg\[15\]", + region="top:*", +) -ppl_aux.set_io_pin_constraint(design, - pin_names="resp_rdy resp_val resp_msg\[1\] " + - "resp_msg\[2\] resp_msg\[3\] resp_msg\[4\] " + - "resp_msg\[5\] resp_msg\[6\] resp_msg\[7\] " + - "resp_msg\[8\] resp_msg\[9\]", - region="right:*") +ppl_aux.set_io_pin_constraint( + design, + pin_names="resp_rdy resp_val resp_msg\[1\] " + + "resp_msg\[2\] resp_msg\[3\] resp_msg\[4\] " + + "resp_msg\[5\] resp_msg\[6\] resp_msg\[7\] " + + "resp_msg\[8\] resp_msg\[9\]", + region="right:*", +) -ppl_aux.place_pins(design, - hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, - min_distance=0.24, - group_pins=["req_msg[10] req_msg[11] req_msg[12] req_msg[13] " + - "req_msg[14] req_msg[15] req_msg[16] req_msg[17] " + - "req_msg[18] req_msg[19] req_msg[20] req_msg[21] " + - "req_msg[22] req_msg[23] req_msg[0] req_msg[1]", - - "req_msg[24] req_msg[25] req_msg[26] req_msg[27] " + - "req_msg[28] req_msg[29] req_msg[2] req_msg[30] " + - "req_msg[31] req_msg[3] req_msg[4] req_msg[5] " + - "req_msg[6] req_msg[7] req_msg[8] req_msg[9]", - - "clk req_rdy req_val reset resp_msg[0] resp_msg[10] " + - "resp_msg[11] resp_msg[12] resp_msg[13] resp_msg[14] " + - "resp_msg[15]", - - "resp_rdy resp_val resp_msg[1] resp_msg[2] resp_msg[3] " + - "resp_msg[4] resp_msg[5] resp_msg[6] resp_msg[7] " + - "resp_msg[8] resp_msg[9]" ] - ) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.24, + group_pins=[ + "req_msg[10] req_msg[11] req_msg[12] req_msg[13] " + + "req_msg[14] req_msg[15] req_msg[16] req_msg[17] " + + "req_msg[18] req_msg[19] req_msg[20] req_msg[21] " + + "req_msg[22] req_msg[23] req_msg[0] req_msg[1]", + "req_msg[24] req_msg[25] req_msg[26] req_msg[27] " + + "req_msg[28] req_msg[29] req_msg[2] req_msg[30] " + + "req_msg[31] req_msg[3] req_msg[4] req_msg[5] " + + "req_msg[6] req_msg[7] req_msg[8] req_msg[9]", + "clk req_rdy req_val reset resp_msg[0] resp_msg[10] " + + "resp_msg[11] resp_msg[12] resp_msg[13] resp_msg[14] " + + "resp_msg[15]", + "resp_rdy resp_val resp_msg[1] resp_msg[2] resp_msg[3] " + + "resp_msg[4] resp_msg[5] resp_msg[6] resp_msg[7] " + + "resp_msg[8] resp_msg[9]", + ], +) def_file = helpers.make_result_file("group_pins7.def") design.writeDef(def_file) diff --git a/src/ppl/test/group_pins8.py b/src/ppl/test/group_pins8.py index 4ed80242178..228b8a4c95c 100644 --- a/src/ppl/test/group_pins8.py +++ b/src/ppl/test/group_pins8.py @@ -8,18 +8,18 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.set_io_pin_constraint(design, - pin_names="resp_val resp_rdy req_rdy", - group=True) -ppl_aux.set_io_pin_constraint(design, - pin_names="req_msg[15] req_msg[14] resp_msg[15] resp_msg[14]", - group=True) +ppl_aux.set_io_pin_constraint(design, pin_names="resp_val resp_rdy req_rdy", group=True) +ppl_aux.set_io_pin_constraint( + design, pin_names="req_msg[15] req_msg[14] resp_msg[15] resp_msg[14]", group=True +) -ppl_aux.place_pins(design, - hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, - min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("group_pins8.def") design.writeDef(def_file) diff --git a/src/ppl/test/group_pins9.py b/src/ppl/test/group_pins9.py index b21b32c28e9..fb671369d19 100644 --- a/src/ppl/test/group_pins9.py +++ b/src/ppl/test/group_pins9.py @@ -8,20 +8,23 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.set_io_pin_constraint(design, - pin_names="resp_val resp_rdy req_rdy", - group=True, - order=True) -ppl_aux.set_io_pin_constraint(design, - pin_names="req_msg[15] req_msg[14] resp_msg[15] resp_msg[14]", - group=True, - order=True) +ppl_aux.set_io_pin_constraint( + design, pin_names="resp_val resp_rdy req_rdy", group=True, order=True +) +ppl_aux.set_io_pin_constraint( + design, + pin_names="req_msg[15] req_msg[14] resp_msg[15] resp_msg[14]", + group=True, + order=True, +) -ppl_aux.place_pins(design, - hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, - min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("group_pins9.def") design.writeDef(def_file) diff --git a/src/ppl/test/min_dist_in_tracks1.py b/src/ppl/test/min_dist_in_tracks1.py index d77c5b76c3e..1a9e72d7c11 100644 --- a/src/ppl/test/min_dist_in_tracks1.py +++ b/src/ppl/test/min_dist_in_tracks1.py @@ -8,10 +8,14 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pins(design, hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, min_distance=1, - min_distance_in_tracks=True) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=1, + min_distance_in_tracks=True, +) def_file = helpers.make_result_file("min_dist_in_tracks1.def") design.writeDef(def_file) diff --git a/src/ppl/test/multi_layers.py b/src/ppl/test/multi_layers.py index 1fc331fcb82..a6e91055940 100644 --- a/src/ppl/test/multi_layers.py +++ b/src/ppl/test/multi_layers.py @@ -8,9 +8,13 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pins(design, hor_layers="metal3 metal5", - ver_layers="metal2 metal4", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3 metal5", + ver_layers="metal2 metal4", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("multi_layers.def") design.writeDef(def_file) diff --git a/src/ppl/test/multiple_calls.py b/src/ppl/test/multiple_calls.py index 6066dab6d2a..ca2f2409364 100644 --- a/src/ppl/test/multiple_calls.py +++ b/src/ppl/test/multiple_calls.py @@ -8,16 +8,24 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pins(design, hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file1 = helpers.make_result_file("mc1_iop.def") design.writeDef(def_file1) -ppl_aux.place_pins(design, hor_layers="metal3", - ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file2 = helpers.make_result_file("mc2_iop.def") design.writeDef(def_file2) diff --git a/src/ppl/test/place_pin1.py b/src/ppl/test/place_pin1.py index fb5ce27c24d..9e707498f44 100644 --- a/src/ppl/test/place_pin1.py +++ b/src/ppl/test/place_pin1.py @@ -8,11 +8,17 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pin(design, pin_name="clk", layer="metal7", location=[40, 30], - pin_size=[1.6,2.5]) +ppl_aux.place_pin( + design, pin_name="clk", layer="metal7", location=[40, 30], pin_size=[1.6, 2.5] +) -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("place_pin1.def") design.writeDef(def_file) diff --git a/src/ppl/test/place_pin2.py b/src/ppl/test/place_pin2.py index 930944ec81b..5d15e01130b 100644 --- a/src/ppl/test/place_pin2.py +++ b/src/ppl/test/place_pin2.py @@ -8,14 +8,24 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pin(design, pin_name="clk", layer="metal7", location=[40, 30], - pin_size=[1.6,2.5]) +ppl_aux.place_pin( + design, pin_name="clk", layer="metal7", location=[40, 30], pin_size=[1.6, 2.5] +) -ppl_aux.place_pin(design, pin_name="resp_val", layer="metal4", location=[12, 50], pin_size=[2, 2]) -ppl_aux.place_pin(design, pin_name="req_msg\[0\]", layer="metal10", location=[25, 70], pin_size=[4, 4]) +ppl_aux.place_pin( + design, pin_name="resp_val", layer="metal4", location=[12, 50], pin_size=[2, 2] +) +ppl_aux.place_pin( + design, pin_name="req_msg\[0\]", layer="metal10", location=[25, 70], pin_size=[4, 4] +) -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - corner_avoidance=0, min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("place_pin2.def") design.writeDef(def_file) diff --git a/src/ppl/test/ppl_aux.py b/src/ppl/test/ppl_aux.py index 5602851c5cd..11c6e9a3cf9 100644 --- a/src/ppl/test/ppl_aux.py +++ b/src/ppl/test/ppl_aux.py @@ -37,16 +37,19 @@ import re -def place_pins(design, *, - hor_layers=None, - ver_layers=None, - random_seed=None, - random=False, - corner_avoidance=None, - min_distance=None, - min_distance_in_tracks=False, - exclude=None, - group_pins=None): +def place_pins( + design, + *, + hor_layers=None, + ver_layers=None, + random_seed=None, + random=False, + corner_avoidance=None, + min_distance=None, + min_distance_in_tracks=False, + exclude=None, + group_pins=None, +): """Perform pin placement keyword arguments: @@ -92,7 +95,7 @@ def place_pins(design, *, if ver_layers == None: utl.error(utl.PPL, 318, "ver_layers is required.") - + # set default interval_length from boundaries as 1u distance = 1 if corner_avoidance != None: @@ -124,10 +127,18 @@ def place_pins(design, *, for hor_layer_name in hor_layers.split(): hor_layer = parse_layer_name(design, hor_layer_name) if not db_layer_has_hor_tracks(design, hor_layer): - utl.error(utl.PPL, 321, f"Horizontal routing tracks not found for layer {hor_layer_name}.") + utl.error( + utl.PPL, + 321, + f"Horizontal routing tracks not found for layer {hor_layer_name}.", + ) if hor_layer.getDirection() != "HORIZONTAL": - utl.error(utl.PPL, 345, f"Layer {hor_layer_name} preferred direction is not horizontal.") + utl.error( + utl.PPL, + 345, + f"Layer {hor_layer_name} preferred direction is not horizontal.", + ) hor_track_grid = dbBlock.findTrackGrid(hor_layer) @@ -138,10 +149,18 @@ def place_pins(design, *, for ver_layer_name in ver_layers.split(): ver_layer = parse_layer_name(design, ver_layer_name) if not db_layer_has_ver_tracks(design, ver_layer): - utl.error(utl.PPL, 323, f"Vertical routing tracks not found for layer {ver_layer_name}.") + utl.error( + utl.PPL, + 323, + f"Vertical routing tracks not found for layer {ver_layer_name}.", + ) if ver_layer.getDirection() != "VERTICAL": - utl.error(utl.PPL, 346, f"Layer {ver_layer_name} preferred direction is not vertical.") + utl.error( + utl.PPL, + 346, + f"Layer {ver_layer_name} preferred direction is not vertical.", + ) ver_track_grid = dbBlock.findTrackGrid(ver_layer) @@ -151,14 +170,22 @@ def place_pins(design, *, num_slots = (2 * num_tracks_x + 2 * num_tracks_y) / min_dist if bterms_cnt > num_slots: - utl.error(utl.PPL, 324, f"Number of pins {bterms_cnt} exceeds max possible {num_slots}.") + utl.error( + utl.PPL, + 324, + f"Number of pins {bterms_cnt} exceeds max possible {num_slots}.", + ) if exclude != None: lef_units = dbTech.getLefUnits() for region in exclude: edge, interval = region.split(":") - if not (edge in ["top","bottom", "left", "right"]): - utl.error(utl.PPL, 326, f"exclude: invalid syntax in {region}. Use (top|bottom|left|right):interval.") + if not (edge in ["top", "bottom", "left", "right"]): + utl.error( + utl.PPL, + 326, + f"exclude: invalid syntax in {region}. Use (top|bottom|left|right):interval.", + ) edge_ = parse_edge(design, edge) if len(interval.split("-")) > 1: @@ -168,7 +195,7 @@ def place_pins(design, *, else: begin = int(begin) if end == "*": - end = get_edge_extreme(design, False, edge) + end = get_edge_extreme(design, False, edge) else: end = int(end) @@ -178,11 +205,11 @@ def place_pins(design, *, elif interval == "*": begin = get_edge_extreme(design, True, edge) - end = get_edge_extreme(design, False, edge) + end = get_edge_extreme(design, False, edge) design.getIOPlacer().excludeInterval(edge_, begin, end) else: - utl.error(utl.PPL, 325, f"-exclude: {interval} is an invalid region.") + utl.error(utl.PPL, 325, f"-exclude: {interval} is an invalid region.") if group_pins != None: group_idx = 0 @@ -196,7 +223,9 @@ def place_pins(design, *, if db_bterm != None: pin_list.append(db_bterm) else: - utl.warn(utl.PPL, 343, f"Pin {pin_name} not found in group {group_idx}.") + utl.warn( + utl.PPL, 343, f"Pin {pin_name} not found in group {group_idx}." + ) design.getIOPlacer().addPinGroup(pin_list, False) group_idx += 1 @@ -204,15 +233,23 @@ def place_pins(design, *, design.getIOPlacer().run(random) -def place_pin(design, pin_name=None, layer=None, location=None, pin_size=None, - force_to_die_boundary=False): - x = design.micronToDBU(location[0]) - y = design.micronToDBU(location[1]) - width = design.micronToDBU(pin_size[0]) +def place_pin( + design, + pin_name=None, + layer=None, + location=None, + pin_size=None, + force_to_die_boundary=False, +): + x = design.micronToDBU(location[0]) + y = design.micronToDBU(location[1]) + width = design.micronToDBU(pin_size[0]) height = design.micronToDBU(pin_size[1]) - pin = parse_pin_names(design, pin_name) - lay = parse_layer_name(design, layer) - design.getIOPlacer().placePin(pin[0], lay, x, y, width, height, force_to_die_boundary) + pin = parse_pin_names(design, pin_name) + lay = parse_layer_name(design, layer) + design.getIOPlacer().placePin( + pin[0], lay, x, y, width, height, force_to_die_boundary + ) def parse_layer_name(design, layer_name): @@ -247,28 +284,38 @@ def db_layer_has_ver_tracks(design, layer): def parse_edge(design, edge): - if not(edge in ["top", "bottom", "left", "right"]): - utl.error(utl.PPL, 327, f"{edge} is an invalid edge. Use top, bottom, left or right.") + if not (edge in ["top", "bottom", "left", "right"]): + utl.error( + utl.PPL, 327, f"{edge} is an invalid edge. Use top, bottom, left or right." + ) return design.getIOPlacer().getEdge(edge) def get_edge_extreme(design, begin, edge): dbBlock = design.getBlock() die_area = dbBlock.getDieArea() - if begin: + if begin: if edge == "top" or edge == "bottom": extreme = die_area.xMin() elif edge == "left" or edge == "right": extreme = die_area.yMin() else: - utl.error(utl.PPL, 329, "Invalid edge {edge}. Should be one of top, bottom, left, right.") + utl.error( + utl.PPL, + 329, + "Invalid edge {edge}. Should be one of top, bottom, left, right.", + ) else: if edge == "top" or edge == "bottom": extreme = die_area.xMax() elif edge == "left" or edge == "right": extreme = die_area.yMax() else: - utl.error(utl.PPL, 330, "Invalid edge {edge}. Should be one of top, bottom, left, right.") + utl.error( + utl.PPL, + 330, + "Invalid edge {edge}. Should be one of top, bottom, left, right.", + ) return extreme @@ -277,16 +324,19 @@ def clear_io_pin_constraints(design): design.getIOPlacer().clearConstraints() -def set_io_pin_constraint(design, *, - direction=None, - pin_names=None, # single string list of pins - region=None, - group=False, - order=False): +def set_io_pin_constraint( + design, + *, + direction=None, + pin_names=None, # single string list of pins + region=None, + group=False, + order=False, +): """Set the region constraints for pins according to the pin direction or the pin name keyword arguments: - direction -- "input" | "output" | "inout" | "feedthru" + direction -- "input" | "output" | "inout" | "feedthru" pin_names -- string list of pins to constrain, can contain regex. Note that we need to escape regex characters for exact matching, ie, use "rqst\[23\]" instead of "rqst[23]" @@ -316,18 +366,22 @@ def set_io_pin_constraint(design, *, else: begin = design.micronsToDBU(begin) - if end =="*": + if end == "*": end = get_edge_extreme(design, False, edge) - else: + else: end = design.micronToDBU(end) elif interval == "*": begin = get_edge_extreme(design, True, edge) - end = get_edge_extreme(design, False, edge) + end = get_edge_extreme(design, False, edge) else: utl.error(utl.PPL, 399, "Unrecognized region specification") if direction != None and pin_names != None: - utl.error(utl.PPL, 316, "Both 'direction' and 'pin_names' constraints not allowed.") + utl.error( + utl.PPL, + 316, + "Both 'direction' and 'pin_names' constraints not allowed.", + ) if direction != None: dir = parse_direction(design, direction) @@ -335,7 +389,7 @@ def set_io_pin_constraint(design, *, # f"{design.micronToDBU(begin)}-{design.micronToDBU(end)}, " + # f"in the {edge} edge.") design.getIOPlacer().addDirectionConstraint(dir, edge_, begin, end) - + if pin_names != None: pin_list = parse_pin_names(design, pin_names) design.getIOPlacer().addNamesConstraint(pin_list, edge_, begin, end) @@ -357,7 +411,9 @@ def set_io_pin_constraint(design, *, urx = design.micronToDBU(float(urx)) ury = design.micronToDBU(float(ury)) else: - utl.error(utl.PPL, 359, 'Box at top layer must have 4 values "llx lly urx ury".') + utl.error( + utl.PPL, 359, 'Box at top layer must have 4 values "llx lly urx ury".' + ) if pin_names != None: pin_list = parse_pin_names(design, pin_names) @@ -374,7 +430,9 @@ def set_io_pin_constraint(design, *, if db_bterm != None: pin_list.append(db_bterm) else: - utl.warn(utl.PPL, 500, f"Group pin {pin_name} not found in the design.") + utl.warn( + utl.PPL, 500, f"Group pin {pin_name} not found in the design." + ) design.getIOPlacer().addPinGroup(pin_list, order) @@ -383,14 +441,15 @@ def set_io_pin_constraint(design, *, def parse_direction(design, direction): - if (re.fullmatch("INPUT", direction, re.I) != None or - re.fullmatch("OUTPUT", direction, re.I) != None or - re.fullmatch("INOUT", direction, re.I) != None or - re.fullmatch("FEEDTHRU", direction, re.I) != None): - - return design.getIOPlacer().getDirection(direction.lower()) - else: - utl.error(utl.PPL, 328, f"Invalid pin direction {direction}.") + if ( + re.fullmatch("INPUT", direction, re.I) != None + or re.fullmatch("OUTPUT", direction, re.I) != None + or re.fullmatch("INOUT", direction, re.I) != None + or re.fullmatch("FEEDTHRU", direction, re.I) != None + ): + return design.getIOPlacer().getDirection(direction.lower()) + else: + utl.error(utl.PPL, 328, f"Invalid pin direction {direction}.") def is_pos_float(x): @@ -420,8 +479,15 @@ def parse_pin_names(design, names): return pin_list -def define_pin_shape_pattern(design, layer_name=None, x_step=None, y_step=None, - region=None, size=None, pin_keepout=None): +def define_pin_shape_pattern( + design, + layer_name=None, + x_step=None, + y_step=None, + region=None, + size=None, + pin_keepout=None, +): """Defines a pin placement grid on the specified layer keyword arguments: @@ -432,7 +498,7 @@ def define_pin_shape_pattern(design, layer_name=None, x_step=None, y_step=None, region -- Defines the "llx lly urx ury" region of the placement grid in microns pin_keepout -- defines the boundary (in microns) around existing routing - obstructions that the pins should avoid. This defaults to the + obstructions that the pins should avoid. This defaults to the layer minimum spacing. """ if layer_name != None: @@ -458,14 +524,21 @@ def define_pin_shape_pattern(design, layer_name=None, x_step=None, y_step=None, ury = die_area.yMax() elif len(region.split()) == 4: - llx, lly, urx, ury, = region.split() + ( + llx, + lly, + urx, + ury, + ) = region.split() llx = design.micronToDBU(float(llx)) lly = design.micronToDBU(float(lly)) urx = design.micronToDBU(float(urx)) ury = design.micronToDBU(float(ury)) else: - utl.error(utl.PPL, 363, f"region should be a list of 4 values. It is {region}.") + utl.error( + utl.PPL, 363, f"region should be a list of 4 values. It is {region}." + ) rect = odb.Rect(llx, lly, urx, ury) else: @@ -484,7 +557,10 @@ def define_pin_shape_pattern(design, layer_name=None, x_step=None, y_step=None, keepout = design.micronToDBU(pin_keepout) else: max_dim = max(width, height) - keepout = design.getTech().getDB().getTech().findLayer(layer_name).getSpacing(max_dim) + keepout = ( + design.getTech().getDB().getTech().findLayer(layer_name).getSpacing(max_dim) + ) - design.getIOPlacer().addTopLayerPinPattern(layer, x_step, y_step, rect, - width, height, keepout) + design.getIOPlacer().addTopLayerPinPattern( + layer, x_step, y_step, rect, width, height, keepout + ) diff --git a/src/ppl/test/ppl_man_tcl_check.py b/src/ppl/test/ppl_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/ppl/test/ppl_man_tcl_check.py +++ b/src/ppl/test/ppl_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/ppl/test/ppl_readme_msgs_check.py b/src/ppl/test/ppl_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/ppl/test/ppl_readme_msgs_check.py +++ b/src/ppl/test/ppl_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/ppl/test/random2.py b/src/ppl/test/random2.py index e755c499d22..815b5f9d563 100644 --- a/src/ppl/test/random2.py +++ b/src/ppl/test/random2.py @@ -8,8 +8,9 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - random=True, random_seed=0) +ppl_aux.place_pins( + design, hor_layers="metal3", ver_layers="metal2", random=True, random_seed=0 +) def_file = helpers.make_result_file("random2.def") design.writeDef(def_file) diff --git a/src/ppl/test/random3.py b/src/ppl/test/random3.py index 0912614609c..80483a8706d 100644 --- a/src/ppl/test/random3.py +++ b/src/ppl/test/random3.py @@ -11,8 +11,7 @@ ppl_aux.set_io_pin_constraint(design, direction="INPUT", region="top:*") ppl_aux.set_io_pin_constraint(design, direction="OUTPUT", region="bottom:*") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - random=True) +ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", random=True) def_file = helpers.make_result_file("random3.def") design.writeDef(def_file) diff --git a/src/ppl/test/random4.py b/src/ppl/test/random4.py index dfb8e6f61f3..e1b8fe784b8 100644 --- a/src/ppl/test/random4.py +++ b/src/ppl/test/random4.py @@ -8,11 +8,16 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.set_io_pin_constraint(design, pin_names="resp_val resp_rdy req_rdy req_val", region="bottom:*") -ppl_aux.set_io_pin_constraint(design, pin_names="req_msg\[15\] req_msg\[14\] resp_msg\[15\] resp_msg\[14\]", region="top:*") +ppl_aux.set_io_pin_constraint( + design, pin_names="resp_val resp_rdy req_rdy req_val", region="bottom:*" +) +ppl_aux.set_io_pin_constraint( + design, + pin_names="req_msg\[15\] req_msg\[14\] resp_msg\[15\] resp_msg\[14\]", + region="top:*", +) -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - random=True) +ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", random=True) def_file = helpers.make_result_file("random4.def") design.writeDef(def_file) diff --git a/src/ppl/test/random7.py b/src/ppl/test/random7.py index 8a964f67eb6..dad0b94c77d 100644 --- a/src/ppl/test/random7.py +++ b/src/ppl/test/random7.py @@ -8,8 +8,13 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", - random=True, group_pins=["req_msg[14] req_msg[15] req_msg[16] req_msg[17]"]) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + random=True, + group_pins=["req_msg[14] req_msg[15] req_msg[16] req_msg[17]"], +) def_file = helpers.make_result_file("random7.def") design.writeDef(def_file) diff --git a/src/ppl/test/top_layer1.py b/src/ppl/test/top_layer1.py index b692158485f..9694784f777 100644 --- a/src/ppl/test/top_layer1.py +++ b/src/ppl/test/top_layer1.py @@ -11,11 +11,18 @@ design = Design(tech) design.readDef("blocked_region.def") -ppl_aux.define_pin_shape_pattern(design, layer_name="met5", x_step=6.8, - y_step=6.8, region="50 50 250 250", size=[1.6, 2.5]) +ppl_aux.define_pin_shape_pattern( + design, + layer_name="met5", + x_step=6.8, + y_step=6.8, + region="50 50 250 250", + size=[1.6, 2.5], +) -ppl_aux.set_io_pin_constraint(design, pin_names="clk resp_val req_val resp_rdy reset req_rdy", - region="up:*") +ppl_aux.set_io_pin_constraint( + design, pin_names="clk resp_val req_val resp_rdy reset req_rdy", region="up:*" +) ppl_aux.place_pins(design, hor_layers="met3", ver_layers="met2") diff --git a/src/ppl/test/top_layer2.py b/src/ppl/test/top_layer2.py index edab1cce0fe..46d4a469927 100644 --- a/src/ppl/test/top_layer2.py +++ b/src/ppl/test/top_layer2.py @@ -11,11 +11,20 @@ design = Design(tech) design.readDef("blocked_region.def") -ppl_aux.define_pin_shape_pattern(design, layer_name="met5", x_step=6.8, - y_step=6.8, region="50 50 250 250", size=[1.6, 2.5]) +ppl_aux.define_pin_shape_pattern( + design, + layer_name="met5", + x_step=6.8, + y_step=6.8, + region="50 50 250 250", + size=[1.6, 2.5], +) -ppl_aux.set_io_pin_constraint(design, pin_names="clk resp_val req_val resp_rdy reset req_rdy", - region="up:170 200 250 250") +ppl_aux.set_io_pin_constraint( + design, + pin_names="clk resp_val req_val resp_rdy reset req_rdy", + region="up:170 200 250 250", +) ppl_aux.place_pins(design, hor_layers="met3", ver_layers="met2") diff --git a/src/ppl/test/top_layer3.py b/src/ppl/test/top_layer3.py index ca46a980430..0aed7c328eb 100644 --- a/src/ppl/test/top_layer3.py +++ b/src/ppl/test/top_layer3.py @@ -9,14 +9,28 @@ design = Design(tech) design.readDef("gcd.def") -ppl_aux.define_pin_shape_pattern(design, layer_name="metal10", x_step=4.8, - y_step=4.8, region="0.095 0.07 90 90", size=[1.6, 2.5]) +ppl_aux.define_pin_shape_pattern( + design, + layer_name="metal10", + x_step=4.8, + y_step=4.8, + region="0.095 0.07 90 90", + size=[1.6, 2.5], +) -ppl_aux.set_io_pin_constraint(design, pin_names="clk resp_val req_val resp_rdy reset req_rdy", - region="up:70 50 95 100") +ppl_aux.set_io_pin_constraint( + design, + pin_names="clk resp_val req_val resp_rdy reset req_rdy", + region="up:70 50 95 100", +) -ppl_aux.place_pins(design, hor_layers="metal3", ver_layers="metal2", corner_avoidance=0, - min_distance=0.12) +ppl_aux.place_pins( + design, + hor_layers="metal3", + ver_layers="metal2", + corner_avoidance=0, + min_distance=0.12, +) def_file = helpers.make_result_file("top_layer3.def") design.writeDef(def_file) diff --git a/src/psm/test/gcd_em_test_vdd.py b/src/psm/test/gcd_em_test_vdd.py index 3649b26e689..f61ae097b70 100644 --- a/src/psm/test/gcd_em_test_vdd.py +++ b/src/psm/test/gcd_em_test_vdd.py @@ -11,7 +11,8 @@ design.evalTclString("read_sdc Nangate45_data/gcd.sdc") em_file = helpers.make_result_file("gcd_em_test_vdd-em.rpt") -pdnsim_aux.analyze_power_grid(design, vsrc="Vsrc_gcd_vdd.loc", enable_em=True, - em_outfile=em_file, net="VDD") +pdnsim_aux.analyze_power_grid( + design, vsrc="Vsrc_gcd_vdd.loc", enable_em=True, em_outfile=em_file, net="VDD" +) helpers.diff_files(em_file, "gcd_em_test_vdd-em.rptok") diff --git a/src/psm/test/gcd_test_vdd.py b/src/psm/test/gcd_test_vdd.py index c39b3cd1337..a1692265637 100644 --- a/src/psm/test/gcd_test_vdd.py +++ b/src/psm/test/gcd_test_vdd.py @@ -14,9 +14,13 @@ error_file = helpers.make_result_file("gcd_test_vdd-error.rpt") pdnsim_aux.check_power_grid(design, net="VDD") -pdnsim_aux.analyze_power_grid(design, vsrc="Vsrc_gcd_vdd.loc", net="VDD", - outfile=voltage_file, - error_file=error_file) +pdnsim_aux.analyze_power_grid( + design, + vsrc="Vsrc_gcd_vdd.loc", + net="VDD", + outfile=voltage_file, + error_file=error_file, +) helpers.diff_files(voltage_file, "gcd_test_vdd-voltage.rptok") helpers.diff_files(error_file, "gcd_test_vdd-error.rptok") diff --git a/src/psm/test/gcd_write_sp_test_vdd.py b/src/psm/test/gcd_write_sp_test_vdd.py index 9e9dd536cfd..f2a7d891740 100644 --- a/src/psm/test/gcd_write_sp_test_vdd.py +++ b/src/psm/test/gcd_write_sp_test_vdd.py @@ -13,7 +13,8 @@ spice_file = helpers.make_result_file("gcd_write_sp_test_vdd.sp") pdnsim_aux.analyze_power_grid(design, net="VDD", vsrc="Vsrc_gcd_vdd.loc") -pdnsim_aux.write_pg_spice(design, vsrc="Vsrc_gcd_vdd.loc", - outfile=spice_file, net="VDD") +pdnsim_aux.write_pg_spice( + design, vsrc="Vsrc_gcd_vdd.loc", outfile=spice_file, net="VDD" +) helpers.diff_files(spice_file, "gcd_write_sp_test_vdd.spok") diff --git a/src/psm/test/pdnsim_aux.py b/src/psm/test/pdnsim_aux.py index 491429c6e18..e48c99bba9b 100644 --- a/src/psm/test/pdnsim_aux.py +++ b/src/psm/test/pdnsim_aux.py @@ -36,14 +36,17 @@ import utl -def analyze_power_grid(design, *, - vsrc=None, - outfile=None, - error_file=None, - enable_em=False, - em_outfile=None, - net=None, - corner=None): +def analyze_power_grid( + design, + *, + vsrc=None, + outfile=None, + error_file=None, + enable_em=False, + em_outfile=None, + net=None, + corner=None +): pdnsim = design.getPDNSim() if not net: @@ -64,45 +67,34 @@ def analyze_power_grid(design, *, if bool(em_outfile): if not enable_em: - utl.error(utl.PSM, 155, "EM outfile defined without EM " + - "enable flag. Add -enable_em.") + utl.error( + utl.PSM, + 155, + "EM outfile defined without EM " + "enable flag. Add -enable_em.", + ) else: em_outfile = "" - pdnsim.analyzePowerGrid(net, - corner, - 2, - outfile, - enable_em, - em_outfile, - error_file, - vsrc) + pdnsim.analyzePowerGrid( + net, corner, 2, outfile, enable_em, em_outfile, error_file, vsrc + ) def check_power_grid(design, *, net=None, error_file=None): pdnsim = design.getPDNSim() if not net: - utl.error( - utl.PSM, - 157, - "Argument 'net' not specified to check_power_grid.") + utl.error(utl.PSM, 157, "Argument 'net' not specified to check_power_grid.") if not error_file: error_file = "" - res = pdnsim.checkConnectivity(design.getBlock().findNet(net), - False, - error_file) + res = pdnsim.checkConnectivity(design.getBlock().findNet(net), False, error_file) if res == 0: utl.error(utl.PSM, 169, "Check connectivity failed.") return res -def write_pg_spice(design, *, - vsrc=None, - outfile=None, - net=None, - corner=None): +def write_pg_spice(design, *, vsrc=None, outfile=None, net=None, corner=None): pdnsim = design.getPDNSim() if not net: @@ -116,22 +108,20 @@ def write_pg_spice(design, *, corner = _find_corner(design, corner) - pdnsim.writeSpiceNetwork(design.getBlock().findNet(net), - corner, - 2, - outfile, - vsrc) + pdnsim.writeSpiceNetwork(design.getBlock().findNet(net), corner, 2, outfile, vsrc) def set_pdnsim_net_voltage(design, *, net=None, voltage=None, corner=None): pdnsim = design.getPDNSim() if bool(net) and bool(voltage): - pdnsim.setNetVoltage(design.getBlock().findNet(net), - corner, - float(voltage)) + pdnsim.setNetVoltage(design.getBlock().findNet(net), corner, float(voltage)) else: - utl.error(utl.PSM, 162, "Argument -net or -voltage not specified. " + - "Please specify both -net and -voltage arguments.") + utl.error( + utl.PSM, + 162, + "Argument -net or -voltage not specified. " + + "Please specify both -net and -voltage arguments.", + ) def _find_corner(design, corner): diff --git a/src/psm/test/psm_man_tcl_check.py b/src/psm/test/psm_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/psm/test/psm_man_tcl_check.py +++ b/src/psm/test/psm_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/psm/test/psm_readme_msgs_check.py b/src/psm/test/psm_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/psm/test/psm_readme_msgs_check.py +++ b/src/psm/test/psm_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/rcx/test/45_gcd.py b/src/rcx/test/45_gcd.py index d80a6c44843..30f60c50932 100644 --- a/src/rcx/test/45_gcd.py +++ b/src/rcx/test/45_gcd.py @@ -17,8 +17,9 @@ rcx_aux.define_process_corner(ext_model_index=0, filename="X") -rcx_aux.extract_parasitics(ext_model_file="45_patterns.rules", - max_res=0, coupling_threshold=0.1) +rcx_aux.extract_parasitics( + ext_model_file="45_patterns.rules", max_res=0, coupling_threshold=0.1 +) spef_file = helpers.make_result_file("45_gcd.spef") rcx_aux.write_spef(filename=spef_file, nets=test_nets) diff --git a/src/rcx/test/ext_pattern.py b/src/rcx/test/ext_pattern.py index 340875683fb..c99b7a657d4 100644 --- a/src/rcx/test/ext_pattern.py +++ b/src/rcx/test/ext_pattern.py @@ -11,9 +11,13 @@ rcx_aux.define_process_corner(ext_model_index=0, filename="X") -rcx_aux.extract_parasitics(ext_model_file="ext_pattern.rules", - cc_model=12, max_res=0, context_depth=10, - coupling_threshold=0.1) +rcx_aux.extract_parasitics( + ext_model_file="ext_pattern.rules", + cc_model=12, + max_res=0, + context_depth=10, + coupling_threshold=0.1, +) spef_file = helpers.make_result_file("ext_pattern.spef") rcx_aux.write_spef(filename=spef_file, nets=test_nets) diff --git a/src/rcx/test/gcd.py b/src/rcx/test/gcd.py index 8219133a538..613a42ee28b 100644 --- a/src/rcx/test/gcd.py +++ b/src/rcx/test/gcd.py @@ -18,8 +18,9 @@ rcx_aux.define_process_corner(ext_model_index=0, filename="X") -rcx_aux.extract_parasitics(ext_model_file="ext_pattern.rules", max_res=0, - coupling_threshold=0.1) +rcx_aux.extract_parasitics( + ext_model_file="ext_pattern.rules", max_res=0, coupling_threshold=0.1 +) spef_file = helpers.make_result_file("gcd.spef") rcx_aux.write_spef(filename=spef_file, nets=test_nets) diff --git a/src/rcx/test/rcx_aux.py b/src/rcx/test/rcx_aux.py index fc7070fe049..e80ec49a828 100644 --- a/src/rcx/test/rcx_aux.py +++ b/src/rcx/test/rcx_aux.py @@ -9,26 +9,30 @@ def define_process_corner(*, ext_model_index=0, filename=""): rcx.define_process_corner(ext_model_index, filename) -def extract_parasitics(*, ext_model_file=None, - corner_cnt=1, - max_res=50.0, - coupling_threshold=0.1, - debug_net_id="", - lef_res=False, - cc_model=10, - context_depth=5, - no_merge_via_res=False - ): +def extract_parasitics( + *, + ext_model_file=None, + corner_cnt=1, + max_res=50.0, + coupling_threshold=0.1, + debug_net_id="", + lef_res=False, + cc_model=10, + context_depth=5, + no_merge_via_res=False +): # NOTE: This is position dependent - rcx.extract(ext_model_file, - corner_cnt, - max_res, - coupling_threshold, - cc_model, - context_depth, - debug_net_id, - lef_res, - no_merge_via_res) + rcx.extract( + ext_model_file, + corner_cnt, + max_res, + coupling_threshold, + cc_model, + context_depth, + debug_net_id, + lef_res, + no_merge_via_res, + ) def write_spef(*, filename="", nets="", net_id=0, coordinates=False): @@ -39,45 +43,48 @@ def bench_verilog(*, filename=""): rcx.bench_verilog(filename) -def bench_wires(*, - met_cnt=1000, - cnt=5, - len=100, - over=False, - diag=False, - all=False, - db_only=False, - under_met=-1, - w_list="1", - s_list="1 2 2.5 3 3.5 4 4.5 5 6 8 10 12", - over_dist=100, - under_dist=100): - rcx.bench_wires(db_only, over, diag, all, met_cnt, cnt, len, under_met, - w_list, s_list, over_dist, under_dist) - - -def adjust_rc(*, res_factor=1.0, - cc_factor=1.0, - gndc_factor=1.0): +def bench_wires( + *, + met_cnt=1000, + cnt=5, + len=100, + over=False, + diag=False, + all=False, + db_only=False, + under_met=-1, + w_list="1", + s_list="1 2 2.5 3 3.5 4 4.5 5 6 8 10 12", + over_dist=100, + under_dist=100 +): + rcx.bench_wires( + db_only, + over, + diag, + all, + met_cnt, + cnt, + len, + under_met, + w_list, + s_list, + over_dist, + under_dist, + ) + + +def adjust_rc(*, res_factor=1.0, cc_factor=1.0, gndc_factor=1.0): rcx.adjust_rc(res_factor, cc_factor, gndc_factor) -def diff_spef(*, filename="", - r_conn=False, - r_res=False, - r_cap=False, - r_cc_cap=False): - rcx.diff_spef(filename, r_conn, r_res, r_cap, r_cc_cap) +def diff_spef(*, filename="", r_conn=False, r_res=False, r_cap=False, r_cc_cap=False): + rcx.diff_spef(filename, r_conn, r_res, r_cap, r_cc_cap) -def write_rules(*, - filename="extRules", - dir="./", - name="TYP", - pattern=0): +def write_rules(*, filename="extRules", dir="./", name="TYP", pattern=0): rcx.write_rules(filename, dir, name, pattern) def read_spef(*, filename): rcx.read_spef(filename) - diff --git a/src/rcx/test/rcx_man_tcl_check.py b/src/rcx/test/rcx_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/rcx/test/rcx_man_tcl_check.py +++ b/src/rcx/test/rcx_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/rcx/test/rcx_readme_msgs_check.py b/src/rcx/test/rcx_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/rcx/test/rcx_readme_msgs_check.py +++ b/src/rcx/test/rcx_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/rcx/test/via_45_resistance.py b/src/rcx/test/via_45_resistance.py index 2419454f9ab..9e35a6e59bd 100644 --- a/src/rcx/test/via_45_resistance.py +++ b/src/rcx/test/via_45_resistance.py @@ -1,5 +1,6 @@ import helpers # only for setting logging + def set_resistance(tech): layer = tech.getDB().getTech().findLayer layer("via1").setResistance(5) diff --git a/src/rmp/test/blif_reader.py b/src/rmp/test/blif_reader.py index f809e3adba5..4195f76c25b 100644 --- a/src/rmp/test/blif_reader.py +++ b/src/rmp/test/blif_reader.py @@ -6,11 +6,9 @@ tech = Tech() design = Design(tech) -blif = rmp_aux.create_blif(design, - hicell="LOGIC1_X1", - hiport="Z", - locell="LOGIC0_X1", - loport="Z") +blif = rmp_aux.create_blif( + design, hicell="LOGIC1_X1", hiport="Z", locell="LOGIC0_X1", loport="Z" +) tech.readLef("./Nangate45/Nangate45.lef") tech.readLiberty("./Nangate45/Nangate45_typ.lib") diff --git a/src/rmp/test/const_cell_removal.py b/src/rmp/test/const_cell_removal.py index c3545cf9ee0..d9643ac2055 100644 --- a/src/rmp/test/const_cell_removal.py +++ b/src/rmp/test/const_cell_removal.py @@ -14,7 +14,13 @@ tiehi = "LOGIC1_X1/Z" tielo = "LOGIC0_X1/Z" -rmp_aux.restructure(design, liberty_file_name="Nangate45/Nangate45_typ.lib", target="area", - abc_logfile="results/abc_rcon.log", tielo_port=tielo, tiehi_port=tiehi) +rmp_aux.restructure( + design, + liberty_file_name="Nangate45/Nangate45_typ.lib", + target="area", + abc_logfile="results/abc_rcon.log", + tielo_port=tielo, + tiehi_port=tiehi, +) design.evalTclString("report_design_area") diff --git a/src/rmp/test/gcd_restructure.py b/src/rmp/test/gcd_restructure.py index 4039ed8c2f0..4262b17eece 100644 --- a/src/rmp/test/gcd_restructure.py +++ b/src/rmp/test/gcd_restructure.py @@ -23,8 +23,14 @@ set_thread_count(3) -rmp_aux.restructure(design, liberty_file_name="Nangate45/Nangate45_typ.lib", target="area", - abc_logfile="results/abc_rcon.log", tielo_port=tielo, tiehi_port=tiehi, - workdir_name="./results") +rmp_aux.restructure( + design, + liberty_file_name="Nangate45/Nangate45_typ.lib", + target="area", + abc_logfile="results/abc_rcon.log", + tielo_port=tielo, + tiehi_port=tiehi, + workdir_name="./results", +) design.evalTclString("report_design_area") diff --git a/src/rmp/test/rmp_aux.py b/src/rmp/test/rmp_aux.py index a262bcd11aa..fbca107bac8 100644 --- a/src/rmp/test/rmp_aux.py +++ b/src/rmp/test/rmp_aux.py @@ -4,13 +4,14 @@ # So, getting back objects from evalTclString is not supported and we # end up with this... These lib pins appear to be Liberty lib pins, -# and it doesn't look like I can use odb to get these objects. +# and it doesn't look like I can use odb to get these objects. # Must wait until sta is wrapped? # # To be used with this substition dict, where portname is a string # {'tielohi_port': portname, 'tie' : 'hi'} or # {'tielohi_port': portname, 'tie' : 'lo'} -lohitemp = Template('''set lohiport $tielohi_port +lohitemp = Template( + """set lohiport $tielohi_port if { ![sta::is_object $$lohiport] } { set lohiport [sta::get_lib_pins $tielohi_port] if { [llength $$lohiport] > 1 } { @@ -21,41 +22,45 @@ if { $$lohiport != "" } { rmp::set_tie${tie}_port_cmd $$lohiport } - ''') + """ +) def set_tiehi(design, tiehi_port): if tiehi_port == None: utl.error(utl.RMP, 301, "Must specify a tiehi_port") tieHiport = design.evalTclString( - lohitemp.substitute({'tielohi_port' : tiehi_port, 'tie': 'hi'})) + lohitemp.substitute({"tielohi_port": tiehi_port, "tie": "hi"}) + ) def set_tielo(design, tielo_port): if tielo_port == None: utl.error(utl.RMP, 302, "Must specify a tielo_port") tieLoport = design.evalTclString( - lohitemp.substitute({'tielohi_port' : tielo_port,'tie': 'lo'})) + lohitemp.substitute({"tielohi_port": tielo_port, "tie": "lo"}) + ) -def restructure(design, *, - liberty_file_name="", - target="area", - slack_threshold=0.0, - depth_threshold=16, - workdir_name=".", - tielo_port=None, - tiehi_port=None, - abc_logfile=""): +def restructure( + design, + *, + liberty_file_name="", + target="area", + slack_threshold=0.0, + depth_threshold=16, + workdir_name=".", + tielo_port=None, + tiehi_port=None, + abc_logfile="" +): rst = design.getRestructure() set_tielo(design, tielo_port) set_tiehi(design, tiehi_port) rst.setMode(target) - rst.run(liberty_file_name, - slack_threshold, - depth_threshold, - workdir_name, - abc_logfile) + rst.run( + liberty_file_name, slack_threshold, depth_threshold, workdir_name, abc_logfile + ) def create_blif(design, *, hicell="", hiport="", locell="", loport=""): diff --git a/src/rmp/test/rmp_man_tcl_check.py b/src/rmp/test/rmp_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/rmp/test/rmp_man_tcl_check.py +++ b/src/rmp/test/rmp_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/rmp/test/rmp_readme_msgs_check.py b/src/rmp/test/rmp_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/rmp/test/rmp_readme_msgs_check.py +++ b/src/rmp/test/rmp_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/rsz/test/rsz_man_tcl_check.py b/src/rsz/test/rsz_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/rsz/test/rsz_man_tcl_check.py +++ b/src/rsz/test/rsz_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/rsz/test/rsz_readme_msgs_check.py b/src/rsz/test/rsz_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/rsz/test/rsz_readme_msgs_check.py +++ b/src/rsz/test/rsz_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/stt/test/check.py b/src/stt/test/check.py index aa7968a4fb0..878c75c811f 100644 --- a/src/stt/test/check.py +++ b/src/stt/test/check.py @@ -11,17 +11,21 @@ # squawk when segment overlap is detected logger.setDebugLevel(utl.STT, "check", 1) -cross1 = [['cross1', 0], - [['p0', 72, 61], - ['p1', 86, 50], - ['p2', 84, 51], - ['p3', 89, 51], - ['p4', 86, 53], - ['p5', 86, 58], - ['p6', 85, 59], - ['p7', 80, 53], - ['p8', 79, 56], - ['p9', 81, 58], - ['p10', 79, 60]]] +cross1 = [ + ["cross1", 0], + [ + ["p0", 72, 61], + ["p1", 86, 50], + ["p2", 84, 51], + ["p3", 89, 51], + ["p4", 86, 53], + ["p5", 86, 58], + ["p6", 85, 59], + ["p7", 80, 53], + ["p8", 79, 56], + ["p9", 81, 58], + ["p10", 79, 60], + ], +] stt_aux.report_stt_net(design, cross1, 0.3) diff --git a/src/stt/test/flute1.py b/src/stt/test/flute1.py index e4a5eb06741..638cc6b47ef 100644 --- a/src/stt/test/flute1.py +++ b/src/stt/test/flute1.py @@ -6,8 +6,10 @@ tech = Tech() design = Design(tech) -net = [[ "net250", 0], - [["p0", 3510237, 1971558], +net = [ + ["net250", 0], + [ + ["p0", 3510237, 1971558], ["p1", 3568506, 3117151], ["p2", 1572870, 2925881], ["p3", 2129150, 2652209], @@ -256,7 +258,8 @@ ["p246", 3348753, 1174173], ["p247", 2011311, 1117972], ["p248", 1923691, 2834442], - ["p249", 3017393, 3424676] - ]] + ["p249", 3017393, 3424676], + ], +] stt_aux.report_flute_net(design, net) diff --git a/src/stt/test/flute_gcd.py b/src/stt/test/flute_gcd.py index d06bb053398..35646d3dddb 100644 --- a/src/stt/test/flute_gcd.py +++ b/src/stt/test/flute_gcd.py @@ -2,6 +2,7 @@ from openroad import Design, Tech import helpers import stt_aux + tech = Tech() design = Design(tech) diff --git a/src/stt/test/pd1.py b/src/stt/test/pd1.py index 6240edf2aab..3fd2b7f1cde 100644 --- a/src/stt/test/pd1.py +++ b/src/stt/test/pd1.py @@ -1,46 +1,33 @@ from openroad import Design, Tech import stt_aux import helpers + tech = Tech() design = Design(tech) alpha = 0.4 -dup1 =[['dup1', 0], - [['p0', 0, 0], - ['p1', 10, 10], - ['p2', 10, 20], - ['p3', 10, 10]]] +dup1 = [["dup1", 0], [["p0", 0, 0], ["p1", 10, 10], ["p2", 10, 20], ["p3", 10, 10]]] stt_aux.report_pd_net(design, dup1, alpha) -dup2 = [['dup2', 2], - [['p0', 29, 43], - ['p1', 28, 45], - ['p2', 28, 44]]] +dup2 = [["dup2", 2], [["p0", 29, 43], ["p1", 28, 45], ["p2", 28, 44]]] stt_aux.report_pd_net(design, dup2, alpha) -dup3 = [['dup3', 2], - [['p0', 100, 56], - ['p1', 65, 37], - ['p2', 65, 38]]] +dup3 = [["dup3", 2], [["p0", 100, 56], ["p1", 65, 37], ["p2", 65, 38]]] stt_aux.report_pd_net(design, dup3, alpha) # 2 duplicate points -dup4 = [['dup4', 0], - [['p0', 10, 10], - ['p1', 10, 10]]] +dup4 = [["dup4", 0], [["p0", 10, 10], ["p1", 10, 10]]] stt_aux.report_pd_net(design, dup4, alpha) -one = [['one', 0], - [['p0', 10, 10]]] +one = [["one", 0], [["p0", 10, 10]]] stt_aux.report_pd_net(design, one, alpha) # driver index changes by duplicate removal -dup5 = [['dup5', 2], - [['p0', 123, 209], - ['p1', 123, 209], - ['p2', 123, 215], - ['p3', 122, 211]]] +dup5 = [ + ["dup5", 2], + [["p0", 123, 209], ["p1", 123, 209], ["p2", 123, 215], ["p3", 122, 211]], +] stt_aux.report_pd_net(design, dup5, 0.3) diff --git a/src/stt/test/pd2.py b/src/stt/test/pd2.py index 2a4fcbc64ef..d898e7a2a68 100644 --- a/src/stt/test/pd2.py +++ b/src/stt/test/pd2.py @@ -9,18 +9,22 @@ alpha = 0.4 # p8 p10 same x -net = [['lalaland1', 0], - [['p0', 2013675, 1174195], - ['p1', 1730950, 624475], - ['p2', 1742950, 751015], - ['p3', 1958747, 834065], - ['p4', 1919867, 767465], - ['p5', 1961350, 840725], - ['p6', 1874470, 807425], - ['p7', 1757627, 854045], - ['p8', 1965947, 1087145], - ['p9', 2005787, 1127105], - ['p10', 1965947, 1100465]]] +net = [ + ["lalaland1", 0], + [ + ["p0", 2013675, 1174195], + ["p1", 1730950, 624475], + ["p2", 1742950, 751015], + ["p3", 1958747, 834065], + ["p4", 1919867, 767465], + ["p5", 1961350, 840725], + ["p6", 1874470, 807425], + ["p7", 1757627, 854045], + ["p8", 1965947, 1087145], + ["p9", 2005787, 1127105], + ["p10", 1965947, 1100465], + ], +] stt_aux.report_pd_net(design, net, alpha) @@ -28,36 +32,40 @@ # p27 p29 same x # p9 p17 same y # p2 p5 same y -net = [['lalaland2', 0], - [['p0', 2013675, 1174195], - ['p1', 1705307, 714185], - ['p2', 1687067, 740825], - ['p3', 1710587, 694205], - ['p4', 1689417, 717715], - ['p5', 1701467, 740825], - ['p6', 1769627, 667565], - ['p7', 1711067, 631135], - ['p8', 1694747, 597835], - ['p9', 1711547, 697735], - ['p10', 1666907, 731035], - ['p11', 1714427, 724375], - ['p12', 1782107, 680885], - ['p13', 1724987, 640925], - ['p14', 1712507, 607625], - ['p15', 1740347, 711055], - ['p16', 1678427, 720845], - ['p17', 1745147, 697735], - ['p18', 1796987, 687545], - ['p19', 1745097, 684415], - ['p20', 1730950, 624475], - ['p21', 1742950, 751015], - ['p22', 1958747, 834065], - ['p23', 1919867, 767465], - ['p24', 1961350, 840725], - ['p25', 1874470, 807425], - ['p26', 1757627, 854045], - ['p27', 1965947, 1087145], - ['p28', 2005787, 1127105], - ['p29', 1965947, 1100465]]] +net = [ + ["lalaland2", 0], + [ + ["p0", 2013675, 1174195], + ["p1", 1705307, 714185], + ["p2", 1687067, 740825], + ["p3", 1710587, 694205], + ["p4", 1689417, 717715], + ["p5", 1701467, 740825], + ["p6", 1769627, 667565], + ["p7", 1711067, 631135], + ["p8", 1694747, 597835], + ["p9", 1711547, 697735], + ["p10", 1666907, 731035], + ["p11", 1714427, 724375], + ["p12", 1782107, 680885], + ["p13", 1724987, 640925], + ["p14", 1712507, 607625], + ["p15", 1740347, 711055], + ["p16", 1678427, 720845], + ["p17", 1745147, 697735], + ["p18", 1796987, 687545], + ["p19", 1745097, 684415], + ["p20", 1730950, 624475], + ["p21", 1742950, 751015], + ["p22", 1958747, 834065], + ["p23", 1919867, 767465], + ["p24", 1961350, 840725], + ["p25", 1874470, 807425], + ["p26", 1757627, 854045], + ["p27", 1965947, 1087145], + ["p28", 2005787, 1127105], + ["p29", 1965947, 1100465], + ], +] stt_aux.report_pd_net(design, net, alpha) diff --git a/src/stt/test/pd_gcd.py b/src/stt/test/pd_gcd.py index e606c9ad64f..0d82fcf378e 100644 --- a/src/stt/test/pd_gcd.py +++ b/src/stt/test/pd_gcd.py @@ -2,6 +2,7 @@ from openroad import Design, Tech import helpers import stt_aux + tech = Tech() design = Design(tech) diff --git a/src/stt/test/stt_aux.py b/src/stt/test/stt_aux.py index 64ec99378a8..b339f33bc7f 100644 --- a/src/stt/test/stt_aux.py +++ b/src/stt/test/stt_aux.py @@ -1,4 +1,5 @@ import stt + FLUTE_ACCURACY = 3 diff --git a/src/stt/test/stt_man_tcl_check.py b/src/stt/test/stt_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/stt/test/stt_man_tcl_check.py +++ b/src/stt/test/stt_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/stt/test/stt_readme_msgs_check.py b/src/stt/test/stt_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/stt/test/stt_readme_msgs_check.py +++ b/src/stt/test/stt_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/tap/test/avoid_overlap.py b/src/tap/test/avoid_overlap.py index 477da7b187f..5ade931362a 100644 --- a/src/tap/test/avoid_overlap.py +++ b/src/tap/test/avoid_overlap.py @@ -10,11 +10,11 @@ options = tap.Options() -options.dist = design.micronToDBU(14) -options.halo_x = design.micronToDBU(2) -options.halo_y = design.micronToDBU(2) +options.dist = design.micronToDBU(14) +options.halo_x = design.micronToDBU(2) +options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("sky130_fd_sc_hs__tap_1") -options.endcap_master = tech.getDB().findMaster("sky130_fd_sc_hs__decap_4") +options.endcap_master = tech.getDB().findMaster("sky130_fd_sc_hs__decap_4") design.getTapcell().run(options) diff --git a/src/tap/test/boundary_macros.py b/src/tap/test/boundary_macros.py index b43a37b672b..71d54d0e730 100644 --- a/src/tap/test/boundary_macros.py +++ b/src/tap/test/boundary_macros.py @@ -15,17 +15,17 @@ options.halo_x = design.micronToDBU(2) options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("TAPCELL_X1") -options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") -options.tap_nwin2_master = tech.getDB().findMaster( "TAPCELL_X1") -options.tap_nwin3_master = tech.getDB().findMaster( "TAPCELL_X1") -options.tap_nwout2_master = tech.getDB().findMaster( "TAPCELL_X1") -options.tap_nwout3_master = tech.getDB().findMaster( "TAPCELL_X1") -options.tap_nwintie_master = tech.getDB().findMaster( "TAPCELL_X1") -options.tap_nwouttie_master = tech.getDB().findMaster( "TAPCELL_X1") -options.cnrcap_nwin_master = tech.getDB().findMaster( "TAPCELL_X1") -options.cnrcap_nwout_master = tech.getDB().findMaster( "TAPCELL_X1") -options.incnrcap_nwin_master = tech.getDB().findMaster( "TAPCELL_X1") -options.incnrcap_nwout_master = tech.getDB().findMaster( "TAPCELL_X1") +options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") +options.tap_nwin2_master = tech.getDB().findMaster("TAPCELL_X1") +options.tap_nwin3_master = tech.getDB().findMaster("TAPCELL_X1") +options.tap_nwout2_master = tech.getDB().findMaster("TAPCELL_X1") +options.tap_nwout3_master = tech.getDB().findMaster("TAPCELL_X1") +options.tap_nwintie_master = tech.getDB().findMaster("TAPCELL_X1") +options.tap_nwouttie_master = tech.getDB().findMaster("TAPCELL_X1") +options.cnrcap_nwin_master = tech.getDB().findMaster("TAPCELL_X1") +options.cnrcap_nwout_master = tech.getDB().findMaster("TAPCELL_X1") +options.incnrcap_nwin_master = tech.getDB().findMaster("TAPCELL_X1") +options.incnrcap_nwout_master = tech.getDB().findMaster("TAPCELL_X1") design.getTapcell().run(options) design.getOpendp().checkPlacement(True) diff --git a/src/tap/test/gcd_fakeram.py b/src/tap/test/gcd_fakeram.py index 80461661b55..b7c590e900b 100644 --- a/src/tap/test/gcd_fakeram.py +++ b/src/tap/test/gcd_fakeram.py @@ -13,7 +13,7 @@ options.halo_x = design.micronToDBU(2) options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("TAPCELL_X1") -options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") +options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") design.getTapcell().run(options) diff --git a/src/tap/test/gcd_nangate45.py b/src/tap/test/gcd_nangate45.py index 6c691169c5b..c3ead5e6ddc 100644 --- a/src/tap/test/gcd_nangate45.py +++ b/src/tap/test/gcd_nangate45.py @@ -9,11 +9,11 @@ design.readDef("gcd_nangate45.def") options = tap.Options() -options.dist = design.micronToDBU(20) +options.dist = design.micronToDBU(20) options.halo_x = design.micronToDBU(2) options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("TAPCELL_X1") -options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") +options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") design.getTapcell().run(options) diff --git a/src/tap/test/gcd_prefix.py b/src/tap/test/gcd_prefix.py index c6240c6f05b..357ff0e7674 100644 --- a/src/tap/test/gcd_prefix.py +++ b/src/tap/test/gcd_prefix.py @@ -10,11 +10,11 @@ design.readDef("gcd_prefix.def") options = tap.Options() -options.dist = design.micronToDBU(20) -options.halo_x = design.micronToDBU(2) -options.halo_y = design.micronToDBU(2) +options.dist = design.micronToDBU(20) +options.halo_x = design.micronToDBU(2) +options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("TAPCELL_X1") -options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") +options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") design.getTapcell().setTapPrefix("CHECK_TAPCELL_") design.getTapcell().setEndcapPrefix("CHECK_END_") diff --git a/src/tap/test/gcd_ripup.py b/src/tap/test/gcd_ripup.py index 6779401fd7a..eb9469277d4 100644 --- a/src/tap/test/gcd_ripup.py +++ b/src/tap/test/gcd_ripup.py @@ -14,7 +14,7 @@ options.halo_x = design.micronToDBU(2) options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("TAPCELL_X1") -options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") +options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") design.getTapcell().run(options) diff --git a/src/tap/test/gcd_sky130.py b/src/tap/test/gcd_sky130.py index 634aa0a6fd7..4727c4dd1b4 100644 --- a/src/tap/test/gcd_sky130.py +++ b/src/tap/test/gcd_sky130.py @@ -9,11 +9,11 @@ design.readDef("gcd_sky130hs_floorplan.def") options = tap.Options() -options.dist = design.micronToDBU(15) +options.dist = design.micronToDBU(15) options.halo_x = design.micronToDBU(2) options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("sky130_fd_sc_hs__tap_1") -options.endcap_master = tech.getDB().findMaster("sky130_fd_sc_hs__decap_4") +options.endcap_master = tech.getDB().findMaster("sky130_fd_sc_hs__decap_4") design.getTapcell().run(options) diff --git a/src/tap/test/multiple_calls.py b/src/tap/test/multiple_calls.py index c5caa381904..f55a530ea67 100644 --- a/src/tap/test/multiple_calls.py +++ b/src/tap/test/multiple_calls.py @@ -9,9 +9,9 @@ design.readDef("gcd_ripup.def") options = tap.Options() -options.dist = design.micronToDBU(20) +options.dist = design.micronToDBU(20) options.tapcell_master = tech.getDB().findMaster("TAPCELL_X1") -options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") +options.endcap_master = tech.getDB().findMaster("TAPCELL_X1") design.getTapcell().run(options) @@ -21,7 +21,7 @@ design.getTapcell().clear() -options.dist = design.micronToDBU(10) +options.dist = design.micronToDBU(10) design.getTapcell().run(options) def_file2 = helpers.make_result_file("mc2.def") design.writeDef(def_file2) diff --git a/src/tap/test/no_endcap.py b/src/tap/test/no_endcap.py index fb75e7d6e2e..e9f58996d67 100644 --- a/src/tap/test/no_endcap.py +++ b/src/tap/test/no_endcap.py @@ -9,7 +9,7 @@ design.readDef("gcd_sky130hs_floorplan.def") options = tap.Options() -options.dist = design.micronToDBU(15) +options.dist = design.micronToDBU(15) options.halo_x = design.micronToDBU(2) options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("sky130_fd_sc_hs__tap_1") diff --git a/src/tap/test/symmetry.py b/src/tap/test/symmetry.py index 6b0d2e926dc..7bea3012af6 100644 --- a/src/tap/test/symmetry.py +++ b/src/tap/test/symmetry.py @@ -9,11 +9,11 @@ design.readDef("symmetry.def") options = tap.Options() -options.dist = design.micronToDBU(120) +options.dist = design.micronToDBU(120) options.halo_x = design.micronToDBU(2) options.halo_y = design.micronToDBU(2) options.tapcell_master = tech.getDB().findMaster("TAPCELL") -options.endcap_master = tech.getDB().findMaster("TAPCELL") +options.endcap_master = tech.getDB().findMaster("TAPCELL") design.getTapcell().run(options) diff --git a/src/tap/test/tap_man_tcl_check.py b/src/tap/test/tap_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/tap/test/tap_man_tcl_check.py +++ b/src/tap/test/tap_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/tap/test/tap_readme_msgs_check.py b/src/tap/test/tap_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/tap/test/tap_readme_msgs_check.py +++ b/src/tap/test/tap_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/upf/test/upf_man_tcl_check.py b/src/upf/test/upf_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/upf/test/upf_man_tcl_check.py +++ b/src/upf/test/upf_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/upf/test/upf_readme_msgs_check.py b/src/upf/test/upf_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/upf/test/upf_readme_msgs_check.py +++ b/src/upf/test/upf_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/src/utl/test/utl_man_tcl_check.py b/src/utl/test/utl_man_tcl_check.py index 09bfed91e0d..589cef67d0c 100644 --- a/src/utl/test/utl_man_tcl_check.py +++ b/src/utl/test/utl_man_tcl_check.py @@ -11,7 +11,7 @@ or_home = os.path.dirname(os.path.dirname(os.path.dirname(path))) os.chdir(or_home) -help_dict, proc_dict, readme_dict = {}, {}, {} +help_dict, proc_dict, readme_dict = {}, {}, {} # Directories to exclude (according to md_roff_compat) exclude = ["sta"] @@ -19,17 +19,23 @@ for path in glob.glob("./src/*/src/*tcl") + include: # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue # exclude these dirs which are not compiled in man (do not have readmes). tool_dir = os.path.dirname(os.path.dirname(path)) - if module not in tool_dir: continue - if "odb" in tool_dir: tool_dir = './src/odb' - if not os.path.exists(f"{tool_dir}/README.md"): continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if module not in tool_dir: + continue + if "odb" in tool_dir: + tool_dir = "./src/odb" + if not os.path.exists(f"{tool_dir}/README.md"): + continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue # special handling for pad, since it has 3 Tcls. - if "ICeWall" in path or "PdnGen" in path: continue + if "ICeWall" in path or "PdnGen" in path: + continue with open(path) as f: # Help patterns @@ -43,9 +49,11 @@ for path in glob.glob("./src/*/README.md"): # exclude all dirs other than the current dir. - if module not in path: continue + if module not in path: + continue - if re.search(f".*{'|'.join(e for e in exclude)}.*", path): continue + if re.search(f".*{'|'.join(e for e in exclude)}.*", path): + continue tool_dir = os.path.dirname(path) # for gui, filter out the gui:: for separate processing @@ -53,15 +61,17 @@ readme_dict[tool_dir] = len(results) # for pad, remove `make_fake_io_site` because it is a hidden cmd arg - if 'pad' in tool_dir: readme_dict[tool_dir] -= 1 + if "pad" in tool_dir: + readme_dict[tool_dir] -= 1 -print("Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count") +print( + "Tool Dir".ljust(20), "Help count".ljust(15), "Proc count".ljust(15), "Readme count" +) for path in help_dict: - h,p,r = help_dict[path], proc_dict[path], readme_dict[path] - print(path.ljust(20), - str(h).ljust(15), - str(p).ljust(15), - str(r)) - if h == p == r: print("Command counts match.") - else: print("Command counts do not match.") \ No newline at end of file + h, p, r = help_dict[path], proc_dict[path], readme_dict[path] + print(path.ljust(20), str(h).ljust(15), str(p).ljust(15), str(r)) + if h == p == r: + print("Command counts match.") + else: + print("Command counts do not match.") diff --git a/src/utl/test/utl_readme_msgs_check.py b/src/utl/test/utl_readme_msgs_check.py index 5f2920c1a42..8a60bb0ff75 100644 --- a/src/utl/test/utl_readme_msgs_check.py +++ b/src/utl/test/utl_readme_msgs_check.py @@ -6,9 +6,8 @@ cur_dir = os.getcwd() doc_dir = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), - "docs" - ) + os.path.dirname(os.path.dirname(os.path.dirname(cur_dir))), "docs" +) save_dir = os.path.join(cur_dir, "results/docs") os.makedirs(save_dir, exist_ok=True) @@ -16,4 +15,4 @@ messages_path = os.path.join(cur_dir, "../messages.txt") man2_translate(readme_path, save_dir) -man3_translate(messages_path, save_dir) \ No newline at end of file +man3_translate(messages_path, save_dir) diff --git a/test/helpers.py b/test/helpers.py index da982675899..e84f06c1f75 100644 --- a/test/helpers.py +++ b/test/helpers.py @@ -3,6 +3,7 @@ import utl import re + def make_rect(design, xl, yl, xh, yh): xl = design.micronToDBU(xl) yl = design.micronToDBU(yl) @@ -10,8 +11,9 @@ def make_rect(design, xl, yl, xh, yh): yh = design.micronToDBU(yh) return odb.Rect(xl, yl, xh, yh) + def make_result_file(filename): - result_dir = os.path.join(os.getcwd(), 'results') + result_dir = os.path.join(os.getcwd(), "results") if not os.path.exists(result_dir): os.mkdir(result_dir) @@ -19,14 +21,15 @@ def make_result_file(filename): filename = "{}-py{}".format(*root_ext) return os.path.join(result_dir, filename) + def diff_files(file1, file2, ignore=None): if ignore: ignore = re.compile(ignore) - with open(file1, 'r') as f: + with open(file1, "r") as f: lines1 = f.readlines() - with open(file2, 'r') as f: + with open(file2, "r") as f: lines2 = f.readlines() num_lines1 = len(lines1) @@ -47,6 +50,7 @@ def diff_files(file1, file2, ignore=None): utl.report("No differences found.") return 0 + # Output voltage file is specified as ... utl.suppress_message(utl.PSM, 2) # Output current file specified ... diff --git a/test/timing_api.py b/test/timing_api.py index 20cb24a7998..33ce4fe4194 100644 --- a/test/timing_api.py +++ b/test/timing_api.py @@ -11,18 +11,23 @@ for corner in timing.getCorners(): for net in design.getBlock().getNets(): - print(net.getName(), - timing.getNetCap(net, corner, Timing.Max), - timing.getNetCap(net, corner, Timing.Min)) + print( + net.getName(), + timing.getNetCap(net, corner, Timing.Max), + timing.getNetCap(net, corner, Timing.Min), + ) for inst in design.getBlock().getInsts(): - print(inst.getName(), inst.getMaster().getName(), - design.isSequential(inst.getMaster())) + print( + inst.getName(), + inst.getMaster().getName(), + design.isSequential(inst.getMaster()), + ) for lib in tech.getDB().getLibs(): for master in lib.getMasters(): print(master.getName()) for mterm in master.getMTerms(): - print(' ', mterm.getName()) + print(" ", mterm.getName()) for m in timing.getTimingFanoutFrom(mterm): - print(' ', m.getName()) + print(" ", m.getName()) diff --git a/test/timing_api_2.py b/test/timing_api_2.py index 5a5be872d57..c34ce10eca8 100644 --- a/test/timing_api_2.py +++ b/test/timing_api_2.py @@ -11,27 +11,30 @@ timing = Timing(design) for inst in design.getBlock().getInsts(): - print(inst.getName(), + print( + inst.getName(), inst.getMaster().getName(), - design.isSequential(inst.getMaster()), + design.isSequential(inst.getMaster()), design.isInClock(inst), design.isBuffer(inst.getMaster()), design.isInverter(inst.getMaster()), + ) + for corner in timing.getCorners(): + print( + timing.staticPower(inst, corner), + timing.dynamicPower(inst, corner), ) - for corner in timing.getCorners(): - print(timing.staticPower(inst, corner), - timing.dynamicPower(inst, corner), - ) - for iTerm in inst.getITerms(): - if not iTerm.getNet(): - continue - if not (design.isInSupply(iTerm)): - print(design.getITermName(iTerm), - timing.getPinArrival(iTerm, Timing.Rise), - timing.getPinArrival(iTerm, Timing.Fall), - timing.getPinSlew(iTerm), - timing.isEndpoint(iTerm) + for iTerm in inst.getITerms(): + if not iTerm.getNet(): + continue + if not (design.isInSupply(iTerm)): + print( + design.getITermName(iTerm), + timing.getPinArrival(iTerm, Timing.Rise), + timing.getPinArrival(iTerm, Timing.Fall), + timing.getPinSlew(iTerm), + timing.isEndpoint(iTerm), ) for net in design.getBlock().getNets(): - print(net.getName(), design.getNetRoutedLength(net)) + print(net.getName(), design.getNetRoutedLength(net)) diff --git a/test/timing_api_3.py b/test/timing_api_3.py index 2983e7de8ec..5ba87755d46 100644 --- a/test/timing_api_3.py +++ b/test/timing_api_3.py @@ -11,19 +11,21 @@ timing = Timing(design) for inst in design.getBlock().getInsts(): - for iTerm in inst.getITerms(): - if not iTerm.getNet(): - continue - if (design.isInSupply(iTerm)): - continue - print(design.getITermName(iTerm), - timing.getPinSlack(iTerm, Timing.Rise, Timing.Max), - timing.getPinSlack(iTerm, Timing.Fall, Timing.Max), - timing.getPinSlack(iTerm, Timing.Rise, Timing.Min), - timing.getPinSlack(iTerm, Timing.Fall, Timing.Min), - ) - for i, corner in enumerate(timing.getCorners()): - print(f"Corner {i}", - timing.getPortCap(iTerm, corner, Timing.Max), - timing.getPortCap(iTerm, corner, Timing.Min), - ) + for iTerm in inst.getITerms(): + if not iTerm.getNet(): + continue + if design.isInSupply(iTerm): + continue + print( + design.getITermName(iTerm), + timing.getPinSlack(iTerm, Timing.Rise, Timing.Max), + timing.getPinSlack(iTerm, Timing.Fall, Timing.Max), + timing.getPinSlack(iTerm, Timing.Rise, Timing.Min), + timing.getPinSlack(iTerm, Timing.Fall, Timing.Min), + ) + for i, corner in enumerate(timing.getCorners()): + print( + f"Corner {i}", + timing.getPortCap(iTerm, corner, Timing.Max), + timing.getPortCap(iTerm, corner, Timing.Min), + ) diff --git a/test/timing_api_4.py b/test/timing_api_4.py index 17264a727ad..8959774a9a6 100644 --- a/test/timing_api_4.py +++ b/test/timing_api_4.py @@ -14,21 +14,28 @@ for corner in timing.getCorners(): for net in design.getBlock().getNets(): - print(net.getName(), - timing.getNetCap(net, corner, Timing.Max), - timing.getNetCap(net, corner, Timing.Min)) + print( + net.getName(), + timing.getNetCap(net, corner, Timing.Max), + timing.getNetCap(net, corner, Timing.Min), + ) for inst in design.getBlock().getInsts(): - print(inst.getName(), inst.getMaster().getName(), - design.isSequential(inst.getMaster())) + print( + inst.getName(), + inst.getMaster().getName(), + design.isSequential(inst.getMaster()), + ) for lib in tech.getDB().getLibs(): for master in lib.getMasters(): print(master.getName()) for mterm in master.getMTerms(): - print(f'{mterm.getName()} {timing.getMaxCapLimit(mterm):12.5e} {timing.getMaxSlewLimit(mterm):12.5e}') + print( + f"{mterm.getName()} {timing.getMaxCapLimit(mterm):12.5e} {timing.getMaxSlewLimit(mterm):12.5e}" + ) for m in timing.getTimingFanoutFrom(mterm): - print(' ', m.getName()) + print(" ", m.getName()) timing.makeEquivCells() for lib in tech.getDB().getLibs(): @@ -37,4 +44,4 @@ dbmaster = db.findMaster(master.getName()) equicCells = timing.equivCells(dbmaster) for equicCell in equicCells: - print(' ',equicCell.getName()) + print(" ", equicCell.getName()) diff --git a/test/two_designs.py b/test/two_designs.py index b9dc01a1686..50ecc1b12e8 100644 --- a/test/two_designs.py +++ b/test/two_designs.py @@ -5,13 +5,13 @@ ord_tech1 = Tech() design1 = Design(ord_tech1) -design1.readDb('../src/odb/test/data/design.odb') +design1.readDb("../src/odb/test/data/design.odb") db2 = Design.createDetachedDb() -db2 = odb.read_db(db2, '../src/odb/test/data/design.odb') +db2 = odb.read_db(db2, "../src/odb/test/data/design.odb") -db1_file = helpers.make_result_file('db1.odb') -db2_file = helpers.make_result_file('db2.odb') +db1_file = helpers.make_result_file("db1.odb") +db2_file = helpers.make_result_file("db2.odb") design1.writeDb(db1_file) odb.write_db(db2, db2_file) From c3a4f977c1cd19a4ae9ded8a5e12aab2e8388422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Tue, 30 Jul 2024 07:37:45 +0200 Subject: [PATCH 2/2] ci: run python black MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Øyvind Harboe --- .github/workflows/black.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/black.yaml diff --git a/.github/workflows/black.yaml b/.github/workflows/black.yaml new file mode 100644 index 00000000000..d14d043183d --- /dev/null +++ b/.github/workflows/black.yaml @@ -0,0 +1,11 @@ +name: Lint Python + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: psf/black@stable +