From 22b68ad24d8c3a70a67582e3fcce8c0e7f28e4cd Mon Sep 17 00:00:00 2001 From: Marlon James Date: Mon, 6 Nov 2023 15:48:07 -0800 Subject: [PATCH 1/2] ivtest/vpi/br_gh317: Update test for missing case of toplevel module with escaped identifier containing '.' --- ivtest/vpi/br_gh317.c | 1 + ivtest/vpi_gold/br_gh317.gold | 1 + 2 files changed, 2 insertions(+) diff --git a/ivtest/vpi/br_gh317.c b/ivtest/vpi/br_gh317.c index 94f3d251d..651d7f690 100644 --- a/ivtest/vpi/br_gh317.c +++ b/ivtest/vpi/br_gh317.c @@ -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); diff --git a/ivtest/vpi_gold/br_gh317.gold b/ivtest/vpi_gold/br_gh317.gold index e88b6c526..98cf2a5c7 100644 --- a/ivtest/vpi_gold/br_gh317.gold +++ b/ivtest/vpi_gold/br_gh317.gold @@ -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" From d4aef1e6d81b627feb5b0b03cfed973401a182f4 Mon Sep 17 00:00:00 2001 From: Marlon James Date: Mon, 6 Nov 2023 15:48:23 -0800 Subject: [PATCH 2/2] Fix vpi_handle_by_name() handling of escaped identifiers when finding a toplevel module find_scope() requires the hierarchical path to use escaped identifiers; without the leading '\' and trailing ' ', if there are any '.' characters, the path will be broken up at the wrong point(s). --- vvp/vpi_priv.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 6d6422d56..eddc0d8fe 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -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);