PLI system functions, size checking, return values and simul

P

Peter Riocreux

Guest
I have a PLI routine where the return size varies with the values of
the parameters used on the instance of the function. I want to check
(in my check function) that the size of reg being assigned into is the
same as the size I want to return.

I haven't found any documentation, either shipped with the simulators
or on the web or Google on how one uses acc_set_value to return
function values. I have been working on the assumption that it is by
using tfarg index 0. Is this right? If so, can this be made also to
work on XL which, AFAICT gives acc_handle_tfarg(0) == 0.

I can't make sure the size is right with a registered function to
return the size (in XL and ncverilog) as you don't get the parameter
that a function was instantiated with in that phase in ncverilog and
therefore I cannot determine what the size will be. Also, my
understanding is that this is a once-per-compile check for each
registered function, and I want to compare sizes on a
once-per-instance basis. Thus I have to set it to 0 in the
registration structure and this, I assume, is what results in it
reporting 32 with acc_fetch_size(acc_handle_tfarg(0))

So there are several questions in this:

1. How can I get the parameters in the size function and get that to
be done for each instance (probably impossible)

2. Can I modify what size the simulator thinks the return size is
later on, to correct it.

3. I can't work out how to get from the handle for the sysfunc or the
0th argument to the handle for the thing being assigned to - can
anyone help?

Pete

--
Peter Riocreux, Amulet Group, Dept. Computer Science, Manchester University,
Oxford Road, MANCHESTER, M13 9PL, UK. <http://www.cs.man.ac.uk/apt/>
 
Peter Riocreux <priocreux@cs.man.ac.uk> wrote in message news:<9kr83o1gmw.fsf@cs.man.ac.uk>...
I have a PLI routine where the return size varies with the values of
the parameters used on the instance of the function. I want to check
(in my check function) that the size of reg being assigned into is the
same as the size I want to return.

I haven't found any documentation, either shipped with the simulators
or on the web or Google on how one uses acc_set_value to return
function values. I have been working on the assumption that it is by
using tfarg index 0. Is this right? If so, can this be made also to
work on XL which, AFAICT gives acc_handle_tfarg(0) == 0.

I can't make sure the size is right with a registered function to
return the size (in XL and ncverilog) as you don't get the parameter
that a function was instantiated with in that phase in ncverilog and
therefore I cannot determine what the size will be. Also, my
understanding is that this is a once-per-compile check for each
registered function, and I want to compare sizes on a
once-per-instance basis. Thus I have to set it to 0 in the
registration structure and this, I assume, is what results in it
reporting 32 with acc_fetch_size(acc_handle_tfarg(0))

So there are several questions in this:

1. How can I get the parameters in the size function and get that to
be done for each instance (probably impossible)

2. Can I modify what size the simulator thinks the return size is
later on, to correct it.

3. I can't work out how to get from the handle for the sysfunc or the
0th argument to the handle for the thing being assigned to - can
anyone help?

Pete
Hello Pete,

One way of solving your problem will be to approach it a bit
differently.

1. Convert the PLI routine to a user-defined task (from a
user-defined function).

2. Pass the return size and an extra argument to hold the output
value. The size of this extra argument will the largest possible
return size.

3. Do the checking of the assignment inside the PLI application.
(Most likely, you will end up doing it in checktf though).

4. Once returned, use the value of the extra argument as the
output of your PLI application.

HTH.
- Swapnajit.
--
=-=-= 100% pure Verilog PLI - go, get it ! =-=-=
Principles of Verilog PLI -By- Swapnajit Mittra
Kluwer Academic Publishers. ISBN: 0-7923-8477-6
http://www.angelfire.com/ca/verilog/
 
"SM" == Swapnajit Mittra <mittra@juno.com> writes:
SM> One way of solving your problem will be to approach it a bit
SM> differently.

SM> 1. Convert the PLI routine to a user-defined task (from a
SM> user-defined function).

A bit of lateral thinking there, thanks. It is of course v. easy, and
quite portable if you do it this way. Thanks for the suggestion.

Peter

--
Peter Riocreux, Amulet Group, Dept. Computer Science, Manchester University,
Oxford Road, MANCHESTER, M13 9PL, UK. <http://www.cs.man.ac.uk/apt/>
 
mittra@juno.com (Swapnajit Mittra) wrote in message news:<57666134.0308141037.7c391d28@posting.google.com>...
Peter Riocreux <priocreux@cs.man.ac.uk> wrote in message news:<9kr83o1gmw.fsf@cs.man.ac.uk>...
I have a PLI routine where the return size varies with the values of
the parameters used on the instance of the function. I want to check
(in my check function) that the size of reg being assigned into is the
same as the size I want to return.
I would use a different calling convention and avoid the return size issue.
Instead of using:

return_reg = $plicall(arg1,arg2....argN);

you could use

$plicall(return_reg,arg1,arg2....argN);

Then you can get the handle and fetch the size for return_reg to check
against any of your other arguments as you wish.


I haven't found any documentation, either shipped with the simulators
or on the web or Google on how one uses acc_set_value to return
function values. I have been working on the assumption that it is by
using tfarg index 0. Is this right? If so, can this be made also to
work on XL which, AFAICT gives acc_handle_tfarg(0) == 0.
tf_putp(0,return_value);

This is limited to 32 bit though...
 

Welcome to EDABoard.com

Sponsor

Back
Top