15 using namespace sc_core;
16 using namespace sc_dt;
18 class scIGPwrite_if :
virtual public sc_interface
21 virtual void write(int32_t) = 0;
22 virtual void reset() = 0;
25 class scIGPread_if :
virtual public sc_interface
28 virtual void read(int32_t &) = 0;
29 virtual int num_available() = 0;
40 class scIGPfifo :
public sc_channel,
public scIGPwrite_if,
public scIGPread_if
43 scIGPfifo(sc_module_name name) : sc_channel(name), num_elements(0), first(0) {}
45 void write(int32_t c) {
46 if (num_elements == max)
47 wait(scIGPread_event);
49 data[(first + num_elements) % max] = c;
51 scIGPwrite_event.notify();
54 void read(int32_t &c){
55 if (num_elements == 0)
56 wait(scIGPwrite_event);
60 first = (first + 1) % max;
61 scIGPread_event.notify();
64 void reset() { num_elements = first = 0; }
66 int num_available() {
return num_elements;}
71 uint16_t num_elements, first;
72 sc_event scIGPwrite_event, scIGPread_event;