Jump to content
TRANG

bind multi ports to other port.

Recommended Posts

Hi all,

I have 2 models, model A and model B

Model A has an output port out_A (bool)

Model B has an input port in_B (bool)

when integrate, I will instance 3 objects of Model A, 1 object of Model B

//file @connection.cpp
...
void initializeENV(){
...
objA_1 = new ModelA("objA_1");
objA_2 = new ModelA("objA_2");
objA_3 = new ModelA("objA_3");

objB = new ModelB("objB");
...
}

the value of in_B = objA_1->out_A or objA_2->out_A or objA_3->out_A

I think that, if I bind as below . It is wrong. Because of when objA_1->out_A is change then affect to obj_2->out_A and objA_3->out_A. Is my understand correct?

//file @connection.cpp
...
sc_signal<bool> sig_1;
sc_signal<bool> sig_2;
sc_signal<bool> sig_3;
void initializeENV(){
...
objA_1 = new ModelA("objA_1");
objA_2 = new ModelA("objA_2");
objA_3 = new ModelA("objA_3");
  
objB = new ModelB("objB");

  objA_1->out_A(sig_1);
  objA_2->out_A(sig_2);
  objA_3->out_A(sig_3);
  objB->in_B(sig_1);
  objB->in_B(sig_2);
  objB->in_B(sig_3);
  
...
}

How to resolve it? How to bind 3 out_A ports to in_B port? .I can't use SC_METHOD in this case.

Thank all.

 

Share this post


Link to post
Share on other sites

sc_core::sc_in<T> only allows binding of a single sc_core::sc_signal<T> (cf. to IEEE Std 1666-2011, clause 6.8). However, you may use for in_B a sc_core::sc_port<sc_core::sc_signal_in_if<T>, 3, SC_ONE_OR_MORE_BOUND> (cf. to IEEE Std 1666-2011, clause 5.12) that will accept binding of exactly three signals. The implementation of the OR relation of the three signals can be then handled inside an SC_METHOD of objB. To access the three different signal from in_B, you can use the operator[] implemented by the sc_port. By the way, you may also specify a different number of channels to be bound and also a different port binding policy.

Share this post


Link to post
Share on other sites

Another option would be to use a resolved signal and connect all output ports to it.

But this is already about techincal implementation options. The question to me is: what would you like to model? Is this the right way to model the intend?

Best regards

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...