Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 comments
  • 2 contributors
Jul 17, 2013
David Carne fhdl/tools: BUGFIX: fix group_by_target grouping
group_by_target does not properly combine target groups if statements
are presented in the order:

 ({A}, statement1)
 ({B}, statement2)
 ({A, B}, statement3)

which returns groups:

 ({A, B}, [statement1, statement3])
 ({B}, [statement2])

This patch fixes group_by_target such that the resulting group is:

 ({A, B}, [statement1, statement2, statement3])
16ebe41
Sébastien Bourdeauducq fhdl/tools/group_by_target: remove resort_statements 939f01c

Showing 1 changed file with 13 additions and 9 deletions. Show diff stats Hide diff stats

  1. 22  migen/fhdl/tools.py
22  migen/fhdl/tools.py
@@ -52,15 +52,19 @@ def group_by_targets(sl):
52 52
 	groups = []
53 53
 	for statement in flat_iteration(sl):
54 54
 		targets = list_targets(statement)
55  
-		processed = False
56  
-		for g in groups:
57  
-			if not targets.isdisjoint(g[0]):
58  
-				g[0].update(targets)
59  
-				g[1].append(statement)
60  
-				processed = True
61  
-				break
62  
-		if not processed:
63  
-			groups.append((targets, [statement]))
  55
+
  56
+		chk_groups = [(targets.isdisjoint(g[0]), g) for g in groups]
  57
+		merge_groups = [g for dj, g in chk_groups if not dj]
  58
+		groups = [g for dj, g in chk_groups if dj]
  59
+
  60
+		new_group = (set(targets), [])
  61
+		for g in merge_groups:
  62
+			new_group[0].update(g[0])
  63
+			new_group[1].extend(g[1])
  64
+		new_group[1].append(statement)
  65
+
  66
+		groups.append(new_group)
  67
+
64 68
 	return groups
65 69
 
66 70
 def list_special_ios(f, ins, outs, inouts):

No commit comments for this range

Something went wrong with that request. Please try again.