summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/internal
diff options
context:
space:
mode:
authorRichard Lin2017-07-28 14:45:09 -0700
committerAdam Izraelevitz2017-07-28 14:45:09 -0700
commit004938693112b2be268b0ee8d91874ba2d993ec3 (patch)
treedcacd98e6a66648f45f4d8aa5a3d5e351fe512ca /src/main/scala/chisel3/internal
parent2666b809a8964a3ec396714c36bd54469e943516 (diff)
Black box top-level IO fix (#655)
Diffstat (limited to 'src/main/scala/chisel3/internal')
-rw-r--r--src/main/scala/chisel3/internal/firrtl/Emitter.scala20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/scala/chisel3/internal/firrtl/Emitter.scala b/src/main/scala/chisel3/internal/firrtl/Emitter.scala
index 593052c7..c7a7f6a4 100644
--- a/src/main/scala/chisel3/internal/firrtl/Emitter.scala
+++ b/src/main/scala/chisel3/internal/firrtl/Emitter.scala
@@ -13,12 +13,17 @@ private[chisel3] object Emitter {
private class Emitter(circuit: Circuit) {
override def toString: String = res.toString
- private def emitPort(e: Port): String = {
- val dir = e.dir match {
+ private def emitPort(e: Port, topDir: UserDirection=UserDirection.Unspecified): String = {
+ val resolvedDir = UserDirection.fromParent(topDir, e.dir)
+ val dirString = resolvedDir match {
case UserDirection.Unspecified | UserDirection.Output => "output"
case UserDirection.Flip | UserDirection.Input => "input"
}
- s"$dir ${e.id.getRef.name} : ${emitType(e.id)}"
+ val clearDir = resolvedDir match {
+ case UserDirection.Input | UserDirection.Output => true
+ case UserDirection.Unspecified | UserDirection.Flip => false
+ }
+ s"$dirString ${e.id.getRef.name} : ${emitType(e.id, clearDir)}"
}
private def emitType(d: Data, clearDir: Boolean = false): String = d match {
@@ -101,8 +106,13 @@ private class Emitter(circuit: Circuit) {
private def moduleDefn(m: Component): String = {
val body = new StringBuilder
withIndent {
- for (p <- m.ports)
- body ++= newline + emitPort(p)
+ for (p <- m.ports) {
+ val portDef = m match {
+ case bb: DefBlackBox => emitPort(p, bb.topDir)
+ case mod: DefModule => emitPort(p)
+ }
+ body ++= newline + portDef
+ }
body ++= newline
m match {