Skip to content

Commit 3425a8c

Browse files
authored
Deprecate Chisel._ Compatibility Mode (#2668)
1 parent 28e3582 commit 3425a8c

9 files changed

+204
-17
lines changed

docs/src/appendix/chisel3-vs-chisel2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ section: "chisel3"
99
import chisel3._
1010
```
1111

12+
**Note** Chisel2 Compatibility Mode is entirely deprecated in 3.6, so this entire page is relevant only for 3.6 and earlier.
13+
1214
## Chisel2 Migration
1315
For those moving from Chisel2, there were some backwards incompatible changes
1416
and your RTL needs to be modified to work with Chisel3. The required

src/main/scala/chisel3/compatibility.scala

Lines changed: 175 additions & 15 deletions
Large diffs are not rendered by default.

src/main/scala/chisel3/util/Math.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ object log2Up {
2727
// https://github.com/freechipsproject/chisel3/issues/847
2828
//@chiselRuntimeDeprecated
2929
//@deprecated("Use log2Ceil instead", "chisel3")
30-
def apply(in: BigInt): Int = Chisel.log2Up(in)
30+
def apply(in: BigInt): Int = {
31+
require(in >= 0)
32+
1.max((in - 1).bitLength)
33+
}
34+
def apply(in: Int): Int = apply(BigInt(in))
3135
}
3236

3337
/** Compute the log2 of a Scala integer, rounded up.
@@ -66,7 +70,8 @@ object log2Down {
6670
// https://github.com/freechipsproject/chisel3/issues/847
6771
//@chiselRuntimeDeprecated
6872
//@deprecated("Use log2Floor instead", "chisel3")
69-
def apply(in: BigInt): Int = Chisel.log2Down(in)
73+
def apply(in: BigInt): Int = log2Up(in) - (if (isPow2(in)) 0 else 1)
74+
def apply(in: Int): Int = apply(BigInt(in))
7075
}
7176

7277
/** Compute the log2 of a Scala integer, rounded down.

src/test/scala/chiselTests/BulkConnectSpec.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import chisel3.util.Decoupled
55
import chisel3.stage.ChiselStage
66
import chisel3.testers.BasicTester
77

8+
import scala.annotation.nowarn
9+
810
class BulkConnectSpec extends ChiselPropSpec {
911
property("Chisel connects should emit FIRRTL bulk connects when possible") {
1012
val chirrtl = ChiselStage.emitChirrtl(new Module {
@@ -22,6 +24,7 @@ class BulkConnectSpec extends ChiselPropSpec {
2224
}
2325

2426
property("Chisel connects should not emit FIRRTL bulk connects for Stringly-typed connections") {
27+
@nowarn("msg=Chisel compatibility mode is deprecated")
2528
object Foo {
2629
import Chisel._
2730
// Chisel._ bundle

src/test/scala/chiselTests/CompatibilityInteroperabilitySpec.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ package chiselTests
55
import scala.collection.immutable.ListMap
66
import chisel3.stage.ChiselStage.emitChirrtl
77

8+
import scala.annotation.nowarn
9+
810
// Keep Chisel._ separate from chisel3._ below
11+
@nowarn("msg=Chisel compatibility mode is deprecated")
912
object CompatibilityComponents {
1013
import Chisel._
1114
import Chisel3Components._
@@ -75,6 +78,7 @@ object Chisel3Components {
7578
class Chisel3ModuleChiselRecordB extends Chisel3PassthroughModule(Flipped(new ChiselRecord))
7679
}
7780

81+
@nowarn("msg=Chisel compatibility mode is deprecated")
7882
class CompatibilityInteroperabilitySpec extends ChiselFlatSpec {
7983

8084
"Modules defined in the Chisel._" should "successfully bulk connect in chisel3._" in {

src/test/scala/chiselTests/CompatibilitySpec.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import org.scalacheck.Gen
99
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
1010

1111
import scala.collection.immutable.ListMap
12+
import scala.annotation.nowarn
1213

1314
// Need separate import to override compile options from Chisel._
15+
@nowarn("msg=Chisel compatibility mode is deprecated")
1416
object CompatibilityCustomCompileOptions {
1517
import Chisel.{defaultCompileOptions => _, _}
1618
implicit val customCompileOptions =
@@ -20,6 +22,7 @@ object CompatibilityCustomCompileOptions {
2022
}
2123
}
2224

25+
@nowarn("msg=Chisel compatibility mode is deprecated")
2326
class CompatibilitySpec extends ChiselFlatSpec with ScalaCheckDrivenPropertyChecks with Utils {
2427
import Chisel._
2528

src/test/scala/chiselTests/CompileOptionsTest.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import chisel3._
66
import chisel3.CompileOptions._
77
import chisel3.stage.ChiselStage
88

9+
import scala.annotation.nowarn
10+
11+
@nowarn("msg=Chisel compatibility mode is deprecated")
912
class CompileOptionsSpec extends ChiselFlatSpec with Utils {
1013

1114
abstract class StrictModule extends Module()(chisel3.ExplicitCompileOptions.Strict)

src/test/scala/chiselTests/MigrateCompileOptionsSpec.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import chisel3.ExplicitCompileOptions
88

99
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
1010

11+
import scala.annotation.nowarn
12+
13+
@nowarn("msg=Chisel compatibility mode is deprecated")
1114
object MigrationExamples {
1215
object InferResets {
1316
import Chisel.{defaultCompileOptions => _, _}
@@ -86,6 +89,7 @@ object MigrationExamples {
8689
}
8790
}
8891

92+
@nowarn("msg=Chisel compatibility mode is deprecated")
8993
class MigrateCompileOptionsSpec extends ChiselFunSpec with Utils {
9094
import Chisel.{defaultCompileOptions => _, _}
9195
import chisel3.RequireSyncReset

src/test/scala/chiselTests/ModuleExplicitResetSpec.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ package chiselTests
44

55
import chisel3.stage.ChiselStage
66

7+
import scala.annotation.nowarn
8+
9+
@nowarn("msg=Chisel compatibility mode is deprecated")
710
class ModuleExplicitResetSpec extends ChiselFlatSpec {
811

912
"A Module with an explicit reset in compatibility mode" should "elaborate" in {

0 commit comments

Comments
 (0)