Jump to content
Sign in to follow this  
veeresh k

basic fifo example error

Recommended Posts

Hi.

I am tring to execute a example from a book,but am getting error of this kind :

In file included from testbench.cpp:6:0:
head1.h: In member function 'void www::woperation()':
head1.h:16:9: error: 'class sc_core::sc_port<sc_core::sc_fifo_out_if<int> >' has no member named 'write'
In file included from testbench.cpp:7:0:
head2.h: In member function 'void rrr::roperation()':
head2.h:17:9: error: 'class sc_core::sc_port<sc_core::sc_fifo_in_if<int> >' has no member named 'read'

 

below is the code:

 

#include<systemc.h>
#include"Head1.h"
#include"Head2.h"

int sc_main(int argc, char* argv[])
{

    sc_fifo<int> fifo(10);

    writer w("writer");
    reader r("reader");
    w.out(fifo);
    r.in(fifo);

    sc_start(-1);

    return 0;

}

//header1
#include<systemc.h>
SC_MODULE(reader) {

    sc_port<sc_fifo_in_if<int> > in;

    void roperation()
    {

        int val;

        while (true)
        {
            wait(10, SC_NS)
                for (int i = 0; i <= 15; i++)
                {

                    in.read(val);

                    cout << val << endl;

                }
        }

        cout << "Availaible : " << in.num availaible() << endl;

    }

   SC_CTOR(writer)
    {
        SC_THREAD(woperation);

    }

};

 


//header2
#include<systemc.h>

SC_MODULE(writer)
{
    sc_port<sc_fifo_out_if<int> > out;

    void woperation()
    {

        int val = 0;
        while (true)
        {
            wait(10, SC_NS);
            for (int i = 0; i <= 20; i++)
            {
                out.write(val++);

            }
        }

    }

    SC_CTOR(writer)
    {
        SC_THREAD(woperation);

    }
};

 

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
Sign in to follow this  

×