-
Notifications
You must be signed in to change notification settings - Fork 237
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
Timing analysis cannot cope with combinatorial loops #109
Comments
The issue here seems to be combinational loops in the design as a result of inferred latches. The topological ordering used in nextpnr's timing analysis isn't capable of handling these in a nice way. An example of one is In general, this should be avoided as it is likely to cause hard-to-analyse timing issues. Nonetheless nextpnr should deal with it better. If you are willing to accept potentially inaccurate timing results, then it is safe to comment out the assertion (it is merely an attempt to check the topological ordering is working correctly, which naturally fails in the case of loops). |
Ah! That makes perfect sense.
That block actually wasn't intended to have any inferred latches, though obviously some got through. Adding a few more assignments-of-X at the top of that block leads to a successful run and working hardware. In the end, Is there a good way to lint for unwanted inferred latches? And is there a better way than "assign X at the top" or "assign X on every 'inactive' branch" to prevent inferring a latch, while still allowing me to define complicated combinatorial logic in an always block? |
What @daveshah1 says is correct. Currently nextpnr does not handle combinational loops at all. Broadly speaking, your upstream synthesis tool should detect latches and warn you of them. By the time it gets to nextpnr, we could have no idea that a latch has been inferred (as typically it just looks like combinatorial logic with feedback) until we try to do timing analysis. |
My giant combinatorial |
After #110: |
Excellent. As far as I'm concerned, that resolves this issue. (I don't know whether it's possible to do a good timing analysis in the presence of a combinatorial loop, in the general case... and I do think it's a good idea to eliminate them from designs anyway...) |
Thanks @SolraBizna. Let me leave a note behind for future devs: |
I am experiencing this error and I'm a bit stumped as to why. It's probably my ignorance in Verilog. But my main issue is the lack of trace-ability to the offending net or code. In my overall design, multiple instances of the error pop out after a gazlion lines of timing reduction net info messages. I'm using the latest stable nextpnr. My specific example has to do with the following module - the transmit side of a simple UART. If I comment out "thr <= data" and "pad_d0 <= tsr[0]", the error goes away. This is a registered block with all assignments registered to a global clock with inferred constraint timing coming from an iCE40up5k's PLL output. `module ice_uart_tx #(
` |
@hightowera , Can you please open a new issue, and provide a complete and verifiable example? (Preferrably a minimal one as well ... but I can take a look either way.) Right now, I'm not seeing any issues with the little bit of code you've posted, and it's not sufficient to duplicate the issue. Dan |
git clone https://github.com/SolraBizna/friedice cd friedice make bin/friedup.asc
Somewhere in that spaghetti bowl of unpipelined logic is yet another edge case that ends up triggering this assert:
This code is difficult to gradually reduce to a minimal test case, because it's all so horribly entangled. All I can say for sure is that the problem lies in
src/friedice.v
orsrc/register_file.v
.The text was updated successfully, but these errors were encountered: