Previous Section Next Section

13.6 Coverage Object

This section discusses the requirements and e code for the coverage object. Coverage is implemented in two forms:

13.6.1 Requirements for Adding Coverage to the Packet Object

Requirements for the packet object are as follows:

13.6.2 e Code for Adding Coverage to the Packet Object

Example 13-6 shows e code for adding coverage to the jacket object.

Example 13-6 e Code for Adding Coverage to the Packet Object
<'
import sbt_packet;

extend sbt_packet {
    -- Extend sbt_packet with event for coverage
    event new_packet;
    -- Coverage will happen on the event new_packet
    cover new_packet is { -- Coverage on fields of packet
        -- Use ranges for the len field
        item len using ranges = {
            range([1..20], "SMALL");
            range([21..40], "MEDIUM");
            range([41..63], "LARGE");
        };
        item addr; -- Cover item addr
        item packet_kind; -- Cover item packet_kind
        item payload_size; -- Cover item payload_size
    };
};

-- Extended the sbt_driver to emit the new_packet coverage event for
-- the current packet at the time it is driven into the DUT
extend sbt_driver {
    on packet_started {
        emit cur_packet.new_packet;
    };
};

'>

13.6.3 Requirements for the Coverage Object

The coverage object is implemented in the form of a scoreboard (sbt_dut_cover). The sbt_dut_cover object performs coverage on the DUT state machine. Requirements for the sbt_dut_cover object are as follows:

13.6.4 e Code for the Coverage Object

Example 13-7 presents e code for the coverage object.

Example 13-7 e Code for the Coverage Object
File contains e code for the coverage object.
Record the DUT state machine coverage
- Create a new enum type fsm_state for the SM (has to match
- the HDL definition)
- Create a new coverage group for the SM coverage
- Cover the DUT state vector
- Create a transition coverage item, define all the illegal
- transitions
  (Define all the legal transitions and invert it using
   the "not" operator)
<'

-- Define enumerated type for fsm_state
-- Order has to be the same as in the HDL source
type fsm_state : [ADDR_WAIT, DATA_LOAD, PARITY_LOAD,
                 HOLD_STATE, BUSY_STATE];

unit sbt_dut_cover {
 -- Event sbt_sm happens every time clock_rise happens
    event sbt_sm is rise('clock')@sim;

    cover sbt_sm using text = "SBT State Machine" is {

        -- Assign the DUT state vector to the item "state"
        item state : fsm_state = 'router1/in_port/state_r';

        -- Legal/illegal states have to be complete!!
        -- We use all the legal transitions and invert them
        transition state using illegal = not ( -- of legal transitions
            (prev_state == ADDR_WAIT and
                ((state == ADDR_WAIT) or (state == DATA_LOAD) or
                (state == BUSY_STATE))) or
            (prev_state == BUSY_STATE and
                ((state == BUSY_STATE) or (state == DATA_LOAD))) or
            (prev_state == DATA_LOAD and
                ((state == DATA_LOAD) or (state == HOLD_STATE) or
                (state == PARITY_LOAD))) or
            (prev_state == HOLD_STATE and
                ((state == HOLD_STATE) or (state == DATA_LOAD) or
                (state == PARITY_LOAD))) or
            (prev_state == PARITY_LOAD and state == ADDR_WAIT)
      ); -- end transition

    }; -- end coverage
}; -- end unit

-- This configuration will enable coverage (Default is disabled)
extend sys {
    setup() is also {
        set_config(cover, mode, on); -- Other coverage options
                                     -- are available
    };
};

'>
Previous Section Next Section