Clock Frequency Check ( considering Jitter )

I have the following assertion ::


property  clock_frequency (  real  TP ,  real  J ) ; //  TP  is  Time  Period  and  J  is  for  Acceptable  Jitter
   realtime Tpos , T ; 

   @( posedge clk )  ( 1 , Tpos = $realtime )  |=>  ( 1 , T = ( $realtime - Tpos ) ) 

   ##0  (  T  inside  { [ ( TP - J ) : ( TP + J ) ] }  )  ;  //  Doubt  here

endproperty

assert  property( clock_frequency( 10**-6  , 0.05 * ( 10**-6 ) )  //  1MHz  Clock  Frequency  with  5%  Jitter  acceptable 
        
         else  $display(" TIME : %0t  Assertion  Fails " , $time ) ;

My question is regarding the end part :: ( T inside { [ ( TP - J ) : ( TP + J ) ] } )

Will the time precision come into picture while calculating the Upper and Lower bound ? OR
Will it calculate the bounds accurately always irrespective of how small the real numbers are

In reply to hisingh:

Time scale or time units is the problem here. $realtime returns the time scaled to current time scale/unit. The period of a 1Mhz clock is 1us. If the current timescale is 1ns, $realtime returns 1000.0, not 10**-6. The you use a time literal, then you don’t have to worry about the current time scale

assert  property( clock_frequency( 1us  , 0.05 * 1us)  //  1MHz  Clock  Frequency  with  5%  Jitter  acceptable 
         else  $display(" TIME : %0t  Assertion  Fails " , $time ) ;

In reply to dave_59:

Dave ,

The period of a 1Mhz clock is 1us. If the current timescale is 1ns, $realtime returns 1000.0, not 10**-6.

Hence if timescale is 1ns , clock frequency of 1MHz i.e 1 us is scaled to 1000ns

EDIT : A short sample_code for the same .

Two quick questions ::

$realtime returns the time scaled to current time scale/unit

[Q1] Assuming that I use a time literal , would the numbers post the decimal point be taken care of automatically ?

My concern was that if the Clock period is in ns / ps / fs , would the actual argument to J ( 5% of 1ns / 1ps / 1fs ) be the appropriate value .

[Q2] What if the input argument of type ’ real ’ is unit less ? Eg: Duty Cycle .

I have code snippet as :: Duty_Cycle_EDA

     If  I  were  to  add  input  argument  to  the  property  ' duty_cycle ' .

       property  duty_cycle ( real duty , real  diff );
         realtime Tpos , Ton , T ; 

           ......................................
 
            ##0  (  T  inside  { [ duty - diff ] : [ duty + diff ] }  )  ;  

         endproperty 

       //   Duty  Cycle  Must  be  55.555 % +-  0.05 %

         assert  property( clock_frequency( 55.555  , 0.05 * ( 55.555 ) )

                 else  $display(" TIME : %0t  Assertion  Fails " , $time ) ;
       

In reply to hisingh:

Like $realtime, time literals are real type values scaled to the current timescale.

If you do not provide a time unit for a numeric literal, than it assume the number is scaled to the current timeunit where the literal is written.

In reply to dave_59:

For the duty cycle related assertion , similar to the solution to the original question I could use a time literal ::


 //   Duty  Cycle  Must  be  55.555 % +-  0.05 %  for  1MHz  Clock
 
         assert  property( clock_frequency( 555.55ns  , 0.05 * ( 555.55ns ) )

But using a time literal restricts the usage of a generic property .

If the clock period is unknown ( hence can’t use a time literal to the argument(s) ) and I simply want to check the duty cycle , is there any alternative ?

In reply to hisingh:

The way you wrote your assertion requires to know the actual clock period. Otherwise you would have to add code that calculates the running average of the clock period and then check that the jitter does not go outside N% of the average period.