Skip to content

Commit

Permalink
Merge pull request #4333 from YosysHQ/fix_hierarchy_generate
Browse files Browse the repository at this point in the history
fix hierarchy -generate mode handling of cells
  • Loading branch information
nakengelhardt authored Apr 25, 2024
2 parents c3ae33d + e8ec19c commit 34d9a74
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion passes/hierarchy/hierarchy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void generate(RTLIL::Design *design, const std::vector<std::string> &celltypes,
{
if (design->module(cell->type) != nullptr)
continue;
if (cell->type.begins_with("$__"))
if (cell->type.begins_with("$") && !cell->type.begins_with("$__"))
continue;
for (auto &pattern : celltypes)
if (patmatch(pattern.c_str(), RTLIL::unescape_id(cell->type).c_str()))
Expand Down
20 changes: 20 additions & 0 deletions tests/various/hierarchy_generate.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
read_verilog -icells <<EOF
module top(input [2:0] a, input [2:0] b, output [2:0] y);

sub sub_i (.a(a[0]), .b(b[0]), .y(y[0]));

unknown_sub sub_ii (.a(a[1]), .b(b[1]), .y(y[1]));

$__dunder_sub sub_iii (.a(a[2]), .b(b[2]), .y(y[2]));

endmodule

module sub(input a, input b, output y);
assign y = a ^ b;
endmodule
EOF
hierarchy -generate unknown_sub i:a i:b o:y
hierarchy -generate $__dunder_sub i:a i:b o:y
hierarchy -generate $xor i:A i:B o:Y # this one is ignored
hierarchy -top top -check
check -assert

0 comments on commit 34d9a74

Please sign in to comment.