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

RegInit errors when passed a Bundle Literal #1787

Open
jackkoenig opened this issue Feb 18, 2021 · 3 comments
Open

RegInit errors when passed a Bundle Literal #1787

jackkoenig opened this issue Feb 18, 2021 · 3 comments
Labels
Milestone

Comments

@jackkoenig
Copy link
Contributor

Type of issue: bug report

Impact: no functional change

Development Phase: request

Other information

Using Chisel v3.4.2

If the current behavior is a bug, please provide the steps to reproduce the problem:

https://scastie.scala-lang.org/4CDkXkNHQpKV7ItnPRtcvw

import chisel3._
import chisel3.experimental.BundleLiterals._

class MyBundle extends Bundle {
  val a = UInt(8.W)
  val b = Bool()
}

class Example extends MultiIOModule {
  val in = IO(Input(new MyBundle))
  val en = IO(Input(Bool()))
  val out = IO(Output(new MyBundle))
  
  // It works if you wrap the Bundle lit in WireInit
  val r = RegInit((new MyBundle).Lit(_.b -> true.B))
  when (en) {
    r := in
  }
  out := r
}

What is the current behavior?

chisel3.internal.ChiselException: operand is not visible from the current module

What is the expected behavior?

This should work, and does if you wrap the Bundle Literal in WireInit

What is the use case for changing the behavior?

Fix a bug

@jackkoenig jackkoenig added the bug label Feb 22, 2021
@ziyue-pan
Copy link

I met the same issue. Is there any chance to fix that bug?

@jackkoenig
Copy link
Contributor Author

I met the same issue. Is there any chance to fix that bug?

It's still not fixed, but the workaround is pretty simple, you can wrap the Bundle literal in WireInit(...), eg.

val r = RegInit(WireInit((new MyBundle).Lit(_.b -> true.B)))

https://scastie.scala-lang.org/jackkoenig/eXjAqmDRRfOMYCMqNkRNXQ/1

@jackkoenig
Copy link
Contributor Author

Maybe fixed by #1689

@jackkoenig jackkoenig added this to the 3.4.x milestone May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants