User guide
24-121
SystemVerilog Testbench Constructs
A randsequence block is made up of one or more productions,
yielding a “production list.”
Productions are made up of terminals and non-terminals, as seen in
the above syntax description. A terminal is an indivisible code
element. It needs no further definition beyond the code block
associated with it. A non-terminal is an intermediate variable defined
in terms of other terminals and non-terminals. If a production item is
defined using non-terminals, those non-terminals must then be
defined in terms of other non-terminals and terminals using the
production definition construct. Ultimately, every non-terminal has to
be broken down into its base terminal elements.
Multiple production items specified in a production list can be
separated by white space or by the or operator (|). Production items
separated by white space indicate that the items are streamed
together in sequence. Production items separated by the | operator
force a random choice, which is made every time the production is
called.
The following is an example of a program including a randsequence
block.
program p;
initial begin
randsequence()
main : repeat (10) TOP;
TOP: RJ {$display("");};
RJ: rand join (1.0) S1 S2 S3;
S1 : A B;
S2 : C D;
S3 : E F G;
A : {$write ("A");};
B : {$write ("B");};
C : {$write ("C");};
D : {$write ("D");};
E : {$write ("E");};