Out of these two I need to generate the following transition bins
[1:4] => [1:2]; i.e a transition from any value in the range [1:4] to any value in the range [1:2] should be counted as 1 bin (ie. it is NOT equvalent to 1=>1 1=>2 2=>1, 2=>2 3=>1 3=>2 4=>1 4=>2)
similarly, we have all bins of cp_abc to cp_xzy (kind of a cross but only that they are transition bins and they have a range of values).
So there should be 16 bins.
I can’t figure out any other possible way to model this covergroup. Can someone help me out with this?
I don’t understand what you mean by a transition from the bins of coverpoint to the bins of another. A transition is only defined within a single coverpoint expression. i.e. the transition of the value of abc from one sample to the next sampled value.
I have some ideas what you might be thinking, but it would save a lot of time if you could show an example series of value pairs of (abc,xyz) that explains what is to be covered.
Oops. I’m sorry. I’ve been carried away by the abc, xyz examples. Its actually the same coverpoint point, but not the same coverpoint expression. It’s like this.
So, it’s all the values of abc divided into 8 categories (8 bins). And I need to collect coverage whenever there is a transition from a value in the range of [1:4] to a value in the range of [1:2] i.e something like [1:4] => [1:2] (this should be taken as 1 bin, instead it gives me 4x2 = 8 bins taking individual values in the range).
So, in this manner I need to get 4x4 16 bins,
like [1:4] => [1:2]
[1:4] => [3:5]
[1:4] => [6:9]
[1:4] => [10:15]
OK, that kind of transition is too complex to be represented in a SystemVerilog transition bin directly. You will have to encode the range into a unique values and you can have a transition bin covering the encoding. You also need to specify if the sequence is overlapping or non-overlapping. An example of the non-overlapping case could be:
module top;
bit [3:0] abc;
bit toggle;
function bit [1:0] rangeEncoding(input [3:0] value, inout bit toggle);
if (toggle++)
case (value) inside
[1:4] : return 0;
[5:7] : return 1;
[8:10] : return 2;
[11:15]: return 3;
endcase
else
case (value) inside
[1:2] : return 0;
[2:5] : return 1;
[6:9] : return 2;
[11:15]: return 3;
endcase
endfunction
covergroup CG;
cp: coverpoint rangeEncoding(abc, toggle) {
bins b[] = ([0:3] => [0:3]);
}
endgroup
CG cg;
initial begin
cg = new;
repeat (20) begin
abc = $urandom;
cg.sample();
end
end
endmodule
A more complicated set of range encodings might be represented by an associative array.
If this is for a finite-state-machine, many tools have FSM coverage built in to figure out all the possible transitions, and which ones were taken.
Otherwise if you are looking to cover all possible transitions of 5 operations, you can create a shift register that you sample every 5 cycles. that would give you thousands of bins. Is that what you really want?
Not shift register, I have this operation type in my transaction class, and in regression, I want to check that all the operations are performed one after another with all possible combinations in random order.
You can add the enum values into a queue and then you can create the transition bins something like this
Probably there are more efficient ways of achieving the same, and also some simulators may not support it, anyways hope it helps
module test();
typedef enum {
ADD,
SUBSTRACT,
MULTIPLY,
DIVIDE
} operation_t;
operation_t ops;
//queue to get the enums
typedef operation_t ops_queue[$];
covergroup cg(ops_queue m_ops_q);
ops_transition_cp: coverpoint ops {
//transitions between the first and last enum and all combinations
bins transitions[]= ([m_ops_q[0] : m_ops_q[$]] => [m_ops_q[0] : m_ops_q[$]]);
}
endgroup
//logic to put all enums in a queue to be used for transitions
function automatic ops_queue get_ops();
ops_queue m_ops_q;
operation_t op = op.first();
m_ops_q.push_back(op.first());
m_ops_q.push_back(op.last());
$display("m_ops_q %p", m_ops_q);
return m_ops_q;
endfunction
initial begin
ops_queue ops;
cg m_cg;
ops = get_ops();
m_cg = new(ops);
repeat(10) begin
if(!std::randomize(ops)) $fatal(1,"Randomize failure");
m_cg.sample();
end
$display("m_cg.get_coverage = %0.2f%%", m_cg.get_coverage());
end
endmodule
In reply to rgarcia07:
Thank you very much for your effort,
As I can see in transition(snip you attached). there are a total of 4 operations in your example.
ADD
SUBTRACT
MULTIPLY
DIVIDE
and you are checking/creating bins for any two possible operations like,
DIVIDE => ADD, ADD => SUBTRACT or MULTIPLY => DIVIDE
but what I am looking for is, in my test, I am performing all operations in a single loop in random order and loop count is random.
So I want transition bins like(taking enum from your example)
bins SEQ_1 = {ADD => SUBTRACT => MULTIPLY => DIVIDE};
bins SEQ_2 = {DIVIDE => ADD => SUBTRACT => MULTIPLY};
bins SEQ_3 = {MULTIPLY => DIVIDE => ADD => SUBTRACT};
bins SEQ_4 = {SUBTRACT => MULTIPLY => DIVIDE => ADD};
Here I want to cover all operation in one bin and have multiple bins with all operation
In your example, there are total four operations in enum so 2^4 = 16 possibilities
and in my project I have total 8 different operations so the total combination will be 2^8 = 256
In reply to rgarcia07:
Hi,
I am creating an array of bins using defines tike this,
`define RD_OP RD => RD_CMP
`define DMA_RD_OP DMA_RD => DMA_RD_CMP
`define NORMAL_OP WR,`RD_OP
`define DMA_OP DMA_WR,`DMA_RD_OP
//for creating bins I am doing like this
bins SEQ_1[] = (`NORMAL_OP => `DMA_OP);
bins SEQ_2[] = (`DMA_OP => `NORMAL_OP);
//As here I have taken array it will generate all the possibility of operation
But, here I want to constraint that if RD operation comes than next operation would be always RD_CMP like,
RD => RD_CMP
DMA_RD => DMA_RD_CMP
but using the above code I am not able to perform the desired operation and the sequence is generated in a random order like,