Peter Riocreux <
[email protected]> wrote in message news:<
[email protected]>...
> 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/