vpiHandle for a portion of a vector

Guest
Hey all,

I have been banging my head against this for quit some time and cant
seem to find a reasonable solution. I have a very large vector of
100bits (ex test_bench.my_vector[0:99]) and I need to deposit data to
it using VPI calls. I know I am limited to 32 bit access to this using
vpi_put_value with a vector_val. What I would love is to be able to
get handles to a sub set of the bits in the vector.

For example I would love to have a vpiHandle to
test_bench.my_vector[0:9] and another vpi_handle to
test_bench.my_vector[10:19] ... etc. I have seen only one way of do
this by passing the bits to my c routine in the $task but I dont wish
to impliment it that way. I know how I want to partition the bits,
and know the path to the vector .. there must be a way to get these
handles without having to set up call backs for all the large vectors
in the design I have been given. If anyone has any ideas I would
greatly appreciate it.


-- Paul
 
On Wed, 11 Jul 2007 20:04:20 -0000, lumby.fruitloop@gmail.com wrote:

Hey all,

I have been banging my head against this for quit some time and cant
seem to find a reasonable solution. I have a very large vector of
100bits (ex test_bench.my_vector[0:99]) and I need to deposit data to
it using VPI calls. I know I am limited to 32 bit access to this using
vpi_put_value with a vector_val.
Not quite - set the format to vpiVectorVal, and then set value.vector
to a pointer to an *array* of s_vpi_vecval structures. Each struct
covers 32 bits of the vector, so you can use
vpi_get_value/vpi_put_value for vectors of any size.

What I would love is to be able to
get handles to a sub set of the bits in the vector.
You can get a handle to a bit-select with vpi_handle_by_index. I don't
think you can get a handle to a part-select; you could try
vpi_get_handle_by_name, but I don't think it'll work.

Have you got 'The Verilog PLI Handbook'? You should get it if not;
ISBN 0-7923-7658-7.

Evan
 
I dont know whether this is standard or not. But handle to part select
is possible in VCS. I will write a small example that will exactly do
that. I am one of the person who implements all these for VCS. Trust
me

Here I am trying to see all the 100 bits and I can see the value using
vpiBinStrVal , why not,

Verilog file
---------------------
module top;
reg [0:99]a;

initial
begin
#1
a[4:16] = 1155;
#1 $display($time, ,"%b", a[5:10]);
#1
$pli(a[0:99]);
end
endmodule

PLI file to get the handle,
----------------------------
#include <stdio.h>
#include "acc_user.h"
#include "vpi_user.h"
int pli(){
vpiHandle h1, h2, h3, h4;
h1 = vpi_handle(vpiSysTfCall, NULL);
h2 = vpi_iterate(vpiArgument, h1);
while ( h3 = vpi_scan(h2)) {
s_vpi_value val= {vpiBinStrVal};
vpi_printf(" the name of the handle is %s\n",
vpi_get_str(vpiFullName, h3));
vpi_get_value (h3, &val);
vpi_printf(" the value is %s\n", val.value.str);
}
}

All the output is visible here ,What more
Contains Synopsys proprietary information.
Compiler version Z-2007.06-A[D] (ENG); Runtime version Z-2007.06-A[D]
(ENG); Jul 16 09:28 2007

2 010010
the name of the handle is top.a[0:99]
the value is
xxxx0010010000011xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Do tell me if it helps
 
Sorry
The last mail was mine. I made it from my sis' account. She had
logged in previously.

My apologies
 
On Mon, 16 Jul 2007 16:31:23 -0000, "parag_paul@hotmail.com"
<parag_paul@hotmail.com> wrote:

Verilog file
---------------------
$pli(a[0:99]);
<snipped>

the value is
xxxx0010010000011xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I may have misunderstood, but I don't think this is what the OP asked
for. He says

I have seen only one way of do
this by passing the bits to my c routine in the $task but I dont wish
to impliment it that way
which is also what you're doing. I think he wants to make part selects
from inside the *C* code.

Anyway, the OP seems to have lost interest, so I guess we'll never
find out.

Evan
 
hi Evan
yes , you can do that to, Twea k with the pli call. Make it
$pli(a[3:4])
I just wanted to tell, the user that all the 100 bits are possible


He was asking this too. He wanted to break it up coz he could not get
bigger numbers. YOu can do anything with VCS debug.

Also, that, let us keep the issue open and bleeding if someone else
ever open this archives.
Some day or the other they do come up in Google searches for novices
 
On Mon, 16 Jul 2007 19:47:41 -0000, "parag_paul@hotmail.com"
<parag_paul@hotmail.com> wrote:

I think you might have misunderstood me. The OP said:

I have seen only one way of do
this by passing the bits to my c routine in the $task but I dont wish
to impliment it that way
Your code does exactly this, so I replied to you:

which is also what you're doing. I think he wants to make part selects
from inside the *C* code.
Your response was:

yes , you can do that to, Twea k with the pli call. Make it
$pli(a[3:4])
but your suggestion is again a part-select within the *Verilog* code,
not the *C* code. My original suggestion to him was that he might be
able to do this with vpi_get_handle_by_name, but I thought it probably
wouldn't work. If you can change your code so that your Verilog call

can print out, for example, "the name of the handle is top.a[10:20]",
instead of

then you will, I think, have answered the OP's second question. Your C
code will need to make the part-select.

Yes, there are multiple ways to answer the OP's first question, about
how to handle all 100 bits. I suggested using vpiVectorVal, and you
suggested using vpiBinStrVal. I suggested vpiVectorVal because it's
more efficient. Sutherland covers this in detail on p153, where he
states that "the least efficient method for run-time performance is to
retrieve a logic value as a C string".

Evan
 
Thanks Evan


I should not switiching context like this,
We can have a many ways of doing this.

ONe is the vpi_handle_by_name ,
do this in the in pli

vpiHandle h1 ;
h1 = vpi_handle_by_name("top.a[2:35]", NULL);
s_vpi_value val = {vpiBinStrVal };
vpi_get_value(h1, &val )

that should do the job equally well.
About the BinStrVal thing, Memory wise it may be more efficient to do
so using Vectors, but internally ( I am opening a can of worms open )
there are a lot of ways the implementations may handle this. They may
take a string and fill out a vector ( yes that can be the ugly truth )

Give me some time. I will tell you the most efficient way to handle
this


Also there is another way, Try and find out the indices and then make
handles for the partselects you want by making strings out of them and
calling vpi_handle_by_name ( obviously you know that )
 
Sorry for being among the missing guys I have not lost interest but I
have lost my cube and computer access for the past few says lol.

I am back in action and trying to find a solution to this problem.
Paul I appreciate all the time you put in to trying to provide me a
solution to this problem. Your solution however is (as Evan points
out) like one the I have seen already that splits up the bus by
passing a portion of it in the argument list of a $task call. I don't
wish to do this as I have over 15 100bit vectors that I need broken up
and the $tasks would be a very messy way to implement this splitting.
In the mean time I have use the array of vector_vals to pass data to
the whole 100bit vector every time I want change a small section of it
but would still like to be able to split it up if possible. If anyone
has seen a way of doing this with out $task args I would greatly
appreciate knowing how.

Again sorry for my absence :-(


-- Paul
 
Sorry for not getting back to you guys for so long. I have not lost
interest in by any means but I did loose my cube and access to my
computer for period of time lol. But I am back in action and looking
to solve this problem.

first of all I want thank you for all you help and suggestions. Paul
the suggestion you have provided would work but it will require a
multitude of $task calls to be able to split up the dozen or so 100bit
vectors I have into smaller handles. This is an implementation I don't
wish to have as I feel it will be too messy.

I did how ever mange to get by using Evans suggestion of arrays of
vector_vals that I am passing to vpi_put_value. Again not
implementation i am happy with but it also gets the job done.

If anyone has seen away to slice up these big vectors without using
$task args please put up post so we can all learn. Seems like this is
not a commonly needed thing and I am just lucky enough to be given
such huge vectors to work with :)

Again Thanks for all the help and patience with my lack of response
time :)

-- Paul
 
Mistake on my account.

But yes we can also do that, make a vpi_handle_by_name.
Let me put the pli code.
I think you know how to do it, just for convenience


p1.v
--------------
module top;
reg [0:99]a;

initial
begin
#1
a[4:16] = 1155;
#1 $display($time, ,"%b", a[5:10]);
#1
$pli();
end
endmodule


p1.c
----------------------------
 
Here is the verilog code that will do it. Sorry could not get time to
write earlier

I think Evan you know how to do it. I am still typing the new solution
that you propose ( and I agree that is better than the string
manipulation ., obviously ) Stu's book need not be a yarstick any s/
w engg should know that

p1.v
----------------
module top;
reg [0:99]a;

initial
begin
#1
a[4:16] = 1155;
#1 $display($time, ,"%b", a[5:10]);
#1
$pli();
end

p1.c
----------------------
#include <stdio.h>
#include "acc_user.h"
#include "vpi_user.h"
int pli(){
vpiHandle h1,h2,h3,h4,h5;
h1 = vpi_handle_by_name ("top.a[3:63]",NULL);
s_vpi_value val = {vpiVectorVal};
vpi_get_value ( h1, &val);
vpi_printf(" the value is %x and %x\n", val.value.vector[0].aval,
val.value.vector[0].bval);
vpi_printf(" the second vcector is %x and %x \n",
val.value.vector[1].aval, val.value.vector[1].bval);
}



p1.tab
---------
$pli call=pli

vcs -debug_all p1.v p1.c -P p1.tab


and output will be

2 010010
the value is ffffffff and ffffffff
the second vcector is 1241ffff and 10007fff



So we can actually, get the handle using name and then do whatever we
want , also set callbacks on the part selects, anything sir

-Parag
endmodule
 

Welcome to EDABoard.com

Sponsor

Back
Top