Closed seldridge closed 2 years ago
For point "If a register is reset, why should it have randomization logic emitted? (Is it problematic to have this be X up until it's reset?)"
I agree -- I wasn't even aware this was the case.
I think the concern is that it will leak X values into non-reset registers and increase the exposure of the simulation to X pessimism and optimism.
It's hard to say whether that would be a meaningful problem given our current strategy of emitting very conservative conditional logic and expressions. However, dropping initializations of reset registers would definitely make it harder to introduce some "better Verilog" patterns like streamlined procedural if
s/else
s (which is a goal) without introducing cases where X optimism is observable.
I think this gets to the heart of a lot of our Verilog emission issues: we have multiple layers of safeguards against simulation issues, which are quite often excessively conservative. However, small peephole optimizations often leave us surprised by unexpected outcomes when suddenly some holes in the assumptions align. I think this is a good argument for a clean-sheet look at Verilog emission down the road.
However, for now, I think that making it optional is a win-win.
Removing randomization from registers that are reset will cause problems in general. For synchronous reset, running the clock to perform the reset will transfer Xs from registers that are reset into registers that are not reset. Even for async reset, some parts of the design may be reset at different times, so Xs lingering in not-yet-reset parts can pessimize other parts of the design.
My experience relying on simulators to do the randomization has been mixed. It’s obviously fine if the simulator has a 2-state-simulation option. My experience using VCS 4-state simulation + using VCS to randomize the initial state was quite negative; the feature was basically broken.
Having an option to suppress emission of randomization code seems fine; jettisoning randomization altogether is not gonna work out for us, though. But, separately, it would be good to improve the way the emitted code looks for marketing purposes.
On Thu, May 14, 2020 at 5:30 PM Albert Magyar notifications@github.com wrote:
I think the concern is that it will leak X values into non-reset registers and increase the exposure of the simulation to X pessimism and optimism.
It's hard to say whether that would be a meaningful problem given our current strategy of emitting very conservative conditional logic and expressions. However, dropping initializations of reset registers would definitely make it harder to introduce some "better Verilog" patterns like streamlined procedural ifs/elses (which is a goal) without introducing cases where X optimism is observable.
I think this gets to the heart of a lot of our Verilog emission issues: we have multiple layers of safeguards against simulation issues, which are quite often excessively conservative. However, small peephole optimizations often leave us surprised by unexpected outcomes when suddenly some holes in the assumptions align. I think this is a good argument for a clean-sheet look at Verilog emission down the road.
However, for now, I think that making it optional is a win-win.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/freechipsproject/chisel3/issues/1444#issuecomment-628956356, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH3XQXDN5OZZ7UHUFLJZRLRRSEKDANCNFSM4NBDVAGQ .
An option to disable that randomization emission seems sane. Let's do it.
Currently, there are a number of personal annoyances with how Chisel/FIRRTL emits verbose randomization logic. This issues is a proposal to add an option to disable randomization logic generation (which would be realized in FIRRTL). Additionally, this brings up a broader discussion about the motivation/need for randomization which I wrote up here.
Annoyances with randomization:
Counterpoints supporting randomization:
chisel3.util
contains generators that suffer from X-pessimism meaning that Chisel designs using the standard library may fail to simulate, but be perfectly correct.At bare minimum, I'd like to have an option to disable randomization logic from being emitted. This shouldn't be the default, just something that a user can turn on if they have some good reason to. Two examples here would be: (1) me writing a Chisel snippet to go on the website and (2) ChiselTest opting to do randomization directly via a Verilator arg.
As further points of discussion:
X
up until it's reset?)As a concrete example, consider the following simple Chisel circuit. Assume that I'm somebody who's showing a colleague how to use Chisel:
This produces the sane high FIRRTL IR:
And vomits the following Verilog:
I would like to have an option to get something cleaner:
Type of issue: feature request
Impact: API addition (no impact on existing code) | Verilog generation
Development Phase: request
Other information
None.
What is the use case for changing the behavior?
Discussed above.