• 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. behavior of disabling constraint_mode from subclass

Stats

  • Locked Locked
  • Replies 0
  • Subscribers 65
  • Views 12527
  • 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

behavior of disabling constraint_mode from subclass

xbluewings
xbluewings over 13 years ago
Hello experts,
we found some inconsistent behavior between qsim and ncsim when trying to enable/disable constraint_mode from subclass. Here is the code sample:


class cls;
    rand int a;
    rand int b;
    rand int c;

    constraint c_a {a == -1;}
    constraint c_b {b == -1;}
    constraint c_c {c == 1;}

    function new();
    endfunction

    virtual function void do_rand();
      $display("Before randomize ...");
      $display("  a = %0d", a);
      $display("  b = %0d", b);
      $display("  c = %0d", c);


      this.constraint_mode(0);   //how many constraint blocks are disable? cls::c_a, cls::c_b, cls::c_c,  cls_e::c_a, cls_e::c_b
      this.c_a.constraint_mode(1); // which is enabled?
      this.c_b.constraint_mode(1); // which is enabled?

      assert(this.randomize(a,b) with {1;});

      this.constraint_mode(1);
      $display("After randomize ...");
      $display("  a = %0d", a);
      $display("  b = %0d", b);
      $display("  c = %0d", c);
    endfunction
endclass

class cls_e extends cls;
    constraint c_a { a==8000; }
    constraint c_b { b==40; }

endclass

module test();
    cls_e cls_inst;
    initial begin
      cls_inst = new;
      cls_inst.do_rand();
    end
endmodule


In qsim, cls_e::c_a and cls_e::c_b are working; but not in ncsim...
Is the behavior of the above three "constraint_mode()" statements clearly defined in spec?

-Xiaofei
  • 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