Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As I cannot comment on the previous post, and my suggested edit is rejected I can only add what looks like a new answer but isn't. Sigh!</p> <p>Here is Subbdue's example edited to fix the following syntax errors:</p> <ol> <li>SV <code>typedef enum {...} &lt;name&gt;;</code> syntax as opposed to OpenVera <code>enum &lt;name&gt; {...};</code> syntax</li> <li>End enum declaration with <code>;</code></li> <li>Declare variable <code>channelNumber</code></li> <li>Declare <code>ipVersion</code> as <code>rand</code></li> <li>SV <code>&lt;var&gt; inside { [&lt;min&gt;:&lt;max&gt;] }</code> syntax as opposed to OpenVera <code>&lt;var&gt; in { min:max }</code> syntax</li> <li>End expressions in <code>constraint</code>s with <code>;</code></li> <li>SV <code>-&gt;</code> syntax as opposed to OpenVera <code>=&gt;</code> syntax</li> <li>Fix typo <code>solver</code> -> <code>solve</code></li> <li>Fix typo <code>IPVx</code> -> <code>IPVX</code></li> </ol> <p>Fixed example: </p> <pre><code>class RandomConstraints; typedef enum {IPV4=2, IPV6, IPVX} IpVersionType; //Randomly iterate over values without repetition randc bit [7:0] cyclicCounter; //Regular random variables rand bit [15:0] destAddress; rand bit [15:0] sourceAddress; rand bit [15:0] numberOfPackets; rand bit [15:0] packetLength; rand bit [3:0] channelNumber; rand bit [7:0] var1; rand bit [7:0] var2; rand IpVersionType ipVersion; //Non-random variables that can be used to control constraints bit [15:0] minNumberOfPackets, maxNumberOfPackets; bit [15:0] minPacketLength, maxPacketLength; integer IPV4Weight, IPV6Weight; constraint cPacketLength { packetLength inside { [ minPacketLength : maxPacketLength ] }; } constraint cChannelNumber { channelNumber inside {[0:1]}; } // Assuming total weight adds up to 100 constraint cIPVersionType { ipVersion dist { IPV4 := IPV4Weight, IPV6 := IPV6Weight, IPVX := (100 - IPV4Weight - IPV6Weight) }; } //Probability of var1 being 1,2,3,4,5 in the ratio 1,2,4,4,4 constraint cDist1 { var1 dist { 1 := 1, 2 := 2, [3:4] := 4 }; } //Probability of var2 being 1,2,3,4,5 is in the ratio 1,2,4/3,4/3,4/3 constraint cDist2 { var2 dist { 1 := 1, 2 := 2, [3:5] :/ 4 }; } //Implication constraint - if(channelNum == i) then { ... } constraint cImplication { (channelNumber == 0) -&gt; { destAddress inside {[0:200]}; sourceAddress inside {[201:400]}; } (channelNumber == 1) -&gt; { destAddress inside {[201:400]}; sourceAddress inside {[0:200]}; } } //Controlling order of constraints solved using a constraint solver constraint order_solver { solve channelNumber before destAddress; solve channelNumber before sourceAddress; } function new(); //Setting default min/max packets and min/max packet length minNumberOfPackets = 100; maxNumberOfPackets = 1000; minPacketLength = 128; maxPacketLength = 256; IPV4Weight = 50; IPV6Weight = 30; endfunction endclass </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload