summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Module.scala
diff options
context:
space:
mode:
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Module.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Module.scala25
1 files changed, 14 insertions, 11 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Module.scala b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
index ca391091..76a3b240 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Module.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
@@ -14,7 +14,7 @@ object Module {
/** A wrapper method that all Module instantiations must be wrapped in
* (necessary to help Chisel track internal state).
*
- * @param m the Module being created
+ * @param bc the Module being created
*
* @return the input module `m` with Chisel metadata properly set
*/
@@ -41,8 +41,16 @@ object Module {
sourceInfo.makeMessage(" See " + _))
}
Builder.currentModule = parent // Back to parent!
+
val ports = m.computePorts
- val component = Component(m, m.name, ports, m._commands)
+ // Blackbox inherits from Module so we have to match on it first TODO fix
+ val component = m match {
+ case bb: BlackBox =>
+ DefBlackBox(bb, bb.name, ports, bb.params)
+ case mod: Module =>
+ mod._commands.prepend(DefInvalid(childSourceInfo, mod.io.ref)) // init module outputs
+ DefModule(mod, mod.name, ports, mod._commands)
+ }
m._component = Some(component)
Builder.components += component
// Avoid referencing 'parent' in top module
@@ -77,6 +85,10 @@ extends HasId {
iodef
}
+ def annotate(annotation: ChiselAnnotation): Unit = {
+ Builder.annotations += annotation
+ }
+
private[core] var ioDefined: Boolean = false
/**
@@ -116,18 +128,9 @@ extends HasId {
/** Legalized name of this module. */
final val name = Builder.globalNamespace.name(desiredName)
- /** FIRRTL Module name */
- private var _modName: Option[String] = None
- private[chisel3] def setModName(name: String) = _modName = Some(name)
- def modName = _modName match {
- case Some(name) => name
- case None => throwException("modName should be called after circuit elaboration")
- }
-
/** Keep component for signal names */
private[chisel3] var _component: Option[Component] = None
-
/** Signal name (for simulation). */
override def instanceName =
if (_parent == None) name else _component match {