From 6de20f185a280de852a76134a6ae5c0a81adec2a Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 2 Dec 2019 09:44:44 +0100 Subject: [PATCH] soc/interconnect/csr: add fields support for CSRStorage's write simulation method --- litex/soc/interconnect/csr.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/litex/soc/interconnect/csr.py b/litex/soc/interconnect/csr.py index a7defd0af..75a7c4886 100644 --- a/litex/soc/interconnect/csr.py +++ b/litex/soc/interconnect/csr.py @@ -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 --------------------------------------------------------------------------------