• 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. Debugging constraints with tcl interactive debug mode

Stats

  • Locked Locked
  • Replies 7
  • Subscribers 68
  • Views 9215
  • 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

Debugging constraints with tcl interactive debug mode

chetan somana
chetan somana over 2 years ago

I'm trying to disable the constraint through tcl using "deposit -constraint_mode constraint_name [=] 0|1"

Here is the snippet from Systemverilog in Simulation pdf"

The -rand_mode and -constraint_mode options
■ Are available only when stopped inside a randomize() call.
■ Are available for class randomize calls; they are not supported for scope randomize calls.
■ Must appear first in the Tcl command line, and cannot be used with other deposit
options. "

From my understanding i'm trying to create a stop at line 26 where randomize() is being called. And i'm setting the scope to top.c1 to satisfy the two conditions. check the attachment for the code and document

xmsim: *W,DBGCMD: The constraint_mode could not be set for this reason: Not in a class randomize method call.

When the simulation is completed my goal is that r2 should be different from what is constrained. But i dont see the same behavior in the simulation

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago

    You've asked this in a forum related to questions and suggestions about the forum itself, so you wouldn't expect to get answers to technical questions. I'll move this to a more appropriate forum.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • chetan somana
    chetan somana over 2 years ago in reply to Andrew Beckett

    Thankyou Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • chetan somana
    chetan somana over 2 years ago

    I've found the solution but it has some limitations. 

    stop -create -randomize -always

    The above command will always create a breakpoint when randomize() is invoked. At this point the scope is " top.c1@1_1.randomize "

    Now we can disable the constraint using  'deposit -constraint_mode con2 = 0 ' ( I dont see any warnings now )

    The only issue is the constraint is disabled in the next randomized call. check in the attached snapshot below.

    Is there any workaround to disable the constraint at the specific instance?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 2 years ago in reply to chetan somana

    Your initial problem was because you hadn't stopped inside a randomize call. The Tcl command for adding constraints is design to help debug randomize calls, so the idea is that you either stop on a randomization failure breakpoint or by single-stepping the source code and stepping into a randomize call.

    The Tcl constraint works for adding a constraint in that particular call, so that you can spin round trying new constraints until the solver gives you an acceptable answer.

    The feature wasn't designed as a generic way to write additional constraints, if you want a more permanent constraint then you need to add it in the SV code itself.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • chetan somana
    chetan somana over 2 years ago in reply to StephenH

    It makes sense as we use debugger mostly when something is failing. And here are my takeaways from this experiment

    When the ranodmize() is failed, disabling the constraints will take effect on the next call. (run -rand_solve helps us to knows if solver is successful after changing the constraints/disabling)

    Constraint_mode() has higher priority over rand_mode() in xcelium tool. Assume we have conflicting constraints on a variable. and we deposit rand_mode is made 0 for that variable and when we do a randomize() call we get SVRNDF randomize method call failed. If we deposit constraint_mode() to 0 we should not see any errors.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 2 years ago in reply to chetan somana

    Nope, there is no "priority" between constraint_mode and rand_mode. In a SV randomize call, ALL the constraints have to be satisfied, even if all the variables have their rand_mode set to 0 (i.e. they are state variables). If you've turned off rand_mode for a variable, then its current value is used when testing the constraint, and if that value prevents the constraint fro being satisfied, then you'll get a randomisation failure error. This is not specific to Xcelium - all SV simulators should follow the exact same rules because this is clearly defined in the SV standard.

    Here's a trivial example:

    class c;

    bit a,b; // non-rand state variables

    constraint will_fail { a != b; }

    endclass

    If you randomize the above class, the constraint cannot be satisfied by the solver because a and b start with the value 0 and they are not rand variables thus the solver cannot change the values. However if you changed a to 1 then called randomize, the constraint would be satisfied and the call would succeed.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • chetan somana
    chetan somana over 2 years ago in reply to StephenH

    You're right. Thanks for the help.

    • 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