• 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

    What behavior are you looking for? Almost any is possible and under your control.

    Do you "new" both groups when you create an instance of class B? Do you assign each covergroup a unique instance name? Are you looking at the instance-based report or the type-based report?

    reg clk=0;
    always #5 clk = !clk;

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

    function new;
    cg = new;
    cg.option.name = "A_group"; // optional
    endfunction endclass // A class B extends A; int b; covergroup cg @(clk); option.per_instance = 1; v_b: coverpoint b iff(reset){} endgroup // cg function new;
    super.new; // optional
    cg = new;
    cg.option.name = "B_group"; // optional
    endfunction

    endclass // B

    B b;
    initial
    begin
    b = new;
    b.a = 1;
    b.b = 2;
    #10 $finish;
    end

    Experiment with different combinations of these and see what results you get.

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

    What behavior are you looking for? Almost any is possible and under your control.

    Do you "new" both groups when you create an instance of class B? Do you assign each covergroup a unique instance name? Are you looking at the instance-based report or the type-based report?

    reg clk=0;
    always #5 clk = !clk;

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

    function new;
    cg = new;
    cg.option.name = "A_group"; // optional
    endfunction endclass // A class B extends A; int b; covergroup cg @(clk); option.per_instance = 1; v_b: coverpoint b iff(reset){} endgroup // cg function new;
    super.new; // optional
    cg = new;
    cg.option.name = "B_group"; // optional
    endfunction

    endclass // B

    B b;
    initial
    begin
    b = new;
    b.a = 1;
    b.b = 2;
    #10 $finish;
    end

    Experiment with different combinations of these and see what results you get.

    • 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