summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Module.scala
diff options
context:
space:
mode:
authorRichard Lin2018-10-03 16:15:37 -0700
committerGitHub2018-10-03 16:15:37 -0700
commitdafdeab614a5106dac4d80e147fdbc2770053e1b (patch)
treeefd4ae2f9b612e55c87227851813afb6644ddd3a /chiselFrontend/src/main/scala/chisel3/core/Module.scala
parentb87e6cf65920832c5a0d908b9862edcccf5cae5d (diff)
Add DataMirror.modulePorts (#901)
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Module.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Module.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Module.scala b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
index 399f0462..88013bae 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Module.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
@@ -187,6 +187,22 @@ abstract class BaseModule extends HasId {
*/
final def toNamed: ModuleName = ModuleName(this.name, CircuitName(this.circuitName))
+ /**
+ * Internal API. Returns a list of this module's generated top-level ports as a map of a String
+ * (FIRRTL name) to the IO object. Only valid after the module is closed.
+ *
+ * Note: for BlackBoxes (but not ExtModules), this returns the contents of the top-level io
+ * object, consistent with what is emitted in FIRRTL.
+ *
+ * TODO: Use SeqMap/VectorMap when those data structures become available.
+ */
+ private[core] def getChiselPorts: Seq[(String, Data)] = {
+ require(_closed, "Can't get ports before module close")
+ _component.get.ports.map { port =>
+ (port.id.getRef.asInstanceOf[ModuleIO].name, port.id)
+ }
+ }
+
/** Called at the Module.apply(...) level after this Module has finished elaborating.
* Returns a map of nodes -> names, for named nodes.
*