FSM state transition coverage issue

Hi I am trying to write a functional coverage for different fsm states
Consider this scenario, There are four FSM states S0,S1,S2,S3.
States will change in order like this S0 → S2 ->S1 → S3 → S0.

if i try to write the bins for the entire transition , bins are not getting covered but if I write individually its getting covered.

STATE_TRANSITIONS : coverpoint curr_state 
{
bins S0_S2_S1_S3_S0 = (S0 => S2 => S1 => S3 => S0); // not working
}

STATE_TRANSITIONS : coverpoint curr_state  // WORKING
 {
  bins S0_S2 = (S0 => S2);
  bins S2_S1 = (S2 => S1);
  bins S1_S3 = (S1 => S3);
  bins S3_S0 = (S3 => S0);
}

Is there anything I am missing in the first coverpoint which is not causing the transition coverage? How exactly I have to do to make the first coverpoint to work ?

In reply to dineshrajendiran0510:
Works for me. Maybe you have a problem capturing the first or last samples. It might help to show the complete code example that can be run. For example:

module top;
typedef enum {S0,S1,S2,S3} state_e;
   covergroup st_cg with function sample(state_e curr_state);
   
      STATE_TRANSITIONS : coverpoint curr_state 
	{
	 bins S0_S2_S1_S3_S0 = (S0 => S2 => S1 => S3 => S0); // not working
      }
	  endgroup // st_cg
   
  st_cg cg;
   
  initial begin
     cg = new;
     cg.sample(S1);
     cg.sample(S0);
     cg.sample(S2);
     cg.sample(S1);
     cg.sample(S3);
     cg.sample(S0);
     
  end
endmodule // top

In reply to dave_59:

Hi Dave,

I have written small example of sequence detector(1011 with no overlap) and I am trying to do the functional coverage for the code. I have written the coverpoint with the help of above explanation. It is working fine but I am not clear with the line
(covergroup st_cg with function sample(state_e curr_state); how it works.
Can you please give me the detailed explanation of this.

Link of my code: Functional_coverage_FSM - EDA Playground

Thanks,
Naren

1 Like

Hello dave,
can you please explain me how this “with function sample” works?

thanks