One stumbling block was the use of parameters and lazy modules. Rocket uses the content dependent environment package for configuring its components. The project template repo offers some explanation on the use of the cake pattern (design pattern) for allowing configuration to complete before hardware elaboration begins (paraphrasing, here). Here is another thread that discusses the strategy.
On to some code (module elaboration only) ...
// Define your very own configuration object ... case object BlankField extends Field[Boolean] class BlankConfig extends Config((site, here, up) => { case BlankField => false }) // Pay close attention to use of LazyModule and LazyModuleImp ... object ChiselTopDriver extends App { implicit val p: Parameters = new BlankConfig chisel3.Driver.execute(args, () => LazyModule(new ChiselTop).module) } class ChiselTop()(implicit p: Parameters) extends LazyModule { val master = LazyModule(new AHBMaster) val slave = LazyModule(new AHBSlave) slave.node := master.node // does not work.. yet.. lazy val module = new LazyModuleImp(this) { val io = new Bundle { val ddrClock = Input(Clock()) val ddrReset = Input(UInt(1.W)) } } } class AHBMaster()(implicit p: Parameters) extends LazyModule { val node = AHBOutputNode() // does not work.. yet.. lazy val module = new LazyModuleImp(this) { val io = new Bundle { val out = node.bundleOut } } } class AHBSlave()(implicit p: Parameters) extends LazyModule { val node = AHBInputNode() // does not work.. yet.. lazy val module = new LazyModuleImp(this) { val io = new Bundle { val in = node.bundleIn } } }
No comments:
Post a Comment