Skip to content

Commit

Permalink
Merge pull request #259 from jix/prepare-check
Browse files Browse the repository at this point in the history
Prepare SBY for upcomming `$check` cell support and prevent backend failure for `$print` cells
  • Loading branch information
jix authored Jan 23, 2024
2 parents 130aa37 + 881082c commit bd9e218
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sbysrc/sby_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ def instance_hierarchy_error_callback(retcode):
print(f"# running in {self.workdir}/model/", file=f)
print(f"""read_ilang design_prep.il""", file=f)
print("hierarchy -smtcheck", file=f)
print("delete */t:$print", file=f)
print("formalff -assume", file=f)
if "_nomem" in model_name:
print("memory_map -formal", file=f)
Expand Down Expand Up @@ -1088,6 +1089,7 @@ def instance_hierarchy_error_callback(retcode):
print(f"# running in {self.workdir}/model/", file=f)
print(f"""read_ilang design_prep.il""", file=f)
print("hierarchy -simcheck", file=f)
print("delete */t:$print", file=f)
print("formalff -assume", file=f)
if "_nomem" in model_name:
print("memory_map -formal", file=f)
Expand Down Expand Up @@ -1122,6 +1124,7 @@ def instance_hierarchy_error_callback(retcode):
with open(f"{self.workdir}/model/design_aiger.ys", "w") as f:
print(f"# running in {self.workdir}/model/", file=f)
print("read_ilang design_prep.il", file=f)
print("delete */t:$print", file=f)
print("hierarchy -simcheck", file=f)
print("formalff -assume", file=f)
print("flatten", file=f)
Expand Down
26 changes: 26 additions & 0 deletions sbysrc/sby_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ def from_cell(c, name):
return c.LIVE
raise ValueError("Unknown property type: " + name)

@classmethod
def from_flavor(c, name):
if name == "assume":
return c.ASSUME
if name == "assert":
return c.ASSERT
if name == "cover":
return c.COVER
if name == "live":
return c.LIVE
raise ValueError("Unknown property type: " + name)

name: str
path: Tuple[str, ...]
type: Type
Expand Down Expand Up @@ -199,6 +211,20 @@ def make_mod_hier(instance_name, module_name, hierarchy="", path=()):
location=location,
hierarchy=sub_hierarchy)
mod.properties.append(p)
if sort["type"] == "$check":
for cell in sort["cells"]:
try:
location = cell["attributes"]["src"]
except KeyError:
location = ""
p = SbyProperty(
name=cell["name"],
path=(*path, *cell_path(cell)),
type=SbyProperty.Type.from_flavor(cell["parameters"]["FLAVOR"]),
location=location,
hierarchy=sub_hierarchy)
mod.properties.append(p)

if sort["type"][0] != '$' or sort["type"].startswith("$paramod"):
for cell in sort["cells"]:
mod.submodules[cell["name"]] = make_mod_hier(
Expand Down

0 comments on commit bd9e218

Please sign in to comment.