#Hammer-vlsi _Chipyard Hi guys, I have a issue whe...
# general
p
#Hammer-vlsi _Chipyard Hi guys, I have a issue when I'm trying to run par by using synopsys tool. I faced a Error like this: "ImportError: cannot import name 'SynopsysTool' from 'hammer.vlsi' (/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi/__init__.py)"
Copy code
(/home/trunglt/chipyard/.conda-env) [trunglt@vncs004 vlsi]$ make par tutorial=sky130-icc2
Running with RISCV=/home/trunglt/chipyard/.conda-env/riscv-tools
./example-vlsi-sky130 -e /home/trunglt/chipyard/vlsi/env.yml -p /home/trunglt/chipyard/vlsi/build-sky130-icc2/chipyard.TestHarness.TinyRocketConfig-ChipTop/par-input.json  --obj_dir /home/trunglt/chipyard/vlsi/build-sky130-icc2/chipyard.TestHarness.TinyRocketConfig-ChipTop par
[<global>] Loading hammer-vlsi libraries and reading settings
[<global>] Loading technology 'hammer.technology.sky130'
[<global>] Key technology.sky130.openram_lib has a type str is not yet implemented
[<global>] Key technology.sky130.dffram_lib has a type Optional[str] is not yet implemented
[<global>] Key technology.sky130.pdk_home has a type Optional[str] is not yet implemented
[<global>] Key technology.sky130.lvs_deck_sources has a type Optional[list[str]] is not yet implemented
[tech] The install path: /path/to/skywater-src-nda does not exist, looked at key technology.sky130.sky130_nda
[<global>] Key technology.sky130.sram22_sky130_macros is not associated with a type
[tech] Modifying CDL netlist: /home/trunglt/.conda-sky130/share/pdk/sky130A/libs.ref/sky130_fd_sc_hd/cdl/sky130_fd_sc_hd.cdl -> /home/trunglt/chipyard/vlsi/build-sky130-icc2/chipyard.TestHarness.TinyRocketConfig-ChipTop/tech-sky130-cache/sky130_fd_sc_hd.cdl
[tech] Modifying Verilog netlist: /home/trunglt/.conda-sky130/share/pdk/sky130A/libs.ref/sky130_fd_sc_hd/verilog/sky130_fd_sc_hd.v -> /home/trunglt/chipyard/vlsi/build-sky130-icc2/chipyard.TestHarness.TinyRocketConfig-ChipTop/tech-sky130-cache/sky130_fd_sc_hd.v
[tech] Modifying Verilog netlist: /home/trunglt/.conda-sky130/share/pdk/sky130A/libs.ref/sky130_fd_sc_hd/verilog/primitives.v -> /home/trunglt/chipyard/vlsi/build-sky130-icc2/chipyard.TestHarness.TinyRocketConfig-ChipTop/tech-sky130-cache/primitives.v
[tech] Modifying Technology LEF: /home/trunglt/.conda-sky130/share/pdk/sky130A/libs.ref/sky130_fd_sc_hd/techlef/sky130_fd_sc_hd__nom.tlef -> /home/trunglt/chipyard/vlsi/build-sky130-icc2/chipyard.TestHarness.TinyRocketConfig-ChipTop/tech-sky130-cache/sky130_fd_sc_hd__nom.tlef
Loaded Sky130 Tech
Traceback (most recent call last):
  File "/home/trunglt/chipyard/vlsi/./example-vlsi-sky130", line 63, in <module>
    ExampleDriver().main()
  File "/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi/cli_driver.py", line 1722, in main
    sys.exit(self.run_main_parsed(vars(parser.parse_args(args))))
  File "/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi/cli_driver.py", line 1627, in run_main_parsed
    output_config = action_func(driver, errors.append)  # type: Optional[dict]
  File "/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi/cli_driver.py", line 607, in action
    if not driver.load_par_tool(get_or_else(self.par_rundir, "")):
  File "/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi/driver.py", line 323, in load_par_tool
    config_result = self.instantiate_tool_from_config("par", HammerPlaceAndRouteTool)
  File "/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi/driver.py", line 190, in instantiate_tool_from_config
    tool_get = load_tool(tool_module)
  File "/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi/hammer_vlsi_impl.py", line 2302, in load_tool
    mod = importlib.import_module(tool_module)
  File "/home/trunglt/chipyard/.conda-env/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/par/icc2/__init__.py", line 21, in <module>
    from hammer.vlsi import SynopsysTool
