Case Class

apaj edited this page Sep 3, 2018 · 1 revision


A case class represents a special type of class in Scala that has the features:

  1. external access to the class parameters,
  2. eliminates the need to use new when instantiating the class
  3. automatically creates an unapply method that supplies access to all of the class Parameters,
  4. cannot be subclassed from.

It's often used to essentially create a data structure.


From RocketTiles.scala line 15:

case class RocketTileParams(
    core: RocketCoreParams = RocketCoreParams(),
    icache: Option[ICacheParams] = Some(ICacheParams()),
    dcache: Option[DCacheParams] = Some(DCacheParams()),
    rocc: Seq[RoCCParams] = Nil,
    btb: Option[BTBParams] = Some(BTBParams()),
    dataScratchpadBytes: Int = 0) extends TileParams {

Which is used this way:

class RocketTile(val rocketParams: RocketTileParams, val hartid: Int)(implicit p: Parameters) extends BaseTile(rocketParams)(p)
      val m = if (rocketParams.core.mulDiv.nonEmpty) "m" else ""
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.