tilelink2 Fuzzer: work around for firrtl/verilator performance issue
Big Vec()s cause very slow compilation.
This commit is contained in:
parent
1e7480b6fc
commit
ed038678ef
@ -14,23 +14,22 @@ class IDMapGenerator(numIds: Int) extends Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// True indicates that the id is available
|
// True indicates that the id is available
|
||||||
val bitmap = RegInit(Vec.fill(numIds){Bool(true)})
|
val bitmap = RegInit(UInt((BigInt(1) << numIds) - 1, width = numIds))
|
||||||
|
|
||||||
io.free.ready := Bool(true)
|
io.free.ready := Bool(true)
|
||||||
assert (!io.free.valid || !bitmap(io.free.bits)) // No double freeing
|
assert (!io.free.valid || !bitmap(io.free.bits)) // No double freeing
|
||||||
|
|
||||||
val mask = bitmap.scanLeft(Bool(false))(_||_).init
|
val select = ~(highOR(bitmap) << 1) & bitmap
|
||||||
val select = mask zip bitmap map { case(m,b) => !m && b }
|
|
||||||
io.alloc.bits := OHToUInt(select)
|
io.alloc.bits := OHToUInt(select)
|
||||||
io.alloc.valid := bitmap.reduce(_||_)
|
io.alloc.valid := bitmap.orR()
|
||||||
|
|
||||||
when (io.alloc.fire()) {
|
val clr = Wire(init = UInt(0, width = numIds))
|
||||||
bitmap(io.alloc.bits) := Bool(false)
|
when (io.alloc.fire()) { clr := UIntToOH(io.alloc.bits) }
|
||||||
}
|
|
||||||
|
|
||||||
when (io.free.fire()) {
|
val set = Wire(init = UInt(0, width = numIds))
|
||||||
bitmap(io.free.bits) := Bool(true)
|
when (io.free.fire()) { set := UIntToOH(io.free.bits) }
|
||||||
}
|
|
||||||
|
bitmap := (bitmap & ~clr) | set
|
||||||
}
|
}
|
||||||
|
|
||||||
object LFSR64
|
object LFSR64
|
||||||
|
@ -10,6 +10,12 @@ package object tilelink2
|
|||||||
def OH1ToUInt(x: UInt) = OHToUInt((x << 1 | UInt(1)) ^ x)
|
def OH1ToUInt(x: UInt) = OHToUInt((x << 1 | UInt(1)) ^ x)
|
||||||
def UIntToOH1(x: UInt, width: Int) = ~(SInt(-1, width=width).asUInt << x)(width-1, 0)
|
def UIntToOH1(x: UInt, width: Int) = ~(SInt(-1, width=width).asUInt << x)(width-1, 0)
|
||||||
def trailingZeros(x: Int) = if (x > 0) Some(log2Ceil(x & -x)) else None
|
def trailingZeros(x: Int) = if (x > 0) Some(log2Ceil(x & -x)) else None
|
||||||
|
def highOR(x: UInt) = {
|
||||||
|
val w = x.getWidth
|
||||||
|
def helper(s: Int, x: UInt): UInt =
|
||||||
|
if (s >= w) x else helper(s+s, x | x << s)
|
||||||
|
helper(1, x)
|
||||||
|
}
|
||||||
|
|
||||||
def sourceLine(sourceInfo: SourceInfo, prefix: String = " (", suffix: String = ")") = sourceInfo match {
|
def sourceLine(sourceInfo: SourceInfo, prefix: String = " (", suffix: String = ")") = sourceInfo match {
|
||||||
case SourceLine(filename, line, col) => s"$prefix$filename:$line:$col$suffix"
|
case SourceLine(filename, line, col) => s"$prefix$filename:$line:$col$suffix"
|
||||||
|
Loading…
Reference in New Issue
Block a user