summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman2016-10-05 14:16:13 -0700
committerAndrew Waterman2016-10-05 16:04:45 -0700
commita18002c879d14b6c51cd49311a3b2a99a6a204fc (patch)
tree1954d414a3f5e274edb429c9d9c9186cfd8438f7
parent0878b7a7d30038797e3711ad2d44ab0bc753bab1 (diff)
Give <> and := legacy behavior in compatibility mode
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala2
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Bits.scala5
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala4
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Data.scala45
-rw-r--r--src/test/scala/chiselTests/CompileOptionsTest.scala2
5 files changed, 39 insertions, 19 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
index 5cec54c2..98455f4d 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
@@ -17,6 +17,8 @@ import chisel3.internal.sourceinfo.{SourceInfo, DeprecatedSourceInfo, VecTransfo
sealed abstract class Aggregate extends Data {
private[core] def cloneTypeWidth(width: Width): this.type = cloneType
private[core] def width: Width = flatten.map(_.width).reduce(_ + _)
+ private[core] def legacyConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit =
+ pushCommand(BulkConnect(sourceInfo, this.lref, that.lref))
}
object Vec {
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
index 24abbdba..741f6aee 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
@@ -5,7 +5,7 @@ package chisel3.core
import scala.language.experimental.macros
import chisel3.internal._
-import chisel3.internal.Builder.pushOp
+import chisel3.internal.Builder.{pushCommand, pushOp}
import chisel3.internal.firrtl._
import chisel3.internal.sourceinfo.{SourceInfo, DeprecatedSourceInfo, SourceInfoTransform, SourceInfoWhiteboxTransform,
UIntTransform, MuxTransform}
@@ -40,6 +40,9 @@ abstract class Element(private[core] val width: Width) extends Data {
private[chisel3] final def allElements: Seq[Element] = Seq(this)
def widthKnown: Boolean = width.known
def name: String = getRef.name
+
+ private[core] def legacyConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit =
+ pushCommand(Connect(sourceInfo, this.lref, that.ref))
}
/** A data type for values represented by a single bitvector. Provides basic
diff --git a/chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala b/chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala
index 85aa8cdc..4dea39b5 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala
@@ -20,6 +20,8 @@ trait CompileOptions {
// Issue a deprecation warning if Data.{flip, asInput,asOutput} is used
// instead of Flipped, Input, or Output.
val deprecateOldDirectionMethods: Boolean
+ // Check that referenced Data have actually been declared.
+ val checkSynthesizable: Boolean
}
object CompileOptions {
@@ -38,6 +40,7 @@ object ExplicitCompileOptions {
val dontTryConnectionsSwapped = false
val dontAssumeDirectionality = false
val deprecateOldDirectionMethods = false
+ val checkSynthesizable = false
}
// Collection of "strict" connection compile options, preferred for new code.
@@ -49,5 +52,6 @@ object ExplicitCompileOptions {
val dontTryConnectionsSwapped = true
val dontAssumeDirectionality = true
val deprecateOldDirectionMethods = true
+ val checkSynthesizable = true
}
}
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
index 922b33a9..4167be98 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
@@ -135,27 +135,35 @@ abstract class Data extends HasId {
private[core] def badConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit =
throwException(s"cannot connect ${this} and ${that}")
private[chisel3] def connect(that: Data)(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): Unit = {
- Binding.checkSynthesizable(this, s"'this' ($this)")
- Binding.checkSynthesizable(that, s"'that' ($that)")
- try {
- MonoConnect.connect(sourceInfo, connectCompileOptions, this, that, Builder.forcedModule)
- } catch {
- case MonoConnect.MonoConnectException(message) =>
- throwException(
- s"Connection between sink ($this) and source ($that) failed @$message"
- )
+ if (connectCompileOptions.checkSynthesizable) {
+ Binding.checkSynthesizable(this, s"'this' ($this)")
+ Binding.checkSynthesizable(that, s"'that' ($that)")
+ try {
+ MonoConnect.connect(sourceInfo, connectCompileOptions, this, that, Builder.forcedModule)
+ } catch {
+ case MonoConnect.MonoConnectException(message) =>
+ throwException(
+ s"Connection between sink ($this) and source ($that) failed @$message"
+ )
+ }
+ } else {
+ this legacyConnect that
}
}
private[chisel3] def bulkConnect(that: Data)(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): Unit = {
- Binding.checkSynthesizable(this, s"'this' ($this)")
- Binding.checkSynthesizable(that, s"'that' ($that)")
- try {
- BiConnect.connect(sourceInfo, connectCompileOptions, this, that, Builder.forcedModule)
- } catch {
- case BiConnect.BiConnectException(message) =>
- throwException(
- s"Connection between left ($this) and source ($that) failed @$message"
- )
+ if (connectCompileOptions.checkSynthesizable) {
+ Binding.checkSynthesizable(this, s"'this' ($this)")
+ Binding.checkSynthesizable(that, s"'that' ($that)")
+ try {
+ BiConnect.connect(sourceInfo, connectCompileOptions, this, that, Builder.forcedModule)
+ } catch {
+ case BiConnect.BiConnectException(message) =>
+ throwException(
+ s"Connection between left ($this) and source ($that) failed @$message"
+ )
+ }
+ } else {
+ this legacyConnect that
}
}
private[chisel3] def lref: Node = Node(this)
@@ -163,6 +171,7 @@ abstract class Data extends HasId {
private[core] def cloneTypeWidth(width: Width): this.type
private[chisel3] def toType: String
private[core] def width: Width
+ private[core] def legacyConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit
def cloneType: this.type
def chiselCloneType: this.type = {
diff --git a/src/test/scala/chiselTests/CompileOptionsTest.scala b/src/test/scala/chiselTests/CompileOptionsTest.scala
index 66a9dcc0..57ceff3f 100644
--- a/src/test/scala/chiselTests/CompileOptionsTest.scala
+++ b/src/test/scala/chiselTests/CompileOptionsTest.scala
@@ -23,6 +23,7 @@ class CompileOptionsSpec extends ChiselFlatSpec {
val dontTryConnectionsSwapped = true
val dontAssumeDirectionality = true
val deprecateOldDirectionMethods = true
+ val checkSynthesizable = true
}
class SmallBundle extends Bundle {
@@ -267,6 +268,7 @@ class CompileOptionsSpec extends ChiselFlatSpec {
val dontTryConnectionsSwapped = true
val dontAssumeDirectionality = true
val deprecateOldDirectionMethods = false
+ val checkSynthesizable = true
}
}