Skip to content

Commit 5977bd6

Browse files
authored
Changed multiplication of SInt and UInt (#611)
Enables changing FIRRTL's IR to only accept multiplication of identical types.
1 parent 8baa2ab commit 5977bd6

File tree

1 file changed

+5
-2
lines changed
  • chiselFrontend/src/main/scala/chisel3/core

1 file changed

+5
-2
lines changed

chiselFrontend/src/main/scala/chisel3/core/Bits.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,11 @@ sealed class SInt private[core] (width: Width, lit: Option[SLit] = None)
594594
binop(sourceInfo, SInt(this.width), RemOp, that)
595595

596596
final def * (that: UInt): SInt = macro SourceInfoTransform.thatArg
597-
def do_* (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt =
598-
binop(sourceInfo, SInt(this.width + that.width), TimesOp, that)
597+
def do_* (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = {
598+
val thatToSInt = that.zext()
599+
val result = binop(sourceInfo, SInt(this.width + thatToSInt.width), TimesOp, thatToSInt)
600+
result.tail(1).asSInt
601+
}
599602

600603
/** add (width +1) operator */
601604
final def +& (that: SInt): SInt = macro SourceInfoTransform.thatArg

0 commit comments

Comments
 (0)