Jump to content

Recommended Posts

*,

How can I randomize with a dist and specify a weight for values not being inside a range?

 class randclass;
    rand logic [3:0] randvalue;

    function void post_randomize();
      $display("value: %0d",randvalue);
    endfunction

   constraint inside_practice {
     randvalue dist {
       [3:4] :/ 50,
       !(inside {[3:4]}) :/ 50    //<---  I try to have a sort of 'others' category here
     };
   }   
 endclass

module top;
  randclass randclass;

  initial begin
    randclass = new();
    repeat (10) begin 
      randclass.randomize();
    end
    $finish();
  end
endmodule

 

Reference:  https://www.edaplayground.com/x/cV5 

 

shaking off the rust after a SystemVerilog hiatus,

thanks

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×