title: Calculation of time between an event in verilog
body: <p>I want to capture the time between an event. Then I have to use this value for another an event. 
  my problem is that what is the unit of time_2 in my program. How I can use this value in if loop. I think this value is not a actual value. </p>
  
  <pre><code>`timescale 1ns / 1ps
  
  module time_control( input clk  );
    reg [7:0] memory [0:15] ;
    integer k=0;
  
    realtime time_1 =0;
    realtime time_2 =0;
  
    always @ ( posedge clk)
    begin 
  
      time_2=time_1 ;
      time_1 = $realtime ;
  
       if( time_2 &lt; 500) //Comparison Not working
       begin 
         memory[k] &lt;=k;
         k         &lt;=k+1 ;
       end     
  
    end
  endmodule
  </code></pre>
  
  <p>In the programming part in the starts is not working. My question was that using the value of tine_2, i can fill the memory. whenever the value of time_2 is greater than 500 ns then it should not place the value of in the memory. i don't want to store the value of time.</p>
  
  <p>This is for simulation only.</p>