cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_state_table.cpp File Reference
#include "state_table.hpp"
Include dependency graph for test_state_table.cpp:

Go to the source code of this file.

Classes

struct  readVerify
 

Functions

void emptyFifos (std::ofstream &out, stream< sessionState > &rxFifoOut, stream< sessionState > &appFifoOut, stream< sessionState > &app2FifoOut, stream< ap_uint< 16 > > &slupOut, int iter)
 
int main ()
 

Function Documentation

◆ emptyFifos()

void emptyFifos ( std::ofstream &  out,
stream< sessionState > &  rxFifoOut,
stream< sessionState > &  appFifoOut,
stream< sessionState > &  app2FifoOut,
stream< ap_uint< 16 > > &  slupOut,
int  iter 
)

Definition at line 38 of file test_state_table.cpp.

39 {
40  sessionState outData;
41  ap_uint<16> outDataId;
42  while (!(rxFifoOut.empty()))
43  {
44  rxFifoOut.read(outData);
45  out << "Step " << iter << ": RX Fifo\t\t";
46  out << outData << std::endl;
47  }
48 
49  while (!(appFifoOut.empty()))
50  {
51  appFifoOut.read(outData);
52  out << "Step " << iter << ": App Fifo\t\t";
53  out << outData << std::endl;
54  }
55 
56  while (!(app2FifoOut.empty()))
57  {
58  app2FifoOut.read(outData);
59  out << "Step " << iter << ": App2 Fifo\t\t";
60  out << outData << std::endl;
61  }
62 
63  while (!(slupOut.empty()))
64  {
65  slupOut.read(outDataId);
66  out << "Step " << iter << ": Slup Fifo\t\t";
67  out << std::hex;
68  out << std::setfill('0');
69  out << std::setw(4) << outDataId;
70  out << std::endl;
71  }
72 }
out
Definition: test.py:12
Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 74 of file test_state_table.cpp.

