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

Unhelpful error if you accidentally try to bitselect low to high #1089

Closed
jackkoenig opened this issue May 7, 2019 · 0 comments · Fixed by #3341
Closed

Unhelpful error if you accidentally try to bitselect low to high #1089

jackkoenig opened this issue May 7, 2019 · 0 comments · Fixed by #3341

Comments

@jackkoenig
Copy link
Contributor

jackkoenig commented May 7, 2019

If you bitselect incorrectly, like from low to high instead of high to low, you get this unhelpful requirement failure:

[error] Exception in thread "main" java.lang.IllegalArgumentException: requirement failed
[error]         at scala.Predef$.require(Predef.scala:264)
[error]         at chisel3.internal.firrtl.KnownWidth.<init>(IR.scala:202)
[error]         at chisel3.internal.firrtl.Width$.apply(IR.scala:176)
[error]         at chisel3.core.Bits.$anonfun$do_apply$6(Bits.scala:221)
[error]         at scala.Option.getOrElse(Option.scala:121)
[error]         at chisel3.core.Bits.do_apply(Bits.scala:219)

This is caused by Chisel trying to create a negative width UInt. Now this error does have a better message (https://github.com/freechipsproject/chisel3/blob/a4a29e29c3f1eed18f851dcf10bdc845571dfcb6/chiselFrontend/src/main/scala/chisel3/core/Bits.scala#L160), but it uses Builder.error which doesn't get reported if a later exception occurs. We can obviously patch this specific issue, but I wonder if better handling of such cases in general would be a better solution.

Type of issue: bug report

Impact: no functional change

Development Phase: request
Other information

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

import chisel3._

class MyModule extends Module {
  val io = IO(new Bundle {
    val in = Input(UInt(8.W))
    val out = Output(UInt())
  })
  
  io.out := io.in(0, 3)
} 

object MyMain extends App {
  println(chisel3.Driver.emitVerilog(new MyModule))
} 

What is the current behavior?

See above

What is the expected behavior?

See above

What is the use case for changing the behavior?

Better user experience

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