• 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. What if inheritance occurs for a class with an embedded...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 64
  • Views 3545
  • 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

What if inheritance occurs for a class with an embedded covergroup?

Jeff000
Jeff000 over 8 years ago

As the code shown below, what is the relationship between those two covergroup named cg?


  class A;
     int a;
     
     covergroup cg @(clk);
        option.per_instance = 1;
        v_a: coverpoint a
          iff(reset){}
        
     endgroup // cg
     
  endclass // A

   class B extends A;
     int b;
      
     covergroup cg @(clk);
        option.per_instance = 1;
        v_b: coverpoint b
          iff(reset){}
        
     endgroup // cg

   endclass // B

  • Cancel
Parents
  • TAM1
    TAM1 over 8 years ago

    Of course, you are correct. SystemVerilog will call the default constructor for A even if it isn't explicitly invoked in B's new function. So you'll have to add some code to control the new'ing of A's covergroup yourself.

    Class A's new function:

    function new(bit make_cg=1);
       if ( make_cg )
       begin
        cg = new;
        cg.option.name = "A_group";
       end
    end endfunction

    Class B's new function:

    function new;
       super.new(0);
       cg = new;
       cg.option.name = "B_group";
    endfunction



    If you forget to call super.new in the B constructor, you'll get an error message like:

    class B extends A;
                     |
    xmvlog: *E,FAABP1 (testit.sv,27|17): Task/function call, or property/sequence instance does not specify all required formal arguments.
    function new(bit makecg);
                          |
    xmvlog: *E,FAABP2 (testit.sv,17|22): Formal argument 'makecg' is missing in the task/function call or property/sequence instance identified by the previous error message.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • TAM1
    TAM1 over 8 years ago

    Of course, you are correct. SystemVerilog will call the default constructor for A even if it isn't explicitly invoked in B's new function. So you'll have to add some code to control the new'ing of A's covergroup yourself.

    Class A's new function:

    function new(bit make_cg=1);
       if ( make_cg )
       begin
        cg = new;
        cg.option.name = "A_group";
       end
    end endfunction

    Class B's new function:

    function new;
       super.new(0);
       cg = new;
       cg.option.name = "B_group";
    endfunction



    If you forget to call super.new in the B constructor, you'll get an error message like:

    class B extends A;
                     |
    xmvlog: *E,FAABP1 (testit.sv,27|17): Task/function call, or property/sequence instance does not specify all required formal arguments.
    function new(bit makecg);
                          |
    xmvlog: *E,FAABP2 (testit.sv,17|22): Formal argument 'makecg' is missing in the task/function call or property/sequence instance identified by the previous error message.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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