Hi, My name is Divyang. I am facing one issue related to timescale and it described below:
[1] There are 2 class defined with different-different timescale. One class is inside a package and another one is not.
[2] Package and Class are included in Module Top and after that there is another timescale define in Module Top.
[3] We are printing timescale in Module as well as in both classes.
[4] Now, Issue is while printing timescale from independent class is not same as defined in class. Printing default timescale(1ps/1ps)
I need a help on this. Why defined timescale not taken and took default one?
Code is as per below:
#**************************************************************************************************************************
(A) Module Top::
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
`include "timescale_package.sv"
import timescale_package::*;
`include "timescale_independent_class.svh"
`timescale 10ns/1ps
module time_scale_experiment;
timer_class timer_class;
timescale_independent_class timescale_independent_class;
initial begin
timer_class = new();
timescale_independent_class = new();
$printtimescale(time_scale_experiment);
#1;
$display("%0gns, %0f Calling Time Class Delay Timer", ($realtime * 10), $realtime);
timer_class.delay();
$printtimescale;
#1;
$display("%0gns, %0f Time Class Delay Timer Done", ($realtime * 10), $realtime);
#50ns;
$display("\n\n%0gns, %0f Calling Independent Class Delay Timer", ($realtime * 10), $realtime);
timescale_independent_class.delay();
$printtimescale;
#1;
$display("%0gns, %0f Independent Class Delay Timer Done", ($realtime * 10), $realtime);
#50ns;
$display("%0gns, %0f Finish Done",
($realt
ime * 10), $realtime);
end
endmodule
(B) Timescale Package::
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
`ifndef TIMER_CLASS_SV
`define TIMER_CLASS_SV
`define TIME_UNIT 100ns
`define TIME_PRECISION 1ps
package timescale_package;
timeunit `TIME_UNIT;
timeprecision `TIME_PRECISION;
class timer_class;
function new();
$display("%0gns, %0f Timer Class:: Instantiation Done", ($realtime * 100), $realtime);
endfunction
task delay();
$printtimescale;
$display("%0gns, %0f Timer Class:: Waiting for Delay", ($realtime * 100), $realtime);
#11;
$display("%0gns, %0f Timer Class:: Waiting for Delay Done", ($realtime * 100), $realtime);
endtask
endclass : timer_class
endpackage
`endif
(C) Independent Time-Scale Class::
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
`timescale 1ns/1ps
`ifndef TIMESCALE_INDEPENDENT_SVH
`define TIMESCALE_INDEPENDENT_SVH
class timescale_independent_class;
function new();
$display("%0gns, %0f Timescale Independent Class:: Instantiation Done", ($realtime * 1), $realtime);
endfunction
task delay();
$printtimescale; // Expected is 1ns/1ps. But printing 1ps/1ps
$display("%0gns, %0f Timescale Independent Class:: Waiting for Delay", ($realtime * 1), $realtime);
#20;
$display("%0gns, %0f Timescale Independent Class:: Waiting for Delay Done", ($realtime * 1), $realtime);
endtask
endclass : timescale_independent_class
`endif
#**************************************************************************************************************************
Output is as per below:
#**************************************************************************************************************************
0ns, 0.000000 Timer Class:: Instantiation Done
0ns, 0.000000 Timescale Independent Class:: Instantiation Done
Time scale of (time_scale_experiment) is 10ns / 1ps
10ns, 1.000000 Calling Time Class Delay Timer
Time scale of (timer_package.timer_class.delay) is 100ns / 1ps
10ns, 0.100000 Timer Class:: Waiting for Delay
1110ns, 11.100000 Timer Class:: Waiting for Delay Done
Time scale of (time_scale_experiment) is 10ns / 1ps
1120ns, 112.000000 Time Class Delay Timer Done
1170ns, 117.000000 Calling Timescale Independent Class Delay Timer
# Time scale of (time_scale_experiment_sv_unit.timescale_independent_class.delay) is 1ps / 1ps
1.17e+06ns, 1170000.000000 Timescale Independent Class:: Waiting for Delay
1.17002e+06ns, 1170020.000000 Timescale Independent Class:: Waiting for Delay Done
Time scale of (time_scale_experiment) is 10ns / 1ps
1180.02ns, 118.002000 Timescale Independent Class Delay Timer Done
1230.02ns, 123.002000 Finish Done
exit
#**************************************************************************************************************************