Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add multi-slicing support on Signals

  • Loading branch information...
commit aa97cd1e924321a8bf97e6d3d98becf09816eab7 1 parent ef14a71
EnjoyDigital authored April 15, 2013

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

  1. 18  migen/fhdl/visit.py
18  migen/fhdl/visit.py
@@ -156,7 +156,23 @@ def visit_Operator(self, node):
156 156
 		return _Operator(node.op, [self.visit(o) for o in node.operands])
157 157
 	
158 158
 	def visit_Slice(self, node):
159  
-		return _Slice(self.visit(node.value), node.start, node.stop)
  159
+		# find consecutive Slices
  160
+		n = node
  161
+		cs = []
  162
+		while(isinstance(n, _Slice)):
  163
+			cs.append(n)
  164
+			n = n.value
  165
+		# reverse list order
  166
+		cs = cs[::-1]
  167
+		# find offset
  168
+		offset = 0
  169
+		for s in cs[:len(cs)-1]:
  170
+			offset += s.start
  171
+		next_node = cs[0].value	
  172
+		if isinstance(next_node, Signal):
  173
+			return _Slice(self.visit(next_node), offset + node.start, offset + node.stop)
  174
+		else:
  175
+			return _Slice(self.visit(node.value), node.start, node.stop)
160 176
 	
161 177
 	def visit_Cat(self, node):
162 178
 		return Cat(*[self.visit(e) for e in node.l])

0 notes on commit aa97cd1

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