Previous Section Next Section

10.10 Exercises

  1. Define a struct packet. Define the following elements in this struct.

    1. Define addr (2 bits)—physical field.

    2. Define len (6 bits)—physical field.

    3. Define payload (list of byte)—physical field.

    4. Define new_packet—event.

    5. Define coverage group new_packet that includes coverage on addr and len.

    6. Use a weight = 5, radix = HEX on addr and a weight = 10, radix = DEC on len.

  2. Extend struct packet.

    1. Extend coverage group new_packet using is also.

    2. Add cross coverage on addr and len.

    3. Cross coverage name addr_len.

  3. Define an enumerated type fsm_state with values [IDLE, EXEC, HOLD]. Extend struct packet.

    1. Extend coverage group new_packet using is also.

    2. Add an item st of type fsm_state that gets a value from HDL signal '~/top/state'.

    3. Add a transition item of st. Exclude illegal transitions. The legal state transitions are IDLE->EXEC, EXEC->HOLD, HOLD->EXEC, EXEC->IDLE. (Hint: Use a not of legal transitions.) Assign a name "State_Machine" to this item.

  4. Extend struct packet.

    1. Add events start and end to the struct.

    2. Take a sample of sys.time when event start is emitted.

    3. Take a sample of sys.time when event end is emitted

    4. Extend coverage group new_packet using is also.

    5. Perform latency coverage on the simulation time difference between the start and end. Ranges for latency coverage are [0..50] = "short", [51..100] = "medium", [101..200] = "long". At least three samples are needed in each range for full coverage. (Hint: Use ranges keyword and at_least option.)

  5. Extend sys. Instantiate the packet struct. Turn coverage ON in normal mode.

Previous Section Next Section