bank: add re to CSRStorage
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 10 Oct 2014 18:45:18 +0000 (20:45 +0200)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Thu, 16 Oct 2014 09:43:41 +0000 (17:43 +0800)
being able to know when a register is updated is useful in many cases and avoid having to handle another register for that.
re is asserted when the the last CSR of the Compound is written. Software must also write Compound in the right order.

migen/bank/description.py

index 7bb3b95a929f0f43998578481b0fcec7f071551d..fd506fe2172d72f44cea57b46b22b12f6f2a75cd 100644 (file)
@@ -53,6 +53,7 @@ class CSRStorage(_CompoundCSR):
                self.storage = Signal(self.size - self.alignment_bits, reset=reset >> alignment_bits)
                self.comb += self.storage.eq(self.storage_full[self.alignment_bits:])
                self.atomic_write = atomic_write
+               self.re = Signal()
                if write_from_dev:
                        self.we = Signal()
                        self.dat_w = Signal(self.size - self.alignment_bits)
@@ -84,6 +85,7 @@ class CSRStorage(_CompoundCSR):
                                        self.sync += If(sc.re, self.storage_full.eq(Cat(sc.r, backstore)))
                        else:
                                self.sync += If(sc.re, self.storage_full[lo:hi].eq(sc.r))
+               self.sync += self.re.eq(sc.re)
 
 def csrprefix(prefix, csrs, done):
        for csr in csrs: