actorlib/structuring/Cast: rawbits parameter
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 29 Jun 2012 14:10:50 +0000 (16:10 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 29 Jun 2012 14:10:50 +0000 (16:10 +0200)
migen/actorlib/structuring.py

index 15ced2d389b81008dc11793bb3fc00927ef270cb..9b798ee5e6a5fd035de48e342eed838e82464fe4 100644 (file)
@@ -1,11 +1,17 @@
 from migen.fhdl.structure import *
 from migen.flow.actor import *
 
+def _rawbits_layout(l):
+       if isinstance(l, int):
+               return [("rawbits", BV(l))]
+       else:
+               return l
+
 class Cast(CombinatorialActor):
        def __init__(self, layout_from, layout_to):
                super().__init__(
-                       ("sink", Sink, layout_from),
-                       ("source", Source, layout_to))
+                       ("sink", Sink, _rawbits_layout(layout_from)),
+                       ("source", Source, _rawbits_layout(layout_to)))
        
        def get_process_fragment(self):
                sigs_from = self.token("sink").flatten()
@@ -45,7 +51,7 @@ class Unpack(Actor):
                        )
                ]
                cases = [(Constant(i, BV(muxbits)) if i else Default(),
-                       Cat(*self.token("source").flatten()).eq(*self.token("sink").subrecord("chunk{0}".format(i)).flatten()))
+                       Cat(*self.token("source").flatten()).eq(Cat(*self.token("sink").subrecord("chunk{0}".format(i)).flatten())))
                        for i in range(self.n)]
                comb.append(Case(mux, *cases))
                return Fragment(comb, sync)