I have made this code. but can’t get unique cards. Can anyone please check and give me the solution.
typedef enum {club,diamond,spade,heart} card_e;
class distr;
rand card_e card;
rand bit[3:0] num;
constraint c2{num inside{[0:12]};}
constraint c3 {unique {num};}
constraint c1{card -> num;}
endclass
class user1 extends distr;
rand distr cardA;
rand distr numA;
function new();
cardA= new();
numA = new();
endfunction
function void get_p1();
$display("User1: %s_%d",cardA.card,numA.num);
endfunction
endclass
class user2 extends user1;
rand user1 cardB;
rand user1 numB;
function new();
cardB= new();
numB = new();
endfunction
function void get_p2();
$display("User2: %s_%d",cardB.card,numB.num);
endfunction
endclass
class user3 extends user2;
rand user2 cardC;
rand user2 numC;
function new();
cardC= new();
numC = new();
endfunction
function void get_p3();
$display("User3: %s_%d",cardC.card,numC.num);
endfunction
endclass
class user4 extends user3;
rand user3 cardD;
rand user3 numD;
function new();
cardD= new();
numD = new();
endfunction
function void get_p4();
$display("User4: %s_%d",cardD.card,numD.num);
endfunction
endclass
module aa;
user4 u4;
initial
begin
u4 = new();
repeat(13)
if (u4.randomize())
begin
u4.get_p1;
u4.get_p2;
u4.get_p3;
u4.get_p4;
end
else
$display(" Randomization fails");
end
endmodule