compat: suppress deprecation warnings that are internal or during test.
This commit is contained in:
parent
7890c0adc8
commit
4bf80a6e33
|
@ -1,6 +1,6 @@
|
||||||
import warnings
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
from ...tools import _ignore_deprecated
|
||||||
from ...hdl.xfrm import ValueTransformer, StatementTransformer
|
from ...hdl.xfrm import ValueTransformer, StatementTransformer
|
||||||
from ...hdl.ast import *
|
from ...hdl.ast import *
|
||||||
from ..fhdl.module import CompatModule, CompatFinalizeError
|
from ..fhdl.module import CompatModule, CompatFinalizeError
|
||||||
|
@ -153,6 +153,7 @@ class FSM(CompatModule):
|
||||||
self.sync += signal.eq(self.before_leaving(state))
|
self.sync += signal.eq(self.before_leaving(state))
|
||||||
return signal
|
return signal
|
||||||
|
|
||||||
|
@_ignore_deprecated
|
||||||
def do_finalize(self):
|
def do_finalize(self):
|
||||||
nstates = len(self.actions)
|
nstates = len(self.actions)
|
||||||
self.encoding = dict((s, n) for n, s in enumerate(self.actions.keys()))
|
self.encoding = dict((s, n) for n, s in enumerate(self.actions.keys()))
|
||||||
|
@ -178,11 +179,10 @@ class FSM(CompatModule):
|
||||||
|
|
||||||
def _finalize_sync(self, ls):
|
def _finalize_sync(self, ls):
|
||||||
cases = dict((self.encoding[k], ls.on_statement(v)) for k, v in self.actions.items() if v)
|
cases = dict((self.encoding[k], ls.on_statement(v)) for k, v in self.actions.items() if v)
|
||||||
with warnings.catch_warnings():
|
self.comb += [
|
||||||
self.comb += [
|
self.next_state.eq(self.state),
|
||||||
self.next_state.eq(self.state),
|
Case(self.state, cases).makedefault(self.encoding[self.reset_state])
|
||||||
Case(self.state, cases).makedefault(self.encoding[self.reset_state])
|
]
|
||||||
]
|
self.sync += self.state.eq(self.next_state)
|
||||||
self.sync += self.state.eq(self.next_state)
|
for register, next_value_ce, next_value in ls.registers:
|
||||||
for register, next_value_ce, next_value in ls.registers:
|
self.sync += If(next_value_ce, register.eq(next_value))
|
||||||
self.sync += If(next_value_ce, register.eq(next_value))
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
from ...tools import _ignore_deprecated
|
||||||
from ...compat import *
|
from ...compat import *
|
||||||
from ...compat.fhdl import verilog
|
from ...compat.fhdl import verilog
|
||||||
|
|
||||||
|
|
||||||
class SimCase:
|
class SimCase:
|
||||||
def setUp(self, *args, **kwargs):
|
def setUp(self, *args, **kwargs):
|
||||||
self.tb = self.TestBench(*args, **kwargs)
|
with _ignore_deprecated():
|
||||||
|
self.tb = self.TestBench(*args, **kwargs)
|
||||||
|
|
||||||
def test_to_verilog(self):
|
def test_to_verilog(self):
|
||||||
verilog.convert(self.tb)
|
verilog.convert(self.tb)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from collections.abc import Iterable
|
import contextlib
|
||||||
import functools
|
import functools
|
||||||
import warnings
|
import warnings
|
||||||
|
from collections.abc import Iterable
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["flatten", "union", "log2_int", "bits_for", "deprecated"]
|
__all__ = ["flatten", "union", "log2_int", "bits_for", "deprecated"]
|
||||||
|
@ -54,6 +56,23 @@ def deprecated(message, stacklevel=2):
|
||||||
return decorator
|
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 extend(cls):
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
if isinstance(f, property):
|
if isinstance(f, property):
|
||||||
|
|
Loading…
Reference in a new issue