Professional Documents
Culture Documents
module
module
module
logic flag = 0;
string hdl_path = $psprintf("%m.");
int diff;
real t0;
real t1;
real tp;
real freq, tON, tOFF;
bit print_info_once = 0;
bit print_err_once = 0;
bit print_err_once_tON = 0;
bit print_tol_once = 0;
bit print_tol_once_tON = 0;
initial begin
$display("%s CLK ALL CHECKING STARTED", name);
integer freq_check_cycles = 0;
integer xz_prop_check_cycles = 0;
integer toggling_check_cycles = 0;
integer delay_check_cycles = 0;
fork
@(posedge stable_lock_signal) begin
`uvm_info("FREQ_CHECK", $sformatf("%0s Harshit CLK FREQ CHECKING
STARTED HDL_PATH = %s", name, hdl_path), UVM_LOW);
forever begin
@ (posedge stable_clock) t0 = $realtime;
@ (negedge stable_clock) tp = $realtime;
@ (posedge stable_clock) t1 = $realtime;
freq = 1.0e6 / (t1 - t0);
tON = tp - t0;
tOFF = t1 - tp;
if (diff != 0) begin
if ((freq inside {[0.99*exp_freq : 1.01*exp_freq]})) begin
if (print_tol_once == 0) begin
`uvm_info("FREQ_CHECK", $psprintf("%0s Harshit
frequency matches expected value with 1 percent tolerance. Actual = %0d MHz,
Expected = %0d MHz, HDL_PATH = %s", name, freq, exp_freq,hdl_path), UVM_LOW);
print_tol_once = 1;
end
end
else begin
if (print_err_once == 0) begin
if (!($test$plusargs("NO_POR_CHKS_NOW"))) begin
`uvm_error("FREQ_CHECK", $psprintf("%0s Harshit
frequency doesn't match expected value. Actual = %7.4f MHz, Expected = %7.4f MHz,
HDL_PATH = %s", name, freq, exp_freq,hdl_path));
print_err_once = 1;
end
end
end
end
else begin
if (print_info_once == 0) begin
`uvm_info("FREQ_CHECK", $psprintf("%0s Harshit
frequency exactly matches with expected value. Actual = %0d MHz, Expected = %0d
MHz, HDL_PATH = %s", name, freq, exp_freq,hdl_path), UVM_LOW);
print_info_once = 1;
end
end
tON = tp - t0;
tOFF = t1 - tp;
freq_check_cycles = freq_check_cycles + 1;
if (freq_check_cycles == MAX_FREQ_CHECK_CYCLES) begin
// Exit condition met, break out of the frequency checking
loop
break;
end
end
`uvm_info("FREQ_CHECK", $sformatf("%0s Harshit CLK FREQ CHECKING
ENDED HDL_PATH = %s ", name, hdl_path), UVM_LOW);
end
begin
`uvm_info("FREQ_CHECK", $sformatf("%0s Harshit CLK X/Z PROP
CHECKING STARTED", name), UVM_LOW);
forever begin
@(stable_clock)
if ($isunknown(stable_clock))
`uvm_error("FREQ_CHECK", $sformatf("%0s Harshit Clk has X/Z
running @ %0t", name, $realtime));
xz_prop_check_cycles = xz_prop_check_cycles + 1;
if (xz_prop_check_cycles == MAX_XZ_PROP_CHECK_CYCLES) begin
// Exit condition met, break out of the X/Z propagation
checking loop
break;
end
end
`uvm_info("FREQ_CHECK", $psprintf("%0s Harshit CLK X/Z PROP
CHECKING ENDED", name), UVM_LOW);
end
begin
fork : TOGGLING
begin
@(stable_clock);
@(stable_clock);
@(stable_clock);
@(stable_clock);
@(stable_clock);
end
begin
#250ns;
`uvm_error("FREQ_CHECK", $sformatf("%0s Harshit Clk Stuck
at 0/1, NOT toggling @ %0t", name, $realtime));
end
join_any
disable fork;
if ($test$plusargs("POR_CLK_CHKS_LONGRUN")) begin
#30us; // Extra 90us
end
#1us;
toggling_check_cycles = toggling_check_cycles + 1;
if (toggling_check_cycles == MAX_TOGGLING_CHECK_CYCLES) begin
// Exit condition met, break out of the toggling checking loop
break;
end
end
begin
`uvm_info("FREQ_CHECK", $sformatf("%0s Harshit CLK DELAY CHECKING
STARTED", name), UVM_LOW);
// Clock delay checking code here...
`uvm_info("FREQ_CHECK", $sformatf("%0s Harshit CLK DELAY CHECKING
ENDED", name), UVM_LOW);
delay_check_cycles = delay_check_cycles + 1;
if (delay_check_cycles == MAX_DELAY_CHECK_CYCLES) begin
// Exit condition met, break out of the delay checking loop
break;
end
end
join_any
disable fork;