We don't want to guarantee backwards compatibility for most of them.
--- /dev/null
+import contextlib
+import functools
+import warnings
+from collections import OrderedDict
+from collections.abc import Iterable
+from contextlib import contextmanager
+
+from .tools import *
+
+
+__all__ = ["flatten", "union" , "log2_int", "bits_for", "memoize", "final", "deprecated"]
+
+
+def flatten(i):
+    for e in i:
+        if isinstance(e, Iterable):
+            yield from flatten(e)
+        else:
+            yield e
+
+
+def union(i, start=None):
+    r = start
+    for e in i:
+        if r is None:
+            r = e
+        else:
+            r |= e
+    return r
+
+
+def memoize(f):
+    memo = OrderedDict()
+    @functools.wraps(f)
+    def g(*args):
+        if args not in memo:
+            memo[args] = f(*args)
+        return memo[args]
+    return g
+
+
+def final(cls):
+    def init_subclass():
+        raise TypeError("Subclassing {}.{} is not supported"
+                        .format(cls.__module__, cls.__name__))
+    cls.__init_subclass__ = init_subclass
+    return cls
+
+
+def deprecated(message, stacklevel=2):
+    def decorator(f):
+        @functools.wraps(f)
+        def wrapper(*args, **kwargs):
+            warnings.warn(message, DeprecationWarning, stacklevel=stacklevel)
+            return f(*args, **kwargs)
+        return wrapper
+    return decorator
+
+
+def _ignore_deprecated(f=None):
+    if f is None:
+        @contextlib.contextmanager
+        def context_like():
+            with warnings.catch_warnings():
+                warnings.filterwarnings(action="ignore", category=DeprecationWarning)
+                yield
+        return context_like()
+    else:
+        @functools.wraps(f)
+        def decorator_like(*args, **kwargs):
+            with warnings.catch_warnings():
+                warnings.filterwarnings(action="ignore", category=DeprecationWarning)
+                f(*args, **kwargs)
+        return decorator_like
+
+
+def extend(cls):
+    def decorator(f):
+        if isinstance(f, property):
+            name = f.fget.__name__
+        else:
+            name = f.__name__
+        setattr(cls, name, f)
+    return decorator
 
 from vcd import VCDWriter
 from vcd.gtkw import GTKWSave
 
-from ..tools import flatten
+from .._tools import flatten
 from ..hdl.ast import *
 from ..hdl.ir import *
 from ..hdl.xfrm import ValueVisitor, StatementVisitor
 
 from collections import defaultdict, OrderedDict
 from contextlib import contextmanager
 
-from ..tools import bits_for, flatten
+from .._tools import bits_for, flatten
 from ..hdl import ast, rec, ir, mem, xfrm
 
 
 
 from ... import tools
 from ...hdl import ast
-from ...tools import deprecated
+from ..._tools import deprecated
 
 
 __all__ = ["log2_int", "bits_for", "value_bits_sign"]
 
 from collections.abc import Iterable
 
-from ...tools import flatten, deprecated
+from ..._tools import flatten, deprecated
 from ...hdl import dsl, ir
 
 
 class CompatModule(ir.Elaboratable):
     _Elaboratable__silence = True
 
-    # Actually returns nmigen.fhdl.Module, not a Fragment.
+    # Actually returns another nMigen Elaboratable (nmigen.dsl.Module), not a Fragment.
     def get_fragment(self):
         assert not self.get_fragment_called
         self.get_fragment_called = True
 
 import warnings
 
-from ...tools import deprecated, extend
+from ..._tools import deprecated, extend
 from ...hdl.ast import *
 from ...hdl.ir import Elaboratable
 from ...hdl.mem import Memory as NativeMemory
 
 from collections import OrderedDict
 
