Permalink
Browse files

actorlib/structuring/Cast: support inversion

  • Loading branch information...
1 parent c4c4765 commit 77a0f0a3bb4b971bb30643935c295940680b72c1 @sbourdeauducq sbourdeauducq committed Mar 25, 2013
Showing with 7 additions and 1 deletion.
  1. +7 −1 migen/actorlib/structuring.py
View
8 migen/actorlib/structuring.py
@@ -8,14 +8,20 @@ def _rawbits_layout(l):
return l
class Cast(CombinatorialActor):
- def __init__(self, layout_from, layout_to):
+ def __init__(self, layout_from, layout_to, reverse_from=False, reverse_to=False):
+ self.reverse_from = reverse_from
+ self.reverse_to = reverse_to
CombinatorialActor.__init__(self,
("sink", Sink, _rawbits_layout(layout_from)),
("source", Source, _rawbits_layout(layout_to)))
def get_process_fragment(self):
sigs_from = self.token("sink").flatten()
+ if self.reverse_from:
+ sigs_from = list(reversed(sigs_from))
sigs_to = self.token("source").flatten()
+ if self.reverse_to:
+ sigs_to = list(reversed(sigs_to))
if sum(len(s) for s in sigs_from) != sum(len(s) for s in sigs_to):
raise TypeError
return Fragment([

0 comments on commit 77a0f0a

Please sign in to comment.