tag:blogger.com,1999:blog-56139196002815958952024-03-25T16:18:07.938+05:30Verification Engineer's BlogI am a Verification Engineer at Intel. I started the Verification blog to store solutions to small (and big) problems I've faced in my day to day work. I want to share them with the community in the hope that they may be useful to someone else.Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.comBlogger89125tag:blogger.com,1999:blog-5613919600281595895.post-85936879551025672232018-11-25T09:36:00.000+05:302018-11-25T09:36:42.579+05:30Compilation switches vs Simulation switches in SystemVerilog<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="font-size: x-large;"><span style="color: blue;"><u><b>Compilation Switches:</b></u></span></span> </span></span></span></h2>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Verilog has following conditional compiler directives.<span class="Apple-converted-space"> </span></span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></span></span></span><br />
<ul style="text-align: left;">
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifdef</span></span></span></li>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`else</span></span></span></li>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`elsif</span></span></span></li>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`endif</span></span></span></li>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifndef</span></span></span></li>
</ul>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">The </span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifdef</span> compiler directive checks for the definition of a text_macro_name. If the text_macro_name is defined, then the lines following the </span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifdef</span> directive are included. If the text_macro_name is not defined and an </span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`else</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span>directive exists, then this source is<span class="Apple-converted-space"> </span></span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">compiled.</span></span></span></div>
<br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">The </span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifndef</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span>compiler directive checks for the definition of a text_macro_name. If the text_macro_name is not defined, then the lines following the </span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifndef</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span>directive are included. If the text_macro_name is defined and an </span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`else</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span></span>directive exists, then this source is compiled.</span></span></span></span><br />
<br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">If the </span></span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`elsif</span> directive exists (instead of the </span></span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`else</span>) the compiler checks for the definition of the text_macro_name. If the name exists the lines following the </span></span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`elsif</span> directive are included. The </span></span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`elsif</span> directive is equivalent to the compiler directive sequence </span></span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`else</span> </span></span></span><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifdef</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"></span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"></span></span> ... </span></span></span><span style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`endif</span>. </span></span></span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">This directive does not need a corresponding </span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`endif</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"></span></span> directive. This directive must be preceded by an </span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifdef</span> or </span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: #9c20ef; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">`ifndef</span> directive.</span></span></span><br />
<br />
<br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">The code written within the compilation flags are compiled at compilation period.<br />As a result, the executable file creates a snap-shot of that particular code written within the compile flag.<br />For example, please go through below code.<br /><span style="color: #3d85c6;">LINE 1 : module xyz ()<br />LINE 2 : `ifdef FIRST<br />LINE 3 : $display ("<span style="color: magenta;">Inside FIRST</span>"); <br />LINE 4 : `elseif SECOND<br />LINE 5 : $display ("<span style="color: magenta;">Inside SECOND</span>"); <br />LINE 6 : `elseif THIRD<br />LINE 7 : $display ("<span style="color: magenta;">Inside THIRD</span>"); <br />LINE 8 : `else<br />LINE 9 : $display ("<span style="color: magenta;">Inside ELSE</span>"); <br />LINE 10 : `endif<br />LINE 11 : $display ("<span style="color: magenta;">Inside LAST</span>"); <br />LINE 12 : endmodule : xyz</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: #3d85c6;"> </span><br />Now compile the code with define "<span style="color: magenta;">+define+FIRST</span>".</span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">The executable file will contains snapshot of "LINE 3 & LINE 11"<br />Now simulating the executable file, output will be as:<br /><span style="color: magenta;">Inside FIRST<br />Inside LAST</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: magenta;"> </span><br />Now we<span style="color: #3d85c6;"> re-simulate(without compiling again)</span>, and pass define "<span style="color: magenta;">+define+SECOND</span>" at run time, output will be as:<br /><span style="color: magenta;">Inside FIRST<br />Inside LAST</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: magenta;"> </span><br />Now we <span style="color: #3d85c6;">re-simulate(without compiling again)</span>, without passing any defines at run time, output will be as:<br /><span style="color: magenta;">Inside FIRST<br />Inside LAST</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: magenta;"> </span><br />If we required to display "LINE 5" we have to <span style="color: #3d85c6;">re-compile</span> complete testbench with <span style="color: magenta;">+define+SECOND</span> at compile time<br />Now simulating the executable file, output will be as:<br /><span style="color: magenta;">Inside SECOND<br />Inside LAST</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span></span>
<br />
<h2 style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="font-size: x-large;"><u><b><span style="color: blue;">Simulation Switches:</span></b></u></span></span></span></span></h2>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br />Variable ( int i / string abc ) are used as simulation flag<br />The complete testbench will be compiled at one-shot, and the executable file will contains snap-shot of complete codes.<br />For example, please go through below code.<br /><br /><span style="color: #3d85c6;">LINE 1 : module xyz ();<br />LINE 2: reg [1:0] arg;<br />LINE 3 : if ($value$plusargs("<span style="color: magenta;">argument=%0d</span>",arg));<br />LINE 4 : if(arg == 1)<br />LINE 5 : $display ("<span style="color: magenta;">Inside FIRST</span>"); <br />LINE 6 : else if(arg == 2)</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: #3d85c6;">LINE 7 : $display ("<span style="color: magenta;">Inside SECOND</span>"); <br />LINE 6 : else if(arg == 3)<br />LINE 7 : $display ("<span style="color: magenta;">Inside THIRD</span>"); <br />LINE 8 : else<br />LINE 9 : $display ("<span style="color: magenta;">Inside ELSE</span>"); <br />LINE 10 : end<br />LINE 11 : $display ("<span style="color: magenta;">Inside LAST</span>"); <br />LINE 12 : endmodule : xyz</span><br /><br /><br />Now compile the testbench without any arguments . The executable file contains snap-shot of <span style="color: #3d85c6;">all </span>complete lines mention in module.<br />Now <span style="color: #3d85c6;">simulating</span> the executable file, and we provide argument "<span style="color: magenta;">+argument=1</span>" at runtime output will be as:<br /><span style="color: magenta;">Inside FIRST<br />Inside LAST</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br />Now we <span style="color: #3d85c6;">re-simulate</span>(without compiling again), and we provide argument <span style="color: magenta;">+argument=2</span>, at runtime output will be as:<br /><span style="color: magenta;">Inside SECOND<br />Inside LAST</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: magenta;"> </span><br />Now we <span style="color: #3d85c6;">re-simulate</span>(without compiling again), and we provide argument <span style="color: magenta;">+argument=3</span>, at runtime output will be as:<br /><span style="color: magenta;">Inside THIRD<br />Inside LAST</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: magenta;"> </span><br />Now we <span style="color: #3d85c6;">re-simulate</span>(without compiling again) without any argument, at runtime output will be as:<br /><span style="color: magenta;">Inside LAST</span></span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: magenta;"> </span><br />As we saw, the benefits of "$values$plusargs" is:<br />One time compiling (creating executable file) and running multiple testcase on same executable file.</span></span></span><br />
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Now for environmental Modification, It is very necessary to reduce down the usage of (`</span><span class="x_ZM-SPELLCHECK-MISSPELLED" id="x_DWT242" style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">ifdef</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span>/ `</span><span class="x_ZM-SPELLCHECK-MISSPELLED" id="x_DWT243" style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">elseif</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span>) to very minimum and try to use<span class="Apple-converted-space"> </span></span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">simulation</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span>time arguments as much as possible. And at the same time we need to take care of single Test run but on other side it will be very much help full for (One time compilation with<span class="Apple-converted-space"> </span></span><span class="x_ZM-SPELLCHECK-MISSPELLED" id="x_DWT244" style="background-color: white; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">multi</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">simulation</span><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">) regression.</span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /><span style="font-size: small;">With the above style of programing,we can save recompilation times.</span></span></div>
<br />
<h2 style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">Difference between $test$plusargs and $value$plusargs:</span></span></span><span style="color: blue;"></span></span></h2>
<h2 style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="font-size: small;"><span style="color: black;">There are two types of Simulation switches in systemverilog.</span></span></span></span></span></span></h2>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"><span style="color: magenta;"><i><b>$value$plusargs:</b></i></span></span></span></span></span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="font-size: small;">We have seen example of $value$plusargs in above explaination. In $value$plusargs user need to pass value in argument and based on that value some decision will be taken.</span></span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"> We will go through another example:</span></span></span></span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">module valuetest(); <br /> integer i;<br /> real r;</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> reg [11:0] v;</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> reg [128:0] s;</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><br /> initial begin</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> if($value$plusargs("<span style="color: magenta;">STRING=%s</span>", s))<br /> $display("<span style="color: magenta;">GOT STRING</span>");<br /> if($value$plusargs("<span style="color: magenta;">INTG=%d</span>", i))</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> $display("<span style="color: magenta;">GOT INTEGER</span>");<br /> if($value$plusargs("<span style="color: magenta;">REAL=%f</span>", r))</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> $display("<span style="color: magenta;">GOT REAL</span>");<br /> if($value$plusargs("<span style="color: magenta;">VECTOR=%b</span>", v))<br /> $display("<span style="color: magenta;">GOT VECTOR</span>");</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><br /> $display( "<span style="color: magenta;">String is %s</span>", s);</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> $display("<span style="color: magenta;">Integer is %d</span>", i);</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> $display("<span style="color: magenta;">Realnum is %f</span>", r);</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> $display("<span style="color: magenta;">Vector is %b</span>", v);<br /> end</span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: blue;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="color: #3d85c6;">endmodule </span><br /><br /><b>Compilation:</b><br />command filename.sv<br />Simulation:<br />command <span style="color: magenta;">+STRING=rrf</span> <span style="color: #3d85c6;">+INTG=123</span> <span style="color: magenta;">+REAL=1.32</span> <span style="color: #3d85c6;">+VECTOR=10101</span> <br /><br /><b>RESULTS:</b></span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: blue;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;">GOT STRING <br />GOT INTEGER <br />GOT REAL <br />GOT VECTOR <br />String is rrf <br />Integer is 123 <br />Realnum is 1.320000e+00 <br />Vector is 000000010101 </span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"> </span></span></span></span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"> </span></span></span></span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"><span style="color: magenta;"><i><b>$test$plusargs:</b></i></span></span></span></span></span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"><span style="color: magenta;"><span style="color: black;">In $test$plusargs user don't need to give value in argument. If user provides simulation argument in simulation command then if condition will be executed otherwise else part (if exists) will be executed.</span></span></span></span></span></span></span></span></span></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: blue;"><span style="font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="color: black;"><span style="font-size: small;"><span style="font-size: large;"><span style="font-size: small;"><span style="color: magenta;"><span style="color: black;">Example:</span></span></span></span></span></span></span></span></span></span></div>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="color: #3d85c6;"><span style="font-size: small;">module switches(); <br /> initial begin</span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"> if($test$plusargs("<span style="color: magenta;">TYPE_1</span>"))</span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"> $display("<span style="color: magenta;">TYPE_1 message</span>");</span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"> else<br /> if($test$plusargs("<span style="color: magenta;">TYPE_2</span>"))</span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"> $display("<span style="color: magenta;">TYPE_2 message</span>");</span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"> end</span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;">endmodule</span></span></span><br />
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="color: #3d85c6;"> </span><br />No need to give +define+TYPE_1 or +define+TYPE_2 during compilation <br /><br />Simulate with <span style="color: magenta;">+TYPE_1</span> <br />RESULT: <br /><span style="color: magenta;">TYPE_1 message</span> <br /><br />Simulate with <span style="color: magenta;">+TYPE_2</span> <br />Then simulate,result is <br />RESULT:<br /><span style="color: magenta;">TYPE_2 message</span></span></span><br />
<br />
<br />
<h2 style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: large;"><span style="color: blue;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">Benefits & disadvantage of Compilation/Simulation Switches:</span></span></span></span></h2>
<h2>
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></span></span></span></h2>
<h4 style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">If we use Compilation switches:</span></span></span></h4>
<ol style="text-align: left;">
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">For Single Test run:</span></span></span></li>
<ol>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Compilation and simulation time reduces. because the very small amount of code will be exercised. </span></span></span></li>
</ol>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">For Regression:</span> </span></span></li>
<ol>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;">If their are defines for each test case / test command we have to COMPILE & SIMULATE each testcase. </span></span></li>
</ol>
</ol>
<h4 style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">If we use Simulation switches:</span></span></span></h4>
<ol style="text-align: left;">
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">For Single Test run:</span> </span></span></li>
<ol>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;">Compilation time increases (because complete code is getting exercised) and simulation time remains same.</span></span></li>
</ol>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;">For Regression:<span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> </span></span></span></li>
<ol>
<li><span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><span style="font-size: small;"><span style="background-color: white; color: black; display: inline; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">We have to compile one time, and we can use same executable file for all the test cases / test commands.</span></span></span></li>
</ol>
</ol>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com17tag:blogger.com,1999:blog-5613919600281595895.post-84932188967323723042018-11-09T10:27:00.000+05:302018-11-09T10:27:28.569+05:30Pass enum value from command line in UVM<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
In verification activity, many times the requirement comes to choose
specific value of enum variable from command line in either randomization of
transaction class or configuring agent.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
System Verilog provides support to pass value of variable of type
int/bit/logic/string from command line using <b>$value$plusargs</b> function but it
does not direct support to pass value of enum variable from command line.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
In earlier version of UVM (uvm 1.1d and prior), we can achieve this by
passing string value from command line and manually converting it into enum by writing
code in TB.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Let’s go through example how we can achieve this,<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/013b3d1416e50bba01d5453d5a53fe24.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
In UVM 1.2 provides inbuilt facility to convert string into enumerated
value.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
In UVM 1.2 library contains <b>uvm_enum_wrapper#(T)</b> class and this class
contains <b>from_name()</b> function.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
from_name() function try to convert any string passed as argument into enumerated
value.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<i>If any matching enumerated value found then this function returns 1 else
it returns 0</i>.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/5d384e61dcb93b5743ae81ea73b73c5d.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Let’s go through example,<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/ad7b876aa07b7e0c5932ccf6c93409ac.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
In above approach from_name() function can convert only one string at a
time. <o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Now think about scenario where to randomize variable of enum user wants
to select from multiple values. But above approach works fine only with one
string value.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
UVM provides <b>uvm_split_string() </b>function which splits the
string based on a delimiter and returns a queue with sub string.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/501cdc9f3982043bdfd110e54b62c31a.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Now after getting queue of substring from uvm_split_string() function, user can pass one one element of substring queue to from_name() function
in some loop and convert it into enumerated value.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Let’s go through example to understand this better,<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/cd74fcaa3d9b0930cb7c03e5b53c4059.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Reference:<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
1) <a href="https://stackoverflow.com/questions/35212974/how-do-i-convert-strings-to-enums-in-systemverilog">https://stackoverflow.com/questions/35212974/how-do-i-convert-strings-to-enums-in-systemverilog</a><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
2) <a href="https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.2/html/">https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.2/html/</a></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com4tag:blogger.com,1999:blog-5613919600281595895.post-83529482548196076902018-11-06T08:50:00.000+05:302018-11-06T08:50:02.662+05:30Drop all objection manually in UVM<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Test requirement is like,</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-indent: 0px;">
<span style="text-indent: -0.25in;">1) When polling for more than one interrupts by
continuously reading different registers in parallel and based on some
indication move to next phase of UVM</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-indent: 0px;">
<span style="text-indent: -0.25in;">2) Waiting for some timer to be expired and then
moving to next phase of UVM</span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Let’s take one scenario where,<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Driver is raising objection but never dropping objection and requirement
is to move to next phase (extract_phase) after #50 timeunit. But because all
the objection are not dropped in run_phase, simulation is not going to
extract_phase.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Let’s go through example.</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/0b0be6f2e63697655842a98b29cbeb84.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p><br /></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Now let’s take another scenario,<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Here driver is dropping objection after #105 timeunit. So simulation
will move to next phase after #105. But the requirement is to move to next
phase which is extract_phase after #50.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Let’s go through example.</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/98b5f9d6285668f75842da4c89aae4db.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p><br /></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
To fulfill the requirement we need to any how drop the pending objection
after #50 to move to next phase after #50.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
We can do this by getting list of all uvm_components (through
get_objector method of uvm_objection class) who raised objection and then we
can manually drop the objection after #50 timeunit.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Let’s go through example.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/2e39d35e4e91b2ebcfaa81afe0783c19.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p>Reference:</o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<o:p><span style="background-color: #fefefe; color: #333333; font-size: 16px; text-align: justify;">1) </span>uvm_objection.svh file </o:p></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com4tag:blogger.com,1999:blog-5613919600281595895.post-29020493830774902662018-11-06T08:05:00.000+05:302018-11-11T16:37:24.391+05:30Automatic configuration through uvm_config_db<div dir="ltr" style="text-align: left;" trbidi="on">
UVM has an internal database table in which we can store values (of any data type including user defined data type) with unique name and can be retrieved later by some other testbench component.<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
There are two interface through which we can access configuration database.</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<span style="text-indent: -24px;">1)<span style="font-size: xx-small;"> </span></span><span style="text-indent: -24px;">u</span><span style="text-indent: -0.25in;">vm_resource_db, </span><span style="text-indent: -0.25in;">2)<span style="font-size: xx-small;"> </span></span><span style="text-indent: -24px;">u</span><span style="text-indent: -0.25in;">vm_config_db</span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: 0in; text-indent: -0.25in;">
<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
Uvm_config_db is a great way to pass different resources (variable/object/virtual interface) within UVM testbench component hierarchy.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
The uvm_config_db class provides a convenience interface on top of the uvm_resource_db to simplify the basic interface that is used for configuring uvm_component instances.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
Let’s go through basic example:<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p><br />
<script src="https://gist.github.com/sagar5258/93f7ddc59ec51a4a42b25027cc90f069.js"></script></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
UVM provides automatic configuration of resources (variable/object etc…) which are registered in the respective component (which is extended from uvm_component) by calling apply_config_settings method.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
Any component which is extended from uvm_component should call super.build_phase(phase) to execute apply_config_settings method.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
Let's go through basic example of automatic configuration.</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p><br />
<script src="https://gist.github.com/sagar5258/aea4253aff0954f800a5bc61a5b40a29.js"></script></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
-------------------------------------------------------------------------</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
But,<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
This is not recommended approach as <span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-hansi-font-family: Calibri;">it introduces extremely poor simulation performance and big confusion on what kind of field/resource it supports and does not supports.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div style="margin: 0in;">
<span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;">Some of the types get automatically configured and while some are not.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
Let’s go through one more example of automatic configuration,</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p><br />
<script src="https://gist.github.com/sagar5258/9d28b9f201fda7be37b03c9cf20614ec.js"></script></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
-------------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<b>Observation:</b></div>
<div style="margin: 0in 0in 0in 0.5in; text-indent: -0.25in;">
<span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;"><span style="mso-list: Ignore;">1)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;"> </span></span></span><span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;">If you set any object which is extended from uvm_object and set it into config_db using extended type it won't get automatically configured (obj2).<o:p></o:p></span></div>
<div style="margin: 0in 0in 0in 0.5in; text-indent: -0.25in;">
<span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;"><span style="mso-list: Ignore;">2)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;"> </span></span></span><span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;">If you set extended object into config_db using uvm_object as type then it will get automatically configured (obj1).<o:p></o:p></span></div>
<div style="margin: 0in 0in 0in 0.5in; text-indent: -0.25in;">
<span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;"><span style="mso-list: Ignore;">3)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;"> </span></span></span><span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;">Unpack array will not get automatically configured (ary_int).<o:p></o:p></span></div>
<div style="margin: 0in 0in 0in 0.5in; text-indent: -0.25in;">
<span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;"><span style="mso-list: Ignore;">4)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;"> </span></span></span><span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;">If resource (variable/object etc) is not registered in respective class using `uvm_field_* macro then it won't get automatically configured (idx1).<o:p></o:p></span></div>
<div style="margin: 0in 0in 0in 0.5in; text-indent: -0.25in;">
<span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;"><span style="mso-list: Ignore;">5)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;"> </span></span></span><span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;">Virtual interface won't get automatically configured as we can't register it using `uvm_field_* macro.<o:p></o:p></span></div>
<div style="margin: 0in 0in 0in 0.5in; text-indent: -0.25in;">
<span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;"><span style="mso-list: Ignore;">6)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;"> </span></span></span><span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;">If you set any vector (let’s say bit [47:0]) in config_db using uvm_config_db#(int)::set then it will get automatically configured. Even though width of int is 32 bit but still 48 bits will get automatically configured (idx2).<o:p></o:p></span></div>
<div style="margin: 0in 0in 0in 0.5in; text-indent: -0.25in;">
<span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;"><span style="mso-list: Ignore;">7)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;"> </span></span></span><span style="color: black; font-family: "calibri" , sans-serif; font-size: 11pt;">But if you set same vector (bit [47:0]) in config_db using uvm_config_db#(bit[47:0])::set then it won't get automatically configured (idx22).<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;">
If you want to pass Unpack array using uvm_config_db then you can set it directly using for loop as done in above example. But this is not efficient approach, instead of that create a class (extended from uvm_object) that includes unpack arrays and then do set/get of that class using uvm_config_db.<br />
<br />
Reference:<br />
1) <a href="https://verificationacademy.com/forums/uvm/uvmconfigdb-usage-big-confusion">https://verificationacademy.com/forums/uvm/uvmconfigdb-usage-big-confusion</a><br />
<br /></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com2tag:blogger.com,1999:blog-5613919600281595895.post-68829339626413367352018-01-28T18:55:00.000+05:302018-01-28T18:55:50.968+05:30Automatic/Static Variables and Function/Task with Automatic Lifetime in SystemVerilog<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Before going into static and automatic variable let’s first go
through 2 important terminology and then will go through automatic and static.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Scope:</b><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><em><span style="background: white; border: 1pt none windowtext; color: #242729; padding: 0in;">Scope</span></em><span style="background: white; color: #242729;"><i> is the region
or section of code where a variable can be accessed.</i><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Variables declared inside a module, interface, program, or
checker, but outside a task, process, or function, are local in scope.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Lifetime:</b><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><em><span style="background: white; border: 1pt none windowtext; color: #242729; padding: 0in;">Lifetime</span></em><span style="background: white; color: #242729;"><i> is the time
duration where an object/variable is in a valid state.</i><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span class="fontstyle01">Variables declared outside a module, program, interface, checker,
task, or function are local to the</span><br />
<span class="fontstyle01">compilation unit and have a static lifetime
(exist for the whole simulation).<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Variables declared inside a static task, function, or block are
local in scope and default to a static lifetime.<o:p></o:p></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span class="fontstyle01">Specific variables within a static task, function, or block can be
explicitly declared as automatic. Such</span><br />
<span class="fontstyle01">variables have the lifetime of the call or
block and are initialized on each entry to the call or block.</span><span style="background: white; color: #242729;"><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/1fa812d92ffe10691991a300a251f352.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Result:</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/93e77ff86cc5f7574c3730f73a980d48.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal;">
<b><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Automatic Function/Task (Function/Task with Automatic Lifetime):</span></b></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-size: 11pt; line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">In Verilog default
lifetime of all the task/function is static.</span></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Tasks and functions may be declared as automatic. Variables
declared in an automatic task, function, or block are local in scope, default
to the lifetime of the call or block, and are initialized on each entry to the call
or block.</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal;">
</div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">In other word, Automatic task/function variables cannot be
accessed by hierarchical references. Automatic variables are automatically destroyed once the scope (task, function, block) in which they are created ends
and regenerated when again enters into scope (task, function, block).<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/8b96a729c165e49288d7766b655bcca4.js"></script></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Class methods has Automatic lifetime by default:</b></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span class="fontstyle01"></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Because of backward compatibility reason, SystemVerilog could not
change the default lifetime qualifier to ‘automatic’ but since <b>class methods</b>
were new, it changed the lifetime of all methods to be automatic.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/80211476546b52ed50ae771320415577.js"></script></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="color: windowtext;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The keyword ‘static’ is overloaded. There is a
semantic difference between the meaning of ‘static’ used to the left of a
function/task keyword and ‘static’ used to the right of the function/task
keyword.<o:p></o:p></span></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="color: windowtext;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="color: windowtext;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">When used to the <b>left of the function or task</b>,
‘static’ is a class qualifier and has the same as on any static method in
C++/Java. It is a method of the class type, not of an instance of a class
object. Other class qualifiers are ‘local’ and ‘protected’ and along with
‘static’ are only allowed in front of methods of a class. There is no
corresponding ‘automatic’ class qualifier.<o:p></o:p></span></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span class="fontstyle01"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">
</span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">When used to the <b>right of a function or task</b>, ‘static’ is
a lifetime qualifier, with ‘automatic’ being the corresponding qualifier.</span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">For more details refer this <a href="https://sagar5258.blogspot.in/2015/06/static-method-vs-task-with-static.html" target="_blank">link</a>.</span></span></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com4tag:blogger.com,1999:blog-5613919600281595895.post-67673994944728358362018-01-26T16:29:00.002+05:302018-01-26T16:29:43.985+05:30`define macro usage in SystemVerilog<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="background: white; color: #242729;">It's not possible to use a `define
macro within a string literal. According to the SystemVerilog LRM</span>: <span style="background-color: #fff2cc;">Macro
substitution and argument substitution shall not occur within string literals</span><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Let’s go through below example to understand it in detail,<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> ---------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/99f63428961f79413802330713098d2e.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> ---------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: #242729;">However a string literal can be
constructed by using a macro that takes an argument and including the quotes in
the macro by using </span><b><span style="color: blue;">`"</span></b><span style="color: #242729;">.</span></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="background-color: white;"><span style="color: #242729;">According to SystemVerilog LRM: An
</span><b><span style="color: blue;">`"</span> </b><span style="color: #242729;">overrides the usual lexical meaning of </span><b><span style="color: blue;">"</span></b><span style="color: #242729;"> and indicates that the
expansion shall include the quotation mark, substitution of actual arguments,
and expansions of embedded macros. This allows string literals to be
constructed from macro arguments.</span></span><span style="background-color: white; color: #242729;"><o:p></o:p></span></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> ---------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/b70de335ea2a2f3d319b1f11e9a60419.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> ---------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white; color: #242729;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Now what if you want to add double
quotes in string which is constructed using macro. SystemVerilog provides
support for that.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: #242729;">A </span><b><span style="color: blue;">`\`"</span></b><span style="color: #242729;"> indicates that the expansion should include the escape
sequence </span><b><span style="color: blue;">\"</span></b><span style="color: #242729;">.<o:p></o:p></span></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white; color: #242729;"><o:p><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">
</span></o:p></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white; color: #242729;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Let’s go through example to see how
it works,<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> ---------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/d47173454885c60c5574dfb7348c9d7e.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white; color: #242729;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> ---------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> SystemVerilog LRM also provides support to construct identifier from arguments using <b><span style="color: blue;">``</span></b>.</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">There are three places where we can substitute argument to construct identifier</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">1) Substitute argument in between something (neither at the end nor at the beginning of the identifier)</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">2) Prepend argument (at the beginning of the identifier)</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">2) Append argument (at the end of the identifier)</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> ---------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/96beb4cf017239b9e7e6afd41764bbc4.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="background: white; color: #242729;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"> ---------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Reference:</span></div>
<div class="MsoNormal" style="line-height: normal;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">1) SystemVerilog 2012 LRM</span></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com1tag:blogger.com,1999:blog-5613919600281595895.post-67085196528834145662018-01-26T14:43:00.000+05:302018-01-26T14:43:38.904+05:30Weighted Distributions in SystemVerilog<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="line-height: normal;">
In constrain random verification,
it may take a long time for a particular corner case to be generated. Sometime even
after running test-case for N number of time corner case may not be generated
and you may see holes in functional coverage. To resolve this you can use a weighted
distribution to drive stimulus in particular direction.</div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
The <b>dist</b> keyword in
systemverilog allows you to create weighted distributions so that some values
are chosen more often than others. There are 2 different kind of distribution
operators available in systemverilog.</div>
<div class="MsoNormal" style="line-height: normal;">
The <b><span style="color: blue;">:= </span></b>operator assigns the specified
weight to the item or, if the item is a range, to every value in the range. </div>
<div class="MsoNormal" style="line-height: normal;">
The<b><span style="color: blue;">
:/ </span></b>operator assigns the specified weight to the item or, if the item is a
range, to the range as a whole. If there are <i>n</i> values in the range, the weight
of each value is <i>range_weight / n</i>.</div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
<b>Limitation:</b></div>
<div class="MsoNormal" style="line-height: normal;">
dist expressions cannot appear in other
expressions.</div>
<div class="MsoNormal" style="line-height: normal;">
dist operation shall not be applied to randc variables.</div>
<div class="MsoNormal" style="line-height: normal;">
<br /></div>
<div class="MsoNormal" style="line-height: normal;">
Let's go through below example to understand how it works,</div>
<div class="MsoNormal" style="line-height: normal;">
----------------------------------------------------------------------------</div>
<div class="MsoNormal" style="line-height: normal;">
<script src="https://gist.github.com/sagar5258/a5bb3d307486daa25c8a009e930cd0e9.js"></script></div>
<div class="MsoNormal" style="line-height: normal;">
----------------------------------------------------------------------------</div>
<div>
<br /></div>
<div>
Reference:</div>
<div>
1) SystemVerilog LRM 2012</div>
<div>
2) SystemVerilog for Verification 3rd edition by Chris Spear</div>
<div class="MsoNormal" style="line-height: normal;">
<o:p></o:p></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com0tag:blogger.com,1999:blog-5613919600281595895.post-23712757785826377332017-11-08T12:11:00.002+05:302017-11-08T12:11:54.900+05:30Timeunit and Timeprecision in SystemVerilog<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Within a design element, such as a module, program or
interface, the time precision specifies how delay values are rounded before
being used in simulation.<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The time precision is relative to the time units. If the
precision is the same as the time units, then delay values are rounded off to
whole numbers (integers). If the precision is one order of magnitude smaller
than the time units, then delay values are rounded off to one decimal place.<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">For example, if the time unit specified is 1ns and the
precision is 100ps, then delay values are rounded off to one decimal place
(100ps is equivalent to 0.1ns). Thus, a delay of 2.75ns would be rounded off to
2.8ns.<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<br /></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The time unit and time precision can be specified in the
following two ways:<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">— Using the compiler directive <b>`timescale</b><o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">— Using the keywords <b>timeunit</b> and <b>timeprecision</b><o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Here in this post, we will go in details of second way (timeunit
and timeprecision).<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The time precision may also be declared using an optional
second argument to the timeunit keyword using the slash separator. For
example:</span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">------------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/f378e3fa5faf250ef6fafe13172295c7.js"></script></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">------------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Defining the timeunit and timeprecision constructs within
the design element removes the file order dependency problems with compiler
directives.<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">There shall be at most one time-unit and one time-precision
for any module, program, package, or interface definition or in any
compilation-unit scope. This shall define a time scope.<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The timeunit and timeprecision declarations shall precede
any other items in the current time scope. i.e. timeunit and timeprecision
shall be declared either inside module, program, package, interface or after
any item in any compilation-unit scope.<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The timeunit and timeprecision declarations can be repeated
as later items, but must match the previous declaration within the current time
scope.<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: justify;">
<br /></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">If a timeunit is not specified within a module, program,
package, or interface definition, then the time unit shall be determined using
the following rules of precedence: <o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: left;">
</div>
<ol style="text-align: left;">
<li style="text-align: justify;">If the module or interface definition is nested, then the
time unit shall be inherited from the enclosing module or interface (programs
and packages cannot be nested).</li>
<li style="text-align: justify;">Else, if a `timescale directive has been previously specified
(within the compilation unit), then the time unit shall be set to the units of
the last `timescale directive.</li>
<li style="text-align: justify;">Else, if the compilation-unit scope specifies a time unit
(outside all other declarations), then the time unit shall be set to the time
units of the compilation unit.</li>
<li style="text-align: justify;">Else, the default time unit shall be used.</li>
</ol>
<br />
<div class="MsoNormal" style="text-align: left;">
</div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The <b>global time
precision</b>, also called the <b><i><span style="color: blue;">simulation
time unit</span></i></b>, is the minimum of,<o:p></o:p></span></div>
<div class="MsoNormal" style="text-align: left;">
</div>
<ul style="text-align: left;">
<li style="text-align: justify;">All the timeprecision statements,</li>
<li style="text-align: justify;">All the time precision arguments to timeunit declarations,
and</li>
<li style="text-align: justify;">The smallest time precision argument of all the `timescale
compiler directives in the design.</li>
</ul>
<br />
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Let's go through one example,</span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">------------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/232a9afc44bbf722f07f2594c7ad67b6.js"></script></span></div>
<div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">------------------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Reference:</span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">1) SystemVerilog LRM (</span><span style="text-align: left;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">1800-2012)</span></span></div>
</div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com3tag:blogger.com,1999:blog-5613919600281595895.post-69742532286548015842017-09-26T18:16:00.002+05:302017-09-26T18:16:52.494+05:30Array Manipulation Methods in SystemVerilog with example<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">SV provides build in methods to facilitate searching from array, array ordering and reduction.</span><br />
<h2 style="text-align: left;">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Array locator methods:</b></span></span></h2>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Array locator methods operate on any unpacked array,
including queues, but their return type is a queue.</span><br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><u>Element locator methods (<b>with </b>clause is
mandatory):</u><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>find()</b> returns all the elements satisfying the given
expression.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>find_first()</b> returns the first element satisfying the
given expression.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>find_last()</b> returns the last element satisfying the
given expression.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><u>Index locator methods (<b>with </b>clause is mandatory):</u><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>find_index()</b> returns the indices of all the elements
satisfying the given expression.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>find_first_index()</b> returns the index of the first
element satisfying the given expression.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>find_last_index()</b> returns the index of the last
element satisfying the given expression.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Index locator methods return a
queue of <b>int </b>for all arrays except associative arrays, which return a
queue of the same type as the associative index type.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">arrays that specify a wildcard
index type shall not be allowed.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">If no elements satisfy the given
expression or the array is empty (in the case of a queue or dynamic array), then
an empty queue is returned.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Index locator methods return a
queue with the indices of all items that satisfy the expression.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The optional expression specified
by the <b>with </b>clause shall evaluate to a Boolean value.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Let's go through below example,</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/24809d81d68f4775e086e1e0bb386fdd.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><u>Element locator methods (<b>with </b>clause is
optional):</u><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>min()</b> returns the element with the minimum value or
whose expression evaluates to a minimum.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>max()</b> returns the element with the maximum value or
whose expression evaluates to a maximum.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="line-height: 107%;"><b>unique</b></span><span style="line-height: 107%;"><b>()</b> returns all
elements with unique values or whose expression evaluates to a unique value.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">
</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>unique_index()</b> returns the indices
of all elements with unique values or whose expression evaluates to a unique
value.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Let's go through below example,</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/d91ae2664534c6a33ebf9a22fede6e19.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<br /></div>
<h3 style="line-height: normal; margin-bottom: 0.0001pt; text-align: left;">
<span style="font-size: large;"><span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Array reduction methods:</span></span></span></h3>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Array reduction methods may be
applied to any unpacked array of integral values to reduce the array to a single
value<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>sum()</b> returns the sum of all the
array elements or, if a <b>with </b>clause is specified, returns the sum of the
values yielded by evaluating the expression for each array element.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>product()</b> returns the product of
all the array elements or, if a <b>with </b>clause is specified, returns the product
of the values yielded by evaluating the expression for each array element.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>and</b>() returns the
bitwise AND ( & ) of all the array elements or, if a <b>with </b>clause is
specified, returns the bitwise AND of the values yielded by evaluating the
expression for each array element.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>or</b>() returns the
bitwise OR ( | ) of all the array elements or, if a <b>with </b>clause is
specified, returns the bitwise OR of the values yielded by evaluating the
expression for each array element.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">
</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>xor</b>() returns the
bitwise XOR ( ^ ) of all the array elements or, if a <b>with </b>clause is
specified, returns the bitwise XOR of the values yielded by evaluating the
expression for each array element.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Let's go through below example,</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/e299348751cf8cffd50bd428ee137916.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<br /></div>
<h3 style="line-height: normal; margin-bottom: 0.0001pt; text-align: left;">
<span style="font-size: large;"><span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Array ordering methods:</b></span></span></span></h3>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Array ordering methods reorder the
elements of any unpacked array (fixed or dynamically sized) except for associative
arrays.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>reverse()</b> reverses the order of the
elements in the array. Specifying a <b>with </b>clause shall be a compiler error.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>sort()</b> sorts the array in ascending
order, optionally using the expression in the <b>with </b>clause.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>rsort()</b> sorts the array in
descending order, optionally using the expression in the <b>with </b>clause.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>shuffle()</b> randomizes the order of
the elements in the array. Specifying a <b>with </b>clause shall be a compiler
error.</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Let's go through below example,</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/8ed1bfd40d0159b91a339ee45d167197.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Now let's see couple of practical examples, let's say we want to find number of 1s from bit array or bit queue or we want to find out number of non-zero elements in any array or queue.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><script src="https://gist.github.com/sagar5258/bdda06f8358db1d5a4fe09b21e278bc3.js"></script></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">---------------------------------------------------------------------</span></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com11tag:blogger.com,1999:blog-5613919600281595895.post-82399036332721613662017-07-23T22:10:00.000+05:302017-08-22T09:43:24.117+05:30Advantage of uvm_event over SV event and how to disable uvm_event using callback<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">The uvm_event#(type T = uvm_object) class is an extension of the abstract uvm_event_base class. The optional parameter T allows the user to define a data type which can be passed during an event trigger. uvm_event class is an abstract wrapper class around SystemVerilog event construct.</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">It provides additional services such as over traditional SystemVerilog event like,</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><b>1) pass data when event is triggered,</b></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">A traditional Systemverilog event does not have functionality to pass data when event is triggered. While uvm_event adds this functionality. So, you can pass the transaction class handle when some event is triggered.</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">By calling trigger task we can trigger the event and optionally give the data which we want to pass using uvm_event.</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">By calling wait_trigger()/wait_ptrigger() task of uvm_event we can wait for event to be trigger and then by calling get_trigger_data() function we can get data.</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">or we can directly use only one task wait_trigger_data()/wait_ptrigger_data() of uvm_event to wait for event to be triggered and to get the data.</span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><b>2) setting callbacks,</b></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">We can also add callbacks whenever an event is triggered. This is done by registering a callback class with particular event.</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><b>3) maintaining the number of waiters,</b></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">We can get the number of processes waiting on the event (using get_num_waiters() function).</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><b>4) maintaining the time when event was triggered,</b></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">We can get the time that this event was last triggered (using get_trigger_time() function)</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;">Like SystemVerilog event has trigger (@event) and persistent trigger (wait(event.triggered)) mode, uvm_event also has trigger (wait_trigger task) and persistent trigger (wait_ptrigger task).</span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue" , "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Let's go through below example and see how we can transfer data using uvm_event and how we can disable uvm_event from triggering using callbacks of uvm_event.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
-------------------------------------------------------------------</div>
<div style="text-align: left;">
<script src="https://gist.github.com/sagar5258/78226e200942cbe8ac3687afcec8093d.js"></script></div>
<div style="text-align: left;">
-------------------------------------------------------------------</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
-------------------------------------------------------------------</div>
<div style="text-align: left;">
<script src="https://gist.github.com/sagar5258/6006f476ac8637bc75bbf3f072f62c63.js"></script></div>
<div style="text-align: left;">
-------------------------------------------------------------------</div>
<div style="text-align: left;">
As shown in above code, one uvm_event named PKT_TX_CMPLT_EV is taken in driver.</div>
<div style="text-align: left;">
In build phase of driver we get global handle of event pool using static method get_event_pool of uvm_event_pool class.</div>
<div style="text-align: left;">
Then PKT_TX_CMPLT_EV is added into associative array of uvm_event_pool using get/add method of uvm_event_pool. Note that here PKT_TX_CMPLT_EV event is added in associative array of uvm_event_pool using <b>key</b> (in string format) DRV_EVENT.</div>
<div style="text-align: left;">
In run phase of driver when stimulus is driven, <b>trigger</b> method of uvm_event is called and transaction class is passed in argument of trigger method.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
uvm_event also provides facility of callback when event is triggered.</div>
<div style="text-align: left;">
In code my_event_callback (callback for uvm_event) class which extended from uvm_event_callback.</div>
<div style="text-align: left;">
uvm_event_callback provides two hookups, 1) pre_trigger, 2) post_trigger.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>pre_trigger:</b></div>
<div style="text-align: left;">
Called just before triggering the associated event. If this function returns 1, then the event will not trigger and the post-trigger callback is not called.</div>
<div style="text-align: left;">
<b><br /></b></div>
<div style="text-align: left;">
<b>post_trigger:</b></div>
Called after triggering the associated event.<br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
-------------------------------------------------------------------</div>
<div style="text-align: left;">
<script src="https://gist.github.com/sagar5258/21d77ef327ff9a21d2df5c4928ced15e.js"></script></div>
<div style="text-align: left;">
-------------------------------------------------------------------</div>
<div style="text-align: left;">
As shown in above code, in sequence, event callback is registered with associated event using <b>add_callback</b> method of uvm_event and also deleted using <b>delete_callback</b> method of uvm_event</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
-------------------------------------------------------------------</div>
<div style="text-align: left;">
<script src="https://gist.github.com/sagar5258/7d387c1c6bcd8337958be76e627c3f58.js"></script></div>
<div style="text-align: left;">
-------------------------------------------------------------------<br />
<br />
<br />
FAQ:<br />
Through uvm_event we can pass data(transaction class) when event is triggered, then why do we need TLM/Analysis ports in UVM?<br />
Ans:<br />
If event is triggered again before receiver gets the data then data will be overwritten.</div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com1tag:blogger.com,1999:blog-5613919600281595895.post-41975433828661105442017-07-23T09:55:00.000+05:302017-07-23T10:03:12.178+05:30Reset Testing using Phase Jump in UVM<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Reset testing is a crucial element of functional sign-off for any chip.
The architectural components of the entire verification environment need to be
correctly synchronized to be made aware of the reset condition. Scoreboards,
drivers and monitors need to be tidied up, and the complex stimulus generation
needs to be killed gracefully.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
As we know, in UVM, there are twelve phases parallel to run_phase:<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
</div>
<ol style="text-align: left;">
<li>pre_reset_phase(), reset_phase(), post_reset_phase(): Phases involved
in reset activity.</li>
<li>pre_configure_phase(), configure_phase(), post_configure_phase():
Phases involved in configuring DUT.</li>
<li>pre_main_phase(), main_phase(), post_main_phase(): Phases involved in
driving main stimulus to the DUT.</li>
<li>pre_shutdown_phase(), shutdown_phase and post_shutdown_phase(): Phases
involved in settling down the DUT after driving main stimulus.</li>
</ol>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Using these phases instead of using only run_phase, we can achieve
synchronization between all components of verification environment also easily
test reset functionality.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
In reset testing, user drives random sequence to the DUT and in between
data transmission, reset is applied followed by driving restart sequence. We
will see how the reset functionality could be easily tested using phases
parallel to run_phase and phase jump feature of UVM.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Let’s go through complete example to understand how it is achieved
using UVM phases and Phase jump feature.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
----------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/1b27b8387314349317c680380202bd69.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
----------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
----------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/b808483a8c56ccdf20e497bc49431073.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
----------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
As shown in above code,<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Driver is waiting for Reset to be asserted (in reset_phase) by raising
objection and then perform action which user want on assertion of Reset signal
and at last drop the objection and move to post_reset_phase. In post_reset_phase
driver is waiting for Reset to de-assert and then move to main_phase. In
main_phase driver drives stimulus on interface and in parallel to that wait for indication
from agent about assertion of reset.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Components such as monitors that attach to signaling interfaces should
be designed to be phase independent because they are intended to mimic other
real devices in the system. These components should watch the reset signal
associated with their interface and reset themselves accordingly.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
You may find that the driver, the sequencer, and their currently
running sequences will squawk with errors if they are not synchronized
properly. UVM requires that the sequencer first stop its sequences and then the
driver must be certain to not call item_done on any outstanding sequences. However, the order that a simulator executes
threads in the various components is indeterminate. To synchronize these
operations, the containing agent has a pre_reset_phase such as the above.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
----------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<script src="https://gist.github.com/sagar5258/e0399aeb7ac9744394efbf0b04afd51e.js"></script><o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
----------------------------------------------------------------------<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
When test enters main_phase initially first time at that time run_count
is 0, so on assertion of Reset test will do phase.jump method and move to
pre_reset_phase from main_phase.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
When test enters main_phase second time at that time run_count is 1, so
at that time it will not do phase jumping.<o:p></o:p></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Note: It is not good to use a phase jumping feature in case any of the
components of testbench don’t use the sub-phases of UVM.<o:p></o:p></div>
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
Reference:</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="text-indent: -0.25in;">1)</span><span style="font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal; text-indent: -0.25in;">
</span><a href="http://www.sunburst-design.com/papers/HunterSNUGSV_UVM_Resets_paper.pdf" style="text-indent: -0.25in;">http://www.sunburst-design.com/papers/HunterSNUGSV_UVM_Resets_paper.pdf</a></div>
<div class="MsoListParagraph" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<o:p></o:p></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com2tag:blogger.com,1999:blog-5613919600281595895.post-65303376159357626782017-07-22T22:01:00.001+05:302017-09-25T09:33:13.571+05:30Extend run_phase using set_drain_time and all_dropped callback after all objection drops <div dir="ltr" style="text-align: left;" trbidi="on">
It is more often that two or more components in verification environment are not in sync with each other. And there may be a case where driver/transmitter finish it's job first and call item_done. After item_done is called from driver and if there is no action pending in sequence then start method of sequence finishes and objection is also dropped.<br />
But we want that simulation (more precisely we can say run_phase) should extend to some more time after all objection are dropped, so that other components which are late with respect to driver can finish it's job. We can achieve this by using set_drain_time in UVM.<br />
<br />
Let's go through example and see how we can achieve this using set_drain_time in UVM.<br />
--------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/8909a643f06ddec26d0c3893232d32cd.js"></script><br />
--------------------------------------------------------------------<br />
<br />
<br />
UVM also provides callback hookups when every objection raises and drops and when all objection drops.<br />
Let's go through example and see how it works,<br />
<br />
--------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/5c226ddec1588a5dbb3ee22036b00743.js"></script><br />
--------------------------------------------------------------------<br />
--------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/58abc4210710e8ba2e1ab7089e6dbf59.js"></script><br />
--------------------------------------------------------------------<br />
<br />
<span style="color: blue;">Once all the objections are dropped, Drain time takes effect. After Drain time is finished, all_dropped callback takes effect.</span></div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com2tag:blogger.com,1999:blog-5613919600281595895.post-29430450783156771562017-07-22T19:54:00.001+05:302017-07-22T19:54:55.351+05:30Pros and Cons of Pointers in C<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Advantages of Pointer:</b></span></h3>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">1) Pointers allow us to perform dynamic memory allocation and deallocation</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">2) Using pointer we can return more than one value from the function</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">3) Using pointer can pass array or string more efficiency</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">4) Pointer helps us to build complex data structure like linked-list, stack, tree, graphs etc.</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">5) Pointers permit references to functions and thereby facilitating passing of functions as arguments to other functions.</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">6) Use function call by reference.</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">4) Increase the execution speed of program. how?</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<h3 style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Drawback of Pointer:</b></span></h3>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">1) Uninitialized pointers might cause segmentation fault.</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">2) Dynamically allocated block needs to be freed explicitly. Otherwise, it would lead to memory leak.</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">3) If pointers are updated with incorrect values, it might lead to memory corruption.</span></div>
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">4) Pointer bugs are difficult to debug.</span></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com1tag:blogger.com,1999:blog-5613919600281595895.post-7615508539542418892017-03-23T15:59:00.000+05:302017-03-23T15:59:45.431+05:30Automatic raise/drop objection with UVM-1.2<div dir="ltr" style="text-align: left;" trbidi="on">
Variable <b>uvm_sequence_base::starting_phase</b> is deprecated and replaced by two new methods <b>set_starting_phase</b> and <b>get_starting_phase</b>, which prevent <b>starting_phase</b> from being modified in the middle of a phase. This change is not backward-compatible with UVM 1.1, though variable <b>starting_phase</b>, although deprecated, has not yet been removed from the base class library.<br />
<br />
New method <b>uvm_sequence_base::set_automatic_phase_objection</b> causes <b>raise_objection</b> and <b>drop_objection</b> to be called automatically around a sequence, avoiding the need to call raise/drop_objection manually in one common situation.<br />
<div>
<br /></div>
<div>
Lets understand it trough below mentioned example.</div>
------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/a30c711ac030fc3c71b870189a46d3db.js"></script><br />
------------------------------------------------<br />
<br />
<br />
<b>Ref:</b><br />
1) <a href="https://www.doulos.com/knowhow/sysverilog/uvm/uvm-1.2/" target="_blank">https://www.doulos.com/knowhow/sysverilog/uvm/uvm-1.2/</a><br />
<br /></div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com24tag:blogger.com,1999:blog-5613919600281595895.post-75831365480656448432017-03-23T12:21:00.001+05:302017-07-23T09:58:35.909+05:30Simulation timeout in UVM using set_timeout and +UVM_TIMEOUT<div dir="ltr" style="text-align: left;" trbidi="on">
Default timeout for simulation or you can say timeout for run_phase (as rest all phases are non-time consuming) is `UVM_DEFAULT_TIMEOUT, if not overridden by uvm_root::set_timeout or uvm_cmdline_processor::+UVM_TIMEOUT.<br />
<br />
Default value of `UVM_DEFAULT_TIMEOUT is 9200 second.<br />
<div>
-------------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/bb725f4d4a690fa451bdda8a3899f70c.js"></script></div>
<div>
-------------------------------------------------</div>
<div>
<br /></div>
<div>
<div>
Example 1 (Timeout at default time which is 9200 second):</div>
<div>
<div>
-------------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/8fd4f6ab37921bb6a3b154e55201720c.js"></script></div>
<div>
-------------------------------------------------</div>
</div>
</div>
<div>
<h3 style="text-align: left;">
<span style="font-size: large;">1) Overridden by uvm_root::set_timeout</span></h3>
<div>
-------------------------------------------------</div>
</div>
<div>
<script src="https://gist.github.com/sagar5258/0f85fcc85bef37bbbca2cc0add793645.js"></script></div>
<div>
-------------------------------------------------</div>
<div>
-------------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/38ce9018260b17ec79809614b9644cb1.js"></script></div>
<div>
-------------------------------------------------</div>
<div>
<br /></div>
<div>
Example 2 (Timeout at specified time which is specified using set_timeout):</div>
<div>
<div>
<div>
-------------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/2f7701b403a144c845f2b968d1886eb6.js"></script></div>
<div>
-------------------------------------------------</div>
</div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<h3 style="text-align: left;">
<span style="font-size: large;">2) Overridden by uvm_cmdline_processor::+UVM_TIMEOUT</span></h3>
<div>
+UVM_TIMEOUT=<timeout>,<overridable> allows users to change the global timeout of the UVM framework. The <overridable> argument (‘YES’ or ‘NO’) specifies whether user code can subsequently change this value. If set to ‘NO’ and the user code tries to change the global timeout value, a warning message will be generated.</overridable></overridable></timeout></div>
<div>
<br /></div>
<div>
<div>
Example 3 (Timeout at 100s using simulation switch <b>+UVM_TIMEOUT=100000000000</b>):</div>
<div>
<b>Note: Here you need to give simulation time in format of timescale defined in simulation</b></div>
<div>
<div>
-------------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/c16dfea828036fc062583b09590be2b2.js"></script></div>
<div>
-------------------------------------------------</div>
</div>
</div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com5tag:blogger.com,1999:blog-5613919600281595895.post-77514448944234113242017-02-21T16:48:00.000+05:302017-02-21T16:49:15.096+05:30Lock and Grab of sequencer in UVM<div dir="ltr" style="text-align: left;" trbidi="on">
There are a number of modelling scenarios where one sequence needs to have exclusive access to a driver via a sequencer. One example of this type of scenario is a sequence which is responding to an interrupt.<br />
In order to accommodate this requirement, the uvm_sequencer provides 2 types of mechanism called lock()-unlock() and grab()-ungrab().<br />
<br />
If sequencer is doing some sequence and based on some external events if user wants sequencer to pause the current sequence, he/she can grab/lock sequencer and start another sequence. Once the started sequence finishes sequencer can resume the normal operation, upon ungrab/unlock.<br />
This mechanism is generally used to mimic CPU behavior, where CPU is doing a normal bus operation and when interrupt comes, CPU needs to suspend the normal operation and start interrupt handling. Once interrupt handling is over, CPU should resume the normal operation from where it was suspended.<br />
<br />
A lock might be used to model a prioritized interrupt and a grab might be used to model a non-mask able interrupt (NMI).<br />
The lock() and grab() calls have antidote calls to release a lock and these are unlock() and ungrab().<br />
<br />
<b><span style="font-size: large;">Lock()</span></b><br />
1) A lock() request is put in <b><span style="color: blue;">back</span></b> of the arbitration queue . A lock request will be arbitrated the same as any other request.<br />
2) A lock is granted after all earlier requests are completed and no other locks or grabs are blocking this sequence.<br />
3) A lock() is blocking task and when access is granted, it will unblock.<br />
4) If no argument is supplied, then current default sequencer is chosen.<br />
<span style="font-size: large;"><br /></span>
<b><span style="font-size: large;">Grab()</span></b><br />
1) A grab() request is put in <b><span style="color: blue;">front</span></b> of the arbitration queue. A grab() request will be arbitrated before any other requests.<br />
2) A grab() is granted when no other grabs or locks are blocking this sequence. (The only thing that stops a sequence from grabbing a sequencer is a pre-existing lock() or grab() condition.)<br />
3) A grab() is blocking task and when access is granted, it will unblock.<br />
4) If no argument is supplied, then current default sequencer is chosen.<br />
<b><br /></b>
<b><span style="font-size: large;">Unlock()</span></b><br />
The unlock sequencer function is called from within a sequence to give up its lock or grab. A locking sequence must call unlock before completion; otherwise the sequencer will remain locked.<br />
<b><br /></b>
<b><span style="font-size: large;">Ungrab()</span></b><br />
An alias of function unlock().<br />
<br />
<br />
<span style="color: blue;">What happens if 2 sequences try to grab or lock the same sequencer?</span><br />
The most recent grab goes to the front of the queue; the most recent lock goes to the back of the queue.<br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">Priority in lock() and grab().</span><br />
The most recent grab comes first, then the previous grab... then the oldest lock, then the most recent lock.<br />
<div>
<br /></div>
<div>
<div>
Let’s go through basic example of lock() and grab()</div>
<div>
<b>1) Lock</b></div>
<div>
---------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/10de96947e29cbb0c3ab3edad11d2d1a.js"></script></div>
<div>
---------------------------------------------</div>
<div>
<br /></div>
<div>
<b>2) Grab</b></div>
<div>
---------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/06714a9a0f8acd2137d39fea7fe413c8.js"></script></div>
<div>
---------------------------------------------</div>
<div>
From output of above two examples, we can see the difference between lock() and grab() as mentioned above.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="color: blue;">When a hierarchical sequence locks/grab a sequencer, then its child sequences will have access to the sequencer.</span></div>
<div>
If one of the child sequences issues a lock/grab, then the parent sequence will not be able to start any parallel sequences or send any sequence_items until the child sequence has unlocked.</div>
<div>
---------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/e77acac2179c048ead14dbfa2f26ab3b.js"></script></div>
<div>
---------------------------------------------</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="color: blue;">A locking or grabbing sequence must always unlock before it completes,</span></div>
<div>
---------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/06563a8409640859f3c8f9236d684e49.js"></script></div>
<div>
---------------------------------------------</div>
<div>
<br /></div>
<div>
Now let’s go through one example where 2 virtual sequences are running in parallel and one virtual sequence put lock/grab on agent’s sequencer.</div>
<div>
<br /></div>
<div>
---------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/64a2d1f24486c816fbcf4774d11a3106.js"></script></div>
<div>
---------------------------------------------</div>
</div>
<div>
<br /></div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com8tag:blogger.com,1999:blog-5613919600281595895.post-46918257400318583342017-02-16T15:48:00.000+05:302017-02-21T16:38:45.961+05:30Difference between @event and wait(event.triggered) in SystemVerilog and usage of non-blocking event<div dir="ltr" style="text-align: left;" trbidi="on">
The event data type provides a handle to a synchronization object.<br />
<br />
There are two ways through which we can wait for particular event to be triggered.<br />
So let's understand what is the exact difference between those 2 ways.<br />
<br />
-----------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/50e4d048c465b16aeb53fc4760ff23f1.js"></script><br />
-----------------------------------------------<br />
<br />
An event trigger ->e is an instantaneous event. The event waiting process @ shall execute before the triggering process -> executes. If the trigger executes first, then the waiting process remains blocked.<br />
<br />
The <i>triggered</i> event property evaluates to true (1'b1) if the given event has been triggered in the current time step and false (1'b0) otherwise.<br />
Now you no longer have to worry which came first, the triggering process –> or the waiting process @ statement. But you still have to execute the waiting process @ in the current time slot to catch the event.<br />
<br />
Let’s see the behavior with examples,<br />
-----------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/d13f198b56952936aa3c123987695c78.js"></script><br />
-----------------------------------------------<br />
<br />
-----------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/1d5bc9a5c573936da526b5a1e9937d8b.js"></script><br />
-----------------------------------------------<br />
<div>
<br />
The other workaround is to use nonblocking event<br />
<br />
<u><span style="font-size: large;"><b>Non-blocking event </b><span style="color: blue;"><b>->></b></span></span></u><br />
Nonblocking events are triggered using the ->> operator.<br />
<br />
The effect of the ->> operator is that the statement executes without blocking, and it creates a nonblocking assign update event in the time in which the delay control expires or the event control occurs. The effect of this update event shall be to trigger the referenced event in the nonblocking assignment region of the simulation cycle.</div>
<div>
<br /></div>
<div>
-----------------------------------------------</div>
<div>
<script src="https://gist.github.com/sagar5258/6c2f51c0928ed3183fe618ded3af7eab.js"></script></div>
<div>
-----------------------------------------------</div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com3tag:blogger.com,1999:blog-5613919600281595895.post-73572130578690966722016-11-23T18:11:00.001+05:302016-11-23T18:11:54.330+05:30Kill process in SystemVerilog using "disable fork" and "disable LABEL"<div dir="ltr" style="text-align: left;" trbidi="on">
Most of us, have faced these some issues at least one time in our SystemVerilog programming while using "disable fork" and "disable LABEL".<br />
<br />
Let's first go through below example,<br />
------------------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/7c5f1b710c8c8c91debbbeaec52d7cf1.js"></script><br />
------------------------------------------------------------------------------<br />
<br />
As shown in above example, "Process:1" is running continuously. Two different processes, "Process:2" and "Process:3" should run in parallel and any of two processes is completed, other process shall stop its execution due to join_any statement.<br />
<br />
While simulating above code, you may face that when the <b>disable fork</b> is executed, "Process:1" also stop it's execution. So, to avoid this kind of situation, it's better to use "disable LABEL" statement.<br />
------------------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/4bd06024945cedc7f55067a5fa175cb1.js"></script><br />
------------------------------------------------------------------------------<br />
<br />
Above code works fine with a single instance of that class. But when there are multiple instances of the same class in the test-bench and all the instances are executing their threads simultaneously then the simulation will stop after executing "disable LABEL" statement of any instance.<br />
------------------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/aa8dac895232907c4d7b7c4eff880b93.js"></script><br />
------------------------------------------------------------------------------<br />
<br />
There are two ways to handle these kind of situations.<br />
1) Limiting scope of "disable fork" by adding one extra hierarchy of fork...join.<br />
2) Using "process" class of SystemVerilog<br />
<br />
Let's see both ways through example,<br />
------------------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/dc2d26842ec8cc4be7f9ba83a1920017.js"></script><br />
------------------------------------------------------------------------------<br />
<br />
<br />
------------------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/edd9db50e69b1a9795f636025243f3b8.js"></script><br />
------------------------------------------------------------------------------</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com1tag:blogger.com,1999:blog-5613919600281595895.post-39302696109340592212016-11-23T17:37:00.001+05:302016-11-23T17:38:35.466+05:30Wait for more than one processes of fork...join_none to complete<div dir="ltr" style="text-align: left;" trbidi="on">
In our project some time we want to wait for more than one process which is invoked from fork...join_none or join_any before proceeding further.<br />
<br />
How to achieve this using SystemVerilog constructs, that we will understand through an example.<br />
<br />
Let's go through below code,<br />
-------------------------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/0eb33f91e574d24fc952da77afe6f338.js"></script><br />
-------------------------------------------------------------------------------------<br />
<br />
In above code, class <span style="background-color: white; color: #795da3; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">abc</span> is having one method named <span class="pl-en" style="background-color: white; box-sizing: border-box; color: #795da3; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">multiple_process</span><span style="background-color: white; color: #333333; font-family: "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">().</span><br />
In API, within fork...join_none 4 process are invoked in parallel.<br />
Each process puts one key into semaphore just before it's completed (Initially semaphore doesn't have any key).<br />
<br />
After fork...join_none, I am waiting for semaphore to get at least two key ().<br />
<br /></div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com0tag:blogger.com,1999:blog-5613919600281595895.post-36749565986974782732016-08-26T12:27:00.001+05:302016-08-26T12:27:50.653+05:30Callback vs Factory in UVM<div dir="ltr" style="text-align: left;" trbidi="on">
Callbacks and factory address different areas of re-usability.<br />
<br />
<b>Callback:</b> Add functionality to existing logic.<br />
<br />
<b>Factory:</b> Change the existing component before build, keeps environment same.<br />
<br />
Although the callback and factory can be interchangeably used to address the same problem. Depending on the need and demand, a wise decision should be made while adopting either of the techniques as they have their own merits and demerits.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-OlV5qCxb3YI/V7_ggycVjGI/AAAAAAAAADM/uaG8Htco7rI4McWw5VhGbT6nKyHdhiQsQCLcB/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="243" src="https://3.bp.blogspot.com/-OlV5qCxb3YI/V7_ggycVjGI/AAAAAAAAADM/uaG8Htco7rI4McWw5VhGbT6nKyHdhiQsQCLcB/s640/Capture.PNG" width="640" /></a></div>
<br /></div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com5tag:blogger.com,1999:blog-5613919600281595895.post-61151034820297232652016-06-22T11:51:00.000+05:302016-06-22T11:56:30.348+05:30Strength in Verilog<div dir="ltr" style="text-align: left;" trbidi="on">
Strengths can be used to resolve which value should appear on a net or gate output.<br />
A strength specification shall have the following two components:<br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>The strength of the 0 portion of the net value, called <i>strength0</i>, designated as one of the following:<br />
<b>supply0 strong0 pull0 weak0 highz0</b><br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>The strength of the 1 portion of the net value, called <i>strength1</i>, designated as one of the following:<br />
<b>supply1 strong1 pull1 weak1 highz1</b><br />
The combinations (highz0, highz1) and (highz1, highz0) shall be considered illegal.<br />
<br />
There are four <u>driving strengths</u>: <b>supply strong pull weak</b><br />
Signals with driving strengths shall propagate from gate outputs and continuous assignment outputs.<br />
<br />
There are three <u>charge storage strengths</u>: <b>large medium small</b><br />
Signals with the charge storage strengths shall originate in the <i>trireg</i> net type.<br />
<br />
It is possible to think of the strengths of signals as locations on the scale<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-UGs3bMKKNLw/V2ovKXjfyRI/AAAAAAAAAC8/-iNX6DEsuxsSYJgkNBOAzFWBTTV4d9rZACLcB/s1600/strength.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="66" src="https://3.bp.blogspot.com/-UGs3bMKKNLw/V2ovKXjfyRI/AAAAAAAAAC8/-iNX6DEsuxsSYJgkNBOAzFWBTTV4d9rZACLcB/s400/strength.PNG" width="400" /></a></div>
<br />
When signals combine, their strengths and values shall determine the strength and value of the resulting signal in accordance with the principle.<br />
<br />
<b><span style="color: blue;">1)<span class="Apple-tab-span" style="white-space: pre;"> </span>If two or more drivers drive a signal with different strength then it will have the value of the strongest driver</span></b><br />
<b><span style="color: blue;">Ex-1:</span></b><br />
<b>buf (strong1, weak0) g1 (y, a);</b><br />
<b>buf (pull1, supply0) g2 (y, b);</b><br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>If a = 0 and b = 0 then y will be 0 with supply strength because both gates will set y to 0 and supply (7) strength has bigger value than weak (3) strength.<br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>If a = 0 and b = 1 then y will be 1 with pull strength because g1 will set y to 0 with weak (3) strength and g2 will set y to 1 with pull (5) strength (pull strength is stronger than the weak strength).<br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>If a = 1 and b = 0 then y will be 0 with supply strength because g1 will set y to 1 with strong (6) strength and g2 will set y to 0 with supply (7) strength (supply strength is stronger than the strong strength).<br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>If a = 1 and b = 1 then y will be 1 with strong strength because g1 will set y to 1 with strong (6) strength and g2 will set y to 1 with pull (5) strength.<br />
<br />
<b><span style="color: blue;">2)<span class="Apple-tab-span" style="white-space: pre;"> </span>The combination of signals identical in strength and value shall result in the same signal (If two drivers of a net have the same strength and value, then the net result will have the same value and strength)</span></b><br />
<b><span style="color: blue;">Ex-2:</span></b><br />
<b>buf (strong1, weak0) g1 (y, a);</b><br />
<b>buf (strong1, weak0) g1 (y, b);</b><br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>If a = 0 and b = 0 then y will be 0 with weak strength.<br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>If a = 1 and b = 1 then y will be 1 with strong strength.<br />
<b><span style="color: blue;"><br /></span></b>
<b><span style="color: blue;">3)<span class="Apple-tab-span" style="white-space: pre;"> </span>If two drivers of a net have the same strength but different values then signal value will be unknown and it will have the same strength as both drivers</span></b><br />
<span style="color: blue;"><b>Ex-3:</b></span><br />
<b>buf (strong1, weak0) g1 (y, a);</b><br />
<b>buf (weak1, strong0) g1 (y, b);</b><br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>If a = 1 and b = 0 then y will be x with strong strength.<br />
<br />
<b>Important Notes:</b><br />
If one of the drivers has an H or L value, then the output value will be X.<br />
<div>
<br />
Reference:<br />
1) <a href="http://verilog.renerta.com/source/vrg00047.htm" target="_blank">http://verilog.renerta.com/source/vrg00047.htm</a><br />
2) System Verilog LRM (1800-2012)</div>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com0tag:blogger.com,1999:blog-5613919600281595895.post-28698709243754259442016-04-30T17:35:00.002+05:302016-04-30T17:59:17.858+05:30Override in UVM using factory with Example<div dir="ltr" style="text-align: left;" trbidi="on">
One of the main advantage of UVM is Creating each components using factory enables them to be overridden in different tests or environments without changing underlying code base.<br />
<br />
uvm_factory provides four different methods to override particular instance or all instances of particular class.<br />
<b>set_inst_override_by_type<br />set_inst_override_by_name<br />set_type_override_by_type<br />set_type_override_by_name</b><br />
<br />
Let's go through example of each one of above four ways.<br />
<br />
<span style="color: blue;">set_inst_override_by_type</span><br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/d14cf3f4e58837f7cc3f.js"></script><br />
-------------------------------------------------------<br />
<br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/b4e2d0f613ad987f621e.js"></script><br />
-------------------------------------------------------<br />
<br />
<span style="color: blue;"><br />set_inst_override_by_name</span><br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/18c19d546383feccf05f.js"></script><br />
-------------------------------------------------------<br />
<br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/f533227badb7e2be17ed.js"></script><br />
-------------------------------------------------------<br />
<br />
<br />
<span style="color: blue;">set_type_override_by_type</span><br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/ebe1144bb805500e424be73a9a63868e.js"></script><br />
-------------------------------------------------------<br />
<br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/079b15f86111bddc6193d06923c6072f.js"></script><br />
-------------------------------------------------------<br />
<br />
<br />
<span style="color: blue;">set_type_override_by_name</span><br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/fd6509fb20c3f5759a06934496b80942.js"></script><br />
-------------------------------------------------------<br />
<br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/3cff3d2079dcc00f7399efae81b06133.js"></script><br />
-------------------------------------------------------<br />
<br />
set_inst_override_* has high precedence than set_type_override_*.<br />
i.e. If any particular instance of class is override by using set_inst_override_* and type of same class is overridden by using set_type_override_* then that particular instance of class is overridden by set_inst_override_* and rest other instances are overridden by set_type_override_*<br />
<br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/2012c6580cfc3adf40b6005576212562.js"></script><br />
-------------------------------------------------------<br />
<br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/30df9432a266d1881df81fb9b5aebdee.js"></script><br />
-------------------------------------------------------<br />
<br />
<br />
<br />
UVM also support override through command line,<br />
<span style="color: blue;">+uvm_set_inst_override=<req_type>,<override_type>,<full_inst_path><br />+uvm_set_type_override=<req_type>,<override_type>[,<replace>]</replace></override_type></req_type></full_inst_path></override_type></req_type></span><br />
work like the <span style="color: blue;"><b>name</b></span> based overrides in the factory--factory.set_inst_override_by_name() and factory.set_type_override_by_name().<br />
<br />
Let's implement same example as above using command line arguments. <br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/38270b25d42a59417dfde8fa4a49fa66.js"></script><br />
-------------------------------------------------------<br />
<br />
Simulation time argument:<br />
<span style="color: blue;">+uvm_set_inst_override=A,A_override,uvm_test_top.env.a3 \</span><br />
<span style="color: blue;">+uvm_set_inst_override=B,B_ovr,path1.b1 \</span><br />
<span style="color: blue;">+uvm_set_type_override=A,A_ovr \</span><br />
<span style="color: blue;">+uvm_set_type_override=B,B_override</span><br />
-------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/27defc0e488a08cf112728475d4707e6.js"></script><br />
-------------------------------------------------------</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com11tag:blogger.com,1999:blog-5613919600281595895.post-52418658860409245702016-04-30T12:53:00.000+05:302016-04-30T12:57:51.970+05:30Singleton class in System Verilog<div dir="ltr" style="text-align: left;" trbidi="on">
Sometimes it is required to have only one object of some classes like configuration classes. For this purpose we create singleton classes.<br />
Only one object is created for a singleton class and whenever we try to create a new object, same object is returned.<br />
<br />
System verilog does not provide construct to create a singleton class. But we can create it with some manipulation.<br />
<br />
---------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/9efd486446fd02de8b70140cce521387.js"></script><br />
---------------------------------------------------------------------<br />
<br />
<br />
uvm_root class defined as a singleton class in UVM source code.<br />
---------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/af6db535ff37476da250a61cb045ea74.js"></script><br />
---------------------------------------------------------------------</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com4tag:blogger.com,1999:blog-5613919600281595895.post-59572187282558211922016-04-25T23:44:00.002+05:302016-07-26T10:58:27.163+05:30UVM FAQ2<div dir="ltr" style="text-align: left;" trbidi="on">
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>Frank Poppen</o:Author>
<o:Version>14.00</o:Version>
</o:DocumentProperties>
<o:OfficeDocumentSettings>
<o:RelyOnVML/>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:RelyOnVML/>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-IN</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: blue;"><span style="background: white none repeat scroll 0% 0%; font-family: "times new roman" , "serif"; font-size: 12pt;">Why phasing is used? What
are the different phases in uvm?</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;">UVM Phases is used to
control the behavior of simulation in a systematic way & execute in a
sequential ordered to avoid race condition. This could also be done in system
verilog but manually.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-align: center;">
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;"> <a href="http://1.bp.blogspot.com/-4fJrVJAubME/Vx-hFJL3NvI/AAAAAAAAACw/c0Dc6NVsV9M35bg2F58f4JpIwWNgd_jtgCK4B/s1600/phase.bmp" imageanchor="1"><img border="0" src="https://1.bp.blogspot.com/-4fJrVJAubME/Vx-hFJL3NvI/AAAAAAAAACw/c0Dc6NVsV9M35bg2F58f4JpIwWNgd_jtgCK4B/s1600/phase.bmp" /></a></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-size: small;"><br /></span>
<span style="font-size: small;"><br /></span>
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><span style="color: blue;">Which phases of UVM are Top-Down?</span></span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">build_phase() & final_phase() are Top-Down, rest all phases are Bottom-Up.</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span>
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span>
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span>
<div style="text-align: left;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue;"><span style="font-size: small;">Which phases of UVM are task?</span></span></span></div>
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">run_phase(),</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">pre_reset_phase(), reset_phase(), post_reset_phase(),</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">pre_configure_phase(), configure_phase(), post_configure_phase(),</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">pre_main_phase(), main_phase(), post_main_phase(),</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;">pre_shutdown_phase(), shutdown_phase(), post_shutdown_phase()</span></span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span>
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span>
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: blue; font-size: small;"><span style="background: white none repeat scroll 0% 0%;">How do uvm phases initiate?</span></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: Arial,Helvetica,sans-serif;"><span style="color: black; font-size: 12.0pt;">Calling run_test() constructs the UVM
environment root component and then initiates the UVM phasing.</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: blue;"><span style="background: white none repeat scroll 0% 0%; font-family: "times new roman" , "serif"; font-size: 12pt;">Why is the build_phase() in
UVM executed in a Top - Down fashion and the other phases in Bottom - Up
fashion?</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;">The build phase has to be
that way because the parent component's build_phase constructs the child
components. You couldn't call the child's build_phase before the parent's
build_phase because they the child objects haven't been constructed yet. You
need a constructed object to call its method.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;">The build_phase() is also
executed top-down so that the parent can provide override setting that the
children will use when they execute their build_phase()</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;">The ordering within the
other phases should not matter, except you might want know that the top level's
report_phase comes last.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: blue;"><span style="background: white none repeat scroll 0% 0%; font-family: "times new roman" , "serif"; font-size: 12pt;">What is the order of
execution of run_phase() ?</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;">The run_phase() of each
component is executed concurrently with no defined order you can depend on.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: blue;"><span style="background: white none repeat scroll 0% 0%; font-family: "times new roman" , "serif"; font-size: 12pt;">During the run_phase() is there
something like super.run_phase(phase) called? </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;">You only need to call
super.method() if you are extending a class an need the functionality of the
base method. There is nothing inside the run_phase() of a uvm_component, so
there is no need to call super.run_phase() when extending from it.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;">You may want to call it when
extending your classes from your base classes.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br /></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br />
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:RelyOnVML/>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-IN</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: blue;"><span style="font-family: "times new roman" , "serif"; font-size: 12.0pt;">What
is the difference between run_phase and main_phase in uvm_component? </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "times new roman" , "serif"; font-size: 12.0pt;">Actually,
you can start a sequence in any phase. It is more important to understand the
domain/scheduling relationships between the task based (i.e. runtime) phases.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "times new roman" , "serif"; font-size: 12.0pt;">UVM undergoes a number of pre-simulation phases (build, connect,
end_of_elaboration, start_of_simulation) that are all implemented with
functions. Once those are completed, the task based phases begin.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "times new roman" , "serif"; font-size: 12.0pt;">The standard
includes two schedules.</span></div>
<br />
<ul style="text-align: left;">
<li><span style="font-family: "times new roman" , "serif"; font-size: 12.0pt;">One is simply the run_phase, which starts executing at
time zero and continues until all components have dropped their objections
within the run_phase.</span></li>
<li><span style="font-family: "times new roman" , "serif"; font-size: 12.0pt;">The other schedule contains twelve phases that execute
parallel to the run phase. They are: pre_reset, reset, post_reset, pre_config,
config, post_config, pre_main, main, post_main, pre_shutdown, shutdown, and post_shutdown.
They execute in sequence.</span></li>
</ul>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="font-family: "times new roman" , "serif"; font-size: 12.0pt;">Every component has the opportunity to define or not
define tasks to execute these phases. A phase starts only when all components
in the previous phase have dropped their objections. A phase continues to
execute until all components have dropped their objections in the current
phase.</span></div>
</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<br />
<br />
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: blue;"><span style="background: white none repeat scroll 0% 0%; font-family: "times new roman" , "serif"; font-size: 12pt;">Why connect_phase() is
bottom-up?</span></span></div>
<br />
<span style="background: white; color: black; font-family: "times new roman" , "serif"; font-size: 12.0pt;"> </span>
</div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com7tag:blogger.com,1999:blog-5613919600281595895.post-17805543314202172442016-04-24T16:28:00.000+05:302016-04-24T16:37:11.415+05:30Difference between m_sequencer and p_sequencer in UVM<div dir="ltr" style="text-align: left;" trbidi="on">
To understand difference between<b> m_sequencer</b> and <b>p_sequencer</b>, let's first go through couple of classes from UVM library.<br />
-------------------------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/f93c61accb3e0bebf638468a0f279479.js"></script> <br />
-------------------------------------------------------------------------------------<br />
<br />
<br />
-------------------------------------------------------------------------------------<br />
<script src="https://gist.github.com/sagar5258/ab97fd26e4007e6c0ffe0f17458f1b63.js"></script> <br />
-------------------------------------------------------------------------------------<br />
<br />
When you call <b>`uvm_declare_p_sequencer</b> from sequence, it overrides <span style="color: blue;"><b>m_set_p_sequencer</b></span> function.<br />
When you call <b>start</b> method of sequence, it calls set_item_context method,<br />
Then <span style="color: blue;"><b>set_item_context</b></span> method calls <span style="color: blue;"><b>set_sequencer</b></span> method,<br />
Then <span style="color: blue;"><b>set_sequencer</b></span> method assign handle of sequencer (which you pass in start method of sequence) to <b>m_sequencer</b>,<br />
set_sequencer also calls <span style="color: blue;"><b>m_set_p_sequencer</b></span> method, but you have override the <span style="color: blue;"><b>m_set_p_sequencer</b> </span>method by declaring <b>`uvm_declare_p_sequencer</b> macro.<br />
So <span style="color: blue;"><b>m_set_p_sequencer</b></span> defined in macro will be executed, and it casts <b>m_sequencer</b> into <b>p_sequencer</b>,<br />
where p_sequencer's type is specified by the argument of <b>`uvm_declare_p_sequencer </b>macro.<br />
<br />
<br />
<h3 style="text-align: left;">
<span style="font-size: large;"><u><b>Conclusion:</b></u></span></h3>
<b>m_sequencer</b> and <b>p_sequencer</b> both point to the same thing (the sequencer on which the sequence is running). However, there are some important differences:<br />
<b>m_sequencer</b> is a <span style="color: red;"><b>generic uvm sequencer pointer</b></span> of type <span style="color: #e69138;"><b>uvm_sequencer_base</b></span>. It will always exist for an uvm_sequence and is initialized when the sequence is started.<br />
<br />
<b>p_sequencer</b> is a reference to <span style="color: #e69138;"><b>uvm_sequencer#(REQ,RSP)</b></span>, the user derived parameterized sequencer class.<br />
Other way you can say that p_sequencer is a <span style="color: red;"><b>type specific sequencer pointer</b></span><i>.</i><br />
<b>p_sequencer</b> will not exist if the <b>`uvm_declare_p_sequencer</b> macros aren't used.<br />
<br />
<span style="font-size: large;"><b>Advantage of p_sequencer over m_sequencer:</b></span><br />
<i><span style="color: blue;">Being type specific, you will be
able to access anything added to the sequencer (i.e. pointers to other
sequencers, handle of environment class (which is defined in user derived virtual sequencer class) etc.).</span></i><br />
<br />
<span style="font-size: large;"><b>Drawback of p_sequencer over m_sequencer:</b></span><br />
<i><span style="color: blue;">p_sequencer creates an additional dependency, means sequence which use p_sequencer may not be executed on all the sequencers. Sequence requires resource in sequencer class which is declared as p_sequencer (i.e. </span></i><i><span style="color: blue;">pointers to other
sequencers, handle of environment class, etc.)</span></i><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #464646; display: inline !important; float: none; font-family: Arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 22px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"></span></div>
Sagar Shahhttp://www.blogger.com/profile/02015039964952909868noreply@blogger.com9