From 5977bd68f9378d9875a2f494195375c1dae442e5 Mon Sep 17 00:00:00 2001 From: Adam Izraelevitz Date: Fri, 12 May 2017 14:09:14 -0700 Subject: Changed multiplication of SInt and UInt (#611) Enables changing FIRRTL's IR to only accept multiplication of identical types.--- chiselFrontend/src/main/scala/chisel3/core/Bits.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'chiselFrontend/src') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala index e8423a99..7de7be09 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala @@ -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 -- cgit v1.2.3