How can I view variables defined in a package during simulation

Hi there!

I don’t think this is a tool specific question, but rather probably a misunderstanding around how packages work. I am not able to see variables defined in a package during simulation. Here is a simple test case.

I created this package:

package test_pkg;

    logic [7:0] test_pkg_vect = 0;

    function set_vect(input logic [7:0] val);
        test_pkg_vect = val;
    endfunction

endpackage

Then I imported the package in my test bench, and added a tiny bit of test code.

import test_pkg::*;
logic [7:0] sim_test_pkg_vect;
always_comb begin
  sim_test_pkg_vect = test_pkg::test_pkg_vect;
end

initial begin
   #500ns;
   test_pkg::set_vect(8'h55);
   #500ns;
   test_pkg::set_vect(8'hAA);
end

During simulation, I am able to see sim_test_pkg_vect that was defined in the test bench, but I am not able to see test_pkg_vect that was defined in the package, which was imported into the test bench. In the initial block, I am able to set test_pkg::test_pkg_vect and see the results show up in sim_test_pkg_vect.

My confusion is this: if I imported the test_pkg into my test bench, why can I not see the variables defined in that package during simulation?

Thanks much!
Aaron

In reply to aale:

I think you may be mixing up the `include construct with the import construct. Importing a package just makes the identifiers in the package visible without using the package scope prefix. It doesn’t change the scope of where those identifiers exist. In your debugger, you’ll have to look in the test_PKG package to find the test_pkg_vec variable. Most tools should have a quick way to jump from the reference to its declaration.

In your example code, once you import the test_pkg, there’s no need to use the test_pkg:: prefix in the code that follows. Or you could remove the import test_pkg::* statement and just use the explicit references.

Although not exactly the same issue, I have an article explaining some of the differences between import and `include.