hdl.ast: add Value.implies.
authorwhitequark <cz@m-labs.hk>
Sat, 19 Jan 2019 08:56:44 +0000 (08:56 +0000)
committerwhitequark <cz@m-labs.hk>
Sat, 19 Jan 2019 08:56:44 +0000 (08:56 +0000)
nmigen/hdl/ast.py

index bd66d45fbba8bc663c4f20dd72989f3ed5df88dc..b330cb332a070f68c18f6113c9ae518d5e4d4e47 100644 (file)
@@ -134,6 +134,16 @@ class Value(metaclass=ABCMeta):
         """
         return Operator("b", [self])
 
+    def implies(premise, conclusion):
+        """Implication.
+
+        Returns
+        -------
+        Value, out
+            ``0`` if ``premise`` is true and ``conclusion`` is not, ``1`` otherwise.
+        """
+        return ~premise | conclusion
+
     def part(self, offset, width):
         """Indexed part-select.