cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
event_engine.cpp
Go to the documentation of this file.
1 
17 
43 
57 #include "event_engine.hpp"
58 
59 using namespace hls;
60 
61 
65 #ifndef __SYNTHESIS__
66  extern bool gTraceEvent;
67 #endif
68 
69 #define THIS_NAME "TOE/EVe"
70 
71 #define TRACE_OFF 0x0000
72 #define TRACE_EVE 1 << 1
73 #define TRACE_ALL 0xFFFF
74 
75 #define DEBUG_LEVEL (TRACE_OFF)
76 
77 
78 
91  stream<Event> &siTAi_Event,
92  stream<ExtendedEvent> &siRXe_Event,
93  stream<Event> &siTIm_Event,
94  stream<ExtendedEvent> &soAKd_Event,
95  stream<SigBit> &siAKd_RxEventSig,
96  stream<SigBit> &siAKd_TxEventSig,
97  stream<SigBit> &siTXe_RxEventSig)
98 {
99  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
100  #pragma HLS PIPELINE II=1 enable_flush
101 
102  const char *myName = THIS_NAME;
103 
104  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
105  //---- Warning: the following counters depend on the FiFo depth between EVe and AKd
106  static ap_uint<8> eve_eve2akd_WrCnt; // #events forwarded by [EVe] to [AKd]
107  #pragma HLS RESET variable = eve_eve2akd_WrCnt
108  static ap_uint<8> eve_eve2akd_RdCnt; // #events received by [AKd] from [EVe].
109  #pragma HLS RESET variable = eve_eve2akd_RdCnt
110  static ap_uint<8> eve_akd2txe_WrCnt; // #events forwarded by [AKd] to [TXe]
111  #pragma HLS RESET variable = eve_akd2txe_WrCnt
112  static ap_uint<8> eve_akd2txe_RdCnt; // #events received by [TXe] from [Akd]
113  #pragma HLS RESET variable = eve_akd2txe_RdCnt
114 
115  //-- DYNAMIC VARIABLES -----------------------------------------------------
116  ExtendedEvent ev;
117 
118  //------------------------------------------
119  // Handle input from [RxEngine]
120  //------------------------------------------
121  if (!siRXe_Event.empty() and !soAKd_Event.full()) {
122  siRXe_Event.read(ev);
123  soAKd_Event.write(ev);
124  if (DEBUG_LEVEL & TRACE_EVE) {
125  printInfo(myName, "S%d - Received '%s' from [RXe] (WrCnt=%3d|RdCnt=%3d).\n",
126  ev.sessionID.to_int(), getEventName(ev.type), eve_eve2akd_WrCnt.to_uint(), eve_eve2akd_RdCnt.to_uint());
127  }
128  eve_eve2akd_WrCnt++;
129  }
130  else if (eve_eve2akd_WrCnt == eve_eve2akd_RdCnt and
131  eve_akd2txe_WrCnt == eve_akd2txe_RdCnt) {
132  //------------------------------------------
133  // Handle input from [Timers]
134  // RetransmitTimer and ProbeTimer events have priority
135  //------------------------------------------
136  if (!siTIm_Event.empty()) {
137  siTIm_Event.read(ev);
138  soAKd_Event.write(ev);
139  if (DEBUG_LEVEL & TRACE_EVE) {
140  printInfo(myName, "S%d - Received '%s' from [TIm] (WrCnt=%3d|RdCnt=%3d).\n",
141  ev.sessionID.to_int(), getEventName(ev.type), eve_eve2akd_WrCnt.to_uint(), eve_eve2akd_RdCnt.to_uint());
142  }
143  eve_eve2akd_WrCnt++;
144  }
145  //--------------------------------------------
146  // Handle input from [TcpApplicationInterface]
147  //--------------------------------------------
148  else if (!siTAi_Event.empty()) {
149  siTAi_Event.read(ev);
150  assessSize(myName, soAKd_Event, "soAKd_Event", cDepth_EVeToAKd_Event);
151  soAKd_Event.write(ev);
152  if (DEBUG_LEVEL & TRACE_EVE) {
153  printInfo(myName, "S%d - Received '%s' from [TAi] (WrCnt=%3d|RdCnt=%3d).\n",
154  ev.sessionID.to_int(), getEventName(ev.type), eve_eve2akd_WrCnt.to_uint(), eve_eve2akd_RdCnt.to_uint());
155  }
156  eve_eve2akd_WrCnt++;
157  }
158  }
159 
160  //------------------------------------------
161  // Handle inputs from [AckDelayer]
162  //------------------------------------------
163  if (!siAKd_RxEventSig.empty()) {
164  // Remote [AKd] just received an event from [EVe]
165  siAKd_RxEventSig.read();
166  eve_eve2akd_RdCnt++;
167  }
168 
169  if (!siAKd_TxEventSig.empty()) {
170  // Remote [AKd] just forwarded an event to [TXe]
171  siAKd_TxEventSig.read();
172  eve_akd2txe_WrCnt++;
173  }
174 
175  //------------------------------------------
176  // Handle input from [TxEngine]
177  //------------------------------------------
178  if (!siTXe_RxEventSig.empty()) {
179  siTXe_RxEventSig.read();
180  eve_akd2txe_RdCnt++;
181  }
182 }
183 
SessionId sessionID
Definition: toe.hpp:664
EventType type
Definition: toe.hpp:663
: Event Engine (EVe) of the TCP Offload Engine (TOE)
#define TRACE_EVE
const char * getEventName(EventType evType)
Returns the name of an enum-based event as a user friendly string.
Definition: toe_utils.cpp:43
void event_engine(stream< Event > &siTAi_Event, stream< ExtendedEvent > &siRXe_Event, stream< Event > &siTIm_Event, stream< ExtendedEvent > &soAKd_Event, stream< SigBit > &siAKd_RxEventSig, stream< SigBit > &siAKd_TxEventSig, stream< SigBit > &siTXe_RxEventSig)
The Event Engine (EVe) arbitrates the incoming events and forwards them to the Tx Engine (TXe) via th...
bool gTraceEvent
Definition: tb_nal.cpp:151
const int cDepth_EVeToAKd_Event
Definition: toe.hpp:209
#define THIS_NAME
#define DEBUG_LEVEL
#define assessSize(callerName, stream, streamName, depth)
A macro that checks if a stream is full.
Definition: nts_utils.hpp:223
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169