Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Latest commit

 

History

History
47 lines (35 loc) · 1.66 KB

cake_pattern.md

File metadata and controls

47 lines (35 loc) · 1.66 KB

Cake pattern

Some notes of the cake pattern used in Rocket.


  • Class combination

For a design that uses cake pattern, 3 classes are needed.

  • abstract class Design(implicit p: Parameters) extends LazyModule with BindingScope
    The design generator (LazyModule).
    • module LazyModuleImp
  • class DesignBundle[+L <: Design](_outer: L) extends GenericParameterizedBundle(_outer)
    The I/O (bundle) definition of the design.
  • class DesignModule[+L <: Design, +B <: DesignBundle[L]](_outer: L, _io: () => B) extends LazyModuleImp(_outer)
    The actual Chisel module that will be generated by the design generator.

Here is the cake pattern for the BaseCoreplex module:

abstract class BaseCoreplex(implicit p: Parameters) extends BareCoreplex
    with CoreplexNetwork
    with BankedL2CoherenceManagers {
  override lazy val module = new BaseCoreplexModule(this, () => new BaseCoreplexBundle(this))
}

class BaseCoreplexBundle[+L <: BaseCoreplex](_outer: L) extends BareCoreplexBundle(_outer)
    with CoreplexNetworkBundle
    with BankedL2CoherenceManagersBundle

class BaseCoreplexModule[+L <: BaseCoreplex, +B <: BaseCoreplexBundle[L]](_outer: L, _io: () => B) extends BareCoreplexModule(_outer, _io)
    with CoreplexNetworkModule
    with BankedL2CoherenceManagersModule

extra notes

  • use module in LazyModule as a virtual variable, to enforce types. See the derived declaration in HasXXXX traits.




Last updated: 14/08/2017
CC BY-NC-SA 4.0, © (2017) Wei Song