summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authormergify[bot]2022-12-07 00:41:55 +0000
committerGitHub2022-12-07 00:41:55 +0000
commit41d0d4cd075130cb6b4e41a7c7b6183830b5b9bc (patch)
tree1a97fffec711926237366ecb3aa8648c55245df9 /core
parentfa11cd7b807656fd3ab8ef62530d77f669584239 (diff)
Make PriorityMux stack safe (backport #2854) (#2855)
* Make PriorityMux stack safe (#2854) It used to be implemented with recursion, now it's implemented with a stack safe reverse and foldLeft. Also there were no tests for PriorityMux so I added one which helps prove the change is functionally correct. (cherry picked from commit 269ce472e9aa0c242fc028871a1fd5b045c82f83) # Conflicts: # src/test/scala/chiselTests/util/PipeSpec.scala * Resolve backport conflicts Co-authored-by: Jack Koenig <koenig@sifive.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/chisel3/SeqUtils.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/src/main/scala/chisel3/SeqUtils.scala b/core/src/main/scala/chisel3/SeqUtils.scala
index b1136120..9d975349 100644
--- a/core/src/main/scala/chisel3/SeqUtils.scala
+++ b/core/src/main/scala/chisel3/SeqUtils.scala
@@ -64,7 +64,10 @@ private[chisel3] object SeqUtils {
if (in.size == 1) {
in.head._2
} else {
- Mux(in.head._1, in.head._2, priorityMux(in.tail))
+ val r = in.view.reverse
+ r.tail.foldLeft(r.head._2) {
+ case (alt, (sel, elt)) => Mux(sel, elt, alt)
+ }
}
}