# Passing Comparator Results or Checked Variable Upstream

**URL:** <https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536>\
**Category:** UVM\
**Tags:** UVM, comparator, scoreboard\
**Created:** [September 12, 2019, 11:37pm UTC](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536 "2019-09-12T23:37:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![polyengineer13](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/polyengineer13/32/1069_2.png) [@polyengineer13](https://verificationacademy.com/forums/u/polyengineer13)\
**Post date:** [September 12, 2019, 11:37pm UTC](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/1 "2019-09-12T23:37:19Z")

</div>

Trying to determine if there is a way to pass comparator matches and mismatches from a lower-level agent’s scoreboard to the overall testbench environment’s scoreboard.

In that way when a test is ran, all checked variables or comparator matches/mismatches are funneled up to the top.

For example, I’m envisioning in my top scoreboard\_c that my report\_phase can gather the comparator results from any agent that ran a comparison.

```verilog
function void scoreboard_c::report_phase(uvm_phase phase);
  int checked;
  `uvm_info(name,$sformatf("Reporting scoreboard information...\n%s", this.sprint()), UVM_LOW)

  //add results of lower level comparators to number of checked
  top.checked += tb_env_h.env1_h.comparator_h.m_matches + env1_h.comparator_h.m_mismatches;

  `uvm_info(get_type_name(), $sformatf("Matches: %0d", tb_env_h.env1_h.comparator_h.m_matches), UVM_LOW)
  `uvm_info(get_type_name(), $sformatf("Mismatches: %0d", env1_h.comparator_h.m_mismatches), UVM_LOW)

  if (top.checked == 0)
    `uvm_error(name, "No Transactions Processed.");

  if (env1_h.comparator_h.m_mismatches > 0)
    `uvm_error(name, "Compare Failed");

endfunction : report_phase

```

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [September 13, 2019, 4:51am UTC](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/2 "2019-09-13T04:51:25Z")

</div>

_In reply to [solosys](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536):_

The extract/check/report\_phases are all executed bottom-up, so you can use that information to help propagate totals up. Even better would be to separate the checking to the check\_phase.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [September 13, 2019, 6:59am UTC](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/3 "2019-09-13T06:59:38Z")

</div>

_In reply to [solosys](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/2):_

> Trying to determine if there is a way to pass comparator matches and mismatches from a lower-level agent’s scoreboard to the overall testbench environment’s scoreboard.  
> In that way when a test is ran, all checked variables or comparator matches/mismatches are funneled up to the top.  
> For example, I’m envisioning in my top scoreboard\_c that my report\_phase can gather the comparator results from any agent that ran a comparison.

```verilog
function void scoreboard_c::report_phase(uvm_phase phase);
int checked;
`uvm_info(name,$sformatf("Reporting scoreboard information...\n%s", this.sprint()), UVM_LOW)
//add results of lower level comparators to number of checked
top.checked += tb_env_h.env1_h.comparator_h.m_matches + env1_h.comparator_h.m_mismatches;
`uvm_info(get_type_name(), $sformatf("Matches: %0d", tb_env_h.env1_h.comparator_h.m_matches), UVM_LOW)
`uvm_info(get_type_name(), $sformatf("Mismatches: %0d", env1_h.comparator_h.m_mismatches), UVM_LOW)
if (top.checked == 0)
`uvm_error(name, "No Transactions Processed.");
if (env1_h.comparator_h.m_mismatches > 0)
`uvm_error(name, "Compare Failed");
endfunction : report_phase

```

The question is what is the benefit of this approach. Finally you want to see all matches/mismatches somewhere in 1 log-file. This can be done from any level.  
In your approach you can pass the lower-level matches/mismatches through the config\_db to the test.

---

<div class="post-metadata">

**Author:** ![polyengineer13](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/polyengineer13/32/1069_2.png) [@polyengineer13](https://verificationacademy.com/forums/u/polyengineer13)\
**Post date:** [September 13, 2019, 5:02pm UTC](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/4 "2019-09-13T17:02:30Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/3):_

So I guess that’s more of my question of what the proper syntax/mechanism to propagate up. Attempting something like the code above doesn’t work because it seems like the scoreboard isn’t “aware” of the testbench hierarchy.

i.e. top.checked += tb\_env\_h.env1\_h.comparator\_h.m\_matches returns an error

the actual comparator is actually a few more levels down.  
more like tb\_env\_h.env1\_h.env1\_h.scoreboard\_h.comparator\_h

---

<div class="post-metadata">

**Author:** ![polyengineer13](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/polyengineer13/32/1069_2.png) [@polyengineer13](https://verificationacademy.com/forums/u/polyengineer13)\
**Post date:** [September 13, 2019, 5:04pm UTC](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/5 "2019-09-13T17:04:07Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/4):_

chr\_sue,  
Wouldn’t this require a change to the lower level egent’s code? The scoreboard is part of a UVC, of which I do not wish to modify.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [September 14, 2019, 7:36am UTC](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/6 "2019-09-14T07:36:16Z")

</div>

_In reply to [solosys](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/5):_

Yes it’s true you had to modify this UVC code. But you have to do this in any way, except the compare results are passed to the config\_db and you can retrieve them from a higher level.

---

<div class="post-metadata">

**Author:** ![polyengineer13](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/polyengineer13/32/1069_2.png) [@polyengineer13](https://verificationacademy.com/forums/u/polyengineer13)\
**Post date:** [September 20, 2019, 12:13pm UTC](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/7 "2019-09-20T12:13:05Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/passing-comparator-results-or-checked-variable-upstream/36536/6):_

Are they any examples on how to propagate the comparator matche/mismatches upstream?
