Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for more general case of getConnectOrigin with reg feedback #301

Merged
merged 1 commit into from Sep 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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