Merge pull request #624 from steveicarus/vvp_stop_scopes

Add more types to vvp-stop
This commit is contained in:
Stephen Williams 2022-02-26 12:14:31 -08:00 committed by GitHub
commit 85a4869ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 19 deletions

View File

@ -232,6 +232,11 @@ static void cmd_list(unsigned, char*[])
struct __vpiSignal*sig;
switch (table[idx]->get_type_code()) {
case vpiPackage:
scope = dynamic_cast<__vpiScope*>(table[idx]);
printf("package : %s\n", scope->scope_name());
break;
case vpiModule:
scope = dynamic_cast<__vpiScope*>(table[idx]);
printf("module : %s\n", scope->scope_name());
@ -292,9 +297,15 @@ static void cmd_list(unsigned, char*[])
sig->msb.get_value(), sig->lsb.get_value());
break;
case vpiPort:
printf("port : %s -- %s\n",
vpi_get_str(vpiName, table[idx]),
direction_as_string(vpi_get(vpiDirection, table[idx])));
break;
default:
printf("%8d: <vpi handle>\n",
table[idx]->get_type_code());
printf("%8s: <vpi handle>\n",
vpi_type_as_string(table[idx]->get_type_code()));
break;
}
@ -324,8 +335,6 @@ static void cmd_push(unsigned argc, char* argv[])
__vpiHandle**table;
unsigned ntable;
__vpiScope*child = 0;
if (stop_current_scope) {
table = &stop_current_scope->intern[0];
ntable = stop_current_scope->intern.size();
@ -333,18 +342,18 @@ static void cmd_push(unsigned argc, char* argv[])
vpip_make_root_iterator(table, ntable);
}
child = 0;
unsigned tmp;
for (tmp = 0 ; tmp < ntable ; tmp += 1) {
if (table[tmp]->get_type_code() != vpiModule)
__vpiScope*child = 0;
for (unsigned tmp = 0 ; tmp < ntable ; tmp += 1) {
// Try to convert this item to a scope. If this is not a
// scope, then continue.
__vpiScope*scope = dynamic_cast<__vpiScope*>(table[tmp]);
if (scope == 0)
continue;
__vpiScope*cp = dynamic_cast<__vpiScope*>(table[tmp]);
/* This is a scope, and the name matches, then
report that I found the child. */
if (strcmp(cp->scope_name(), argv[idx]) == 0) {
child = cp;
// This is a scope, and the name matches, then
// report that I found the child.
if (strcmp(scope->scope_name(), argv[idx]) == 0) {
child = scope;
break;
}
}
@ -404,6 +413,9 @@ static void cmd_where(unsigned, char*[])
case vpiModule:
printf("module %s\n", cur->scope_name());
break;
case vpiGenScope:
printf("generate %s\n", cur->scope_name());
break;
default:
printf("scope (%d) %s;\n", cur->get_type_code(), cur->scope_name());
break;
@ -464,7 +476,8 @@ static void cmd_help(unsigned, char*[])
printf("\nIf the command name starts with a '$' character, it\n"
"is taken to be the name of a system task, and a call is\n"
"built up and executed.\n");
"built up and executed. For example, \"$display foo\" will\n"
"call the function as $display(foo).\n");
}

View File

@ -39,6 +39,24 @@ FILE*vpi_trace = 0;
static s_vpi_vlog_info vpi_vlog_info;
static s_vpi_error_info vpip_last_error = { 0, 0, 0, 0, 0, 0, 0 };
const char* direction_as_string(int dir)
{
switch (dir) {
case vpiInput:
return "input";
case vpiOutput:
return "output";
case vpiInout:
return "inout";
case vpiMixedIO:
return "mixed io";
case vpiNoDirection:
return "no direction";
default:
return "INVALID-DIRECTION";
}
}
__vpiHandle::~__vpiHandle()
{ }
@ -307,7 +325,7 @@ static const char* vpi_property_str(PLI_INT32 code)
return buf;
}
static const char* vpi_type_values(PLI_INT32 code)
const char* vpi_type_as_string(PLI_INT32 code)
{
static char buf[32];
switch (code) {
@ -400,7 +418,7 @@ PLI_INT32 vpi_get(int property, vpiHandle ref)
if (property == vpiType) {
if (vpi_trace) {
fprintf(vpi_trace, "vpi_get(vpiType, %p) --> %s\n",
ref, vpi_type_values(ref->get_type_code()));
ref, vpi_type_as_string(ref->get_type_code()));
}
if (ref->get_type_code() == vpiMemory && is_net_array(ref))
@ -444,7 +462,7 @@ char* vpi_get_str(PLI_INT32 property, vpiHandle ref)
if (property == vpiType) {
if (vpi_trace) {
fprintf(vpi_trace, "vpi_get(vpiType, %p) --> %s\n",
ref, vpi_type_values(ref->get_type_code()));
ref, vpi_type_as_string(ref->get_type_code()));
}
PLI_INT32 type;
@ -452,7 +470,7 @@ char* vpi_get_str(PLI_INT32 property, vpiHandle ref)
type = vpiNetArray;
else
type = ref->get_type_code();
return (char *)vpi_type_values(type);
return (char *)vpi_type_as_string(type);
}
char*res = ref->vpi_get_str(property);

View File

@ -64,6 +64,18 @@ extern bool code_is_instrumented;
extern vpiHandle vpip_build_file_line(char*description,
long file_idx, long lineno);
/*
* vpi_type_values returns the text form of the vpi type. If the type name
* is unknown, then return the number stringified. Note that the return
* value may return to a static buffer.
*/
extern const char* vpi_type_as_string(PLI_INT32 code);
/*
* Return the port direction as a string.
*/
extern const char* direction_as_string(int dir);
/*
* Private VPI properties that are only used in the cleanup code.
*/