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
- module
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
- 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