After randomized once , I want to use get 4 wstrb[7:0] random number as a cyclic random type.
wstrb_task.wstrb:1100 5ns
wstrb_task.wstrb:11 15ns
wstrb_task.wstrb:11000000 25ns
wstrb_task.wstrb:11000000 35ns
why is the same value generated? How to generate multiple cyclic random number? I must use fork ~join statement for another hand shake processing.
class test_c;
randc logic [7:0] wstrb [3:0];
constraint wstrb_const {
foreach (wstrb[i]) wstrb[i] inside { 8'b00000011, 8'b00001100, 8'b00110000, 8'b11000000};
}
endclass
module dut;
bit clk=0;
initial begin
forever #5 clk = ~clk;
end
test_c test;
initial begin
repeat (1) begin
fork
test = new();
assert(test.randomize());
wstrb_task(test.wstrb);
join
end
end
task automatic wstrb_task (const ref logic [7:0] in_wstrb [3:0]);
@(posedge clk);
$display("wstrb_task.wstrb:%0b", in_wstrb[0], $time);
@(posedge clk);
$display("wstrb_task.wstrb:%0b", in_wstrb[1], $time);
@(posedge clk);
$display("wstrb_task.wstrb:%0b", in_wstrb[2], $time);
@(posedge clk);
$display("wstrb_task.wstrb:%0b", in_wstrb[3], $time);
endtask
initial begin
#5000;
$finish;
end
endmodule
Here is EDA Playground implemented.