{"id":28,"date":"2020-12-23T09:31:08","date_gmt":"2020-12-23T09:31:08","guid":{"rendered":"https:\/\/amvrao.in\/blog\/?p=28"},"modified":"2021-02-03T10:23:07","modified_gmt":"2021-02-03T10:23:07","slug":"delaying-phases-in-uvm","status":"publish","type":"post","link":"https:\/\/amvrao.in\/blog\/index.php\/2020\/12\/23\/delaying-phases-in-uvm\/","title":{"rendered":"delaying phases in uVM"},"content":{"rendered":"\n<p>Sometimes you will need to delay execution of a phase in your verification environment. A basic example is that in your test you might drive the sequences and then drop objection in the test to exit the test. In scoreboards or any monitors, if the transactions are still in line waiting for any responses or other stuff, you will have to delay the phase execution to flush all transactions. <\/p>\n\n\n\n<p>One of the way is to set the &#8220;<strong>set_drain_time<\/strong>&#8221; to specific phase that you need.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"verilog\" class=\"language-verilog\">... inside the component you want to set the drain time ... \ntask main_phase(uvm_phase phase);\n  phase.set_drain_time(this, 500); \/\/this will set 500 timeunits of delay once all objections are dropped.\n  \/\/You can also pass timeunits to the time like 500ns.. \nendtask<\/code><\/pre>\n\n\n\n<p>Another way is to use the &#8220;<strong>phase_ready_to_end<\/strong>&#8221; function of uvm component to induce delay.<\/p>\n\n\n\n<p>Well &#8220;phase_ready_to_end&#8221; is a function, but how can i call it to insert delay. You need to raise objection create a fork join_none block and then you have to drop objection once your processing is complete. An example can be found below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"verilog\" class=\"language-verilog\">function void phase_ready_to_end(uvm_phase phase);\n  if(phase.get_name == \"main\" &amp;&amp; (should_i_wait_or_not)) begin \/\/Use your own phase name which you want to stall, should_i_wait_or_not is a variable or function that you should see when do you want to delay the phase or not.\n     phase.raise_objection(this);\n     fork\n     begin\n       your_task_to_execute();\n     end\n     join_none\n   end\n endfunction<\/code><\/pre>\n\n\n\n<p>Some caveats:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The phase_ready_to_end is called when the objections for that phase are down to 0.<\/li><li>So when you raise objection in the phase_ready_to_end and when you call the drop_objection, the phase_ready_to_end will be again re-called.<\/li><li>So it is better to place a condition on the check in your function to check if is it really required to wait or not.<\/li><li>The UVM phase class a limit of 20 on the phase_ready_to_end, that means when you call the phase_ready_to_end 20 times, next time when objections are dropped to &#8216;0&#8217;, the phase_ready_to_end is not called.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you will need to delay execution of a phase in your verification environment. A&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/amvrao.in\/blog\/index.php\/2020\/12\/23\/delaying-phases-in-uvm\/\">Read the post<span class=\"screen-reader-text\">delaying phases in uVM<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-uvm","excerpt","zoom","full-without-featured","even","excerpt-0"],"_links":{"self":[{"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/28"}],"collection":[{"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=28"}],"version-history":[{"count":4,"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":36,"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/28\/revisions\/36"}],"wp:attachment":[{"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/amvrao.in\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}