3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-07 11:41:23 +00:00

faster and simpler code

This commit is contained in:
Alain Dargelas 2024-11-09 14:00:57 -08:00
parent 72ff11fb9b
commit a8eb39f569

View file

@ -172,29 +172,25 @@ struct SplitNetlist : public ScriptPass {
if (!wire->port_output) if (!wire->port_output)
continue; continue;
std::string output_port_name = wire->name.c_str(); std::string output_port_name = wire->name.c_str();
if (output_port_name.empty())
continue;
// We want to truncate the final _<index>_ part of the string // We want to truncate the final _<index>_ part of the string
// Example: "add_Y_0_" // Example: "add_Y_0_"
// Result: "add_Y" // Result: "add_Y"
bool bitblastedIndex = false;
std::string::iterator end = output_port_name.end()-1; std::string::iterator end = output_port_name.end()-1;
for (; end != output_port_name.begin(); end--) { if ((*end) == '_') {
char c = (*end); // Last character is an _, it is a bit blasted index
if ((end == output_port_name.end()-1) && (c == '_')) { end--;
// bit blasted index for (; end != output_port_name.begin(); end--) {
bitblastedIndex = true; if ((*end) != '_') {
continue; // Truncate until the next _
}
if (bitblastedIndex) {
if (c != '_') {
continue; continue;
} else { } else {
end--; // Truncate the _
break; break;
} }
} }
} }
if (!bitblastedIndex)
end = output_port_name.end()-1;
std::string no_bitblast_prefix; std::string no_bitblast_prefix;
std::copy(output_port_name.begin(), end, std::back_inserter(no_bitblast_prefix)); std::copy(output_port_name.begin(), end, std::back_inserter(no_bitblast_prefix));
// We then truncate the port name, Result: "add" // We then truncate the port name, Result: "add"