actorlib/spi/SingleGenerator: use CSR alignment bits
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Tue, 30 Apr 2013 16:54:47 +0000 (18:54 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Tue, 30 Apr 2013 16:54:47 +0000 (18:54 +0200)
migen/actorlib/spi.py

index bc5456d513b9c7917b30b2356a8828e7c639ff4e..d136f97c6f7dfb376cfbbcf36c71a531650a8d0f 100644 (file)
@@ -40,9 +40,10 @@ def _create_csrs_assign(layout, target, atomic, prefix=""):
                                alignment = element[3]
                        else:
                                alignment = 0
-                       reg = CSRStorage(nbits + alignment, reset=reset, atomic_write=atomic, name=prefix + name)
+                       reg = CSRStorage(nbits + alignment, reset=reset, atomic_write=atomic,
+                               alignment_bits=alignment, name=prefix + name)
                        csrs.append(reg)
-                       assigns.append(getattr(target, name).eq(reg.storage[alignment:]))
+                       assigns.append(getattr(target, name).eq(reg.storage))
        return csrs, assigns
 
 (MODE_EXTERNAL, MODE_SINGLE_SHOT, MODE_CONTINUOUS) = range(3)
@@ -51,10 +52,10 @@ class SingleGenerator(Module):
        def __init__(self, layout, mode):
                self.source = Source(_convert_layout(layout))
                self.busy = Signal()
-               self._csrs, assigns = _create_csrs_assign(layout, self.source.payload,
-                 mode != MODE_SINGLE_SHOT)
+               self._csrs, assigns = _create_csrs_assign(layout, self.source.payload, mode != MODE_SINGLE_SHOT)
                if mode == MODE_EXTERNAL:
-                       trigger = self.trigger = Signal()
+                       self.trigger = Signal()
+                       trigger = self.trigger
                elif mode == MODE_SINGLE_SHOT:
                        shoot = CSR()
                        self._csrs.insert(0, shoot)
@@ -67,7 +68,7 @@ class SingleGenerator(Module):
                        raise ValueError
                self.comb += self.busy.eq(self.source.stb)
                stmts = [self.source.stb.eq(trigger)] + assigns
-               self.sync += [If(self.source.ack | ~self.source.stb, *stmts)]
+               self.sync += If(self.source.ack | ~self.source.stb, *stmts)
        
        def get_csrs(self):
                return self._csrs