Skip to content
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

lack of warnings/errors for unwanted latches #56

Open
astrollo opened this issue Oct 2, 2024 · 3 comments
Open

lack of warnings/errors for unwanted latches #56

astrollo opened this issue Oct 2, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@astrollo
Copy link

astrollo commented Oct 2, 2024

Consider the following trivial (and buggy) code:

module test1 (input logic a, b, output logic y);
always_comb begin
 if (a)
   y = b;
end
endmodule

read_slang does not give any error or warning, and a muliplexer with output connected to in_0 is synthesized.
read_verilog -sv followed by: proc gives correctly the following message and exit: ERROR: Latch inferred for signal \test1.\y from always_comb process
Similar problems occur for case statement, with case values incompletely covered (no default)

@povik
Copy link
Owner

povik commented Oct 2, 2024

Thanks, that needs addressing

@povik povik added bug Something isn't working and removed bug Something isn't working labels Oct 2, 2024
@povik
Copy link
Owner

povik commented Oct 2, 2024

Actually I am not sure it needs addressing, this will emit a combinational loop which will be caught in a subsequent check call. To me a combinational loop is not an invalid reading of the input code when always_comb prohibits inference of latches.

We could detect this in the frontend and emit a warning/error, but there's risk of false positives depending on how we do the detection. In any case I reclassify this as an enhancement.

@povik povik added the enhancement New feature or request label Oct 2, 2024
@phsauter
Copy link

phsauter commented Oct 2, 2024

I think the way it is currently handled in yosys-slang itself is fine (ie check catching the loop).
What would be more interesting would be a warning (or just info) in Slang itself that warns of incomplete cases.
-Wcase-gen-dup and -Wcase-gen-none show that something like that is probably possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants