[sv-ec] Review Items for Chapter 12


Subject: [sv-ec] Review Items for Chapter 12
From: Arturo Salz (Arturo.Salz@synopsys.com)
Date: Mon Feb 16 2004 - 02:35:20 PST


My review of Chapter 12 is below.

    Arturo

--------------------------------------------------------------------------------

Section 12.1 (second paragraph)

The scope randomize generalized the class-randomize.

Change From:
The random constraints are built on top of an object oriented data abstraction.that models the data to be randomized as objects that contain random variables and user-defined constraints. The constraints determine the legal values that can be assigned to the random variables. Objects are ideal for representing complex aggregate data types and protocols such as Ethernet packets.
To:
The random constraints are typically specified on top of an object oriented data abstraction that models the data to be randomized as objects that contain random variables and user-defined constraints. The constraints determine the legal values that can be assigned to the random variables. Objects are ideal for representing complex aggregate data types and protocols such as Ethernet packets.

--------------------------------------------------------------------------------

Section 12.2 (second example on page 129)

The keyword "with" should be bold:

    task exercise_bus (MyBus bus);
        int res;

        // EXAMPLE 1: restrict to small addresses
        res = bus.randomize() with {atype == small;};

        // EXAMPLE 2: restrict to address between 10 and 20
        res = bus.randomize() with {10 <= addr && addr <= 20;};

        // EXAMPLE 3: restrict data values to powers-of-two
        res = bus.randomize() with {data & (data - 1) == 0;};
    endtask

--------------------------------------------------------------------------------

Section 12.2 (last bullet item on page 129)

Change From:
Constraints support only 2-state values. X and Z values and 4-state operators (e.g., ===, !== ) are illegal and shall result in an error.
To:
Constraints support only 2-state values. 4-state values (X or Z) or 4-state operators (e.g., ===, !== ) are illegal and shall result in an error.

--------------------------------------------------------------------------------

Section 12.2 (last example on page 130)

The keyword "super" should be in bold:

        super.pre_randomize();

--------------------------------------------------------------------------------

Section 12.4.2 (last bullet item)

Change From:
- The randomize() task is virtual. Accordingly, it treats the class constraints in a virtual manner. When a named constraint is overloaded, the previous definition is overridden.
To:
- The randomize() task is virtual. Accordingly, it treats the class constraints in a virtual manner. When a named constraint is redefined in an extended class, the previous definition is overridden.

--------------------------------------------------------------------------------

Section 12.4.3 (first and third paragraphs)

Change From:
Constraints support integer value sets and set membership operators (as defined in Section 7.20).

Absent any other constraints, all values (either single values or value ranges), have an equal probability of being chosen by the inside operator.

The negated form denotes that expression lies outside the set: !(expression inside { set }).
To:
Constraints support integer value sets and the set membership operator (as defined in Section 7.20).

Absent any other constraints, all values (either single values or value ranges), have an equal probability of being chosen by the inside operator.

The negated form of the inside operator denotes that expression lies outside the set: !(expression inside { set }).

--------------------------------------------------------------------------------

Section 12.4.4 (last paragraph of page 135)

Change From:
In general, distributions guarantee two properties: set membership and monotonic weighting, which means that increasing a weight shall increase the likelihood of choosing those values.
To:
In general, distributions guarantee two properties: set membership and monotonic weighting, which means that increasing a weight increases the likelihood of choosing those values.

--------------------------------------------------------------------------------

Section 12.4.5 (second paragraph after syntax box 12-4)

Change From:
The boolean equivalent of the implication operator a -> b is (!a || b). This states that if the expression is true, then random numbers generated are constrained by the constraint (or constraint block). Otherwise the random numbers generated are unconstrained.
To:
The boolean equivalent of the implication operator a -> b is (!a || b). This states that if the expression is true, then random numbers generated are constrained by the constraint (or constraint set). Otherwise the random numbers generated are unconstrained.

--------------------------------------------------------------------------------

Section 12.4.6 (second paragraph in page 137)

Change From:
constraint_set represents any valid constraint or an unnamed constraint block. If the expression is true, all of the constraints in the first constraint or constraint block must be satisfied, otherwise all of the constraints in the optional else constraint or constraint-block must be satisfied. Constraint blocks can be used to group multiple constraints.
To:
constraint_set represents any valid constraint or an unnamed constraint block. If the expression is true, all of the constraints in the first constraint or constraint set must be satisfied, otherwise all of the constraints in the optional else constraint or constraint-block must be satisfied. Constraint sets can be used to group multiple constraints.

