//**********************************************************************
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "vpi_user.h"
PLI_INT32 PLI_Module_Explore_CallTF(PLI_BYTE8 *user_data);
/**********************************************************************
* VPI Registration Data
*********************************************************************/
void PLI_Module_Explore_RGSTR()
{
s_vpi_systf_data tf_data; /* allocate register data structure */
tf_data.type = vpiSysTask;
tf_data.sysfunctype = 0;
tf_data.tfname = "$module_explore";
tf_data.calltf = PLI_Module_Explore_CallTF;
tf_data.compiletf = NULL;
tf_data.sizetf = NULL;
tf_data.user_data = NULL;
vpi_register_systf(&tf_data);
}
/*********************************************************************/
PLI_INT32 PLI_Module_Explore_CallTF(PLI_BYTE8 *user_data)
{
vpiHandle systf_handle, scope_handle;
vpiHandle module_iterator, module_handle;
vpiHandle gen_scope_iterator, gen_scope_handle;
vpiHandle gen_state_handle;
vpiHandle module_with_generate_handle;
systf_handle = vpi_handle(vpiSysTfCall, NULL);
scope_handle = vpi_handle(vpiScope, systf_handle);
vpi_printf("\nScope is: %-10s\n", vpi_get_str(vpiName, scope_handle));
if (vpi_get(vpiType, scope_handle) == vpiModule)
{
// Get list of modules
module_iterator = vpi_iterate(vpiModule, scope_handle);
if (module_iterator != NULL)
{
vpi_printf("List of modules:\n");
while ((module_handle = vpi_scan(module_iterator)) != NULL )
{
vpi_printf("\tModule Name: %-10s\n", vpi_get_str(vpiName, module_handle));
}
}
else
vpi_printf("\tThis scope doesn't contain modules\n");
[B] module_with_generate_handle = vpi_handle_by_name("Shift_REG_TB.U_DUT", NULL);
// Get list of generate statements
gen_scope_iterator = vpi_iterate(vpiGenScope, module_with_generate_handle);
if (gen_scope_iterator != NULL)
{
vpi_printf("List of generate statements:\n");
while ((gen_scope_handle = vpi_scan(gen_scope_iterator)) != NULL )
{
vpi_printf("\tExpression: %-10s\n", vpi_get_str(vpiName, gen_scope_handle));
}
}
else
vpi_printf("\tThis scope doesn't contain generate statements\n");[/B]
gen_state_handle = vpi_handle_by_name("Shift_REG_TB.U_DUT.Loop_DFF[0]", NULL);
if (gen_state_handle != NULL)
vpi_printf("\nShift_REG_TB.U_DUT.Loop_DFF[0] type: %s", vpi_get_str(vpiType, gen_state_handle));
gen_state_handle = vpi_handle_by_name("Loop_DFF[0]", scope_handle);
if (gen_state_handle != NULL)
{
vpi_printf("\nLoop_DFF[0] type: %s", vpi_get_str(vpiType, gen_state_handle));
}
}
return(0);
}