Bind usage in System verilog

Hi,
I have following code in a separate bind file -


bind A: A1_inst A_bind 
#(  .P     (P1)   
  )
A1_bind_inst (.*);

bind A: A2_inst A_bind 
#(  .P    (P2)   
  )
A2_bind_inst (.*);

bind A: A3_inst A_bind 
#(  .P     (P3)   
  )
A3_bind_inst (.*);


.

Now, A_bind file has code -


bind B B_bind
 # (  .P    (P)   
   )
   B_bind_inst (.*);


.

I am getting error - B_bind_inst already declared in the scope.
I am getting this error two times.
Pls help

In reply to ashish_banga:
You need to give some more context for the bind inside the A_bind file. If it is inside the A_bind module, then each instance of A_bind will try to add the same bind to module B. You probably want to do an instance specific bind to B.

In reply to dave_59:
Right. But how to do that?

In reply to ashish_banga:

You need to show more context. Why is the bind statement inside the A_bind module? Can it be moved outside? Where is A instantiated in relation B? If you could show a small example that demonstrates what you are trying to accomplished, then we could show you how.

In reply to dave_59:

Ok, let me try,

There is a module C.
module C has multiple instances of module A, named A1_inst,A2_inst,A3_inst.
module A has instance of module B .

There is a bind file for module A , A_bind.
and a corresponding bind file for module B - B_bind .

So, I want different instances of B_bind for each instance of A_bind,as shown in my question

In reply to ashish_banga:
You’re still being lazy in your description of the problem. This is what I mean by showing the complete context of of the situation as I see it.

module A;
   parameter P1=1,P2=2,P3=3;
   B #(.P(P1)) B_inst();
endmodule 
module B #(int P);
   initial $display("%m %d",P);
endmodule

module A_bind #(int P);
   bind B:B_inst B_bind #(.P(P)) B_bind_inst ();
   
endmodule
module B_bind #(P);
endmodule // A_bind

bind A: top.A1_inst A_bind 
#(  .P     (P1)   
  )
A1_bind_inst ();
 
bind A: top.A2_inst A_bind 
#(  .P    (P2)   
  )
A2_bind_inst ();
 
bind A: top.A3_inst A_bind 
#(  .P     (P3)   
  )
A3_bind_inst ();

module top;
   A A1_inst();
   A A2_inst();
   A A3_inst();
endmodule 

With just a little more code, now we both have something to compile and experiment with.