This section discusses the requirements and e code for the coverage object. Coverage is implemented in two forms:
By extending the packet object to add coverage on the items of the packet struct.
By creating a separate coverage object (sbt_dut_cover) to perform coverage on the state machine.
Requirements for the packet object are as follows:
Add an event new_packet to use for coverage of packet items.
Extend the sbt_packet struct and cover the fields addr, len, packet_kind, and payload_size.
For the len field, use the ranges{} coverage item option to create three buckets of equal range size.
Example 13-6 shows e code for adding coverage to the jacket 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; }; }; '>
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:
Define an enumerated type for the states of the DUT finite state macine (FSM).
Add a coverage item of type fsm_state to cover the HDL DUT state.
Add a transition coverage item for the state register. Define the illegal transitions in the DUT state machine. (Here it is easier to specify illegal transitions as a not of legal transitions.)
Example 13-7 presents 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 }; }; '>