diff --git a/core/src/main/scala-2/chisel3/BitsIntf.scala b/core/src/main/scala-2/chisel3/BitsIntf.scala index bc7904c661a..24feae30103 100644 --- a/core/src/main/scala-2/chisel3/BitsIntf.scala +++ b/core/src/main/scala-2/chisel3/BitsIntf.scala @@ -900,5 +900,5 @@ private[chisel3] trait BoolIntf extends ToBoolable { self: Bool => def implies(that: Bool): Bool = macro SourceInfoTransform.thatArg /** @group SourceInfoTransformMacro */ - def do_implies(that: Bool)(implicit sourceInfo: SourceInfo): Bool = (!this) | that + def do_implies(that: Bool)(implicit sourceInfo: SourceInfo): Bool = _impl_implies(that) } diff --git a/core/src/main/scala-3/chisel3/BitsIntf.scala b/core/src/main/scala-3/chisel3/BitsIntf.scala index 4f911871555..9599151fe5d 100644 --- a/core/src/main/scala-3/chisel3/BitsIntf.scala +++ b/core/src/main/scala-3/chisel3/BitsIntf.scala @@ -597,4 +597,11 @@ private[chisel3] trait BoolIntf extends ToBoolable { self: Bool => def asClock(using SourceInfo): Clock = _asClockImpl def asAsyncReset(using SourceInfo): AsyncReset = _asAsyncResetImpl + + /** Logical implication + * + * @param that a boolean signal + * @return [[!this || that]] + */ + def implies(that: Bool)(using SourceInfo): Bool = _impl_implies(that) } diff --git a/core/src/main/scala/chisel3/Bits.scala b/core/src/main/scala/chisel3/Bits.scala index 9e8cf05d8e3..69dbf505633 100644 --- a/core/src/main/scala/chisel3/Bits.scala +++ b/core/src/main/scala/chisel3/Bits.scala @@ -691,6 +691,8 @@ sealed class Bool() extends UInt(1.W) with BoolIntf with Reset { protected def _asAsyncResetImpl(implicit sourceInfo: SourceInfo): AsyncReset = pushOp(DefPrim(sourceInfo, AsyncReset(), AsAsyncResetOp, ref)) + protected def _impl_implies(that: Bool)(implicit sourceInfo: SourceInfo): Bool = (!this) | that + override protected def _fromUInt(that: UInt)(implicit sourceInfo: SourceInfo): this.type = { _resizeToWidth(that, this.widthOption, true)(identity).asBool.asInstanceOf[this.type] }