Friday, April 14, 2017

Parameters and lazy modules

I haven't looked at rocket chip in ~2 years or so.  Wow, did it grow in complexity.  One area where I am lacking familiarily (and where documentation is notably absent) is in the use of TileLink2.  For the purpose of learning and exploration, I'll take it one step at a time and try to connect a single AHB master to an AHB slave using TileLink.

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

4 comments:

  1. Replies
    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Excellent Articles are shared!!! Here I Grasp lots of things Regarding Technically for My feature reference.Looking for More Updates
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete