• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. Using strings in constraints to randomize data

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 65
  • Views 16039
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using strings in constraints to randomize data

PSAM
PSAM over 7 years ago

Hi,

 I am using a constraint that uses a string var to randomize a random variable(data). But xcelium give me an error:

Constraint:

constraint data {
    sel_string inside {"A"} -> data[0] == 1;}

Error:

xmvlog: *E,WOUPYR (): As a temporary implementation restriction, string is not permitted in this context.
 |     sel_string inside {"A"} -> data[0] == 1,

Any suggestions, how to get around this?

Thanks,

Preethi

  • Cancel
  • muffi
    muffi over 7 years ago

    One way to work around this is to convert the string variable to a SystemVerilog enumeration. The following code snippet illustrates this.

    typedef enum {A, B} sel_string_e;

    class foo;
    rand sel_string_e sel_string;
    rand bit [2:0] data;
    constraint data_c {
        //sel_string == A -> data[0] == 1;}
        sel_string inside {A} -> data[0] == 1;}
    function void printme();
        $display("sel_string is : %s", sel_string.name);
        $display("data[0] is : %d",data[0]);
    endfunction
    endclass

    module test;
      initial begin
        foo foo_i = new();
        void'(foo_i.randomize());
        foo_i.printme();
      end
    endmodule

    The following article talks about this in more detail.

    https://support.cadence.com/apex/ArticleAttachmentPortal?id=a1Od0000000nTeVEAU&pageName=ArticleContent&sq=

    "Using strings in constraints results in ncsim: *E,RNCTYP: A 'string type' cannot be used within a constraint expression"

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • PSAM
    PSAM over 7 years ago in reply to muffi

    Hi,

    Thanks for this solution. The compilation error is gone.

    Thanks,

    Preethi

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information