Skip to content

read_verilog: conflicting drivers for integers set in multiple processes #5106

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

Open
widlarizer opened this issue May 8, 2025 · 4 comments
Open
Assignees
Labels
pending-verification This issue is pending verification and/or reproduction

Comments

@widlarizer
Copy link
Collaborator

widlarizer commented May 8, 2025

Version

Yosys 0.51 (git sha1 c4b5190, g++ 14.2.1 -fPIC -O3)

On which OS did this happen?

Linux

Reproduction Steps

module bug (
	clk_a,
	clk_b,
);
	input wire clk_a;
	input wire clk_b;
	integer i;
	always @(posedge clk_a) begin
		i = 1;
	end

	always @(posedge clk_b) begin
		i = 2;
	end
endmodule

read_verilog bug.v; proc; check

This is notable as it seems to be a realistic pattern to iterate over integer i from 0 to whatever in two distinct processes, like in techlibs/quicklogic/qlf_k6n10f/sram1024x18_mem.v. I intuitively expect it to be valid Verilog and can't figure out anything clearly to the contrary, even if the standard ominously says "If loops in two or more parallel processes use the same loop control variable, there is a potential of one loop modifying the variable while other loops are still using it."

Expected Behavior

No warnings

Actual Behavior

Warning: multiple conflicting drivers for bad.\i [31]:
    port Q[31] of cell $procdff$4 ($dff)
    port Q[31] of cell $procdff$3 ($dff)
Warning: multiple conflicting drivers for bad.\i [30]:

etc

@widlarizer widlarizer self-assigned this May 8, 2025
@widlarizer widlarizer added the pending-verification This issue is pending verification and/or reproduction label May 8, 2025
@widlarizer
Copy link
Collaborator Author

Discussed at dev JF. I think this sums up how we see desired behavior:

If such an variable has multiple drivers created in proc_dff then either

@povik
Copy link
Member

povik commented May 12, 2025

@widlarizer Why doesn't it suffice to check whether i has any uses at all? Once it's been blockingly assigned, any uses of i in the same process see the assigned value, so i as an RTLIL wire won't have uses.

Let me link proc_usage: #4325 (comment)

@widlarizer
Copy link
Collaborator Author

@povik When you read_verilog techlibs/quicklogic/qlf_k6n10f/sram1024x18_mem.v; proc; dump you can see i is used by procmux cells. Good to know about proc_usage though

@povik
Copy link
Member

povik commented May 13, 2025

I think you can have the same problem with combinational processes in which case proc_dff won't catch it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-verification This issue is pending verification and/or reproduction
Projects
None yet
Development

No branches or pull requests

2 participants