I was asked the below question in my recent interview.
Write coverage for 4-bit address, so that each bit has been 0 to 1 at least once.
bit [3:0] addr;
covergroup cg (@posedge clk)
a: coverpoint addr; //This will create 16 auto bins for coverpoint addr for all 16 values starting from 0000 to 1111
b: coverpoint addr
bins b1 = (4'b0000 => 4'b1111); //This covers the state from 0000 to 1111 which will cover all bits from 0 to 1.
cg cg_inst = new();
I have written the above cover group but I am not sure if I interpreted the question correctly - if this is a state transition or if this is to cover each bit transition. If it's each bit toggle then we have toggle coverage in code coverage. Can you please help me understand how to interpret this question?
Thanks in advance.