question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FIR crashes on Bool type resolution

See original GitHub issue

Hello A snippet below crashes when I try to instantiate a Counter module in my design. Bool type resolution being the victim. If I use a function to implement a counter in my design, all works seamlessly: System: Ubuntu 16.04.5, Scala version: 2.11.12, Chisel version: 3.1.0 Code

package  counter_pkg 
import    chisel3._
import    chisel3.util._

class Counter (max:UInt, ena:Bool ) extends Module {
  val width = max.getWidth
    val io = IO (new Bundle {
    val out  = Output(UInt(width.W))
  })
    val x = RegInit(0.asUInt(width.W))
  x := Mux(x === max, 0.U, Mux (ena, x + 1.U, x))
  io.out := x
}

class CounterWrap extends Module {
  val io = IO (new Bundle {
    val out  = Output (UInt(16.W))
    })
   
  val idle :: run :: Nil = Enum (2)
  val state = RegInit(idle)
    val ena  = RegInit (false.B)
  ena := state === run
  val cnt  = Module (new Counter(16.U, **ena.toBool**)) // This won't compile if I remove .toBool
   io.out := 0.U
}

Execution Result Log

[info] [0.003] Elaborating design...
[info] [0.237] Done elaborating.
Total FIRRTL Compile Time: 327.7 ms
Total FIRRTL Compile Time: 35.0 ms
End of dependency graph
Circuit state created
Exception during evaluation: mux(WRef(cnt._T_12,UIntType(IntWidth(6)),NodeKind,MALE)) must be (0|1).U<1> was 18.PU<6>  @[Counter.scala 16:32:@12.4]  @[Counter.scala 16:32:@12.4]
Expression Evaluation stack
   0 cnt.x:Reg -> mux(cnt.reset, UInt<5>("h0"), cnt._T_15)
   1 cnt._T_15:Node -> mux(cnt._T_9, UInt<1>("h0"), cnt._T_14)
   2 cnt._T_14:Node -> mux(cnt._T_12, cnt._T_13, cnt.x)
Error: InterpreterExecption(mux(WRef(cnt._T_12,UIntType(IntWidth(6)),NodeKind,MALE)) must be (0|1).U<1> was 18.PU<6>  @[Counter.scala 16:32:@12.4] during warmup evaluation
Exception during evaluation: mux(WRef(cnt._T_12,UIntType(IntWidth(6)),NodeKind,MALE)) must be (0|1).U<1> was 18.PU<6>  @[Counter.scala 16:32:@12.4]  @[Counter.scala 16:32:@12.4]
Expression Evaluation stack
   0 cnt.x:Reg -> mux(cnt.reset, UInt<5>("h0"), cnt._T_15)
   1 cnt._T_15:Node -> mux(cnt._T_9, UInt<1>("h0"), cnt._T_14)
   2 cnt._T_14:Node -> mux(cnt._T_12, cnt._T_13, cnt.x)
[error] (run-main-2) firrtl_interpreter.InterpreterException: mux(WRef(cnt._T_12,UIntType(IntWidth(6)),NodeKind,MALE)) must be (0|1).U<1> was 18.PU<6>  @[Counter.scala 16:32:@12.4]
[error] firrtl_interpreter.InterpreterException: mux(WRef(cnt._T_12,UIntType(IntWidth(6)),NodeKind,MALE)) must be (0|1).U<1> was 18.PU<6>  @[Counter.scala 16:32:@12.4]
[error] 	at firrtl_interpreter.InterpreterException$.apply(InterpreterException.scala:10)
[error] 	at firrtl_interpreter.LoFirrtlExpressionEvaluator.evaluate(LoFirrtlExpressionEvaluator.scala:302)
[error] 	at firrtl_interpreter.LoFirrtlExpressionEvaluator$$anonfun$5.apply(LoFirrtlExpressionEvaluator.scala:453)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
seldridgecommented, Aug 22, 2018

It helps when I compile it before posting. It should be io.en, not en. I corrected the example above and added a note that I edited it.

@edwardcwang beat me to the punch! GitHub flavored Markdown provides a lot of neat functionality. There’s a small guide here.

1reaction
edwardcwangcommented, Aug 22, 2018

Also try io.en instead of just en since en is a signal inside of io.

Read more comments on GitHub >

github_iconTop Results From Across the Web

decodeBool cannot fail, but may cr… | Apple Developer Forums
I don't know how to handle this situation properly. I have coded a value in a class. When I decode, it should be...
Read more >
[Android] Crashes when secureTextEntry is not a boolean #2907
I found a interesting thing.When I use the TextInput with secureTextEntry property.If both Android and IOS works fine.
Read more >
Crashing at checkInoutAndNativeTypeCheckedBounds
I understand that crash is due to index not being Int. I have a doubt, is crash due to different queue editing array,...
Read more >
Visual Studio crashes while doing code analysis in background
Visual Studio 2019 16.3.9 just crashed with the trace below. I was working in 7 files with changes which were not recovered. Why...
Read more >
[JDK-8250861] Crash in MinINode::Ideal(PhaseGVN*, bool)
Resolved. Backport - A issue that is required to port a Bug or Feature into another product JDK-8255887 Crash in MinINode::Ideal(PhaseGVN*, bool).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found