-from ...tools import deprecated, extend
+from ..._tools import deprecated, extend
 from ...hdl import ast
 from ...hdl.ast import (DUID, Value, Signal, Mux, Slice as _Slice, Cat, Repl, Const, C,
                         ClockSignal, ResetSignal,
 
 import warnings
 
-from ...tools import deprecated
+from ..._tools import deprecated
 from ...lib.cdc import FFSynchronizer as NativeFFSynchronizer
 from ...hdl.ast import *
 from ..fhdl.module import CompatModule
 
-from ...tools import deprecated, extend
+from ..._tools import deprecated, extend
 from ...lib.fifo import (FIFOInterface as NativeFIFOInterface,
   SyncFIFO as NativeSyncFIFO, SyncFIFOBuffered as NativeSyncFIFOBuffered,
   AsyncFIFO as NativeAsyncFIFO, AsyncFIFOBuffered as NativeAsyncFIFOBuffered)
 
 from collections import OrderedDict
 
-from ...tools import _ignore_deprecated
+from ..._tools import _ignore_deprecated
 from ...hdl.xfrm import ValueTransformer, StatementTransformer
 from ...hdl.ast import *
 from ..fhdl.module import CompatModule, CompatFinalizeError
 
-from ...tools import deprecated
+from ..._tools import deprecated
 from ...lib.cdc import ResetSynchronizer as NativeResetSynchronizer
 
 
 
 from enum import Enum
 
 from .. import tracer
-from ..tools import *
+from .._tools import *
 
 
 __all__ = [
 
 from enum import Enum
 import warnings
 
-from ..tools import flatten, bits_for, deprecated
+from .._tools import flatten, bits_for, deprecated
 from .. import tracer
 from .ast import *
 from .ir import *
 
 import traceback
 import sys
 
-from ..tools import *
+from .._tools import *
 from .ast import *
 from .cd import *
 
 
 from functools import reduce
 
 from .. import tracer
-from ..tools import union, deprecated
+from .._tools import union, deprecated
 from .ast import *
 
 
 
 from collections import OrderedDict
 from collections.abc import Iterable
 
-from ..tools import flatten, deprecated
+from .._tools import flatten, deprecated
 from .. import tracer
 from .ast import *
 from .ast import _StatementList
 
-from ..tools import deprecated
+from .._tools import deprecated
 from .. import *
 
 
 
 
 from .. import *
 from ..asserts import *
-from ..tools import log2_int, deprecated
+from .._tools import log2_int, deprecated
 from .coding import GrayEncoder
 from .cdc import FFSynchronizer
 
 
-from ...tools import _ignore_deprecated
+from ..._tools import _ignore_deprecated
 from ...compat import *
 from ...compat.fhdl import verilog
 
 
 import unittest
 
-from ...tools import _ignore_deprecated
+from ..._tools import _ignore_deprecated
 from ...compat import *
 
 
 
 from contextlib import contextmanager
 
 from .tools import *
-from ..tools import flatten, union
+from .._tools import flatten, union
 from ..hdl.ast import *
 from ..hdl.cd import  *
 from ..hdl.mem import *
 
-import contextlib
-import functools
-import warnings
-from collections import OrderedDict
-from collections.abc import Iterable
-from contextlib import contextmanager
-
-
-__all__ = ["flatten", "union", "log2_int", "bits_for", "memoize", "final", "deprecated"]
-
-
-def flatten(i):
-    for e in i:
-        if isinstance(e, Iterable):
-            yield from flatten(e)
-        else:
-            yield e
-
-
-def union(i, start=None):
-    r = start
-    for e in i:
-        if r is None:
-            r = e
-        else:
-            r |= e
-    return r
+__all__ = ["log2_int", "bits_for"]
 
 
 def log2_int(n, need_pow2=True):
     if require_sign_bit:
         r += 1
     return r
-
-
-def memoize(f):
-    memo = OrderedDict()
-    @functools.wraps(f)
-    def g(*args):
-        if args not in memo:
-            memo[args] = f(*args)
-        return memo[args]
-    return g
-
-
-def final(cls):
-    def init_subclass():
-        raise TypeError("Subclassing {}.{} is not supported"
-                        .format(cls.__module__, cls.__name__))
-    cls.__init_subclass__ = init_subclass
-    return cls
-
-
-def deprecated(message, stacklevel=2):
-    def decorator(f):
-        @functools.wraps(f)
-        def wrapper(*args, **kwargs):
-            warnings.warn(message, DeprecationWarning, stacklevel=stacklevel)
-            return f(*args, **kwargs)
-        return wrapper
-    return decorator
-
-
-def _ignore_deprecated(f=None):
-    if f is None:
-        @contextlib.contextmanager
-        def context_like():
-            with warnings.catch_warnings():
-                warnings.filterwarnings(action="ignore", category=DeprecationWarning)
-                yield
-        return context_like()
-    else:
-        @functools.wraps(f)
-        def decorator_like(*args, **kwargs):
-            with warnings.catch_warnings():
-                warnings.filterwarnings(action="ignore", category=DeprecationWarning)
-                f(*args, **kwargs)
-        return decorator_like
-
-
-def extend(cls):
-    def decorator(f):
-        if isinstance(f, property):
-            name = f.fget.__name__
-        else:
-            name = f.__name__
-        setattr(cls, name, f)
-    return decorator