Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > ffa1e6f5ad04360808fe8840fe3ba036 > files > 436

vrq-devel-1.0.88-1.fc14.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>vrq: Xprop Rational</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
  <table border="0" cellspacing="0" cellpadding="0" width="100%">
   <tr>
    <td width="180"><a href="index.html"><img src="vrq.png" width="150" height="100" border="0" alt="vrq"></a></td>
    <td background="top_bg.png" align="right" width="100%">
      <img src="glyth.png" width="500" height="100" border="0" alt="">
    </td>
   </tr>
   <tr>
    <td background="#FFFFFF" align="right" width="50" height="4"></td>
   </tr>
  </table>
</head><body>
<!-- Generated by Doxygen 1.7.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<h1>Xprop Rational </h1>  </div>
</div>
<div class="contents">
<p>Xprop is a tool that instruments verilog code such that x's are propagated and not squashed.</p>
<p>This is desirable as it reduces the simulation differences between RTL and gate level simulations. This sometimes masks bugs in RTL simulations and thereby requires a much greater degree of gate level simulation be performed. It is the experience of many who have used this tool that most of the discovered bug at the gate level would have been caught at the RTL simulation level if an xprop tool had been applied prior to RTL simulation.</p>
<p>X's occur in simulation for a number of reasons:</p>
<ul>
<li>Use in RTL to indicated don't care degrees of freedom to synthesis.</li>
<li>Uninitialized flops.</li>
</ul>
<h2><a class="anchor" id="Terms"></a>
Terms</h2>
<ul>
<li><b>X-propagation</b> is the process of outputing an X from a block of logic when it's inputs are X.</li>
<li><b>X-pessimism</b> Is the condition when output of a block of logic is X in cases where it never could be based upon the inputs.</li>
<li><b>X-optimism or X-squashing</b> Is the condition when a block of logic outputs a non-X value when one or more of it's inputs are X. Note this naturally occurs in verilog due to the fact that X's are interpreted as 0's in conditional expressions.</li>
</ul>
<h2><a class="anchor" id="theory_of_operation"></a>
Theory of Operation</h2>
<p>Here is an example: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span>( select )
     <span class="comment">// this branch is taken when cond is 1</span>
     out = in1;
 <span class="keywordflow">else</span>
     <span class="comment">// this branch is taken when cond is either 0 or X</span>
     out = in2;
</pre></div><p>In this case an X on signal select does not result in out being X. Hence X's are squashed. Synthesis may result in code that looks like this: </p>
<div class="fragment"><pre class="fragment"> out = (in1 &amp; select) | (in2 &amp; select)
</pre></div><p>The simulation of these statements will not match in all cases. Another example where gate level simulation may not match RTL is for a 2-to-1 mux expressed as: </p>
<div class="fragment"><pre class="fragment"> out = select ? in1 : in2;
</pre></div><p>However synthesis may result in the following: </p>
<div class="fragment"><pre class="fragment"> out = (in1 &amp; select) | (in2 &amp; select)
</pre></div><p>When select is X the simulation of these statements will differ.</p>
<p>Similar issues arise with case statements and assignments to variables that use non-constant indices. The solution is to instrument the verilog code to add pessimism to such statements.</p>
<p>One way to model this is whenever an ambitious (relative to X) construct is used there are multiple possible outcomes. These multiple possible outcomes need to be modeled resolving the ambiguity create by the X. This can be done using a XResolution() function. It takes two inputs, one for each possible expression output. The resolution function combines the two possiblities and creates a pessimistic output. For instances the code: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span>( select )
     out = in1;
 <span class="keywordflow">else</span>
     out = in2;&lt;/pre&gt;
