create dsl.Module._setAstTypeCastFn to decouple constructor of dsl.Module
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Oct 2021 13:26:35 +0000 (14:26 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Oct 2021 13:26:35 +0000 (14:26 +0100)
from setting the context for AST typecasting

nmigen/hdl/dsl.py

index 09fa92a08200bc65cf4484b3ccf11dfb73a1fdec..7db499f81c9fb23830c12d4104bc568ba70a9606 100644 (file)
@@ -181,7 +181,10 @@ class Module(_ModuleBuilderRoot, Elaboratable):
         # to complete the Type 1 (ast.*) nmigen language construct abstraction
         # from Type 2 (Module - this class) Module must be told what AST type
         # it may cast m.If/Elif conditions and m.Switch
-        self._astTypeCast  = _astTypeFn or Value.cast
+        sself._setATypeCastFn(_astTypeFn)
+
+    def _setAstTypeCastFn(self, typefn=None):
+        self._astTypeCast  = typefn or Value.cast
 
     def _check_context(self, construct, context):
         if self._ctrl_context != context: