PDA

View Full Version : How to pass a dynamic array to a sequence



dheeraj.ameta
07-21-2009, 02:46 AM
Hi All,
I have a requirement in which I am suppose to pass an entire array of values to a sequence. One by one these values are to be delivered to `ovm_do_with(). Can we pass an entire array (fixed or dynamic) through set_config_* methods. Or any other idea??
Thanks for the reply in advance.

-Dheeraj

dave_59
08-03-2009, 08:25 AM
The OVM config mechanism only supports three data types: int, string, and class object. So if you have a data type that is not an int or string, just wrap it in a class object. Just be mindful of the cloning options if you want to pass the arrays by value or by reference.

Dave

dheeraj.ameta
08-06-2009, 10:08 PM
The OVM config mechanism only supports three data types: int, string, and class object. So if you have a data type that is not an int or string, just wrap it in a class object. Just be mindful of the cloning options if you want to pass the arrays by value or by reference.

Dave

Thanks Dave!
I will use a class and pass the same object to the sequence by set_config_object (no clone).

-Dheeraj

avidan_efody
08-07-2009, 02:58 AM
Hi,
I'm using the following wrapper object template for all the types I need to pass with set_config_object(). This will work for every type and also for virtual interfaces (many thanks to Dave who pointed me to this fact, which I was unaware of):



class wrapper_template#(type wrapped_up_type=int) extends ovm_object;
wrapped_up_type data;
typedef wrapper_template#(wrapped_up_type) this_type;

virtual function ovm_object create(string name="");
this_type t = new();
return t;
endfunction
function void do_copy (ovm_object rhs);
this_type tmp;
tmp = this_type'(rhs);
data = tmp.data;
endfunction
endclass


And now you can do:



inteface my_if;
endinterface

typedef int int_q[$];
typedef virtual my_if my_vif;

typedef wrapper_template#(int_q) int_q_wrapper;
typedef wrapper_template#(my_vif) my_vif_wrapper;


And use int_q_wrapper and my_vif_wrapper with set_config_object().

Hope this helps,
Avidan Efody (http://www.specman-verification.com)