ImportError: cannot import name 'SynopsysTool' from 'hammer.vlsi' (/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi/__init__.py)
make: *** [/home/trunglt/chipyard/vlsi/build-sky130-icc2/chipyard.TestHarness.TinyRocketConfig-ChipTop/hammer.d:94: /home/trunglt/chipyard/vlsi/build-sky130-icc2/chipyard.TestHarness.TinyRocketConfig-ChipTop/par-rundir/par-output-full.json] Error 1
I was import icc2 from hammer-synopsys-plugins under /home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/par Do you have any ideas to solve this problem? Best regards, Peter
j
Hello! It looks like you do have some
hammer.vlsi
library, but that library lacks the
SynopsysTool
in it... Could it be that you have an outdated
hammer-vlsi
library? You can check that it is
1.1.1
with
pip3 show hammer-vlsi
I think...
Ah, I get the same error:
Copy code
>>> from hammer.vlsi import SynopsysTool
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'SynopsysTool' from 'hammer.vlsi' (/home/josuah/.local/lib/python3.11/site-packages/hammer/vlsi/__init__.py)
The
hammer-vlsi
tool might be dynamically checking for available toolchains installed.
Do you have the synopsys tools setup on your machine? That'd be the first thing to check
p
Do you have the synopsys tools setup on your machine? That'd be the first thing to check
Yes. I have synopsys tool setup in my machine.
j
Maybe the import location did just change? I can run the following:
Copy code
>>> from hammer.common.synopsys import SynopsysTool
Either this, or the auto-import it does on
hammer.vlsi
does not work...
Although, the file doing the import is from hammer itself... I suppose they are aware of their own package organization.
Copy code
/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/par/icc2/__init__.py
Oh! I do not have a icc2 in par in hammer...
Could you try uninstalling hammer-vlsi then installing it again?
It could have been an issue if upgrading this package from an earlier version
p
With hammer version 1.1.1. It do not have synopsys tool. So You mean I should install old hammer-vlsi version?
I was pull hammer-synopsys-plugin and then I copy icc folder under this path. /home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/par
j
Oh right! thanks, I was wondering where this plugin came from.
p
One more thing in this file
Copy code
/home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/par/icc2/__init__.py:
  1 #!/usr/bin/env python3 
  2 # -*- coding: utf-8 -*- 
  3 # 
  4 #  hammer-vlsi plugin for Synopsys ICC.
  5 #
  6 #  See LICENSE for licence details.
  7 
  8 import os
  9 import sys
 10 import errno
 11 from shutil import copyfile
 12 from os.path import dirname
 13 from typing import List, Optional,Callable, Tuple, Set, Any, cast, Dict
 14 from decimal import Decimal
 15 
 16 from hammer.utils import get_or_else, optional_map
 17 import hammer.tech as hammer_tech
 18 from hammer.tech import RoutingDirection, Metal, LibraryFilter
 19 from hammer.vlsi import HammerTool, HammerToolHookAction, HammerPlaceAndRouteTool, HammerToolStep, PlacementConstraintType, HierarchicalMode, ObstructionType, Margins, Supply, PlacementConstraint, MMMCCornerType
 20 from hammer.vlsi import SynopsysTool
 21 from hammer.logging import HammerVLSILogging
 22 from hammer.tech import HammerTechnologyUtils
 23 from hammer.tech.specialcells import CellType, SpecialCell
 24 from hammer.vlsi.constraints import BumpsDefinition
 25 
 26 class ICC(HammerPlaceAndRouteTool, SynopsysTool):
....
It try to import SynopsysTool class. But under this path: /home/trunglt/chipyard/.conda-env/lib/python3.10/site-packages/hammer/vlsi do not contain it
j
I have absolutely no idea if that is the right thing to do 🤪 but here is what I suggest to try:
Copy code
pip3 uninstall hammer-vlsi
to remove any custom edits to this package
Copy code
git clone <https://github.com/ucb-bar/hammer-synopsys-plugins>
cd hammer-synopsys-plugins
to get the plugin from source (you might already have it) then replace the line
from hammer.vlsi import SynopsysTool
with
from hammer.common.synopsys import SynopsysTool
from the file https://github.com/ucb-bar/hammer-synopsys-plugins/blob/master/hammer/par/icc/__init__.py#L20 then install the local source as a python package with
Copy code
pip3 install .
p
OK. Thanks. I'll try and let you know later
j
It looks like some change was introduced in version
1.1.0
that could be related with it: https://github.com/ucb-bar/hammer/commit/419766d857bf21db03b4047b9efa077a28b7e71e
👍 1