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

Connectable does not properly handle Views #4024

Open
jackkoenig opened this issue Apr 23, 2024 · 0 comments
Open

Connectable does not properly handle Views #4024

jackkoenig opened this issue Apr 23, 2024 · 0 comments

Comments

@jackkoenig
Copy link
Contributor

Type of issue: Bug Report

Please provide the steps to reproduce the problem:

Run the following Scala CLI, using current head of main (same bug exists in v6.3.0):

//> using repository "sonatype-s01:snapshots"
//> using scala "2.13.12"
//> using dep "org.chipsalliance::chisel:7.0.0-M1+76-03ef61f3-SNAPSHOT"
//> using plugin "org.chipsalliance:::chisel-plugin:7.0.0-M1+76-03ef61f3-SNAPSHOT"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"

import chisel3._
import chisel3.experimental.dataview._
// _root_ disambiguates from package chisel3.util.circt if user imports chisel3.util._
import _root_.circt.stage.ChiselStage

class MyBundle(cond: Boolean) extends Bundle {
  val foo = UInt(8.W)
  val realBar = Option.when(cond)(UInt(8.W))
  def bar = realBar.map(_.viewAs)
}

class Foo extends Module {
  val in = IO(Input(new MyBundle(true)))
  val out = IO(Output(new MyBundle(false)))

  out :<>= in.waiveEach { case b: MyBundle => b.bar.toSeq }
}

object Main extends App {
  println(
    ChiselStage.emitSystemVerilog(
      gen = new Foo,
      firtoolOpts = Array("-disable-all-randomization", "-strip-debug-info")
    )
  )
}

What is the current behavior?

This will error with:

[error] .../example.scala 22:7: dangling producer field Foo.in.realBar: IO[UInt<8>]

What is the expected behavior?

If you change the waiver to use .realBar instead of .bar, then the code properly waives the existence of realBar and generates Verilog. Since bar is just a view of realBar, the behavior should be identical when waiving bar.

Please tell us about your environment:

Other Information

What is the use case for changing the behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant