Skip to content

Commit

Permalink
fixup! [core] Add private Layer.layerSeq member function
Browse files Browse the repository at this point in the history
  • Loading branch information
seldridge committed Dec 11, 2024
1 parent 362d104 commit 75bf5b3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions core/src/main/scala/chisel3/Layer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,17 @@ object layer {
case _ => this.canWriteTo(that.parent)
}

/** Return a sequence of this layer and all its parents, excluding the root layer.
/** Return a list containg this layer and all its parents, excluding the root
* layer. The deepest layer (this layer) is the first element in the list.
*
* @return a sequence of all layers
*/
private[chisel3] def layerSeq: Seq[Layer] = {
var currentLayer: Layer = this
val layers = ArrayBuffer.empty[Layer]
while (currentLayer != Layer.Root) {
layers.addOne(currentLayer)
currentLayer = currentLayer.parent
private[chisel3] def layerSeq: List[Layer] = {
def rec(current: Layer, acc: List[Layer]): List[Layer] = current match {
case Layer.root => acc
case _ => rec(current.parent, current :: acc)
}
layers.reverse.toSeq
rec(this, Nil)
}
}

Expand Down

0 comments on commit 75bf5b3

Please sign in to comment.