# How to read and use the alert\_counters

**URL:** <https://forum.uvvm.org/t/how-to-read-and-use-the-alert-counters/241>\
**Category:** Uncategorized\
**Created:** [November 17, 2021, 1:56pm UTC](https://forum.uvvm.org/t/how-to-read-and-use-the-alert-counters/241 "2021-11-17T13:56:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@Eric](https://forum.uvvm.org/u/Eric)\
**Post date:** [November 17, 2021, 1:56pm UTC](https://forum.uvvm.org/t/how-to-read-and-use-the-alert-counters/241/1 "2021-11-17T13:56:48Z")

</div>

Hi,

In the example testbenches I see  
report\_alert\_counters(FINAL);  
I need not the reporting, but I need the actual values.  
How do you read a t\_alert\_level?

For example, to through an error in ModelSIM.

So I want conceptual:

if (TB\_WARNING == 0) then  
“no tb\_warnings seen”  
end if;  
if (TB\_ERROR != 0) then  
“Throw Fatal”  
exit(1);  
else  
exit(0);  
end if;

---

<div class="post-metadata">

**Author:** ![EspenTa](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/espenta/32/52_2.png) [@EspenTa](https://forum.uvvm.org/u/EspenTa)\
**Post date:** [November 21, 2021, 6:31pm UTC](https://forum.uvvm.org/t/how-to-read-and-use-the-alert-counters/241/2 "2021-11-21T18:31:48Z")

</div>

Hi Eric,

First of all, please note that UVVM has 4 different status variables that can be used to check the result of your simulation, Util Quick reference page 8. These are intended for exactly this.

You can also check the error counters directly using:  
protected\_alert\_attention\_counters.get(alert\_level, attention); or  
protected\_alert\_attention\_counters.get(alert\_level);  
where attention is one of regard, expect, ignore (default here is regard)  
and allert\_level is for instance TB\_ERROR - and all the other UVVM alert levels.

– Espen

---

<div class="post-metadata">

**Author:** ![Eric](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@Eric](https://forum.uvvm.org/u/Eric)\
**Post date:** [November 24, 2021, 2:26pm UTC](https://forum.uvvm.org/t/how-to-read-and-use-the-alert-counters/241/3 "2021-11-24T14:26:33Z")

</div>

Hi Espen,

I’m still missing something, as I can’t get it compiled.  
What should I change to the uart\_vvc\_demo\_tb.vhd for example to be able to test these status variables?

I tried the following:

- added a variable sim\_results in the main process

```auto
...
 p_main: process
           variable sim_results : t_alert_level;
begin
...

```

And then trying to assign a value to it

```auto
...
report_final_counters(FINAL);
sim_result: protected_alert_attention_counters.get(TB_ERROR);
...

```

But this then results in an error  
`Unknown identifier "protected_alert_attention_counters"`

Question 2: If that is solved  
Can I then do

```auto
if (sim_result /= 0) then
 $fatal()
end if

```

Rgds,  
Eric

---

<div class="post-metadata">

**Author:** ![EspenTa](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/espenta/32/52_2.png) [@EspenTa](https://forum.uvvm.org/u/EspenTa)\
**Post date:** [November 25, 2021, 6:55pm UTC](https://forum.uvvm.org/t/how-to-read-and-use-the-alert-counters/241/4 "2021-11-25T18:55:49Z")

</div>

Hi Eric,

Sorry, but that I just noticed that solution is actually not availabe externally.  
It seems this shared variable is private (i.e. only inside the body of the methods package).  
I’m afraid that only leaves the status variables as mentioned in my initial answer.  
I would recommend that you manage with that - if possible?

Otherwise - you **could** also modify the methods package and move  
‘shared variable protected\_alert\_attention\_counters : t\_protected\_alert\_attention\_counters;’ from the body to the header of the package, thus making it available outside this package.

So far users have managed with the 4 status variables, but please let me know if that is not sufficient. Then at least we need to re-evaluate the visibility of the counters.

– Espen

---

<div class="post-metadata">

**Author:** ![Eric](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@Eric](https://forum.uvvm.org/u/Eric)\
**Post date:** [December 2, 2021, 7:33am UTC](https://forum.uvvm.org/t/how-to-read-and-use-the-alert-counters/241/5 "2021-12-02T07:33:19Z")

</div>

Just to let you know that reading the shared variables solves this issue. I now have

```auto
if (shared_uvvm_status.found_unexpected_similation_warnings_or_worse /= 0) or
  ( ... the other 3 that are mentioned in the reference from Espen... ) then
  simulation_result <= "FAILED";
else
  simulation_result <= "PASSED";
end if;

```

---

<div class="post-metadata">

**Author:** ![EspenTa](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.uvvm.org/espenta/32/52_2.png) [@EspenTa](https://forum.uvvm.org/u/EspenTa)\
**Post date:** [December 2, 2021, 2:53pm UTC](https://forum.uvvm.org/t/how-to-read-and-use-the-alert-counters/241/6 "2021-12-02T14:53:59Z")

</div>

Good to hear 🙂  
– Espen
