From 6e46710678a9f36ee4f63daaa0bb751b95a6d8f8 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 14 Jul 2023 10:01:32 +0200 Subject: [PATCH] gen/fhdl/module: Fix CSR clock domain renaming to cores converted to LiteXModule, thanks @smunaut. --- CHANGES.md | 1 + litex/gen/fhdl/module.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a7d0d11eb..2953cf799 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ - cpu/vexriscv_smp : Fixed compilation with Gowin toolchain (ex for Tang Nano 20K Linux). - liteiclink/serwb : Fixed 7-Series initialization corner cases. - liteeth/core/icmp : Fixed length check on LiteEthICMPEcho before passing data to buffer. + - LiteXModule/CSR : Fixed CSR collection order causing CSR clock domain to be changed. [> Added -------- diff --git a/litex/gen/fhdl/module.py b/litex/gen/fhdl/module.py index a3fa016b1..fe756318e 100644 --- a/litex/gen/fhdl/module.py +++ b/litex/gen/fhdl/module.py @@ -8,7 +8,7 @@ from migen import * from migen.fhdl.module import _ModuleProxy from migen.fhdl.specials import Special -from litex.soc.interconnect.csr import AutoCSR +from litex.soc.interconnect.csr import _CSRBase, AutoCSR from litex.soc.integration.doc import AutoDoc # LiteX Module ------------------------------------------------------------------------------------- @@ -21,7 +21,8 @@ class LiteXModule(Module, AutoCSR, AutoDoc): raise AttributeError("Attempted to assign special Module property - use += instead") # LiteX fix-up: Automatically collect specials/submodules/clock_domains: # - m.module_x = .. equivalent of Migen's m.submodules.module_x = .. - elif isinstance(value, Module) and ((name, value) not in m._submodules): + # Note: Do an exception for CSRs that have a specific collection mechanism. + elif (isinstance(value, Module) and ((name, value) not in m._submodules) and (not isinstance(value, _CSRBase))): setattr(m.submodules, name, value) # - m.special_x = .. equivalent of Migen's m.specials.special_x = .. elif isinstance(value, Special) and (value not in m._fragment.specials):