Combine Direct and Random vectors.

T

terabits

Guest
Hi

This is regarding how can i make a test becnh which can take eithr
random or constrained.
for example

i have a class packet,
fields are address, data and id. all these are randomized with rand.

in the class i have some tasks, these address and data are fed to the
tasks so as to generate a complete packet,
this is well and good, now i want to have some direct test cases like
i want to give my own address and data and id,
is it possible ? i have declared them as rand bits. pls clarify

rgds
 
On 20 Feb 2007 12:43:53 -0800, "terabits" <tera.bits@gmail.com> wrote:

Hi

This is regarding how can i make a test becnh which can take eithr
random or constrained.
for example

i have a class packet,
fields are address, data and id. all these are randomized with rand.

in the class i have some tasks, these address and data are fed to the
tasks so as to generate a complete packet,
this is well and good, now i want to have some direct test cases like
i want to give my own address and data and id,
is it possible ? i have declared them as rand bits. pls clarify

The rand qualifier on your data members affects randomization,
but nothing else. You can set these data members in the usual
way, and the rand qualiifer has no effect unless you invoke
..randomize on the object.

Alternatively, you could call .randomize and add a set of highly
directed constraints using with{}.

packet my_object = new; // all members initialized
my_object.randomize(); // random values
my_object.adrs = 16'h1234; // change a data member
my_object.randomize() with {adrs==0; data==16'hABCD; id==42;};

hope this helps
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
Great it helps !!!! thanq..
i was trying using my_object.rand_mode(0); and assigning my own..
well,..with i best option..thnx
The rand qualifier on your data members affects randomization,
but nothing else. You can set these data members in the usual
way, and the rand qualiifer has no effect unless you invoke
.randomize on the object.

Alternatively, you could call .randomize and add a set of highly
directed constraints using with{}.

packet my_object = new; // all members initialized
my_object.randomize(); // random values
my_object.adrs = 16'h1234; // change a data member
my_object.randomize() with {adrs==0; data==16'hABCD; id==42;};

hope this helps
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.brom...@MYCOMPANY.comhttp://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 

Welcome to EDABoard.com

Sponsor

Back
Top