pavel47
Member level 4
- Joined
- Nov 8, 2005
- Messages
- 68
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Switzerland
- Activity points
- 1,790
Hello,
While accessing simple module instances is quite simple, the same procedure for "module instances inside of generate loop" isn't so simple.
Here is module, where I want to access to module instance array:
Here is VPI routine, I use:
And here is simulation output:
As you can constate the modules inside of generate loop aren't revealed (scope U_DUT) ...
Any ideas ?
Regards.
Pavel.
While accessing simple module instances is quite simple, the same procedure for "module instances inside of generate loop" isn't so simple.
Here is module, where I want to access to module instance array:
Code:
`timescale 1us/1ns
`define reg_len 16
module Shift_REG(input Din, CLK, LOAD, [`reg_len-1:0] DATA_L, output Dout);
wire [`reg_len-1:0] DATA;
genvar i;
assign Dout = DATA[`reg_len-1];
initial begin
#1 $module_explore;
end
DFF_wload U0(.D(Din), .CLK(CLK), .DL(DATA_L[0]), .LOAD(LOAD), .Q(DATA[0]));
generate
for (i = 0; i < `reg_len; i = i + 1) begin : Loop_DFF
if(i == 0)
DFF_wload U_DFF(.D(Din), .CLK(CLK), .DL(DATA_L[0]), .LOAD(LOAD), .Q(DATA[0]));
else
DFF_wload U_DFF(.D(DATA[i-1]), .CLK(CLK), .DL(DATA_L[i]), .LOAD(LOAD), .Q(DATA[i]));
end
endgenerate
endmodule
Here is VPI routine, I use:
Code:
//**********************************************************************
#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 module_arr_iterator, module_arr_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)
{
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");
module_arr_iterator = vpi_iterate(vpiModuleArray, scope_handle);
if (module_arr_iterator != NULL)
{
vpi_printf("List of modules arrays:\n");
while ((module_arr_handle = vpi_scan(module_arr_iterator)) != NULL )
{
vpi_printf("\tModule Array Name: %-10s\n", vpi_get_str(vpiName, module_arr_handle));
}
}
else
vpi_printf("\tThis scope doesn't contain module arrays\n");
}
return(0);
}
And here is simulation output:
Code:
restart
# Loading D:\PROJ_ModelSim\PLI_LIB\mti_pli_apps.dll
# Refreshing D:\PROJ_ModelSim\PLI_Routines_Explore\work.Shift_REG
# Loading work.Shift_REG
run
#
# Scope is: Shift_REG_TB
# List of modules:
# Module Name: U_DUT
# This scope doesn't contain module arrays
#
# Scope is: U_DUT
# List of modules:
# Module Name: U0
# This scope doesn't contain module arrays
As you can constate the modules inside of generate loop aren't revealed (scope U_DUT) ...
Any ideas ?
Regards.
Pavel.