--------------------------------------------------------------------------------

Section 12.4.8 (first sentence of second paragraph in page 139)

Change From (variable name x is wrong):
This example uses global constraints to define the legal values of an ordered binary tree. Class A represents a leaf node with an 8-bit value x. ...
To:
This example uses global constraints to define the legal values of an ordered binary tree. Class A represents a leaf node with an 8-bit value v. ...

--------------------------------------------------------------------------------

Section 12.4.9 (In syntax box 12-7)
 
Change From (Incomplete production):
constraint_block ::= // from Annex A.1.9
      solve identifier_list before identifier_list ;
To:
constraint_block ::= // from Annex A.1.9
      solve identifier_list before identifier_list ;
    | constraint_expression

--------------------------------------------------------------------------------

Section 12.4.10 (top of page 141)

Replace the following pseudo-BNF:
    static constraint constraint_identifier { contraint_expressions }
With the following syntax box:
    constraint_declaration ::= // from Annex A.1.9
            [ static ] constraint constraint_identifier { { constraint_block } }

    <Caption: Static constraint syntax (excerpt from Annex A)>

--------------------------------------------------------------------------------

Section 12.4.12 (two bullet items towards the end of page 142)

Change From (encoding is wrong):
- 0 TRUE Sub-expression evaluates to TRUE
- 1 FALSE Sub-expression evaluates to FALSE
To:
- 0 FALSE Sub-expression evaluates to FALSE
- 1 TRUE Sub-expression evaluates to TRUE

--------------------------------------------------------------------------------

Section 12.4.12 (third major bullet on page 143)

Change From:
- Negation ( ! ): If the sub-expression evaluates ERROR, then the guard evaluates to ERROR. Otherwise, if the sub-expression evaluates to TRUE or FALSE then the guard evaluates to FALSE or TRUE, respectively.
To:
- Negation ( ! ): If the sub-expression evaluates to ERROR, then the guard evaluates to ERROR. Otherwise, if the sub-expression evaluates to TRUE or FALSE then the guard evaluates to FALSE or TRUE, respectively.

--------------------------------------------------------------------------------

Section 12.4.12 (last bullet of page 143)

Change From:
- If the final result of the evaluation is RANDOM then a guarded constraint is generated.
To:
- If the final result of the evaluation is RANDOM then a conditional constraint is generated.

--------------------------------------------------------------------------------

Section 12.5.1

Remove paragraph containing extraneous word "Conjuction".

Change From:
    Conjunction <== Remove this

    virtual function int randomize();
To:
    virtual function int randomize();

--------------------------------------------------------------------------------

Section 12.5.3 (fourth and fifth bullets in page 146)

Change From:
- The randomize() method shall not be overridden.

- The randomize() method implements object random stability. An object can be seeded by the $srandom() system call (see Section 12.12.3), specifying the object in the second argument.
To:
- The randomize() method is built-in and cannot be overridden.

- The randomize() method implements object random stability. An object can be seeded by calling its srandom() method (see Section 12.12.3).

--------------------------------------------------------------------------------

Section 12.6 (Syntax Box 12-8 and Annex A.6.2)

Add
  -- optinal argument (variable_identifier_list | null)
 -- curly braces around constraint_block
 -- square brackets around "with" construct

Change Production From:
        | class_variable_identifier . randomize [ ( ) ] with constraint_block
To:
        | class_variable_identifier . randomize [ ( [ variable_identifier_list | null ] ) ] [ with { constraint_block } ]

--------------------------------------------------------------------------------

Section 12.8 (first paragraph following example on page 150)

Change From:
In this example, the toggle_rand function first checks the current active state of the constraint filter1 in the specified Packet object p. If the constraint is active, then the function shall deactivate it; if it is inactive, the function shall activate it. Finally, the function calls the randomize method to generate a new random value for variable source_value.
To:
In this example, the toggle_rand function first checks the current active state of the constraint filter1 in the specified Packet object p. If the constraint is active, the function deactivates it; if it is inactive, the function activates it. Finally, the function calls the randomize method to generate a new random value for variable source_value.

--------------------------------------------------------------------------------

Section 12.10 (Last four lines of the example)

Incorrect punctuation in comments.