</pre></div><p> Can be abstractly represented as: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span>( ^select === 1<span class="stringliteral">&#39;bX )</span>
<span class="stringliteral">     out = XResolution( in1, in2 );</span>
<span class="stringliteral"> else if( select )</span>
<span class="stringliteral">     out = in1;</span>
<span class="stringliteral"> else</span>
<span class="stringliteral">     out = in2;</span>
</pre></div><p>Vrq uses a very simplistic XResolution function that results in less code bloat and overhead at the expense of increased pessimism. The XResolution function ignores the inputs and always returns X.</p>
<h2><a class="anchor" id="transformations"></a>
Transformations</h2>
<h3><a class="anchor" id="if_transformation"></a>
If Transformation</h3>
<p>The following code snippet: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span>( cond ) being
     r1 = r2;
 end
</pre></div><p> Is transformed into: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span>(cond) begin
     r1 = r2;
 end <span class="keywordflow">else</span> <span class="keywordflow">if</span>(~cond) ;
 <span class="keywordflow">else</span> begin
     r1 = 1<span class="stringliteral">&#39;hx;</span>
<span class="stringliteral"> end</span>
</pre></div><p>When an else clause is included, this code snippet: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span>( cond ) begin
     r1 = r2;
 end <span class="keywordflow">else</span> begin
    r1 = r3;
 end
</pre></div><p> is transformed into: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span>(cond) begin
     r1 = r2;
 end <span class="keywordflow">else</span> <span class="keywordflow">if</span>(~cond) begin
     r1 = r3;
 end <span class="keywordflow">else</span> begin
     r1 = 1<span class="stringliteral">&#39;hx;</span>
<span class="stringliteral"> end</span>
</pre></div><h2><a class="anchor" id="case_transformation"></a>
Case Constructs</h2>
<p>A case statement without a default clause, like this: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">case</span>( cond )
 0: out = in0;
 1: out = in1;
 2: out = in2;
 endcase
</pre></div><p>Is transformed into this: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">case</span>(cond)
 0: begin
     out = in0;
    end
 1: begin
     out = in1;
    end
 2: begin
     out = in2;
    end
 <span class="keywordflow">default</span>: begin
    <span class="keywordflow">case</span>(^cond)
        1<span class="stringliteral">&#39;b0,</span>
<span class="stringliteral">        1&#39;</span>b1: ;
           <span class="keywordflow">default</span>: begin
              out = 1<span class="stringliteral">&#39;hx;</span>
<span class="stringliteral">           end</span>
<span class="stringliteral">     endcase</span>
<span class="stringliteral">   end</span>
<span class="stringliteral"> endcase</span>
</pre></div><p>A case statement with a default clause is transformed from: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">case</span>( cond )
 0: out = in0;
 1: out = in1;
 2: out = in2;
 <span class="keywordflow">default</span>: out = in3;
 endcase
</pre></div><p> to this: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">case</span>(cond)
 0: begin
     out = in0;
 end
 1: begin
     out = in1;
 end
 2: begin
     out = in2;
 end
 <span class="keywordflow">default</span>: begin
     <span class="keywordflow">case</span>(^cond)
         1<span class="stringliteral">&#39;b0,</span>
<span class="stringliteral">         1&#39;</span>b1: begin
     out = in3;
     end
     <span class="keywordflow">default</span>: begin
             out = 1<span class="stringliteral">&#39;hx;</span>
<span class="stringliteral">         end</span>
<span class="stringliteral">     endcase</span>
<span class="stringliteral"> end</span>
<span class="stringliteral"> endcase</span>
</pre></div><p>A case statement with a constant case expression is transformed from: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">case</span>( 1<span class="stringliteral">&#39;b1 )</span>
<span class="stringliteral"> cond1: out = in0;</span>
<span class="stringliteral"> cond2: out = in1;</span>
<span class="stringliteral"> cond3: out = in2;</span>
<span class="stringliteral"> default: out = in3;</span>
<span class="stringliteral"> endcase</span>
</pre></div><p> to this: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">case</span>(^{cond1,cond2,cond3})
 1<span class="stringliteral">&#39;b0,</span>
<span class="stringliteral"> 1&#39;</span>b1: begin
     <span class="keywordflow">case</span>(1<span class="stringliteral">&#39;b0)</span>
<span class="stringliteral">         cond1: begin</span>
<span class="stringliteral">             out = in0;</span>
<span class="stringliteral">         end</span>
<span class="stringliteral">         cond2: begin</span>
<span class="stringliteral">             out = in1;</span>
<span class="stringliteral">         end</span>
<span class="stringliteral">         cond3: begin</span>
<span class="stringliteral">             out = in2;</span>
<span class="stringliteral">         end</span>
<span class="stringliteral">         default: begin</span>
<span class="stringliteral">             out = in3;</span>
<span class="stringliteral">         end</span>
<span class="stringliteral">     endcase</span>
<span class="stringliteral"> end</span>
<span class="stringliteral"> default: begin</span>
<span class="stringliteral">     out = 1&#39;</span>hx;
 end
 endcase
</pre></div> <h2><a class="anchor" id="bit_select_transformation"></a>
Assignment with Bit Select</h2>
<p>An assignment with a bit select is transformed from: </p>
<div class="fragment"><pre class="fragment"> reg [3:0] out;
 ...
 out[i] = in;
</pre></div><p> to: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">case</span>(^i)
 1<span class="stringliteral">&#39;b0,</span>
<span class="stringliteral"> 1&#39;</span>b1: begin
      out[i] = in;
 end
 <span class="keywordflow">default</span>: begin
      out = 4<span class="stringliteral">&#39;hx;</span>
<span class="stringliteral"> end</span>
<span class="stringliteral"> endcase</span>
</pre></div><h2><a class="anchor" id="part_select_transformation"></a>
Assignment with Part Select</h2>
<p>An assignment with a part select is transformed from: </p>
<div class="fragment"><pre class="fragment"> reg [1:0] in;
 reg [3:0] out;
 ...
 out[i+:2] = in;
</pre></div><p> to: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordflow">case</span>(^i)
 1<span class="stringliteral">&#39;b0,</span>
<span class="stringliteral"> 1&#39;</span>b1: begin
     out[i+:2] = in;
 end
 <span class="keywordflow">default</span>: begin
     out = 4<span class="stringliteral">&#39;hx;</span>
<span class="stringliteral"> end</span>
<span class="stringliteral"> endcase</span>
</pre></div><h2><a class="anchor" id="array_with_index_transformation"></a>
Assignment to Array with Index</h2>
<p>The following code gets transformed: </p>
<div class="fragment"><pre class="fragment"> reg [3:0] in;
 reg [3:0] array[8:0][2:0];
 ...
 array[w][y] = in;
 array[w][1] = in;
 array[w][y][1:0] = in[1:0];
</pre></div><p> to: </p>
<div class="fragment"><pre class="fragment"> <span class="comment">// array[w][y] = in;</span>
 <span class="keywordflow">case</span>(^{w,y})
 1<span class="stringliteral">&#39;b0,</span>
<span class="stringliteral"> 1&#39;</span>b1: begin
     array[w][y] = in;
 end
 <span class="keywordflow">default</span>: begin : ___block0002
     integer ___index0000;
     integer ___index0001;
     <span class="keywordflow">for</span>(___index0001 = 2&amp;gt;=0 ? 0 : 2;___index0001&amp;lt;=(2&amp;gt;=0 ? 2 : 0);___index0001 = ___index0001+1) begin
         <span class="keywordflow">for</span>(___index0000 = 8&amp;gt;=0 ? 0 : 8;___index0000&amp;lt;=(8&amp;gt;=0 ? 8 : 0);___index0000 = ___index0000+1) begin
              array[___index0000][___index0001] = 4<span class="stringliteral">&#39;hx;</span>
<span class="stringliteral">         end</span>
<span class="stringliteral">     end</span>
<span class="stringliteral"> end</span>
<span class="stringliteral"> endcase</span>
<span class="stringliteral"></span>
<span class="stringliteral"> // array[w][1] = in;</span>
<span class="stringliteral"> case(^w)</span>
<span class="stringliteral"> 1&#39;</span>b0,
 1<span class="stringliteral">&#39;b1: begin</span>
<span class="stringliteral">      array[w][1] = in;</span>
<span class="stringliteral"> end</span>
<span class="stringliteral"> default: begin : ___block0004</span>
<span class="stringliteral">     integer ___index0003;</span>
<span class="stringliteral">     for(___index0003 = 8&amp;gt;=0 ? 0 : 8;___index0003&amp;lt;=(8&amp;gt;=0 ? 8 : 0);___index0003 = ___index0003+1) begin</span>
<span class="stringliteral">          array[___index0003][1] = 4&#39;</span>hx;
     end
 end
 endcase

 <span class="comment">// array[w][y][1:0] = in[1:0];</span>
 <span class="keywordflow">case</span>(^{w,y})
 1<span class="stringliteral">&#39;b0,</span>
<span class="stringliteral"> 1&#39;</span>b1: begin
      array[w][y][1:0] = in[1:0];
 end
 <span class="keywordflow">default</span>: begin : ___block0007
     integer ___index0005;
     integer ___index0006;
     <span class="keywordflow">for</span>(___index0006 = 2&amp;gt;=0 ? 0 : 2;___index0006&amp;lt;=(2&amp;gt;=0 ? 2 : 0);___index0006 = ___index0006+1) begin
          <span class="keywordflow">for</span>(___index0005 = 8&amp;gt;=0 ? 0 : 8;___index0005&amp;lt;=(8&amp;gt;=0 ? 8 : 0);___index0005 = ___index0005+1) begin
              array[___index0005][___index0006][1:0] = 2<span class="stringliteral">&#39;hx;</span>
<span class="stringliteral">          end</span>
<span class="stringliteral">      end</span>
<span class="stringliteral">  end</span>
<span class="stringliteral">  endcase</span>
</pre></div><h2><a class="anchor" id="hook_transformation"></a>
? Operator</h2>
<p>This code is transformed: </p>
<div class="fragment"><pre class="fragment"> `
 out = cond ? in1 : in2;
</pre></div><p> to: </p>
<div class="fragment"><pre class="fragment"> out = cond ? in1 : ~cond ? in2 : 1<span class="stringliteral">&#39;hx;</span>
</pre></div><h2><a class="anchor" id="clock_enable_t"></a>
Clock Enables</h2>
<p>This code is transformed: </p>
<div class="fragment"><pre class="fragment"> always @(posedge clk)
     r &lt;= r_P;
</pre></div><p> to: </p>
<div class="fragment"><pre class="fragment"> `ifdef XPROP_BOTH_EDGES
 always @(clk)
 `<span class="keywordflow">else</span>
 always @(posedge clk)
 `endif
 <span class="keywordflow">if</span>( clk ) begin
     r &lt;= r_P;
 end <span class="keywordflow">else</span> <span class="keywordflow">if</span>( ~clk ) ; 
 <span class="keywordflow">else</span> begin
     r &lt;= 1<span class="stringliteral">&#39;bx;</span>
<span class="stringliteral"> end</span>
</pre></div> </div>
<hr class="footer"/><address class="footer"><small>Generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>