summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chiselFrontend/src/main/scala/chisel3/internal/Builder.scala16
-rw-r--r--src/test/scala/chiselTests/ConnectSpec.scala28
2 files changed, 26 insertions, 18 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala b/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
index d6c3c5d6..360994b1 100644
--- a/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
+++ b/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
@@ -79,6 +79,10 @@ private[chisel3] trait HasId extends InstanceId {
private[chisel3] val _id: Long = Builder.idGen.next
+ // TODO: remove this, but its removal seems to cause a nasty Scala compiler crash.
+ override def hashCode: Int = super.hashCode()
+ override def equals(that: Any): Boolean = super.equals(that)
+
// Facilities for 'suggesting' a name to this.
// Post-name hooks called to carry the suggestion to other candidates as needed
private var suggested_name: Option[String] = None
@@ -200,7 +204,10 @@ private[chisel3] object Builder {
def annotations: ArrayBuffer[ChiselAnnotation] = dynamicContext.annotations
def namingStack: internal.naming.NamingStack = dynamicContext.namingStack
- def currentModule: Option[BaseModule] = dynamicContext.currentModule
+ def currentModule: Option[BaseModule] = dynamicContextVar.value match {
+ case Some(dyanmicContext) => dynamicContext.currentModule
+ case _ => None
+ }
def currentModule_=(target: Option[BaseModule]): Unit = {
dynamicContext.currentModule = target
}
@@ -284,9 +291,10 @@ private[chisel3] object Builder {
}
def errors: ErrorLog = dynamicContext.errors
- def error(m: => String): Unit = errors.error(m)
- def warning(m: => String): Unit = errors.warning(m)
- def deprecated(m: => String, location: Option[String] = None): Unit = errors.deprecated(m, location)
+ def error(m: => String): Unit = if (dynamicContextVar.value.isDefined) errors.error(m)
+ def warning(m: => String): Unit = if (dynamicContextVar.value.isDefined) errors.warning(m)
+ def deprecated(m: => String, location: Option[String] = None): Unit =
+ if (dynamicContextVar.value.isDefined) errors.deprecated(m, location)
/** Record an exception as an error, and throw it.
*
diff --git a/src/test/scala/chiselTests/ConnectSpec.scala b/src/test/scala/chiselTests/ConnectSpec.scala
index ac6508ef..51814998 100644
--- a/src/test/scala/chiselTests/ConnectSpec.scala
+++ b/src/test/scala/chiselTests/ConnectSpec.scala
@@ -41,58 +41,58 @@ class ConnectSpec extends ChiselPropSpec {
assertTesterPasses{ new CrossConnectTester(SInt(16.W), SInt(16.W)) }
}
property("SInt := UInt should fail") {
- intercept[ChiselException]{ new CrossConnectTester(UInt(16.W), SInt(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(UInt(16.W), SInt(16.W)) } }
}
property("SInt := FixedPoint should fail") {
- intercept[ChiselException]{ new CrossConnectTester(FixedPoint(16.W, 8.BP), UInt(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(FixedPoint(16.W, 8.BP), UInt(16.W)) } }
}
property("UInt := UInt should succeed") {
assertTesterPasses{ new CrossConnectTester(UInt(16.W), UInt(16.W)) }
}
property("UInt := SInt should fail") {
- intercept[ChiselException]{ new CrossConnectTester(SInt(16.W), UInt(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(SInt(16.W), UInt(16.W)) } }
}
property("UInt := FixedPoint should fail") {
- intercept[ChiselException]{ new CrossConnectTester(FixedPoint(16.W, 8.BP), UInt(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(FixedPoint(16.W, 8.BP), UInt(16.W)) } }
}
property("Clock := Clock should succeed") {
assertTesterPasses{ new CrossConnectTester(Clock(), Clock()) }
}
property("Clock := UInt should fail") {
- intercept[ChiselException]{ new CrossConnectTester(Clock(), UInt(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(Clock(), UInt(16.W)) } }
}
property("FixedPoint := FixedPoint should succeed") {
assertTesterPasses{ new CrossConnectTester(FixedPoint(16.W, 8.BP), FixedPoint(16.W, 8.BP)) }
}
property("FixedPoint := SInt should fail") {
- intercept[ChiselException]{ new CrossConnectTester(SInt(16.W), FixedPoint(16.W, 8.BP)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(SInt(16.W), FixedPoint(16.W, 8.BP)) } }
}
property("FixedPoint := UInt should fail") {
- intercept[ChiselException]{ new CrossConnectTester(UInt(16.W), FixedPoint(16.W, 8.BP)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(UInt(16.W), FixedPoint(16.W, 8.BP)) } }
}
property("Analog := Analog should fail") {
- intercept[ChiselException]{ new CrossConnectTester(Analog(16.W), Analog(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(Analog(16.W), Analog(16.W)) } }
}
property("Analog := FixedPoint should fail") {
- intercept[ChiselException]{ new CrossConnectTester(Analog(16.W), FixedPoint(16.W, 8.BP)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(Analog(16.W), FixedPoint(16.W, 8.BP)) } }
}
property("FixedPoint := Analog should fail") {
- intercept[ChiselException]{ new CrossConnectTester(FixedPoint(16.W, 8.BP), Analog(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(FixedPoint(16.W, 8.BP), Analog(16.W)) } }
}
property("Analog := UInt should fail") {
- intercept[ChiselException]{ new CrossConnectTester(Analog(16.W), UInt(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(Analog(16.W), UInt(16.W)) } }
}
property("Analog := SInt should fail") {
- intercept[ChiselException]{ new CrossConnectTester(Analog(16.W), SInt(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(Analog(16.W), SInt(16.W)) } }
}
property("UInt := Analog should fail") {
- intercept[ChiselException]{ new CrossConnectTester(UInt(16.W), Analog(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(UInt(16.W), Analog(16.W)) } }
}
property("SInt := Analog should fail") {
- intercept[ChiselException]{ new CrossConnectTester(SInt(16.W), Analog(16.W)) }
+ intercept[ChiselException]{ elaborate { new CrossConnectTester(SInt(16.W), Analog(16.W)) } }
}
property("Pipe internal connections should succeed") {
elaborate( new PipeInternalWires)