0

I am new to TLM. Someone can give me an example code for connecting two processes by a TLM fifo?

Thank you

4

2 回答 2

3

我在 doulos 中进行了搜索,但只看到了套接字的示例。有人帮助了我,我在这里留下了一个 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;
}

谢谢

于 2012-10-04T10:04:26.847 回答
1

doulos 网站上有一些很好的例子。

于 2012-10-02T17:16:09.010 回答