|
| 1 | +SV-UVM-Style Reporting |
| 2 | +====================== |
| 3 | + |
| 4 | +pyuvm uses Python logging as its reporting backend. Existing testbenches can |
| 5 | +continue to use ``self.logger.info()``, ``self.logger.warning()``, and |
| 6 | +``self.logger.error()`` directly. |
| 7 | + |
| 8 | +For testbenches that need UVM-style report IDs, UVM verbosity filtering, |
| 9 | +severity counts, report summaries, or report catching, pyuvm also provides an |
| 10 | +opt-in SV-UVM-style reporting path. The UVM-style layer performs the UVM |
| 11 | +reporting decisions and then emits through Python logging. |
| 12 | + |
| 13 | +Enabling SV-UVM-Style Reporting |
| 14 | +------------------------------- |
| 15 | + |
| 16 | +Enable the shared reporting mode before creating UVM objects or components: |
| 17 | + |
| 18 | +.. code-block:: bash |
| 19 | +
|
| 20 | + PYUVM_ENABLE_SV_UVM_STYLE_REPORTING=1 make sim |
| 21 | +
|
| 22 | +You can also enable it from Python before constructing the testbench: |
| 23 | + |
| 24 | +.. code-block:: python |
| 25 | +
|
| 26 | + from pyuvm import set_sv_uvm_style_reporting_enabled |
| 27 | +
|
| 28 | + set_sv_uvm_style_reporting_enabled(True) |
| 29 | +
|
| 30 | +When this mode is enabled, ``uvm_object`` loggers propagate to the shared |
| 31 | +``uvm`` logger. In this mode, ``uvm_report_object`` does not install a default |
| 32 | +stream handler on every report object. This preserves Python logging as the |
| 33 | +transport while giving the testbench a shared path for report rendering. |
| 34 | + |
| 35 | +To collect severity counts, use report summaries, or install report catcher |
| 36 | +rules, create the report server early in the test: |
| 37 | + |
| 38 | +.. code-block:: python |
| 39 | +
|
| 40 | + from pyuvm import UVM_LOW, uvm_report_server |
| 41 | +
|
| 42 | + report_server = uvm_report_server.create(verbosity=UVM_LOW) |
| 43 | +
|
| 44 | +Writing Reports |
| 45 | +--------------- |
| 46 | + |
| 47 | +Every ``uvm_object`` has a ``uvm_report`` property. Use it when you want |
| 48 | +UVM-style report IDs and UVM verbosity semantics: |
| 49 | + |
| 50 | +.. code-block:: python |
| 51 | +
|
| 52 | + from pyuvm import UVM_HIGH, UVM_LOW, uvm_component |
| 53 | +
|
| 54 | +
|
| 55 | + class Scoreboard(uvm_component): |
| 56 | + def check_phase(self): |
| 57 | + self.uvm_report.info("SCOREBOARD", "checking final results", UVM_LOW) |
| 58 | +
|
| 59 | + if self.mismatch_seen: |
| 60 | + self.uvm_report.error("SCOREBOARD", "result mismatch detected") |
| 61 | + else: |
| 62 | + self.uvm_report.info("SCOREBOARD", "all results matched", UVM_HIGH) |
| 63 | +
|
| 64 | +The available report methods are: |
| 65 | + |
| 66 | +* ``self.uvm_report.info(report_id, message, verbosity)`` |
| 67 | +* ``self.uvm_report.warning(report_id, message)`` |
| 68 | +* ``self.uvm_report.error(report_id, message)`` |
| 69 | +* ``self.uvm_report.fatal(report_id, message)`` |
| 70 | + |
| 71 | +UVM Verbosity |
| 72 | +------------- |
| 73 | + |
| 74 | +UVM verbosity is not mapped onto Python logging levels. It is evaluated before |
| 75 | +the logging call using UVM semantics: an info report passes when its message |
| 76 | +verbosity is less than or equal to the configured verbosity. |
| 77 | + |
| 78 | +.. code-block:: python |
| 79 | +
|
| 80 | + from pyuvm import UVM_HIGH, UVM_LOW, uvm_report_server |
| 81 | +
|
| 82 | + uvm_report_server.create(verbosity=UVM_LOW) |
| 83 | +
|
| 84 | + self.uvm_report.info("LOW_ID", "visible", UVM_LOW) |
| 85 | + self.uvm_report.info("HIGH_ID", "suppressed", UVM_HIGH) |
| 86 | +
|
| 87 | +Warning, error, and fatal reports are severity reports. They are not suppressed |
| 88 | +by info verbosity. Python logging levels still carry severity to the backend |
| 89 | +formatter and handlers. |
| 90 | + |
| 91 | +Report Summary and Failure Policy |
| 92 | +--------------------------------- |
| 93 | + |
| 94 | +The report server tracks UVM severity counts. At the end of a test, emit a |
| 95 | +summary and assert the failure policy: |
| 96 | + |
| 97 | +.. code-block:: python |
| 98 | +
|
| 99 | + import logging |
| 100 | + from pyuvm import uvm_report_server |
| 101 | +
|
| 102 | + report_server = uvm_report_server.get() |
| 103 | + report_server.log_summary(logging.getLogger("uvm")) |
| 104 | + report_server.assert_no_failures("end of test") |
| 105 | +
|
| 106 | +By default, warnings do not fail the test, while errors and fatals do. The |
| 107 | +policy can be changed when the report server is created: |
| 108 | + |
| 109 | +.. code-block:: python |
| 110 | +
|
| 111 | + from pyuvm import uvm_report_policy, uvm_report_server |
| 112 | +
|
| 113 | + policy = uvm_report_policy(fail_on_warning=True, max_quit_count=5) |
| 114 | + uvm_report_server.create(policy=policy) |
| 115 | +
|
| 116 | +Report Catching |
| 117 | +--------------- |
| 118 | + |
| 119 | +The report server supports simple severity rewrites by report ID and message |
| 120 | +regular expression: |
| 121 | + |
| 122 | +.. code-block:: python |
| 123 | +
|
| 124 | + from pyuvm import UVM_WARNING, uvm_report_server |
| 125 | +
|
| 126 | + report_server = uvm_report_server.get() |
| 127 | + report_server.add_change_sev("KNOWN_ISSUE", "temporary", UVM_WARNING) |
| 128 | +
|
| 129 | + self.uvm_report.error("KNOWN_ISSUE", "temporary mismatch") |
| 130 | +
|
| 131 | +Formatter Relationship |
| 132 | +---------------------- |
| 133 | + |
| 134 | +SV-UVM-style reporting does not replace Python logging. It provides UVM-shaped |
| 135 | +report metadata and filtering before the message reaches logging. The rendered |
| 136 | +timestamp, hierarchy, filename, line number, and final text layout still come |
| 137 | +from the active Python logging formatter. |
| 138 | + |
| 139 | +pyuvm's ``PyuvmFormatter`` remains the customization point for teams that want |
| 140 | +a different log layout while keeping the UVM-style report metadata, verbosity |
| 141 | +filtering, counts, summaries, and catcher behavior. |
0 commit comments