Creating HDL Text Modules, страница 38

9.5 Running the Wizard

4.  Start the wizard with the VHPI/PLI Wizard command from the Tools menu.

5.  Start the wizard with the VHPI/PLI Wizard command from the Tools menu.


7.  Type dump_hierarchy in the VHDL procedure/function/ architecture name field. Set the remaining options as shown in the figure above.

8.  Press Modify list, then Generate, and close the window by clicking OK.

9.6 Reviewing Created Files

7.  Review the list of files created by the wizard. The list is printed to the Console window.

# Design: Created file C:\My_Designs\Samples_62\Datapath\src\VHPI\vhpiuser_aldec.cpp

# Design: Created file C:\My_Designs\Samples_62\Datapath\src\VHPI\dump_hierarchy_vhpi.h

# Design: Created file C:\My_Designs\Samples_62\Datapath\src\VHPI\dump_hierarchy_vhpi.cpp

# Design: Created file C:\My_Designs62\Samples_62\Datapath\src\VHPI\dump_hierarchy_vhpi.vhd

The files are also visible in the VHPI folder in the Design Manager.

Also a DLM C/C++ configuration file is automatically added for building the application.

9.7 Editing C Code

8.  The dump_hierarchy_vhpi.cpp file contains an empty body of the dump_hierarchy_proc function.

          The following slides show complete code for the modified dump_hierarchy_vhpi function and for an auxiliary traverse_hierarchy routine.

          Before editing the functions add the following #include directive to the beginning of the dump_hierarchy_vhpi.cpp file:

                    #include "stdio.h"

9.8 dump_hierarchy_vhpi function

Replace the // put your code here comment in the dump_hierarchy_vhpi.cpp file with following code:

vhpiHandleT rootInstHdl = NULL; // handler to rootInst component

vhpiHandleT iteratorSigHdl = NULL; // iterator for SigDecls

vhpiHandleT Hdl = NULL; // handler

vhpiHandleT archBodyHdl = NULL; // handler to archBody

vhpiHandleT entityDeclHdl = NULL; // handler to entityDecl

int numObjs = 0;   // initialize objects counter

vhpi_printf("\nUsing VHPI application as Foreign Architecture to count declared signals...");


if ( rootInstHdl = vhpi_handle(vhpiRootInst, NULL) ){


          // signal declarations

          if ( iteratorSigHdl= vhpi_iterator(vhpiSigDecls, rootInstHdl) )


                    while ( Hdl = vhpi_scan(iteratorSigHdl) ){

                              // handler points to object of type vhpiSignalDeclK (signal)

                              vhpi_printf("found signal: %s ", // signal name

                              vhpi_get_str(vhpiNameP, Hdl));




9.8. dump_hierarchy_vhpi (continued)

(function defined in the dump_hierarchy_vhpi.cpp file continued)

          traverse_hierarchy(rootInstHdl, &numObjs);

          //  fetching some information about analyzed design:

          //  name of architecture of top level design

          if ( archBodyHdl = vhpi_handle(vhpiDesignUnit, rootInstHdl) ){

                    // name of entity of top level design

                    if ( entityDeclHdl = vhpi_handle(vhpiPrimaryUnit, archBodyHdl) ){



                              vhpi_printf("Analyzed entire design '%s' contains %d signal(s)",
                                       vhpi_get_str(vhpiNameP, entityDeclHdl), numObjs);




vhpi_printf("\nEnd of Your VHPI application.......");

9.9 traverse_hierarchy function

Above the dump_hierarchy_proc function type the following code:

PLI_VOID traverse_hierarchy(vhpiHandleT ScopeHdl, int *numObjs){

          vhpiHandleT iteratorSigHdl = NULL; // iterator for SigDecls

          vhpiHandleT iteratorRegHdl = NULL; // iterator for InternalRegions

          vhpiHandleT Hdl = NULL; // handler