S
SB
Guest
All,
Question on the use of the real datatype in Verilog:
I have the following Verilog testbench. (DUT has been removed for
clarity)
///////////////////////////////////////////////////////////////////////////
`timescale 1ps / 1ps
module tb_test ();
reg sig_in_tb;
real current_delay;
real time1;
real time2;
real sig_in_period;
initial
begin
time1 = 0.0;
time2 = 0.0;
sig_in_period = 0.0;
current_delay = 0.0;
sig_in_tb = 1'b0;
//#1000;
current_delay = 30000;
get_clock_period;
#400000;
current_delay = 20000;
get_clock_period;
#400000;
current_delay = 10000;
get_clock_period;
#400000;
$finish;
end
always
begin
sig_in_tb = #(current_delay) ~sig_in_tb;
end
task get_clock_period;
begin
@ (posedge sig_in_tb)
begin
time1 = $realtime;
end
@ (posedge sig_in_tb)
begin
time2 = $realtime;
end
sig_in_period=time2-time1;
end
endtask
endmodule
///////////////////////////////////////////////////////////////////////////
The above task, get_clock_period, is being used to capture the period
of the clock, sig_in_tb.
It does this by capturing the time for the first positive edge on the
clock,
then the time for the next positive edge and then captures the
difference
between the two timestamps and returns this to a testbench variable
called "sig_in_period".
This is not working, for all but the last frequency on sig_in_tb.
For the first two frequencies on sig_in_tb, i.e. for the first two
values on
current_delay, the time1 and time2 values are merely the simulation
timestamp.
This ramps up as the simulation progresses.
Only at the final current_delay value, i.e. the third frequency, do
the time1 and time2 variables
get assigned the timestamps of the first and second positive edges of
sig_in_tb
after current_delay is assigned 10000.
I am using the VerilogXL simulator for this.
How do I ensure that time1 and time2 are operating correctly?
Is this problem related to improper use of the real datatype?
Thanks in advance.
SB
Question on the use of the real datatype in Verilog:
I have the following Verilog testbench. (DUT has been removed for
clarity)
///////////////////////////////////////////////////////////////////////////
`timescale 1ps / 1ps
module tb_test ();
reg sig_in_tb;
real current_delay;
real time1;
real time2;
real sig_in_period;
initial
begin
time1 = 0.0;
time2 = 0.0;
sig_in_period = 0.0;
current_delay = 0.0;
sig_in_tb = 1'b0;
//#1000;
current_delay = 30000;
get_clock_period;
#400000;
current_delay = 20000;
get_clock_period;
#400000;
current_delay = 10000;
get_clock_period;
#400000;
$finish;
end
always
begin
sig_in_tb = #(current_delay) ~sig_in_tb;
end
task get_clock_period;
begin
@ (posedge sig_in_tb)
begin
time1 = $realtime;
end
@ (posedge sig_in_tb)
begin
time2 = $realtime;
end
sig_in_period=time2-time1;
end
endtask
endmodule
///////////////////////////////////////////////////////////////////////////
The above task, get_clock_period, is being used to capture the period
of the clock, sig_in_tb.
It does this by capturing the time for the first positive edge on the
clock,
then the time for the next positive edge and then captures the
difference
between the two timestamps and returns this to a testbench variable
called "sig_in_period".
This is not working, for all but the last frequency on sig_in_tb.
For the first two frequencies on sig_in_tb, i.e. for the first two
values on
current_delay, the time1 and time2 values are merely the simulation
timestamp.
This ramps up as the simulation progresses.
Only at the final current_delay value, i.e. the third frequency, do
the time1 and time2 variables
get assigned the timestamps of the first and second positive edges of
sig_in_tb
after current_delay is assigned 10000.
I am using the VerilogXL simulator for this.
How do I ensure that time1 and time2 are operating correctly?
Is this problem related to improper use of the real datatype?
Thanks in advance.
SB