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: fix vcd writer scope handling #4655

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

rroohhh
Copy link
Contributor

@rroohhh rroohhh commented Oct 11, 2024

The vcd writer incorrectly treated two scope vectors as the same, whenever they have the same length of entries and the last item matches. This is however not always true, for example consider a current_scope of ["top", "something0", "other_i"] and a scope of ["top", "something1", "other_i"] as one might obtain from the following verilog file:

module other2();
    wire w_inner;
endmodule

module other();
    other2 other_i();
endmodule


module top();
    other something0();
    other something1();
endmodule

The old code emitted a vcd of

$scope module top $end
$scope module something0 $end
$scope module other_i $end
$var wire 1 ! w_inner $end
$var wire 1 " w_inner $end
$upscope $end
$upscope $end
$upscope $end
$enddefinitions $end
#0
0!
0"

not changing the scope correctly for the two w_inner wires. This now correctly generates

$scope module top $end
$scope module something0 $end
$scope module other_i $end
$var wire 1 ! w_inner $end
$upscope $end
$upscope $end
$scope module something1 $end
$scope module other_i $end
$var wire 1 " w_inner $end
$upscope $end
$upscope $end
$upscope $end
$enddefinitions $end
#0
0!
0"

The vcd writer incorrectly treated two scope vectors as the same, whenever
they have the same length of entries and the last item matches.
This is however not always true, for example consider a current_scope of
["top", "something0", "same"]
and a scope of
["top", "something1", "same"]
@rroohhh rroohhh requested a review from whitequark as a code owner October 11, 2024 16:01
@whitequark whitequark merged commit 0f762f7 into YosysHQ:main Oct 12, 2024
24 checks passed
@rroohhh rroohhh deleted the cxxrtl_vcd_scope_fix branch October 12, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants