FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-14-2003, 04:02 PM
Peter Riocreux
Guest
 
Posts: n/a
Default PLI system functions, size checking, return values and simulatordifferences

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/>
Reply With Quote
  #2 (permalink)  
Old 08-14-2003, 08:35 PM
Swapnajit Mittra
Guest
 
Posts: n/a
Default Re: PLI system functions, size checking, return values and simulator differences

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/
Reply With Quote
  #3 (permalink)  
Old 08-19-2003, 10:23 AM
Peter Riocreux
Guest
 
Posts: n/a
Default Re: PLI system functions, size checking, return values andsimulator differences

>> "SM" == Swapnajit Mittra <[email protected]> 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/>

Reply With Quote
  #4 (permalink)  
Old 08-22-2003, 02:32 AM
Michael Neilly
Guest
 
Posts: n/a
Default Re: PLI system functions, size checking, return values and simulator differences

[email protected] (Swapnajit Mittra) wrote in message news:<[email protected] com>...
> 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 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...
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:58 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved