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

Clone child elements lazily in Vec (bp #1329) #1333

Merged
merged 2 commits into from
Feb 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions chiselFrontend/src/main/scala/chisel3/Aggregate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,12 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int)
// Note: the constructor takes a gen() function instead of a Seq to enforce
// that all elements must be the same and because it makes FIRRTL generation
// simpler.
private val self: Seq[T] = Vector.fill(length)(gen)
for ((elt, i) <- self.zipWithIndex)
elt.setRef(this, i)
private lazy val self: Seq[T] = {
val _self = Vector.fill(length)(gen)
for ((elt, i) <- _self.zipWithIndex)
elt.setRef(this, i)
_self
}

/**
* sample_element 'tracks' all changes to the elements.
Expand Down