Home > Community > Forums > Functional Verification > Functional coverage

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Functional coverage 

Last post Sun, Mar 18 2012 6:17 PM by jxker. 3 replies.
Started by jxker 14 Mar 2012 12:26 AM. Topic has 3 replies and 3530 views
Page 1 of 1 (4 items)
Sort Posts:
  • Wed, Mar 14 2012 12:26 AM

    • jxker
    • Not Ranked
    • Joined on Tue, Mar 13 2012
    • beijing, Beijing
    • Posts 13
    • Points 140
    Functional coverage Reply

    Hi, all. I am trying to do functional coverage, but it seems something wrong with my command line, that I cannot get a functional coverage result, but only the code coverage result. Can anyone tell me where I make a mistake?

    my systemverilog code is:

    class rand_cov;
       rand bit[4:0] data_a;
    endclass

    module cov;
       int i;
       int succ;
       bit[4:0] data;
      
       rand_cov cov_t;
       
       covergroup cg;
          cov_a: coverpoint data;
       endgroup
       cg cg_inst;

       initial begin
          cg_inst =new();
          cov_t = new();
         
          for(i=0; i<20; i++) begin
              succ = cov_t.randomize();
              data = cov_t.data_a;
              cg_inst.sample();
              $display("data=%0d, now coverage is: %0d",data, cg_inst.get_coverage());
          end      
       end
    endmodule

    And my command is :

    ncvlog -message -sv cov.v
    ncelab -message -access +rcw -covdut cov -coverage all work.cov:module
    ncsim -message -covoverwrite -covtest cov -covscope cov work.cov:module

    Filed under:
    • Post Points: 5
  • Thu, Mar 15 2012 11:46 PM

    • jxker
    • Not Ranked
    • Joined on Tue, Mar 13 2012
    • beijing, Beijing
    • Posts 13
    • Points 140
    Re: Functional coverage Reply

    Hi, all.

    I find where I am wrong. I should add "option.per_instance = 1;" in the covergroup declaration. And this enables saving the coverage of covergroup instances to the coverage database.

    And in my ncverilog version, the default value of option.per_instance is 0

    • Post Points: 20
  • Fri, Mar 16 2012 4:02 PM

    • tmackett
    • Not Ranked
    • Joined on Thu, Jan 8 2009
    • Irvine, CA
    • Posts 7
    • Points 80
    Re: Functional coverage Reply

     

     Change your code as below adding:

    option.per_instance=1;

    and

        cg_inst.set_inst_name($psprintf({"%m","_cg_inst"}));

    Otherwise you'll end up with a covergroup machine generated name like: cg_inst@1_1

    class rand_cov;
       rand bit[4:0] data_a;
    endclass

    module cov;
       int i;
       int succ;
       bit[4:0] data;
      
       rand_cov cov_t;
      
       covergroup cg;
      option.per_instance = 1;
          cov_a: coverpoint data;
       endgroup
       cg cg_inst;

       initial begin
          cg_inst =new();
          cov_t = new();
          cg_inst.set_inst_name($psprintf({"%m","_cg_inst"}));
         
          for(i=0; i<20; i++) begin
              succ = cov_t.randomize();
              data = cov_t.data_a;
              cg_inst.sample();
              $display("data=%0d, now coverage is: %0d",data, cg_inst.get_coverage());
          end     
       end
    endmodule

    • Post Points: 20
  • Sun, Mar 18 2012 6:17 PM

    • jxker
    • Not Ranked
    • Joined on Tue, Mar 13 2012
    • beijing, Beijing
    • Posts 13
    • Points 140
    Re: Functional coverage Reply

    Thank you very much!

    • Post Points: 5
Page 1 of 1 (4 items)
Sort Posts:
Started by jxker at 14 Mar 2012 12:26 AM. Topic has 3 replies.