Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fhdl/namer: detect leaf nodes better

  • Loading branch information...
commit 2c580fff03c31b0b823ae47a38cdda3019714129 1 parent eb1417c
Sébastien Bourdeauducq authored August 08, 2013

Showing 1 changed file with 17 additions and 16 deletions. Show diff stats Hide diff stats

  1. 33  migen/fhdl/namer.py
33  migen/fhdl/namer.py
@@ -61,24 +61,25 @@ def _build_tree(signals, basic_tree=None):
61 61
 	return root
62 62
 
63 63
 def _set_use_name(node, node_name=""):
64  
-	if not node.children:
  64
+	cnames = [(k, _set_use_name(v, k)) for k, v in node.children.items()]
  65
+	for (c1_prefix, c1_names), (c2_prefix, c2_names) in combinations(cnames, 2):
  66
+		if not c1_names.isdisjoint(c2_names):
  67
+			node.children[c1_prefix].use_name = True
  68
+			node.children[c2_prefix].use_name = True
  69
+	r = set()
  70
+	for c_prefix, c_names in cnames:
  71
+		if node.children[c_prefix].use_name:
  72
+			for c_name in c_names:
  73
+				r.add((c_prefix, ) + c_name)
  74
+		else:
  75
+			r |= c_names
  76
+	
  77
+	if node.signal_count > sum(c.signal_count for c in node.children.values()):
65 78
 		node.use_name = True
66  
-		return {(node_name, )}
67  
-	else:
68  
-		cnames = [(k, _set_use_name(v, k)) for k, v in node.children.items()]
69  
-		for (c1_prefix, c1_names), (c2_prefix, c2_names) in combinations(cnames, 2):
70  
-			if not c1_names.isdisjoint(c2_names):
71  
-				node.children[c1_prefix].use_name = True
72  
-				node.children[c2_prefix].use_name = True
73  
-		r = set()
74  
-		for c_prefix, c_names in cnames:
75  
-			if node.children[c_prefix].use_name:
76  
-				for c_name in c_names:
77  
-					r.add((c_prefix, ) + c_name)
78  
-			else:
79  
-				r |= c_names
80  
-		return r
  79
+		r.add((node_name, ))
81 80
 
  81
+	return r
  82
+		
82 83
 def _name_signal(tree, signal):
83 84
 	elements = []
84 85
 	treepos = tree

0 notes on commit 2c580ff

Please sign in to comment.
Something went wrong with that request. Please try again.