Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the hierarchical scope from where a function was called

When calling a function, is it possible for that function to get the hierarchical scope of the location where it was called?

Let me give you an example. I have the following code:

package some_pkg;

function void some_function();
  $display("%m");
endfunction

endpackage


module top;
  import some_pkg::*;

  initial
    some_function();

endmodule

When running it, it will display "some_pkg::some_function". Is there any way that I can get the function to display "top"? Or if I would have some other sub-module where it is called from, could it display "top.submodule"?

like image 343
Tudor Timi Avatar asked Dec 07 '25 23:12

Tudor Timi


1 Answers

This is going to be tool specific and requires extra debugger information to dynamically track scopes. Modelsim/Questa has $stacktrace that will display the scope and filename/linenumber

like image 98
dave_59 Avatar answered Dec 09 '25 16:12

dave_59



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!