diff --git a/docs/VLSI/Tutorial.rst b/docs/VLSI/Tutorial.rst index 40ce3abd..7c2e0d2f 100644 --- a/docs/VLSI/Tutorial.rst +++ b/docs/VLSI/Tutorial.rst @@ -98,6 +98,8 @@ example-vlsi ^^^^^^^^^^^^ This is the entry script with placeholders for hooks. In the ``ExampleDriver`` class, a list of hooks is passed in the ``get_extra_par_hooks``. Hooks are additional snippets of python and TCL (via ``x.append()``) to extend the Hammer APIs. Hooks can be inserted using the ``make_pre/post/replacement_hook`` methods as shown in this example. Refer to the Hammer documentation on hooks for a detailed description of how these are injected into the VLSI flow. +The ``scale_final_gds`` hook is a particularly powerful hook. It dumps a Python script provided by the ASAP7 tech plugin, an executes it within the Innovus TCL interpreter. This hook is run after ``write_design`` because the ASAP7 PDK requires post-par GDSs to be scaled down by a factor of 4. + example.yml ^^^^^^^^^^^ This contains the Hammer configuration for this example project. Example clock constraints, power straps definitions, placement constraints, and pin constraints are given. Additional configuration for the extra libraries and tools are at the bottom. diff --git a/vlsi/example-vlsi b/vlsi/example-vlsi index 5d43f8c5..a17f4f0c 100755 --- a/vlsi/example-vlsi +++ b/vlsi/example-vlsi @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import os import hammer_vlsi from hammer_vlsi import CLIDriver, HammerToolHookAction @@ -26,6 +27,22 @@ def example_tool_settings(x: hammer_vlsi.HammerTool) -> bool: ''') return True +def scale_final_gds(x: hammer_vlsi.HammerTool) -> bool: + """ + Scale the final GDS by a factor of 4 + """ + x.append(''' +# Write script out to a temporary file and execute it +set fp [open "{script_file}" "w"] +puts -nonewline $fp "{script_text}" +close $fp +if {{ [catch {{ exec python3 {script_file} }} msg] }} {{ + puts "$::errorInfo" +}} +'''.format(script_text=x.technology.scale_gds_script(x.output_gds_filename), script_file=os.path.join(x.run_dir, "gds_scale.py"))) + return True + + class ExampleDriver(CLIDriver): def get_extra_par_hooks(self) -> List[HammerToolHookAction]: extra_hooks = [ @@ -39,8 +56,11 @@ class ExampleDriver(CLIDriver): # make_replacement_hook will replace the specified step with a custom hook hammer_vlsi.HammerTool.make_replacement_hook("place_tap_cells", example_place_tap_cells), # make_removal_hook will remove the specified step from the flow - hammer_vlsi.HammerTool.make_removal_hook("place_bumps") + hammer_vlsi.HammerTool.make_removal_hook("place_bumps"), # The target step in any of the above calls may be a default step or another one of your custom hooks + + # This is an example of a technology-supplied hook (look in hammer/src/hammer-vlsi/technology/asap7/__init__.py) + hammer_vlsi.HammerTool.make_post_insertion_hook("write_design", scale_final_gds) ] return extra_hooks diff --git a/vlsi/hammer b/vlsi/hammer index 946c4f41..1b07b9a3 160000 --- a/vlsi/hammer +++ b/vlsi/hammer @@ -1 +1 @@ -Subproject commit 946c4f416709663651580f7c4c1be2e2652dff6f +Subproject commit 1b07b9a378c2936389b95f7ee1436e1f492d55e2