From: Sebastien Bourdeauducq Date: Thu, 8 Aug 2013 10:22:58 +0000 (+0200) Subject: fhdl/namer: detect leaf nodes better X-Git-Tag: 24jan2021_ls180~2099^2~477 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2c580fff03c31b0b823ae47a38cdda3019714129;p=litex.git fhdl/namer: detect leaf nodes better --- diff --git a/migen/fhdl/namer.py b/migen/fhdl/namer.py index ddb5f654..a97c7d3f 100644 --- a/migen/fhdl/namer.py +++ b/migen/fhdl/namer.py @@ -61,24 +61,25 @@ def _build_tree(signals, basic_tree=None): return root def _set_use_name(node, node_name=""): - if not node.children: + cnames = [(k, _set_use_name(v, k)) for k, v in node.children.items()] + for (c1_prefix, c1_names), (c2_prefix, c2_names) in combinations(cnames, 2): + if not c1_names.isdisjoint(c2_names): + node.children[c1_prefix].use_name = True + node.children[c2_prefix].use_name = True + r = set() + for c_prefix, c_names in cnames: + if node.children[c_prefix].use_name: + for c_name in c_names: + r.add((c_prefix, ) + c_name) + else: + r |= c_names + + if node.signal_count > sum(c.signal_count for c in node.children.values()): node.use_name = True - return {(node_name, )} - else: - cnames = [(k, _set_use_name(v, k)) for k, v in node.children.items()] - for (c1_prefix, c1_names), (c2_prefix, c2_names) in combinations(cnames, 2): - if not c1_names.isdisjoint(c2_names): - node.children[c1_prefix].use_name = True - node.children[c2_prefix].use_name = True - r = set() - for c_prefix, c_names in cnames: - if node.children[c_prefix].use_name: - for c_name in c_names: - r.add((c_prefix, ) + c_name) - else: - r |= c_names - return r + r.add((node_name, )) + return r + def _name_signal(tree, signal): elements = [] treepos = tree