random_pulse_gen.svh 911 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
module random_pulse_gen
  (
   input enable_i,
   output reg pulse_o
   );


   parameter real g_pulse_width  = 30ns;
   parameter real g_min_spacing  = 300ns;
   parameter real g_max_spacing  = 600ns;
11 12 13 14
   parameter int  g_repetition = 1;
   parameter real g_burst_spacing = 50ns;
   
   
15 16 17 18 19 20
   int seed 			 = 1;
   

   initial forever
     if(enable_i)
       begin
21 22
          int i;
          
23 24
	  real delta;
	  seed 	   = $urandom(seed);
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
25
	  delta    = $dist_uniform(seed, g_min_spacing - g_pulse_width, g_max_spacing - g_pulse_width);
26 27 28 29 30 31 32 33 34
	  for(i=0;i<g_repetition;i++)
            begin
               pulse_o  = 1;
	       #(g_pulse_width);
	       pulse_o  = 0;
               if(g_repetition > 1)
                 #(g_burst_spacing);
               
            end
35
	  
36 37
          #(delta);
          
38 39
       end else begin
	  pulse_o <= 1'b0;
40
	  @(posedge enable_i);
41 42 43
       end
   
endmodule // random_pulse_gen