Jump to content
mohitnegi

help me with this error

Recommended Posts

hi,

this is a simple example  for fifo in which i did some experiments the codes are as follows:

 

main file:

#include "systemc.h"
#include "initiator.h"
#include "target.h"

using namespace std;

int sc_main(int argc, char* argv[])
{
	cout << "\n" <<endl;
	Initiator iInit("Initiator");
	Target iTarg("Target");
	
	iInit.mPort.bind(iTarg.mExport);
	sc_start();
	return 0;
}

intiator file:

#ifndef INITIATOR_H
#define INITIATOR_H

#include "systemc.h"
#define SC_INCLUDE_DYNAMIC_PROCESSES

#include "systemc"
using namespace sc_core;
using namespace sc_dt;
using namespace std;

#include "tlm.h"
#include "tlm_utils/simple_initiator_socket.h"
#include "tlm_utils/simple_target_socket.h"

class Initiator: public sc_module
{
	public:
	sc_port<sc_fifo <unsigned int> > mPort;

	SC_HAS_PROCESS(Initiator);

	Initiator(sc_module_name name);

	void write_data_in_fifo();
};

Initiator::Initiator(sc_module_name name)
	:mPort("port")
{
	SC_THREAD(write_data_in_fifo);
}

void
Initiator::write_data_in_fifo()
{
	unsigned int data = rand();
	cout << " Data Written in FiFo = " << data <<endl;
	mPort->write(data);
}

#endif 

target file

#include "systemc.h"

using namespace std;

class Target:public sc_module
{
	public:
    sc_fifo<unsigned int> mDataFIFO;

    sc_export<sc_fifo<unsigned int> > mExport;

	Target(sc_module_name name);

	SC_HAS_PROCESS(Target);

	void read_data_4m_fifo();
};

Target::Target(sc_module_name name)
		:mExport("export")
{
	mExport.bind(mDataFIFO);
	SC_THREAD(read_data_4m_fifo);
}

void Target::read_data_4m_fifo()
{
	cout << " Data Read From FiFo = " << mDataFIFO.read()<<endl;
}

the files are compiling well

but there seems to be some error while execution which i am not

able to figure out 

the error is as follows:

/FiFo_Read$ ./hello 

             SystemC 2.3.0-ASI --- Nov  1 2013 05:05:54
        Copyright (c) 1996-2012 by all Contributors,
        ALL RIGHTS RESERVED




Error: (E107) bind interface to port failed: sc_fifo<T> port not recognized
In file: /home/mohit/Downloads/systemc-2.3.0/include/sysc/communication/sc_fifo.h:211

Share this post


Link to post
Share on other sites

Hi. 

 

You should use 

sc_fifo_out< unsigned int > mPort;

instead of 

sc_port<sc_fifo <unsigned int> > mPort;

to declare the fifo out port of module Initiator. 

 

Another remark: 

it is dangerous to define SC_INCLUDE_DYNAMIC_PROCESSES in your code. 

The C++ include mechanism in combination with include guards may hide the definition when the order of include statements changes. Thus, you have to make sure, that the definition is always before any include statement that relies on it. 

The best way to ensure this is to pass it as a command line argument to the compiler, i.e.

-DSC_INCLUDE_DYNAMIC_PROCESSES

for gcc/g++. 

 

Greetings

Ralph

Share this post


Link to post
Share on other sites

Mohit,
 
as Ralph correctly pointed out, you should use the correct interfaces in your ports (preferably by using the specialized ports for sc_fifo) and exports:

sc_fifo_out< unsigned int > mPort; // Initiator
// or: sc_port< sc_fifo_out_if<unsigned int> > mPort;

sc_export< sc_fifo_out_if<unsigned int> >  mExport; // Target

 Another addition regarding Ralph's second remark:

The C++ include mechanism in combination with include guards may hide the definition when the order of include statements changes. Thus, you have to make sure, that the definition is always before any include statement that relies on it.

 
In general it is indeed good practice to define global preprocessor definitions on the command-line (e.g. from your Makefile) to avoid the problems described by Ralph.  For SC_INCLUDE_DYNAMIC_PROCESSES this has indeed been a problem in SystemC 2.2.0.

 

Fortunately, SystemC 2.3.0 is more forgiving and will still include the required dynamic process support at a later inclusion, even if it has been included without an explicit request for it beforehand.

 

Greetings from Oldenburg,

  Philipp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×