Skip to content

Commit

Permalink
Changed multiplication of SInt and UInt (#611)
Browse files Browse the repository at this point in the history
Enables changing FIRRTL's IR to only accept multiplication of identical
types.
  • Loading branch information
azidar authored May 12, 2017
1 parent 8baa2ab commit 5977bd6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chiselFrontend/src/main/scala/chisel3/core/Bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,11 @@ sealed class SInt private[core] (width: Width, lit: Option[SLit] = None)
binop(sourceInfo, SInt(this.width), RemOp, that)

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

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

0 comments on commit 5977bd6

Please sign in to comment.