"value io is not a member of chisel3.Module" error after upgrading to chisel 3.5.0-RC1

484 views
Skip to first unread message

sam...@gmail.com

unread,
Nov 29, 2021, 2:04:07 AM11/29/21
to chisel-users

Hi all,

As in the Chisel 3.5.0-RC1 release note https://github.com/chipsalliance/chisel3/releases,
the val io in Module is now deprecated, for solving issues with Scala 2.13 compatibility as discussed in https://github.com/chipsalliance/chisel3/pull/1550.
And it was mentioned in https://github.com/chipsalliance/chisel3/blob/8a73362bb6fe87817a1867cc2482c1841f95c077/core/src/main/scala/chisel3/RawModule.scala#L156
that the “val io” is now by Java or Scala reflection.

However, this reflection mechanism don’t seem to have worked for me and I got the error as titled for this code:

class PeArrayWithDelay[T <: chisel3.Data: Ring]( p: SsagParams[T]) extends Module {

  val peArray = p.dx match {
    case false => Module(new PeArraySx(p)) 
    case true =>
      val x = Module(new PeArrayDx(p))
      x.io.clockDx := io.clockDx.get
      x
  }

 dlyA.zipWithIndex.foreach { case (x, i) => peArray.io.inA(i) <> x } // <== error, io not a member

I did eventually figured out a workaround, since it was mentioned the original val io was a virtual method, I injected a method named io like this:

trait WithIO extends Module {
  def io: Bundle
}

then in the instantiation lines:

  val peArray = p.dx match {
    case false => Module(new PeArraySx(p) with WithIO) 
    case true =>
      val x = Module(new PeArrayDx(p) with WithIO)
      x.io.clockDx := io.clockDx.get
      x
  }

Question is, is this even a proper workaround?
And why did the reflection not work in the first place?
(BTW if there’s no other workaround, maybe this should be in FAQ/Cookbook?)

Best regards,
Sam

Jack Koenig

unread,
Dec 2, 2021, 12:28:43 AM12/2/21
to chisel...@googlegroups.com
Hi Sam,

I apologize for not responding earlier. This is a great question and I wanted to do it justice in response.

The only feature supported by reflection for "val io" is enforcing that Chisel.Module (ie. Chisel2 compatibility layer modules) are only allowed to have a single interface named "io".
In this case, you are hitting a compile-time type error which we unfortunately cannot do anything about with runtime reflection.

Your workaround is fine as a workaround, but it is actually pretty close to the proper solution. Your question inspired me to write the answer as a new doc.

And more importantly for you, here's the rendered Markdown: https://gist.github.com/jackkoenig/4949f6a455ae74923bbcce10dbf846b5

--
You received this message because you are subscribed to the Google Groups "chisel-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chisel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/8264c38f-acff-4eec-ae3b-5e98378456d9n%40googlegroups.com.

sam...@gmail.com

unread,
Dec 6, 2021, 9:25:12 AM12/6/21
to chisel-users
Hi Jack,

Thanks for the reply, and the well explained doc in the PR too.
Btw I ended up making the 2 modules inherit from a parent module that only contains the `val io`,
as my IOs are parameterised and Scala traits don't take constructor parameters.
May be worth noting for Scala beginners.

Best regards,
Sam
Reply all
Reply to author
Forward
0 new messages