I was trying to understand the implementation of the AsyncQueue in the RocketChip , and quite puzzled by the use of option method on Boolean data type (not Option). In the code we have a parametr class :
case class AsyncQueueParams(
depth: Int = 8,
sync: Int = 3,
safe: Boolean = true,
narrow: Boolean = false)
{
require (depth > 0 && isPow2(depth))
require (sync >= 2)
val bits = log2Ceil(depth)
val wires = if (narrow) 1 else depth
}
Then when the above is used:
class AsyncBundle[T <: Data](private val gen: T, val params: AsyncQueueParams = AsyncQueueParams()) extends Bundle {
val mem = Output(Vec(params.wires, gen))
val ridx = Input (UInt((params.bits+1).W))
val widx = Output(UInt((params.bits+1).W))
val index = params.narrow.option(Input(UInt(params.bits.W)))
// Signals used to self-stabilize a safe AsyncQueue
val safe = params.safe.option(new AsyncBundleSafety) // <--- Never seen use of option !!
}
Now, I can guess what was the intention here, to condition the creation of the val safe & narrow. My question is where this option is defined ? I have looked at the scala docs for Boolean. I don't see option as a member of class Boolean. Can someone explain this please ?