Change From:
    a.randomize(); // random variables: x, ystate variables: v, w
    a.randomize( x ); // random variables: xstate variables: y, v, w
    a.randomize( v, w ); // random variables: v, wstate variables: x, y
    a.randomize( w, x ); // random variables: w, xstate variables: y, v
 To:
    a.randomize(); // random variables: x, y. state variables: v, w
    a.randomize( x ); // random variables: x. state variables: y, v, w
    a.randomize( v, w ); // random variables: v, w. state variables: x, y
    a.randomize( w, x ); // random variables: w, x. state variables: y, v

--------------------------------------------------------------------------------

Section 12.11.1

Replace "::randomize" with "std::randomize", as shown:

12.11.1 Adding constraints to scope variables - std::randomize() with

The std::randomize() with form of the scope randomize method allows users to specify random constraints to be applied to the local scope variables. When specifying constraints, the arguments to the scope randomize method become random variables, all other variables are considered state variables.

        task stimulus( int length );
            int a, b, c, success;

            success = std::randomize( a, b, c ) with { a < b ; a + b < length };
            ...
            success = std::randomize( a, b ) with { b - a > length };
            ...
        endtask

The task stimulus above calls std::randomize twice resulting in two sets of random values for its local variables a, b, and c. In the first call variables a and b are constrained such that variable a is less than b, and their sum is less than the task argument length, which is designated as a state variable. In the second call, variables a and b are constrained such that their difference is greater than state variable length.

--------------------------------------------------------------------------------

 Section 12.13 (two bullets)

Incorrect mention of use of $srandom.

Change From:
- The system randomization calls, $urandom, $urandom_range(), and $srandom().

- The object randomization method, randomize().
To:
- The system randomization calls, $urandom() and $urandom_range().

- The object and process random seeding method, $srandom().

- The object randomization method, randomize().

--------------------------------------------------------------------------------

Section 12.13.2 (code example)

Incorrect use of $srandom.

Change From:
    integer x, y, z;
    fork //set a seed at the start of a thread
        begin $srandom(100); x = $urandom; end
                //set a seed during a thread
        begin y = $urandom; $srandom(200); end
                // draw 2 values from the thread RNG
        begin z = $urandom + $urandom ; end
    join
To:
    integer x, y, z;
    fork //set a seed at the start of a thread
       begin process::self.srandom(100); x = $urandom; end
                //set a seed during a thread
       begin y = $urandom; process::self.srandom(200); end
                // draw 2 values from the thread RNG
       begin z = $urandom + $urandom ; end
    join

--------------------------------------------------------------------------------

Section 12.13.3 (last bullet in the sub-section, page 156)

Incorrect use of $srandom.

Change From:
    - Objects can be seeded at any time using the $srandom() system task with an optional object argument.
    class Foo;
        function new (integer seed);
            //set a new seed for this instance
            $srandom(seed, this);
        endfunction
    endclass
To:
    - Objects can be seeded at any time using the srandom() method .
    class Foo;
        function new (integer seed);
            //set a new seed for this instance
            this.srandom(seed);
        endfunction
    endclass

--------------------------------------------------------------------------------

Section 12.13.3 (last bullet in the sub-section, page 156)

Incorrect use of $srandom.

Change From:
Sometimes it is desirable to manually seed an object's RNG using the $srandom() system call. This can be done either in a class method, or external to the class definition:

An example of seeding the RNG internally, as a class method is:

    class Packet;
        rand bit[15:0] header;
        ...
        function new (int seed);
            $srandom(seed, this);
            ...
        endfunction
    endclass

An example of seeding the RNG externally is:

    Packet p = new(200); // Create p with seed 200.
    $srandom(300, p); // Re-seed p with seed 300.

Calling $srandom() in an object's new() function, assures the object's RNG is set with the new seed before any class member values are randomized.
To:
Sometimes it is desirable to manually seed an object's RNG using the srandom() method. This can be done either in a class method, or external to the class definition.

An example of seeding the RNG internally, as a class method is:

    class Packet;
        rand bit[15:0] header;
        ...
        function new (int seed);
            this.srandom(seed);
            ...
        endfunction
    endclass

An example of seeding the RNG externally is:

    Packet p = new(200); // Create p with seed 200.
    p.srandom(300); // Re-seed p with seed 300.

Calling srandom() in an object's new() function, assures the object's RNG is set with the new seed before any class member values are randomized.

--------------------------------------------------------------------------------

Section 12.16

The syntax boxes in the following sections are missing a caption:

    Section 12.16.1
    Section 12.16.2
    Section 12.16.3
    Section 12.16.4
    Section 12.16.5
    Section 12.16.7

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------



This archive was generated by hypermail 2b28 : Mon Feb 16 2004 - 02:39:58 PST