The value of ADDR is read when calling the covergroup’s constructor. That is when the bins for the coverpoint are created. There is no more bin creation after constructing the covergroup.
So if ADDR has the value 0 when executing the statement
** Warning: (vsim-8546) The number of values specified ‘1’ is less than the size ‘16’ of fixed-size array bin ‘Addr’ in Coverpoint ‘addr’ of Covergroup instance '/top/xyz::access '. The ‘15’ empty bins will not contribute towards coverage.
Actually in the function I have calculated the range of address which i want to use in my covergroup.
Basically i want to do this
memory_range : coverpoint range {bins addr = {[base_addr, final_addr]};}
which will be dependant on the size of the memory for which i have defined a function. The size and base_addr are read from registers inside the function.
function void calc();
bit [3:0] size;
register read to get size;
register read to get base_addr;
case(size)
4’b0000: begin
Max_addr = ‘h10000;
Final_addr= base_addr+max_addr;
covergroup.sample();
end
4’b0001: …….
endfunction
How should I access the base addr and final addr from the function in my covergroup?
You still have not explained your situation very well. Functional coverage in SystemVerilog works by creating in set of value bins associated with a coverpoint, and a set of coverpoints or grouped within a covergroup. The bins are set up once during the covergroup’s constructor. The the covergroup repeatedly samples the values of the coverpoint, and the matching value bins are incremented with hits. You call sample() repeatedly hoping the every bin gets hot.
You need to explain what value will be repeatedly sampled and compared with the predefined set of bin values. Perhaps you need to show an example set of data that would be sampled, and explain which bins would be hit those values.
In reply to dave_59:
Thanks for sharing the solution. The problem with maximum_width is that simulator expects an equivalent type for ref formal ‘vector’ (ie. Questa will return error 8282).
However, one can override built-in sample method:
covergroup cgmaskbit(input bit [31:0] position) with function sample (bit [MAX_WIDTH-1:0] vector);
pos: coverpoint (position & vector) !=0;
option.per_instance = 1;
endgroup