Jump to content
Yash Jain

get interface failed: port is not bound:

Recommended Posts

I am getting the following error. I can't figure out why I am getting error:

Quote

get interface failed: port is not bound: port 'server.outgoin1' (sc_out)

Server.cpp

#include "systemc.h"

SC_MODULE(server){
	sc_in<bool> begin1, begin2, begin3, end1, end2, end3, incoming1, incoming2, incoming3;
	sc_out<bool> free, outgoing1, outgoing2, outgoing3;

	void monitor(){
		free = true;
		outgoing1 = false;
		outgoing2 = false;
		outgoing3 = false;

		while(true){
			wait(incoming1 | incoming2 | incoming3);

			//Mobile 1
			if(incoming1 == true){
				cout << "Mobile 1 received." << endl;
				while(!free); // Wait for the server to free up

				//Now that the server has freed up, proceed
				outgoing1 = true;
				free = false;
				wait(begin1);
				cout << "Begin1 @" << sc_simulation_time() << endl;
				wait(end1);
				cout << "End1 @" << sc_simulation_time() << endl;
				free = true;
			}

			//Mobile 2
			if(incoming2 == true){
				cout << "Mobile 2 received." << endl;
				while(!free);// Wait for the server to free up

				//Now that the server has freed up, proceed
				outgoing2 = true;
				free = false;
				wait(begin2);
				cout << "Begin2 @" << sc_simulation_time() << endl;
				wait(end2);
				cout << "End2 @" << sc_simulation_time() << endl;
				free = true;
			}

			//Mobile 3
			if(incoming3 == true){
				cout << "Mobile 3 received." << endl;
				while(!free);// Wait for the server to free up

				//Now that the server has freed up, proceed
				outgoing3 = true;
				free = false;
				wait(begin3);
				cout << "Begin3 @" << sc_simulation_time() << endl;
				wait(end3);
				cout << "End3 @" << sc_simulation_time() << endl;
				free = true;
			}
		}
	}

	SC_CTOR(server):free("free"), outgoing1("outgoin1"), outgoing2("outgoing2"),outgoing3("outgoing3"){
		outgoing1 = false;
		outgoing2 = false;
		outgoing3 = false;
		SC_THREAD(monitor);
		sensitive << incoming1.pos() << incoming2.pos() << incoming3.pos();
	}
};

And this is my testbench

tb_server.cpp

#include "systemc.h"
#include "server.cpp"

int sc_main(int argc, char* argv[]){
  //Inputs
  sc_signal<bool> begin1;
  sc_signal<bool> begin2;
  sc_signal<bool> begin3;
  sc_signal<bool> end1;
  sc_signal<bool> end2;
  sc_signal<bool> end3;
  sc_signal<bool> incoming1;
  sc_signal<bool> incoming2;
  sc_signal<bool> incoming3;
  sc_signal<bool> outgoing1;
  sc_signal<bool> outgoing2;
  sc_signal<bool> outgoing3;
  sc_signal<bool> free;


  server srvr("server");
  srvr.begin1(begin1);
  srvr.begin2(begin2);
  srvr.begin3(begin3);
  srvr.end1(end1);
  srvr.end2(end2);
  srvr.end3(end3);
  srvr.incoming1(incoming1);
  srvr.incoming2(incoming2);
  srvr.incoming3(incoming3);
  srvr.outgoing1(outgoing1);
  srvr.outgoing2(outgoing2);
  srvr.outgoing3(outgoing3);
  srvr.free(free);

  incoming1 = 1;
  incoming2 = 1;
  incoming3 = 1;

  for(int i = 0; i < 30; i++){
    sc_start(10, SC_MS);
  }

}

 

Share this post


Link to post
Share on other sites

You are writing to ports in the constructor of server. At this point they are not bound. Since you initialize them in the beginning of your thread this is not needed anyways.

Aside of that you also do not need the sensitivity list for the monitor thread as you never use the default sensitivity (by using wait() ). And if you use C++11 or newer you should use In-class member initializers which eases the naming of signals (and you should name them to make debugging easier):

sc_in<bool> begin1{"begin1"}, begin2{"begin2"}, begin3{"begin3"};
sc_in<bool> end1{"end1"}, end2{"end2"}, end3{"end3"};
sc_in<bool> incoming1{"incoming1"}, incoming2{"incoming2"}, incoming3{"incoming3"};
sc_out<bool> free{"free"}, outgoing1{"outgoing1"}, outgoing2{"outgoing2"}, outgoing3{"outgoing3"};

 

Share this post


Link to post
Share on other sites

Hey Eyck. Nothing was fixed. I removed the ports in the constructor and I' still getting the error:

SC_CTOR(server){
		SC_THREAD(monitor);
}

In fact I tried simplifying it further and still get the error: 

void monitor(){
		free = true;
		outgoing1 = false;
		outgoing2 = false;
		outgoing3 = false;
}

 

Share this post


Link to post
Share on other sites

Update. I removed the testbench and added a new testbench for a different module. I deleted the old one and re-added the tb_server.cpp testbench and now I'm not getting the error. Not sure if this a problem in systemC or my compiler. 

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...