75 {
76  stream<stateQuery> rxIn;
77  stream<sessionState> rxOut;
78  stream<stateQuery> txAppIn;
79  stream<sessionState> txAppOut;
80  stream<stateQuery> txApp2In;
81  stream<sessionState> txApp2Out;
82  stream<ap_uint<16> > timerIn;
83  stream<ap_uint<16> > slupOut;
84 
85  stateQuery inData;
86  sessionState outData;
87 
88  std::ifstream inputFile;
89  std::ofstream outputFile;
90 
91  /*inputFile.open("/home/dasidler/toe/hls/toe/state_table/in.dat");
92  if (!inputFile)
93  {
94  std::cout << "Error: could not open test input file." << std::endl;
95  return -1;
96  }*/
97  outputFile.open("/home/dasidler/toe/hls/toe/state_table/out.dat");
98  if (!outputFile)
99  {
100  std::cout << "Error: could not open test output file." << std::endl;
101  }
102 
103  int count = 0;
104 
105  /*
106  * Test 1: rx(x, ESTA); timer(x), rx(x, FIN_WAIT)
107  */
108  //ap_uint<16> id = rand() % 100;
109  ap_uint<16> id = 0x57;
110  outputFile << "Test 1" << std::endl;
111  outputFile << "ID: " << id << std::endl;
112  while (count < 20)
113  {
114  switch (count)
115  {
116  case 1:
117  rxIn.write(stateQuery(id, ESTABLISHED, 1));
118  break;
119  case 2:
120  timerIn.write(id);
121  break;
122  case 3:
123  rxIn.write(stateQuery(id, FIN_WAIT_1, 1));
124  break;
125  default:
126  break;
127 
128  }
129  state_table(rxIn, txAppIn, txApp2In, timerIn, rxOut, txAppOut, txApp2Out, slupOut);
130  emptyFifos(outputFile, rxOut, txAppOut, txApp2Out, slupOut, count);
131  count++;
132  }
133  outputFile << "------------------------------------------------" << std::endl;
134 
135  //BREAK
136  count = 0;
137  while (count < 200)
138  {
139  state_table(rxIn, txAppIn, txApp2In, timerIn, rxOut, txAppOut, txApp2Out, slupOut);
140  count++;
141  }
142 
143  /*
144  * Test 2: rx(x, ESTA); rx(y, ESTA); timer(x), time(y)
145  */
146  //ap_uint<16> id = rand() % 100;
147  count = 0;
148  id = 0x6f;
149  ap_uint<16> id2 = 0x3a;
150  outputFile << "Test 2" << std::endl;
151  outputFile << "ID: " << id << " ID2: " << id2 << std::endl;
152  while (count < 20)
153  {
154  switch (count)
155  {
156  case 1:
157  rxIn.write(stateQuery(id, ESTABLISHED, 1));
158  break;
159  case 2:
160  rxIn.write(stateQuery(id2, ESTABLISHED, 1));
161  break;
162  case 3:
163  timerIn.write(id2);
164  break;
165  case 4:
166  timerIn.write(id);
167  break;
168  case 5:
169  timerIn.write(id);
170  break;
171  default:
172  break;
173 
174  }
175  state_table(rxIn, txAppIn, txApp2In, timerIn, rxOut, txAppOut, txApp2Out, slupOut);
176  emptyFifos(outputFile, rxOut, txAppOut, txApp2Out, slupOut, count);
177  count++;
178  }
179  outputFile << "------------------------------------------------" << std::endl;
180  //BREAK
181  count = 0;
182  while (count < 200)
183  {
184  state_table(rxIn, txAppIn, txApp2In, timerIn, rxOut, txAppOut, txApp2Out, slupOut);
185  count++;
186  }
187 
188  /*
189  * Test 3: rx(x); timer(x), rx(x, ESTABLISHED)
190  * Pause then: rx(y), txApp(y), rx(y, ESTABLISHED), txApp(y, value)
191  */
192  //ap_uint<16> id = rand() % 100;
193  count = 0;
194  id = 0x6f;
195  id2 = 0x3a;
196  outputFile << "Test 3" << std::endl;
197  outputFile << "ID: " << id << " ID2: " << id2 << std::endl;
198  while (count < 40)
199  {
200  switch (count)
201  {
202  case 1:
203  rxIn.write(stateQuery(id));
204  break;
205  case 2:
206  timerIn.write(id);
207  break;
208  case 5:
209  rxIn.write(stateQuery(id, ESTABLISHED, 1));
210  break;
211  case 10:
212  rxIn.write(stateQuery(id2));
213  break;
214  case 11:
215  txAppIn.write(stateQuery(id2));
216  break;
217  case 14:
218  rxIn.write(stateQuery(id2, CLOSING, 1));
219  break;
220  case 15:
221  txAppIn.write(stateQuery(id2, SYN_SENT, 1));
222  break;
223  case 19:
224  txApp2In.write(id2);
225  break;
226  default:
227  break;
228 
229  }
230  state_table(rxIn, txAppIn, txApp2In, timerIn, rxOut, txAppOut, txApp2Out, slupOut);
231  emptyFifos(outputFile, rxOut, txAppOut, txApp2Out, slupOut, count);
232  count++;
233  }
234  outputFile << "------------------------------------------------" << std::endl;
235  //BREAK
236  count = 0;
237  while (count < 200)
238  {
239  state_table(rxIn, txAppIn, txApp2In, timerIn, rxOut, txAppOut, txApp2Out, slupOut);
240  count++;
241  }
242 
243 
244  /*
245  * Test 4: txApp(x); rx(x), txApp(x, SYN_SENT), rx(x, ESTABLISHED), txApp2(x)
246  */
247  //ap_uint<16> id = rand() % 100;
248  count = 0;
249  id = 0x7f3;
250  outputFile << "Test 4" << std::endl;
251  outputFile << "ID: " << id << std::endl;
252  while (count < 40)
253  {
254  switch (count)
255  {
256  case 1:
257  txAppIn.write(stateQuery(id));
258  break;
259  case 2:
260  rxIn.write(stateQuery(id));
261  break;
262  case 5:
263  txAppIn.write(stateQuery(id, SYN_SENT, 1));
264  break;
265  case 7:
266  rxIn.write(stateQuery(id, ESTABLISHED, 1));
267  break;
268  case 19:
269  txApp2In.write(id);
270  break;
271  default:
272  break;
273 
274  }
275  state_table(rxIn, txAppIn, txApp2In, timerIn, rxOut, txAppOut, txApp2Out, slupOut);
276  emptyFifos(outputFile, rxOut, txAppOut, txApp2Out, slupOut, count);
277  count++;
278  }
279  outputFile << "------------------------------------------------" << std::endl;
280 
281  return 0;
282 }
void state_table(stream< StateQuery > &siRXe_SessStateQry, stream< TcpState > &soRXe_SessStateRep, stream< StateQuery > &siTAi_ConnectStateQry, stream< TcpState > &soTAi_ConnectStateRep, stream< SessionId > &siTAi_StreamStateReq, stream< TcpState > &soTAi_StreamStateRep, stream< SessionId > &siTIm_SessCloseCmd, stream< SessionId > &soSLc_SessReleaseCmd)
State Table (STt)
Definition: state_table.cpp:99
@ FIN_WAIT_1
Definition: nts_types.hpp:297
@ SYN_SENT
Definition: nts_types.hpp:296
@ ESTABLISHED
Definition: nts_types.hpp:296
@ CLOSING
Definition: nts_types.hpp:297
void emptyFifos(std::ofstream &out, stream< sessionState > &rxFifoOut, stream< sessionState > &appFifoOut, stream< sessionState > &app2FifoOut, stream< ap_uint< 16 > > &slupOut, int iter)
Here is the call graph for this function: