I am new to TLM. Someone can give me an example code for connecting two processes by a TLM fifo?
Thank you
I searched in doulos, but I only saw examples of sockets. Someone helped me and I leave here a code example of a tlm fifo
#include "systemc"
#include "tlm.h"
// PRODUCER 1
SC_MODULE(producer)
{
sc_core::sc_port< tlm::tlm_fifo_put_if<int> > out; //FIFO OUT
SC_CTOR(producer)
: out("out")
{
SC_THREAD(run); //função
}
void run()
{
int i = 42;
std::cout << name() << ": " << i << std::endl;
out->put(i);
}
}; // producer
// CONSUMER
SC_MODULE(consumer)
{
sc_core::sc_port< tlm::tlm_fifo_get_if<int> > in;
SC_CTOR(consumer)
: in("in")
{
SC_THREAD(run); //função
}
void run()
{
int i = in->get();
std::cout << name() << ": " << i << std::endl;
}
}; // consumer
// MAIN
int sc_main(int, char*[] )
{
tlm::tlm_fifo<int> fifo("fifo");
producer prod("producer");
prod.out(fifo);
consumer cons("consumer");
cons.in(fifo);
sc_core::sc_start();
char myLine[100];
cin.getline(myLine, 100);
return 0;
}
Thank you