Importing a package question

When a package is imported in a module. does it also import the packages nested within it too? What I mean is assume I have the following example:


// Code your testbench here
// or browse Examples
package p;
reg p1;
endpackage

package q;
import p::*;
reg q1;
endpackage

module test;
import p::*;
import q::*;
task q_load;
 reg temp;
    begin
      fork:FJA
        reg temp;
        #200    q1  <= p1;
        #100 $display ("Statement 1 of package FJA ", $time);
        #200    q1  <= 0;
        #150 $display ("Statement 2 of package FJA ", $time);
      join_any
      $display("Out of fork join of pkg::task", $time);
    end
       endtask // q_load
   
  initial begin
    q1 = 0;
     p1 = 1;
     
    fork
      q_load;
      #50 $display ("Inside fork join of module ", $time);
    join_any
//    $display("Value of q::q_load.temp=%d", q::q_load.temp);
     disable q_load.FJA;
 
     
    $display ("Outside fork join of module", $time);
    #400 $finish;
  end
endmodule

In reply to haithamx15:

Package imports to not nest/chain by default. There is an export package construct can give you that behavior, but because of the way wildcard importing works, an identifier needs appear in the package before it can be exported.

package p;
reg p1;
endpackage
 
package q;
import p::*;
export p::p1;
reg q1;
endpackage

See 26.6 Exporting imported names from packages in the 1800-2017 LRM

@dave_59 What about for enum typedefs?

Example:

package b;
   typedef enum byte{
      B_VALUE = "B";
   } enum_ex_t;
endpackage

package a;
   import b;
   export b::enum_ex_t;
endpackage

class example; // Both packages included
   a::enum_ex_t enum_ex; // This works
   function bit get_true();
      if (enum_ex == a::B_VALUE) // ERROR: Could not find member 'B_VALUE' in package 'a'
         return 1;
      else
         return 0;
   endfunction
endclass

Then names/labels of an enumerated type are not nested inside the enum type, they need to be imported/exported independently. That is also the reason why you can’t have two enum types with the same names defined within the same scope.