Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Constraint in SystemVerilog

499 views
Skip to first unread message

Amir

unread,
May 17, 2009, 7:04:34 AM5/17/09
to
Hi,
I would like to write a constraint in SystemVerilog which is like:

for(int i=0;i<`DATA_TRANS;i++)
begin
constraint c_prk_data_rdy_delay {
prk_data_rdy_delay[i] inside {[lo_delay:hi_delay]};
}
end

but it's not working, do you have any idea how can I enter a variable
in an constraint such as the aforementioned example?

Thanks a lot
-Amir


Jonathan Bromley

unread,
May 17, 2009, 10:05:30 AM5/17/09
to

I guess you want a constraint on every element of
the array? That's straightforward, using an array
constraint:

constraint all_delays_sensible {
foreach (prk_data_rdy_delay[i]) {


prk_data_rdy_delay[i] inside {[lo_delay:hi_delay]};

};
}

You can also use the subscript [i] in the constraint.
So, for example, suppose you also wanted all even-numbered
elements of the array to be zero, and the highest-
numbered element of the array to be an odd number:

constraint all_delays_silly {
foreach (prk_data_rdy_delay[i]) {
if (i%2 == 0)
// Even-numbered subscript: constrain to zero
prk_data_rdy_delay[i] == 0;
else
// Odd-numbered subscript: constrain into range


prk_data_rdy_delay[i] inside {[lo_delay:hi_delay]};

// Additional constraint on highest-numbered element:
i == $high(prk_data_rdy_delay) ->
prk_data_rdy_delay[i] % 1 == 1;
}

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...@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.

Amir

unread,
May 18, 2009, 8:14:38 AM5/18/09
to

thanks :) it's working
0 new messages