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

Can't use Mux with DontCare while equivalent when() statement is fine #848

Closed
edwardcwang opened this issue Jul 7, 2018 · 0 comments · Fixed by #995
Closed

Can't use Mux with DontCare while equivalent when() statement is fine #848

edwardcwang opened this issue Jul 7, 2018 · 0 comments · Fixed by #995
Assignees
Labels
Milestone

Comments

@edwardcwang
Copy link
Contributor

Type of issue: bug report

Development Phase: request

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

Consider the following two functions below, muxLess and whenLess. As a user, they appear to implement the same logic and I would expect them to both function. However, the whenLess case elaborates and works as expected while muxLess flames out with an error:

java.lang.AssertionError: can't create Mux with heterogeneous types class chisel3.core.UInt and class chisel3.core.DontCare$
  chisel3.core.cloneSupertype$$anonfun$1.apply(Data.scala:132)
  chisel3.core.cloneSupertype$$anonfun$1.apply(Data.scala:112)
[...]
  scala.collection.AbstractTraversable.reduce(Traversable.scala:104)
  chisel3.core.cloneSupertype$.apply(Data.scala:112)
  chisel3.core.Mux$.do_apply(Mux.scala:32)
[...]
// doesn't work
def muxLess(in: UInt, outWire: UInt): Unit = {
    outWire := Mux(in < 48.U, in, DontCare)
}

// works fine
def whenLess(in: UInt, outWire: UInt): Unit = {
    when(in < 48.U) {
        outWire := in
    } .otherwise {
        outWire := DontCare
    }
}

class MyMyModule extends Module {
  val io = IO(new Bundle {
    val in = Input(UInt(12.W))
    val out = Output(UInt(12.W))
  })
  
  whenLess(io.in, io.out) // works
  muxLess(io.in, io.out) // doesn't work
}

Please tell us about your environment: Chisel 3.1

What is the use case for changing the behavior? Seems like an arbitrary restriction to a user that we can't use DontCare in a Mux() but can use it in a when() statement to accomplish the exact same thing.

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.

3 participants