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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...