Constraint in SystemVerilog

A

Amir

Guest
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 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
 
On Sun, 17 May 2009 04:04:34 -0700 (PDT), Amir wrote:

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 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?

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) {
prk_data_rdy_delay inside {[lo_delay:hi_delay]};
};
}

You can also use the subscript 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) {
if (i%2 == 0)
// Even-numbered subscript: constrain to zero
prk_data_rdy_delay == 0;
else
// Odd-numbered subscript: constrain into range
prk_data_rdy_delay inside {[lo_delay:hi_delay]};

// Additional constraint on highest-numbered element:
i == $high(prk_data_rdy_delay) ->
prk_data_rdy_delay % 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.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.
 

Welcome to EDABoard.com

Sponsor

Back
Top