hdl: add missing compatibility shims.

These were originally planned to be committed as a part of 5dd1223c,
but were lost during rebasing.
This commit is contained in:
Catherine 2024-01-31 01:59:20 +00:00
parent 1506f08b81
commit 572a60d838
6 changed files with 148 additions and 0 deletions

32
amaranth/hdl/ast.py Normal file
View file

@ -0,0 +1,32 @@
# TODO(amaranth-0.6): remove module
from .. import hdl as __hdl
from . import _ast as __origin
__all__ = [
"Shape", "signed", "unsigned", "ShapeCastable", "ShapeLike",
"Value", "Const", "C", "AnyConst", "AnySeq", "Operator", "Mux", "Part", "Slice", "Cat", "Repl",
"Array", "ArrayProxy",
"Signal", "ClockSignal", "ResetSignal",
"ValueCastable", "ValueLike",
"Initial",
"Statement", "Switch",
"Property", "Assign", "Assert", "Assume", "Cover",
"ValueKey", "ValueDict", "ValueSet", "SignalKey", "SignalDict", "SignalSet",
]
def __getattr__(name):
import warnings
if name in __hdl.__dict__:
if not (name.startswith("__") and name.endswith("__")):
warnings.warn(f"instead of `{__name__}.{name}`, use `{__hdl.__name__}.{name}`",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
elif name in __origin.__dict__:
warnings.warn(f"name `{__name__}.{name}` is a private implementation detail and "
f"should not be imported",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

22
amaranth/hdl/cd.py Normal file
View file

@ -0,0 +1,22 @@
# TODO(amaranth-0.6): remove module
from .. import hdl as __hdl
from . import _cd as __origin
__all__ = ["ClockDomain", "DomainError"]
def __getattr__(name):
import warnings
if name in __hdl.__dict__:
if not (name.startswith("__") and name.endswith("__")):
warnings.warn(f"instead of `{__name__}.{name}`, use `{__hdl.__name__}.{name}`",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
elif name in __origin.__dict__:
warnings.warn(f"name `{__name__}.{name}` is a private implementation detail and "
f"should not be imported",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

22
amaranth/hdl/dsl.py Normal file
View file

@ -0,0 +1,22 @@
# TODO(amaranth-0.6): remove module
from .. import hdl as __hdl
from . import _dsl as __origin
__all__ = ["SyntaxError", "SyntaxWarning", "Module"]
def __getattr__(name):
import warnings
if name in __hdl.__dict__:
if not (name.startswith("__") and name.endswith("__")):
warnings.warn(f"instead of `{__name__}.{name}`, use `{__hdl.__name__}.{name}`",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
elif name in __origin.__dict__:
warnings.warn(f"name `{__name__}.{name}` is a private implementation detail and "
f"should not be imported",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

22
amaranth/hdl/ir.py Normal file
View file

@ -0,0 +1,22 @@
# TODO(amaranth-0.6): remove module
from .. import hdl as __hdl
from . import _ir as __origin
__all__ = ["UnusedElaboratable", "Elaboratable", "DriverConflict", "Fragment", "Instance"]
def __getattr__(name):
import warnings
if name in __hdl.__dict__:
if not (name.startswith("__") and name.endswith("__")):
warnings.warn(f"instead of `{__name__}.{name}`, use `{__hdl.__name__}.{name}`",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
elif name in __origin.__dict__:
warnings.warn(f"name `{__name__}.{name}` is a private implementation detail and "
f"should not be imported",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

22
amaranth/hdl/mem.py Normal file
View file

@ -0,0 +1,22 @@
# TODO(amaranth-0.6): remove module
from .. import hdl as __hdl
from . import _mem as __origin
__all__ = ["Memory", "ReadPort", "WritePort", "DummyPort"]
def __getattr__(name):
import warnings
if name in __hdl.__dict__:
if not (name.startswith("__") and name.endswith("__")):
warnings.warn(f"instead of `{__name__}.{name}`, use `{__hdl.__name__}.{name}`",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
elif name in __origin.__dict__:
warnings.warn(f"name `{__name__}.{name}` is a private implementation detail and "
f"should not be imported",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

28
amaranth/hdl/xfrm.py Normal file
View file

@ -0,0 +1,28 @@
# TODO(amaranth-0.6): remove module
from .. import hdl as __hdl
from . import _xfrm as __origin
__all__ = ["ValueVisitor", "ValueTransformer",
"StatementVisitor", "StatementTransformer",
"FragmentTransformer",
"TransformedElaboratable",
"DomainCollector", "DomainRenamer", "DomainLowerer",
"SwitchCleaner", "LHSGroupAnalyzer", "LHSGroupFilter",
"ResetInserter", "EnableInserter"]
def __getattr__(name):
import warnings
if name in __hdl.__dict__:
if not (name.startswith("__") and name.endswith("__")):
warnings.warn(f"instead of `{__name__}.{name}`, use `{__hdl.__name__}.{name}`",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
elif name in __origin.__dict__:
warnings.warn(f"name `{__name__}.{name}` is a private implementation detail and "
f"should not be imported",
DeprecationWarning, stacklevel=2)
return getattr(__origin, name)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")