Expression Coverage in SV
Recently I was going through coverage topic where an expression like a+b was being covered. And earlier I had a doubt whether i can partially cover a variable. So went out to checkout all them doubs with a simple code.
module top;
logic clk=0;
logic a;
logic [1:0] b,c;
logic [7:0] d;
covergroup cg@(posedge clk);
option.auto_bin_max=32;
a_cov : coverpoint a;
b_cov : coverpoint b;
c_cov : coverpoint c;
d_cov : coverpoint d;
sum : coverpoint c+a;
expr : coverpoint (b&&c) + |d;
narrow: coverpoint d[3:0];
con : coverpoint {c+a,a};
crs : cross a_cov,sum;
endgroup
cg cg_h=new();
initial forever #5 clk=~clk;
always_ff @(posedge clk) {a,b,c,d} = $random();
initial #100 $finish;
endmodule
Note: option.auto_bin_max set to 32
sum coverpoint will have same bins as b_cov or c_cov, but will differ from c_cov because of the summation with a variable.
expr coverpoint will have same bins as sum because b&&c will result in a bit and |d into a bit and their sum as another bit. This way we can have any complex expression. This type of coverage is thus useful to check whether a case statement or loop and if blocks with complex expressions are being covered or not.
narrow coverpoint will only have 16 autobins unlike d_cov because it only covers d variable partially
Can we do cross coverage of two variable without using cross keyword?
Yes, ofcourse. But it will be cumbersome without cross coverage. We can just concatenate variables.
Leave Expression Coverage in SV to:
Read more #coding posts
Best Posts From Shaik Azhar Madar
We have not curated any of azarmadr3's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Shaik Azhar Madar
- My Actifit Report Card: March 1 2026
- My Actifit Report Card: February 20 2026
- My Actifit Report Card: February 20 2026
- PhotoFeed Contest - Macro Photography Round 157 - Closer look at clover flower
- My Actifit Report Card: February 17 2026
- My Actifit Report Card: February 13 2026
- My Actifit Report Card: February 11 2026
- My Actifit Report Card: February 9 2026
- My Actifit Report Card: February 8 2026
- My Actifit Report Card: February 7 2026