3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-11-22 21:51:28 +00:00

Fix reset_auto_counter_id to correctly detect _NNN_ patterns

This fixes a regression caused by commit c4c389fdd7.
This commit is contained in:
Robert O'Callahan 2025-11-17 09:11:15 +00:00
parent 677bf21947
commit b870693393
2 changed files with 22 additions and 5 deletions

View file

@ -116,21 +116,21 @@ void reset_auto_counter_id(RTLIL::IdString id, bool may_rename)
if (*it == '$' && may_rename && !norename)
auto_name_map[id] = auto_name_counter++;
if (*it != '\\' || *it != '_' || (it + 1) == it_end)
if (*it != '\\' || (it + 1) == it_end || *(it + 1) != '_' || (it + 2) == it_end)
return;
std::string s;
it += 2;
auto start = it;
while (it != it_end) {
char ch = *it;
if (ch == '_' && (it + 1) == it_end)
continue;
break;
if (ch < '0' || ch > '9')
return;
s.push_back(ch);
++it;
}
std::string s;
std::copy(start, it_end, std::back_inserter(s));
int num = atoi(s.c_str());
if (num >= auto_name_offset)
auto_name_offset = num + 1;

View file

@ -0,0 +1,17 @@
read_verilog -sv <<EOT
module arithmetic (
input logic [7:0] _0_,
input logic [7:0] _1_,
output logic [7:0] _2_,
);
assign _2_ = _0_ + _1_;
endmodule : arithmetic
EOT
hierarchy
techmap
write_verilog reset_auto_counter.v
! ! grep -qE '_0+0_' reset_auto_counter.v
! ! grep -qE '_0+1_' reset_auto_counter.v
! ! grep -qE '_0+2_' reset_auto_counter.v