How to exit a 'while' loop in OVM / verilog after checking for a specific timeout condition -


i have 'while' loop part of ovm test looks this:

while (signal_val == 0) begin     signal_val  = sla_vpi_get_value_by_name ("blah"); end 

i want restrict loop 120 microseconds , exit after that. want quit test if (signal_val == 0) still not being satisfied @ end of 120µs. how achieve this?

i figured i'll have call 'global_stop_request()' quit test, trying check existing condition in while loop fixed timeout value (120µs) seems tricky. also, 'break' not seem working. ideas?

tried using 'break' way, 'break' gives syntax error:

while (signal_val == 0) begin     signal_val  = sla_vpi_get_value_by_name ("blah");     #120us;     break; end 

your code won't work expecting. let take look:

while (signal_val == 0) begin     signal_val  = sla_vpi_get_value_by_name ("blah");     #120us;     break; end 

signal_val evaluated once @ while statement, , since 0, enter while loop

signal_val gets value returned function call. happens @ same simulation cycle previous evaluation of while. assuming there no change, 0 return value again

now, function waits 120us

finally, breaks out of while loop. signal_val isn't evaluated again.

to achieve functionality want, need use fork...join , watchdog task

fork   begin: wait_signal_val     while (signal_val == 0) begin       signal_val  = sla_vpi_get_value_by_name ("blah");       if (signal_val == 1) begin         `uvm_info(get_name(), "yes!! signal_val seen 1", uvm_low);       end       else begin          #20ns; // (or clocking mechanism)       end     end   end    begin: watchdog     #120us;     `uvm_fatal(get_name(), "nope!! signal_val still 0 after 120us. killing test");   end join_any disable fork 

in above code, either watchdog or wait_signal_val finishes. when happens, fork...join_any completes , disables fork.

i use lot in testbench functionality describe , works seamlessly.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -