SystemC sc_event - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

202


 
1
#include "test.h"
2
3
int sc_main(int argc, char* argv[])
4
{
5
  Test test_inst("test_inst");
6
  sc_start();
7
  return 0;
8
}
9
40
 
1
#ifndef TEST_H
2
#define TEST_H
3
4
#include "systemc"
5
using namespace sc_core;
6
using std::cout;
7
using std::endl;
8
9
SC_MODULE(Test)
10
{
11
  int data;
12
  
13
  sc_event e;
14
15
  SC_CTOR(Test)
16
  {
17
    SC_THREAD(producer);
18
    SC_THREAD(consumer);
19
  }
20
  
21
  void producer()
22
  {
23
    wait(1, SC_NS);
24
    for (data = 0; data < 10; data++) {
25
      e.notify();
26
      wait(1, SC_NS);
27
    }
28
  }
29
  
30
  void consumer()
31
  {
32
    for (;;) {
33
      wait(e);
34
      cout << "Received " << data << endl;
35
    }
36
  }
37
};
38
39
#endif
40
64 views and 0 likes     
 
Uses an immediate event notification to synchronize two thread processes

Uses an immediate event notification to synchronize two thread processes

1100:0