diff options
Diffstat (limited to 'src/main/scala/firrtl/annotations/Target.scala')
| -rw-r--r-- | src/main/scala/firrtl/annotations/Target.scala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/scala/firrtl/annotations/Target.scala b/src/main/scala/firrtl/annotations/Target.scala index 10c74e77..f33a8fdf 100644 --- a/src/main/scala/firrtl/annotations/Target.scala +++ b/src/main/scala/firrtl/annotations/Target.scala @@ -366,6 +366,9 @@ trait CompleteTarget extends Target { def addHierarchy(root: String, instance: String): IsComponent override def toTarget: CompleteTarget = this + + // Very useful for debugging, I (@azidar) think this is reasonable + override def toString = serialize } @@ -668,10 +671,14 @@ case class InstanceTarget(circuit: String, override def instOf(inst: String, of: String): InstanceTarget = InstanceTarget(circuit, module, asPath, inst, of) override def stripHierarchy(n: Int): IsModule = { - require(path.size >= n, s"Cannot strip $n levels of hierarchy from $this") + require(path.size + 1 >= n, s"Cannot strip $n levels of hierarchy from $this") if(n == 0) this else { - val newModule = path(n - 1)._2.value - InstanceTarget(circuit, newModule, path.drop(n), instance, ofModule) + if(path.size < n){ + ModuleTarget(circuit, ofModule) + } else { + val newModule = path(n - 1)._2.value + InstanceTarget(circuit, newModule, path.drop(n), instance, ofModule) + } } } |
