From a7a7d3209948b0f48f9ff275140850cdae408983 Mon Sep 17 00:00:00 2001 From: Wanda Date: Tue, 16 Apr 2024 13:45:05 +0200 Subject: [PATCH] hdl._ast: deprecate `Value.implies`. --- amaranth/hdl/_ast.py | 3 ++- docs/guide.rst | 2 -- tests/test_hdl_rec.py | 6 ++++-- tests/test_lib_fifo.py | 9 ++++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/amaranth/hdl/_ast.py b/amaranth/hdl/_ast.py index 819a0f7..8eea927 100644 --- a/amaranth/hdl/_ast.py +++ b/amaranth/hdl/_ast.py @@ -994,8 +994,9 @@ class Value(metaclass=ABCMeta): """ return Operator("r^", [self]) + # TODO(amaranth-0.6): remove + @deprecated("`a.implies(b)` is deprecated, use `~a | b` instead") def implies(self, conclusion): - # TODO: should we document or just deprecate this? return ~self | conclusion def __check_shamt(self): diff --git a/docs/guide.rst b/docs/guide.rst index d62a5c0..0474f48 100644 --- a/docs/guide.rst +++ b/docs/guide.rst @@ -566,7 +566,6 @@ Operation Description Notes ``a & b`` bitwise AND ``a | b`` bitwise OR ``a ^ b`` bitwise XOR -``a.implies(b)`` bitwise IMPLY_ ``a >> b`` arithmetic right shift by variable amount [#opB1]_, [#opB2]_ ``a << b`` left shift by variable amount [#opB2]_ ``a.rotate_left(i)`` left rotate by constant amount [#opB3]_ @@ -575,7 +574,6 @@ Operation Description Notes ``a.shift_right(i)`` right shift by constant amount [#opB3]_ ===================== ========================================== ====== -.. _IMPLY: https://en.wikipedia.org/wiki/IMPLY_gate .. [#opB1] Logical and arithmetic right shift of an unsigned value are equivalent. Logical right shift of a signed value can be expressed by :ref:`converting it to unsigned ` first. .. [#opB2] Shift amount must be unsigned; integer shifts in Python require the amount to be positive. .. [#opB3] Shift and rotate amounts can be negative, in which case the direction is reversed. diff --git a/tests/test_hdl_rec.py b/tests/test_hdl_rec.py index 4f26c4c..0f77194 100644 --- a/tests/test_hdl_rec.py +++ b/tests/test_hdl_rec.py @@ -6,6 +6,7 @@ from amaranth.hdl._ast import * with warnings.catch_warnings(): warnings.filterwarnings(action="ignore", category=DeprecationWarning) from amaranth.hdl.rec import * +from amaranth._utils import _ignore_deprecated from .utils import * @@ -299,8 +300,9 @@ class RecordTestCase(FHDLTestCase): self.assertEqual(repr(r1.any()), "(r| (cat (sig r1__a)))") self.assertEqual(repr(r1.all()), "(r& (cat (sig r1__a)))") self.assertEqual(repr(r1.xor()), "(r^ (cat (sig r1__a)))") - self.assertEqual(repr(r1.implies(1)), "(| (~ (cat (sig r1__a))) (const 1'd1))") - self.assertEqual(repr(r1.implies(s1)), "(| (~ (cat (sig r1__a))) (sig s1))") + with _ignore_deprecated(): + self.assertEqual(repr(r1.implies(1)), "(| (~ (cat (sig r1__a))) (const 1'd1))") + self.assertEqual(repr(r1.implies(s1)), "(| (~ (cat (sig r1__a))) (sig s1))") # bit_select, word_select, matches, self.assertEqual(repr(r1.bit_select(0, 1)), "(slice (cat (sig r1__a)) 0:1)") diff --git a/tests/test_lib_fifo.py b/tests/test_lib_fifo.py index 6257c92..d813674 100644 --- a/tests/test_lib_fifo.py +++ b/tests/test_lib_fifo.py @@ -156,12 +156,15 @@ class FIFOModelEquivalenceSpec(Elaboratable): gold.w_data.eq(dut.w_data), ] - m.d.comb += Assert(dut.r_rdy.implies(gold.r_rdy)) - m.d.comb += Assert(dut.w_rdy.implies(gold.w_rdy)) + with m.If(dut.r_rdy): + m.d.comb += Assert(gold.r_rdy) + with m.If(dut.w_rdy): + m.d.comb += Assert(gold.w_rdy) m.d.comb += Assert(dut.r_level == gold.r_level) m.d.comb += Assert(dut.w_level == gold.w_level) - m.d.comb += Assert(dut.r_rdy.implies(dut.r_data == gold.r_data)) + with m.If(dut.r_rdy): + m.d.comb += Assert(dut.r_data == gold.r_data) return m