Generating weighted random number - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

209


18
 
1
//-------------------------------------------------------------------------
2
//                      www.verificationguide.com
3
// In the below code,
4
// On randomization of 'a', the probabality of getting the value '1' is more. 
5
// because of more weightage is specified for '1'.
6
//-------------------------------------------------------------------------
7
module random_number;
8
  
9
  //Variable Declaration
10
  bit a;
11
  
12
  initial begin
13
    repeat(4) begin
14
      assert(randomize(a) with { a dist {0 := 4, 1 := 6}; });
15
      $display("Value of a == %0d",a);
16
    end
17
  end
18
endmodule
2
 
1
// Code your design here
2
5544 views and 2 likes     
 
SystemVerilog randomizing the number with weighted distribution.

SystemVerilog randomizing the number with weighted distribution.

170:0