From 28e358235ef9b68ce9bad7bcf1d7e778ef17008c Mon Sep 17 00:00:00 2001 From: Jiuyang Liu Date: Mon, 5 Dec 2022 17:55:56 +0000 Subject: [PATCH 1/9] SerializableModuleGenerator (#2857) * add upickle to dependency * implement SerializableModuleGenerator to serialize a parameterized module * add simple test * Add mdoc Co-authored-by: Jack Koenig Co-authored-by: Jack Koenig --- build.sbt | 6 +- build.sc | 4 +- .../SerializableModuleGenerator.scala | 83 +++++++++++++++++ docs/src/cookbooks/serialization.md | 89 +++++++++++++++++++ .../SerializableModuleGeneratorSpec.scala | 82 +++++++++++++++++ 5 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 core/src/main/scala/chisel3/experimental/SerializableModuleGenerator.scala create mode 100644 docs/src/cookbooks/serialization.md create mode 100644 src/test/scala/chiselTests/experimental/SerializableModuleGeneratorSpec.scala diff --git a/build.sbt b/build.sbt index 675ee41d98b..b3feb806728 100644 --- a/build.sbt +++ b/build.sbt @@ -73,7 +73,7 @@ lazy val chiselSettings = Seq( libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % "3.2.12" % "test", "org.scalatestplus" %% "scalacheck-1-14" % "3.2.2.0" % "test", - "com.lihaoyi" %% "os-lib" % "0.8.1" + "com.lihaoyi" %% "upickle" % "2.0.0" ) ) ++ ( // Tests from other projects may still run concurrently @@ -174,6 +174,10 @@ lazy val core = (project in file("core")) .settings(mimaPreviousArtifacts := Set()) .settings( name := "chisel3-core", + libraryDependencies ++= Seq( + "com.lihaoyi" %% "upickle" % "2.0.0", + "com.lihaoyi" %% "os-lib" % "0.8.1" + ), scalacOptions := scalacOptions.value ++ Seq( "-deprecation", "-explaintypes", diff --git a/build.sc b/build.sc index 717134a6ae6..0a1400622ae 100644 --- a/build.sc +++ b/build.sc @@ -29,6 +29,7 @@ object v { val scalatest = ivy"org.scalatest::scalatest:3.2.12" val scalacheck = ivy"org.scalatestplus::scalacheck-1-14:3.2.2.0" val osLib = ivy"com.lihaoyi::os-lib:0.8.1" + val upickle = ivy"com.lihaoyi::upickle:2.0.0" val macroParadise = ivy"org.scalamacros:::paradise:2.1.1" } @@ -61,7 +62,8 @@ trait CommonModule extends CrossSbtModule with PublishModule with ScalafmtModule override def moduleDeps = super.moduleDeps ++ firrtlModule override def ivyDeps = super.ivyDeps() ++ Agg( - v.osLib + v.osLib, + v.upickle ) ++ firrtlIvyDeps def publishVersion = "3.6-SNAPSHOT" diff --git a/core/src/main/scala/chisel3/experimental/SerializableModuleGenerator.scala b/core/src/main/scala/chisel3/experimental/SerializableModuleGenerator.scala new file mode 100644 index 00000000000..3cf8dc34390 --- /dev/null +++ b/core/src/main/scala/chisel3/experimental/SerializableModuleGenerator.scala @@ -0,0 +1,83 @@ +package chisel3.experimental + +import upickle.default._ + +import scala.reflect.runtime.universe + +/** Parameter for SerializableModule, it should be serializable via upickle API. + * For more information, please refer to [[https://com-lihaoyi.github.io/upickle/]] + */ +trait SerializableModuleParameter + +/** Mixin this trait to let chisel auto serialize module, it has these constraints: + * 1. Module should not be any inner class of other class, since serializing outer class is impossible. + * 2. Module should have and only have one parameter with type `T`: + * {{{ + * class FooSerializableModule[FooSerializableModuleParameter](val parameter: FooSerializableModuleParameter) + * }}} + * 3. user should guarantee the module is reproducible on their own. + */ +trait SerializableModule[T <: SerializableModuleParameter] { this: BaseModule => + val parameter: T +} +object SerializableModuleGenerator { + + /** serializer for SerializableModuleGenerator. */ + implicit def rw[P <: SerializableModuleParameter, M <: SerializableModule[P]]( + implicit rwP: ReadWriter[P], + pTypeTag: universe.TypeTag[P], + mTypeTag: universe.TypeTag[M] + ): ReadWriter[SerializableModuleGenerator[M, P]] = readwriter[ujson.Value].bimap[SerializableModuleGenerator[M, P]]( + { (x: SerializableModuleGenerator[M, P]) => + ujson + .Obj( + "parameter" -> upickle.default.writeJs[P](x.parameter), + "generator" -> x.generator.getName + ) + }, + { (json: ujson.Value) => + SerializableModuleGenerator[M, P]( + Class.forName(json.obj("generator").str).asInstanceOf[Class[M]], + upickle.default.read[P](json.obj("parameter")) + ) + } + ) +} + +/** the serializable module generator: + * @param generator a non-inner class of module, which should be a subclass of [[SerializableModule]] + * @param parameter the parameter of `generator` + */ +case class SerializableModuleGenerator[M <: SerializableModule[P], P <: SerializableModuleParameter]( + generator: Class[M], + parameter: P +)( + implicit val pTag: universe.TypeTag[P], + implicit val mTag: universe.TypeTag[M]) { + private[chisel3] def construct: M = { + require( + generator.getConstructors.length == 1, + s"""only allow constructing SerializableModule from SerializableModuleParameter via class Module(val parameter: Parameter), + |you have ${generator.getConstructors.length} constructors + |""".stripMargin + ) + require( + !generator.getConstructors.head.getParameterTypes.last.toString.contains("$"), + s"""You define your ${generator.getConstructors.head.getParameterTypes.last} inside other class. + |This is a forbidden behavior, since we cannot serialize the out classes, + |for debugging, these are full parameter types of constructor: + |${generator.getConstructors.head.getParameterTypes.mkString("\n")} + |""".stripMargin + ) + require( + generator.getConstructors.head.getParameterCount == 1, + s"""You define multiple constructors: + |${generator.getConstructors.head.getParameterTypes.mkString("\n")} + |""".stripMargin + ) + generator.getConstructors.head.newInstance(parameter).asInstanceOf[M] + } + + /** elaborate a module from this generator. */ + def module(): M = construct +} diff --git a/docs/src/cookbooks/serialization.md b/docs/src/cookbooks/serialization.md new file mode 100644 index 00000000000..ec4ead6008f --- /dev/null +++ b/docs/src/cookbooks/serialization.md @@ -0,0 +1,89 @@ +--- +layout: docs +title: "Serialization Cookbook" +section: "chisel3" +--- + +# Serialization Cookbook + +* [Why do I need to serialize Modules](#why-do-i-need-to-serialize-modules) +* [How do I serialize Modules with SerializableModuleGenerator](#how-do-i-seerialize-modules-with-serializablemodulegenerator) + +## Why do I need to serialize Modules +Chisel provides a very flexible hardware design experience. However, it sometimes becomes too flexible to design a relative big designs, since parameters of module might come from: 1. Global variables; 2. Outer class; 3. Entropies(time, random). It becomes really hard or impossible to describe "how to reproduce this single module?". This forbids doing unit-test for a module generator, and introduces issues in post-synthesis when doing ECO: a change to Module A might lead to change in Module B. +Thus `SerializableModuleGenerator`, `SerializableModule[T <: SerializableModuleParameter]` and `SerializableModuleParameter` are provided to solve these issues. +For any `SerializableModuleGenerator`, Chisel can automatically serialize and de-serialize it by adding these constraints: +1. the `SerializableModule` should not be inner class, since the outer class is a parameter to it; +1. the `SerializableModule` has and only has one parameter with `SerializableModuleParameter` as its type. +1. the Module neither depends on global variables nor uses non-reproducible functions(random, time, etc), and this should be guaranteed by user, since Scala cannot detect it. + +It can provide these benefits: +1. user can use `SerializableModuleGenerator(module: class[SerializableModule], parameter: SerializableModuleParameter)` to auto serialize a Module and its parameter. +1. user can nest `SerializableModuleGenerator` in other serializable parameters to represent a relative large parameter. +1. user can elaborate any `SerializableModuleGenerator` into a single module for testing. + + +## How do I serialize Modules with `SerializableModuleGenerator` +It is pretty simple and illustrated by example below, the `GCD` Module with `width` as its parameter. + +```scala mdoc:silent +import chisel3._ +import chisel3.experimental.{SerializableModule, SerializableModuleGenerator, SerializableModuleParameter} +import upickle.default._ + +// provide serialization functions to GCDSerializableModuleParameter +object GCDSerializableModuleParameter { + implicit def rwP: ReadWriter[GCDSerializableModuleParameter] = macroRW +} + +// Parameter +case class GCDSerializableModuleParameter(width: Int) extends SerializableModuleParameter + +// Module +class GCDSerializableModule(val parameter: GCDSerializableModuleParameter) + extends Module + with SerializableModule[GCDSerializableModuleParameter] { + val io = IO(new Bundle { + val a = Input(UInt(parameter.width.W)) + val b = Input(UInt(parameter.width.W)) + val e = Input(Bool()) + val z = Output(UInt(parameter.width.W)) + }) + val x = Reg(UInt(parameter.width.W)) + val y = Reg(UInt(parameter.width.W)) + val z = Reg(UInt(parameter.width.W)) + val e = Reg(Bool()) + when(e) { + x := io.a + y := io.b + z := 0.U + } + when(x =/= y) { + when(x > y) { + x := x - y + }.otherwise { + y := y - x + } + }.otherwise { + z := x + } + io.z := z +} +``` +using `write` function in `upickle`, it should return a json string: +```scala mdoc +val j = upickle.default.write( + SerializableModuleGenerator( + classOf[GCDSerializableModule], + GCDSerializableModuleParameter(32) + ) +) +``` + +You can then read from json string and elaborate the Module: +```scala mdoc:compile-only +chisel3.stage.ChiselStage.emitVerilog( + upickle.default.read[SerializableModuleGenerator[GCDSerializableModule, GCDSerializableModuleParameter]]( + ujson.read(j) + ).module() +) diff --git a/src/test/scala/chiselTests/experimental/SerializableModuleGeneratorSpec.scala b/src/test/scala/chiselTests/experimental/SerializableModuleGeneratorSpec.scala new file mode 100644 index 00000000000..a6c32652f0a --- /dev/null +++ b/src/test/scala/chiselTests/experimental/SerializableModuleGeneratorSpec.scala @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: Apache-2.0 + +package chiselTests +package experimental +import chisel3._ +import chisel3.experimental.{SerializableModule, SerializableModuleGenerator, SerializableModuleParameter} +import upickle.default._ +object GCDSerializableModuleParameter { + implicit def rwP: ReadWriter[GCDSerializableModuleParameter] = macroRW +} + +case class GCDSerializableModuleParameter(width: Int) extends SerializableModuleParameter + +class GCDSerializableModule(val parameter: GCDSerializableModuleParameter) + extends Module + with SerializableModule[GCDSerializableModuleParameter] { + val io = IO(new Bundle { + val a = Input(UInt(parameter.width.W)) + val b = Input(UInt(parameter.width.W)) + val e = Input(Bool()) + val z = Output(UInt(parameter.width.W)) + }) + val x = Reg(UInt(parameter.width.W)) + val y = Reg(UInt(parameter.width.W)) + val z = Reg(UInt(parameter.width.W)) + val e = Reg(Bool()) + when(e) { + x := io.a + y := io.b + z := 0.U + } + when(x =/= y) { + when(x > y) { + x := x - y + }.otherwise { + y := y - x + } + }.otherwise { + z := x + } + io.z := z +} + +class SerializableModuleGeneratorSpec extends ChiselFlatSpec with Utils { + val g = SerializableModuleGenerator( + classOf[GCDSerializableModule], + GCDSerializableModuleParameter(32) + ) + + "SerializableModuleGenerator" should "be serialized and deserialized" in { + assert( + g == upickle.default.read[SerializableModuleGenerator[GCDSerializableModule, GCDSerializableModuleParameter]]( + upickle.default.write(g) + ) + ) + } + + "SerializableModuleGenerator" should "be able to elaborate" in { + chisel3.stage.ChiselStage.emitChirrtl(g.module()) + } + + case class FooParameter() extends SerializableModuleParameter + + class InnerFoo(val parameter: FooParameter) extends RawModule with SerializableModule[FooParameter] + + "InnerClass" should "not be able to serialize" in { + assert( + intercept[java.lang.IllegalArgumentException]( + chisel3.stage.ChiselStage.emitChirrtl( + { + SerializableModuleGenerator( + classOf[InnerFoo], + FooParameter() + ).module() + } + ) + ).getMessage.contains( + "You define your class chiselTests.experimental.SerializableModuleGeneratorSpec$FooParameter inside other class." + ) + ) + } +} From 3425a8c97e81501c23ff2f61912d72fe89007d06 Mon Sep 17 00:00:00 2001 From: Megan Wachs Date: Mon, 5 Dec 2022 13:46:15 -0800 Subject: [PATCH 2/9] Deprecate Chisel._ Compatibility Mode (#2668) --- docs/src/appendix/chisel3-vs-chisel2.md | 2 + src/main/scala/chisel3/compatibility.scala | 190 ++++++++++++++++-- src/main/scala/chisel3/util/Math.scala | 9 +- .../scala/chiselTests/BulkConnectSpec.scala | 3 + .../CompatibilityInteroperabilitySpec.scala | 4 + .../scala/chiselTests/CompatibilitySpec.scala | 3 + .../chiselTests/CompileOptionsTest.scala | 3 + .../MigrateCompileOptionsSpec.scala | 4 + .../chiselTests/ModuleExplicitResetSpec.scala | 3 + 9 files changed, 204 insertions(+), 17 deletions(-) diff --git a/docs/src/appendix/chisel3-vs-chisel2.md b/docs/src/appendix/chisel3-vs-chisel2.md index cafd29e3b30..3f7281f962a 100644 --- a/docs/src/appendix/chisel3-vs-chisel2.md +++ b/docs/src/appendix/chisel3-vs-chisel2.md @@ -9,6 +9,8 @@ section: "chisel3" import chisel3._ ``` +**Note** Chisel2 Compatibility Mode is entirely deprecated in 3.6, so this entire page is relevant only for 3.6 and earlier. + ## Chisel2 Migration For those moving from Chisel2, there were some backwards incompatible changes and your RTL needs to be modified to work with Chisel3. The required diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala index 1c831c92f39..69e2bdd619e 100644 --- a/src/main/scala/chisel3/compatibility.scala +++ b/src/main/scala/chisel3/compatibility.scala @@ -7,6 +7,8 @@ import chisel3._ // required for implicit conversions. import chisel3.util.random.FibonacciLFSR import chisel3.stage.{phases, ChiselCircuitAnnotation, ChiselOutputFileAnnotation, ChiselStage} +import scala.annotation.nowarn + package object Chisel { import chisel3.internal.firrtl.Width @@ -15,25 +17,37 @@ package object Chisel { import scala.annotation.compileTimeOnly import scala.language.implicitConversions + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") implicit val defaultCompileOptions = chisel3.ExplicitCompileOptions.NotStrict + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") abstract class Direction + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") case object INPUT extends Direction + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") case object OUTPUT extends Direction + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") case object NODIR extends Direction + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Input = chisel3.Input + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Output = chisel3.Output + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object Flipped { def apply[T <: Data](target: T): T = chisel3.Flipped[T](target) } + @nowarn("msg=Chisel compatibility mode is deprecated") implicit class AddDirectionToData[T <: Data](target: T) { - def asInput: T = Input(target) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") + def asInput: T = Input(target) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def asOutput: T = Output(target) - def flip: T = Flipped(target) - + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") + def flip: T = Flipped(target) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") @deprecated( "Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5" @@ -41,11 +55,13 @@ package object Chisel { def flip(dummy: Int*): T = flip } + @nowarn("msg=Chisel compatibility mode is deprecated") implicit class AddDirMethodToData[T <: Data](target: T) { import chisel3.ActualDirection import chisel3.reflect.DataMirror import chisel3.internal.requireIsHardware + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def dir: Direction = { requireIsHardware(target) // This has the side effect of calling _autoWrapPorts target match { @@ -59,16 +75,22 @@ package object Chisel { } } } + + @nowarn("msg=Chisel compatibility mode is deprecated") implicit class cloneTypeable[T <: Data](target: T) { import chisel3.reflect.DataMirror + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def chiselCloneType: T = { DataMirror.internal.chiselTypeClone(target).asInstanceOf[T] } } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type ChiselException = chisel3.internal.ChiselException + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Data = chisel3.Data + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object Wire extends WireFactory { import chisel3.CompileOptions @@ -78,6 +100,7 @@ package object Chisel { def apply[T <: Data](t: T, init: T)(implicit compileOptions: CompileOptions): T = chisel3.WireDefault(t, init) } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object Clock { def apply(): Clock = new Clock @@ -90,9 +113,11 @@ package object Chisel { } } } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Clock = chisel3.Clock // Implicit conversion to allow fromBits because it's being deprecated in chisel3 + @nowarn("msg=Chisel compatibility mode is deprecated") implicit class fromBitsable[T <: Data](data: T) { import chisel3.CompileOptions import chisel3.internal.sourceinfo.SourceInfo @@ -107,16 +132,20 @@ package object Chisel { * @note does NOT check bit widths, may drop bits during assignment * @note what fromBits assigs to must have known widths */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def fromBits(that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = { that.asTypeOf(data) } } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Aggregate = chisel3.Aggregate + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object Vec extends chisel3.VecFactory { import chisel3.CompileOptions import chisel3.internal.sourceinfo._ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") @deprecated("Vec argument order should be size, t; this will be removed by the official release", "chisel3") def apply[T <: Data](gen: T, n: Int)(implicit compileOptions: CompileOptions): Vec[T] = apply(n, gen) @@ -162,42 +191,58 @@ package object Chisel { ): Vec[T] = chisel3.VecInit.tabulate(n)(gen) } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Vec[T <: Data] = chisel3.Vec[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type VecLike[T <: Data] = chisel3.VecLike[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Record = chisel3.Record + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Bundle = chisel3.Bundle + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val assert = chisel3.assert + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val stop = chisel3.stop /** This contains literal constructor factory methods that are deprecated as of Chisel3. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") trait UIntFactory extends chisel3.UIntFactory { /** Create a UInt literal with inferred width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(n: String): UInt = n.asUInt /** Create a UInt literal with fixed width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(n: String, width: Int): UInt = n.asUInt(width.W) /** Create a UInt literal with specified width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(value: BigInt, width: Width): UInt = value.asUInt(width) /** Create a UInt literal with fixed width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(value: BigInt, width: Int): UInt = value.asUInt(width.W) /** Create a UInt with a specified width - compatibility with Chisel2. */ // NOTE: This resolves UInt(width = 32) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Option[Direction] = None, width: Int): UInt = apply(width.W) /** Create a UInt literal with inferred width.- compatibility with Chisel2. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(value: BigInt): UInt = value.asUInt /** Create a UInt with a specified direction and width - compatibility with Chisel2. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Direction, width: Int): UInt = apply(dir, width.W) /** Create a UInt with a specified direction, but unspecified width - compatibility with Chisel2. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Direction): UInt = apply(dir, Width()) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Direction, width: Width): UInt = { val result = apply(width) dir match { @@ -208,42 +253,57 @@ package object Chisel { } /** Create a UInt with a specified width */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def width(width: Int): UInt = apply(width.W) /** Create a UInt port with specified width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def width(width: Width): UInt = apply(width) } /** This contains literal constructor factory methods that are deprecated as of Chisel3. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") trait SIntFactory extends chisel3.SIntFactory { /** Create a SInt type or port with fixed width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def width(width: Int): SInt = apply(width.W) /** Create an SInt type with specified width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def width(width: Width): SInt = apply(width) /** Create an SInt literal with inferred width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(value: BigInt): SInt = value.asSInt /** Create an SInt literal with fixed width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(value: BigInt, width: Int): SInt = value.asSInt(width.W) /** Create an SInt literal with specified width. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(value: BigInt, width: Width): SInt = value.asSInt(width) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def Lit(value: BigInt): SInt = value.asSInt + + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def Lit(value: BigInt, width: Int): SInt = value.asSInt(width.W) /** Create a SInt with a specified width - compatibility with Chisel2. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Option[Direction] = None, width: Int): SInt = apply(width.W) /** Create a SInt with a specified direction and width - compatibility with Chisel2. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Direction, width: Int): SInt = apply(dir, width.W) /** Create a SInt with a specified direction, but unspecified width - compatibility with Chisel2. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Direction): SInt = apply(dir, Width()) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Direction, width: Width): SInt = { val result = apply(width) dir match { @@ -256,13 +316,16 @@ package object Chisel { /** This contains literal constructor factory methods that are deprecated as of Chisel3. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") trait BoolFactory extends chisel3.BoolFactory { /** Creates Bool literal. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(x: Boolean): Bool = x.B /** Create a UInt with a specified direction and width - compatibility with Chisel2. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(dir: Direction): Bool = { val result = apply() dir match { @@ -273,45 +336,67 @@ package object Chisel { } } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Element = chisel3.Element + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Bits = chisel3.Bits + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object Bits extends UIntFactory + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Num[T <: Data] = chisel3.Num[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type UInt = chisel3.UInt + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object UInt extends UIntFactory + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type SInt = chisel3.SInt + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object SInt extends SIntFactory + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Bool = chisel3.Bool + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object Bool extends BoolFactory + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Mux = chisel3.Mux + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Reset = chisel3.Reset + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") implicit def resetToBool(reset: Reset): Bool = reset.asBool + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type BlackBox = chisel3.internal.LegacyBlackBox + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type MemBase[T <: Data] = chisel3.MemBase[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Mem = chisel3.Mem + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Mem[T <: Data] = chisel3.Mem[T] implicit class MemCompatibility(a: Mem.type) { import chisel3.internal.sourceinfo.UnlocatableSourceInfo + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply[T <: Data](t: T, size: BigInt)(implicit compileOptions: CompileOptions): Mem[T] = a.do_apply(size, t)(UnlocatableSourceInfo, compileOptions) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply[T <: Data](t: T, size: Int)(implicit compileOptions: CompileOptions): Mem[T] = a.do_apply(size, t)(UnlocatableSourceInfo, compileOptions) } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val SeqMem = chisel3.SyncReadMem + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type SeqMem[T <: Data] = chisel3.SyncReadMem[T] implicit class SeqMemCompatibility(a: SeqMem.type) { import chisel3.internal.sourceinfo.SourceInfo + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply[T <: Data]( t: T, size: BigInt @@ -321,6 +406,7 @@ package object Chisel { ): SyncReadMem[T] = a.do_apply(size, t) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply[T <: Data]( t: T, size: Int @@ -335,13 +421,20 @@ package object Chisel { @deprecated("Use Chisel.Module", "Chisel 3.5") type CompatibilityModule = chisel3.internal.LegacyModule + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Module = chisel3.Module + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Module = chisel3.internal.LegacyModule + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val printf = chisel3.printf + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val RegNext = chisel3.RegNext + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val RegInit = chisel3.RegInit + + @nowarn("msg=Chisel compatibility mode is deprecated") object Reg { import chisel3.CompileOptions import chisel3.internal.sourceinfo.SourceInfo @@ -349,6 +442,7 @@ package object Chisel { // Passthrough for chisel3.Reg // Single-element constructor to avoid issues caused by null default args in a type // parameterized scope. + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply[T <: Data](t: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = chisel3.Reg(t) @@ -365,6 +459,7 @@ package object Chisel { * is a valid value. In those cases, you can either use the outType only Reg * constructor or pass in `null.asInstanceOf[T]`. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply[T <: Data]( t: T = null, next: T = null, @@ -397,7 +492,9 @@ package object Chisel { } } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val when = chisel3.when + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type WhenContext = chisel3.WhenContext implicit class fromBigIntToLiteral(x: BigInt) extends chisel3.fromBigIntToLiteral(x) @@ -409,6 +506,7 @@ package object Chisel { @deprecated("Use object firrtl.util.BackendCompilationUtilities instead", "Chisel 3.5") type BackendCompilationUtilities = chisel3.BackendCompilationUtilities + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val ImplicitConversions = chisel3.util.ImplicitConversions // Deprecated as of Chisel3 @@ -425,9 +523,11 @@ package object Chisel { } } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply[T <: Module](args: Array[String], gen: () => T): Unit = Predef.assert(false, "No more chiselMain in Chisel3") + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def run[T <: Module](args: Array[String], gen: () => T): Unit = { val circuit = ChiselStage.elaborate(gen()) parseArgs(args) @@ -438,12 +538,14 @@ package object Chisel { } } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") @deprecated("debug doesn't do anything in Chisel3 as no pruning happens in the frontend", "chisel3") object debug { def apply(arg: Data): Data = arg } - // Deprecated as of Chsiel3 + // Deprecated as of Chisel3 + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object throwException { @throws(classOf[Exception]) def apply(s: String, t: Throwable = null): Nothing = { @@ -452,68 +554,92 @@ package object Chisel { } } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") object testers { type BasicTester = chisel3.testers.BasicTester val TesterDriver = chisel3.testers.TesterDriver } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val log2Ceil = chisel3.util.log2Ceil + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val log2Floor = chisel3.util.log2Floor + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val isPow2 = chisel3.util.isPow2 /** Compute the log2 rounded up with min value of 1 */ - object log2Up { - def apply(in: BigInt): Int = { - require(in >= 0) - 1.max((in - 1).bitLength) - } - def apply(in: Int): Int = apply(BigInt(in)) - } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") + val log2Up = chisel3.util.log2Up /** Compute the log2 rounded down with min value of 1 */ - object log2Down { - def apply(in: BigInt): Int = log2Up(in) - (if (isPow2(in)) 0 else 1) - def apply(in: Int): Int = apply(BigInt(in)) - } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") + val log2Down = chisel3.util.log2Down + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val BitPat = chisel3.util.BitPat + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type BitPat = chisel3.util.BitPat implicit class BitsObjectCompatibility(a: BitPat.type) { + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def DC(width: Int): BitPat = a.dontCare(width) } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type ArbiterIO[T <: Data] = chisel3.util.ArbiterIO[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type LockingArbiterLike[T <: Data] = chisel3.util.LockingArbiterLike[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type LockingRRArbiter[T <: Data] = chisel3.util.LockingRRArbiter[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type LockingArbiter[T <: Data] = chisel3.util.LockingArbiter[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type RRArbiter[T <: Data] = chisel3.util.RRArbiter[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Arbiter[T <: Data] = chisel3.util.Arbiter[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val FillInterleaved = chisel3.util.FillInterleaved + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val PopCount = chisel3.util.PopCount + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Fill = chisel3.util.Fill + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Reverse = chisel3.util.Reverse + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Cat = chisel3.util.Cat + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Log2 = chisel3.util.Log2 + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type SwitchContext[T <: Bits] = chisel3.util.SwitchContext[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val is = chisel3.util.is + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val switch = chisel3.util.switch + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Counter = chisel3.util.Counter + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Counter = chisel3.util.Counter + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type DecoupledIO[+T <: Data] = chisel3.util.DecoupledIO[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val DecoupledIO = chisel3.util.Decoupled + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Decoupled = chisel3.util.Decoupled + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type QueueIO[T <: Data] = chisel3.util.QueueIO[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Queue = chisel3.util.Queue + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Queue[T <: Data] = QueueCompatibility[T] + @nowarn("msg=Chisel compatibility mode is deprecated") sealed class QueueCompatibility[T <: Data]( gen: T, entries: Int, @@ -528,6 +654,7 @@ package object Chisel { this.override_reset = override_reset } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def this(gen: T, entries: Int, pipe: Boolean, flow: Boolean, _reset: Bool) = { this(gen, entries, pipe, flow) this.override_reset = Some(_reset) @@ -554,6 +681,7 @@ package object Chisel { * } * }}} */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply[T <: Bits](nodeType: T, n: Int): List[T] = { require(nodeType.isInstanceOf[UInt], "Only UInt supported for enums") require(!nodeType.widthKnown, "Bit width may no longer be specified for enums") @@ -569,6 +697,7 @@ package object Chisel { * Despite being deprecated, this is not to be removed from the compatibility layer API. * Deprecation is only to nag users to do something safer. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") @deprecated("Use list-based Enum", "not soon enough") def apply[T <: Bits](nodeType: T, l: Symbol*): Map[Symbol, T] = { require(nodeType.isInstanceOf[UInt], "Only UInt supported for enums") @@ -585,6 +714,7 @@ package object Chisel { * Despite being deprecated, this is not to be removed from the compatibility layer API. * Deprecation is only to nag users to do something safer. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") @deprecated("Use list-based Enum", "not soon enough") def apply[T <: Bits](nodeType: T, l: List[Symbol]): Map[Symbol, T] = { require(nodeType.isInstanceOf[UInt], "Only UInt supported for enums") @@ -611,11 +741,13 @@ package object Chisel { * * }}} */ + @nowarn("msg=Chisel compatibility mode is deprecated") object LFSR16 { /** Generates a 16-bit linear feedback shift register, returning the register contents. * @param increment optional control to gate when the LFSR updates. */ + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def apply(increment: Bool = true.B): UInt = VecInit( FibonacciLFSR @@ -626,25 +758,41 @@ package object Chisel { } + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val ListLookup = chisel3.util.ListLookup + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Lookup = chisel3.util.Lookup + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Mux1H = chisel3.util.Mux1H + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val PriorityMux = chisel3.util.PriorityMux + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val MuxLookup = chisel3.util.MuxLookup + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val MuxCase = chisel3.util.MuxCase + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val OHToUInt = chisel3.util.OHToUInt + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val PriorityEncoder = chisel3.util.PriorityEncoder + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val UIntToOH = chisel3.util.UIntToOH + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val PriorityEncoderOH = chisel3.util.PriorityEncoderOH + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val RegEnable = chisel3.util.RegEnable + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val ShiftRegister = chisel3.util.ShiftRegister + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type ValidIO[+T <: Data] = chisel3.util.Valid[T] + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Valid = chisel3.util.Valid + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") val Pipe = chisel3.util.Pipe + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") type Pipe[T <: Data] = chisel3.util.Pipe[T] /** Package for experimental features, which may have their API changed, be removed, etc. @@ -655,36 +803,48 @@ package object Chisel { object experimental { import scala.annotation.compileTimeOnly + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") class dump extends chisel3.internal.naming.dump + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") class treedump extends chisel3.internal.naming.treedump } + @nowarn("msg=Chisel compatibility mode is deprecated") implicit class DataCompatibility(a: Data) { import chisel3.internal.sourceinfo.DeprecatedSourceInfo + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def toBits(implicit compileOptions: CompileOptions): UInt = a.do_asUInt(DeprecatedSourceInfo, compileOptions) } + @nowarn("msg=Chisel compatibility mode is deprecated") implicit class VecLikeCompatibility[T <: Data](a: VecLike[T]) { import chisel3.internal.sourceinfo.DeprecatedSourceInfo + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def read(idx: UInt)(implicit compileOptions: CompileOptions): T = a.do_apply(idx)(compileOptions) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") def write(idx: UInt, data: T)(implicit compileOptions: CompileOptions): Unit = a.do_apply(idx)(compileOptions).:=(data)(DeprecatedSourceInfo, compileOptions) } + @nowarn("msg=Chisel compatibility mode is deprecated") implicit class BitsCompatibility(a: Bits) { import chisel3.internal.sourceinfo.DeprecatedSourceInfo + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") final def asBits(implicit compileOptions: CompileOptions): Bits = a.do_asUInt(DeprecatedSourceInfo, compileOptions) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") final def toSInt(implicit compileOptions: CompileOptions): SInt = a.do_asSInt(DeprecatedSourceInfo, compileOptions) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") final def toUInt(implicit compileOptions: CompileOptions): UInt = a.do_asUInt(DeprecatedSourceInfo, compileOptions) + @deprecated("Chisel compatibility mode is deprecated. Use the chisel3 package instead.", "Chisel 3.6") final def toBools(implicit compileOptions: CompileOptions): Seq[Bool] = a.do_asBools(DeprecatedSourceInfo, compileOptions) } diff --git a/src/main/scala/chisel3/util/Math.scala b/src/main/scala/chisel3/util/Math.scala index 6eab9241d8d..822b3eb1b33 100644 --- a/src/main/scala/chisel3/util/Math.scala +++ b/src/main/scala/chisel3/util/Math.scala @@ -27,7 +27,11 @@ object log2Up { // https://github.com/freechipsproject/chisel3/issues/847 //@chiselRuntimeDeprecated //@deprecated("Use log2Ceil instead", "chisel3") - def apply(in: BigInt): Int = Chisel.log2Up(in) + def apply(in: BigInt): Int = { + require(in >= 0) + 1.max((in - 1).bitLength) + } + def apply(in: Int): Int = apply(BigInt(in)) } /** Compute the log2 of a Scala integer, rounded up. @@ -66,7 +70,8 @@ object log2Down { // https://github.com/freechipsproject/chisel3/issues/847 //@chiselRuntimeDeprecated //@deprecated("Use log2Floor instead", "chisel3") - def apply(in: BigInt): Int = Chisel.log2Down(in) + def apply(in: BigInt): Int = log2Up(in) - (if (isPow2(in)) 0 else 1) + def apply(in: Int): Int = apply(BigInt(in)) } /** Compute the log2 of a Scala integer, rounded down. diff --git a/src/test/scala/chiselTests/BulkConnectSpec.scala b/src/test/scala/chiselTests/BulkConnectSpec.scala index 0a1616d3155..e69c8cd1e62 100644 --- a/src/test/scala/chiselTests/BulkConnectSpec.scala +++ b/src/test/scala/chiselTests/BulkConnectSpec.scala @@ -5,6 +5,8 @@ import chisel3.util.Decoupled import chisel3.stage.ChiselStage import chisel3.testers.BasicTester +import scala.annotation.nowarn + class BulkConnectSpec extends ChiselPropSpec { property("Chisel connects should emit FIRRTL bulk connects when possible") { val chirrtl = ChiselStage.emitChirrtl(new Module { @@ -22,6 +24,7 @@ class BulkConnectSpec extends ChiselPropSpec { } property("Chisel connects should not emit FIRRTL bulk connects for Stringly-typed connections") { + @nowarn("msg=Chisel compatibility mode is deprecated") object Foo { import Chisel._ // Chisel._ bundle diff --git a/src/test/scala/chiselTests/CompatibilityInteroperabilitySpec.scala b/src/test/scala/chiselTests/CompatibilityInteroperabilitySpec.scala index d388c09346d..869c2abe5f6 100644 --- a/src/test/scala/chiselTests/CompatibilityInteroperabilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilityInteroperabilitySpec.scala @@ -5,7 +5,10 @@ package chiselTests import scala.collection.immutable.ListMap import chisel3.stage.ChiselStage.emitChirrtl +import scala.annotation.nowarn + // Keep Chisel._ separate from chisel3._ below +@nowarn("msg=Chisel compatibility mode is deprecated") object CompatibilityComponents { import Chisel._ import Chisel3Components._ @@ -75,6 +78,7 @@ object Chisel3Components { class Chisel3ModuleChiselRecordB extends Chisel3PassthroughModule(Flipped(new ChiselRecord)) } +@nowarn("msg=Chisel compatibility mode is deprecated") class CompatibilityInteroperabilitySpec extends ChiselFlatSpec { "Modules defined in the Chisel._" should "successfully bulk connect in chisel3._" in { diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala index 93ae8904794..b924587326b 100644 --- a/src/test/scala/chiselTests/CompatibilitySpec.scala +++ b/src/test/scala/chiselTests/CompatibilitySpec.scala @@ -9,8 +9,10 @@ import org.scalacheck.Gen import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import scala.collection.immutable.ListMap +import scala.annotation.nowarn // Need separate import to override compile options from Chisel._ +@nowarn("msg=Chisel compatibility mode is deprecated") object CompatibilityCustomCompileOptions { import Chisel.{defaultCompileOptions => _, _} implicit val customCompileOptions = @@ -20,6 +22,7 @@ object CompatibilityCustomCompileOptions { } } +@nowarn("msg=Chisel compatibility mode is deprecated") class CompatibilitySpec extends ChiselFlatSpec with ScalaCheckDrivenPropertyChecks with Utils { import Chisel._ diff --git a/src/test/scala/chiselTests/CompileOptionsTest.scala b/src/test/scala/chiselTests/CompileOptionsTest.scala index b39d8ee3424..56a309b1b01 100644 --- a/src/test/scala/chiselTests/CompileOptionsTest.scala +++ b/src/test/scala/chiselTests/CompileOptionsTest.scala @@ -6,6 +6,9 @@ import chisel3._ import chisel3.CompileOptions._ import chisel3.stage.ChiselStage +import scala.annotation.nowarn + +@nowarn("msg=Chisel compatibility mode is deprecated") class CompileOptionsSpec extends ChiselFlatSpec with Utils { abstract class StrictModule extends Module()(chisel3.ExplicitCompileOptions.Strict) diff --git a/src/test/scala/chiselTests/MigrateCompileOptionsSpec.scala b/src/test/scala/chiselTests/MigrateCompileOptionsSpec.scala index 091f7f28cbf..c624e19ec60 100644 --- a/src/test/scala/chiselTests/MigrateCompileOptionsSpec.scala +++ b/src/test/scala/chiselTests/MigrateCompileOptionsSpec.scala @@ -8,6 +8,9 @@ import chisel3.ExplicitCompileOptions import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks +import scala.annotation.nowarn + +@nowarn("msg=Chisel compatibility mode is deprecated") object MigrationExamples { object InferResets { import Chisel.{defaultCompileOptions => _, _} @@ -86,6 +89,7 @@ object MigrationExamples { } } +@nowarn("msg=Chisel compatibility mode is deprecated") class MigrateCompileOptionsSpec extends ChiselFunSpec with Utils { import Chisel.{defaultCompileOptions => _, _} import chisel3.RequireSyncReset diff --git a/src/test/scala/chiselTests/ModuleExplicitResetSpec.scala b/src/test/scala/chiselTests/ModuleExplicitResetSpec.scala index 1a55fb3f610..e621dbea8ea 100644 --- a/src/test/scala/chiselTests/ModuleExplicitResetSpec.scala +++ b/src/test/scala/chiselTests/ModuleExplicitResetSpec.scala @@ -4,6 +4,9 @@ package chiselTests import chisel3.stage.ChiselStage +import scala.annotation.nowarn + +@nowarn("msg=Chisel compatibility mode is deprecated") class ModuleExplicitResetSpec extends ChiselFlatSpec { "A Module with an explicit reset in compatibility mode" should "elaborate" in { From 70081d03c3581bdc83bc23c24ea06e6eebe35084 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:37:24 +0100 Subject: [PATCH 3/9] Update sbt-mima-plugin to 1.1.1 (#2736) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index bcb720fdb1f..7fbcb2141c1 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -22,7 +22,7 @@ addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") addSbtPlugin("com.eed3si9n" % "sbt-sriracha" % "0.1.0") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") From 281857a1974bdb13f2959dfb5d73c6874685584f Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:49:25 +0100 Subject: [PATCH 4/9] Update sbt-ci-release to 1.5.11 (#2811) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 7fbcb2141c1..4224b8b168d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -24,7 +24,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-sriracha" % "0.1.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") From 7e0835ea98c62a61d1d0908b8e322d0fed565fbe Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Tue, 6 Dec 2022 00:01:49 +0100 Subject: [PATCH 5/9] Update sbt-mdoc to 2.3.6 (#2813) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4224b8b168d..4677af3a10f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -18,7 +18,7 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.15") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.6") addSbtPlugin("com.eed3si9n" % "sbt-sriracha" % "0.1.0") From 9c973ab7c6e097a314ccbcb5271e72debdc6e0b9 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Tue, 6 Dec 2022 00:14:24 +0100 Subject: [PATCH 6/9] Update scalatest to 3.2.14 (#2814) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- build.sbt | 6 +++--- build.sc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index b3feb806728..261b767313b 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ enablePlugins(SiteScaladocPlugin) val defaultVersions = Map( "firrtl" -> "edu.berkeley.cs" %% "firrtl" % "1.6-SNAPSHOT", - "treadle" -> "edu.berkeley.cs" %% "treadle" % "1.6-SNAPSHOT", + "treadle" -> "edu.berkeley.cs" %% "treadle" % "1.6-SNAPSHOT" // chiseltest intentionally excluded so that release automation does not try to set its version // The projects using chiseltest are not published, but SBT resolves dependencies for all projects // when doing publishing and will not find a chiseltest release since chiseltest depends on @@ -71,7 +71,7 @@ lazy val publishSettings = Seq( lazy val chiselSettings = Seq( name := "chisel3", libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % "3.2.12" % "test", + "org.scalatest" %% "scalatest" % "3.2.14" % "test", "org.scalatestplus" %% "scalacheck-1-14" % "3.2.2.0" % "test", "com.lihaoyi" %% "upickle" % "2.0.0" ) @@ -118,7 +118,7 @@ lazy val pluginScalaVersions = Seq( "2.13.7", "2.13.8", "2.13.9", - "2.13.10", + "2.13.10" ) lazy val plugin = (project in file("plugin")) diff --git a/build.sc b/build.sc index 0a1400622ae..90e3921b5f3 100644 --- a/build.sc +++ b/build.sc @@ -26,7 +26,7 @@ object v { val firrtl = getVersion("firrtl") val treadle = getVersion("treadle") val chiseltest = ivy"edu.berkeley.cs::chiseltest:0.6-SNAPSHOT" - val scalatest = ivy"org.scalatest::scalatest:3.2.12" + val scalatest = ivy"org.scalatest::scalatest:3.2.14" val scalacheck = ivy"org.scalatestplus::scalacheck-1-14:3.2.2.0" val osLib = ivy"com.lihaoyi::os-lib:0.8.1" val upickle = ivy"com.lihaoyi::upickle:2.0.0" From a7ad4999ce78e5617e4d92f775de7ad6e7f9506c Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Tue, 6 Dec 2022 00:27:24 +0100 Subject: [PATCH 7/9] Update sbt-scalafmt to 2.5.0 (#2853) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4677af3a10f..447fcb92733 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -26,7 +26,7 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") // From FIRRTL for building from source addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.33") From 61dec9a0442f8628da2ff16cbf7eef504dfae8a8 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Mon, 5 Dec 2022 16:38:31 -0800 Subject: [PATCH 8/9] Bump SBT to 1.8.0 (#2870) This means dropping Scala 2.12.4 support which is broken in Zinc newer than 1.6.0. Chisel users of Scala 2.12.4 should upgrade to 2.12.17. --- build.sbt | 8 +++----- project/build.properties | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 261b767313b..ef6cb6c2ee2 100644 --- a/build.sbt +++ b/build.sbt @@ -12,10 +12,8 @@ val defaultVersions = Map( ) lazy val commonSettings = Seq( - resolvers ++= Seq( - Resolver.sonatypeRepo("snapshots"), - Resolver.sonatypeRepo("releases") - ), + resolvers ++= Resolver.sonatypeOssRepos("snapshots"), + resolvers ++= Resolver.sonatypeOssRepos("releases"), organization := "edu.berkeley.cs", version := "3.6-SNAPSHOT", autoAPIMappings := true, @@ -94,7 +92,7 @@ lazy val pluginScalaVersions = Seq( // scalamacros paradise version used is not published for 2.12.0 and 2.12.1 "2.12.2", "2.12.3", - "2.12.4", + // 2.12.4 is broken in newer versions of Zinc: https://github.com/sbt/sbt/issues/6838 "2.12.5", "2.12.6", "2.12.7", diff --git a/project/build.properties b/project/build.properties index e64c208ff50..8b9a0b0ab03 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.8 +sbt.version=1.8.0 From 9f080d51d1e7bb9d44fb10da86fcaab68a21377b Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Mon, 5 Dec 2022 17:13:18 -0800 Subject: [PATCH 9/9] Add versionScheme (PVP) to SBT publish settings (#2871) This allows build tools to warn users about possible binary incompatibility issues when using dependencies that depend on mutually incompatible versions of Chisel. --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index ef6cb6c2ee2..9f97151b1b1 100644 --- a/build.sbt +++ b/build.sbt @@ -37,6 +37,7 @@ lazy val commonSettings = Seq( ) lazy val publishSettings = Seq( + versionScheme := Some("pvp"), publishMavenStyle := true, Test / publishArtifact := false, pomIncludeRepository := { x => false },