<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arvind Soni on Medium]]></title>
        <description><![CDATA[Stories by Arvind Soni on Medium]]></description>
        <link>https://medium.com/@a.soniarav?source=rss-7bbfa74316de------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*aSga2VU9YNcN3SmP</url>
            <title>Stories by Arvind Soni on Medium</title>
            <link>https://medium.com/@a.soniarav?source=rss-7bbfa74316de------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 04:39:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a.soniarav/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why do we have do_copy(), do_compare() etc]]></title>
            <link>https://medium.com/@a.soniarav/why-do-we-have-do-copy-do-compare-etc-fc2fcce0644c?source=rss-7bbfa74316de------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc2fcce0644c</guid>
            <category><![CDATA[vlsi-design]]></category>
            <category><![CDATA[system-verilog]]></category>
            <category><![CDATA[vlsi]]></category>
            <category><![CDATA[uvm-training]]></category>
            <category><![CDATA[vlsi-verification]]></category>
            <dc:creator><![CDATA[Arvind Soni]]></dc:creator>
            <pubDate>Tue, 19 May 2026 07:24:26 GMT</pubDate>
            <atom:updated>2026-05-19T07:24:26.691Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most confusing concepts for beginners in UVM:</p><h3>Why do we have do_copy(), do_compare() etc.</h3><p>when UVM already provides copy() and compare() ?</p><p>At first, many engineers think:</p><blockquote><em>“Both are doing the same thing…”</em></blockquote><p>But internally, UVM follows a very smart OOP design pattern.</p><p>Let’s simplify it 👇</p><h3>First Understand This</h3><p>In UVM:</p><pre>copy()<br>compare()<br>print()<br>pack()<br>unpack()<br>clone()</pre><p>are the <strong>public API methods</strong>.</p><p>But:</p><pre>do_copy()<br>do_compare()<br>do_print()<br>do_pack()<br>do_unpack()</pre><p>are the <strong>customization hooks</strong>.</p><h3>Real Meaning</h3><p>Think like this:</p><p>Public MethodMeaningcopy()“Please copy this object”do_copy()“This is HOW my fields should be copied”</p><p>Public MethodMeaningcompare()“Please compare these objects”do_compare()“This is HOW my fields should be compared”</p><h3>Why UVM Uses This Design</h3><p>Because UVM base class (uvm_object) is GENERIC.</p><p>It does NOT know:</p><ul><li>your packet fields</li><li>your protocol structure</li><li>your transaction format</li></ul><p>For example, your transaction may contain:</p><pre>addr<br>data<br>burst<br>id<br>resp</pre><p>UVM cannot automatically guess:</p><ul><li>what to copy</li><li>what to compare</li><li>what to print</li></ul><p>So UVM gives:<br>✅ standard framework methods<br>✅ user customization hooks</p><h3>What Happens Internally?</h3><p>When you write:</p><pre>pkt2.copy(pkt1);</pre><p>UVM internally calls:</p><pre>pkt2.do_copy(pkt1);</pre><p>Similarly:</p><pre>pkt1.compare(pkt2);</pre><p>internally calls:</p><pre>pkt1.do_compare(pkt2, comparer);</pre><h3>Why NOT Override copy() Directly?</h3><p>Because copy() is the framework-level method.</p><p>It may already handle:<br>✅ null checks<br>✅ type safety<br>✅ generic UVM operations<br>✅ object consistency</p><p>UVM wants users to customize ONLY:</p><h3>object field behavior</h3><p>That’s why we override:</p><pre>do_copy()<br>do_compare()</pre><p>instead of framework APIs.</p><h3>Simple Real-Life Analogy</h3><p>Think of:</p><h3>copy()</h3><p>as:</p><blockquote><em>“Submit the application form”</em></blockquote><p>and</p><h3>do_copy()</h3><p>as:</p><blockquote><em>“Fill your personal details inside the form”</em></blockquote><p>Framework stays same.<br>User data changes.</p><h3>Real Verification Usage</h3><p>These methods are heavily used in:</p><p>✅ Scoreboards<br>✅ Reference models<br>✅ Packet cloning<br>✅ Transaction comparison<br>✅ Debugging mismatches<br>✅ Functional checking</p><p>For example:</p><ul><li>Driver sends packet</li><li>Monitor captures packet</li><li>Scoreboard compares expected vs actual</li></ul><p>That comparison often depends on:</p><h3>do_compare()</h3><h3>Important Interview Point</h3><p>copy() and compare() are:</p><h3>wrapper/framework methods</h3><p>while</p><p>do_copy() and do_compare() are:</p><h3>user-overridable customization methods</h3><h3>Final Takeaway</h3><p>This design is one of the best examples of:</p><h3>Object-Oriented Programming inside UVM</h3><p>It gives:<br>✅ framework consistency<br>✅ reusability<br>✅ customization flexibility<br>✅ cleaner verification architecture</p><p>And once you truly understand this,<br>many other UVM concepts start making much more sense.</p><p>#UVM #SystemVerilog #VLSI #DesignVerification #ASIC #SoC #Verification #Semiconductor #RTL #OOP #DVEngineer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ht6vnsAV3mLk1xcS7YUUnw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc2fcce0644c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solve before in SystemVerilog Constraints]]></title>
            <link>https://medium.com/@a.soniarav/solve-before-in-systemverilog-constraints-144a87fee08c?source=rss-7bbfa74316de------2</link>
            <guid isPermaLink="false">https://medium.com/p/144a87fee08c</guid>
            <dc:creator><![CDATA[Arvind Soni]]></dc:creator>
            <pubDate>Tue, 19 May 2026 06:07:04 GMT</pubDate>
            <atom:updated>2026-05-19T06:07:04.082Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most misunderstood concepts in SystemVerilog Constraints:<br>solve before</p><p>Many engineers know the syntax…</p><pre>solve a before b;</pre><p>…but very few truly understand:<br>👉 WHY we use it<br>👉 WHAT problem it solves<br>👉 WHAT it actually changes internally</p><p>Let’s simplify it.</p><h3>First Important Point</h3><p>solve before does NOT:<br>❌ add new constraints<br>❌ change legal solutions<br>❌ force a value</p><p>It ONLY:<br>✅ controls constraint solving order</p><h3>The Real Problem It Solves</h3><p>Consider this example:</p><pre>class pkt;</pre><pre>  rand bit a;<br>  rand bit [3:0] b;</pre><pre>  constraint c {<br>    (a == 1) -&gt; b == 15;<br>  }</pre><pre>endclass</pre><p>Looks fine, right?</p><p>But internally, the solver sees:</p><h3>Case 1:</h3><pre>a == 1</pre><p>Only ONE valid value for b</p><pre>b == 15</pre><h3>Case 2:</h3><pre>a == 0</pre><p>Now b can be:</p><pre>0 to 15</pre><p>That means:<br>👉 MUCH larger solution space exists for a == 0</p><p>So during randomization, solver statistically starts favoring:</p><pre>a == 0</pre><p>Result?<br>❌ a == 1 occurs very rarely</p><p>This is called:</p><h3>Solver Bias</h3><h3>Solution → solve before</h3><pre>constraint c {</pre><pre>  solve a before b;</pre><pre>  (a == 1) -&gt; b == 15;<br>}</pre><p>Now solver:</p><ol><li>Solves a first</li><li>Then solves b</li></ol><p>This improves:<br>✅ randomization distribution<br>✅ scenario generation fairness<br>✅ corner-case exploration</p><h3>Important Interview Point</h3><p>solve before affects:</p><h3>distribution</h3><p>NOT legality.</p><p>Legal solution space remains SAME.</p><h3>Real Verification Usage</h3><p>solve before is commonly useful in:</p><p>✅ Protocol packet generation<br>✅ Mode-dependent constraints<br>✅ Scenario balancing<br>✅ Command/data dependency generation<br>✅ Coverage improvement<br>✅ Avoiding randomization bias</p><h3>Common Mistake</h3><p>Many engineers think:</p><blockquote><em>“solve before changes constraints”</em></blockquote><p>❌ Wrong.</p><p>It only guides:</p><h3>variable solving order</h3><h3>Quick Comparison</h3><p>Featuresolve beforedistControls solving order✅❌Controls probability directly❌✅Affects legality❌❌Helps avoid solver bias✅Limited</p><h3>Final Takeaway</h3><p>If your constrained-random test is:</p><ul><li>missing corner cases</li><li>generating biased scenarios</li><li>Heavily favoring one condition</li></ul><p>…then understanding solve before can make a BIG difference in verification quality.</p><p>Sometimes the issue is not your constraint.<br>It’s the solver behavior behind it.</p><p>#SystemVerilog #UVM #VLSI #DesignVerification #ASIC #SoC #Constraints #Randomization #Verification #Semiconductor #RTL #DVEngineer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6vJ04R7bVqEUuET9AGykLw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=144a87fee08c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a tb_top in a UVM TB?]]></title>
            <link>https://medium.com/@a.soniarav/what-is-a-tb-top-in-a-uvm-tb-a8c26e29f7c0?source=rss-7bbfa74316de------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8c26e29f7c0</guid>
            <dc:creator><![CDATA[Arvind Soni]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 08:59:35 GMT</pubDate>
            <atom:updated>2026-04-17T08:59:35.183Z</atom:updated>
            <content:encoded><![CDATA[<p>tb_top is the only SystemVerilog module in your entire UVM testbench. Everything else — test, env, agent, driver, monitor, scoreboard — lives inside UVM class objects. <br>tb_top is the bridge that connects those class objects to the real hardware signals of the DUT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dK5k-7xIm6uEEi8LnP3RWQ.png" /></figure><h4><strong>The 7 things always present inside tb_top-</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*I66gjemQcBqz6SJiX2ZwUg.png" /></figure><h3><strong>Why tb_top must be a module, not a class:</strong></h3><ol><li><strong>Modules can contain interfaces<br></strong>SystemVerilog interfaces must be instantiated inside modules. Classes cannot contain interface instances — only virtual interface handles. tb_top is the module that owns all real interface instances.</li><li><strong>Modules drive real signals<br></strong>Clock generation with always, reset with initial — these are procedural module constructs. A UVM class has no concept of simulation time in the structural sense.</li><li><strong>Modules connect to the DUT<br></strong>The DUT is a synthesizable RTL module. It can only be instantiated and connected inside another module — never inside a class. tb_top owns that structural connection.</li></ol><p>Now let’s go deep — every block inside tb_top, visualised with its full wiring.</p><p><strong>Diagram 1</strong> — <strong>The complete anatomy of </strong><strong>tb_top: every block and its role</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qjfWmCl4Xx9vZikstjTeNQ.png" /></figure><p><strong>Diagram 2 — The interface: the most important element inside </strong><strong>tb_top</strong></p><p>The interface is the most critical structural element. It is the only legal way to pass hardware signals from a SystemVerilog module into a UVM class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HGoyGgnM-rTiMojub_TlAg.png" /></figure><p><strong>Diagram 3 — </strong><strong>run_test(): what happens when that one line executes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vjT1oCTosPkrU5BtnP049A.png" /></figure><p><strong>Diagram 4 — Clock and reset generation: every pattern you’ll encounter</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8sKjifCZsKSWtQiLaxDvQ.png" /></figure><p><strong>Diagram 5 — The complete </strong><strong>tb_top for a multi-agent testbench</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yM-QUcQbQHfrDYjMxFY3Ng.png" /></figure><p>Now here is the complete, production-grade tb_top code covering every concept.</p><p><strong>Complete </strong><strong>tb_top — every element annotated</strong></p><blockquote>// <em>===============================================================</em>// tb_top.sv — The ONLY module in a UVM testbench<br>//<br>// Responsibilities:<br>// 1. Import UVM packages<br>// 2. Generate clocks and resets<br>// 3. Instantiate the SystemVerilog interface(s)<br>// 4. Instantiate the DUT and connect it to the interface<br>// 5. Push virtual interface handles into config_db<br>// 6. Call run_test() — launches the entire UVM kernel<br>// 7. Optional: waveform dump, SVA bind, coverage control<br>//<br>// Rule: tb_top contains ZERO UVM class instantiation.<br>// All UVM objects are created by run_test() → factory.<br>//<em> ================================================================<br>module tb_top;</em></blockquote><blockquote>// ── 1. PACKAGE IMPORTS ───────────────────────────────────────<br> // <strong>uvm_pkg :</strong> all UVM base classes, macros, phase engine<br> // <strong>uvm_macros :</strong> `uvm_info, `uvm_fatal, `uvm_component_utils etc.<br> // <strong>tb_pkg :</strong> your testbench package (seq items, sequences, tests)<em><br> import uvm_pkg::*;<br> `include “uvm_macros.svh”<br> import axi4_tb_pkg::*; // contains all testbench class definitions</em></blockquote><blockquote>// ── 2. CLOCK GENERATION ──────────────────────────────────────<em><br></em> // Use ‘logic’ not ‘reg’ — logic is preferred in SV interfaces.<br> // Initialize to 0 so simulator knows the starting state.<br> // always #N toggles every N time units → period = 2N.<em><br> logic axi_clk = 0;<br> logic apb_clk = 0;</em></blockquote><blockquote><em>always #5 axi_clk = ~axi_clk; // 100 MHz (period = 10 ns with 1ns precision)<br> always #20 apb_clk = ~apb_clk; // 25 MHz (period = 40 ns)</em></blockquote><blockquote>// ── 3. RESET GENERATION ──────────────────────────────────────<br> // Active-low reset (most common in AXI designs).<br> // Initialize to 0 (asserted) — DUT starts in reset.<br> // Align release to a clock rising edge to avoid setup violations.<em><br> logic rst_n = 0;</em></blockquote><blockquote><em>initial begin<br></em> // Hold reset for 5 clock cycles, then release on a clock edge<br><em> repeat(5) @(posedge axi_clk);<br> @(posedge axi_clk); // align to edge<br> #1; </em>// tiny offset to avoid race with clk edge<em><br> rst_n = 1;<br> `uvm_info(“TB_TOP”, “Reset released”, UVM_LOW)<br> end</em></blockquote><blockquote>// ── 4. INTERFACE INSTANTIATION ───────────────────────────────<br> // The interface owns the actual signal wires.<br> // It receives clock and reset as inputs.<br> // ‘dut_if’ is the REAL instance — not a virtual interface.<br> // A virtual interface is a handle (pointer) to this instance.<em><br> axi4_if dut_axi_if (<br> .aclk (axi_clk),<br> .aresetn (rst_n)<br> );</em></blockquote><blockquote><em>apb_if dut_apb_if (<br> .pclk (apb_clk),<br> .presetn (rst_n)<br> );</em></blockquote><blockquote><em>/</em>/ ── 5. DUT INSTANTIATION ─────────────────────────────────────<br> // The DUT (RTL) connects signal-by-signal to the interface.<br> // The interface signals are referenced as dut_axi_if.signal_name.<br> // This is the ONLY place where RTL meets the testbench.<em><br> soc_dut u_dut (<br></em> // AXI4 write address channel<br><em> .aclk (dut_axi_if.aclk),<br> .aresetn (dut_axi_if.aresetn),<br> .awid (dut_axi_if.awid),<br> .awaddr (dut_axi_if.awaddr),<br> .awlen (dut_axi_if.awlen),<br> .awsize (dut_axi_if.awsize),<br> .awburst (dut_axi_if.awburst),<br> .awvalid (dut_axi_if.awvalid),<br> .awready (dut_axi_if.awready),<br></em> // AXI4 write data channel<br><em> .wdata (dut_axi_if.wdata),<br> .wstrb (dut_axi_if.wstrb),<br> .wlast (dut_axi_if.wlast),<br> .wvalid (dut_axi_if.wvalid),<br> .wready (dut_axi_if.wready),<br></em> // AXI4 write response channel<br><em> .bid (dut_axi_if.bid),<br> .bresp (dut_axi_if.bresp),<br> .bvalid (dut_axi_if.bvalid),<br> .bready (dut_axi_if.bready),<br></em> // APB slave port<br><em> .pclk (dut_apb_if.pclk),<br> .presetn (dut_apb_if.presetn),<br> .psel (dut_apb_if.psel),<br> .penable (dut_apb_if.penable),<br> .pwrite (dut_apb_if.pwrite),<br> .paddr (dut_apb_if.paddr),<br> .pwdata (dut_apb_if.pwdata),<br> .prdata (dut_apb_if.prdata),<br> .pready (dut_apb_if.pready)<br> );</em></blockquote><blockquote>// ── 6. OPTIONAL: SVA ASSERTIONS VIA BIND ─────────────────────<br> // bind attaches an assertion module to the DUT without<br> // modifying any RTL source. The assertion sees all DUT signals.<em><br> bind soc_dut axi4_protocol_checker u_chk (<br> .aclk (aclk),<br> .aresetn (aresetn),<br> .awvalid (awvalid),<br> .awready (awready)<br> // … </em>remaining <em>signals<br> );</em></blockquote><blockquote>// ── 7. OPTIONAL: WAVEFORM DUMP ───────────────────────────────<br> // Guard with a plusarg so it only runs when explicitly requested.<br> // +DUMP_WAVES on the command line enables it.<em><br> initial begin<br> if ($test$plusargs(“DUMP_WAVES”)) begin<br> $dumpfile(“tb_top.vcd”);<br> $dumpvars(0, tb_top); // 0 = all hierarchy levels<br> `uvm_info(“TB_TOP”, “VCD dump enabled”, UVM_LOW)<br> end<br> end</em></blockquote><blockquote>// ── 8. MAIN INITIAL BLOCK: config_db + run_test() ────────────<br> // CRITICAL ORDER:<br> // a) All config_db::set() BEFORE run_test()<br> // b) run_test() LAST — it never returns<br> //<br> // Why before run_test()?<br> // run_test() triggers build_phase where drivers/monitors call get().<br> // If set() happens after, get() finds nothing → uvm_fatal.<br> //<br> // Why null context?<br> // We are inside a module, not a uvm_component.<br> // null + absolute path = exact scope string stored verbatim.<br> //<br> // Why “uvm_test_top.*”?<br> // * wildcard matches any component anywhere under the test root.<br> // driver path: “uvm_test_top.env.axi_agt.drv” → MATCH<br> // monitor path: “uvm_test_top.env.axi_agt.mon” → MATCH<em><br> initial begin</em></blockquote><blockquote>// ── Push AXI virtual interface ──────────────────────────<br> // scope: “uvm_test_top.env.axi_agt.*”<br> // Only the AXI agent’s driver and monitor will find this.<br> // The APB agent will NOT find it (different path prefix).<em><br> uvm_config_db #(virtual axi4_if)::set(<br> null,<br> “uvm_test_top.env.axi_agt.*”, </em>// instance-specific: AXI agent only<em><br> “vif”,<br> dut_axi_if<br> );</em></blockquote><blockquote>// ── Push APB virtual interface ──────────────────────────<br><em> uvm_config_db #(virtual apb_if)::set(<br> null,<br> “uvm_test_top.env.apb_agt.*”, // instance-specific: APB agent only<br> “vif”,<br> dut_apb_if<br> );</em></blockquote><blockquote>// ── Optional: push any global config flags ──────────────<br><em> uvm_config_db #(int)::set(<br> null,<br> “uvm_test_top.*”,<br> “verbosity”,<br> UVM_MEDIUM<br> );</em></blockquote><blockquote>/<em>/ ── Launch the UVM kernel ───────────────────────────────<br> // Test name comes from: +UVM_TESTNAME=axi4_smoke_test<br> // If not provided, the optional argument below is the fallback.<br> // Best practice: always pass empty string — force use of plusarg.<br> run_test(); </em>// NEVER RETURNS — $finish called by UVM at end</blockquote><blockquote><em>end</em></blockquote><blockquote><em>endmodule</em></blockquote><h3>The complete mental model — tb_top in 7 laws</h3><p><strong>Law 1 — tb_top is the ONLY module.</strong> Every other testbench file is a SystemVerilog class inside a package. The module boundary exists solely because interfaces and DUT connections require it.</p><p><strong>Law 2 — tb_top never instantiates UVM classes directly.</strong> You never write axi4_env env = new() inside tb_top. The factory, triggered by run_test(), creates everything. tb_top just provides the resources (interfaces) that those objects will use.</p><p><strong>Law 3 — Interfaces live in tb_top, virtual interfaces live in classes.</strong> The real axi4_if dut_if(...) instance lives in tb_top. The virtual axi4_if vif handle inside driver and monitor is just a pointer to it, passed through config_db.</p><p><strong>Law 4 — All </strong><strong>config_db::set() calls happen before </strong><strong>run_test().</strong> This is the only ordering guarantee you have. run_test() starts build_phase which calls get(). Set before run, or the get finds nothing.</p><p><strong>Law 5 — Use </strong><strong>null as context in all tb_top set() calls.</strong> You are in a module, not a component. Null means the inst_path is used verbatim as an absolute scope. Using this in a module is illegal.</p><p><strong>Law 6 — In multi-agent testbenches, use instance-specific paths.</strong> &quot;uvm_test_top.env.axi_agt.*&quot; and &quot;uvm_test_top.env.apb_agt.*&quot; ensure each agent gets only its own VIF. A wildcard &quot;uvm_test_top.*&quot; for two different interface types would cause the wrong agent to find the wrong interface.</p><p><strong>Law 7 — </strong><strong>run_test() never returns.</strong> It drives the entire simulation lifecycle from build through report, then calls $finish. Any code written after run_test() in the initial block is unreachable.</p><p>That’s all about tb_top in UVM.<br>Please do share your comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8c26e29f7c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UVM Phases — Complete Reference Guide:]]></title>
            <link>https://medium.com/@a.soniarav/uvm-phases-complete-reference-guide-ae454a8c3264?source=rss-7bbfa74316de------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae454a8c3264</guid>
            <category><![CDATA[vlsi-design]]></category>
            <category><![CDATA[vlsi]]></category>
            <category><![CDATA[vlsi-verification]]></category>
            <category><![CDATA[system-verilog]]></category>
            <category><![CDATA[uvm-training]]></category>
            <dc:creator><![CDATA[Arvind Soni]]></dc:creator>
            <pubDate>Wed, 08 Apr 2026 05:21:57 GMT</pubDate>
            <atom:updated>2026-05-19T07:25:39.241Z</atom:updated>
            <content:encoded><![CDATA[<p>Every concept, every phase, the full simulation timeline</p><h3>1. What Is a UVM Phase?</h3><p>A UVM phase is a <strong>named time slot</strong> in the simulation lifecycle. The UVM phase engine walks the entire component tree in a defined order and calls the corresponding method on every component. No component can skip ahead — everyone must finish the current phase before the next one begins.</p><p>Phases exist because without them you could never safely assume: “is my config set yet?”, “are all ports connected?”, “has the DUT come out of reset?”. Phases eliminate all of that uncertainty with iron-clad sequencing guarantees.</p><h3><strong>Function phase: Zero simulation time</strong></h3><p>Executes and returns immediately. Cannot use @, wait, or #delay. Cannot call tasks.</p><p><em>build, connect, end_of_elaboration, start_of_simulation, extract, check, report, final</em></p><h3><strong>Task phase: Consumes simulation time</strong></h3><p>Blocks — simulation time passes. Can use @posedge clk, wait(signal), #delay. Must manage the objection mechanism.</p><p><em>run_phase and all runtime sub-phases</em></p><h3>2. All 12 Phases — Complete Reference</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bT_nlx0KHa1A70AFhGwtfA.png" /></figure><h3>3. Execution Direction — The Rule That Surprises Everyone</h3><p><strong>Only build_phase is top-down.</strong> Every other phase (except final_phase) runs bottom-up. This surprises engineers coming from RTL or scripted testbenches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNKU-JhtaXEnmLNNKEOV4g.png" /></figure><h3>4. The Objection Mechanism — How run_phase Ends</h3><p>The objection mechanism is <strong>the only way to control simulation duration</strong> in UVM. The run_phase ends when every outstanding objection has been dropped. If no component ever raises an objection, the simulation ends instantly at time 0 after run_phase starts.</p><p><strong>Mental model:</strong> Think of objections like a reference count. Simulation runs while count &gt; 0. When count reaches 0, UVM starts a drain timer, then ends the phase.</p><pre>virtual task run_phase(uvm_phase phase);<br>  // ── STEP 1: raise objection BEFORE doing any time-consuming work<br>  // Without this, sim may end before your sequence even starts<br>  phase.raise_objection(this, &quot;smoke test running&quot;);</pre><pre>  // ── STEP 2: do your work (sequences, waits, protocol activity)<br>  my_seq seq = my_seq::type_id::create(&quot;seq&quot;);<br>  seq.start(env.agt.sqr);</pre><pre>  // ── STEP 3: drop objection when work is COMPLETE<br>  // This allows simulation to end if no other component has an objection<br>  phase.drop_objection(this, &quot;smoke test done&quot;);<br>endtask</pre><h3>Objection rules that prevent common bugs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACprRezgjG28oG9T5kw41w.png" /></figure><h3>set_drain_time — giving the DUT a chance to flush</h3><pre>// After last objection drops, wait 100ns before ending phase<br>// Allows DUT to complete any in-flight operations<br>phase.phase_done.set_drain_time(this, 100ns);</pre><h3>5. Simulation Time vs Phase Execution — The Complete Timeline</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qAuIPOekioZF3-iYtqjgw.png" /></figure><h3>6. Runtime Sub-Phases (UVM 1.2 Advanced)</h3><p>UVM 1.2 introduced 12 runtime sub-phases that run <em>inside</em> run_phase. They partition the simulation into structured stages. Each sub-phase has its own objection mechanism. You can use just run_phase, just sub-phases, or both simultaneously.</p><p><strong>Critical rule:</strong> run_phase and its sub-phases run CONCURRENTLY. A component that raises an objection in run_phase keeps the entire run group alive even after all sub-phase objections are dropped. Use one or the other consistently per component — mixing them in the same component causes complex ordering issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*LP6P4PdNORDKq38LnN-Iuw.png" /></figure><h3>7. Phase Jumping (Advanced)</h3><p>UVM provides a mechanism to skip forward or backward to another phase. This is an advanced feature used for error recovery and rapid re-test scenarios.</p><pre>// Inside a component&#39;s run_phase — jump to configure_phase<br>// (skips main_phase and shutdown_phase)<br>phase.jump(uvm_configure_phase::get());</pre><pre>// Common use: re-configure DUT after detecting a fatal error<br>// without restarting the entire simulation</pre><pre>// Jump to reset_phase from main_phase (restart the test cycle)<br>phase.jump(uvm_reset_phase::get());</pre><pre>// Jump to end of simulation<br>phase.jump(uvm_run_phase::get());  // effectively end run</pre><p><strong>Phase jumping rules:</strong> You can only jump to phases within the same schedule (the runtime sub-phase schedule). Jumping from run_phase to build_phase is illegal. Phase jumping affects ALL components simultaneously — it is not per-component. Use sparingly; it makes testbench flow hard to reason about.</p><h3>8. Phase Callbacks (Advanced)</h3><p>UVM provides callbacks at the start and end of each phase. These allow you to hook into phase transitions without overriding the phase method itself.</p><pre>// Fires at the START of a phase (before the phase body)<br>virtual function void phase_started(uvm_phase phase);<br>  if (phase.is(uvm_run_phase::get()))<br>    `uvm_info(get_type_name(), &quot;Run phase starting!&quot;, UVM_LOW);<br>endfunction</pre><pre>// Fires at the END of a phase (after the phase body)<br>virtual function void phase_ended(uvm_phase phase);<br>  if (phase.is(uvm_run_phase::get()))<br>    `uvm_info(get_type_name(), &quot;Run phase ended!&quot;, UVM_LOW);<br>endfunction</pre><pre>// Fires when run_phase is about to end (last objection dropped)<br>// Return 0 to extend the phase, 1 to allow it to end<br>virtual function bit phase_ready_to_end(uvm_phase phase);<br>  if (phase.is(uvm_run_phase::get())) begin<br>    if (scoreboard.pending_count &gt; 0) begin<br>      phase.raise_objection(this);   // not ready — re-raise<br>      return 0;<br>    end<br>  end<br>  return 1;<br>endfunction</pre><h3>9. Custom Phases (Advanced)</h3><p>You can define your own phases and insert them into UVM’s standard schedule. Custom phases are used when your DUT protocol has a specific handshaking stage that doesn’t map to any standard UVM phase.</p><pre>// Step 1: Define the custom phase class<br>class axi4_handshake_phase extends uvm_task_phase;<br>  `uvm_type_utils(axi4_handshake_phase)</pre><pre>  static function axi4_handshake_phase get();<br>    if (m_inst == null) m_inst = new;<br>    return m_inst;<br>  endfunction</pre><pre>  function new(string name = &quot;axi4_handshake&quot;);<br>    super.new(name);<br>  endfunction</pre><pre>  virtual task exec_task(uvm_component comp, uvm_phase phase);<br>    axi4_base_component c;<br>    if ($cast(c, comp))<br>      c.axi4_handshake_phase(phase);  // call phase method on component<br>  endtask</pre><pre>  local static axi4_handshake_phase m_inst;<br>endclass</pre><pre>// Step 2: Insert into schedule (in tb_top or test)<br>initial begin<br>  uvm_domain::get_uvm_domain().add(<br>    axi4_handshake_phase::get(),<br>    .after_phase(uvm_reset_phase::get())  // insert after reset<br>  );<br>  run_test();<br>end</pre><h3>10. Complete Phase Code — Every Phase Implemented</h3><pre>class axi4_scoreboard extends uvm_scoreboard;<br>  `uvm_component_utils(axi4_scoreboard)<br>  axi4_seq_item pending_q[$];</pre><pre>  // ── build_phase: create sub-components, get config ──────────<br>  virtual function void build_phase(uvm_phase phase);<br>    super.build_phase(phase);   // ALWAYS call super first<br>    // create TLM exports, get cfg from config_db<br>    if (!uvm_config_db#(int)::get(this,&quot;&quot;,&quot;en_checks&quot;,en_checks))<br>      en_checks = 1;  // default: checks on<br>  endfunction</pre><pre>  // ── connect_phase: wire ports (SB receives via analysis_export)<br>  virtual function void connect_phase(uvm_phase phase);<br>    // usually nothing — monitor connects TO us<br>  endfunction</pre><pre>  // ── end_of_elaboration: verify wiring is complete ────────────<br>  virtual function void end_of_elaboration_phase(uvm_phase phase);<br>    if (analysis_export.size_connections() == 0)<br>      `uvm_warning(get_type_name(), &quot;No monitor connected to scoreboard!&quot;);<br>  endfunction</pre><pre>  // ── run_phase: scoreboard does NOT control simulation duration<br>  // It passively receives transactions via write() — NO objection<br>  virtual task run_phase(uvm_phase phase);<br>    // scoreboard is passive in run_phase<br>    // write() callback receives observed transactions<br>  endtask</pre><pre>  // ── extract_phase: read metrics from the scoreboard ──────────<br>  virtual function void extract_phase(uvm_phase phase);<br>    pass_count = m_pass;<br>    fail_count = m_fail;<br>    pending_at_end = pending_q.size();<br>  endfunction</pre><pre>  // ── check_phase: verify final correctness ───────────────────<br>  virtual function void check_phase(uvm_phase phase);<br>    if (pending_q.size() &gt; 0)<br>      `uvm_error(get_type_name(),<br>        $sformatf(&quot;%0d transactions never received B channel response!&quot;,<br>                  pending_q.size()));<br>    if (fail_count &gt; 0)<br>      `uvm_error(get_type_name(),<br>        $sformatf(&quot;%0d scoreboard mismatches detected&quot;, fail_count));<br>  endfunction</pre><pre>  // ── report_phase: print summary ──────────────────────────────<br>  virtual function void report_phase(uvm_phase phase);<br>    `uvm_info(get_type_name(), $sformatf(<br>      &quot;\n=== SCOREBOARD SUMMARY ===\n  PASS: %0d\n  FAIL: %0d\n  PENDING: %0d\n===========================&quot;,<br>      pass_count, fail_count, pending_at_end), UVM_NONE);<br>  endfunction</pre><pre>endclass<br></pre><pre>class axi4_driver extends uvm_driver#(axi4_seq_item);<br>  `uvm_component_utils(axi4_driver)<br>  virtual axi4_if vif;</pre><pre>  virtual function void build_phase(uvm_phase phase);<br>    super.build_phase(phase);<br>    if (!uvm_config_db#(virtual axi4_if)::get(this,&quot;&quot;,&quot;vif&quot;,vif))<br>      `uvm_fatal(&quot;NO_VIF&quot;,&quot;vif not found&quot;);<br>  endfunction</pre><pre>  // run_phase: driver MUST raise objection — it drives the DUT<br>  virtual task run_phase(uvm_phase phase);<br>    // Driver does NOT raise objection — test does<br>    // Driver is always-on: it runs as long as the test keeps going<br>    vif.driver_cb.awvalid &lt;= 0;     // idle all outputs<br>    @(posedge vif.aresetn);          // wait for reset release<br>    forever begin<br>      seq_item_port.get_next_item(req);<br>      drive_txn(req);<br>      seq_item_port.item_done();<br>    end<br>  endtask</pre><pre>endclass<br></pre><pre>class axi4_base_test extends uvm_test;<br>  `uvm_component_utils(axi4_base_test)<br>  axi4_env env;</pre><pre>  virtual function void build_phase(uvm_phase phase);<br>    super.build_phase(phase);<br>    env = axi4_env::type_id::create(&quot;env&quot;, this);<br>  endfunction</pre><pre>  virtual function void end_of_elaboration_phase(uvm_phase phase);<br>    uvm_top.print_topology();   // confirm hierarchy<br>    factory.print();             // confirm overrides<br>  endfunction</pre><pre>  // Test raises objection — test controls simulation duration<br>  virtual task run_phase(uvm_phase phase);<br>    axi4_smoke_seq seq;<br>    phase.raise_objection(this, &quot;smoke test running&quot;);</pre><pre>    phase.phase_done.set_drain_time(this, 100ns); // drain after drop</pre><pre>    seq = axi4_smoke_seq::type_id::create(&quot;seq&quot;);<br>    seq.start(env.agt.sqr);</pre><pre>    phase.drop_objection(this, &quot;smoke test done&quot;);<br>  endtask</pre><pre>endclass</pre><h3>11. The 10 Phase Laws Every Engineer Must Know</h3><ol><li>build_phase is the ONLY top-down phase. All others are bottom-up. This rule never changes.</li><li>Always call super.build_phase(phase) first — it applies config_db and factory settings.</li><li>Never create components outside build_phase. The hierarchy is locked after build.</li><li>Never connect TLM ports in build_phase — ports don’t exist until after build_phase returns.</li><li>run_phase is a task. All other phases are functions. If you need time — use run_phase.</li><li>ALWAYS raise objection before doing any time-consuming work in run_phase.</li><li>ALWAYS drop objection when work is complete — forgetting causes simulation to hang forever.</li><li>Monitor and scoreboard never raise objections in run_phase — only the test or sequences do.</li><li>run_phase and sub-phases run concurrently — never mix them in the same component.</li><li>Use check_phase for final correctness checks — not in run_phase where ordering is uncertain.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae454a8c3264" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>