1
0

More utils for nbdcache

This commit is contained in:
Henry Cook 2012-01-17 23:49:32 -08:00
parent 7e25749581
commit 29ed8eb31a

View File

@ -13,7 +13,7 @@ object foldR
object log2up
{
def apply(in: Int) = ceil(log(in)/log(2)).toInt
def apply(in: Int) = if (in == 1) 1 else ceil(log(in)/log(2)).toInt
}
object FillInterleaved
@ -38,6 +38,27 @@ object Reverse
}
}
object OHToUFix
{
def apply(in: Bits): UFix =
{
var out = UFix(0)
for(i <- 0 until in.getWidth)
if(in(i) == Bits(1))
out = UFix(i)
out
}
}
object UFixToOH
{
def apply(in: UFix, width: Int): Bits =
{
val out = Bits(1, width)
out << in
}
}
class Mux1H(n: Int, w: Int) extends Component
{
val io = new Bundle {