Merge pull request #1023 from marlonjames/fix-escaped-vpi_handle_by_name

Fix vpi_handle_by_name() for toplevel modules with escaped identifiers
This commit is contained in:
Cary R 2023-11-06 18:43:02 -08:00 committed by GitHub
commit 28987277ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View File

@ -17,6 +17,7 @@ static PLI_INT32 CompileTF(PLI_BYTE8 *x)
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle scope = vpi_handle(vpiScope, callh);
get_type("\\esc.mod ", NULL);
get_type("\\esc.port", scope);
get_type("\\esc.port ", scope);
get_type("\\esc.mod .\\esc.inm .\\esc.port", NULL);

View File

@ -1,5 +1,6 @@
Compiling vpi/br_gh317.c...
Making br_gh317.vpi from br_gh317.o...
Looking for "\esc.mod ": found "esc.mod"
Looking for "\esc.port": found "esc.port"
Looking for "\esc.port ": found "esc.port"
Looking for "\esc.mod .\esc.inm .\esc.port": found "esc.port"

View File

@ -1473,16 +1473,6 @@ vpiHandle vpi_handle_by_name(const char *name, vpiHandle scope)
*(nm_base-1) = 0;
}
if (*nm_base == '\\') {
// Skip the \ at the beginning
++nm_base;
// Drop the space at the end if it exists
if ((next = strchr(nm_base, ' '))) {
*next = 0;
}
}
// If there is no escaped identifier then just look for the last '.'
} else {
nm_base = strrchr(nm_path, '.');
@ -1554,6 +1544,18 @@ vpiHandle vpi_handle_by_name(const char *name, vpiHandle scope)
hand = tmp;
}
// find_name() expects escaped identifiers to be stripped
if (*nm_base == '\\') {
// Skip the \ at the beginning
++nm_base;
// Drop the space at the end if it exists
char *next;
if ((next = strchr(nm_base, ' '))) {
*next = 0;
}
}
// Now we have the correct scope, look for the item.
vpiHandle out = find_name(nm_base, hand);