Hi,
Testing different clock frequencies for my design, for example: 480Mhz, 320MHz and 200MHz.
So I have added in my ip_tb clk gen which can generate 3 clocks based on clk_period for each frequency.
module ip_tb
logic _clk;
// Clock Cycle period
real CLK_PERIOD = 2083; //in psec units; //frequency=480MHz
initial
begin
automatic int unsigned frequency = 480; // in MHz, 480Mhz is default one
if ($value$plusargs("CLK_FREQ=%d", frequency)) begin
case (frequency)
480 : CLK_PERIOD = 2083; //in psec units; //frequency=480MHz
320 : CLK_PERIOD = 3125; //in psec units
200 : CLK_PERIOD = 5000; //in psec units
default : $fatal("TB_TOP", "Unsupported frequency");
endcase
$display($realtime," %m: Clock frequency set by Plusarg. FREQUENCY=%0d MHz. CLK_PERIOD=%0t(%0d)", frequency, CLK_PERIOD, CLK_PERIOD);
end
forever
begin
#(CLK_PERIOD/2) _clk = ~_clk;
end
end
endmodule
First question:
is this the correct way, from methodology point of view, to generate clk with different frequencies?
Next problem:
I have added kind of a global timeout mechanism in my Env file + including some heartbeat prints to log, just to see if simulation is alive.
Which when expired finishes the test with uvm_fatal error.
Usually in all my tests, it was enough for the timeout to be: 1500 * 100usec.
Code below:
parameter GLOBAL_RUN_TIMEOUT = 1500;
task global_timeout();
fork : WRAPPING_FORK
begin : FORK_GUARD
fork
begin
`uvm_info(get_type_name(), $sformatf("Global_timeout_limit = %0t", (GLOBAL_RUN_TIMEOUT * 100us) ), UVM_NONE)
#( GLOBAL_RUN_TIMEOUT * 100us );
end
begin
forever
begin
#( plus_arg_heartbeat_interval * 50us );
`uvm_info(get_type_name(), $sformatf("heartbeat.. %0t to termination", (GLOBAL_RUN_TIMEOUT * 100us) - $time), UVM_NONE)
end
end
join_any
disable fork;
end : FORK_GUARD
join : WRAPPING_FORK
`uvm_fatal(get_type_name(), $sformatf("%m: Simulation global_timeout_limit %0t was reached", (GLOBAL_RUN_TIMEOUT * 100us) ))
endtask : global_timeout
But when my clock was generated with frequency=200Mhz, the timeout expired before test traffic ended.
Second question:
How can I waterfall the CLK_PEROID chosen in ip_tb to other parts of my verification environment?
If anyone can point me to some paper, or add code with good working practice to handle it will be awesome.
Thanks,
Michael