From dafdeab614a5106dac4d80e147fdbc2770053e1b Mon Sep 17 00:00:00 2001 From: Richard Lin Date: Wed, 3 Oct 2018 16:15:37 -0700 Subject: Add DataMirror.modulePorts (#901) --- chiselFrontend/src/main/scala/chisel3/core/Module.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'chiselFrontend/src/main/scala/chisel3/core/Module.scala') 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. * -- cgit v1.2.3