Std::randomize specific use

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?

Thanks

In reply to UVM_learner6:

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     

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr


  1. SVA Alternative for Complex Assertions
    Verification Horizons - March 2018 Issue | Verification Academy
  2. SVA: Package for dynamic and range delays and repeats | Verification Academy
  3. SVA in a UVM Class-based Environment
    SVA in a UVM Class-based Environment | Verification Horizons | Verification Academy

In reply to ben@SystemVerilog.us:

Thank you, that was very helpful. Also the idea about unit tests and quick assertions check.