How should I do when two package be dependent on each other?

if two class be dependent on each other

class a
class b

this could be solved using
typedef class a;

still the two class
package pa;
`include “a.sv”
endpackage

package pb;
`include “b.sv”
endpackage

and pa.sv and pb.sv in different path.

how to solve this problem?

Thanks

In reply to designer007:

You cannot have circular dependencies between two different classes in two different packages. The classes need to be in the same package, or you need to figure out a way to break the circular dependencies. See the https://xyproblem.info.

In reply to dave_59:

I am working on a layered UVC project.
create three UVC : base_layer_uvc , high_layer_uvc, low_layer_uvc; each uvc have a pkg
low_layer_monitor extends base_layer_monitor;
and then a testcase is included in base_layer_uvc pkg which use high_layer_item;
so there is a circular dependencies between base_layer_pkg and high_layer_pkg.
"not include testcase in base_layer_pkg " is the only way to solve this problem?

In reply to designer007:

I don’t see any reason why the testcase needs to be imported into any UVC.

In reply to dave_59:

@designer007: I’m not sure if I understand your problem correctly. Might this be a solution?

package pa;
  typedef class a;
endpackage
package pb;
  import pa::*;
  export pa::a;
<more entries>
endpackage

class test extends base_test;
  import pb::*;
  a aobj;
.....
endclass

In reply to chr_sue:

Christoph, this will not work. A forward typedef must be completed in the same scope.

In reply to dave_59:

Dave you are right. But putting the class a definition into package pa like this

package pa;
  class a extends uvm_sequence_item;
   .....
  endclass
endpackage
package pb;
  import pa::*;
  export pa::a;
<more entries>
endpackage
 
class test extends base_test;
  import pb::*;
  a aobj;
.....
endclass

In reply to chr_sue:

package base;
include "base_monitor.sv" include “testcase0.sv” //have a member : h_item hobj;
endpackage

package high;
import base::*;
include "high_monitor.sv" //extends base_monitor include “h_item.sv”
endpackage

high_monitor depends on base_monitor;

testcase0 depends on h_item;

so how to deal with this scene

In reply to designer007:

//top.sv

import base::;
import high::
;

`include “testcase0.sv” //if testcase0 not include in base pck, I think this way works

module top()

endmodue

before this way, I try to add testcase0 in the filelist.f
add always get errors.
//filelist.f
./base.sv
./high.sv
./testcase0.sv
./top.sv

In reply to designer007:

If you have the situation you need any type, class or whatever (methods) in different components put this contenet in a seperate package and compile it first.
The you can import this content in any other place (component, object) where you need this content.