[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gEDA: VPI in Icarus Verilog



Hi all,

	I decided to have a go at writing a VPI module for Icarus Verilog and have a
few observations/questions:

1) When a callback is registered using vpi_register_cb() who allocates/owns
the memory pointed to by the argument?  The Verilog-1995 standard is not clear
on this point, except to say that when the callback is called the pointer to
the cb_data structure is not a pointer to the same structure as was passed to
the vpi_register_cb() function.  This would imply a copy of the data structure
is made somwhere in the simulator engine.  Does IVL make such a copy?  Or do I
need to allocate memory with malloc() to store these things? (Who cleans up?)
(The standard is also confusing as it uses `static' in the example for these
structures.)  Also, if I pass in a NULL cb.value pointer, I get a NULL value
pointer back later when the callback is called... I had expected one to be
allocated for me to read from when the callback is called, this is how it
worked with PLI.

2) Callbacks only seem to happen once, yet the standard implies that once a
callback has been installed it keeps getting called. (At least for
cbValueChange events.)  This is how it worked with PLI, so I had expected it
to work the same in VPI.  The example given in the standard is a simple
`$monitor' type function, and does not have a re-activation inside it like the
IVL provided $monitor implementation in sys_display.c.

3) The VPI loading diagnostics could be improved. :-) I was having trouble
loading my VPI module because there were some unresolved symbols (leftover PLI
calls...), but the only message I got from vvp was that it couldn't find the
vpi module.  I added a call to `dlerror()' and discovered the real error. 
Perhaps during the looking for-the-module-in-the-path phase you could use
`stat()' instead of `dlopen()' to test for the existance of the file, then if
the file is actually present, do a call to `dlopen()' whith a printout of
`dlerror()' if that fails? (I can write a patch for this if you want.)

Otherwise my VPI module seems to work, which is pretty cool on a GPL
simulator!  (So I am not limited to working at work, which is a good thing(?)
;-)

-- 
--------------------------------------------------
                              Mike Jarabek
                                FPGA/ASIC Designer
   http://www.doncaster.on.ca/~mjarabek
--------------------------------------------------