Constraints can be declared as class properties.
- No end-of-line semi-colon
Constraints can enforce dependencies for randomization.
- Size of dynamic array must equal len property
Dynamic array is now rand. Both size and contents are randomized, but… …size is randomized first post_randomize and data_rand methods are no longer required.
01.
class
randframe;
02.
local
logic
[3:0] addr;
03.
rand
local
logic
[3:0] len;
04.
rand
logic
[7:0] data_arr [];
05.
06.
function
new
(input
logic
[3:0] pa);
07.
addr = pa;
08.
endfunction
09.
10.
constraint framelength {
11.
data_arr.size() == len;
12.
}
13.
14.
endclass
15.
16.
randframe one =
new
(.pa(5));
17.
18.
initial
begin
19.
assert
(one.randomize() with {len>0; len<=7;});
20.
...