soc/interconnect/csr: add fields support for CSRStorage's write simulation method
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 2 Dec 2019 08:44:44 +0000 (09:44 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 2 Dec 2019 08:44:44 +0000 (09:44 +0100)
litex/soc/interconnect/csr.py

index a7defd0afbceab3b14bd73b2f42a580e68571de8..75a7c488672d7198880436d56977187a61b3f17d 100644 (file)
@@ -411,8 +411,15 @@ class CSRStorage(_CompoundCSR):
         """Write method for simulation."""
         yield self.storage.eq(value)
         yield self.re.eq(1)
+        if hasattr(self, "fields"):
+            for field in [*self.fields.fields]:
+                yield getattr(self.fields, field.name).eq((value >> field.offset) & (2**field.size -1))
         yield
         yield self.re.eq(0)
+        if hasattr(self, "fields"):
+            for field in [*self.fields.fields]:
+                if field.pulse:
+                    yield getattr(self.fields, field.name).eq(0)
 
 # AutoCSR & Helpers --------------------------------------------------------------------------------