Skip to content

Commit

Permalink
implemented abstract method for tech plugins to generate their own li…
Browse files Browse the repository at this point in the history
…brary config
  • Loading branch information
harrisonliew committed Mar 8, 2024
1 parent f42634e commit 52ee341
Show file tree
Hide file tree
Showing 13 changed files with 315 additions and 544 deletions.
7 changes: 6 additions & 1 deletion hammer/par/openroad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,12 @@ def write_gds(self) -> str:
ilm_gds = list(map(lambda ilm: ilm.gds, self.get_input_ilms()))
gds_files.extend(ilm_gds)

layer_map_file=self.get_setting('par.inputs.gds_map_file')
layer_map_file=self.get_gds_map_file()
if layer_map_file is None:
self.logger.error("Must have GDS layer map for macro PG library generation! Skipping.")
return True
else:
assert isinstance(layer_map_file, str)

# the first entry of $KLAYOUT_PATH will be the one where the configuration is stored when KLayout exits
# otherwise KLayout tries to write everything to the same directory as the klayout binary and throws an error if it is not writeable
Expand Down
16 changes: 13 additions & 3 deletions hammer/tech/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,14 @@ def __init__(self):
self.time_unit: Optional[str] = None
self.cap_unit: Optional[str] = None

@abstractmethod
def gen_config(self) -> None:
"""For subclasses to set self.config directly, instead of from static JSON file"""
pass

@classmethod
def load_from_module(cls, tech_module: str) -> Optional["HammerTechnology"]:
#def load_from_module(cls, tech_module: str) -> Optional["HammerTechnology"]:
def load_from_module(cls, tech_module: str) -> "HammerTechnology":
"""Load a technology from a given module.
:param tech_module: Technology module (e.g. "hammer.technology.asap7")
Expand All @@ -366,17 +372,21 @@ def load_from_module(cls, tech_module: str) -> Optional["HammerTechnology"]:
tech.name = technology_name
tech.package = tech_module

#tech.config = tech.gen_config()
tech_json = importlib.resources.files(tech_module) / f"{technology_name}.tech.json"
tech_yaml = importlib.resources.files(tech_module) / f"{technology_name}.tech.yml"

#if tech.config is not None: # pydantic model already created
# print("Tech gen")
# return tech
if tech_json.is_file():
tech.config = TechJSON.model_validate_json(tech_json.read_text())
return tech
elif tech_yaml.is_file():
tech.config = TechJSON.model_validate_json(json.dumps(load_yaml(tech_yaml.read_text())))
return tech
else: #TODO - from Pydantic model instance
return None
else: # Assume tech implents gen_config()
return tech

def get_lib_units(self) -> None:
"""
Expand Down
292 changes: 285 additions & 7 deletions hammer/technology/sky130/__init__.py

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions hammer/technology/sky130/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ technology.sky130:

io_file: "extra/efabless_template.io" # IO ring - take this template and modify for your own use
io_file_meta: prependlocal


stdcell_library: "sky130_fd_sc_hd" # Choose between "sky130_fd_sc_hd" (open-source) or "sky130_scl" (Cadence)

mentor.extra_env_vars_meta: lazydeepsubst # Mentor environment variables
# Override this in project
Expand Down Expand Up @@ -109,9 +110,6 @@ synthesis.yosys:

par.inputs:
gds_merge: true
gds_map_mode: manual
gds_map_file: "extra/sky130_lefpin.map"
gds_map_file_meta: prependlocal

par.openroad: # openroad setup/files
setrc_file: "extra/setRC.tcl"
Expand Down
3 changes: 3 additions & 0 deletions hammer/technology/sky130/defaults_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ technology.sky130:

# Path to IO file
io_file: str

# Choose between "sky130_fd_sc_hd" (open-source) or "sky130_scl" (Cadence)
stdcell_library: str

This file was deleted.

This file was deleted.

54 changes: 0 additions & 54 deletions hammer/technology/sky130/extra/sky130-tech-gen-files/cells.json

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 52ee341

Please sign in to comment.