From 572a60d8389e5aef72886ea4bc4d5b62d450cdff Mon Sep 17 00:00:00 2001 From: Catherine Date: Wed, 31 Jan 2024 01:59:20 +0000 Subject: [PATCH] hdl: add missing compatibility shims. These were originally planned to be committed as a part of 5dd1223c, but were lost during rebasing. --- amaranth/hdl/ast.py | 32 ++++++++++++++++++++++++++++++++ amaranth/hdl/cd.py | 22 ++++++++++++++++++++++ amaranth/hdl/dsl.py | 22 ++++++++++++++++++++++ amaranth/hdl/ir.py | 22 ++++++++++++++++++++++ amaranth/hdl/mem.py | 22 ++++++++++++++++++++++ amaranth/hdl/xfrm.py | 28 ++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+) create mode 100644 amaranth/hdl/ast.py create mode 100644 amaranth/hdl/cd.py create mode 100644 amaranth/hdl/dsl.py create mode 100644 amaranth/hdl/ir.py create mode 100644 amaranth/hdl/mem.py create mode 100644 amaranth/hdl/xfrm.py diff --git a/amaranth/hdl/ast.py b/amaranth/hdl/ast.py new file mode 100644 index 0000000..41e6a8b --- /dev/null +++ b/amaranth/hdl/ast.py @@ -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}") diff --git a/amaranth/hdl/cd.py b/amaranth/hdl/cd.py new file mode 100644 index 0000000..854a8d2 --- /dev/null +++ b/amaranth/hdl/cd.py @@ -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}") diff --git a/amaranth/hdl/dsl.py b/amaranth/hdl/dsl.py new file mode 100644 index 0000000..fce61e4 --- /dev/null +++ b/amaranth/hdl/dsl.py @@ -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}") diff --git a/amaranth/hdl/ir.py b/amaranth/hdl/ir.py new file mode 100644 index 0000000..db44e53 --- /dev/null +++ b/amaranth/hdl/ir.py @@ -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}") diff --git a/amaranth/hdl/mem.py b/amaranth/hdl/mem.py new file mode 100644 index 0000000..b3db4b0 --- /dev/null +++ b/amaranth/hdl/mem.py @@ -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}") diff --git a/amaranth/hdl/xfrm.py b/amaranth/hdl/xfrm.py new file mode 100644 index 0000000..2b96db6 --- /dev/null +++ b/amaranth/hdl/xfrm.py @@ -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}")