Skip to content

Commit

Permalink
Fix for more general case of getConnectOrigin with reg feedback (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
shunshou authored and donggyukim committed Sep 15, 2016
1 parent 1fe291c commit 92c31ab
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/main/scala/firrtl/passes/AnnotateMemMacros.scala
Expand Up @@ -45,12 +45,7 @@ object AnalysisUtils {
// limitation: only works in a module (stops @ module inputs)
// TODO: more thorough (i.e. a + 0 = a)
def getConnectOrigin(connects: Map[String, Expression], node: String): Expression = {
if (connects contains node) {
val exp = connects(node)
// handles case when a node is connected to itself (connecting reg output back to input)
if (exp.serialize == node) exp
else getOrigin(connects, exp)
}
if (connects contains node) getOrigin(connects, connects(node))
else EmptyExpression
}

Expand All @@ -75,7 +70,8 @@ object AnalysisUtils {
else e
case DoPrim((PrimOps.AsUInt | PrimOps.AsSInt | PrimOps.AsClock), args, _, _) =>
getOrigin(connects, args.head)
case _: WRef | _: SubField | _: SubIndex | _: SubAccess if connects contains e.serialize =>
// note: this should stop on a reg, but will stack overflow for combinational loops (not allowed)
case _: WRef | _: SubField | _: SubIndex | _: SubAccess if connects.contains(e.serialize) && kind(e) != RegKind =>
getConnectOrigin(connects, e.serialize)
case _ => e
}
Expand Down

0 comments on commit 92c31ab

Please sign in to comment.