Randomization of time delay #t us. How to?

Hello everyone,

Is it possible to randomize the time delay in order to create random sequences? What I mean is for example,

forever loop
begin
sig_value = 1’b1;
#10ns
sig_value = 1_b0;
# random_delay
end

Can someone shed light on how to do this? Thank you in advance.

You can’t randomize time variables directly, but you can randomize an integer and multiply that by your desired time unit:


module top;
  
  initial begin
    int some_rand_delay;
    
    std::randomize(some_rand_delay) with {
      some_rand_delay < 5;
      some_rand_delay > 2;
    };
    
    #(some_rand_delay * 1ns);
    $display("time = ", $time);
    
    $finish();
  end

endmodule