summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
diff options
context:
space:
mode:
authorJim Lawson2016-08-12 09:39:39 -0700
committerJim Lawson2016-08-12 09:59:02 -0700
commit8c8349e3eab69235f48826b59af8f67fe0b3e80c (patch)
tree4817e73f2886e2ed03dd59e870025f889ce57ab0 /chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
parent2a074c828ddd8e6c20fa21d618664d50120f3d7a (diff)
Add support for per-Module compilation options.
Nothing uses these now, but when we integrate Stephen's PR200, we'll need a way to selectively enable some strict connection checks on a file by file basis. We plan to do this using package imports which will define suitable compilation options.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/internal/Builder.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/internal/Builder.scala11
1 files changed, 8 insertions, 3 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala b/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
index cecbd91e..68dd269c 100644
--- a/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
+++ b/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
@@ -97,12 +97,16 @@ private[chisel3] trait HasId {
private[chisel3] def getRef: Arg = _ref.get
}
-private[chisel3] class DynamicContext {
+private[chisel3] class DynamicContext(optionMap: Option[Map[String, String]] = None) {
val idGen = new IdGen
val globalNamespace = new Namespace(None, Set())
val components = ArrayBuffer[Component]()
var currentModule: Option[Module] = None
val errors = new ErrorLog
+ val compileOptions = new CompileOptions(optionMap match {
+ case Some(map: Map[String, String]) => map
+ case None => Map[String, String]()
+ })
}
private[chisel3] object Builder {
@@ -115,6 +119,7 @@ private[chisel3] object Builder {
def globalNamespace: Namespace = dynamicContext.globalNamespace
def components: ArrayBuffer[Component] = dynamicContext.components
+ def compileOptions = dynamicContext.compileOptions
def pushCommand[T <: Command](c: T): T = {
dynamicContext.currentModule.foreach(_._commands += c)
c
@@ -124,8 +129,8 @@ private[chisel3] object Builder {
def errors: ErrorLog = dynamicContext.errors
def error(m: => String): Unit = errors.error(m)
- def build[T <: Module](f: => T): Circuit = {
- dynamicContextVar.withValue(Some(new DynamicContext)) {
+ def build[T <: Module](f: => T, optionMap: Option[Map[String, String]] = None): Circuit = {
+ dynamicContextVar.withValue(Some(new DynamicContext(optionMap))) {
errors.info("Elaborating design...")
val mod = f
mod.forceName(mod.name, globalNamespace)