cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
TOECAM_TEST

Testbench for the Content-Addressable Memory (CAM) for the TCP Offload Engine (TOE) of the Network Transport Stack (NTS). More...

Collaboration diagram for TOECAM_TEST:

Macros

#define THIS_NAME   "TB"
 
#define TRACE_OFF   0x0000
 
#define TRACE_TOE   1 << 1
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 
#define TB_MAX_SIM_CYCLES   250
 
#define TB_STARTUP_DELAY   0
 
#define TB_GRACE_TIME   500
 
#define CAM_LOOKUP_LATENCY   2
 
#define CAM_UPDATE_LATENCY   10
 
#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC813
 
#define DEFAULT_FPGA_TCP_PORT   0x2263
 
#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832
 
#define DEFAULT_HOST_TCP_PORT   0xa263
 
#define DEFAULT_SESSION_ID   42
 
#define CAM_SIZE   2
 

Functions

void stepSim ()
 Increment the simulation counter. More...
 
void pTOE (int &nrErr, stream< CamSessionLookupRequest > &soCAM_SssLkpReq, stream< CamSessionLookupReply > &siCAM_SssLkpRep, stream< CamSessionUpdateRequest > &soCAM_SssUpdReq, stream< CamSessionUpdateReply > &siCAM_SssUpdRep)
 Emulate the behavior of the TCP Offload Engine (TOE). More...
 
int main (int argc, char *argv[])
 Main function. More...
 

Variables

const Ip4Addr RESERVED_SENDER_PROTOCOL_ADDRESS = 0xCAFEFADE
 
bool gTraceEvent
 
bool gFatalError
 
unsigned int gSimCycCnt
 
unsigned int gMaxSimCycles
 

Detailed Description

Testbench for the Content-Addressable Memory (CAM) for the TCP Offload Engine (TOE) of the Network Transport Stack (NTS).

Macro Definition Documentation

◆ CAM_LOOKUP_LATENCY

#define CAM_LOOKUP_LATENCY   2

Definition at line 55 of file test_toecam.hpp.

◆ CAM_SIZE

#define CAM_SIZE   2

Definition at line 83 of file test_toecam.hpp.

◆ CAM_UPDATE_LATENCY

#define CAM_UPDATE_LATENCY   10

Definition at line 56 of file test_toecam.hpp.

◆ DEBUG_LEVEL

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 45 of file test_toecam.cpp.

◆ DEFAULT_FPGA_IP4_ADDR

#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC813

Definition at line 76 of file test_toecam.hpp.

◆ DEFAULT_FPGA_TCP_PORT

#define DEFAULT_FPGA_TCP_PORT   0x2263

Definition at line 77 of file test_toecam.hpp.

◆ DEFAULT_HOST_IP4_ADDR

#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832

Definition at line 78 of file test_toecam.hpp.

◆ DEFAULT_HOST_TCP_PORT

#define DEFAULT_HOST_TCP_PORT   0xa263

Definition at line 79 of file test_toecam.hpp.

◆ DEFAULT_SESSION_ID

#define DEFAULT_SESSION_ID   42

Definition at line 81 of file test_toecam.hpp.

◆ TB_GRACE_TIME

#define TB_GRACE_TIME   500

Definition at line 53 of file test_toecam.hpp.

◆ TB_MAX_SIM_CYCLES

#define TB_MAX_SIM_CYCLES   250

Definition at line 51 of file test_toecam.hpp.

◆ TB_STARTUP_DELAY

#define TB_STARTUP_DELAY   0

Definition at line 52 of file test_toecam.hpp.

◆ THIS_NAME

#define THIS_NAME   "TB"

Definition at line 39 of file test_toecam.cpp.

◆ TRACE_ALL

#define TRACE_ALL   0xFFFF

Definition at line 43 of file test_toecam.cpp.

◆ TRACE_OFF

#define TRACE_OFF   0x0000

