Question about call back routine's in vpi...

Hi Sankar,

<snipping long post>

I expect the simulator to only call you once. You said:

    ecbp->reason = cbAtStartOfSimTime;
so it called you then. Did you mean:

ecbp->reason = cbValueChange;

That will call you back on any change in the signal. Be careful, it
may call you back many times at the same sim time. It will also call
you back for ANY change, including X and Z.

Hope this helps. If you want, I have some open-source code that uses
VPI. www.trusster.com.

Take Care,
Mike Mintz
mike <> trusster <> com
 

Guest
hi all,
i facing problem in using Time related callback routine's . iam
posting my code as well.
////////////////////////this is file.c file
/*simple display of simulation time fn*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* better to install the in include directory and use <> */
#include "vpi_user.h"

/* global function prototypes */
extern void register_cbs(void);

/*
* one call in procedural code to set up not model
*
* returns 0 since required by vpi_user.h types but unused
*/


/*
* call back routine - called at start of simulation time value
changes (model goes here)
*/
static int p_prog(s_cb_data *cbp)
{

vpi_printf("p_prog called @ %x %x \n",cbp->time->high,cbp->time-
}

void register_cbs(void)
{
p_cb_data ecbp;
s_cb_data ecbrec;

vpiHandle href, iter, inh, outh;
s_vpi_time tmptim;
s_vpi_value inval;

tmptim.type = vpiSuppressTime;
vpi_printf("at 86 in call back reg\n");
/* notice cb records must be in global storage */
ecbp = &ecbrec;
// ecbp->reason = cbReadWriteSynch;
ecbp->reason = cbAtStartOfSimTime;
// ecbp->reason = cbNextSimTime;
ecbp->cb_rtn = p_prog;
ecbp->obj = NULL;
ecbp->time = &tmptim;
ecbp->value =NULL ;
ecbp->user_data = NULL;
if ((href = vpi_register_cb(ecbp)) == NULL)
vpi_printf("**ERR: cannot regiser register callback.\n");
}

/* Template functin table for added user systf tasks and functions.
See file vpi_user.h for structure definition
Note only vpi_register_systf and vpi_ or tf_ utility routines that
do not access the simulation data base may be called from these
routines
*/

void (*vlog_startup_routines[]) () =
{
register_cbs,
0
};



/* dummy +loadvpi= boostrap routine - mimics old style exec all
routines */
/* in standard PLI vlog_startup_routines */
void vpi_compat_bootstrap(void)
{
int i;

for (i = 0;; i++)
{
if (vlog_startup_routines == NULL) break;
vlog_startup_routines();
}
}
/////////////////////file.v///////////veriolg file
module test;
wire w,j;
integer i, ij;

initial begin
#10;
force w = 0;
#10;
force w = 1;
$display("@ time : %t...", $time);
#10;
force w = 1;
$display("@ time : %t...", $time);
#10;
force w = 1;
$display("@ time : %t...", $time);
#10;
force w = 1;
$display("@ time : %t...", $time);
#10;
force w = 1;
$display("@ time : %t...", $time);
#10;
force w = 1;
$display("@ time : %t...", $time);
#10;
force w = 1;
$display("@ time : %t...", $time);
#10;
force w = 1;
$display("@ time : %t...", $time);
#10;
force w = 1;
$display("@ time : %t...", $time);
$display("finishing...");
end

always @(i) $display("i is %0d", i);

endmodule
////////////////////////
in result the print stmnt in vpi call back routine is executed only
once.........
 
On Mar 6, 7:23 pm, "mmi...@gmail.com" <mmi...@gmail.com> wrote:
Hi Sankar,

snipping long post

I expect the simulator to only call you once. You said:

ecbp->reason = cbAtStartOfSimTime;

so it called you then. Did you mean:

ecbp->reason = cbValueChange;

That will call you back on any change in the signal. Be careful, it
may call you back many times at the same sim time. It will also call
you back for ANY change, including X and Z.

Hope this helps. If you want, I have some open-source code that uses
VPI.www.trusster.com.

Take Care,
Mike Mintz
mike <> trusster <> com



thx mintz...but my need is tht i hav a group of signals and i want to
read them at cont.. cycles....using vpi...n using a call back event..
 

Welcome to EDABoard.com

Sponsor

Back
Top