Negative Width Gives Bad Error Message
seldridge opened this issue · comments
If you have a negative width, this produces a bad error message about "requirement failed". Consider:
//> using scala "2.13.12"
//> using repository sonatype-s01:snapshots
//> using lib "org.chipsalliance::chisel::6.0.0+74-0a437d8f-SNAPSHOT"
//> using plugin "org.chipsalliance:::chisel-plugin::6.0.0+74-0a437d8f-SNAPSHOT"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
import chisel3._
import circt.stage.ChiselStage
class Foo extends RawModule with Public {
val x = IO(Input(UInt(-8.W)))
}
object Main extends App {
println(
ChiselStage.emitSystemVerilog(
new Foo,
firtoolOpts = Array("-g", "-emit-hgldd", "-output-final-mlir=Foo.mlir")
)
)
}
This produces:
Exception in thread "main" java.lang.IllegalArgumentException: requirement failed
at ... ()
at Foo.$anonfun$x$4(NegativeWidth.scala:11)
at chisel3.SpecifiedDirection$.specifiedDirection(Data.scala:66)
at chisel3.Input$.apply(Data.scala:264)
at Foo.$anonfun$x$3(NegativeWidth.scala:11)
at chisel3.IO$.apply(IO.scala:34)
at chisel3.experimental.BaseModule.IO(Module.scala:821)
at Foo.$anonfun$x$2(NegativeWidth.scala:11)
at chisel3.experimental.prefix$.apply(prefix.scala:50)
at Foo.$anonfun$x$1(NegativeWidth.scala:11)
at chisel3.internal.plugin.package$.autoNameRecursively(package.scala:33)
at Foo.<init>(NegativeWidth.scala:11)
at Main$.$anonfun$new$1(NegativeWidth.scala:17)
at ... ()
at ... (Stack trace trimmed to user code only. Rerun with --full-stacktrace to see the full stack trace)
h/t @mmaloney-sf for finding this.