Use of Randomization in queues

module element;
 class abc;
   randc bit[7:0] a[$:7];
 endclass
 initial begin
    abc b = new();
    for(int i = 0; i<8; i++) 
        begin    
          if(!b.randomize()) $display("error");
            else $display ("Success");
          $display("a[%0d] = %0d", i, b.a[i]);
        end
    end
endmodule

simulation report:

Success
a[0] = 0
Success
a[1] = 0
Success
a[2] = 0
Success
a[3] = 0
Success
a[4] = 0
Success
a[5] = 0
Success
a[6] = 0
Success
a[7] = 0

In reply to Maniramadugu:

I think what you want to write is

module element;
 class abc;
   randc bit[7:0] a[8];
   constraint u_c { unique {a};}
 endclass
 initial begin
    abc b;
    b = new(); 
    if(!b.randomize()) $error("randomize failed");
            else begin
               $display ("Success");
               foreach(b.a[i]) $display("a[%0d] = %0d", i, b.a[i]);
            end
    end
endmodule

In reply to Maniramadugu:
I think what you want to write is

module element;
class abc;
randc bit[7:0] a[8];
constraint u_c { unique {a};}
endclass
initial begin
abc b;
b = new(); 
if(!b.randomize()) $error("randomize failed");
else begin
$display ("Success");
foreach(b.a[i]) $display("a[%0d] = %0d", i, b.a[i]);
end
end
endmodule

ranc is not applicable for unique function.

I want to know the concept of how to access the queues using randomization.

In reply to Maniramadugu:

I want to know the concept of how to access the queues using randomization

What do you mean by this?

A queue can be randomized in 2 steps.

  1. size constraint, if it is an unbounded queue. q.size() == length;
  2. value of each element constraint. This can be done using a foreach loop
foreach (q[i]) begin
q[i] <= x;
q[i] >= y;
end

All of this is easily available in the LRM or a simple search of the forum will lead you to your answer.

I have 1 query about FIFO.
Let say I have defined FIFO as [65:0] reg [1023:0], so what I am doing taking 5 data of 66 bit each per clock from 5 signals of the interface so 5 location will be filled. so now let’s say per clock I want to delete particular data and if in same clock data is been deleted then it should not delete other data for the same clock even though same data detected.