diff options
| author | Jim Lawson | 2016-08-12 14:17:52 -0700 |
|---|---|---|
| committer | Jim Lawson | 2016-08-12 14:17:52 -0700 |
| commit | 4ab2aa0e9209000fb0ba1299ac18db2e033f708f (patch) | |
| tree | 39196e284bcf1d06149fa12d61fe63bb34071f6a /chiselFrontend | |
| parent | 8c919f86fec33f1cdb367ae5e13f0cb7d5071ef5 (diff) | |
Use compileOptions to determine if Missing...FieldExceptions are thrown.
Diffstat (limited to 'chiselFrontend')
3 files changed, 20 insertions, 8 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/BiConnect.scala b/chiselFrontend/src/main/scala/chisel3/core/BiConnect.scala index cb76159a..71de50f6 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/BiConnect.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/BiConnect.scala @@ -1,9 +1,9 @@ package chisel3.core -import chisel3.internal.Builder.pushCommand +import chisel3.internal.Builder.{compileOptions, pushCommand} import chisel3.internal.firrtl.Connect import scala.language.experimental.macros -import chisel3.internal.sourceinfo.{SourceInfo, DeprecatedSourceInfo, UnlocatableSourceInfo, WireTransform, SourceInfoTransform} +import chisel3.internal.sourceinfo._ /** * BiConnect.connect executes a bidirectional connection element-wise. @@ -69,14 +69,22 @@ object BiConnect { case (left_b: Bundle, right_b: Bundle) => { // Verify right has no extra fields that left doesn't have for((field, right_sub) <- right_b.elements) { - if(!left_b.elements.isDefinedAt(field)) throw MissingLeftFieldException(field) + if(!left_b.elements.isDefinedAt(field)) { + if (compileOptions.connectFieldsMustMatch) { + throw MissingLeftFieldException(field) + } + } } // For each field in left, descend with right for((field, left_sub) <- left_b.elements) { try { right_b.elements.get(field) match { case Some(right_sub) => connect(sourceInfo, left_sub, right_sub, context_mod) - case None => throw MissingRightFieldException(field) + case None => { + if (compileOptions.connectFieldsMustMatch) { + throw MissingRightFieldException(field) + } + } } } catch { case BiConnectException(message) => throw BiConnectException(s".$field$message") diff --git a/chiselFrontend/src/main/scala/chisel3/core/MonoConnect.scala b/chiselFrontend/src/main/scala/chisel3/core/MonoConnect.scala index 64c71cb2..bf8e7e28 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/MonoConnect.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/MonoConnect.scala @@ -1,9 +1,9 @@ package chisel3.core -import chisel3.internal.Builder.pushCommand +import chisel3.internal.Builder.{compileOptions, pushCommand} import chisel3.internal.firrtl.Connect import scala.language.experimental.macros -import chisel3.internal.sourceinfo.{SourceInfo, DeprecatedSourceInfo, UnlocatableSourceInfo, WireTransform, SourceInfoTransform} +import chisel3.internal.sourceinfo.{DeprecatedSourceInfo, SourceInfo, SourceInfoTransform, UnlocatableSourceInfo, WireTransform} /** * MonoConnect.connect executes a mono-directional connection element-wise. @@ -78,7 +78,11 @@ object MonoConnect { try { source_b.elements.get(field) match { case Some(source_sub) => connect(sourceInfo, sink_sub, source_sub, context_mod) - case None => throw MissingFieldException(field) + case None => { + if (compileOptions.connectFieldsMustMatch) { + throw MissingFieldException(field) + } + } } } catch { case MonoConnectException(message) => throw MonoConnectException(s".$field$message") diff --git a/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala b/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala index dddc261e..9f2b1631 100644 --- a/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala +++ b/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala @@ -118,6 +118,7 @@ private[chisel3] object Builder { def idGen: IdGen = dynamicContext.idGen def globalNamespace: Namespace = dynamicContext.globalNamespace def components: ArrayBuffer[Component] = dynamicContext.components + def compileOptions = dynamicContext.compileOptions def currentModule: Option[Module] = dynamicContext.currentModule def currentModule_=(target: Option[Module]): Unit = { @@ -133,7 +134,6 @@ private[chisel3] object Builder { // TODO(twigg): Ideally, binding checks and new bindings would all occur here // However, rest of frontend can't support this yet. - def compileOptions = dynamicContext.compileOptions def pushCommand[T <: Command](c: T): T = { forcedModule._commands += c c |
