More utils for nbdcache
This commit is contained in:
parent
7e25749581
commit
29ed8eb31a
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user