mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-15 11:45:41 +00:00
fixes for arrays
This commit is contained in:
parent
8268a79af5
commit
01f0fd751f
2 changed files with 131 additions and 11 deletions
|
|
@ -195,13 +195,38 @@ void FstData::extractVarNames()
|
|||
}
|
||||
if (clean_name[0]=='\\')
|
||||
clean_name = clean_name.substr(1);
|
||||
|
||||
// Strip bit ranges like [4:0] from the end (only if no space)
|
||||
if (!has_space) {
|
||||
size_t pos = clean_name.find_last_of("[");
|
||||
std::string index_or_range = clean_name.substr(pos+1);
|
||||
if (index_or_range.find(":") != std::string::npos) {
|
||||
clean_name = clean_name.substr(0,pos);
|
||||
if (pos != std::string::npos) {
|
||||
std::string index_or_range = clean_name.substr(pos+1);
|
||||
if (index_or_range.find(":") != std::string::npos) {
|
||||
clean_name = clean_name.substr(0,pos);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Handle "signal [index][bitrange]" format
|
||||
std::string full_name = h->u.var.name;
|
||||
size_t space_pos = full_name.find(' ');
|
||||
if (space_pos != std::string::npos) {
|
||||
std::string suffix = full_name.substr(space_pos + 1);
|
||||
// Parse first bracket pair for array index
|
||||
if (!suffix.empty() && suffix[0] == '[') {
|
||||
size_t close_bracket = suffix.find(']');
|
||||
if (close_bracket != std::string::npos) {
|
||||
std::string index_str = suffix.substr(1, close_bracket - 1);
|
||||
// Check it's an array index (no colon), not a bit range
|
||||
if (index_str.find(':') == std::string::npos) {
|
||||
int array_index = std::stoi(index_str);
|
||||
memory_to_handle[var.scope+"."+clean_name][array_index] = var.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle memory addresses
|
||||
size_t pos = clean_name.find_last_of("<");
|
||||
if (pos != std::string::npos && clean_name.back() == '>') {
|
||||
std::string mem_cell = clean_name.substr(0, pos);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue