• 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
  • Jeff000
    Jeff000 over 8 years ago

    Thanks TAM1 for your kind reply.

    What I expect is to have A and B take their own covergroup, i.e. A with covergroup defined in class A while B has covergroup defined in class B. I've "new" both for A and B as below and assign distinct name for each by calling cg.set_inst_name(), which I think will have the same effect as cg.option.name = "".

    
    reg clk=0;
    always #5 clk = !clk;
    
    class A;
        bit[1:0] 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;
        bit[1:0] 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
    
    A c_a;
    B c_b;
    initial
    begin
        c_a = new;
        c_b = new;
        c_a.a = 1;
        c_b.a = 2;
        c_b.b = 3;
        #10 $finish;
    end
    

    As the instance-based report shows, the A's covergroup still exists in B's covergroup (even without calling super.new in B), is there any way to ignore cov_A in cov_B?

    Thanks.

    
    Name         Average, Covered Grade Line Source Code
    c_a.A_group  25.00%, 25.00% (1/4)   299  covergroup cg (@clk);
    |--v_a       25.00% (1/4)           301  coverpoint a
    | --auto[0]  0.00% (0/1)            301  coverpoint a
    | |--auto[1] 100.00% (39/1)         301  coverpoint a
    | |--auto[2] 0.00% (0/1)            301  coverpoint a
    | |--auto[3] 0.00% (0/1)            301  coverpoint a
    c_b.A_group  25.00%, 25.00% (1/4)   299  covergroup cg (@clk);
    | - -v_a     25.00% (1/4)           301  coverpoint a
    | |--auto[0] 0.00% (0/1)            301  coverpoint a
    | |--auto[1] 0.00% (0/1)            301  coverpoint a
    | |--auto[2]  100.00% (39/1)         301  coverpoint a
    | |--auto[3] 0.00% (0/1)            301  coverpoint a
    c_b.B_group  25.00%, 25.00% (1/4)   315  covergroup cg (@clk);
    |--v_b       25.00% (1/4)           317  coverpoint b
    | |--auto[0] 0.00% (0/1)            317  coverpoint b
    | |--auto[1] 0.00% (0/1)            317  coverpoint b
    | |--auto[2] 0.00% (0/1)            317  coverpoint b
    | |--auto[3] 100.00% (39/1)         317  coverpoint b
    
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Jeff000
    Jeff000 over 8 years ago

    Thanks TAM1 for your kind reply.

    What I expect is to have A and B take their own covergroup, i.e. A with covergroup defined in class A while B has covergroup defined in class B. I've "new" both for A and B as below and assign distinct name for each by calling cg.set_inst_name(), which I think will have the same effect as cg.option.name = "".

    
    reg clk=0;
    always #5 clk = !clk;
    
    class A;
        bit[1:0] 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;
        bit[1:0] 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
    
    A c_a;
    B c_b;
    initial
    begin
        c_a = new;
        c_b = new;
        c_a.a = 1;
        c_b.a = 2;
        c_b.b = 3;
        #10 $finish;
    end
    

    As the instance-based report shows, the A's covergroup still exists in B's covergroup (even without calling super.new in B), is there any way to ignore cov_A in cov_B?

    Thanks.

    
    Name         Average, Covered Grade Line Source Code
    c_a.A_group  25.00%, 25.00% (1/4)   299  covergroup cg (@clk);
    |--v_a       25.00% (1/4)           301  coverpoint a
    | --auto[0]  0.00% (0/1)            301  coverpoint a
    | |--auto[1] 100.00% (39/1)         301  coverpoint a
    | |--auto[2] 0.00% (0/1)            301  coverpoint a
    | |--auto[3] 0.00% (0/1)            301  coverpoint a
    c_b.A_group  25.00%, 25.00% (1/4)   299  covergroup cg (@clk);
    | - -v_a     25.00% (1/4)           301  coverpoint a
    | |--auto[0] 0.00% (0/1)            301  coverpoint a
    | |--auto[1] 0.00% (0/1)            301  coverpoint a
    | |--auto[2]  100.00% (39/1)         301  coverpoint a
    | |--auto[3] 0.00% (0/1)            301  coverpoint a
    c_b.B_group  25.00%, 25.00% (1/4)   315  covergroup cg (@clk);
    |--v_b       25.00% (1/4)           317  coverpoint b
    | |--auto[0] 0.00% (0/1)            317  coverpoint b
    | |--auto[1] 0.00% (0/1)            317  coverpoint b
    | |--auto[2] 0.00% (0/1)            317  coverpoint b
    | |--auto[3] 100.00% (39/1)         317  coverpoint b
    
    • 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