Clock period absolute time

Is there a way to get the clock period in absolute time (i meain in terms of seconds)?

For example I have a realtime 6.4ns clock period (and timeunit is 1ns). Ho can I get this value in seconds?

Alessandro

In reply to alexkidd84:

6.4ns/1s
will give you a real number in seconds.

In reply to dave_59:

In reply to alexkidd84:

6.4ns/1s
will give you a real number in seconds.

I meant that I have stored the clock period value in a realtime variable, how can I get that value in terms of seconds (let’s suppose I don’t know the timeunit value…)?

In reply to alexkidd84:

Show me how you calculated the clock period. There’s nothing special about a realtime variable; it’s just a real variable. And how can I suppose you don’t know the clock period if you already told me?

In reply to dave_59:

In reply to alexkidd84:
Show me how you calculated the clock period. There’s nothing special about a realtime variable; it’s just a real variable. And how can I suppose you don’t know the clock period if you already told me?

for example:


timeunit 1ns
timeprecision 1ps
clk_period = 3.2ns

how can I get the value 0.0000000032 sec?
I thought that I can obtain this value by dividing clk_period per timeunit, but timeunit is a systemverilog directive…
In fact if I make clk_period/1ns and timeunit changes this formula is not more correct.

In reply to alexkidd84:

You can do

parameter real one_sec = 1s;
real clk_period, clk_period__sec;
clk_period = 3.2ns;
clk_period__sec = clk_period/one_sec;

how you calcuate clk period in your code? if its not constant then you can define timeunit and timeprecision inside class , so that it wont change for that class or pkg.


class test_class;
  timeunit 1ns;
  
  function real get_clk_in_sec();
     //add dave_59 code here.
     return clk_period__sec;
  endfunction : get_clk_in_sec