Transition coverage items record the change in the item's value between two consecutive samplings of the item. Transition items are very useful for covering DUT state machines. The syntax for the transition item is as follows:
transition item-name [using coverage-item-option, ...];
The coverage options for transition coverage items are very similar to the options described in Table 10-3 for basic coverage items. However, the ranges option is not available with transition coverage items. The transition between two samples is specified with the key word prev_ that is prefixed before the name of the transition coverage item. Example 10-5 shows the usage of transition coverage items for covering a DUT state machine.
Example that shows how to cover a DUT state machine
using transition items.
<'
type cpu_state: [START, FETCH1, FETCH2, EXEC];
struct cpu {
//Define a coverage event
event clk_rise is rise('~/top/clk') @sim;
//Define a coverage struct member
cover clk_rise is {
//Define item that tracks the HDL state vector
item state: cpu_state = '~/top/state';
//Define transition items using the option
//illegal. This option prints an error message
//when the boolean expression is true. Inside the
//boolean expression is a list of all legal state
//transitions with a not() around it i.e all illegal
//state transitions. Thus, if any illegal transition
//is taken, an error message is displayed. This technique
//is preferred compared to specifying all illegal transitions.
transition state using illegal =
//A not of all legal state transitions
not ((prev_st == START and st == FETCH1)//State transition
or (prev_st == FETCH1 and st == FETCH2)//State transition
or (prev_st == FETCH1 and st == EXEC)//State transition
or (prev_st == FETCH2 and st == EXEC)//State transition
or (prev_st == EXEC and st == START)); //State transition
};
};
'>