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

Mux or ProbeExpr of View doesn't work #4079

Closed
dtzSiFive opened this issue May 22, 2024 · 0 comments · Fixed by #4080
Closed

Mux or ProbeExpr of View doesn't work #4079

dtzSiFive opened this issue May 22, 2024 · 0 comments · Fixed by #4080

Comments

@dtzSiFive
Copy link
Member

Type of issue: Bug Report

Please provide the steps to reproduce the problem:

Consider these tests (drop in DataView.scala test):

  • Mux :
  it should "handle mux of bundle view" in {
    import SimpleBundleDataView._
    class MyModule extends Module {
      val cond = IO(Input(Bool()))
      val in1 = IO(Input(new BundleA(8)))
      val in2 = IO(Input(new BundleA(8)))
      val out = IO(Output(new BundleB(8)))

      out := Mux(cond, in1.viewAs[BundleB], in2.viewAs[BundleB])
    }
    val chirrtl = ChiselStage.emitCHIRRTL(new MyModule)
    chirrtl should include("asdf")
  }

  it should "handle view of mux of bundle" in {
    import SimpleBundleDataView._
    class MyModule extends Module {
      val cond = IO(Input(Bool()))
      val in1 = IO(Input(new BundleA(8)))
      val in2 = IO(Input(new BundleA(8)))
      val out = IO(Output(new BundleB(8)))

      out := Mux(cond, in1, in2).viewAs[BundleB]
    }
    val chirrtl = ChiselStage.emitCHIRRTL(new MyModule)
    chirrtl should include("asdf")
  }
  • Probe:
  it should "handle Probe of view, member" in {
    import SimpleBundleDataView._
    class MyModule extends Module {
      val in = IO(Input(new BundleA(8)))
      val out_probe = IO(Output(Probe(UInt(8.W))))
      val view = in.viewAs[BundleB]
      define(out_probe, ProbeValue(view.bar))
    }
    val chirrtl = ChiselStage.emitCHIRRTL(new MyModule)
    chirrtl should include("define out_probe = probe(in.foo)")
    ChiselStage.emitSystemVerilog(new MyModule)
  }

  it should "handle Probe of view, bundle" in {
    import SimpleBundleDataView._
    class MyModule extends Module {
      val in = IO(Input(new BundleA(8)))
      val out_probe = IO(Output(Probe(new BundleB(8))))
      val view = in.viewAs[BundleB]
      define(out_probe, ProbeValue(view))
    }
    val chirrtl = ChiselStage.emitCHIRRTL(new MyModule)
    chirrtl should include("define out_probe = probe(in)")
  }

What is the current behavior?

Mux:
The latter works, but the former does not, producing an error instead.

Probe:
Former works (member of view), but latter does not.

What is the expected behavior?

Ability to use view refs in expressions.

Other Information

Mux Error:

[info] - should handle mux of bundle view *** FAILED ***
[info]   chisel3.package$ChiselException: Internal Error: In .ref for MyModule.in1: IO[BundleB] got 'Some(AggregateViewBinding(Map(MyModule.in1.foo: IO[UInt<8>] -> MyModule.in1.foo: IO[UInt<8>], MyModule.in1: IO[BundleB] -> MyModule.in1: IO[BundleA])))' and 'Some(MyModule.in1: IO[BundleA])'
[info]   at ... ()
[info]   at chiselTests.experimental.DataViewSpec$MyModule$41.$anonfun$new$187(DataView.scala:945)
[info]   at chisel3.Data.$anonfun$$colon$eq$1(Data.scala:736)
[info]   at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[info]   at chisel3.experimental.prefix$.apply(prefix.scala:33)
[info]   at chisel3.Data.$colon$eq(Data.scala:736)
[info]   at chiselTests.experimental.DataViewSpec$MyModule$41.<init>(DataView.scala:945)
[info]   at chiselTests.experimental.DataViewSpec.$anonfun$new$188(DataView.scala:947)
[info]   at chisel3.Module$.evaluate(Module.scala:92)
[info]   at chisel3.Module$.do_apply(Module.scala:35)
[info]   at chisel3.stage.phases.Elaborate.$anonfun$transform$2(Elaborate.scala:53)
[info]   at chisel3.internal.Builder$.$anonfun$buildImpl$1(Builder.scala:1025)
[info]   at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
[info]   at chisel3.internal.Builder$.buildImpl(Builder.scala:1019)
[info]   at chisel3.internal.Builder$.$anonfun$build$1(Builder.scala:1011)
[info]   at logger.Logger$.$anonfun$makeScope$4(Logger.scala:148)
[info]   at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
[info]   at logger.Logger$.makeScope(Logger.scala:146)
[info]   at logger.Logger$.makeScope(Logger.scala:133)
[info]   at ... ()
[info]   at ... (Stack trace trimmed to user code only. Rerun with --full-stacktrace to see the full stack trace)

Probe test error:

[info] - should handle Probe of view, bundle *** FAILED ***
[info]   chisel3.package$ChiselException: Internal Error: In .ref for MyModule.in: IO[BundleB] got 'Some(AggregateViewBinding(Map(MyModule.in.foo: IO[UInt<8>] -> MyModule.in.foo: IO[UInt<8>], MyModule.in: IO[BundleB] -> MyModule.in: IO[BundleA])))' and 'Some(MyModule.in: IO[BundleA])'
[info]   at ... ()
[info]   at chiselTests.experimental.DataViewSpec$MyModule$39.<init>(DataView.scala:909)
[info]   at chiselTests.experimental.DataViewSpec.$anonfun$new$183(DataView.scala:911)
[info]   at chisel3.Module$.evaluate(Module.scala:92)
[info]   at chisel3.Module$.do_apply(Module.scala:35)
[info]   at chisel3.stage.phases.Elaborate.$anonfun$transform$2(Elaborate.scala:53)
[info]   at chisel3.internal.Builder$.$anonfun$buildImpl$1(Builder.scala:1025)
[info]   at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
[info]   at chisel3.internal.Builder$.buildImpl(Builder.scala:1019)
[info]   at chisel3.internal.Builder$.$anonfun$build$1(Builder.scala:1011)
[info]   at logger.Logger$.$anonfun$makeScope$4(Logger.scala:148)
[info]   at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
[info]   at logger.Logger$.makeScope(Logger.scala:146)
[info]   at logger.Logger$.makeScope(Logger.scala:133)
[info]   at ... ()
[info]   at ... (Stack trace trimmed to user code only. Rerun with --full-stacktrace to see the full stack trace)

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

Successfully merging a pull request may close this issue.

1 participant