diff options
| author | Richard Lin | 2017-04-26 17:52:29 -0700 |
|---|---|---|
| committer | GitHub | 2017-04-26 17:52:29 -0700 |
| commit | 36718cf6040990f2be9ab143adb1d3c519e9d983 (patch) | |
| tree | 34ae121faf999bb962f5257c26de651bd08ecf04 /chiselFrontend | |
| parent | 7449fdc9043708e426aeb8b12b30226db9e47a80 (diff) | |
Deprecate fromBits and clock/reset constructors (#583)
Diffstat (limited to 'chiselFrontend')
3 files changed, 18 insertions, 21 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala index e945cfbe..580dabe0 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala @@ -283,22 +283,6 @@ abstract class Data extends HasId { /** Returns Some(width) if the width is known, else None. */ final def widthOption: Option[Int] = if (isWidthKnown) Some(getWidth) else None - /** Creates an new instance of this type, unpacking the input Bits into - * structured data. - * - * This performs the inverse operation of toBits. - * - * @note does NOT assign to the object this is called on, instead creates - * and returns a NEW object (useful in a clone-and-assign scenario) - * @note does NOT check bit widths, may drop bits during assignment - * @note what fromBits assigs to must have known widths - */ - def fromBits(that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): this.type = { - val output = Wire(chiselCloneType).asInstanceOf[this.type] - output.connectFromBits(that) - output - } - /** Packs the value of this object as plain Bits. * * This performs the inverse operation of fromBits(Bits). diff --git a/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala b/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala index 49e96ddf..69f54102 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala @@ -70,7 +70,7 @@ private[chisel3] object SeqUtils { def buildAndOrMultiplexor[TT <: Data](inputs: Iterable[(Bool, TT)]): T = { val masked = for ((s, i) <- inputs) yield Mux(s, i.asUInt(), 0.U) - output.fromBits(masked.reduceLeft(_ | _)) + masked.reduceLeft(_ | _).asTypeOf(output) } output match { @@ -82,7 +82,7 @@ private[chisel3] object SeqUtils { } val masked = for ((s, i) <- sInts) yield Mux(s, i, 0.S) - output.fromBits(masked.reduceLeft(_ | _)) + masked.reduceLeft(_ | _).asTypeOf(output) case _: FixedPoint => val (sels, possibleOuts) = in.toSeq.unzip diff --git a/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala b/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala index 916ab119..666be4d0 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala @@ -117,14 +117,27 @@ abstract class ImplicitModule(implicit moduleCompileOptions: CompileOptions) * IO), the clock and reset constructors will be phased out. Recommendation is to wrap the module * in a withClock/withReset/withClockAndReset block, or directly hook up clock or reset IO pins. */ -abstract class LegacyModule( - override_clock: Option[Clock]=None, override_reset: Option[Bool]=None) - (implicit moduleCompileOptions: CompileOptions) +abstract class LegacyModule(implicit moduleCompileOptions: CompileOptions) extends ImplicitModule { + // These are to be phased out + protected var override_clock: Option[Clock] = None + protected var override_reset: Option[Bool] = None + // _clock and _reset can be clock and reset in these 2ary constructors // once chisel2 compatibility issues are resolved + @deprecated("Module constructor with override_clock and override_reset deprecated, use withClockAndReset", "chisel3") + def this(override_clock: Option[Clock]=None, override_reset: Option[Bool]=None) + (implicit moduleCompileOptions: CompileOptions) = { + this() + this.override_clock = override_clock + this.override_reset = override_reset + } + + @deprecated("Module constructor with override _clock deprecated, use withClock", "chisel3") def this(_clock: Clock)(implicit moduleCompileOptions: CompileOptions) = this(Option(_clock), None)(moduleCompileOptions) + @deprecated("Module constructor with override _reset deprecated, use withReset", "chisel3") def this(_reset: Bool)(implicit moduleCompileOptions: CompileOptions) = this(None, Option(_reset))(moduleCompileOptions) + @deprecated("Module constructor with override _clock, _reset deprecated, use withClockAndReset", "chisel3") def this(_clock: Clock, _reset: Bool)(implicit moduleCompileOptions: CompileOptions) = this(Option(_clock), Option(_reset))(moduleCompileOptions) // IO for this Module. At the Scala level (pre-FIRRTL transformations), |
