S. Takano
S. Takano

Reputation: 313

value is not a member of chisel3.Bundle

sbt does not recognize a bundle. Errors are these:

[error] /home/xxx/src/main/scala/NoC.scala:12:8: value Grant is not a member of chisel3.Bundle
[error]     io.Grant := io.Req & !io.Rls
[error]        ^
[error] /home/xxx/src/main/scala/NoC.scala:12:20: value Req is not a member of chisel3.Bundle
[error]     io.Grant := io.Req & !io.Rls
[error]                    ^
[error] /home/xxx/src/main/scala/NoC.scala:12:30: value Rls is not a member of chisel3.Bundle
[error]     io.Grant := io.Req & !io.Rls
[error]                              ^

Reproducible code is;

//Priority Encoder
class P_Encoder() extends Module {
    val io = IO(new Bundle {
        val Req         = Input(Bool())    //Requests
        val Rls         = Input(Bool())    //Releases
        val Grant       = Output(Bool())   //Grants
    })

    io.Grant := io.Req & !io.Rls
}

Probably I missed something on grammers, but not yet find out. Does anyone can point out?

Upvotes: 3

Views: 2194

Answers (1)

Jack Koenig
Jack Koenig

Reputation: 6064

This is due to a change in type inference between Scala 2.11 and 2.12. You can work around this issue by adding -Xsource:2.11 to your scalacOptions in your build.sbt. You'll see this in most chisel3 projects like the chisel-template, rocket-chip, and sifive/freedom. It's generally a good idea to create new projects from the chisel-template until you are comfortable with the Scala ecosystem and the related tools (like SBT).

EDIT March 2023: This -Xsource:2.11 trick worked for Scala 2.12, but does not work when upgrading to Scala 2.13. You can see some discussion of how to deal with this on the Chisel website page for upgrading from Chisel 3.4 to 3.5. As a general rule of thumb, the most robust solution is to name your Bundle types (rather than relying on anonymous, structurally typed Bundles), for the example above, change it to:

class P_Encoder_Intf extends Bundle {
    val Req         = Input(Bool())    //Requests
    val Rls         = Input(Bool())    //Releases
    val Grant       = Output(Bool())   //Grants
}
class P_Encoder() extends Module {
    val io = IO(new P_Encoder_Intf)
    io.Grant := io.Req & !io.Rls
}

Upvotes: 4

Related Questions