Definition at line 41 of file test_toecam.cpp.

◆ TRACE_TOE

#define TRACE_TOE   1 << 1

Definition at line 42 of file test_toecam.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function.

Definition at line 247 of file test_toecam.cpp.

247  {
248 
249  //------------------------------------------------------
250  //-- TESTBENCH GLOBAL VARIABLES
251  //------------------------------------------------------
252  gTraceEvent = false;
253  gFatalError = false;
254  gSimCycCnt = 0;
255 
256  //------------------------------------------------------
257  //-- DUT STREAM INTERFACES
258  //------------------------------------------------------
259  //-- MMIO Interfaces
260  ap_uint<1> sMMIO_CamReady("sMMIO_CamReady");
261  //-- CAM / This / Session Lookup & Update Interfaces
262  stream<CamSessionLookupRequest> ssTOE_CAM_SssLkpReq("ssTOE_CAM_SssLkpReq");
263  stream<CamSessionLookupReply> ssCAM_TOE_SssLkpRep("ssCAM_TOE_SssLkpRep");
264  stream<CamSessionUpdateRequest> ssTOE_CAM_SssUpdReq("ssTOE_CAM_SssUpdReq");
265  stream<CamSessionUpdateReply> ssCAM_TOE_SssUpdRep("ssCAM_TOE_SssUpdRep");
266 
267  //------------------------------------------------------
268  //-- TESTBENCH VARIABLES
269  //------------------------------------------------------
270  int nrErr = 0; // Total number of testbench errors
271  int tbRun = 0; // Total duration of the test (in clock cycles)
272 
273  printInfo(THIS_NAME, "############################################################################\n");
274  printInfo(THIS_NAME, "## TESTBENCH 'test_toecam' STARTS HERE ##\n");
275  printInfo(THIS_NAME, "############################################################################\n");
276  printInfo(THIS_NAME, "This testbench will be executed with the following parameters: \n");
277  for (int i=1; i<argc; i++) {
278  printInfo(THIS_NAME, "\t==> Param[%d] = %s\n", (i-1), argv[i]);
279  }
280  printf("\n\n");
281 
282  //-----------------------------------------------------
283  //-- MAIN LOOP
284  //-----------------------------------------------------
285  tbRun = (nrErr == 0) ? (TB_MAX_SIM_CYCLES + TB_GRACE_TIME) : 0;
286  while (tbRun) {
287  //-------------------------------------------------
288  //-- EMULATE TOE
289  //-------------------------------------------------
290  if (sMMIO_CamReady == 1) {
291  pTOE(
292  nrErr,
293  //-- TOE / Lookup Request Interfaces
294  ssTOE_CAM_SssLkpReq,
295  ssCAM_TOE_SssLkpRep,
296  //-- TOE / Update Request Interfaces
297  ssTOE_CAM_SssUpdReq,
298  ssCAM_TOE_SssUpdRep
299  );
300  }
301  //-------------------------------------------------
302  //-- RUN DUT
303  //-------------------------------------------------
304  toecam_top(
305  //-- MMIO Interfaces
306  &sMMIO_CamReady,
307  //-- Session Lookup & Update Interfaces
308  ssTOE_CAM_SssLkpReq,
309  ssCAM_TOE_SssLkpRep,
310  ssTOE_CAM_SssUpdReq,
311  ssCAM_TOE_SssUpdRep
312  );
313 
314  //------------------------------------------------------
315  //-- INCREMENT SIMULATION COUNTER
316  //------------------------------------------------------
317  stepSim();
318  tbRun--;
319  } // End of: while()
320 
321  printInfo(THIS_NAME, "############################################################################\n");
322  printInfo(THIS_NAME, "## TESTBENCH 'test_toecam' ENDS HERE ##\n");
323  printInfo(THIS_NAME, "############################################################################\n");
324  stepSim();
325 
326  if (nrErr) {
327  printError(THIS_NAME, "###########################################################\n");
328  printError(THIS_NAME, "#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
329  printError(THIS_NAME, "###########################################################\n");
330  printInfo(THIS_NAME, "FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
331  }
332  else {
333  printInfo(THIS_NAME, "#############################################################\n");
334  printInfo(THIS_NAME, "#### SUCCESSFUL END OF TEST ####\n");
335  printInfo(THIS_NAME, "#############################################################\n");
336  }
337 
338  return(nrErr);
339 
340 }
unsigned int gSimCycCnt
Definition: tb_nal.cpp:150
bool gTraceEvent
Definition: tb_nal.cpp:151
bool gFatalError
Definition: tb_nal.cpp:152
#define TB_GRACE_TIME
Definition: test_arp.hpp:54
#define TB_MAX_SIM_CYCLES
Definition: test_arp.hpp:52
void stepSim()
Increment the simulation counter.
Definition: test_toecam.cpp:50
void pTOE(int &nrErr, stream< CamSessionLookupRequest > &soCAM_SssLkpReq, stream< CamSessionLookupReply > &siCAM_SssLkpRep, stream< CamSessionUpdateRequest > &soCAM_SssUpdReq, stream< CamSessionUpdateReply > &siCAM_SssUpdRep)
Emulate the behavior of the TCP Offload Engine (TOE).
Definition: test_toecam.cpp:73
#define THIS_NAME
Definition: test_toecam.cpp:39
void toecam_top(ap_uint< 1 > *poMMIO_CamReady, stream< CamSessionLookupRequest > &siTOE_SssLkpReq, stream< CamSessionLookupReply > &soTOE_SssLkpRep, stream< CamSessionUpdateRequest > &siTOE_SssUpdReq, stream< CamSessionUpdateReply > &soTOE_SssUpdRep)
Top of Content-Addressable Memory (TOECAM).
Definition: toecam.cpp:414
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
Here is the call graph for this function:

◆ pTOE()

void pTOE ( int &  nrErr,
stream< CamSessionLookupRequest > &  soCAM_SssLkpReq,
stream< CamSessionLookupReply > &  siCAM_SssLkpRep,
stream< CamSessionUpdateRequest > &  soCAM_SssUpdReq,
stream< CamSessionUpdateReply > &  siCAM_SssUpdRep 
)

Emulate the behavior of the TCP Offload Engine (TOE).

Parameters
[in]nrErrA ref to the error counter of main. //– TOE / Lookup Request Interfaces
[out]soCAM_SssLkpReqSession lookup request to CAM,
[in]siCAM_SssLkpRepSession lookup reply from CAM. //– TOE / Update Request Interfaces
[out]soCAM_SssUpdReqSession update request to CAM.
[in]siCAM_SssUpdRepSession update reply from CAM.

Definition at line 73 of file test_toecam.cpp.

80 {
81  const char *myName = concat3(THIS_NAME, "/", "TOE");
82 
83  static enum slcStates { LOOKUP_REQ, LOOKUP_REP,
84  INSERT_REQ, INSERT_REP, \
85  DELETE_REQ, DELETE_REP, \
86  TB_ERROR, TB_DONE } slcState = LOOKUP_REQ;
87 
88  //------------------------------------------------------
89  //-- EMULATE THE SESSION LOOKUP CONTROLLER
90  //------------------------------------------------------
91  static int rdCnt;
92 
93  switch (slcState) {
94  case LOOKUP_REQ: // SEND A LOOKUP REQUEST TO [CAM]
95  for (int i=0; i<CAM_SIZE; i++) {
96  if (!soCAM_SssLkpReq.full()) {
97  // Build a new request
100  LkpSrcBit src = FROM_RXe;
101  CamSessionLookupRequest lkpRequest(key, src);
102  // Send the new request
103  soCAM_SssLkpReq.write(lkpRequest);
104  printInfo(myName, "Sending LOOKUP request[%d] to [CAM].\n", i);
105  }
106  else {
107  printWarn(myName, "Cannot send LOOKUP request to [CAM] because stream is full.\n");
108  nrErr++;
109  slcState = TB_ERROR;
110  }
111  }
112  // Goto next step
113  slcState = LOOKUP_REP;
114  rdCnt = 0;
115  break;
116  case LOOKUP_REP: // WAIT FOR LOOKUP REPLY FROM [CAM]
117  while (rdCnt < CAM_SIZE) {
118  if (!siCAM_SssLkpRep.empty()) {
119  CamSessionLookupReply lkpReply;
120  siCAM_SssLkpRep.read(lkpReply);
121  if (DEBUG_LEVEL & TRACE_TOE) {
122  printInfo(myName, "Received a lookup reply from [CAM]. \n");
123  printInfo(myName, "Src=%d, SessId=%d, Hit=%d\n", lkpReply.source.to_int(),
124  lkpReply.sessionID.to_int(), lkpReply.hit);
125  }
126  rdCnt++;
127  }
128  else
129  return;
130  }
131  // Goto next step
132  slcState = INSERT_REQ;
133  rdCnt = 0;
134  break;
135  case INSERT_REQ: // SEND AN INSERT REQUEST TO [CAM]
136  for (int i=0; i<CAM_SIZE; i++) {
137  if (!soCAM_SssUpdReq.full()) {
138  // Build a new request
141  LkpSrcBit src = FROM_RXe;
142  RtlSessId value = DEFAULT_SESSION_ID+i;
143  CamSessionUpdateRequest updRequest(key, value, INSERT, src);
144  // Send the new request
145  soCAM_SssUpdReq.write(updRequest);
146  printInfo(myName, "Sending UPDATE request[%d] to [CAM].\n", i);
147  }
148  else {
149  printWarn(myName, "Cannot send INSERT request to [CAM] because stream is full.\n");
150  nrErr++;
151  slcState = TB_ERROR;
152  }
153  }
154  // Goto next step
155  slcState = INSERT_REP;
156  rdCnt = 0;
157  break;
158  case INSERT_REP: // WAIT FOR INSERT REPLY FROM [CAM]
159  while (rdCnt<CAM_SIZE) {
160  if (!siCAM_SssUpdRep.empty()) {
161  CamSessionUpdateReply updReply;
162  siCAM_SssUpdRep.read(updReply);
163  if (DEBUG_LEVEL & TRACE_TOE) {
164  printInfo(myName, "Received an insert reply from [CAM]. \n");
165  printInfo(myName, "Src=%d, Op=%d, SessId=%d.\n",
166  updReply.source.to_int(), updReply.op,
167  updReply.sessionID.to_int());
168  }
169  if (updReply.sessionID != DEFAULT_SESSION_ID+rdCnt) {
170  printError(myName, "Got a wrong session ID (%d) as reply from [CAM].\n",
171  updReply.source.to_int());
172  nrErr++;
173  slcState = TB_ERROR;
174  }
175  rdCnt++;
176  }
177  else
178  return;
179  }
180  // Goto next step
181  slcState = DELETE_REQ;
182  rdCnt = 0;
183  break;
184  case DELETE_REQ: // SEND A DELETE REQUEST TO [CAM]
185  for (int i=0; i<CAM_SIZE; i++) {
186  if (!soCAM_SssUpdReq.full()) {
187  // Build a new request
190  LkpSrcBit src = FROM_RXe;
191  RtlSessId value = DEFAULT_SESSION_ID+i;
192  CamSessionUpdateRequest updRequest(key, value, DELETE, src);
193  // Send the new request
194  soCAM_SssUpdReq.write(updRequest);
195  printInfo(myName, "Sending DELETE request[%d] to [CAM].\n", i);
196  }
197  else {
198  printWarn(myName, "Cannot send DELETE request to [CAM] because stream is full.\n");
199  nrErr++;
200  slcState = TB_ERROR;
201  }
202  }
203  // Goto next step
204  slcState = DELETE_REP;
205  rdCnt = 0;
206  break;
207  case DELETE_REP: // WAIT FOR DELETE REPLY FROM [CAM]
208  while (rdCnt<CAM_SIZE) {
209  if (!siCAM_SssUpdRep.empty()) {
210  CamSessionUpdateReply updReply;
211  siCAM_SssUpdRep.read(updReply);
212  if (DEBUG_LEVEL & TRACE_TOE) {
213  printInfo(myName, "Received a delete reply from [CAM]. \n");
214  printInfo(myName, "Src=%d, Op=%d, SessId=%d.\n",
215  updReply.source.to_int(), updReply.op,
216  updReply.sessionID.to_int());
217  }
218  if (updReply.sessionID != DEFAULT_SESSION_ID+rdCnt) {
219  printError(myName, "Got a wrong session ID (%d) as reply from [CAM].\n",
220  updReply.source.to_int());
221  nrErr++;
222  slcState = TB_ERROR;
223  }
224  rdCnt++;
225  }
226  else
227  return;
228  }
229  // Goto next step
230  slcState = TB_DONE;
231  break;
232  case TB_ERROR:
233  slcState = TB_ERROR;
234  break;
235  case TB_DONE:
236  slcState = TB_DONE;
237  break;
238  } // End-of: switch (lsnState) {
239 
240 }
#define DEFAULT_SESSION_ID
Definition: tb_nal.cpp:75
#define DEFAULT_HOST_IP4_ADDR
Definition: tb_nal.cpp:72
#define DEFAULT_FPGA_IP4_ADDR
Definition: tb_nal.cpp:70
#define CAM_SIZE
Definition: test_toecam.hpp:83
#define DEFAULT_HOST_TCP_PORT
Definition: test_toecam.hpp:79
#define DEFAULT_FPGA_TCP_PORT
Definition: test_toecam.hpp:77
#define DEBUG_LEVEL
Definition: test_toecam.cpp:45
#define TRACE_TOE
Definition: test_toecam.cpp:42
ap_uint< 1 > LkpSrcBit
Definition: nts_types.hpp:379
#define FROM_RXe
Definition: nts_types.hpp:380
#define printWarn(callerName, format,...)
A macro to print a warning message.
Definition: nts_utils.hpp:182
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
ap_uint< 14 > RtlSessId
Definition: nts_types.hpp:378
@ DELETE
Definition: nts_types.hpp:382
@ INSERT
Definition: nts_types.hpp:382
Here is the caller graph for this function:

◆ stepSim()

void stepSim ( )

Increment the simulation counter.

Definition at line 50 of file test_toecam.cpp.

50  {
51  gSimCycCnt++;
52  if (gTraceEvent || ((gSimCycCnt % 1000) == 0)) {
53  printInfo(THIS_NAME, "-- [@%4.4d] -----------------------------\n", gSimCycCnt);
54  gTraceEvent = false;
55  }
56  else if (0) {
57  printInfo(THIS_NAME, "------------------- [@%d] ------------\n", gSimCycCnt);
58  }
59 }
Here is the caller graph for this function:

Variable Documentation

◆ gFatalError

bool gFatalError

Definition at line 66 of file test_toecam.hpp.

◆ gMaxSimCycles

unsigned int gMaxSimCycles

Definition at line 68 of file test_toecam.hpp.

◆ gSimCycCnt

unsigned int gSimCycCnt

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 67 of file test_toecam.hpp.

◆ gTraceEvent

bool gTraceEvent

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 65 of file test_toecam.hpp.

◆ RESERVED_SENDER_PROTOCOL_ADDRESS

const Ip4Addr RESERVED_SENDER_PROTOCOL_ADDRESS = 0xCAFEFADE

Definition at line 58 of file test_toecam.hpp.