4

Oftentimes our UVM simulations fail with signatures that we end up debugging to unconnected analysis ports.

Is there a way to check up front whether the analysis ports are connected before the run_phase?

Victor Lyuboslavsky
  • 9,882
  • 25
  • 87
  • 134

3 Answers3

7

It is not a UVM requirement that analysis ports are connected. However, some UVM components will not function correctly when their analysis ports are unconnected.

For those cases, I recommend checking the analysis import connections during the end_of_elaboration_phase:

`CHECK_PORT_CONNECTION(my_analysis_imp)

Where the above macro is defined like:

`define CHECK_PORT_CONNECTION(PORT) \
  begin \
    uvm_port_list list; \
    PORT.get_provided_to(list); \
    if (!list.size()) begin \
      `uvm_fatal("AP_CONNECT", \
        $sformatf("Analysis port %s not connected.", PORT.get_full_name())); \
    end \
  end

Complete working example with one connected port and one not connected: http://www.edaplayground.com/x/2YG

Victor Lyuboslavsky
  • 9,882
  • 25
  • 87
  • 134
1

Thanks Victor for the example. I didn't know the logic that you gave. There is a minor issue in the example that Victor gave, w.r.t the uvm_analysis_imp declaration. Multiple analysis implementations should use uvm_analysis_imp_decl macro. Please see the below link for the corrected example. http://www.edaplayground.com/x/3qx

NB: Posting as answer since I cant comment :(

Vineeth VS
  • 404
  • 8
  • 18
  • 1
    Yes, you're correct that `uvm_analysis_impl_decl` should be used :) I had them in originally, but then removed them in an effort to make the example simpler. I'll add them back in. – Victor Lyuboslavsky Jan 31 '14 at 16:08
1

I believe that this should be unnecessary because this checking is already in uvm_port_base::resolve_bindings. However, I believe that there is a bug there. The bug is that for an imp size() doesn't report the number of ports that are bound to the imp. So if 3 ports are bound to the imp then size reports 1 even though the list of ports is correctly of size 3.