`assert` emits `$fatal` before error messages in generated Verilog
See original GitHub issueType of issue: bug report Impact: API modification Development Phase: request
Other information
As per the implementation of assert
https://github.com/chipsalliance/chisel3/blob/024847d75079a125e5946e9dcf2ed9c14d2db730/core/src/main/scala/chisel3/VerificationStatement.scala#L94-L97
A verification statement is generated before the failure message, which gets turned into a $fatal
statement by firrtl. This makes the failure message never visible in simulations.
steps to reproduce the problem
Call assert
in any elaborated code.
What is the current behavior?
$fatal
generated before $fwrite
What is the expected behavior?
$fwrite
generated before $fatal
, or at least have a switch for changing the order.
Please tell us about your environment: Windows 11 WSL2, ArchLinux
What is the use case for changing the behavior? Better debug experience using external simulator.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top GitHub Comments
Integrating the Message with the Verification Statement
Unfortunately (1) won’t work without some significant work on the firrtl compilers. You would have to extend the assert and assume statements to support format strings and potentially duplicate some code for handling print statements. I think this would be a nice solution, just want to point out that there would be some work involved.
Assertion Message Semantics
The Verilog that the C++ firrtl compiler generates would work well when there is, however what would happen if there are two assertions that fail in the same cycle? What if they are in different modules? Are we giving any guarantees in that case? Would it be OK for the Scala firrlt compiler to move all assert/stop statements below all printf statements? I.e. we would guarantee that printfs inside a module happen in order, but assertions will always happen after all printfs (inside a module).
Fixing this Issue
I have a short fix which should bring things back to the state we had in
3.4
: https://github.com/chipsalliance/chisel3/pull/2484Is there any activity on this? This is a significant nuisance on 3.5.0 and newer.