Difficulty: Medium · Puzzle 3 of 6 · Topic: UVM Phases and Objections
UVM 1.2. The scoreboard prints its verdict in report_phase using the report server's error count. The env (the scoreboard's parent) finds a leftover-state problem and calls `uvm_error` in its own report_phase. What does the log show, and how do you restructure so the verdict is trustworthy?
class my_sb extends uvm_scoreboard;
`uvm_component_utils(my_sb)
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void report_phase(uvm_phase phase);
uvm_report_server rs = uvm_report_server::get_server();
if (rs.get_severity_count(UVM_ERROR) == 0) `uvm_info("SB", "TEST PASSED", UVM_NONE)
else `uvm_info("SB", "TEST FAILED", UVM_NONE)
endfunction
endclass
class my_env extends uvm_env;
`uvm_component_utils(my_env)
int leftover;
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void report_phase(uvm_phase phase);
if (leftover != 0) `uvm_error("ENV", "leftover state at end of test")
endfunction
endclassWhich of the two report_phase functions runs first, the parent's or the child's?
1) report_phase is bottom-up: the scoreboard (child) runs before the env (parent).
2) At the scoreboard's report_phase the error count is still 0, so it prints TEST PASSED.
3) Then the env's report_phase raises the UVM_ERROR, so the log ends with a PASSED banner followed by an ERROR.
4) Fix: do every check that can fail in check_phase (which finishes for all components before any report_phase starts) and keep report_phase for printing; or print the verdict once from the test's own report_phase, which runs last among the report_phase calls.Answer: The log shows TEST PASSED first and the UVM_ERROR after it, because the child's report_phase runs before the parent's; move the checks to check_phase.
Not run here: The UVM library is not installed here, so this cannot be executed; uvm_report_server, uvm_error and the phase scheduler are UVM library behaviour; the bottom-up versus top-down order it relies on is the one executed in uvm-phase-01.. The answer follows the language rules and the solution steps above.
Deciding pass/fail in a report_phase that other components may still add errors to: bottom-up order means the child sees only the errors of components that ran before it, not those of its ancestors.
Where would an error raised in final_phase appear relative to a PASSED banner printed in report_phase? Model answer: after it, since final_phase starts only after all report_phase calls are done; the report server's end-of-run summary (counts) is printed later still, so the summary count includes that error even though the banner does not.