State Coverage Report

Medium Python Verification Asked at Cadence
Solve this problem

Given an FSM definition and a simulation trace, report which states and which transitions were never exercised, so a testbench gap is visible.

Constraints

  • FSM is a dict mapping state to a list of reachable states.
  • Trace is a list of visited states in order.
  • Report unvisited states and untaken transitions as sorted lists.
  • A trace containing an undefined state must raise ValueError.
  • Also report coverage percentages for both.
Starter codePython
1def coverage_report(fsm, trace):2    # TODO3    return {}