Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chisel Hierarchy API not working after Scala 2.13 update #1356

Closed
3 tasks done
tymcauley opened this issue Feb 22, 2023 · 0 comments · Fixed by #1361
Closed
3 tasks done

Chisel Hierarchy API not working after Scala 2.13 update #1356

tymcauley opened this issue Feb 22, 2023 · 0 comments · Fixed by #1361
Labels

Comments

@tymcauley
Copy link
Contributor

Background Work

Chipyard Version and Hash

Release: main
Hash: c8764d6

OS Setup

macOS 13.2.1

Other Setup

Check out fresh Chipyard, run ./scripts/init-submodules-no-riscv-tools.sh

Current Behavior

It looks like the recent update to Scala 2.13 (#1303) broke the Chisel Hierarchy API. It looks like we'll need an extra scalac option to fix the issue.

To reproduce, take this code snippet from the Chisel Hierarchy Cookbook, and place it at the end of generators/chipyard/src/main/scala/example/GCD.scala:

import chisel3.experimental.hierarchy.{Definition, Instance, instantiable, public}

@instantiable
class AddOne(width: Int) extends Module {
  @public val in  = IO(Input(UInt(width.W)))
  @public val out = IO(Output(UInt(width.W)))
  out := in + 1.U
}

class AddTwo(width: Int) extends Module {
  val in  = IO(Input(UInt(width.W)))
  val out = IO(Output(UInt(width.W)))
  val addOneDef = Definition(new AddOne(width))
  val i0 = Instance(addOneDef)
  val i1 = Instance(addOneDef)
  i0.in := in
  i1.in := i0.out
  out   := i1.out
}

Try to compile, and you should see these errors:

[info] compiling 1 Scala source to /path/to/chipyard/generators/chipyard/target/scala-2.13/classes ...
[error] /path/to/chipyard/generators/chipyard/src/main/scala/example/GCD.scala:224:6: value in is not a member of chisel3.experimental.hierarchy.Instance[chipyard.example.AddOne]
[error] did you mean isA?
[error]   i0.in := in
[error]      ^
[error] /path/to/chipyard/generators/chipyard/src/main/scala/example/GCD.scala:225:6: value in is not a member of chisel3.experimental.hierarchy.Instance[chipyard.example.AddOne]
[error] did you mean isA?
[error]   i1.in := i0.out
[error]      ^
[error] /path/to/chipyard/generators/chipyard/src/main/scala/example/GCD.scala:225:15: value out is not a member of chisel3.experimental.hierarchy.Instance[chipyard.example.AddOne]
[error]   i1.in := i0.out
[error]               ^
[error] /path/to/chipyard/generators/chipyard/src/main/scala/example/GCD.scala:226:15: value out is not a member of chisel3.experimental.hierarchy.Instance[chipyard.example.AddOne]
[error]   out   := i1.out
[error]               ^
[error] four errors found
[error] (Compile / compileIncremental) Compilation failed

Expected Behavior

I would expect the above code to compile without error. In fact, if you add "-Ymacro-annotations" to scalacOptions in build.sbt, the build works. I'm not sure if there are other Scala compiler options that we're missing, but that one certainly seems necessary.

Other Information

No response

@tymcauley tymcauley added the bug label Feb 22, 2023
jerryz123 added a commit that referenced this issue Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant