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

CXXRTL: Information loss when outputs are aliased #4405

Closed
noeamiot opened this issue May 21, 2024 · 4 comments
Closed

CXXRTL: Information loss when outputs are aliased #4405

noeamiot opened this issue May 21, 2024 · 4 comments
Labels

Comments

@noeamiot
Copy link
Contributor

Version

Yosys 0.39

On which OS did this happen?

Linux

Reproduction Steps

For the following and_ti.v file:

module top(input a0, input a1, input b0, input b1, input z, output c0, output c1);
    wire a0b0, a0b1, a1b0, a1b1;
    wire a0b1z, a1b0z;
    wire culprit;

    assign a0b0 = a0 & b0;
    assign a0b1 = a0 & b1;
    assign a1b0 = a1 & b0;
    assign a1b1 = a1 & b1;

    //assign a1b0 = a1b0 ^ z;
    //assign a0b1 = a0b1 ^ z;
    assign a0b1z = a0b1 ^ z;
    assign a1b0z = a1b0 ^ z;
    
    //assign c0 = a0b0 ^ (a0b1 ^ z);
    //assign c1 = a1b1 ^ (a1b0 ^ z);
    assign culprit = a1b1 ^ a1b0z; 
    assign c0 = culprit;
    assign c1 = a0b0 ^ a0b1z;
endmodule

The workflow used is simple:

read_verilog and_ti.v 
write_cxxrtl -O6 -g4 -header cxxrtl_and_ti.cpp

Gives the following debug information for the wires c0 and c1 :

items->add(path + "culprit", debug_item(debug_eval_outline, p_culprit, 0), metadata_map({
	{ "src", "and_ti.v:4.10-4.17" },
}));
...
items->add(path + "c1", debug_item(p_c1, 0, debug_item::OUTPUT|debug_item::DRIVEN_COMB), metadata_map({
	{ "src", "and_ti.v:1.79-1.81" },
}));
items->add(path + "c0", debug_item(debug_eval_outline, p_culprit, 0), metadata_map({
	{ "src", "and_ti.v:4.10-4.17" },
}));

There are other combinations of HDL or -O flags that can lead to this behavior, sometimes on an outline like here, sometimes on normal wires.

Expected Behavior

There exists a way to retrieve the information that c0 is an output wire like for c1.

Actual Behavior

There is no way to know that c0 is an output because it is aliased to another wire that is not an output.

@noeamiot noeamiot added the pending-verification This issue is pending verification and/or reproduction label May 21, 2024
@whitequark whitequark added cxxrtl and removed pending-verification This issue is pending verification and/or reproduction labels May 21, 2024
@whitequark
Copy link
Member

Thanks for the report. Yeah, ports should probably just not be aliasable.

@whitequark
Copy link
Member

Do you think you could write a patch?

@noeamiot
Copy link
Contributor Author

Sure !

@noeamiot
Copy link
Contributor Author

Resolved by #4406.

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

No branches or pull requests

2 participants