I understand that the std::randomize() is for non-class based randomization.
How ever, is there a guideline on where std::randomize is powerful to use? Or in other words, when you start writing a constraint how would you decide that some variables don’t need class based randomization?
I use it in light weight unit tests that consist of just a testbench module and a DUT module. Oftentimes I don’t care what the data path value is and just randomize it in hopes that it might uncover a bug.
In reply to sbellock:
I use the randomize to quickly test assertions. I use the following template saved in PhaseExpress https://www.phraseexpress.com/ (free for single user) Text Expander and Autotext Software. This is a great tool!
module top;
timeunit 1ns/100ps;
`include "uvm_macros.svh"
import uvm_pkg::*;
bit clk, a, b;
default clocking @(posedge clk);
endclocking
initial forever #10 clk=!clk;
initial begin
$timeformat(-9, 1, "ns", 8);
$display("%t", $realtime);
end
always @(posedge clk) begin
end
initial begin
bit va, vb;
repeat(200) begin
@(posedge clk);
if (!randomize(va, vb) with
{ va dist {1'b1:=1, 1'b0:=3};
vb dist {1'b1:=1, 1'b0:=2};
}) `uvm_fatal("RAND", "This is a randomize error")
#1; a <= va;
b <= vb;
end
$stop;
end
endmodule