How can I obtain code coverage information in ModelSim?

A procedure is:
  1. At the shell, enter the command,
    prep mentor

  2. At the shell, enter the command,
    vsim  -coverage  module_name
    i.e., for the module tb_h4ba,
    vsim  -coverage  tb_h4ba

  3. The ModelSim main window will open.  Open the ModelSim source window by entering the command,
    view source
    in the ModelSim main window.

  4. Run the simulation, i.e.,
    run  -all

  5. From the ModelSim main window menu, choose View | Structure.  The structure window will open.  Select the module in the structure window whose code coverage statistics you wish to view in the ModelSim source window.  The code corresponding to that module will be displayed in the ModelSim source window.  In the ModelSim source window, the executable lines of code are denoted by their line number set in blue font.  A check symbol to the left of a line number means the line was executed at least once in the run and a 'X' symbol means that the line was not executed or that a branch condition on the line did not evaluate to true in the run.  To view the number of hits for an executable line of code, place the mouse pointer over the Verilog code corresponding to that line.  This will cause the line to be highlighted in blue and the number of hits for that line to be displayed at the left side of the window.  Each branch statement will also indicate the number of times it evaluated to true and the number of times it evaluated to false in the run.

  6. To view a coverage report,
    1. From the Modelsim Main window menu, choose Tools > Coverage > Reports...

    2. The Coverage Report window will open.

    3. In the Coverage Report window, Select "Include Line Details" in addition to the defaults.  Select "OK".

    4. A Notepad window will open with a code coverage report listing the number of hits from the run for each executable line of code.