From c70c71502e489c4bf453b49539b54b2ac0aec197 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 30 Apr 2013 18:54:47 +0200 Subject: [PATCH] actorlib/spi/SingleGenerator: use CSR alignment bits --- migen/actorlib/spi.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/migen/actorlib/spi.py b/migen/actorlib/spi.py index bc5456d5..d136f97c 100644 --- a/migen/actorlib/spi.py +++ b/migen/actorlib/spi.py @@ -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 -- 2.30.2