class cfg0
rand bit[31:0] rate
constraint c_rate {rate inside {[something]};}
…
endclass
class cfg1
rand cfg0 m_cfg0[4];
…
endclass
How to constrain total rate (rate sum) in cfg1 so that the sum of m_cfg0[i].rate<N ?
class cfg0
rand bit[31:0] rate
constraint c_rate {rate inside {[something]};}
…
endclass
class cfg1
rand cfg0 m_cfg0[4];
…
endclass
How to constrain total rate (rate sum) in cfg1 so that the sum of m_cfg0[i].rate<N ?
In reply to cattt:
You can try with following code:
class cfg1;
rand cfg0 m_cfg0[4];
constraint c_rate_sume {
m_cfg0.sum(x) with (x.rate) == SOME_EXPECTED_VALUE;
};
function new();
foreach(m_cfg0[i])
m_cfg0[i] = new;
endfunction
endclass
This is the test that I created, it worked.