1
0

Better foldR

This commit is contained in:
Henry Cook
2012-02-25 15:27:09 -08:00
parent df97de0fd3
commit db6d480778
2 changed files with 18 additions and 15 deletions

View File

@ -5,10 +5,11 @@ import Chisel._
import Node._
import scala.math._
object foldR
{
def apply[T <: Bits](x: Seq[T], f: (T, T) => T): T =
if (x.length == 1) x(0) else f(x(0), foldR(x.slice(1, x.length), f))
def apply[T <: Bits](x: Seq[T])(f: (T, T) => T): T =
if (x.length == 1) x(0) else f(x(0), foldR(x.slice(1, x.length))(f))
}
object log2up