[Question] Some doubt about using Lazymodule and LazyModuleImp?

117 views
Skip to first unread message

goal Raul

unread,
Jan 15, 2018, 8:34:49 AM1/15/18
to RISC-V HW Dev
Hi,

I study some implementations in rocket chip and follow it to complete my project.
However, some questions emerge from processing my project.

The purpose of my project is to generate blockdevice system and attach it on rocket system.

My partial implementation code:

class System (address: BigInt)(implicit p: Parameters) extends LazyModule{
  
  val mmio  = TLIdentityNode()
  val tobus  = TLIdentityNode()

  val frontend = LazyModule(new SystemTLFrontend(SystemParams(address))(p))
  frontend.node := mmio

  val tobusend = LazyModule(new SystemBackend(address))
  tobus := tobusend.node
    
  lazy val module = new LazyModuleImp(this){ }
}

When I go to build the emulator, there are some errors happen.
error: 
Caused by: java.lang.IllegalArgumentException: requirement failed: tobusend.node (System.scala:176:28) was incorrectly connected as a source at System.scala:177:9

On the other hand, I rearrange two statements as shown below:

class System (address: BigInt)(implicit p: Parameters) extends LazyModule{
  
  val mmio  = TLIdentityNode()
  val tobus  = TLIdentityNode()

  val frontend = LazyModule(new SystemTLFrontend(SystemParams(address))(p))
  frontend.node := mmio

  lazy val module = new LazyModuleImp(this){ 

    val tobusend = LazyModule(new SystemBackend(address))
    tobus := tobusend.node
  }

}

It could pass compile without error.

But I still cannot realize the reason with such revision. 
For my realization,  lazy val module = new LazyModuleImp(this){ ....}
 is as implementation part that can declare IO ports, etc. 
 
The below two line may put outside LazyModuleImp from my comprehension with studying rocket chip source code.

val tobusend = LazyModule(new SystemBackend(address))
 tobus := tobusend.node

Can anyone gives me some answers?

kritik bhimani

unread,
Jan 15, 2018, 10:12:13 AM1/15/18
to RISC-V HW Dev
connections between nodes is not made inside LazyModuleImp. LazyModuleImp is used to operate on the bundles/io wires of the nodes just like your normal Module. You have to make graph(DAG) of nodes outside it i.e. inside LazyModule. This is why you have LazyModule and LazyModuleImp

From your error it seems that tobusend.node is a manager node and not a client node and so you have connected it wrong.
manager.node := client.node
If you give details of SystemBackend then I can help you better

Reply all
Reply to author
Forward
0 new messages