junit: use write_jny instead of write_json
authorN. Engelhardt <nak@yosyshq.com>
Thu, 10 Mar 2022 16:46:08 +0000 (17:46 +0100)
committerN. Engelhardt <nak@yosyshq.com>
Wed, 6 Apr 2022 16:35:01 +0000 (18:35 +0200)
sbysrc/sby_core.py
sbysrc/sby_design.py

index 1e96d00e9b73e8f7a6403879abc1d1b0c10590cb..3908f6572f4649aa945eddd6c25d96020754ad63 100644 (file)
@@ -395,7 +395,7 @@ class SbyTask:
                     print(cmd, file=f)
                 # the user must designate a top module in [script]
                 print("hierarchy -simcheck", file=f)
-                print(f"""write_json ../model/design.json""", file=f)
+                print(f"""write_jny -no-connections ../model/design.json""", file=f)
                 print(f"""write_rtlil ../model/design.il""", file=f)
 
             proc = SbyProc(
index d18d6d9bbc5a315abe45da1d8b1b335e299232f8..8fc7895567ec8d73e565b9533a2c033f16a003cc 100644 (file)
@@ -103,26 +103,34 @@ def design_hierarchy(filename):
     design_json = json.load(filename)
     def make_mod_hier(instance_name, module_name, hierarchy=""):
         # print(instance_name,":", module_name)
+        sub_hierarchy=f"{hierarchy}/{instance_name}" if hierarchy else instance_name
         mod = SbyModule(name=instance_name, type=module_name)
 
-        cells = design_json["modules"][module_name]["cells"]
-        for cell_name, cell in cells.items():
-            sub_hierarchy=f"{hierarchy}/{instance_name}" if hierarchy else instance_name
-            if cell["type"][0] != '$' or cell["type"].startswith("$paramod"):
-                mod.submodules[cell_name] = make_mod_hier(cell_name, cell["type"], hierarchy=sub_hierarchy)
-            if cell["type"] in ["$assume", "$assert", "$cover", "$live"]:
-                try:
-                    location = cell["attributes"]["src"]
-                except KeyError:
-                    location = ""
-                p = SbyProperty(name=cell_name, type=SbyProperty.Type.from_cell(cell["type"]), location=location, hierarchy=sub_hierarchy)
-                mod.properties.append(p)
+        for m in design_json["modules"]:
+            if m["name"] == module_name:
+                cell_sorts = m["cell_sorts"]
+                break
+        else:
+            raise ValueError(f"Cannot find module {module_name}")
+
+        for sort in cell_sorts:
+            if sort["type"] in ["$assume", "$assert", "$cover", "$live"]:
+                for cell in sort["cells"]:
+                    try:
+                        location = cell["attributes"]["src"]
+                    except KeyError:
+                        location = ""
+                    p = SbyProperty(name=cell["name"], type=SbyProperty.Type.from_cell(sort["type"]), 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(cell["name"], sort["type"], hierarchy=sub_hierarchy)
         return mod
 
-    for module_name in design_json["modules"]:
-        attrs = design_json["modules"][module_name]["attributes"]
+    for m in design_json["modules"]:
+        attrs = m["attributes"]
         if "top" in attrs and int(attrs["top"]) == 1:
-            hierarchy = make_mod_hier(module_name, module_name)
+            hierarchy = make_mod_hier(m["name"], m["name"])
             return hierarchy
     else:
         raise ValueError("Cannot find top module")