utils/vlog: Make output more deterministic Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/vlog_to_pbtype.py b/vlog_to_pbtype.py index 506043f..1e0e27f 100755 --- a/vlog_to_pbtype.py +++ b/vlog_to_pbtype.py
@@ -222,7 +222,7 @@ # Combinational delays dly_prefix = "DELAY_CONST_" dly_mat_prefix = "DELAY_MATRIX_" - for attr, atvalue in mod.net_attrs(name).items(): + for attr, atvalue in sorted(mod.net_attrs(name).items()): if attr.startswith(dly_prefix): # Single, constant delays inp = attr[len(dly_prefix):]
diff --git a/yosys/json.py b/yosys/json.py index 968fbdd..37c2121 100755 --- a/yosys/json.py +++ b/yosys/json.py
@@ -27,7 +27,7 @@ The direction, should be either `input` or `output` """ plist = [] - for port, pdata in self.data["ports"].items(): + for port, pdata in sorted(self.data["ports"].items()): plist.append((port, len(pdata["bits"]), pdata["direction"])) return plist @@ -42,7 +42,7 @@ type: str """ clist = [] - for cell, cdata in self.data["cells"].items(): + for cell, cdata in sorted(self.data["cells"].items()): if cell.startswith("$"): continue clist.append((cell, cdata["type"])) @@ -111,7 +111,7 @@ """ cdata = self.data["cells"][cell] conns = [] - for port, condata in cdata["connections"].items(): + for port, condata in sorted(cdata["connections"].items()): if cdata["port_directions"][port] == direction: N = len(condata) if N == 1: @@ -129,7 +129,7 @@ port : str """ conn_io = [] - for port, pdata in self.data["ports"].items(): + for port, pdata in sorted(self.data["ports"].items()): if pdata["direction"] == iodir: if net in pdata["bits"]: if len(pdata["bits"]) == 1: @@ -147,11 +147,11 @@ port : str """ conn_ports = [] - for cell in self.data["cells"]: + for cell in sorted(self.data["cells"].keys()): if cell.startswith("$"): continue cdata = self.data["cells"][cell] - for port, condata in cdata["connections"].items(): + for port, condata in sorted(cdata["connections"].items()): if cdata["port_directions"][port] == pdir: if net in condata: if len(condata) == 1: