title: How to correctly pass implicit parameters to a module?
body: <p>I'm trying to pass implicit parameters to a submodule in an instantiated module. The implicit parameter is the config package defined in rocketchip<a href="https://github.com/chipsalliance/api-config-chipsalliance/blob/fd8df1105a92065425cd353b6855777e35bd79b4/design/craft/src/config/Config.scala" rel="nofollow noreferrer">enter link description here</a>, I want to use the config package to pass some constants to submodules.But when I use the module instantiation, the port I define in the submodule is always not found.</p>
  <p>The top-level module is defined as follows：</p>
  <pre><code>package test
  import chisel3._
  import chisel3.util._
  import chisel3.experimental.BaseModule
  import chipsalliance.rocketchip.config._
  class B extends Module{
    val io = IO(
       ...)
    val config = new TConfig
    val submod: Class[_ &lt;: Any] = Class.forName(&quot;test.T&quot;).asInstanceOf[Class[_ &lt;: BaseModule]]
    val u_T = Module(submod.getConstructor(classOf[Parameters]).newInstance(config) match {
      case a: RawModule =&gt; a
    })
     u_T.io &lt;&gt; ...
  }
  </code></pre>
  <p>Define submodule and its parameters：</p>
  <pre><code>case class TParams(
    P: Int = 100
  )
  
  case object TKey extends Field[TParams()]
  
  class TConfig extends Config((site, up, here) =&gt; {
    case TKey =&gt; {
      TParams(P=1024)
  }
  })
  
  abstract class TModule(implicit val p: Parameters) extends Module
  with HasParameters
  
  trait HasParameters {
   implicit val p: Parameters
  }
  
  class T(implicit p: Parameters) extends TModule()(p)
  {
    val io = IO(new Bundle{...})
  }
  </code></pre>
  <p>When compiling, the report shows that I cannot find the io port of the submodule.</p>
  <p><strong>value io is not a member of chisel3.RawModule</strong></p>