Skip to content

Commit

Permalink
Attempt to dedup ILMs after both syn_map and syn_generic
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryz123 committed Nov 17, 2023
1 parent 81a1731 commit d924785
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions hammer/synthesis/genus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def steps(self) -> List[HammerToolStep]:
steps_methods = [
self.init_environment,
self.syn_generic,
self.dedup_ilms_post_generic,
self.syn_map,
self.dedup_ilms_post_map,
self.add_tieoffs,
self.write_regs,
self.generate_reports,
Expand Down Expand Up @@ -282,6 +284,28 @@ def retime_modules(self) -> bool:

return True

def dedup_ilms(self) -> bool:
"""After DDI, syn_generic and syn_map will sometimes uniquify hierarchical ILMs,
despite .preserve being set on the ILM modules. From observation, the uniquified
modules are identical to the read-in ILM, so we can safely change_link to
dedup.
TODO: Correctly disable uniquification in Genus for hierarchical blocks"""

if self.hierarchical_mode.is_nonleaf_hierarchical() and self.version() >= self.version_number("211"):
pcs = list(filter(lambda c: c.type == PlacementConstraintType.Hierarchical, self.get_placement_constraints()))
for pc in pcs:
self.append("""
# Attempt to deuniquify hinst:{inst}, incase it was uniquified
set uniquified_name [get_db hinst:{inst} .module.name]
if {{ $uniquified_name ne \"{master}\" }} {{
puts [format \"WARNING: instance hinst:{inst} was uniquified to be an instance of $uniquified_name, not {master}. Attempting to fix\"]
change_link -copy_attributes -instances {{{inst}}} -design_name module:{top}/{master}
}}
set_db hinst:{inst} .preserve true
""".format(inst=pc.path, top=self.top_module, master=pc.master))
return True

def syn_generic(self) -> bool:
# Add clock mapping flow if special cells are specified
if self.version() >= self.version_number("211"):
Expand All @@ -303,20 +327,15 @@ def syn_generic(self) -> bool:
self.append("set_db map_clock_tree true")
self.verbose_append("syn_generic")

# With DDI, hierarchical instances may be uniquified. Use change_link to deuniquify them
if self.hierarchical_mode.is_nonleaf_hierarchical() and self.version() >= self.version_number("211"):
pcs = list(filter(lambda c: c.type == PlacementConstraintType.Hierarchical, self.get_placement_constraints()))
for pc in pcs:
self.append("""
# Attempt to deuniquify hinst:{inst}, incase it was uniquified
set uniquified_name [get_db hinst:{inst} .module.name]
if {{ $uniquified_name ne \"{master}\" }} {{
puts [format \"WARNING: instance hinst:{inst} was uniquified to be an instance of $uniquified_name, not {master}. Attempting to fix\"]
change_link -copy_attributes -instances {{{inst}}} -design_name module:{top}/{master}
}}""".format(inst=pc.path, top=self.top_module, master=pc.master))

return True

# We need to run dedup_ilms at two points in the flow, but each step must have a unique name
def dedup_ilms_post_generic(self) -> bool:
return self.dedup_ilms()

def dedup_ilms_post_map(self) -> bool:
return self.dedup_ilms()

def syn_map(self) -> bool:
self.verbose_append("syn_map")
# Need to suffix modules for hierarchical simulation if not top
Expand Down

0 comments on commit d924785

Please sign in to comment.