mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-22 05:36:43 +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:
parent
677bf21947
commit
b870693393
2 changed files with 22 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
17
tests/verilog/reset_auto_counter.ys
Normal file
17
tests/verilog/reset_auto_counter.ys
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue