aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAdam Izraelevitz2018-07-10 18:36:02 -0700
committerJack Koenig2018-07-10 18:36:02 -0700
commit6b02d09eb412df275d00930ab0e167b07fa61862 (patch)
treed2e9933d7cd7c13f09f9a085e9a1efb61aa48ecf /src/main
parenta0d23c1192712be1a5970bb70bb8f0cbafbe4e11 (diff)
Combinational Dependency Annotation (#809)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/firrtl/transforms/CheckCombLoops.scala22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/main/scala/firrtl/transforms/CheckCombLoops.scala b/src/main/scala/firrtl/transforms/CheckCombLoops.scala
index e1e6cf63..98033a2f 100644
--- a/src/main/scala/firrtl/transforms/CheckCombLoops.scala
+++ b/src/main/scala/firrtl/transforms/CheckCombLoops.scala
@@ -24,6 +24,14 @@ object CheckCombLoops {
case object DontCheckCombLoopsAnnotation extends NoTargetAnnotation
+case class CombinationalPath(sink: ComponentName, sources: Seq[ComponentName]) extends Annotation {
+ override def update(renames: RenameMap): Seq[Annotation] = {
+ val newSources = sources.flatMap { s => renames.get(s).getOrElse(Seq(s)) }
+ val newSinks = renames.get(sink).getOrElse(Seq(sink))
+ newSinks.map(snk => CombinationalPath(snk, newSources))
+ }
+}
+
/** Finds and detects combinational logic loops in a circuit, if any
* exist. Returns the input circuit with no modifications.
*
@@ -181,7 +189,7 @@ class CheckCombLoops extends Transform {
* and only if it combinationally depends on input Y. Associate this
* reduced graph with the module for future use.
*/
- private def run(c: Circuit): Circuit = {
+ private def run(c: Circuit): (Circuit, Seq[Annotation]) = {
val errors = new Errors()
/* TODO(magyar): deal with exmodules! No pass warnings currently
* exist. Maybe warn when iterating through modules.
@@ -211,8 +219,14 @@ class CheckCombLoops extends Transform {
errors.append(new CombLoopException(m.info, m.name, expandedCycle))
}
}
+ val mn = ModuleName(c.main, CircuitName(c.main))
+ val annos = simplifiedModuleGraphs(c.main).getEdgeMap.collect { case (from, tos) if tos.nonEmpty =>
+ val sink = ComponentName(from.name, mn)
+ val sources = tos.map(x => ComponentName(x.name, mn))
+ CombinationalPath(sink, sources.toSeq)
+ }
errors.trigger()
- c
+ (c, annos.toSeq)
}
def execute(state: CircuitState): CircuitState = {
@@ -221,8 +235,8 @@ class CheckCombLoops extends Transform {
logger.warn("Skipping Combinational Loop Detection")
state
} else {
- val result = run(state.circuit)
- CircuitState(result, outputForm, state.annotations, state.renames)
+ val (result, annos) = run(state.circuit)
+ CircuitState(result, outputForm, state.annotations ++ annos, state.renames)
}
}
}