vpiFullname of a package should have a "::" after the name
This commit is contained in:
parent
4251ea9553
commit
b4b8006460
|
|
@ -1,5 +1,5 @@
|
|||
Time scale of (top) is 1ns / 1ps
|
||||
Time scale of (top) is 1ns / 1ps
|
||||
Time scale of ($unit) is 100ps / 10ps
|
||||
Time scale of ($unit::) is 100ps / 10ps
|
||||
50 5
|
||||
PASSED
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Time scale of (top) is 1ns / 1ps
|
||||
Time scale of (top) is 1ns / 1ps
|
||||
Time scale of ($unit) is 100ps / 10ps
|
||||
Time scale of ($unit::) is 100ps / 10ps
|
||||
50 5
|
||||
PASSED
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Time scale of (top) is 1ns / 1ps
|
||||
Time scale of (top) is 1ns / 1ps
|
||||
Time scale of ($unit) is 100ps / 10ps
|
||||
Time scale of ($unit::) is 100ps / 10ps
|
||||
50 5
|
||||
PASSED
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Time scale of (top) is 1ns / 1ps
|
||||
Time scale of (top) is 1ns / 1ps
|
||||
Time scale of (testpackage) is 100ps / 10ps
|
||||
Time scale of (testpackage::) is 100ps / 10ps
|
||||
50 5
|
||||
PASSED
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
VCD info: dumpfile work/dumptest.vcd opened for output.
|
||||
VCD warning: $dumpvars: Package ($unit) is not dumpable with VCD.
|
||||
VCD warning: $dumpvars: Package ($unit::) is not dumpable with VCD.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <sv_vpi_user.h>
|
||||
|
||||
static PLI_INT32 check_items_calltf(PLI_BYTE8 *xx)
|
||||
{
|
||||
(void)xx; /* Parameter is not used. */
|
||||
vpiHandle th, ih;
|
||||
|
||||
// Get the top level instances.
|
||||
th = vpi_iterate(vpiInstance, NULL);
|
||||
while((ih = vpi_scan(th))) {
|
||||
vpiHandle vh;
|
||||
vpi_printf("Found an item named %s ", vpi_get_str(vpiFullName, ih));
|
||||
vpi_printf("of type %s\n", vpi_get_str(vpiType, ih));
|
||||
vh = vpi_iterate(vpiVariables, ih);
|
||||
if (vh != 0) {
|
||||
vpiHandle vi;
|
||||
while((vi = vpi_scan(vh))) {
|
||||
s_vpi_value value;
|
||||
char*str_val;
|
||||
value.format = vpiDecStrVal;
|
||||
vpi_get_value(vi, &value);
|
||||
str_val = strdup(value.value.str);
|
||||
vpi_printf(" - Has a variable named %s ", vpi_get_str(vpiFullName, vi));
|
||||
vpi_printf("of type %s and a value of %s\n", vpi_get_str(vpiType, vi), str_val);
|
||||
free(str_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
vpi_printf("All done with items\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void check_items_register(void)
|
||||
{
|
||||
s_vpi_systf_data tf_data;
|
||||
|
||||
tf_data.type = vpiSysTask;
|
||||
tf_data.tfname = "$check_items";
|
||||
tf_data.calltf = check_items_calltf;
|
||||
tf_data.compiletf = 0;
|
||||
tf_data.sizetf = 0;
|
||||
vpi_register_systf(&tf_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a table of register functions. This table is the external
|
||||
* symbol that the simulator looks for when loading this .vpi module.
|
||||
*/
|
||||
void (*vlog_startup_routines[])(void) = {
|
||||
check_items_register,
|
||||
0
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
int top_var = 1;
|
||||
|
||||
module top;
|
||||
int val = 2;
|
||||
initial begin
|
||||
#1;
|
||||
$check_items();
|
||||
end
|
||||
endmodule
|
||||
|
||||
package top;
|
||||
int val = 3;
|
||||
endpackage
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Compiling vpi/br_gh1037.c...
|
||||
Making br_gh1037.vpi from br_gh1037.o...
|
||||
Found an item named $unit:: of type vpiPackage
|
||||
- Has a variable named $unit::top_var of type vpiIntVar and a value of 1
|
||||
Found an item named top:: of type vpiPackage
|
||||
- Has a variable named top::val of type vpiIntVar and a value of 3
|
||||
Found an item named top of type vpiModule
|
||||
- Has a variable named top.val of type vpiIntVar and a value of 2
|
||||
All done with items
|
||||
|
|
@ -70,6 +70,7 @@ br_gh235 normal,-g2009 br_gh235.c br_gh235.gold
|
|||
br_gh308 normal br_gh308.c br_gh308.gold
|
||||
br_gh317 normal br_gh317.c br_gh317.gold
|
||||
br_gh496 normal,-g2009 br_gh496.c br_gh496.gold
|
||||
br_gh1037 normal,-g2009 br_gh1037.c br_gh1037.gold
|
||||
br_ml20191013 normal br_ml20191013.c br_ml20191013.gold
|
||||
by_index normal by_index.c by_index.gold
|
||||
by_name normal by_name.c by_name.log
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001-2021 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2023 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -180,10 +180,15 @@ static void construct_scope_fullname(__vpiScope*ref, char*buf)
|
|||
{
|
||||
if (ref->scope) {
|
||||
construct_scope_fullname(ref->scope, buf);
|
||||
strcat(buf, ".");
|
||||
// Add a "." separator, unless this is for a package
|
||||
if (ref->scope->get_type_code() != vpiPackage) {
|
||||
strcat(buf, ".");
|
||||
}
|
||||
}
|
||||
|
||||
strcat(buf, ref->scope_name());
|
||||
// For a package, add a "::" to the end
|
||||
if (ref->get_type_code() == vpiPackage) strcat(buf, "::");
|
||||
}
|
||||
|
||||
static const char* scope_get_type(int code)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001-2022 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2023 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -104,9 +104,13 @@ char *generic_get_str(int code, vpiHandle ref, const char *name, const char *ind
|
|||
{
|
||||
size_t len = strlen(name) + 1; /* include space for null termination */
|
||||
char *bn = NULL;
|
||||
bool is_bn_a_pkg = false;
|
||||
if (code == vpiFullName) {
|
||||
bn = strdup(vpi_get_str(code,ref));
|
||||
len += strlen(bn) + 1; /* include space for "." separator */
|
||||
size_t bn_len = strlen(bn);
|
||||
is_bn_a_pkg = bn[bn_len-1] == ':' && bn[bn_len-2] == ':';
|
||||
len += bn_len;
|
||||
if (! is_bn_a_pkg) len += 1; // include space for "." separator
|
||||
}
|
||||
if (index != NULL) len += strlen(index) + 2; /* include space for brackets */
|
||||
|
||||
|
|
@ -120,7 +124,8 @@ char *generic_get_str(int code, vpiHandle ref, const char *name, const char *ind
|
|||
/* if this works, I can make it more efficient later */
|
||||
if (bn != NULL) {
|
||||
strcat(res, bn);
|
||||
strcat(res, ".");
|
||||
// A package already has the "::" separator in the name
|
||||
if (! is_bn_a_pkg) strcat(res, ".");
|
||||
free(bn);
|
||||
}
|
||||
strcat(res, name);
|
||||
|
|
|
|||
Loading…
Reference in New Issue